From be7d8500e2eba057605eaf3f9f8107e338afe369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristo=20Est=C3=A9vez?= Date: Tue, 15 Jan 2019 10:12:48 +0000 Subject: [PATCH 1/2] Added button on EditContacto to create a customer using an existing contact. --- Core/Controller/EditContacto.php | 25 +++++++++++++++++++++++++ Core/XMLView/EditContacto.xml | 5 +++++ 2 files changed, 30 insertions(+) diff --git a/Core/Controller/EditContacto.php b/Core/Controller/EditContacto.php index 983863fa1a..03f8cadda7 100644 --- a/Core/Controller/EditContacto.php +++ b/Core/Controller/EditContacto.php @@ -19,11 +19,13 @@ namespace FacturaScripts\Core\Controller; use FacturaScripts\Core\Lib\ExtendedController; +use FacturaScripts\Core\Model\Contacto; /** * Controller to edit a single item from the Contacto model * * @author Carlos García Gómez + * @author Cristo M. Estévez Hernández */ class EditContacto extends ExtendedController\EditController { @@ -61,4 +63,27 @@ public function getPageData() return $pagedata; } + + /** + * Run the controller after actions + * + * @param string $action + */ + protected function execAfterAction($action) + { + switch ($action) { + case 'convert-to-customer': + $code = $this->request->request->get('code', ''); + $contact = new Contacto(); + $contact->loadFromCode($code); + + $customer = $contact->getCustomer(); + if(empty($customer->codcliente)) { + $this->miniLog->error($this->i18n->trans('problem-storage-customer')); + } else { + $this->miniLog->info($this->i18n->trans('customer-created')); + } + break; + } + } } diff --git a/Core/XMLView/EditContacto.xml b/Core/XMLView/EditContacto.xml index 9f1c6b850e..51d6a6f415 100644 --- a/Core/XMLView/EditContacto.xml +++ b/Core/XMLView/EditContacto.xml @@ -117,4 +117,9 @@ + + +