From fdd5878b8c687254e49649d272eab3f22c2ec044 Mon Sep 17 00:00:00 2001 From: Nathan Cheval <nathan.cheval@outlook.fr> Date: Mon, 10 Dec 2018 18:05:12 +0100 Subject: [PATCH] Delete Reconciliation Model --- modules/attachments/fill_input.php | 2 - .../controllers/ReconciliationController.php | 25 ++++----- .../attachment/models/ReconciliationModel.php | 14 ----- .../models/ReconciliationModelAbstract.php | 51 ------------------- 4 files changed, 11 insertions(+), 81 deletions(-) delete mode 100755 src/app/attachment/models/ReconciliationModel.php delete mode 100755 src/app/attachment/models/ReconciliationModelAbstract.php diff --git a/modules/attachments/fill_input.php b/modules/attachments/fill_input.php index 4c39773a0ac..c4e77fe6cf8 100755 --- a/modules/attachments/fill_input.php +++ b/modules/attachments/fill_input.php @@ -6,8 +6,6 @@ * */ -use Attachments\Models\ReconciliationModel; - $core = new core_tools(); $core->test_user(); $core->load_js(); diff --git a/src/app/attachment/controllers/ReconciliationController.php b/src/app/attachment/controllers/ReconciliationController.php index 31e7667e1e6..0780d7629c9 100755 --- a/src/app/attachment/controllers/ReconciliationController.php +++ b/src/app/attachment/controllers/ReconciliationController.php @@ -4,7 +4,8 @@ namespace Attachment\controllers; use Slim\Http\Request; use Slim\Http\Response; -use Attachment\models\ReconciliationModel; +use Attachment\models\AttachmentModel; +use Resource\models\ResModel; use Respect\Validation\Validator; use History\controllers\HistoryController; use Resource\controllers\StoreController; @@ -22,7 +23,7 @@ class ReconciliationController return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); } - $resId = $this->getWs($data); + $resId = ReconciliationController::getWs($data); if (empty($resId) || !empty($resId['errors'])) { return $response->withStatus(500)->withJson(['errors' => '[ReconciliationController create] ' . $resId['errors']]); @@ -40,16 +41,15 @@ class ReconciliationController return $response->withJson(['resId' => $resId]); } - public function getWs($aArgs) + public static function getWs($aArgs) { $identifier = $aArgs['chrono']; $res_id = (int)$aArgs['resId']; $encodedContent = $aArgs['encodedFile']; - $info = ReconciliationModel::getReconciliation([ + $info = AttachmentModel::getOnView([ 'select' => ['*'], - 'table' => ['res_attachments'], - 'where' => ['identifier = (?)', "status IN ('A_TRA', 'NEW','TMP')"], + 'where' => ['identifier = ?', "status IN ('A_TRA', 'NEW','TMP')"], 'data' => [$identifier], 'orderBy' => ['res_id DESC'] ])[0]; @@ -142,21 +142,19 @@ class ReconciliationController $close_incoming = $reconciliationConfig->close_incoming; if ($delete_response_project == 'true') { - ReconciliationModel::updateReconciliation([ + AttachmentModel::update([ 'set' => ['status' => 'DEL'], - 'where' => ['res_id = (?)'], + 'where' => ['res_id = ?'], 'data' => [$info['res_id']], - 'table' => 'res_attachments' ]); } // Cloture du courrier entrant if ($close_incoming == 'true') { - ReconciliationModel::updateReconciliation([ + ResModel::update([ 'set' => ['status' => 'END'], - 'where' => ['res_id = (?)'], + 'where' => ['res_id = ?'], 'data' => [$res_id], - 'table' => 'res_letterbox' ]); } } @@ -170,9 +168,8 @@ class ReconciliationController $aArgs = $request->getParams(); } - $attachment = ReconciliationModel::getReconciliation([ + $attachment = AttachmentModel::getOnView([ 'select' => ['*'], - 'table' => ['res_attachments'], 'where' => ['identifier = (?)', "status IN ('A_TRA', 'NEW','TMP')"], 'data' => [$aArgs['chrono']], 'orderBy' => ['res_id DESC'] diff --git a/src/app/attachment/models/ReconciliationModel.php b/src/app/attachment/models/ReconciliationModel.php deleted file mode 100755 index c9f2082fa32..00000000000 --- a/src/app/attachment/models/ReconciliationModel.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php -/** - *​ ​Copyright​ ​Maarch​ since ​2008​ under licence ​GPLv3. - *​ ​See​ LICENCE​.​txt file at the root folder ​for​ more details. - *​ ​This​ file ​is​ part of ​Maarch​ software. - * - */ - - -namespace Attachment\models; - -class ReconciliationModel extends ReconciliationModelAbstract -{ -} diff --git a/src/app/attachment/models/ReconciliationModelAbstract.php b/src/app/attachment/models/ReconciliationModelAbstract.php deleted file mode 100755 index 97d1e33024d..00000000000 --- a/src/app/attachment/models/ReconciliationModelAbstract.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - *​ ​Copyright​ ​Maarch​ since ​2008​ under licence ​GPLv3. - *​ ​See​ LICENCE​.​txt file at the root folder ​for​ more details. - *​ ​This​ file ​is​ part of ​Maarch​ software. - * - */ - - -namespace Attachment\models; - -use SrcCore\models\DatabaseModel; -use SrcCore\models\ValidatorModel; - -class ReconciliationModelAbstract { - public static function getReconciliation (array $aArgs = []) - { - ValidatorModel::notEmpty($aArgs, ['select']); - ValidatorModel::arrayType($aArgs, ['select', 'where', 'data', 'orderBy']); - - $select = [ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => gettype($aArgs['table']) == 'string' ? array($aArgs['table']) : $aArgs['table'], - 'where' => $aArgs['where'], - 'data' => $aArgs['data'], - ]; - - if (!empty($aArgs['orderBy'])) { - $select['order_by'] = $aArgs['orderBy']; - } - - $aReturn = $aAttachments = DatabaseModel::select($select); - - return $aReturn; - } - -public static function updateReconciliation (array $aArgs = []) - { - ValidatorModel::notEmpty($aArgs, ['set']); - ValidatorModel::arrayType($aArgs, ['where', 'data', 'set']); - - DatabaseModel::update([ - 'set' => $aArgs['set'], - 'table' => gettype($aArgs['table']) == 'array' ? (string) $aArgs['table'] : $aArgs['table'], - 'where' => $aArgs['where'], - 'data' => $aArgs['data'], - ]); - - return true; - } -} -- GitLab