Merge branch 'master' into loops

This commit is contained in:
Etienne Roudeix
2013-09-12 17:21:13 +02:00
46 changed files with 1457 additions and 411 deletions

View File

@@ -25,57 +25,51 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Model\AttributeQuery;
use Thelia\Model\Attribute as AttributeModel;
use Thelia\Model\AttributeAvQuery;
use Thelia\Model\AttributeAv as AttributeAvModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeUpdateEvent;
use Thelia\Core\Event\AttributeCreateEvent;
use Thelia\Core\Event\AttributeDeleteEvent;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeAvCreateEvent;
use Thelia\Core\Event\AttributeAvDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\UpdatePositionEvent;
class Attribute extends BaseAction implements EventSubscriberInterface
class AttributeAv extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new attribute entry
*
* @param AttributeCreateEvent $event
* @param AttributeAvCreateEvent $event
*/
public function create(AttributeCreateEvent $event)
public function create(AttributeAvCreateEvent $event)
{
$attribute = new AttributeModel();
$attribute = new AttributeAvModel();
$attribute
->setDispatcher($this->getDispatcher())
->setAttributeId($event->getAttributeId())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->save()
;
$event->setAttribute($attribute);
// Add atribute to all product templates if required
if ($event->getAddToAllTemplates() != 0) {
// TODO: add to all product template
}
$event->setAttributeAv($attribute);
}
/**
* Change a product attribute
*
* @param AttributeUpdateEvent $event
* @param AttributeAvUpdateEvent $event
*/
public function update(AttributeUpdateEvent $event)
public function update(AttributeAvUpdateEvent $event)
{
$search = AttributeQuery::create();
$search = AttributeAvQuery::create();
if (null !== $attribute = AttributeQuery::create()->findPk($event->getAttributeId())) {
if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId())) {
$attribute
->setDispatcher($this->getDispatcher())
@@ -88,26 +82,26 @@ class Attribute extends BaseAction implements EventSubscriberInterface
->save();
$event->setAttribute($attribute);
$event->setAttributeAv($attribute);
}
}
/**
* Delete a product attribute entry
*
* @param AttributeDeleteEvent $event
* @param AttributeAvDeleteEvent $event
*/
public function delete(AttributeDeleteEvent $event)
public function delete(AttributeAvDeleteEvent $event)
{
if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) {
if (null !== ($attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId()))) {
$attribute
->setDispatcher($this->getDispatcher())
->delete()
;
$event->setAttribute($attribute);
$event->setAttributeAv($attribute);
}
}
@@ -118,7 +112,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface
*/
public function updatePosition(UpdatePositionEvent $event)
{
if (null !== $attribute = AttributeQuery::create()->findPk($event->getObjectId())) {
if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getObjectId())) {
$attribute->setDispatcher($this->getDispatcher());
@@ -140,10 +134,10 @@ class Attribute extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
TheliaEvents::ATTRIBUTE_CREATE => array("create", 128),
TheliaEvents::ATTRIBUTE_UPDATE => array("update", 128),
TheliaEvents::ATTRIBUTE_DELETE => array("delete", 128),
TheliaEvents::ATTRIBUTE_UPDATE_POSITION => array("updatePosition", 128),
TheliaEvents::ATTRIBUTE_AV_CREATE => array("create", 128),
TheliaEvents::ATTRIBUTE_AV_UPDATE => array("update", 128),
TheliaEvents::ATTRIBUTE_AV_DELETE => array("delete", 128),
TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128),
);
}
}

View File

@@ -26,6 +26,7 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Customer as CustomerModel;
use Thelia\Core\Event\CustomerLoginEvent;
@@ -59,6 +60,13 @@ class Customer extends BaseAction implements EventSubscriberInterface
}
public function delete(CustomerEvent $event)
{
$customer = $event->getCustomer();
$customer->delete();
}
private function createOrUpdateCustomer(CustomerModel $customer, CustomerCreateOrUpdateEvent $event)
{
$customer->setDispatcher($this->getDispatcher());
@@ -80,7 +88,8 @@ class Customer extends BaseAction implements EventSubscriberInterface
$event->getLang(),
$event->getReseller(),
$event->getSponsor(),
$event->getDiscount()
$event->getDiscount(),
$event->getCompany()
);
$event->setCustomer($customer);
@@ -143,6 +152,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
TheliaEvents::CUSTOMER_UPDATEACCOUNT => array("modify", 128),
TheliaEvents::CUSTOMER_LOGOUT => array("logout", 128),
TheliaEvents::CUSTOMER_LOGIN => array("login" , 128),
TheliaEvents::CUSTOMER_DELETEACCOUNT => array("delete", 128),
);
}
}

View File

@@ -32,29 +32,38 @@ use Thelia\Model\ConfigQuery;
/**
*
* Class PageNotFound
* Class HttpException
* @package Thelia\Action
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class PageNotFound extends BaseAction implements EventSubscriberInterface
class HttpException extends BaseAction implements EventSubscriberInterface
{
public function display404(GetResponseForExceptionEvent $event)
public function checkHttpException(GetResponseForExceptionEvent $event)
{
if ($event->getException() instanceof NotFoundHttpException) {
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
$parser->setTemplate(ConfigQuery::getActiveTemplate());
//$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView());
$response = new Response($parser->render(ConfigQuery::getPageNotFoundView()), 404);
$event->setResponse($response);
$this->display404($event);
}
}
protected function display404(GetResponseForExceptionEvent $event)
{
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
$parser->setTemplate(ConfigQuery::getActiveTemplate());
//$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView());
$response = new Response($parser->render(ConfigQuery::getPageNotFoundView()), 404);
$event->setResponse($response);
}
protected function display403(GetResponseForExceptionEvent $event)
{
$event->setResponse(new Response("You don't have access to this resources", 403));
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
@@ -78,7 +87,7 @@ class PageNotFound extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
KernelEvents::EXCEPTION => array("display404", 128),
KernelEvents::EXCEPTION => array("checkHttpException", 128),
);
}
}

View File

@@ -62,7 +62,12 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.pageNotFound" class="Thelia\Action\PageNotFound">
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.httpException" class="Thelia\Action\HttpException">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>

View File

@@ -70,7 +70,8 @@
<form name="thelia.admin.attribute.creation" class="Thelia\Form\AttributeCreationForm"/>
<form name="thelia.admin.attribute.modification" class="Thelia\Form\AttributeModificationForm"/>
<form name="thelia.admin.attribute-value.creation" class="Thelia\Form\AttributeValueCreationForm"/>
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
</forms>

View File

@@ -37,18 +37,27 @@
<default key="_controller">Thelia\Controller\Admin\CustomerController::indexAction</default>
</route>
<route id="admin.customer.update.view" path="/admin/customer/update/{customer_id}">
<route id="admin.customer.update.view" path="/admin/customer/update/{customer_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\CustomerController::viewAction</default>
<requirement key="customer_id">\d+</requirement>
</route>
<route id="admin.customer.update.process" path="/admin/customer/update/{customer_id}" methods="post">
<default key="_controller">Thelia\Controller\Admin\CustomerController::updateAction</default>
<requirement key="customer_id">\d+</requirement>
</route>
<route id="admin.customer.delete" path="/admin/customer/delete">
<default key="_controller">Thelia\Controller\Admin\CustomerController::deleteAction</default>
</route>
<!-- end Customer rule management -->
<!-- Order rule management -->
<route id="admin.order" path="/admin/order">
<default key="_controller">Thelia\Controller\Admin\OrderController::indexAction</default>
</route>
</route>
<route id="admin.order.update.view" path="/admin/order/update/{order_id}">
<default key="_controller">Thelia\Controller\Admin\OrderController::viewAction</default>
@@ -68,11 +77,11 @@
</route>
<route id="admin.categories.update" path="/admin/categories/update">
<default key="_controller">Thelia\Controller\Admin\CategoryController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\CategoryController::updateAction</default>
</route>
<route id="admin.categories.save" path="/admin/categories/save">
<default key="_controller">Thelia\Controller\Admin\CategoryController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\CategoryController::processUpdateAction</default>
</route>
<route id="admin.categories.set-default" path="/admin/categories/toggle-online">
@@ -129,11 +138,11 @@
</route>
<route id="admin.configuration.variables.update" path="/admin/configuration/variables/update">
<default key="_controller">Thelia\Controller\Admin\ConfigController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\ConfigController::updateAction</default>
</route>
<route id="admin.configuration.variables.save" path="/admin/configuration/variables/save">
<default key="_controller">Thelia\Controller\Admin\ConfigController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\ConfigController::processUpdateAction</default>
</route>
<route id="admin.configuration.variables.delete" path="/admin/configuration/variables/delete">
@@ -151,11 +160,11 @@
</route>
<route id="admin.configuration.messages.update" path="/admin/configuration/messages/update">
<default key="_controller">Thelia\Controller\Admin\MessageController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\MessageController::updateAction</default>
</route>
<route id="admin.configuration.messages.save" path="/admin/configuration/messages/save">
<default key="_controller">Thelia\Controller\Admin\MessageController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\MessageController::processUpdateAction</default>
</route>
<route id="admin.configuration.messages.delete" path="/admin/configuration/messages/delete">
@@ -173,11 +182,11 @@
</route>
<route id="admin.configuration.currencies.update" path="/admin/configuration/currencies/update">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updateAction</default>
</route>
<route id="admin.configuration.currencies.save" path="/admin/configuration/currencies/save">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\CurrencyController::processUpdateAction</default>
</route>
<route id="admin.configuration.currencies.set-default" path="/admin/configuration/currencies/set-default">
@@ -200,7 +209,8 @@
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
</route>
<!-- attribute and feature routes management -->
<!-- attribute and attributes value management -->
<route id="admin.configuration.attributes.default" path="/admin/configuration/attributes">
<default key="_controller">Thelia\Controller\Admin\AttributeController::defaultAction</default>
@@ -210,30 +220,43 @@
<default key="_controller">Thelia\Controller\Admin\AttributeController::createAction</default>
</route>
<route id="admin.configuration.attributes.create" path="/admin/configuration/attributes/create-value">
<default key="_controller">Thelia\Controller\Admin\AttributeController::createValueAction</default>
</route>
<route id="admin.configuration.attributes.update" path="/admin/configuration/attributes/update">
<default key="_controller">Thelia\Controller\Admin\AttributeController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\AttributeController::updateAction</default>
</route>
<route id="admin.configuration.attributes.save" path="/admin/configuration/attributes/save">
<default key="_controller">Thelia\Controller\Admin\AttributeController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\AttributeController::processUpdateAction</default>
</route>
<route id="admin.configuration.attributes.delete" path="/admin/configuration/attributes/delete">
<default key="_controller">Thelia\Controller\Admin\AttributeController::deleteAction</default>
</route>
<route id="admin.configuration.attributes.delete" path="/admin/configuration/attributes/delete-value">
<default key="_controller">Thelia\Controller\Admin\AttributeController::deleteValueAction</default>
</route>
<route id="admin.configuration.attributes.update-position" path="/admin/configuration/attributes/update-position">
<default key="_controller">Thelia\Controller\Admin\AttributeController::updatePositionAction</default>
</route>
<route id="admin.configuration.attributes-av.create" path="/admin/configuration/attributes-av/create">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::createAction</default>
</route>
<route id="admin.configuration.attributes-av.update" path="/admin/configuration/attributes-av/update">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::updateAction</default>
</route>
<route id="admin.configuration.attributes-av.save" path="/admin/configuration/attributes-av/save">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::processUpdateAction</default>
</route>
<route id="admin.configuration.attributes-av.delete" path="/admin/configuration/attributes-av/delete">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::deleteAction</default>
</route>
<route id="admin.configuration.attributes-av.update-position" path="/admin/configuration/attributes-av/update-position">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::updatePositionAction</default>
</route>
<!-- end attribute and feature routes management -->
<!-- The default route, to display a template -->

View File

@@ -10,15 +10,31 @@
</route>
<!-- Customer routes -->
<route id="customer.create.view" path="/register">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">register</default>
</route>
<route id="customer.login.view" path="/login">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">login</default>
</route>
<route id="customer.logout.process" path="/logout">
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
</route>
<route id="customer.account.view" path="/customer/account">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">account</default>
</route>
<route id="customer.create.process" path="/customer/create" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
<default key="_view">register</default>
</route>
<route id="customer.create.view" path="/register">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">register</default>
</route>
<route id="customer.update.process" path="/customer/update" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::updateAction</default>
@@ -29,14 +45,6 @@
<default key="_view">login</default>
</route>
<route id="customer.login.view" path="/login">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">login</default>
</route>
<route id="customer.logout.process" path="/logout">
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
</route>
<route id="customer.password.retrieve.view" path="/password" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
@@ -58,12 +66,19 @@
<route id="address.edit" path="/address/edit/{address_id}">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">address_edit</default>
<default key="_view">address-edit</default>
</route>
<route id="address.update" path="/address/update" >
<default key="_controller">Thelia\Controller\Front\AddressController::updateAction</default>
</route>
<route id="address.generateModal" path="/address/modal/{address_id}" methods="get">
<default key="_controller">Thelia\Controller\Front\AddressController::generateModalAction</default>
<default key="_view">modal-address</default>
<requirement key="address_id">\d+</requirement>
</route>
<!-- end customer address routes -->
<!-- cart routes -->
@@ -86,6 +101,8 @@
<default key="_view">cart</default>
</route>
<!-- end cart routes -->
<!-- order management process -->
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>

View File

@@ -28,7 +28,7 @@ use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ToggleVisibilityEvent;
/**
* Manages currencies sent by mail
* An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object.
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
@@ -53,6 +53,23 @@ abstract class AbstractCrudController extends BaseAdminController
protected $changePositionEventIdentifier;
/**
* @param string $objectName the lower case object name. Example. "message"
*
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
*
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
*
* @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE
* @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
*
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
*/
public function __construct(
$objectName,
@@ -187,15 +204,14 @@ abstract class AbstractCrudController extends BaseAdminController
}
/**
* Render the object list, ensuring the sort order is set.
*
* @return Symfony\Component\HttpFoundation\Response the response
* Return the current list order identifier, updating it in the same time.
*/
protected function renderList()
{
protected function getCurrentListOrder($update_session = true) {
$order = null;
if ($this->defaultListOrder != null) {
if ($this->defaultListOrder) {
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $this->objectName);
// Find the current order
@@ -204,11 +220,20 @@ abstract class AbstractCrudController extends BaseAdminController
$this->getSession()->get($orderSessionIdentifier, $this->defaultListOrder)
);
// Store the current sort order in session
$this->getSession()->set($orderSessionIdentifier, $order);
if ($update_session) $this->getSession()->set($orderSessionIdentifier, $order);
}
return $this->renderListTemplate($order);
return $order;
}
/**
* Render the object list, ensuring the sort order is set.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
protected function renderList()
{
return $this->renderListTemplate($this->getCurrentListOrder());
}
/**
@@ -286,7 +311,7 @@ abstract class AbstractCrudController extends BaseAdminController
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function changeAction()
public function updateAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
@@ -312,7 +337,7 @@ abstract class AbstractCrudController extends BaseAdminController
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function saveChangeAction()
public function processUpdateAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;

View File

@@ -0,0 +1,180 @@
<?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 Thelia\Controller\Admin;
use Thelia\Core\Event\AttributeAvDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeAvCreateEvent;
use Thelia\Model\AttributeAvQuery;
use Thelia\Form\AttributeAvModificationForm;
use Thelia\Form\AttributeAvCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
/**
* Manages attributes-av sent by mail
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class AttributeAvController extends AbstractCrudController
{
public function __construct() {
parent::__construct(
'attribute',
'manual',
'admin.configuration.attributes-av.view',
'admin.configuration.attributes-av.create',
'admin.configuration.attributes-av.update',
'admin.configuration.attributes-av.delete',
TheliaEvents::ATTRIBUTE_AV_CREATE,
TheliaEvents::ATTRIBUTE_AV_UPDATE,
TheliaEvents::ATTRIBUTE_AV_DELETE,
null, // No visibility toggle
TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION
);
}
protected function getCreationForm() {
return new AttributeAvCreationForm($this->getRequest());
}
protected function getUpdateForm() {
return new AttributeAvModificationForm($this->getRequest());
}
protected function getCreationEvent($formData) {
$createEvent = new AttributeAvCreateEvent();
$createEvent
->setAttributeId($formData['attribute_id'])
->setTitle($formData['title'])
->setLocale($formData["locale"])
;
return $createEvent;
}
protected function getUpdateEvent($formData) {
$changeEvent = new AttributeAvUpdateEvent($formData['id']);
// Create and dispatch the change event
$changeEvent
->setLocale($formData["locale"])
->setTitle($formData['title'])
->setChapo($formData['chapo'])
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
;
return $changeEvent;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
return new UpdatePositionEvent(
$this->getRequest()->get('attributeav_id', null),
$positionChangeMode,
$positionValue
);
}
protected function getDeleteEvent() {
return new AttributeAvDeleteEvent($this->getRequest()->get('attributeav_id'));
}
protected function eventContainsObject($event) {
return $event->hasAttributeAv();
}
protected function hydrateObjectForm($object) {
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'chapo' => $object->getChapo(),
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum()
);
// Setup the object form
return new AttributeAvModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
return $event->hasAttributeAv() ? $event->getAttributeAv() : null;
}
protected function getExistingObject() {
return AttributeAvQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('attributeav_id'));
}
protected function getObjectLabel($object) {
return $object->getTitle();
}
protected function getObjectId($object) {
return $object->getId();
}
protected function getViewArguments() {
return array(
'attribute_id' => $this->getRequest()->get('attribute_id'),
'order' => $this->getCurrentListOrder()
);
}
protected function renderListTemplate($currentOrder) {
// We always return to the attribute edition form
return $this->render(
'attribute-edit',
$this->getViewArguments()
);
}
protected function renderEditionTemplate() {
// We always return to the attribute edition form
return $this->render('attribute-edit', $this->getViewArguments());
}
protected function redirectToEditionTemplate() {
// We always return to the attribute edition form
$this->redirectToRoute(
"admin.configuration.attributes.update",
$this->getViewArguments()
);
}
protected function redirectToListTemplate() {
$this->redirectToRoute(
"admin.configuration.attributes.update",
$this->getViewArguments()
);
}
}

View File

@@ -122,7 +122,7 @@ class AttributeController extends AbstractCrudController
);
// Setup the object form
$changeForm = new AttributeModificationForm($this->getRequest(), "form", $data);
return new AttributeModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
@@ -136,7 +136,7 @@ class AttributeController extends AbstractCrudController
}
protected function getObjectLabel($object) {
return $object->getName();
return $object->getTitle();
}
protected function getObjectId($object) {

View File

@@ -22,6 +22,15 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\Form\Form;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerController
@@ -32,15 +41,141 @@ class CustomerController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.customers.view")) return $response;
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
return $this->render("customers", array("display_customer" => 20));
}
public function viewAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
/**
* update customer action
*
* @param $customer_id
* @return mixed|\Symfony\Component\HttpFoundation\Response
*/
public function updateAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.update")) return $response;
$message = false;
$customerModification = new CustomerModification($this->getRequest());
try {
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
throw new \InvalidArgumentException(sprintf("%d customer id does not exists", $customer_id));
}
$form = $this->validateForm($customerModification);
$event = $this->createEventInstance($form->getData());
$event->setCustomer($customer);
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $event);
$customerUpdated = $event->getCustomer();
$this->adminLogAppend(sprintf("Customer with Ref %s (ID %d) modified", $customerUpdated->getRef() , $customerUpdated->getId()));
if($this->getRequest()->get("save_mode") == "close") {
$this->redirectToRoute("admin.customers");
} else {
$this->redirectSuccess($customerModification);
}
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
} catch (PropelException $e) {
$message = $e->getMessage();
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage()." ".$e->getFile());
}
if ($message !== false) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error during customer login process : %s.", $message));
$customerModification->setErrorMessage($message);
$this->getParserContext()
->addForm($customerModification)
->setGeneralError($message)
;
}
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
public function deleteAction()
{
if (null !== $response = $this->checkAuth("admin.customer.delete")) return $response;
$message = null;
try {
$customer_id = $this->getRequest()->get("customer_id");
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exists"));
}
$event = new CustomerEvent($customer);
$this->dispatch(TheliaEvents::CUSTOMER_DELETEACCOUNT, $event);
} catch(\Exception $e) {
$message = $e->getMessage();
}
$params = array(
"customer_page" => $this->getRequest()->get("customer_page", 1)
);
if ($message) {
$params["delete_error_message"] = $message;
}
$this->redirectToRoute("admin.customers", $params);
}
/**
* @param $data
* @return CustomerCreateOrUpdateEvent
*/
private function createEventInstance($data)
{
$customerCreateEvent = new CustomerCreateOrUpdateEvent(
$data["title"],
$data["firstname"],
$data["lastname"],
$data["address1"],
$data["address2"],
$data["address3"],
$data["phone"],
$data["cellphone"],
$data["zipcode"],
$data["city"],
$data["country"],
isset($data["email"])?$data["email"]:null,
isset($data["password"]) ? $data["password"]:null,
$this->getRequest()->getSession()->getLang()->getId(),
isset($data["reseller"])?$data["reseller"]:null,
isset($data["sponsor"])?$data["sponsor"]:null,
isset($data["discount"])?$data["discount"]:null,
isset($data["company"])?$data["company"]:null
);
return $customerCreateEvent;
}
}

View File

@@ -25,6 +25,7 @@ namespace Thelia\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
@@ -263,4 +264,21 @@ class BaseController extends ContainerAware
{
return $this->container->getParameter('kernel.debug');
}
protected function accessDenied()
{
throw new AccessDeniedHttpException();
}
/**
* check if the current http request is a XmlHttpRequest.
*
* If not, send a
*/
protected function checkXmlHttpRequest()
{
if(false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) {
$this->accessDenied();
}
}
}

View File

@@ -39,6 +39,21 @@ use Thelia\Tools\URL;
class AddressController extends BaseFrontController
{
/**
* Controller for generate modal containing update form
* Check if request is a XmlHttpRequest and address owner is the current customer
* @param $address_id
*/
public function generateModalAction($address_id)
{
if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->accessDenied();
}
$this->checkXmlHttpRequest();
}
/**
* Create controller.
* Check if customer is logged in
@@ -48,7 +63,7 @@ class AddressController extends BaseFrontController
public function createAction()
{
if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirect(URL::getInstance()->getIndexPage());
$this->accessDenied()
}
$addressCreate = new AddressCreateForm($this->getRequest());

View File

@@ -278,7 +278,8 @@ class CustomerController extends BaseFrontController
$this->getRequest()->getSession()->getLang()->getId(),
isset($data["reseller"])?$data["reseller"]:null,
isset($data["sponsor"])?$data["sponsor"]:null,
isset($data["discount"])?$data["discount"]:null
isset($data["discount"])?$data["discount"]:null,
isset($data["company"])?$data["company"]:null
);
return $customerCreateEvent;

View File

@@ -23,7 +23,7 @@
namespace Thelia\Core\Event;
class AttributeValueCreateEvent extends AttributeValueEvent
class AttributeAvCreateEvent extends AttributeAvEvent
{
protected $title;
protected $locale;

View File

@@ -23,23 +23,23 @@
namespace Thelia\Core\Event;
class AttributeValueDeleteEvent extends AttributeValueEvent
class AttributeAvDeleteEvent extends AttributeAvEvent
{
protected $attributeValue_id;
protected $attributeAv_id;
public function __construct($attributeValue_id)
public function __construct($attributeAv_id)
{
$this->setAttributeValueId($attributeValue_id);
$this->setAttributeAvId($attributeAv_id);
}
public function getAttributeValueId()
public function getAttributeAvId()
{
return $this->attributeValue_id;
return $this->attributeAv_id;
}
public function setAttributeValueId($attributeValue_id)
public function setAttributeAvId($attributeAv_id)
{
$this->attributeValue_id = $attributeValue_id;
$this->attributeAv_id = $attributeAv_id;
return $this;
}

View File

@@ -24,28 +24,28 @@
namespace Thelia\Core\Event;
use Thelia\Model\AttributeAv;
class AttributeValueEvent extends ActionEvent
class AttributeAvEvent extends ActionEvent
{
protected $attributeValue = null;
protected $attributeAv = null;
public function __construct(AttributeAv $attributeValue = null)
public function __construct(AttributeAv $attributeAv = null)
{
$this->attributeValue = $attributeValue;
$this->attributeAv = $attributeAv;
}
public function hasAttributeValue()
public function hasAttributeAv()
{
return ! is_null($this->attributeValue);
return ! is_null($this->attributeAv);
}
public function getAttributeValue()
public function getAttributeAv()
{
return $this->attributeValue;
return $this->attributeAv;
}
public function setAttributeValue($attributeValue)
public function setAttributeAv($attributeAv)
{
$this->attributeValue = $attributeValue;
$this->attributeAv = $attributeAv;
return $this;
}

View File

@@ -23,27 +23,27 @@
namespace Thelia\Core\Event;
class AttributeValueUpdateEvent extends AttributeValueCreateEvent
class AttributeAvUpdateEvent extends AttributeAvCreateEvent
{
protected $attributeValue_id;
protected $attributeAv_id;
protected $description;
protected $chapo;
protected $postscriptum;
public function __construct($attributeValue_id)
public function __construct($attributeAv_id)
{
$this->setAttributeValueId($attributeValue_id);
$this->setAttributeAvId($attributeAv_id);
}
public function getAttributeValueId()
public function getAttributeAvId()
{
return $this->attributeValue_id;
return $this->attributeAv_id;
}
public function setAttributeValueId($attributeValue_id)
public function setAttributeAvId($attributeAv_id)
{
$this->attributeValue_id = $attributeValue_id;
$this->attributeAv_id = $attributeAv_id;
return $this;
}

View File

@@ -1,17 +1,35 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: manu
* Date: 16/08/13
* Time: 10:24
* To change this template use File | Settings | File Templates.
*/
/*************************************************************************************/
/* */
/* 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 Thelia\Core\Event;
use Symfony\Component\EventDispatcher\Event;
use Thelia\Model\Customer;
/**
* Class CustomerCreateOrUpdateEvent
* @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CustomerCreateOrUpdateEvent extends ActionEvent
{
//base parameters for creating new customer
@@ -32,6 +50,7 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
protected $reseller;
protected $sponsor;
protected $discount;
protected $company;
/**
* @var \Thelia\Model\Customer
@@ -39,7 +58,7 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
protected $customer;
/**
* @param int $title the title customer id
* @param int $title the title customer id
* @param string $firstname
* @param string $lastname
* @param string $address1
@@ -49,15 +68,16 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
* @param string $cellphone
* @param string $zipcode
* @param string $city
* @param int $country the country id
* @param int $country the country id
* @param string $email
* @param string $password plain password, don't put hash password, it will hashes again
* @param $lang
* @param int $reseller if customer is a reseller
* @param int $sponsor customer's id sponsor
* @param int $reseller if customer is a reseller
* @param int $sponsor customer's id sponsor
* @param float $discount
* @param string $company
*/
public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount)
public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount, $company)
{
$this->address1 = $address1;
$this->address2 = $address2;
@@ -72,9 +92,18 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
$this->cellphone = $cellphone;
$this->title = $title;
$this->zipcode = $zipcode;
$this->city = $city;
$this->reseller = $reseller;
$this->sponsor = $sponsor;
$this->discount = $discount;
$this->company = $company;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**

View File

@@ -71,6 +71,11 @@ final class TheliaEvents
*/
const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer";
/**
* sent on customer removal
*/
const CUSTOMER_DELETEACCOUNT = "action.deleteCustomer";
/**
* sent when a customer need a new password
*/
@@ -103,6 +108,16 @@ final class TheliaEvents
*/
const AFTER_UPDATECUSTOMER = "action.after_updateCustomer";
/**
* sent just before customer removal
*/
const BEFORE_DELETECUSTOMER = "action.before_updateCustomer";
/**
* sent just after customer removal
*/
const AFTER_DELETECUSTOMER = "action.after_deleteCustomer";
// -- ADDRESS MANAGEMENT ---------------------------------------------------------
/**
* sent for address creation
@@ -365,17 +380,17 @@ final class TheliaEvents
// -- Attributes values management ----------------------------------------
const ATTRIBUTE_VALUE_CREATE = "action.createAttributeValue";
const ATTRIBUTE_VALUE_UPDATE = "action.updateAttributeValue";
const ATTRIBUTE_VALUE_DELETE = "action.deleteAttributeValue";
const ATTRIBUTE_VALUE_UPDATE_POSITION = "action.updateAttributeValuePosition";
const ATTRIBUTE_AV_CREATE = "action.createAttributeAv";
const ATTRIBUTE_AV_UPDATE = "action.updateAttributeAv";
const ATTRIBUTE_AV_DELETE = "action.deleteAttributeAv";
const ATTRIBUTE_AV_UPDATE_POSITION = "action.updateAttributeAvPosition";
const BEFORE_CREATEATTRIBUTE_VALUE = "action.before_createAttributeValue";
const AFTER_CREATEATTRIBUTE_VALUE = "action.after_createAttributeValue";
const BEFORE_CREATEATTRIBUTE_AV = "action.before_createAttributeAv";
const AFTER_CREATEATTRIBUTE_AV = "action.after_createAttributeAv";
const BEFORE_UPDATEATTRIBUTE_VALUE = "action.before_updateAttributeValue";
const AFTER_UPDATEATTRIBUTE_VALUE = "action.after_updateAttributeValue";
const BEFORE_UPDATEATTRIBUTE_AV = "action.before_updateAttributeAv";
const AFTER_UPDATEATTRIBUTE_AV = "action.after_updateAttributeAv";
const BEFORE_DELETEATTRIBUTE_VALUE = "action.before_deleteAttributeValue";
const AFTER_DELETEATTRIBUTE_VALUE = "action.after_deleteAttributeValue";
const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv";
const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv";
}

View File

@@ -63,7 +63,7 @@ class Address extends BaseLoop
),
'current'
),
Argument::createBooleanTypeArgument('default', false),
Argument::createBooleanTypeArgument('default'),
Argument::createIntListTypeArgument('exclude')
);
}
@@ -100,6 +100,8 @@ class Address extends BaseLoop
if ($default === true) {
$search->filterByIsDefault(1, Criteria::EQUAL);
} else if($default === false) {
$search->filterByIsDefault(0, Criteria::EQUAL);
}
$exclude = $this->getExclude();

View File

@@ -28,7 +28,7 @@ use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class AttributeValueCreationForm extends BaseForm
class AttributeAvCreationForm extends BaseForm
{
protected function buildForm()
{
@@ -57,6 +57,6 @@ class AttributeValueCreationForm extends BaseForm
public function getName()
{
return "thelia_attribute_value_creation";
return "thelia_attributeav_creation";
}
}

View File

@@ -43,6 +43,10 @@ class AttributeModificationForm extends AttributeCreationForm
)
)
))
->add('attribute_values', 'collection', array(
'type' => 'text',
'options' => array('required' => false)
))
;
// Add standard description fields

View File

@@ -58,6 +58,12 @@ class CustomerModification extends BaseForm
$this->formBuilder
->add('update_logged_in_user', 'integer') // In a front office context, update the in-memory logged-in user data
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company"),
"label_attr" => array(
"for" => "company"
)
))
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()

View File

@@ -71,4 +71,14 @@ class Address extends BaseAddress {
$this->dispatchEvent(TheliaEvents::AFTER_DELETEADDRESS, new AddressEvent($this));
}
public function preSave()
{
$valid = true;
if($this->getIsDefault()) {
$valid = false;
}
return $valid;
}
}

View File

@@ -3,7 +3,7 @@
namespace Thelia\Model;
use Thelia\Model\Base\AttributeAv as BaseAttributeAv;
use Thelia\Core\Event\AttributeValueEvent;
use Thelia\Core\Event\AttributeAvEvent;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\Event\TheliaEvents;
use Propel\Runtime\ActiveQuery\Criteria;
@@ -11,21 +11,14 @@ use Propel\Runtime\ActiveQuery\Criteria;
class AttributeAv extends BaseAttributeAv {
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
/**
* Get the position of the next inserted object
* when dealing with position, be sure to work insite the current attribute.
*/
public function getNextPosition($parent = null) {
$last = $this->createQuery()
->filterByAttributeId($this->getAttributeId())
->orderByPosition(Criteria::DESC)
->limit(1)
->findOne()
;
return $last != null ? $last->getPosition() + 1 : 1;
protected function addCriteriaToPositionQuery($query) {
$query->filterByAttributeId($this->getAttributeId());
}
/**
@@ -33,11 +26,11 @@ class AttributeAv extends BaseAttributeAv {
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEATTRIBUTE_VALUE, new AttributeValueEvent($this));
// Set the current position for the new object
$this->setPosition($this->getNextPosition());
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEATTRIBUTE_AV, new AttributeAvEvent($this));
return true;
}
@@ -46,7 +39,7 @@ class AttributeAv extends BaseAttributeAv {
*/
public function postInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CREATEATTRIBUTE_VALUE, new AttributeValueEvent($this));
$this->dispatchEvent(TheliaEvents::AFTER_CREATEATTRIBUTE_AV, new AttributeAvEvent($this));
}
/**
@@ -54,7 +47,7 @@ class AttributeAv extends BaseAttributeAv {
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEATTRIBUTE_VALUE, new AttributeValueEvent($this));
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEATTRIBUTE_AV, new AttributeAvEvent($this));
return true;
}
@@ -64,7 +57,7 @@ class AttributeAv extends BaseAttributeAv {
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEATTRIBUTE_VALUE, new AttributeValueEvent($this));
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEATTRIBUTE_AV, new AttributeAvEvent($this));
}
/**
@@ -72,7 +65,7 @@ class AttributeAv extends BaseAttributeAv {
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEATTRIBUTE_VALUE, new AttributeValueEvent($this));
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEATTRIBUTE_AV, new AttributeAvEvent($this));
return true;
}
@@ -82,6 +75,6 @@ class AttributeAv extends BaseAttributeAv {
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETEATTRIBUTE_VALUE, new AttributeValueEvent($this));
$this->dispatchEvent(TheliaEvents::AFTER_DELETEATTRIBUTE_AV, new AttributeAvEvent($this));
}
}

View File

@@ -99,6 +99,13 @@ abstract class Cart implements ActiveRecordInterface
*/
protected $currency_id;
/**
* The value for the discount field.
* Note: this column has a database default value of: 0
* @var double
*/
protected $discount;
/**
* The value for the created_at field.
* @var string
@@ -151,11 +158,24 @@ abstract class Cart implements ActiveRecordInterface
*/
protected $cartItemsScheduledForDeletion = null;
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
* equivalent initialization method).
* @see __construct()
*/
public function applyDefaultValues()
{
$this->discount = 0;
}
/**
* Initializes internal state of Thelia\Model\Base\Cart object.
* @see applyDefaults()
*/
public function __construct()
{
$this->applyDefaultValues();
}
/**
@@ -471,6 +491,17 @@ abstract class Cart implements ActiveRecordInterface
return $this->currency_id;
}
/**
* Get the [discount] column value.
*
* @return double
*/
public function getDiscount()
{
return $this->discount;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -653,6 +684,27 @@ abstract class Cart implements ActiveRecordInterface
return $this;
} // setCurrencyId()
/**
* Set the value of [discount] column.
*
* @param double $v new value
* @return \Thelia\Model\Cart The current object (for fluent API support)
*/
public function setDiscount($v)
{
if ($v !== null) {
$v = (double) $v;
}
if ($this->discount !== $v) {
$this->discount = $v;
$this->modifiedColumns[] = CartTableMap::DISCOUNT;
}
return $this;
} // setDiscount()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -705,6 +757,10 @@ abstract class Cart implements ActiveRecordInterface
*/
public function hasOnlyDefaultValues()
{
if ($this->discount !== 0) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -750,13 +806,16 @@ abstract class Cart implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CartTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)];
$this->currency_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CartTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CartTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)];
$this->discount = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CartTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CartTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -769,7 +828,7 @@ abstract class Cart implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 8; // 8 = CartTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 9; // 9 = CartTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Cart object", 0, $e);
@@ -1075,6 +1134,9 @@ abstract class Cart implements ActiveRecordInterface
if ($this->isColumnModified(CartTableMap::CURRENCY_ID)) {
$modifiedColumns[':p' . $index++] = 'CURRENCY_ID';
}
if ($this->isColumnModified(CartTableMap::DISCOUNT)) {
$modifiedColumns[':p' . $index++] = 'DISCOUNT';
}
if ($this->isColumnModified(CartTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1110,6 +1172,9 @@ abstract class Cart implements ActiveRecordInterface
case 'CURRENCY_ID':
$stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
break;
case 'DISCOUNT':
$stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR);
break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -1197,9 +1262,12 @@ abstract class Cart implements ActiveRecordInterface
return $this->getCurrencyId();
break;
case 6:
return $this->getCreatedAt();
return $this->getDiscount();
break;
case 7:
return $this->getCreatedAt();
break;
case 8:
return $this->getUpdatedAt();
break;
default:
@@ -1237,8 +1305,9 @@ abstract class Cart implements ActiveRecordInterface
$keys[3] => $this->getAddressDeliveryId(),
$keys[4] => $this->getAddressInvoiceId(),
$keys[5] => $this->getCurrencyId(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
$keys[6] => $this->getDiscount(),
$keys[7] => $this->getCreatedAt(),
$keys[8] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1315,9 +1384,12 @@ abstract class Cart implements ActiveRecordInterface
$this->setCurrencyId($value);
break;
case 6:
$this->setCreatedAt($value);
$this->setDiscount($value);
break;
case 7:
$this->setCreatedAt($value);
break;
case 8:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1350,8 +1422,9 @@ abstract class Cart implements ActiveRecordInterface
if (array_key_exists($keys[3], $arr)) $this->setAddressDeliveryId($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setAddressInvoiceId($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setCurrencyId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
if (array_key_exists($keys[6], $arr)) $this->setDiscount($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
}
/**
@@ -1369,6 +1442,7 @@ abstract class Cart implements ActiveRecordInterface
if ($this->isColumnModified(CartTableMap::ADDRESS_DELIVERY_ID)) $criteria->add(CartTableMap::ADDRESS_DELIVERY_ID, $this->address_delivery_id);
if ($this->isColumnModified(CartTableMap::ADDRESS_INVOICE_ID)) $criteria->add(CartTableMap::ADDRESS_INVOICE_ID, $this->address_invoice_id);
if ($this->isColumnModified(CartTableMap::CURRENCY_ID)) $criteria->add(CartTableMap::CURRENCY_ID, $this->currency_id);
if ($this->isColumnModified(CartTableMap::DISCOUNT)) $criteria->add(CartTableMap::DISCOUNT, $this->discount);
if ($this->isColumnModified(CartTableMap::CREATED_AT)) $criteria->add(CartTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CartTableMap::UPDATED_AT)) $criteria->add(CartTableMap::UPDATED_AT, $this->updated_at);
@@ -1439,6 +1513,7 @@ abstract class Cart implements ActiveRecordInterface
$copyObj->setAddressDeliveryId($this->getAddressDeliveryId());
$copyObj->setAddressInvoiceId($this->getAddressInvoiceId());
$copyObj->setCurrencyId($this->getCurrencyId());
$copyObj->setDiscount($this->getDiscount());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -1982,10 +2057,12 @@ abstract class Cart implements ActiveRecordInterface
$this->address_delivery_id = null;
$this->address_invoice_id = null;
$this->currency_id = null;
$this->discount = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);

View File

@@ -109,6 +109,13 @@ abstract class CartItem implements ActiveRecordInterface
*/
protected $price_end_of_life;
/**
* The value for the discount field.
* Note: this column has a database default value of: 0
* @var double
*/
protected $discount;
/**
* The value for the created_at field.
* @var string
@@ -153,6 +160,7 @@ abstract class CartItem implements ActiveRecordInterface
public function applyDefaultValues()
{
$this->quantity = 1;
$this->discount = 0;
}
/**
@@ -508,6 +516,17 @@ abstract class CartItem implements ActiveRecordInterface
}
}
/**
* Get the [discount] column value.
*
* @return double
*/
public function getDiscount()
{
return $this->discount;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -728,6 +747,27 @@ abstract class CartItem implements ActiveRecordInterface
return $this;
} // setPriceEndOfLife()
/**
* Set the value of [discount] column.
*
* @param double $v new value
* @return \Thelia\Model\CartItem The current object (for fluent API support)
*/
public function setDiscount($v)
{
if ($v !== null) {
$v = (double) $v;
}
if ($this->discount !== $v) {
$this->discount = $v;
$this->modifiedColumns[] = CartItemTableMap::DISCOUNT;
}
return $this;
} // setDiscount()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -784,6 +824,10 @@ abstract class CartItem implements ActiveRecordInterface
return false;
}
if ($this->discount !== 0) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -838,13 +882,16 @@ abstract class CartItem implements ActiveRecordInterface
}
$this->price_end_of_life = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)];
$this->discount = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -857,7 +904,7 @@ abstract class CartItem implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 10; // 10 = CartItemTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 11; // 11 = CartItemTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\CartItem object", 0, $e);
@@ -1139,6 +1186,9 @@ abstract class CartItem implements ActiveRecordInterface
if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) {
$modifiedColumns[':p' . $index++] = 'PRICE_END_OF_LIFE';
}
if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) {
$modifiedColumns[':p' . $index++] = 'DISCOUNT';
}
if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1180,6 +1230,9 @@ abstract class CartItem implements ActiveRecordInterface
case 'PRICE_END_OF_LIFE':
$stmt->bindValue($identifier, $this->price_end_of_life ? $this->price_end_of_life->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'DISCOUNT':
$stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR);
break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -1273,9 +1326,12 @@ abstract class CartItem implements ActiveRecordInterface
return $this->getPriceEndOfLife();
break;
case 8:
return $this->getCreatedAt();
return $this->getDiscount();
break;
case 9:
return $this->getCreatedAt();
break;
case 10:
return $this->getUpdatedAt();
break;
default:
@@ -1315,8 +1371,9 @@ abstract class CartItem implements ActiveRecordInterface
$keys[5] => $this->getPrice(),
$keys[6] => $this->getPromoPrice(),
$keys[7] => $this->getPriceEndOfLife(),
$keys[8] => $this->getCreatedAt(),
$keys[9] => $this->getUpdatedAt(),
$keys[8] => $this->getDiscount(),
$keys[9] => $this->getCreatedAt(),
$keys[10] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1393,9 +1450,12 @@ abstract class CartItem implements ActiveRecordInterface
$this->setPriceEndOfLife($value);
break;
case 8:
$this->setCreatedAt($value);
$this->setDiscount($value);
break;
case 9:
$this->setCreatedAt($value);
break;
case 10:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1430,8 +1490,9 @@ abstract class CartItem implements ActiveRecordInterface
if (array_key_exists($keys[5], $arr)) $this->setPrice($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setPromoPrice($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setPriceEndOfLife($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]);
if (array_key_exists($keys[8], $arr)) $this->setDiscount($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]);
}
/**
@@ -1451,6 +1512,7 @@ abstract class CartItem implements ActiveRecordInterface
if ($this->isColumnModified(CartItemTableMap::PRICE)) $criteria->add(CartItemTableMap::PRICE, $this->price);
if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) $criteria->add(CartItemTableMap::PROMO_PRICE, $this->promo_price);
if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) $criteria->add(CartItemTableMap::PRICE_END_OF_LIFE, $this->price_end_of_life);
if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) $criteria->add(CartItemTableMap::DISCOUNT, $this->discount);
if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) $criteria->add(CartItemTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CartItemTableMap::UPDATED_AT)) $criteria->add(CartItemTableMap::UPDATED_AT, $this->updated_at);
@@ -1523,6 +1585,7 @@ abstract class CartItem implements ActiveRecordInterface
$copyObj->setPrice($this->getPrice());
$copyObj->setPromoPrice($this->getPromoPrice());
$copyObj->setPriceEndOfLife($this->getPriceEndOfLife());
$copyObj->setDiscount($this->getDiscount());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
if ($makeNew) {
@@ -1719,6 +1782,7 @@ abstract class CartItem implements ActiveRecordInterface
$this->price = null;
$this->promo_price = null;
$this->price_end_of_life = null;
$this->discount = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;

View File

@@ -29,6 +29,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method ChildCartItemQuery orderByPrice($order = Criteria::ASC) Order by the price column
* @method ChildCartItemQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column
* @method ChildCartItemQuery orderByPriceEndOfLife($order = Criteria::ASC) Order by the price_end_of_life column
* @method ChildCartItemQuery orderByDiscount($order = Criteria::ASC) Order by the discount column
* @method ChildCartItemQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCartItemQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
@@ -40,6 +41,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method ChildCartItemQuery groupByPrice() Group by the price column
* @method ChildCartItemQuery groupByPromoPrice() Group by the promo_price column
* @method ChildCartItemQuery groupByPriceEndOfLife() Group by the price_end_of_life column
* @method ChildCartItemQuery groupByDiscount() Group by the discount column
* @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column
* @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -70,6 +72,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method ChildCartItem findOneByPrice(double $price) Return the first ChildCartItem filtered by the price column
* @method ChildCartItem findOneByPromoPrice(double $promo_price) Return the first ChildCartItem filtered by the promo_price column
* @method ChildCartItem findOneByPriceEndOfLife(string $price_end_of_life) Return the first ChildCartItem filtered by the price_end_of_life column
* @method ChildCartItem findOneByDiscount(double $discount) Return the first ChildCartItem filtered by the discount column
* @method ChildCartItem findOneByCreatedAt(string $created_at) Return the first ChildCartItem filtered by the created_at column
* @method ChildCartItem findOneByUpdatedAt(string $updated_at) Return the first ChildCartItem filtered by the updated_at column
*
@@ -81,6 +84,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method array findByPrice(double $price) Return ChildCartItem objects filtered by the price column
* @method array findByPromoPrice(double $promo_price) Return ChildCartItem objects filtered by the promo_price column
* @method array findByPriceEndOfLife(string $price_end_of_life) Return ChildCartItem objects filtered by the price_end_of_life column
* @method array findByDiscount(double $discount) Return ChildCartItem objects filtered by the discount column
* @method array findByCreatedAt(string $created_at) Return ChildCartItem objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCartItem objects filtered by the updated_at column
*
@@ -171,7 +175,7 @@ abstract class CartItemQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0';
$sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, DISCOUNT, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -596,6 +600,47 @@ abstract class CartItemQuery extends ModelCriteria
return $this->addUsingAlias(CartItemTableMap::PRICE_END_OF_LIFE, $priceEndOfLife, $comparison);
}
/**
* Filter the query on the discount column
*
* Example usage:
* <code>
* $query->filterByDiscount(1234); // WHERE discount = 1234
* $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34)
* $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12
* </code>
*
* @param mixed $discount 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 ChildCartItemQuery The current query, for fluid interface
*/
public function filterByDiscount($discount = null, $comparison = null)
{
if (is_array($discount)) {
$useMinMax = false;
if (isset($discount['min'])) {
$this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($discount['max'])) {
$this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -27,6 +27,7 @@ use Thelia\Model\Map\CartTableMap;
* @method ChildCartQuery orderByAddressDeliveryId($order = Criteria::ASC) Order by the address_delivery_id column
* @method ChildCartQuery orderByAddressInvoiceId($order = Criteria::ASC) Order by the address_invoice_id column
* @method ChildCartQuery orderByCurrencyId($order = Criteria::ASC) Order by the currency_id column
* @method ChildCartQuery orderByDiscount($order = Criteria::ASC) Order by the discount column
* @method ChildCartQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCartQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
@@ -36,6 +37,7 @@ use Thelia\Model\Map\CartTableMap;
* @method ChildCartQuery groupByAddressDeliveryId() Group by the address_delivery_id column
* @method ChildCartQuery groupByAddressInvoiceId() Group by the address_invoice_id column
* @method ChildCartQuery groupByCurrencyId() Group by the currency_id column
* @method ChildCartQuery groupByDiscount() Group by the discount column
* @method ChildCartQuery groupByCreatedAt() Group by the created_at column
* @method ChildCartQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -72,6 +74,7 @@ use Thelia\Model\Map\CartTableMap;
* @method ChildCart findOneByAddressDeliveryId(int $address_delivery_id) Return the first ChildCart filtered by the address_delivery_id column
* @method ChildCart findOneByAddressInvoiceId(int $address_invoice_id) Return the first ChildCart filtered by the address_invoice_id column
* @method ChildCart findOneByCurrencyId(int $currency_id) Return the first ChildCart filtered by the currency_id column
* @method ChildCart findOneByDiscount(double $discount) Return the first ChildCart filtered by the discount column
* @method ChildCart findOneByCreatedAt(string $created_at) Return the first ChildCart filtered by the created_at column
* @method ChildCart findOneByUpdatedAt(string $updated_at) Return the first ChildCart filtered by the updated_at column
*
@@ -81,6 +84,7 @@ use Thelia\Model\Map\CartTableMap;
* @method array findByAddressDeliveryId(int $address_delivery_id) Return ChildCart objects filtered by the address_delivery_id column
* @method array findByAddressInvoiceId(int $address_invoice_id) Return ChildCart objects filtered by the address_invoice_id column
* @method array findByCurrencyId(int $currency_id) Return ChildCart objects filtered by the currency_id column
* @method array findByDiscount(double $discount) Return ChildCart objects filtered by the discount column
* @method array findByCreatedAt(string $created_at) Return ChildCart objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCart objects filtered by the updated_at column
*
@@ -171,7 +175,7 @@ abstract class CartQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, TOKEN, CUSTOMER_ID, ADDRESS_DELIVERY_ID, ADDRESS_INVOICE_ID, CURRENCY_ID, CREATED_AT, UPDATED_AT FROM cart WHERE ID = :p0';
$sql = 'SELECT ID, TOKEN, CUSTOMER_ID, ADDRESS_DELIVERY_ID, ADDRESS_INVOICE_ID, CURRENCY_ID, DISCOUNT, CREATED_AT, UPDATED_AT FROM cart WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -502,6 +506,47 @@ abstract class CartQuery extends ModelCriteria
return $this->addUsingAlias(CartTableMap::CURRENCY_ID, $currencyId, $comparison);
}
/**
* Filter the query on the discount column
*
* Example usage:
* <code>
* $query->filterByDiscount(1234); // WHERE discount = 1234
* $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34)
* $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12
* </code>
*
* @param mixed $discount 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 ChildCartQuery The current query, for fluid interface
*/
public function filterByDiscount($discount = null, $comparison = null)
{
if (is_array($discount)) {
$useMinMax = false;
if (isset($discount['min'])) {
$this->addUsingAlias(CartTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($discount['max'])) {
$this->addUsingAlias(CartTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartTableMap::DISCOUNT, $discount, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -54,7 +54,7 @@ class Customer extends BaseCustomer implements UserInterface
* @param int $discount
* @throws \Exception|\Symfony\Component\Config\Definition\Exception\Exception
*/
public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email = null, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0)
public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email = null, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0, $company = null)
{
$this
->setTitleId($titleId)
@@ -79,6 +79,7 @@ class Customer extends BaseCustomer implements UserInterface
$address = new Address();
$address
->setCompany($company)
->setTitleId($titleId)
->setFirstname($firstname)
->setLastname($lastname)
@@ -88,6 +89,7 @@ class Customer extends BaseCustomer implements UserInterface
->setPhone($phone)
->setCellphone($cellphone)
->setZipcode($zipcode)
->setCity($city)
->setCountryId($countryId)
->setIsDefault(1)
;
@@ -98,6 +100,7 @@ class Customer extends BaseCustomer implements UserInterface
$address = $this->getDefaultAddress();
$address
->setCompany($company)
->setTitleId($titleId)
->setFirstname($firstname)
->setLastname($lastname)
@@ -107,6 +110,7 @@ class Customer extends BaseCustomer implements UserInterface
->setPhone($phone)
->setCellphone($cellphone)
->setZipcode($zipcode)
->setCity($city)
->setCountryId($countryId)
->save($con)
;
@@ -242,7 +246,7 @@ class Customer extends BaseCustomer implements UserInterface
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECONFIG, new CustomerEvent($this));
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECUSTOMER, new CustomerEvent($this));
return true;
}
@@ -251,6 +255,6 @@ class Customer extends BaseCustomer implements UserInterface
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETECONFIG, new CustomerEvent($this));
$this->dispatchEvent(TheliaEvents::AFTER_DELETECUSTOMER, new CustomerEvent($this));
}
}

View File

@@ -57,7 +57,7 @@ class CartItemTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 10;
const NUM_COLUMNS = 11;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class CartItemTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 10;
const NUM_HYDRATE_COLUMNS = 11;
/**
* the column name for the ID field
@@ -109,6 +109,11 @@ class CartItemTableMap extends TableMap
*/
const PRICE_END_OF_LIFE = 'cart_item.PRICE_END_OF_LIFE';
/**
* the column name for the DISCOUNT field
*/
const DISCOUNT = 'cart_item.DISCOUNT';
/**
* the column name for the CREATED_AT field
*/
@@ -131,12 +136,12 @@ class CartItemTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'Discount', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'discount', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::DISCOUNT, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'discount', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
@@ -146,12 +151,12 @@ class CartItemTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'createdAt' => 8, 'updatedAt' => 9, ),
self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::CREATED_AT => 8, CartItemTableMap::UPDATED_AT => 9, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ),
self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'created_at' => 8, 'updated_at' => 9, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'Discount' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'discount' => 8, 'createdAt' => 9, 'updatedAt' => 10, ),
self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::DISCOUNT => 8, CartItemTableMap::CREATED_AT => 9, CartItemTableMap::UPDATED_AT => 10, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'DISCOUNT' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ),
self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'discount' => 8, 'created_at' => 9, 'updated_at' => 10, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
@@ -178,6 +183,7 @@ class CartItemTableMap extends TableMap
$this->addColumn('PRICE', 'Price', 'FLOAT', false, null, null);
$this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null);
$this->addColumn('PRICE_END_OF_LIFE', 'PriceEndOfLife', 'TIMESTAMP', false, null, null);
$this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, 0);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -351,6 +357,7 @@ class CartItemTableMap extends TableMap
$criteria->addSelectColumn(CartItemTableMap::PRICE);
$criteria->addSelectColumn(CartItemTableMap::PROMO_PRICE);
$criteria->addSelectColumn(CartItemTableMap::PRICE_END_OF_LIFE);
$criteria->addSelectColumn(CartItemTableMap::DISCOUNT);
$criteria->addSelectColumn(CartItemTableMap::CREATED_AT);
$criteria->addSelectColumn(CartItemTableMap::UPDATED_AT);
} else {
@@ -362,6 +369,7 @@ class CartItemTableMap extends TableMap
$criteria->addSelectColumn($alias . '.PRICE');
$criteria->addSelectColumn($alias . '.PROMO_PRICE');
$criteria->addSelectColumn($alias . '.PRICE_END_OF_LIFE');
$criteria->addSelectColumn($alias . '.DISCOUNT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}

View File

@@ -57,7 +57,7 @@ class CartTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 8;
const NUM_COLUMNS = 9;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class CartTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 8;
const NUM_HYDRATE_COLUMNS = 9;
/**
* the column name for the ID field
@@ -99,6 +99,11 @@ class CartTableMap extends TableMap
*/
const CURRENCY_ID = 'cart.CURRENCY_ID';
/**
* the column name for the DISCOUNT field
*/
const DISCOUNT = 'cart.DISCOUNT';
/**
* the column name for the CREATED_AT field
*/
@@ -121,12 +126,12 @@ class CartTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Token', 'CustomerId', 'AddressDeliveryId', 'AddressInvoiceId', 'CurrencyId', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'token', 'customerId', 'addressDeliveryId', 'addressInvoiceId', 'currencyId', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CartTableMap::ID, CartTableMap::TOKEN, CartTableMap::CUSTOMER_ID, CartTableMap::ADDRESS_DELIVERY_ID, CartTableMap::ADDRESS_INVOICE_ID, CartTableMap::CURRENCY_ID, CartTableMap::CREATED_AT, CartTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'TOKEN', 'CUSTOMER_ID', 'ADDRESS_DELIVERY_ID', 'ADDRESS_INVOICE_ID', 'CURRENCY_ID', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'token', 'customer_id', 'address_delivery_id', 'address_invoice_id', 'currency_id', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
self::TYPE_PHPNAME => array('Id', 'Token', 'CustomerId', 'AddressDeliveryId', 'AddressInvoiceId', 'CurrencyId', 'Discount', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'token', 'customerId', 'addressDeliveryId', 'addressInvoiceId', 'currencyId', 'discount', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CartTableMap::ID, CartTableMap::TOKEN, CartTableMap::CUSTOMER_ID, CartTableMap::ADDRESS_DELIVERY_ID, CartTableMap::ADDRESS_INVOICE_ID, CartTableMap::CURRENCY_ID, CartTableMap::DISCOUNT, CartTableMap::CREATED_AT, CartTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'TOKEN', 'CUSTOMER_ID', 'ADDRESS_DELIVERY_ID', 'ADDRESS_INVOICE_ID', 'CURRENCY_ID', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'token', 'customer_id', 'address_delivery_id', 'address_invoice_id', 'currency_id', 'discount', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -136,12 +141,12 @@ class CartTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Token' => 1, 'CustomerId' => 2, 'AddressDeliveryId' => 3, 'AddressInvoiceId' => 4, 'CurrencyId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'token' => 1, 'customerId' => 2, 'addressDeliveryId' => 3, 'addressInvoiceId' => 4, 'currencyId' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
self::TYPE_COLNAME => array(CartTableMap::ID => 0, CartTableMap::TOKEN => 1, CartTableMap::CUSTOMER_ID => 2, CartTableMap::ADDRESS_DELIVERY_ID => 3, CartTableMap::ADDRESS_INVOICE_ID => 4, CartTableMap::CURRENCY_ID => 5, CartTableMap::CREATED_AT => 6, CartTableMap::UPDATED_AT => 7, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TOKEN' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_DELIVERY_ID' => 3, 'ADDRESS_INVOICE_ID' => 4, 'CURRENCY_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
self::TYPE_FIELDNAME => array('id' => 0, 'token' => 1, 'customer_id' => 2, 'address_delivery_id' => 3, 'address_invoice_id' => 4, 'currency_id' => 5, 'created_at' => 6, 'updated_at' => 7, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
self::TYPE_PHPNAME => array('Id' => 0, 'Token' => 1, 'CustomerId' => 2, 'AddressDeliveryId' => 3, 'AddressInvoiceId' => 4, 'CurrencyId' => 5, 'Discount' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'token' => 1, 'customerId' => 2, 'addressDeliveryId' => 3, 'addressInvoiceId' => 4, 'currencyId' => 5, 'discount' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
self::TYPE_COLNAME => array(CartTableMap::ID => 0, CartTableMap::TOKEN => 1, CartTableMap::CUSTOMER_ID => 2, CartTableMap::ADDRESS_DELIVERY_ID => 3, CartTableMap::ADDRESS_INVOICE_ID => 4, CartTableMap::CURRENCY_ID => 5, CartTableMap::DISCOUNT => 6, CartTableMap::CREATED_AT => 7, CartTableMap::UPDATED_AT => 8, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TOKEN' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_DELIVERY_ID' => 3, 'ADDRESS_INVOICE_ID' => 4, 'CURRENCY_ID' => 5, 'DISCOUNT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
self::TYPE_FIELDNAME => array('id' => 0, 'token' => 1, 'customer_id' => 2, 'address_delivery_id' => 3, 'address_invoice_id' => 4, 'currency_id' => 5, 'discount' => 6, 'created_at' => 7, 'updated_at' => 8, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -166,6 +171,7 @@ class CartTableMap extends TableMap
$this->addForeignKey('ADDRESS_DELIVERY_ID', 'AddressDeliveryId', 'INTEGER', 'address', 'ID', false, null, null);
$this->addForeignKey('ADDRESS_INVOICE_ID', 'AddressInvoiceId', 'INTEGER', 'address', 'ID', false, null, null);
$this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', false, null, null);
$this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, 0);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -339,6 +345,7 @@ class CartTableMap extends TableMap
$criteria->addSelectColumn(CartTableMap::ADDRESS_DELIVERY_ID);
$criteria->addSelectColumn(CartTableMap::ADDRESS_INVOICE_ID);
$criteria->addSelectColumn(CartTableMap::CURRENCY_ID);
$criteria->addSelectColumn(CartTableMap::DISCOUNT);
$criteria->addSelectColumn(CartTableMap::CREATED_AT);
$criteria->addSelectColumn(CartTableMap::UPDATED_AT);
} else {
@@ -348,6 +355,7 @@ class CartTableMap extends TableMap
$criteria->addSelectColumn($alias . '.ADDRESS_DELIVERY_ID');
$criteria->addSelectColumn($alias . '.ADDRESS_INVOICE_ID');
$criteria->addSelectColumn($alias . '.CURRENCY_ID');
$criteria->addSelectColumn($alias . '.DISCOUNT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}

View File

@@ -45,29 +45,34 @@ trait PositionManagementTrait {
return $class->getConstant('DATABASE_NAME');
}
/**
* Implementors may add some search criteria (e.g., parent id) to the queries
* used to change/get position by overloading this method.
*/
protected function addCriteriaToPositionQuery($query) {
// Add required criteria here...
}
/**
* Get the position of the next inserted object
*/
public function getNextPosition($parent = null) {
public function getNextPosition() {
$query = $this->createQuery()
->orderByPosition(Criteria::DESC)
->limit(1);
if ($parent !== null) $query->filterByParent($parent);
$this->addCriteriaToPositionQuery($query);
$last = $query->findOne()
;
$last = $query->findOne();
return $last != null ? $last->getPosition() + 1 : 1;
return $last != null ? $last->getPosition() + 1 : 1;
}
/**
* Move up a object
*/
public function movePositionUp() {
echo "move up !";
$this->movePositionUpOrDown(true);
}
@@ -91,7 +96,7 @@ trait PositionManagementTrait {
// Find object to exchange position with
$search = $this->createQuery();
if (method_exists($this, 'getParent')) $search->filterByParent($this->getParent());
$this->addCriteriaToPositionQuery($search);
// Up or down ?
if ($up === true) {
@@ -152,7 +157,7 @@ trait PositionManagementTrait {
// Find categories to offset
$search = $this->createQuery();
if (method_exists($this, 'getParent')) $search->filterByParent($this->getParent());
$this->addCriteriaToPositionQuery($search);
if ($newPosition > $current_position) {
// The new position is after the current position -> we will offset + 1 all categories located between us and the new position

View File

@@ -0,0 +1,102 @@
<?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 Thelia\Tests\Action\ImageTest;
use Thelia\Action\Customer;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
/**
* Class CustomerTest
* @package Thelia\Tests\Action\ImageTest
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CustomerTest extends \PHPUnit_Framework_TestCase
{
public function getContainer()
{
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
$container->set("event_dispatcher", $dispatcher);
return $container;
}
public function testCreatedCustomer()
{
$customerCreateEvent = new CustomerCreateOrUpdateEvent(
1,
"thelia",
"thelia",
"street address 1",
"street address 2",
"street address 3",
"0102030405",
"0607080910",
"63000",
"clermont-ferrand",
64,
sprintf("%s@thelia.fr", uniqid()),
uniqid(),
1,
0,
0,
0,
'My super company'
);
$customerAction = new Customer($this->getContainer());
$customerAction->create($customerCreateEvent);
$customerCreated = $customerCreateEvent->getCustomer();
$this->assertInstanceOf("Thelia\Model\Customer", $customerCreated, "new customer created must be an instance of Thelia\Model\Customer");
$this->assertFalse($customerCreated->isNew());
$this->assertEquals($customerCreateEvent->getFirstname(), $customerCreated->getFirstname());
$this->assertEquals($customerCreateEvent->getLastname(), $customerCreated->getLastname());
$this->assertEquals($customerCreateEvent->getTitle(), $customerCreated->getTitleId());
$this->assertEquals($customerCreateEvent->getEmail(), $customerCreated->getEmail());
$this->assertEquals($customerCreated->getReseller(), $customerCreated->getReseller());
$this->assertEquals($customerCreated->getSponsor(), $customerCreated->getSponsor());
$this->assertEquals($customerCreated->getDiscount(), $customerCreated->getDiscount());
$addressCreated = $customerCreated->getDefaultAddress();
$this->assertEquals($customerCreateEvent->getFirstname(), $addressCreated->getFirstname());
$this->assertEquals($customerCreateEvent->getLastname(), $addressCreated->getLastname());
$this->assertEquals($customerCreateEvent->getTitle(), $addressCreated->getTitleId());
$this->assertEquals($customerCreateEvent->getAddress1(), $addressCreated->getAddress1());
$this->assertEquals($customerCreateEvent->getAddress2(), $addressCreated->getAddress2());
$this->assertEquals($customerCreateEvent->getAddress3(), $addressCreated->getAddress3());
$this->assertEquals($customerCreateEvent->getZipcode(), $addressCreated->getZipcode());
$this->assertEquals($customerCreateEvent->getCity(), $addressCreated->getCity());
$this->assertEquals($customerCreateEvent->getCountry(), $addressCreated->getCountryId());
$this->assertEquals($customerCreateEvent->getPhone(), $addressCreated->getPhone());
$this->assertEquals($customerCreateEvent->getCellphone(), $addressCreated->getCellphone());
$this->assertEquals($customerCreateEvent->getCompany(), $addressCreated->getCompany());
}
}

View File

@@ -156,6 +156,45 @@ try {
"azerty"
);
for($i = 0; $i < 50; $i++) {
$customer = new Thelia\Model\Customer();
$customer->createOrUpdate(
rand(1,3),
$faker->firstname,
$faker->lastname,
$faker->streetAddress,
$faker->streetAddress,
$faker->streetAddress,
$faker->phoneNumber,
$faker->phoneNumber,
$faker->postcode,
$faker->city,
64,
$faker->email,
"azerty".$i
);
for ($j = 0; $j <= 3; $j++) {
$address = new Thelia\Model\Address();
$address->setLabel($faker->text(20))
->setTitleId(rand(1,3))
->setFirstname($faker->firstname)
->setLastname($faker->lastname)
->setAddress1($faker->streetAddress)
->setAddress2($faker->streetAddress)
->setAddress3($faker->streetAddress)
->setCellphone($faker->phoneNumber)
->setPhone($faker->phoneNumber)
->setZipcode($faker->postcode)
->setCity($faker->city)
->setCountryId(64)
->setCustomer($customer)
->save()
;
}
}
//features and features_av
$featureList = array();
for($i=0; $i<4; $i++) {

View File

@@ -32,10 +32,10 @@ INSERT INTO `customer_title`(`id`, `by_default`, `position`, `created_at`, `upda
INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES
(1, 'fr_FR', 'Mr', 'Monsieur'),
(1, 'en_US', 'M', 'Mister'),
(2, 'fr_FR', 'Mrs', 'Madame'),
(2, 'en_US', 'Mme', 'Misses'),
(3, 'fr_FR', 'Miss', 'Madamemoiselle'),
(3, 'en_US', 'Mlle', 'Miss');
(2, 'fr_FR', 'Mme', 'Madame'),
(2, 'en_US', 'Mrs', 'Misses'),
(3, 'fr_FR', 'Mlle', 'Madamemoiselle'),
(3, 'en_US', 'Miss', 'Miss');
INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate`, `position` ,`by_default` ,`created_at` ,`updated_at`)
VALUES

View File

@@ -1153,6 +1153,7 @@ CREATE TABLE `cart`
`address_delivery_id` INTEGER,
`address_invoice_id` INTEGER,
`currency_id` INTEGER,
`discount` FLOAT DEFAULT 0,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
@@ -1191,6 +1192,7 @@ CREATE TABLE `cart_item`
`price` FLOAT,
`promo_price` FLOAT,
`price_end_of_life` DATETIME,
`discount` FLOAT DEFAULT 0,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),

View File

@@ -870,6 +870,7 @@
<column name="address_delivery_id" type="INTEGER" />
<column name="address_invoice_id" type="INTEGER" />
<column name="currency_id" type="INTEGER" />
<column defaultValue="0" name="discount" type="FLOAT" />
<foreign-key foreignTable="customer" name="fk_cart_customer_id">
<reference foreign="id" local="customer_id" />
</foreign-key>
@@ -908,6 +909,7 @@
<column name="price" type="FLOAT" />
<column name="promo_price" type="FLOAT" />
<column name="price_end_of_life" type="TIMESTAMP" />
<column defaultValue="0" name="discount" type="FLOAT" />
<foreign-key foreignTable="cart" name="fk_cart_item_cart_id">
<reference foreign="id" local="cart_id" />
</foreign-key>

View File

@@ -27,16 +27,15 @@
</div>
<div class="col-md-12">
<div class="form-container">
<div class="form-container">
{form name="thelia.admin.attribute.modification"}
<form method="POST" action="{url path='/admin/configuration/attributes/save'}" {form_enctype form=$form} class="clearfix">
{include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/attributes'}"}
{include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/attributes'}"}
<div class="col-md-6">
<div class="col-md-6">
<p class="title title-without-tabs">{intl l='Attribute information'}</p>
{form name="thelia.admin.attribute.modification"}
<form method="POST" action="{url path='/admin/configuration/attributes/save'}" {form_enctype form=$form} class="clearfix">
<p class="title title-without-tabs">{intl l='Attribute information'}</p>
{* Be sure to get the attribute ID, even if the form could not be validated *}
<input type="hidden" name="attribute_id" value="{$attribute_id}" />
@@ -53,114 +52,116 @@
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{include file="includes/standard-description-form-fields.html"}
{include file="includes/standard-description-form-fields.html"}
</div>
</form>
{/form}
<div class="col-md-6">
</div>
<p class="title title-without-tabs">
<div class="col-md-6">
{intl l='Attribute values'}
<p class="title title-without-tabs">
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attribute-av.create"}
<span class="pull-right">
<a data-toggle="modal" href="#creation_dialog" title="Add a new attribute value" class="btn btn-default btn-primary">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
</span>
{/loop}
</p>
{intl l='Attribute values'}
<div class="alert alert-info">
{intl l="Enter here all possible attribute values."}
</div>
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attribute-values.create"}
<span class="pull-right">
<a data-toggle="modal" href="#creation_dialog" title="Add a new attribute value" class="btn btn-default btn-primary">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
</span>
{/loop}
</p>
<table class="table table-striped table-condensed table-left-aligned">
<thead>
<tr>
<th>
{admin_sortable_header
current_order=$order
order='id'
reverse_order='id_reverse'
path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id}
label="{intl l='ID'}"
}
</th>
<div class="alert alert-info">
{intl l="Enter here all possible attribute values. If you don't enter any value, you will be able to set a free value to this attribute on the product form."}
</div>
<th>
{admin_sortable_header
current_order=$order
order='alpha'
reverse_order='alpha_reverse'
path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id}
label="{intl l='Value'}"
}
</th>
<table class="table table-striped table-condensed table-left-aligned">
<thead>
<tr>
<th>
{admin_sortable_header
current_order=$order
order='id'
reverse_order='id_reverse'
path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id}
label="{intl l='ID'}"
}
</th>
<th class="text-center">
{admin_sortable_header
current_order=$order
order='manual'
reverse_order='manual_reverse'
path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id}
label="{intl l="Position"}"
}
</th>
<th>
{admin_sortable_header
current_order=$order
order='alpha'
reverse_order='alpha_reverse'
path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id}
label="{intl l='Value'}"
}
</th>
{module_include location='attributes_value_table_header'}
<th class="text-center">
{admin_sortable_header
current_order=$order
order='manual'
reverse_order='manual_reverse'
path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id}
label="{intl l="Position"}"
}
</th>
<th class="actions">{intl l="Actions"}</th>
</tr>
</thead>
{module_include location='attributes_value_table_header'}
<tbody>
{loop name="list" type="attribute_availability" attribute=$attribute_id backend_context="1" lang=$edit_language_id order=$order}
<tr>
<td>{$ID}</td>
<th class="actions">{intl l="Actions"}</th>
</tr>
</thead>
<td>
<input class="js-edit form-control" type="text" name="" value="{$TITLE}" />
</td>
<tbody>
{loop name="list" type="attribute_availability" attribute=$attribute_id backend_context="1" lang=$edit_language_id order=$order}
<tr>
<td>{$ID}</td>
<td class="text-center">
{admin_position_block
permission="admin.attributes.edit"
path={url path='/admin/configuration/attributes-av/update-position' attribute_id=$attribute_id}
url_parameter="attributeav_id"
in_place_edit_class="positionChange"
position="$POSITION"
id="$ID"
}
</td>
<td>
<input class="js-edit form-control" type="text" name="" value="{$TITLE}" />
</td>
{module_include location='attributes_value_table_row'}
<td class="text-center">
{admin_position_block
permission="admin.attributes.edit"
path="/admin/configuration/attributes/update-value-position"
url_parameter="attribute_id"
in_place_edit_class="positionChange"
position="$POSITION"
id="$ID"
}
</td>
<td class="actions">
<div class="btn-group">
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attribute-av.delete"}
<a class="btn btn-default btn-xs value-delete" title="{intl l='Delete this value'}" href="#delete_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
{module_include location='attributes_value_table_row'}
<td class="actions">
<div class="btn-group">
<a class="btn btn-default btn-xs value-delete" title="{intl l='Delete this value'}" href="#delete_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
</div>
</td>
</tr>
{/loop}
{elseloop rel="list"}
<tr>
<td colspan="4">
<div class="alert alert-info">
{intl l="No product attribute has been created yet. Click the + button to create one."}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
{elseloop rel="list"}
<tr>
<td colspan="4">
<div class="alert alert-info">
{intl l="No product attribute has been created yet. Click the + button to create one."}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</form>
{/form}
</div>
</div>
</div>
</div>
@@ -184,7 +185,7 @@
{* Adding a new attribute *}
{form name="thelia.admin.attribute-value.creation"}
{form name="thelia.admin.attributeav.creation"}
{* Capture the dialog body, to pass it to the generic dialog *}
@@ -235,7 +236,7 @@
dialog_ok_label = {intl l="Create this value"}
form_action = {url path='/admin/configuration/attributes/create-value'}
form_action = {url path='/admin/configuration/attributes-av/create'}
form_enctype = {form_enctype form=$form}
form_error_message = $form_error_message
}
@@ -244,7 +245,8 @@
{* Delete value confirmation dialog *}
{capture "delete_dialog"}
<input type="hidden" name="attribute_value_id" id="value_delete_id" value="" />
<input type="hidden" name="attribute_id" value="{$attribute_id}" />
<input type="hidden" name="attributeav_id" id="value_delete_id" value="" />
{/capture}
{include
@@ -254,7 +256,7 @@
dialog_title = {intl l="Delete attribute value"}
dialog_message = {intl l="Do you really want to delete this attribute value ?"}
form_action = {url path='/admin/configuration/attributes/delete-value'}
form_action = {url path='/admin/configuration/attributes-av/delete'}
form_content = {$smarty.capture.delete_dialog nofilter}
}
@@ -278,7 +280,7 @@
{include
file = "includes/generic-js-dialog.html"
dialog_id = "creation_dialog"
form_name = "thelia.admin.attribute-value.creation"
form_name = "thelia.admin.attributeav.creation"
}
{* Inline editing of object position using bootstrap-editable *}
@@ -291,7 +293,7 @@
placement : 'left',
success : function(response, newValue) {
// The URL template
var url = "{url path='/admin/configuration/attributes/update-value-position' attribute_value_id='__ID__' position='__POS__'}";
var url = "{url path='/admin/configuration/attributes-av/update-position' attributeav_id='__ID__' position='__POS__' attribute_id=$attribute_id}";
// Perform subtitutions
url = url.replace('__ID__', $(this).data('id')).replace('__POS__', newValue);

View File

@@ -29,17 +29,18 @@
<div class="col-md-12">
{form name="thelia.customer.modification"}
<form method="POST" action="{url path='/admin/customers/save'}" {form_enctype form=$form} class="clearfix">
{* Be sure to get the customer ID, even if the form could not be validated *}
<input type="hidden" name="customer_id" value="{$customer_id}" />
{include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/customers'}"}
<form method="POST" action="{url path="/admin/customer/update/{$ID}"}" {form_enctype form=$form} class="clearfix">
<div class="row inner-toolbar clearfix">
<div class="col-md-6 inner-actions pull-right">
<button type="submit" name="save_mode" value="stay" class="btn btn-default btn-primary" title="{intl l='Save'}">{intl l='Save'} <span class="glyphicon glyphicon-ok"></span></button>
<button type="submit" name="save_mode" value="close" class="btn btn-default btn-info" title="{intl l='Save and close'}">{intl l='Save and close'} <span class="glyphicon glyphicon-remove"></span></button>
</div>
</div>
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/customers'}" />
<input type="hidden" name="{$name}" value="{url path="/admin/customer/update/{$ID}"}" />
{/form_field}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
@@ -52,8 +53,8 @@
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
{loop type="title" name="title1"}
<option value="{$ID}">{$LONG}</option>
{loop type="title" name="title1" backend_context="1"}
<option value="{$ID}" {if $ID == $TITLE}selected{/if}>{$LONG}</option>
{/loop}
</select>
</div>
@@ -77,6 +78,13 @@
<p class="title title-without-tabs">{intl l="Default address"}</p>
{form_field form=$form field='company'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$COMPANY}" title="{intl l="{$label}"}" placeholder="{intl l='Company'}">
</div>
{/form_field}
{form_field form=$form field='address1'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
@@ -143,67 +151,20 @@
</tr>
</thead>
<tbody>
{loop name="address" type="address" customer="$customer_id" backend_context="1" default="0"}
<tr>
<td>
<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
</address>
</td>
<td>
<div class="btn-group">
<a class="btn btn-default btn-xs" title="{intl l='Edit this address'}" href="#edit_address_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl l='Use this address by default'}" href="#use_address_dialog" data-toggle="modal" rel="tooltip">
<span class="glyphicon glyphicon-pushpin"></span>
</a>
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_address_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
<tr>
<td>
<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
</address>
</td>
<td>
<div class="btn-group">
<a class="btn btn-default btn-xs" title="{intl l='Edit this address'}" href="#edit_address_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl l='Use this address by default'}" href="#use_address_dialog" data-toggle="modal" rel="tooltip">
<span class="glyphicon glyphicon-pushpin"></span>
</a>
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_address_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
<tr>
<td>
<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
<strong>{loop name="address.title" type="title" id=$TITLE}{$SHORT}{/loop} {$FIRSTNAME} {$LASTNAME}</strong><br>
{$ADDRESS1}<br>
{$ADDRESS2}<br>
{$ADDRESS3}<br>
{if $PHONE}
<abbr title="{intl l="Phone"}">P:</abbr> {$PHONE}<br>
{/if}
{if $CELLPHONE}
<abbr title="{intl l="cell phone"}">P:</abbr> {$CELLPHONE}
{/if}
</address>
</td>
<td>
@@ -224,6 +185,7 @@
</div>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>

View File

@@ -128,12 +128,13 @@
<li class="active"><a href="#">{$PAGE}</a></li>
{/if}
{/pageloop}
{if $PAGE == $LAST && $LAST != $CURRENT}
<li><a href="{url path="/admin/customers" page="$PAGE"}">&raquo;</a></li>
{else}
<li class="disabled"><a href="#">&raquo;</a></li>
{/if}
{/pageloop}
</ul>
</div>
@@ -259,7 +260,8 @@
{* Delete confirmation dialog *}
{capture "delete_customer_dialog"}
<input type="hidden" name="customer_id" id="customer_delete_id" value="" />
<input type="hidden" name="customer_page" value="{$customer_page}">
<input type="hidden" name="customer_id" id="delete_customer_id">
{/capture}
{include
@@ -270,7 +272,18 @@
dialog_message = {intl l="Do you really want to delete this customer ?"}
form_action = {url path='/admin/customer/delete'}
form_content = {$smarty.capture.delete_dialog nofilter}
form_content = {$smarty.capture.delete_customer_dialog nofilter}
form_id = "form_delete_customer"
}
{/block}
{block name="javascript-initialization"}
<script type="text/javascript">
$(".customer-delete").click(function(){
$("#delete_customer_id").val($(this).attr("data-id"));
});
</script>
{/block}

View File

@@ -14,6 +14,7 @@ Parameters:
form_action = the form action URL, subtitted by a click on OK button
form_method = the form method, default "POST"
form_content = the form content
form_id = the form id
*}
<div class="modal fade" id="{$dialog_id}" tabindex="-1" role="dialog" aria-hidden="true">
@@ -28,7 +29,7 @@ Parameters:
{$dialog_message nofilter}
</div>
<form method="{$form_method|default:POST}" action="{$form_action}">
<form method="{$form_method|default:POST}" action="{$form_action}" id="{$form_id}">
{$form_content nofilter}

View File

@@ -0,0 +1,175 @@
{extends file="layout.tpl"}
{block name="breadcrumb"}
<nav class="nav-breadcrumb" role="navigation" aria-labelledby="breadcrumb-label">
<strong id="breadcrumb-label">{intl l="You are here"}: </strong>
<ul class="breadcrumb" itemprop="breadcrumb">
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="index.php" itemprop="url"><span itemprop="title">{intl l="Home"}</span></a></li>
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="active"><span itemprop="title">{intl l="Account"}</span></li>
</ul>
</nav><!-- /.nav-breadcrumb -->
{/block}
{block name="main-content"}
<div class="main">
<article class="col-main" role="main" aria-labelledby="main-label">
<h1 id="main-label" class="page-header">{intl l="My Account"}</h1>
<div id="account" class="panel-group">
<div class="panel account-info">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#account" href="#account-info">
{intl l="Personal Informations"}
</a>
</h4>
</div>
<div id="account-info" class="panel-collapse collapse in">
{loop type="customer" name="customer.info"}
<div class="panel-body">
<p class="fn">{loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$FIRSTNAME} {$LASTNAME}</p>
{loop type="address" name="address.default" default="true"}
<ul class="list-info">
<li>
<address class="adr">
<span class="street-address">{$ADDRESS1}</span><br>
{if $ADDRESS2 != ""}
<span class="street-address">{$ADDRESS2}</span><br>
{/if}
{if $ADDRESS3 != ""}
<span class="street-address">{$ADDRESS3}</span><br>
{/if}
<span class="postal-code">{$ZIPCODE}</span>
<span class="locality">{$CITY}, <span class="country-name">{loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop}</span></span>
</address>
</li>
<li>
{if $CELLPHONE != ""}
<span class="tel">{$CELLPHONE}</span>
{/if}
{if $PHONE != ""}
<span class="tel">{$PHONE}</span>
{/if}
<span class="email"><a href="mailto:{$EMAIL}">{$EMAIL}</a></span>
</li>
<li class="group-btn">
<a href="#" class="btn btn-change-account"><i class="icon-pencil"></i> Change my account informations</a>
<a href="#" class="btn btn-change-password"><i class="icon-lock"></i> Change my password</a>
</li>
</ul>
{/loop}
</div>
{/loop}
</div>
</div>
<div class="panel account-address">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#account" href="#account-address">
{intl l="My Address book"}
</a>
</h4>
</div>
<div id="account-address" class="panel-collapse collapse">
<div class="panel-body">
<a href="address.php" class="btn btn-add-address">{intl l="Add a new address"}</a>
<table class="table table-address" role="presentation" summary="{intl l="My Address Books"}">
<tbody>
{loop type="address" name="customer.addresses"}
<tr class="{if $DEFAULT == 1}address-primary{else}address-additional{/if}">
<th>{$LABEL}</th>
<td>
<ul class="list-address">
<li>
<span class="fn">{loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$FIRSTNAME} {$LASTNAME}</span>
{if $COMPANY}
<span class="org">{$COMPANY}</span>
{/if}
</li>
<li>
<address class="adr">
<span class="street-address">{$ADDRESS1}</span><br>
{if $ADDRESS2 != ""}
<span class="street-address">{$ADDRESS2}</span><br>
{/if}
{if $ADDRESS3 != ""}
<span class="street-address">{$ADDRESS3}</span><br>
{/if}
<span class="postal-code">{$ZIPCODE}</span>
<span class="locality">{$CITY}, <span class="country-name">{loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop}</span></span>
</address>
</li>
<li>
{if $CELLPHONE != ""}
<span class="tel">{$CELLPHONE}</span><br>
{/if}
{if $PHONE != ""}
<span class="tel">{$PHONE}</span><br>
{/if}
</li>
</ul>
</td>
<td>
<div class="group-btn">
<a href="{url path="/address/edit/{$ID}"}" class="btn btn-edit-address" data-toggle="tooltip" title="Edit this address"><i class="icon-pencil"></i> <span>{intl l="Edit"}</span></a>
{if $DEFAULT != 1}
<a href="#" class="btn btn-remove-address" data-toggle="tooltip" title="Remove this address"><i class="icon-remove"></i> <span>{intl l="Cancel"}</span></a>
{/if}
</div>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
</div>
</div>
<div class="panel account-orders">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#account" href="#account-orders">
{intl l="My Orders"}
</a>
</h4>
</div>
<div id="account-orders" class="panel-collapse collapse">
<div class="panel-body table-responsive">
<table class="table table-orders" summary="{intl l="List of orders"}">
<thead>
<tr>
<th>{intl l="Order Number"}</th>
<th>{intl l="Date"}</th>
<th>{intl l="Amount"}</th>
<th>{intl l="Status"}</th>
<th>{intl l="View"}</th>
</tr>
</thead>
<tbody>
{loop type="order" name="customer.orders"}
<tr>
<td>{$REF}</td>
<td>{format_date date=$CREATED_AT}</td>
<td>{loop type="currency" name="order.currency" id={$CURRENCY}}{$SYMBOL}{/loop} {format_number number=$TOTAL}</td>
<td><span class="label-delivered">{$STATUS}</span></td>
<td><a href="#" class="btn btn-order-details" data-toggle="tooltip" title="{intl l="View order %ref as pdf document" ref={$REF}}"><span class="icon-cloud-download"></span> {intl l="Order details"}</a></td>
</tr>
{/loop}
</tbody>
</table>
{elseloop rel="customer.orders"}
<div class="orders-warning">
<strong>{intl l="Warning"}!</strong> {intl l="You don't have orders yet"}
</div>
{/elseloop}
</div>
</div>
</div>
</div>
</article>
</div><!-- /.layout -->
{/block}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B