From afac07d143b9fbd7f7f6943a620ac3a9bfcb336d Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 19 Sep 2018 14:57:18 +0200 Subject: [PATCH] fix set in signaturebook bool type --- apps/maarch_entreprise/class/class_lists_Abstract.php | 4 ++-- apps/maarch_entreprise/js/angularFunctions.js | 2 +- src/app/attachment/controllers/AttachmentController.php | 3 +++ src/app/attachment/models/AttachmentModelAbstract.php | 7 +++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index 421d9bfe07d..a72ab552450 100755 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -1617,9 +1617,9 @@ abstract class lists_Abstract extends Database $return .= 'checked '; } - $isVersion = false; + $isVersion = 'false'; if ($resultTheLine[1]['value'] > 1) { - $isVersion = true; + $isVersion = 'true'; } $return .= 'onclick="setAttachmentInSignatureBook('.$resultTheLine[0]['value'].', '.$isVersion.');"/>Intégrer au parapheur'; diff --git a/apps/maarch_entreprise/js/angularFunctions.js b/apps/maarch_entreprise/js/angularFunctions.js index f1e4a86e4f1..3530d43437c 100755 --- a/apps/maarch_entreprise/js/angularFunctions.js +++ b/apps/maarch_entreprise/js/angularFunctions.js @@ -135,7 +135,7 @@ function setAttachmentInSignatureBook(id, isVersion) { window.parent.angularSignatureBookComponent.componentAfterAttach("left"); } }, error: function(err) { - alert("Une erreur s'est produite"); + alert("Une erreur s'est produite : " + err.responseJSON.exception[0].message); } }); } diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index 587199606a9..9aea5047560 100644 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -47,6 +47,9 @@ class AttachmentController $data = $request->getParams(); + $data['isVersion'] = filter_var($data['isVersion'], FILTER_VALIDATE_BOOLEAN); + + var_dump($data['isVersion']); $attachment = AttachmentModel::getById(['id' => $aArgs['id'], 'isVersion' => $data['isVersion']]); if (empty($attachment)) { diff --git a/src/app/attachment/models/AttachmentModelAbstract.php b/src/app/attachment/models/AttachmentModelAbstract.php index 2a914c3f92b..17fbf2c7815 100644 --- a/src/app/attachment/models/AttachmentModelAbstract.php +++ b/src/app/attachment/models/AttachmentModelAbstract.php @@ -183,12 +183,11 @@ abstract class AttachmentModelAbstract public static function setInSignatureBook(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['id', 'isVersion']); + ValidatorModel::notEmpty($aArgs, ['id']); ValidatorModel::intVal($aArgs, ['id']); - ValidatorModel::stringType($aArgs, ['isVersion']); - ValidatorModel::boolType($aArgs, ['inSignatureBook']); + ValidatorModel::boolType($aArgs, ['inSignatureBook', 'isVersion']); - if ($aArgs['isVersion'] == 'true') { + if ($aArgs['isVersion'] == true) { $table = 'res_version_attachments'; } else { $table = 'res_attachments'; -- GitLab