diff --git a/apps/maarch_entreprise/Models/ResModelAbstract.php b/apps/maarch_entreprise/Models/ResModelAbstract.php index 8115d78caa82785c91f0d993cc74aac1ca684e74..874131d0d8b2dde9ad0295c462a002c7ae220161 100644 --- a/apps/maarch_entreprise/Models/ResModelAbstract.php +++ b/apps/maarch_entreprise/Models/ResModelAbstract.php @@ -81,12 +81,17 @@ class ResModelAbstract extends Apps_Table_Service static::checkArray($aArgs, ['notIn']); - $aReturn = static::select([ + $select = [ 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], 'table' => ['res_view_attachments'], 'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status not in ('DEL', 'TMP', 'OBS')"], - 'data' => [$aArgs['resIdMaster'], $aArgs['notIn']] - ]); + 'data' => [$aArgs['resIdMaster'], $aArgs['notIn']], + ]; + if (!empty($aArgs['orderBy'])) { + $select['order_by'] = $aArgs['orderBy']; + } + + $aReturn = static::select($select); return $aReturn; } diff --git a/modules/visa/Controllers/VisaController.php b/modules/visa/Controllers/VisaController.php index 2dee2d065b842f547babe23f3b637ec9c4f3bfb7..e3a0ae7fd9e243f96dfed68d99fc234d84dd7b62 100644 --- a/modules/visa/Controllers/VisaController.php +++ b/modules/visa/Controllers/VisaController.php @@ -147,7 +147,7 @@ class VisaController return $response->withJson($this->getAttachmentsForSignatureBook(['resId' => $resId])); } - private function getAttachmentsForSignatureBook($aArgs) + private function getAttachmentsForSignatureBook(array $aArgs = []) { if (file_exists('custom/' .$_SESSION['custom_override_id']. '/apps/maarch_entreprise/xml/entreprise.xml')) { @@ -174,7 +174,8 @@ class VisaController 'status', 'typist', 'path', 'filename', 'updated_by', 'creation_date', 'validation_date', 'format', 'relation', 'dest_user', 'dest_contact_id', 'dest_address_id', 'origin' - ] + ], + 'orderBy' => "CASE WHEN attachment_type = 'response_project' THEN 1 ELSE 2 END, creation_date" ]); foreach ($attachments as $key => $value) {