Merge branch 'template'
Conflicts: templates/admin/default/customer-edit.html
This commit is contained in:
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,20 @@
|
||||
<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 -->
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -56,8 +75,9 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
102
core/lib/Thelia/Tests/Action/CustomerTest.php
Normal file
102
core/lib/Thelia/Tests/Action/CustomerTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"}">»</a></li>
|
||||
{else}
|
||||
<li class="disabled"><a href="#">»</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}
|
||||
@@ -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}
|
||||
|
||||
|
||||
175
templates/default/account.html
Normal file
175
templates/default/account.html
Normal 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}
|
||||
BIN
tests/functionnal/casperjs/pictures/screenshot-category-rule.png
Normal file
BIN
tests/functionnal/casperjs/pictures/screenshot-category-rule.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 582 B |
Reference in New Issue
Block a user