* Date: 21/07/2016 22:40 */ namespace RibClient\Controller; use RibClient\Model\RibClient; use RibClient\Model\RibClientQuery; use Thelia\Controller\Admin\BaseAdminController; use Thelia\Core\Event\Newsletter\NewsletterEvent; use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Security\AccessManager; use Thelia\Core\Security\Resource\AdminResources; use Thelia\Form\Exception\FormValidationException; use Thelia\Model\CustomerQuery; use Thelia\Model\NewsletterQuery; use Thelia\Model\Order; use Thelia\Model\OrderQuery; use Thelia\Model\OrderStatusQuery; use Thelia\Tools\URL; class ConfigurationController extends BaseAdminController { public function configureCustomer($customerId) { $error_msg = false; if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'RibClient', AccessManager::UPDATE)) { return $response; } $configurationForm = $this->createForm('rib_client.form.configure_customer'); try { $form = $this->validateForm($configurationForm, "POST"); // Get the form field values $data = $form->getData(); if (null === $ribClient = RibClientQuery::create()->findOneByCustomerId($customerId)) { $ribClient = (new RibClient())->setCustomerId($customerId); } $ribClient ->setEcheance($data['echeance']) ->save() ; } catch (FormValidationException $ex) { $error_msg = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { $error_msg = $ex->getMessage(); } if ($error_msg) { $this->setupFormErrorContext( $this->getTranslator()->trans("Echéance client", [], \RibClient\RibClient::DOMAIN_NAME), $error_msg, $configurationForm, $ex ); } return $this->generateRedirect( URL::getInstance()->absoluteUrl( '/admin/customer/update', [ 'customer_id' => $customerId ] ) . '#RibClient' ); } }