Skip to content
Snippets Groups Projects
Commit fdd5878b authored by Nathan Cheval's avatar Nathan Cheval
Browse files

Delete Reconciliation Model

parent abc1aa7d
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
* *
*/ */
use Attachments\Models\ReconciliationModel;
$core = new core_tools(); $core = new core_tools();
$core->test_user(); $core->test_user();
$core->load_js(); $core->load_js();
......
...@@ -4,7 +4,8 @@ namespace Attachment\controllers; ...@@ -4,7 +4,8 @@ namespace Attachment\controllers;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
use Attachment\models\ReconciliationModel; use Attachment\models\AttachmentModel;
use Resource\models\ResModel;
use Respect\Validation\Validator; use Respect\Validation\Validator;
use History\controllers\HistoryController; use History\controllers\HistoryController;
use Resource\controllers\StoreController; use Resource\controllers\StoreController;
...@@ -22,7 +23,7 @@ class ReconciliationController ...@@ -22,7 +23,7 @@ class ReconciliationController
return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); return $response->withStatus(400)->withJson(['errors' => 'Bad Request']);
} }
$resId = $this->getWs($data); $resId = ReconciliationController::getWs($data);
if (empty($resId) || !empty($resId['errors'])) { if (empty($resId) || !empty($resId['errors'])) {
return $response->withStatus(500)->withJson(['errors' => '[ReconciliationController create] ' . $resId['errors']]); return $response->withStatus(500)->withJson(['errors' => '[ReconciliationController create] ' . $resId['errors']]);
...@@ -40,16 +41,15 @@ class ReconciliationController ...@@ -40,16 +41,15 @@ class ReconciliationController
return $response->withJson(['resId' => $resId]); return $response->withJson(['resId' => $resId]);
} }
public function getWs($aArgs) public static function getWs($aArgs)
{ {
$identifier = $aArgs['chrono']; $identifier = $aArgs['chrono'];
$res_id = (int)$aArgs['resId']; $res_id = (int)$aArgs['resId'];
$encodedContent = $aArgs['encodedFile']; $encodedContent = $aArgs['encodedFile'];
$info = ReconciliationModel::getReconciliation([ $info = AttachmentModel::getOnView([
'select' => ['*'], 'select' => ['*'],
'table' => ['res_attachments'], 'where' => ['identifier = ?', "status IN ('A_TRA', 'NEW','TMP')"],
'where' => ['identifier = (?)', "status IN ('A_TRA', 'NEW','TMP')"],
'data' => [$identifier], 'data' => [$identifier],
'orderBy' => ['res_id DESC'] 'orderBy' => ['res_id DESC']
])[0]; ])[0];
...@@ -142,21 +142,19 @@ class ReconciliationController ...@@ -142,21 +142,19 @@ class ReconciliationController
$close_incoming = $reconciliationConfig->close_incoming; $close_incoming = $reconciliationConfig->close_incoming;
if ($delete_response_project == 'true') { if ($delete_response_project == 'true') {
ReconciliationModel::updateReconciliation([ AttachmentModel::update([
'set' => ['status' => 'DEL'], 'set' => ['status' => 'DEL'],
'where' => ['res_id = (?)'], 'where' => ['res_id = ?'],
'data' => [$info['res_id']], 'data' => [$info['res_id']],
'table' => 'res_attachments'
]); ]);
} }
// Cloture du courrier entrant // Cloture du courrier entrant
if ($close_incoming == 'true') { if ($close_incoming == 'true') {
ReconciliationModel::updateReconciliation([ ResModel::update([
'set' => ['status' => 'END'], 'set' => ['status' => 'END'],
'where' => ['res_id = (?)'], 'where' => ['res_id = ?'],
'data' => [$res_id], 'data' => [$res_id],
'table' => 'res_letterbox'
]); ]);
} }
} }
...@@ -170,9 +168,8 @@ class ReconciliationController ...@@ -170,9 +168,8 @@ class ReconciliationController
$aArgs = $request->getParams(); $aArgs = $request->getParams();
} }
$attachment = ReconciliationModel::getReconciliation([ $attachment = AttachmentModel::getOnView([
'select' => ['*'], 'select' => ['*'],
'table' => ['res_attachments'],
'where' => ['identifier = (?)', "status IN ('A_TRA', 'NEW','TMP')"], 'where' => ['identifier = (?)', "status IN ('A_TRA', 'NEW','TMP')"],
'data' => [$aArgs['chrono']], 'data' => [$aArgs['chrono']],
'orderBy' => ['res_id DESC'] 'orderBy' => ['res_id DESC']
......
<?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
{
}
<?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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment