diff --git a/src/app/action/controllers/ExternalSignatoryBookTrait.php b/src/app/action/controllers/ExternalSignatoryBookTrait.php index 4027cec45320b18e62cbbf760bfe816102e6e1a3..b51716950d4dfbce7bb3c123d31d164e19cb6591 100644 --- a/src/app/action/controllers/ExternalSignatoryBookTrait.php +++ b/src/app/action/controllers/ExternalSignatoryBookTrait.php @@ -12,6 +12,7 @@ namespace Action\controllers; +use Attachment\controllers\AttachmentController; use Attachment\models\AttachmentModel; use ExternalSignatoryBook\controllers\MaarchParapheurController; use ExternalSignatoryBook\controllers\XParaphController; @@ -38,6 +39,25 @@ trait ExternalSignatoryBookTrait } } + if (!empty($config['id'])) { + $attachments = AttachmentModel::get([ + 'select' => [ + 'res_id', 'status' + ], + 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP')", "in_signature_book = 'true'"], + 'data' => [$args['resId'], ['converted_pdf', 'print_folder', 'signed_response']] + ]); + + foreach ($attachments as $attachment) { + if ($attachment['status'] == 'SEND_MASS') { + $generated = AttachmentController::generateMailing(['id' => $attachment['res_id'], 'userId' => $GLOBALS['id']]); + if (!empty($generated['errors'])) { + return ['errors' => $generated['errors']]; + } + } + } + } + if ($config['id'] == 'ixbus') { // TODO } elseif ($config['id'] == 'iParapheur') { @@ -45,21 +65,13 @@ trait ExternalSignatoryBookTrait } elseif ($config['id'] == 'fastParapheur') { // TODO } elseif ($config['id'] == 'maarchParapheur') { - $attachments = AttachmentModel::get([ - 'select' => [ - 'count(1) as nb' - ], - 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP', 'SEND_MASS')", "in_signature_book = 'true'"], - 'data' => [$args['resId'], ['converted_pdf', 'print_folder', 'signed_response']] - ]); - $integratedResource = ResModel::get([ 'select' => [1], 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_id->>\'signatureBookId\' is null', 'res_id = ?'], 'data' => [$args['resId']] ]); - if ($attachments[0]['nb'] == 0 && empty($integratedResource) && $args['data']['objectSent'] == 'attachment') { + if (empty($attachments) && empty($integratedResource) && $args['data']['objectSent'] == 'attachment') { $noAttachmentsResource = ResModel::getById(['resId' => $args['resId'], 'select' => ['alt_identifier']]); return ['errors' => ['No attachment for this mail : ' . $noAttachmentsResource['alt_identifier']]]; } @@ -80,14 +92,7 @@ trait ExternalSignatoryBookTrait $historyInfo = $sendedInfo['historyInfos']; } elseif ($config['id'] == 'xParaph') { - $attachments = AttachmentModel::get([ - 'select' => [ - 'count(1) as nb' - ], - 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP', 'SEND_MASS')", "in_signature_book = 'true'"], - 'data' => [$args['resId'], ['converted_pdf', 'print_folder', 'signed_response']] - ]); - if ($attachments[0]['nb'] == 0) { + if (empty($attachments)) { $noAttachmentsResource = ResModel::getById(['resId' => $args['resId'], 'select' => ['alt_identifier']]); return ['errors' => ['No attachment for this mail : ' . $noAttachmentsResource['alt_identifier']]]; } diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index 74112da219320054913807e65dd7ff9a98a099bb..cc749c10e6ae4ef7ba45d2b18e49c2dc26496868 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -423,7 +423,7 @@ class PreProcessActionController 'status', 'typist', 'docserver_id', 'path', 'filename', 'creation_date', 'validation_date', 'relation', 'origin_id' ], - 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP', 'SEND_MASS')", "in_signature_book = 'true'"], + 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP')", "in_signature_book = 'true'"], 'data' => [$resId, ['converted_pdf', 'print_folder', 'signed_response']] ]); @@ -507,7 +507,7 @@ class PreProcessActionController 'status', 'typist', 'docserver_id', 'path', 'filename', 'creation_date', 'validation_date', 'relation', 'origin_id' ], - 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP', 'SEND_MASS')", "in_signature_book = 'true'"], + 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP')", "in_signature_book = 'true'"], 'data' => [$resId, ['converted_pdf', 'print_folder', 'signed_response']] ]); diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index 09e744e61aaa7134e8e86b8254ed279de2aab76e..e30e2a7a65cdfaf39b2b54d223e0a77b48b9d0bc 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -33,9 +33,7 @@ use Respect\Validation\Validator; use Slim\Http\Request; use Slim\Http\Response; use SrcCore\models\CoreConfigModel; -use SrcCore\models\DatabaseModel; use SrcCore\models\ValidatorModel; -use Template\controllers\TemplateController; use User\models\UserModel; class AttachmentController diff --git a/src/app/resource/controllers/ResourceListController.php b/src/app/resource/controllers/ResourceListController.php index e847c5cd04206968bebf1c337548cd51719b0a9b..445214718ef641259966a284e38512e638161da2 100644 --- a/src/app/resource/controllers/ResourceListController.php +++ b/src/app/resource/controllers/ResourceListController.php @@ -25,7 +25,6 @@ use Contact\controllers\ContactController; use Entity\models\EntityModel; use Entity\models\ListInstanceModel; use Folder\models\FolderModel; -use Group\controllers\PrivilegeController; use Group\models\GroupModel; use Note\models\NoteModel; use Priority\models\PriorityModel; @@ -88,7 +87,7 @@ class ResourceListController $defaultAction = []; $displayFolderTags = false; if (!empty($resIds)) { - $excludeAttachmentTypes = ['converted_pdf', 'print_folder']; + $excludeAttachmentTypes = ['converted_pdf', 'print_folder', 'signed_response']; $attachments = AttachmentModel::get([ 'select' => ['COUNT(res_id)', 'res_id_master'], 'where' => ['res_id_master in (?)', 'status not in (?)', 'attachment_type not in (?)', '((status = ? AND typist = ?) OR status != ?)'],