diff --git a/app/config/routing/admin_accounting/journal.yml b/app/config/routing/admin_accounting/journal.yml index 5ef2494ca..0de103c76 100644 --- a/app/config/routing/admin_accounting/journal.yml +++ b/app/config/routing/admin_accounting/journal.yml @@ -33,3 +33,11 @@ admin_accounting_journal_export: path: /export defaults: _controller: AppBundle\Controller\Admin\Accounting\Journal\ExportAction + + +admin_accounting_journal_update_info: + path: /update-info/{id}/{modification} + defaults: + _controller: AppBundle\Controller\Admin\Accounting\Journal\UpdateInfoAction + requirements: + id: \d+ diff --git a/htdocs/pages/administration/compta_journal.php b/htdocs/pages/administration/compta_journal.php index aca9b103b..15434a10c 100755 --- a/htdocs/pages/administration/compta_journal.php +++ b/htdocs/pages/administration/compta_journal.php @@ -252,99 +252,6 @@ $smarty->assign('formulaire', genererFormulaire($formulaire)); } -/* - * This action is used in AJAX in order to update "compta" data. - * Only 4 columns are available for update: - * - categorie - * - reglement - * - evenement - * - comment - * - attachment_required - * The new value is passed with the `val` variable (POST). - * The column and the "compta" identifier are passed with GET vars. - * - * There is no content return on failure, only headers. - * If the update succeed we display a simple JSON element with a 200 status code. - * - * This action is added to perform Ajax updates directly on the "journal" list - * in order to improve utilization. - */ elseif ($action === 'modifier_colonne') { - try { - // Bad request? - if (!isset($_POST['val']) || !isset($_GET['column']) || !isset($_GET['id']) || !($line = $compta->obtenir((int) $_GET['id']))) { - throw new Exception("Please verify parameters", 400); - } - - // Test line existence - if (!$line['id']) { - throw new Exception("Not found", 404); - } - - $allowEmpty = false; - - switch ($_GET['column']) { - case 'categorie': - $column = 'idcategorie'; - $value = (int) $_POST['val']; - break; - case 'reglement': - $column = 'idmode_regl'; - $value = (int) $_POST['val']; - break; - case 'evenement': - $column = 'idevenement'; - $value = (int) $_POST['val']; - break; - case 'comment': - $column = 'comment'; - $value = (string) $_POST['val']; - $allowEmpty = true; - break; - case 'attachment_required': - $column = 'attachment_required'; - $value = (int) $_POST['val']; - $allowEmpty = true; - break; - default: - throw new Exception("Bad column name", 400); - } - - // No value? - if (!$allowEmpty && !$value) { - throw new Exception("Bad value", 400); - } - - if ($compta->modifierColonne($line['id'], $column, $value)) { - $response = [ - 'success' => true, - ]; - - // Done! - header('Content-Type: application/json; charset=utf-8'); - header('HTTP/1.1 200 OK'); - die(json_encode($response)); - } else { - throw new Exception("An error occurred", 409); - } - } catch (Exception $e) { - switch ($e->getCode()) { - case 404: - $httpStatus = "Not Found"; - break; - case 409: - $httpStatus = "Conflict"; - break; - case 400: - default: - $httpStatus = "Bad Request"; - break; - } - header('HTTP/1.1 ' . $e->getCode() . ' ' . $httpStatus); - header('X-Info: ' . $e->getMessage()); - exit; - } -} - /** * Upload an attachment and save it on the specific line. * We save the uploads in a directory at the same month of the line diff --git a/htdocs/templates/administration/compta_journal.html b/htdocs/templates/administration/compta_journal.html index 0f4856ed2..01edf0bce 100644 --- a/htdocs/templates/administration/compta_journal.html +++ b/htdocs/templates/administration/compta_journal.html @@ -96,7 +96,7 @@