Colissimo fix routing.xml, thelia.sql and adding "Activate free shipping" option

new file:   local/modules/Colissimo/AdminIncludes/module-config-js.html
	modified:   local/modules/Colissimo/AdminIncludes/module_configuration.html
	modified:   local/modules/Colissimo/Colissimo.php
	modified:   local/modules/Colissimo/Config/config.xml
	modified:   local/modules/Colissimo/Config/routing.xml
	new file:   local/modules/Colissimo/Config/schema.xml
	modified:   local/modules/Colissimo/Config/thelia.sql
	new file:   local/modules/Colissimo/Controller/FreeShipping.php
	new file:   local/modules/Colissimo/Form/FreeShipping.php
	modified:   local/modules/Colissimo/I18n/en_US.php
	modified:   local/modules/Colissimo/I18n/fr_FR.php
	new file:   local/modules/Colissimo/Model/Base/ColissimoFreeshipping.php
	new file:   local/modules/Colissimo/Model/Base/ColissimoFreeshippingQuery.php
	new file:   local/modules/Colissimo/Model/ColissimoFreeshipping.php
	new file:   local/modules/Colissimo/Model/ColissimoFreeshippingQuery.php
	new file:   local/modules/Colissimo/Model/Map/ColissimoFreeshippingTableMap.php
This commit is contained in:
Benjamin Perche
2014-02-19 11:49:04 +01:00
parent d00bc84cd5
commit ce9a1bb519
16 changed files with 2642 additions and 115 deletions

View File

@@ -0,0 +1,40 @@
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(document).ready(function() {
$(".freeshipping-activation").on("switch-change", function(e, data){
var is_checked = data.value;
var form = $("#freeshippingform");
$('body').append('<div class="modal-backdrop fade in" id="loading-event"><div class="loading"></div></div>');
$.ajax({
url: form.attr('action'),
type: form.attr('method'),
data: form.serialize()
}).done(function(){
$("#loading-event").remove();
})
.success(function() {
if (is_checked) {
$('#config-btn-0').removeClass('disabled');
$('#table-prices-colissimo').hide('slow');
} else {
$('#config-btn-0').addClass('disabled');
$('#table-prices-colissimo').show('slow');
}
})
.fail(function(jqXHR, textStatus, errorThrown){
$("#loading-event").remove();
$('#freeshipping-failed-body').html(jqXHR.responseJSON.error);
$("#freeshipping-failed").modal("show");
});
});
});
</script>
{/block}

View File

@@ -8,109 +8,146 @@
</div>
{elseloop rel="checkrights.colissimo"}
<div class="modal fade" id="freeshipping-failed" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="An error occured"}</h3>
</div>
<div class="modal-body" id="freeshipping-failed-body">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="alert alert-info">
<p>{intl l="Colissimo Module allows to send your products all around the world with La Poste."}</p>
</div>
<div class="general-block-decorator">
<!-- checkbox free shipping -->
{assign var="isColissimoFreeShipping" value=0}
{form name="colissimo.freeshipping.form"}
<form action="{url path="/admin/module/colissimo/freeshipping"}" method="post" id="freeshippingform">
{form_hidden_fields form=$form}
{* -- Add price slice confirmation dialog ----------------------------------- *}
{loop type="area" name="list area" backend_context=true}
{include
file = "includes/generic-create-dialog.html"
{form_field form=$form field="freeshipping"}
<label>
{$label}
</label>
dialog_id = "price_slice_create_dialog_{$ID}"
dialog_title = {intl l="Create a price slice"}
dialog_body = "<input type=\"hidden\" name=\"operation\" value=\"add\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\" />
<label for=\"weight_{$ID}\">{intl l="Weight up to ... (kg)"}</label></label>
<input type=\"number\" id=\"weight_{$ID}\" name=\"weight\" value=\"1\" class=\"form-control\" pattern=\"\\d+\\.?\\d*\" required/>
<label for=\"price_{$ID}\">{intl l="Price (€)"}</label></label>
<input type=\"number\" id=\"price_{$ID}\" name=\"price\" value=\"1\" class=\"form-control\" pattern=\"\\d+\\.?\\d*\" required/>"
<div class="make-switch switch-small freeshipping-activation" data-id="0" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>">
<input type="checkbox" name="{$name}" value="true" {if $data}checked{assign var="isColissimoFreeShipping" value=1}{/if} />
</div>
{/form_field}
</form>
{/form}
<div id="table-prices-colissimo" {if $isColissimoFreeShipping eq 1} style="display:none;" {/if}>
<!-- Prices editing -->
{* -- Add price slice confirmation dialog ----------------------------------- *}
{loop type="area" name="list area" backend_context=true}
{include
file = "includes/generic-create-dialog.html"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_id = "price_slice_create_dialog_{$ID}"
dialog_title = {intl l="Create a price slice"}
dialog_body = "<input type=\"hidden\" name=\"operation\" value=\"add\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\" />
<label for=\"weight_{$ID}\">{intl l="Weight up to ... (kg)"}</label></label>
<input type=\"number\" id=\"weight_{$ID}\" name=\"weight\" value=\"1\" class=\"form-control\" pattern=\"\\d+\\.?\\d*\" required/>
<label for=\"price_{$ID}\">{intl l="Price (€)"}</label></label>
<input type=\"number\" id=\"price_{$ID}\" name=\"price\" value=\"1\" class=\"form-control\" pattern=\"\\d+\\.?\\d*\" required/>"
dialog_ok_label = {intl l="Create"}
dialog_cancel_label = {intl l="Cancel"}
}
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">
{intl l="Area : "}{$NAME}
{loop type="auth" name="can_create" role="ADMIN" module="colissimo" access="CREATE"}
<a class="btn btn-default btn-primary pull-right" title="{intl l='Create a new price slice'}" href="#price_slice_create_dialog_{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-plus"></span>
</a>
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl l="Create"}
dialog_cancel_label = {intl l="Cancel"}
}
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">
{intl l="Area : "}{$NAME}
{loop type="auth" name="can_create" role="ADMIN" module="colissimo" access="CREATE"}
<a class="btn btn-default btn-primary pull-right" title="{intl l='Create a new price slice'}" href="#price_slice_create_dialog_{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-plus"></span>
</a>
{/loop}
</caption>
<thead>
<tr>
<th class="col-md-3">{intl l="Weight up to ... (kg)"}</th>
<th class="col-md-5">{intl l="Price (€)"}</th>
<th class="col-md-1">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop type="colissimo" name="colissimo" area=$ID}
{* -- EDIT price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "price_slice_edit_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}"
dialog_title = {intl l="Edit a price slice"}
dialog_message = "<input type=\"hidden\" name=\"operation\" value=\"add\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\"/>
<input type=\"hidden\" name=\"weight\" value=\"{$MAX_WEIGHT}\"/>
<label for=\"price_edit_{$ID}_{$MAX_WEIGHT}\">{intl l='Price (€)'}</label>
<input type=\"number\" id=\"price_edit_{$ID}_{$MAX_WEIGHT}\" class=\"form-control\" name=\"price\" value=\"{$PRICE}\" pattern=\"\\d+\\.?\\d*\" required/>"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl l="Edit"}
dialog_cancel_label = {intl l="Cancel"}
}
{* -- Delete price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "price_slice_delete_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}"
dialog_title = {intl l="Delete a price slice"}
dialog_message = "<input type=\"hidden\" name=\"operation\" value=\"delete\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\"/>
<input type=\"hidden\" name=\"weight\" value=\"{$MAX_WEIGHT}\"/>
{intl l="Do you really want to delete this slice ?"}"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl l="Delete"}
dialog_cancel_label = {intl l="Cancel"}
}
<tr>
<td>{$MAX_WEIGHT}</td>
<td>{$PRICE}</td>
<td>
<div class="btn-group">
{loop type="auth" name="can_change" role="ADMIN" module="colissimo" access="UPDATE"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this price slice'}" href="#price_slice_edit_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl l='Delete this price slice'}" href="#price_slice_delete_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
</caption>
<thead>
<tr>
<th class="col-md-3">{intl l="Weight up to ... (kg)"}</th>
<th class="col-md-5">{intl l="Price (€)"}</th>
<th class="col-md-1">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop type="colissimo" name="colissimo" area=$ID}
{* -- EDIT price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-confirm-dialog.html"
</tbody>
</table>
</div>
{/loop}
dialog_id = "price_slice_edit_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}"
dialog_title = {intl l="Edit a price slice"}
dialog_message = "<input type=\"hidden\" name=\"operation\" value=\"add\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\"/>
<input type=\"hidden\" name=\"weight\" value=\"{$MAX_WEIGHT}\"/>
<label for=\"price_edit_{$ID}_{$MAX_WEIGHT}\">{intl l='Price (€)'}</label>
<input type=\"number\" id=\"price_edit_{$ID}_{$MAX_WEIGHT}\" class=\"form-control\" name=\"price\" value=\"{$PRICE}\" pattern=\"\\d+\\.?\\d*\" required/>"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl l="Edit"}
dialog_cancel_label = {intl l="Cancel"}
}
{* -- Delete price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "price_slice_delete_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}"
dialog_title = {intl l="Delete a price slice"}
dialog_message = "<input type=\"hidden\" name=\"operation\" value=\"delete\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\"/>
<input type=\"hidden\" name=\"weight\" value=\"{$MAX_WEIGHT}\"/>
{intl l="Do you really want to delete this slice ?"}"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl l="Delete"}
dialog_cancel_label = {intl l="Cancel"}
}
<tr>
<td>{$MAX_WEIGHT}</td>
<td>{$PRICE}</td>
<td>
<div class="btn-group">
{loop type="auth" name="can_change" role="ADMIN" module="colissimo" access="UPDATE"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this price slice'}" href="#price_slice_edit_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl l='Delete this price slice'}" href="#price_slice_delete_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
{/loop}
</div>
</div>
</div>
{/elseloop}
{/elseloop}

View File

@@ -23,6 +23,7 @@
namespace Colissimo;
use Colissimo\Model\ColissimoFreeshippingQuery;
use Propel\Runtime\Connection\ConnectionInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -59,34 +60,38 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
*/
public static function getPostageAmount($areaId, $weight)
{
$prices = self::getPrices();
$freeshipping = ColissimoFreeshippingQuery::create()->getLast();
$postage=0;
if(!$freeshipping) {
$prices = self::getPrices();
/* check if Colissimo delivers the asked area */
if(!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
throw new OrderException("Colissimo delivery unavailable for the chosen delivery country", OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
/* check if Colissimo delivers the asked area */
if(!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
throw new OrderException("Colissimo delivery unavailable for the chosen delivery country", OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
/* check this weight is not too much */
end($areaPrices);
$maxWeight = key($areaPrices);
if($weight > $maxWeight) {
throw new OrderException(sprintf("Colissimo delivery unavailable for this cart weight (%s kg)", $weight), OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$postage = current($areaPrices);
while(prev($areaPrices)) {
if($weight > key($areaPrices)) {
break;
/* check this weight is not too much */
end($areaPrices);
$maxWeight = key($areaPrices);
if($weight > $maxWeight) {
throw new OrderException(sprintf("Colissimo delivery unavailable for this cart weight (%s kg)", $weight), OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$postage = current($areaPrices);
}
while(prev($areaPrices)) {
if($weight > key($areaPrices)) {
break;
}
$postage = current($areaPrices);
}
}
return $postage;
}
public function setRequest(Request $request)

View File

@@ -10,9 +10,7 @@
</loops>
<forms>
<!--
<form name="MyFormName" class="MyModule\Form\MySuperForm" />
-->
<form name="colissimo.freeshipping.form" class="Colissimo\Form\FreeShipping" />
</forms>
<commands>

View File

@@ -3,8 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="icirelais.edit.prices" path="/admin/module/colissimo/prices" methods="post">
<route id="colissimo.edit.prices" path="/admin/module/colissimo/prices" methods="post">
<default key="_controller">Colissimo\Controller\EditPrices::editprices</default>
</route>
<route id="colissimo.edit.freeshipping" path="/admin/module/colissimo/freeshipping" methods="post">
<default key="_controller">Colissimo\Controller\FreeShipping::set</default>
</route>
</routes>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="Colissimo\Model">
<table name="colissimo_freeshipping">
<column name="id" primaryKey="true" autoIncrement="true" required="true" type="INTEGER" />
<column name="active" required="true" type="BOOLEAN" />
<behavior name="timestampable" />
</table>
<external-schema filename="/home/benjamin/dev/thelia2/local/config/schema.xml" referenceOnly="true" />
</database>

24
local/modules/Colissimo/Config/thelia.sql Executable file → Normal file
View File

@@ -1,9 +1,27 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- Mail templates for icirelais
-- colissimo_freeshipping
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `colissimo_freeshipping`;
CREATE TABLE `colissimo_freeshipping`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`active` TINYINT(1) NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
INSERT INTO `colissimo_freeshipping`(`active`, `created_at`, `updated_at`) VALUES (0, NOW(), NOW());
-- ---------------------------------------------------------------------
-- Mail templates for colissimo
-- ---------------------------------------------------------------------
-- First, delete existing entries
SET @var := 0;
@@ -27,4 +45,6 @@ INSERT INTO `message_i18n` (`id`, `locale`, `title`, `subject`, `text_message`,
(@max, 'fr_FR', 'mail livraison colissimo', 'Suivi colissimo commande : {$order_ref}', '{loop type="customer" name="customer.order" current="false" id="$customer_id" backend_context="1"}\r\n{$LASTNAME} {$FIRSTNAME},\r\n{/loop}\r\nNous vous remercions de votre commande sur notre site {config key="store_name"}\r\nUn colis concernant votre commande {$order_ref} du {format_date date=$order_date} a quitté nos entrepôts pour être pris en charge par La Poste le {format_date date=$update_date}.\r\nSon numéro de suivi est le suivant : {$package}\r\nIl vous permet de suivre votre colis en ligne sur le site de La Poste : www.coliposte.net\r\nIl vous sera, par ailleurs, très utile si vous étiez absent au moment de la livraison de votre colis : en fournissant ce numéro de Colissimo Suivi, vous pourrez retirer votre colis dans le bureau de Poste le plus proche.\r\nATTENTION ! Si vous ne trouvez pas l''avis de passage normalement déposé dans votre boîte aux lettres au bout de 48 Heures jours ouvrables, n''hésitez pas à aller le réclamer à votre bureau de Poste, muni de votre numéro de Colissimo Suivi.\r\nNous restons à votre disposition pour toute information complémentaire.\r\nCordialement', '{loop type="customer" name="customer.order" current="false" id="$customer_id" backend_context="1"}\r\n{$LASTNAME} {$FIRSTNAME},\r\n{/loop}\r\nNous vous remercions de votre commande sur notre site {config key="store_name"}\r\nUn colis concernant votre commande {$order_ref} du {format_date date=$order_date} a quitté nos entrepôts pour être pris en charge par La Poste le {format_date date=$update_date}.\r\nSon numéro de suivi est le suivant : {$package}\r\nIl vous permet de suivre votre colis en ligne sur le site de La Poste : www.coliposte.net\r\nIl vous sera, par ailleurs, très utile si vous étiez absent au moment de la livraison de votre colis : en fournissant ce numéro de Colissimo Suivi, vous pourrez retirer votre colis dans le bureau de Poste le plus proche.\r\nATTENTION ! Si vous ne trouvez pas l''avis de passage normalement déposé dans votre boîte aux lettres au bout de 48 Heures jours ouvrables, n''hésitez pas à aller le réclamer à votre bureau de Poste, muni de votre numéro de Colissimo Suivi.\r\nNous restons à votre disposition pour toute information complémentaire.\r\nCordialement');
SET FOREIGN_KEY_CHECKS = 1;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,48 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Colissimo\Controller;
use Colissimo\Model\ColissimoFreeshipping;
use Symfony\Component\HttpFoundation\JsonResponse;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\HttpFoundation\Response;
class FreeShipping extends BaseAdminController {
public function set() {
$form = new \Colissimo\Form\FreeShipping($this->getRequest());
$response=null;
try {
$vform = $this->validateForm($form);
$data = $vform->get('freeshipping')->getData();
$save = new ColissimoFreeshipping();
$save->setActive(!empty($data))->save();
$response = Response::create('');
} catch (\Exception $e) {
$response = JsonResponse::create(array("error"=>$e->getMessage()), 500);
}
return $response;
}
}

View File

@@ -0,0 +1,72 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Colissimo\Form;
use Colissimo\Model\ColissimoFreeshippingQuery;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
class FreeShipping extends BaseForm {
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new \Symfony\Component\Validator\Constraints\NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
$freeshipping = ColissimoFreeshippingQuery::create()->getLast();
$this->formBuilder
->add("freeshipping", "checkbox", array(
'data'=>$freeshipping,
'label'=>Translator::getInstance()->trans("Activate free shipping: ")
))
;
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "colissimofreeshipping";
}
}

View File

@@ -18,4 +18,5 @@
'Delete a price slice'=>'Delete a price slice',
'Do you really want to delete this slice '=>'Do you really want to delete this slice ',
'Delete'=>'Delete',
'Activate free shipping: '=>'Activate free shipping: ',
);

View File

@@ -18,4 +18,5 @@
'Delete a price slice' => 'Supprimer une tranche de prix',
'Do you really want to delete this slice ?'=>'Voulez-vous réellement supprimer cette tranche de prix ?',
'Delete'=>'Supprimer',
'Activate free shipping: '=>'Livraison offerte: ',
);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,535 @@
<?php
namespace Colissimo\Model\Base;
use \Exception;
use \PDO;
use Colissimo\Model\ColissimoFreeshipping as ChildColissimoFreeshipping;
use Colissimo\Model\ColissimoFreeshippingQuery as ChildColissimoFreeshippingQuery;
use Colissimo\Model\Map\ColissimoFreeshippingTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
/**
* Base class that represents a query for the 'colissimo_freeshipping' table.
*
*
*
* @method ChildColissimoFreeshippingQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildColissimoFreeshippingQuery orderByActive($order = Criteria::ASC) Order by the active column
* @method ChildColissimoFreeshippingQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildColissimoFreeshippingQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildColissimoFreeshippingQuery groupById() Group by the id column
* @method ChildColissimoFreeshippingQuery groupByActive() Group by the active column
* @method ChildColissimoFreeshippingQuery groupByCreatedAt() Group by the created_at column
* @method ChildColissimoFreeshippingQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildColissimoFreeshippingQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildColissimoFreeshippingQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildColissimoFreeshippingQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildColissimoFreeshipping findOne(ConnectionInterface $con = null) Return the first ChildColissimoFreeshipping matching the query
* @method ChildColissimoFreeshipping findOneOrCreate(ConnectionInterface $con = null) Return the first ChildColissimoFreeshipping matching the query, or a new ChildColissimoFreeshipping object populated from the query conditions when no match is found
*
* @method ChildColissimoFreeshipping findOneById(int $id) Return the first ChildColissimoFreeshipping filtered by the id column
* @method ChildColissimoFreeshipping findOneByActive(boolean $active) Return the first ChildColissimoFreeshipping filtered by the active column
* @method ChildColissimoFreeshipping findOneByCreatedAt(string $created_at) Return the first ChildColissimoFreeshipping filtered by the created_at column
* @method ChildColissimoFreeshipping findOneByUpdatedAt(string $updated_at) Return the first ChildColissimoFreeshipping filtered by the updated_at column
*
* @method array findById(int $id) Return ChildColissimoFreeshipping objects filtered by the id column
* @method array findByActive(boolean $active) Return ChildColissimoFreeshipping objects filtered by the active column
* @method array findByCreatedAt(string $created_at) Return ChildColissimoFreeshipping objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildColissimoFreeshipping objects filtered by the updated_at column
*
*/
abstract class ColissimoFreeshippingQuery extends ModelCriteria
{
/**
* Initializes internal state of \Colissimo\Model\Base\ColissimoFreeshippingQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Colissimo\\Model\\ColissimoFreeshipping', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildColissimoFreeshippingQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildColissimoFreeshippingQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Colissimo\Model\ColissimoFreeshippingQuery) {
return $criteria;
}
$query = new \Colissimo\Model\ColissimoFreeshippingQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildColissimoFreeshipping|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = ColissimoFreeshippingTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(ColissimoFreeshippingTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildColissimoFreeshipping A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, ACTIVE, CREATED_AT, UPDATED_AT FROM colissimo_freeshipping WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildColissimoFreeshipping();
$obj->hydrate($row);
ColissimoFreeshippingTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildColissimoFreeshipping|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(ColissimoFreeshippingTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(ColissimoFreeshippingTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(ColissimoFreeshippingTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(ColissimoFreeshippingTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ColissimoFreeshippingTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the active column
*
* Example usage:
* <code>
* $query->filterByActive(true); // WHERE active = true
* $query->filterByActive('yes'); // WHERE active = true
* </code>
*
* @param boolean|string $active The value to use as filter.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function filterByActive($active = null, $comparison = null)
{
if (is_string($active)) {
$active = in_array(strtolower($active), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(ColissimoFreeshippingTableMap::ACTIVE, $active, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(ColissimoFreeshippingTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(ColissimoFreeshippingTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ColissimoFreeshippingTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(ColissimoFreeshippingTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(ColissimoFreeshippingTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ColissimoFreeshippingTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Exclude object from result
*
* @param ChildColissimoFreeshipping $colissimoFreeshipping Object to remove from the list of results
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function prune($colissimoFreeshipping = null)
{
if ($colissimoFreeshipping) {
$this->addUsingAlias(ColissimoFreeshippingTableMap::ID, $colissimoFreeshipping->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the colissimo_freeshipping table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ColissimoFreeshippingTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
ColissimoFreeshippingTableMap::clearInstancePool();
ColissimoFreeshippingTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildColissimoFreeshipping or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildColissimoFreeshipping object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ColissimoFreeshippingTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(ColissimoFreeshippingTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
ColissimoFreeshippingTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
ColissimoFreeshippingTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(ColissimoFreeshippingTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(ColissimoFreeshippingTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(ColissimoFreeshippingTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(ColissimoFreeshippingTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(ColissimoFreeshippingTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildColissimoFreeshippingQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(ColissimoFreeshippingTableMap::CREATED_AT);
}
} // ColissimoFreeshippingQuery

View File

@@ -0,0 +1,10 @@
<?php
namespace Colissimo\Model;
use Colissimo\Model\Base\ColissimoFreeshipping as BaseColissimoFreeshipping;
class ColissimoFreeshipping extends BaseColissimoFreeshipping
{
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Colissimo\Model;
use Colissimo\Model\Base\ColissimoFreeshippingQuery as BaseColissimoFreeshippingQuery;
/**
* Skeleton subclass for performing query and update operations on the 'colissimo_freeshipping' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class ColissimoFreeshippingQuery extends BaseColissimoFreeshippingQuery
{
public function getLast() {
return $this->orderById('desc')->findOne()->getActive();
}
} // ColissimoFreeshippingQuery

View File

@@ -0,0 +1,439 @@
<?php
namespace Colissimo\Model\Map;
use Colissimo\Model\ColissimoFreeshipping;
use Colissimo\Model\ColissimoFreeshippingQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'colissimo_freeshipping' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class ColissimoFreeshippingTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'Colissimo.Model.Map.ColissimoFreeshippingTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'colissimo_freeshipping';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\Colissimo\\Model\\ColissimoFreeshipping';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'Colissimo.Model.ColissimoFreeshipping';
/**
* The total number of columns
*/
const NUM_COLUMNS = 4;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 4;
/**
* the column name for the ID field
*/
const ID = 'colissimo_freeshipping.ID';
/**
* the column name for the ACTIVE field
*/
const ACTIVE = 'colissimo_freeshipping.ACTIVE';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'colissimo_freeshipping.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'colissimo_freeshipping.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Active', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'active', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(ColissimoFreeshippingTableMap::ID, ColissimoFreeshippingTableMap::ACTIVE, ColissimoFreeshippingTableMap::CREATED_AT, ColissimoFreeshippingTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'ACTIVE', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'active', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Active' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'active' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
self::TYPE_COLNAME => array(ColissimoFreeshippingTableMap::ID => 0, ColissimoFreeshippingTableMap::ACTIVE => 1, ColissimoFreeshippingTableMap::CREATED_AT => 2, ColissimoFreeshippingTableMap::UPDATED_AT => 3, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ACTIVE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
self::TYPE_FIELDNAME => array('id' => 0, 'active' => 1, 'created_at' => 2, 'updated_at' => 3, ),
self::TYPE_NUM => array(0, 1, 2, 3, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('colissimo_freeshipping');
$this->setPhpName('ColissimoFreeshipping');
$this->setClassName('\\Colissimo\\Model\\ColissimoFreeshipping');
$this->setPackage('Colissimo.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('ACTIVE', 'Active', 'BOOLEAN', true, 1, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? ColissimoFreeshippingTableMap::CLASS_DEFAULT : ColissimoFreeshippingTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (ColissimoFreeshipping object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = ColissimoFreeshippingTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = ColissimoFreeshippingTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + ColissimoFreeshippingTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = ColissimoFreeshippingTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
ColissimoFreeshippingTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = ColissimoFreeshippingTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = ColissimoFreeshippingTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
ColissimoFreeshippingTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(ColissimoFreeshippingTableMap::ID);
$criteria->addSelectColumn(ColissimoFreeshippingTableMap::ACTIVE);
$criteria->addSelectColumn(ColissimoFreeshippingTableMap::CREATED_AT);
$criteria->addSelectColumn(ColissimoFreeshippingTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.ACTIVE');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(ColissimoFreeshippingTableMap::DATABASE_NAME)->getTable(ColissimoFreeshippingTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(ColissimoFreeshippingTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(ColissimoFreeshippingTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new ColissimoFreeshippingTableMap());
}
}
/**
* Performs a DELETE on the database, given a ColissimoFreeshipping or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ColissimoFreeshipping object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ColissimoFreeshippingTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \Colissimo\Model\ColissimoFreeshipping) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ColissimoFreeshippingTableMap::DATABASE_NAME);
$criteria->add(ColissimoFreeshippingTableMap::ID, (array) $values, Criteria::IN);
}
$query = ColissimoFreeshippingQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { ColissimoFreeshippingTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { ColissimoFreeshippingTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the colissimo_freeshipping table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return ColissimoFreeshippingQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a ColissimoFreeshipping or Criteria object.
*
* @param mixed $criteria Criteria or ColissimoFreeshipping object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ColissimoFreeshippingTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from ColissimoFreeshipping object
}
if ($criteria->containsKey(ColissimoFreeshippingTableMap::ID) && $criteria->keyContainsValue(ColissimoFreeshippingTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.ColissimoFreeshippingTableMap::ID.')');
}
// Set the correct dbName
$query = ColissimoFreeshippingQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // ColissimoFreeshippingTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
ColissimoFreeshippingTableMap::buildTableMap();