diff --git a/Extension/Controller/EditAsiento.php b/Extension/Controller/EditAsiento.php new file mode 100644 index 0000000..4ec25f5 --- /dev/null +++ b/Extension/Controller/EditAsiento.php @@ -0,0 +1,47 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +namespace FacturaScripts\Plugins\Proyectos\Extension\Controller; + +use Closure; +use FacturaScripts\Dinamic\Model\Proyecto; +use FacturaScripts\Plugins\Proyectos\Extension\Traits\ProjectControllerSalesPurchases; + +/** + * @author Esteban Sánchez Martínez + */ + +class EditAsiento +{ + use ProjectControllerSalesPurchases; + + public function createViews(): Closure + { + return function () { + $this->views['main']->template = '@PluginProyectos/Tab/AccountingEntry.html.twig'; + }; + } + + public function getProyectos(): Closure + { + return function () { + return Proyecto::all([], ['nombre' => 'ASC'], 0, 0); + }; + } +} diff --git a/Extension/Model/Asiento.php b/Extension/Model/Asiento.php new file mode 100644 index 0000000..4b77742 --- /dev/null +++ b/Extension/Model/Asiento.php @@ -0,0 +1,49 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +namespace FacturaScripts\Plugins\Proyectos\Extension\Model; + +use Closure; + +/** + * @author Esteban Sánchez Martínez + */ + +class Asiento +{ + public function saveInsertBefore(): Closure + { + return function () { + $data = json_decode($_POST['data'] ?? '{}', true); + if (array_key_exists('idproyecto', $data)) { + $this->idproyecto = empty($data['idproyecto']) ? null : (int)$data['idproyecto']; + } + }; + } + + public function saveUpdateBefore(): Closure + { + return function () { + $data = json_decode($_POST['data'] ?? '{}', true); + if (array_key_exists('idproyecto', $data)) { + $this->idproyecto = empty($data['idproyecto']) ? null : (int)$data['idproyecto']; + } + }; + } +} diff --git a/Extension/XMLView/EditAsiento.xml b/Extension/XMLView/EditAsiento.xml deleted file mode 100644 index 1c63766..0000000 --- a/Extension/XMLView/EditAsiento.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Init.php b/Init.php index 226bb91..6b37716 100644 --- a/Init.php +++ b/Init.php @@ -51,6 +51,7 @@ final class Init extends InitClass public function init(): void { $this->loadExtension(new Extension\Controller\DocumentStitcher()); + $this->loadExtension(new Extension\Controller\EditAsiento()); $this->loadExtension(new Extension\Controller\EditAlbaranCliente()); $this->loadExtension(new Extension\Controller\EditAlbaranProveedor()); $this->loadExtension(new Extension\Controller\EditCliente()); @@ -71,6 +72,7 @@ public function init(): void $this->loadExtension(new Extension\Controller\ListPresupuestoCliente()); $this->loadExtension(new Extension\Controller\ListPresupuestoProveedor()); $this->loadExtension(new Extension\Controller\NewServicioAT()); + $this->loadExtension(new Extension\Model\Asiento()); $this->loadExtension(new Extension\Model\Base\BusinessDocument()); $this->loadExtension(new Extension\Model\Stock()); $this->loadExtension(new Extension\Model\FacturaProgramada()); diff --git a/View/Tab/AccountingEntry.html.twig b/View/Tab/AccountingEntry.html.twig new file mode 100644 index 0000000..37d9599 --- /dev/null +++ b/View/Tab/AccountingEntry.html.twig @@ -0,0 +1,250 @@ +{% set model = fsc.getCurrentView().model %} + + + +{# Template oculto del campo proyecto, clonado en el header via JS #} + + +
+ {{ formToken() }} + + + + + + {{ fsc.renderAccEntryForm(model, model.getLines()) | raw }} +