diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index ca0ce3652..d0c96eef5 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -28,6 +28,7 @@ use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\BaseForm; use Thelia\Form\CustomerCreation; +use Thelia\Log\Tlog; class Customer implements EventSubscriberInterface { @@ -48,6 +49,26 @@ class Customer implements EventSubscriberInterface $form->bind($request); if ($form->isValid()) { + $data = $form->getData(); + $customer = new \Thelia\Model\Customer(); + try { + $customer->createOrUpdate( + $data["title"], + $data["firstname"], + $data["lastname"], + $data["address1"], + $data["address2"], + $data["address3"], + $data["phone"], + $data["cellphone"], + $data["zipcode"], + $data["country"], + $data["email"], + $data["password"] + ); + } catch (\PropelException $e) { + Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); + } echo "ok"; exit; } else { diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 4edd5628e..e2816edc0 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -85,6 +85,12 @@ class CustomerCreation extends BaseForm ), "label" => "country" )) + ->add("title", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "title" + )) ->add("email", "email", array( "constraints" => array( new Constraints\NotBlank(), diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 885d867b0..b78a09cd0 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -18,9 +18,10 @@ use Thelia\Model\om\BaseCustomer; */ class Customer extends BaseCustomer { - public function create($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) + public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) { $this + ->setCustomerTitleId($titleId) ->setFirstname($firstname) ->setLastname($lastname) ->setAddress1($address1) @@ -35,6 +36,7 @@ class Customer extends BaseCustomer ->setReseller($reseller) ->setSponsor($sponsor) ->setDiscount($discount) + ->save() ; } diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html index 45ad06a3d..44b13386e 100644 --- a/templates/smarty-sample/connexion.html +++ b/templates/smarty-sample/connexion.html @@ -4,6 +4,21 @@
{form_field_hidden form=$form} + + {form_field form=$form.title} + {form_error form=$form.title} + {$message} + {/form_error} + + + +
+ {/form_field} + {form_field form=$form.firstname} {form_error form=$form.firstname} {$message}