diff --git a/apps/maarch_entreprise/actions/sendToExternalNoteBook.php b/apps/maarch_entreprise/actions/sendToExternalNoteBook.php deleted file mode 100755 index 2af24b3428edd749125ccb25b1edb248f39d0007..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/actions/sendToExternalNoteBook.php +++ /dev/null @@ -1,200 +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. - -* -* @brief sendToExternalNote -* -* @author dev <dev@maarch.org> -* @ingroup visa -*/ - -$confirm = true; -$frm_width = '400px'; -$frm_height = 'auto'; -$warnMsg = ''; - -$etapes = ['form']; - -function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode) -{ - $db = new Database(); - $values_str = ''; - if (empty($_SESSION['stockCheckbox'])) { - for ($i=0; $i<count($values); $i++) { - $values_str .= $values[$i].', '; - } - } else { - for ($i=0; $i<count($_SESSION['stockCheckbox']); $i++) { - $values_str .= $_SESSION['stockCheckbox'][$i].', '; - } - } - $values_str = preg_replace('/, $/', '', $values_str); - - $config = getXml(); - - $labelAction = ''; - if ($id_action <> '') { - $stmt = $db->query("SELECT label_action FROM actions WHERE id = ?", array($id_action)); - $resAction = $stmt->fetchObject(); - $labelAction = functions::show_string($resAction->label_action); - } - - $html = '<div id="frm_error_'.$id_action.'" class="error"></div>'; - $html .= '<h2 class="title">' . $labelAction . '</h2>'; - - $html .= '<form name="sendToExternalSB" id="sendToExternalSB" method="post" class="forms" action="#">'; - $html .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />'; - - if (!empty($config)) { - include_once 'modules/visa/class/MaarchParapheurController.php'; - - $initializeDatas = MaarchParapheurController::getInitializeDatas($config); - if (!empty($initializeDatas['error'])) { - $error = $initializeDatas['error']; - } else { - $html .= '<label for="processingUser">' . _USER_MAARCH_PARAPHEUR . '</label><select name="processingUser" id="processingUser">'; - if (!empty($initializeDatas['users'])) { - foreach ($initializeDatas['users'] as $value) { - $html .= '<option value="'; - $html .= $value['id']; - $html .= '">'; - $html .= $value['firstname'] . ' ' . $value['lastname']; - $html .= '</option>'; - } - } - $html .= '</select><br /><br /><br /><br />'; - } - } else { - $error = _FILE . ' modules/visa/xml/remoteSignatoryBooks.xml' . ' ' . _NOT_EXISTS; - } - - $html .='<div align="center">'; - if (empty($error)) { - $html .=' <input type="button" name="validate" id="validate" value="'._VALIDATE.'" class="button" ' . - 'onclick="valid_action_form(\'sendToExternalSB\', \'' . $path_manage_action . - '\', \'' . $id_action . '\', \'' . $values_str . '\', \'res_letterbox\', \'null\', \'letterbox_coll\', \'' . - $mode . '\');" /> '; - } else { - $html .= '<br>' . $error . '<br><br>'; - } - $html .='<input type="button" name="cancel" id="cancel" class="button" value="'._CANCEL.'" onclick="pile_actions.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>'; - - $html .='</div>'; - $html .='</form>'; - - return addslashes($html); -} - -function check_form($form_id, $values) -{ - $_SESSION['action_error'] = ''; - - if (!empty($_SESSION['stockCheckbox'])) { - $aResources = $_SESSION['stockCheckbox']; - } else { - $aResources = [$_SESSION['doc_id']]; - } - - foreach ($aResources as $resId) { - $adrMainInfo = \Convert\controllers\ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => 'letterbox_coll']); - $docserverMainInfo = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $adrMainInfo['docserver_id']]); - $filePath = $docserverMainInfo['path_template'] . str_replace('#', '/', $adrMainInfo['path']) . $adrMainInfo['filename']; - if (!is_file($filePath)) { - $_SESSION['action_error'] = _FILE_MISSING . ' : ' . $filePath; - return false; - } - } - - return true; -} - -function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form) -{ - $result = ''; - $config = getXml(); - - $coll_id = $_SESSION['current_basket']['coll_id']; - $message = ''; - - foreach ($arr_id as $res_id) { - $result .= $res_id.'#'; - - if (!empty($config)) { - $processingUser = get_value_fields($values_form, 'processingUser'); - $processingUserInfo = \ExternalSignatoryBook\controllers\MaarchParapheurController::getUserById(['config' => $config, 'id' => $processingUser]); - $sendedInfo = \ExternalSignatoryBook\controllers\MaarchParapheurController::sendDatas([ - 'config' => $config, - 'resIdMaster' => $res_id, - 'processingUser' => $processingUser, - 'objectSent' => 'mail', - 'userId' => $_SESSION['user']['UserId'] - ]); - - if (!empty($sendedInfo['error'])) { - var_dump($sendedInfo['error']); - exit; - } else { - $attachmentToFreeze = $sendedInfo['sended']; - } - - $message = ' (à ' . $processingUserInfo['firstname'] . ' ' . $processingUserInfo['lastname'] . ')'; - } - - if (!empty($attachmentToFreeze)) { - if (!empty($attachmentToFreeze['letterbox_coll'])) { - \Resource\models\ResModel::update([ - 'set' => ['external_signatory_book_id' => $attachmentToFreeze['letterbox_coll'][$res_id]], - 'where' => ['res_id = ?'], - 'data' => [$res_id] - ]); - } - } - } - - return ['result' => $result, 'history_msg' => $message]; -} - -function getXml() -{ - if (file_exists("custom/{$_SESSION['custom_override_id']}/modules/visa/xml/remoteSignatoryBooks.xml")) { - $path = "custom/{$_SESSION['custom_override_id']}/modules/visa/xml/remoteSignatoryBooks.xml"; - } else { - $path = 'modules/visa/xml/remoteSignatoryBooks.xml'; - } - - $config = []; - if (file_exists($path)) { - $loadedXml = simplexml_load_file($path); - if ($loadedXml) { - $config['id'] = 'maarchParapheur'; - foreach ($loadedXml->signatoryBook as $value) { - if ($value->id == $config['id']) { - $config['data'] = (array)$value; - } - } - } - } - - return $config; -} - - /** - * Get the value of a given field in the values returned by the form - * - * @param $values Array Values of the form to check - * @param $field String the field - * @return String the value, false if the field is not found - **/ -function get_value_fields($values, $field) -{ - for ($i=0; $i<count($values); $i++) { - if ($values[$i]['ID'] == $field) { - return $values[$i]['VALUE']; - } - } - return false; -} diff --git a/migration/20.03/2003-postScript.sql b/migration/20.03/2003-postScript.sql index 530f0e61b3b2a293cc8acba0e22627d59f5d36ac..a8eda48478ac59ded2da39af1334bf2ec79b92cd 100644 --- a/migration/20.03/2003-postScript.sql +++ b/migration/20.03/2003-postScript.sql @@ -169,7 +169,6 @@ SELECT r.res_id, r.opinion_limit_date, r.department_number_id, r.barcode, - r.external_signatory_book_id, r.initiator, r.destination, r.dest_user, diff --git a/migration/20.03/2003.sql b/migration/20.03/2003.sql index 63e3fb87a1d42488a0d6499b7124810af968f001..862204d5b37f54a917aa53810185fe8ad100bc21 100644 --- a/migration/20.03/2003.sql +++ b/migration/20.03/2003.sql @@ -356,6 +356,12 @@ DO $$ BEGIN END IF; END$$; +DO $$ BEGIN + IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_letterbox') AND attname = 'external_signatory_book_id') = 0 THEN + UPDATE res_letterbox SET external_id = jsonb_set(external_id, '{signatureBookId}', external_signatory_book_id::text::jsonb) WHERE external_signatory_book_id IS NOT NULL; + ALTER TABLE res_letterbox DROP COLUMN IF EXISTS external_signatory_book_id; + END IF; +END$$; /* RES_LETTERBOX */ ALTER TABLE res_letterbox DROP COLUMN IF EXISTS model_id; diff --git a/migration/20.03/migrateOutgoingAttachments.php b/migration/20.03/migrateOutgoingAttachments.php index 6d84d0ee48c1e53da78b0508e81915b354de3044..f66d5e6f4f9b4842da057a4d7c611cd6421d1003 100644 --- a/migration/20.03/migrateOutgoingAttachments.php +++ b/migration/20.03/migrateOutgoingAttachments.php @@ -23,7 +23,7 @@ foreach ($customs as $custom) { $migrated = 0; $attachmentsInfo = \SrcCore\models\DatabaseModel::select([ 'select' => ['l.category_id', 'a.res_id', 'a.relation', 'a.docserver_id', 'a.path', 'a.filename', 'a.filesize', 'a.format', 'a.res_id_master', 'a.in_signature_book', - 'a.in_send_attach', 'a.external_id', 'a.origin_id', 'a.external_id', 'l.external_id as letterbox_external_id'], + 'a.in_send_attach', 'a.external_id->>\'signatureBookId\' as signaturebookid', 'a.origin_id'], 'table' => ['res_attachments a, res_letterbox l'], 'where' => ['attachment_type = ?', 'a.status not in (?)', 'a.res_id_master = l.res_id', 'category_id = ?'], 'data' => ['outgoing_mail', ['DEL', 'TMP', 'OBS'], 'outgoing'], @@ -57,12 +57,7 @@ foreach ($customs as $custom) { $integration = []; $integration['inSignatureBook'] = empty($attachmentInfo['in_signature_book']) ? 'false' : 'true'; $integration['inShipping'] = empty($attachmentInfo['in_send_attach']) ? 'false' : 'true'; - $attachmentExternalId = json_decode($attachmentInfo['external_id'], true); - $externalId = json_decode($attachmentInfo['letterbox_external_id'], true); - $attachmentExternalId = empty($attachmentExternalId) ? [] : $attachmentExternalId; - $externalId = empty($externalId) ? [] : $externalId; - $externalId = array_merge($externalId, $attachmentExternalId); ResModel::update([ 'set' => [ 'docserver_id' => $attachmentInfo['docserver_id'], @@ -71,9 +66,9 @@ foreach ($customs as $custom) { 'fingerprint' => $attachmentInfo['fingerprint'], 'filesize' => $attachmentInfo['filesize'], 'version' => $attachmentInfo['relation'], - 'integrations' => json_encode($integration), - 'external_id' => json_encode($externalId) + 'integrations' => json_encode($integration) ], + 'postSet' => ['external_id' => "jsonb_set(external_id, '{signatureBookId}', '{$attachmentInfo['signaturebookid']}'::text::jsonb)"], 'where' => ['res_id = ?'], 'data' => [$attachmentInfo['res_id_master']] ]); diff --git a/modules/visa/batch/batch_tools.php b/modules/visa/batch/batch_tools.php index d3ec70618ae93b995a12023165d685f1a9cc5864..926b7ebccaf81c174847d7e6d7a728343132ba8a 100755 --- a/modules/visa/batch/batch_tools.php +++ b/modules/visa/batch/batch_tools.php @@ -161,7 +161,10 @@ function Bt_createAttachment($aArgs = []) if (!empty($aArgs['noteCreatorId'])) { $creatorId = $aArgs['noteCreatorId']; } else { - $creatorId = 'superadmin'; + $req = "SELECT id FROM users ORDER BY user_id='superadmin' desc limit 1"; + $stmt = $GLOBALS['db']->query($req, array([])); + $reqResult = $stmt->fetchObject(); + $creatorId = $reqResult->id; $creatorName = $aArgs['noteCreatorName'] . ' : '; } $GLOBALS['db']->query( @@ -170,65 +173,22 @@ function Bt_createAttachment($aArgs = []) ); } - if (!empty($aArgs['attachment_type'])) { - $attachmentType = $aArgs['attachment_type']; - } else { - $attachmentType = 'signed_response'; - } - - if (!empty($aArgs['in_signature_book'])) { - $inSignatureBook = $aArgs['in_signature_book']; - } else { - $inSignatureBook = 'true'; - } - - if (!empty($aArgs['table'])) { - $table = $aArgs['table']; - } else { - $table = 'res_attachments'; - } - - if (!empty($aArgs['relation'])) { - $relation = $aArgs['relation']; - } else { - $relation = 1; - } - - if (!empty($aArgs['status'])) { - $status = $aArgs['status']; - } else { - $status = 'TRA'; - } - $dataValue = []; - array_push($dataValue, ['column' => 'res_id_master', 'value' => $aArgs['res_id_master'], 'type' => 'integer']); - array_push($dataValue, ['column' => 'title', 'value' => $aArgs['title'], 'type' => 'string']); - array_push($dataValue, ['column' => 'identifier', 'value' => $aArgs['identifier'], 'type' => 'string']); - array_push($dataValue, ['column' => 'type_id', 'value' => 1, 'type' => 'integer']); - array_push($dataValue, ['column' => 'dest_contact_id', 'value' => $aArgs['dest_contact_id'], 'type' => 'integer']); - array_push($dataValue, ['column' => 'dest_address_id', 'value' => $aArgs['dest_address_id'], 'type' => 'integer']); - array_push($dataValue, ['column' => 'dest_user', 'value' => $aArgs['dest_user'], 'type' => 'string']); - array_push($dataValue, ['column' => 'typist', 'value' => $aArgs['typist'], 'type' => 'string']); - array_push($dataValue, ['column' => 'attachment_type', 'value' => $attachmentType, 'type' => 'string']); - array_push($dataValue, ['column' => 'coll_id', 'value' => 'letterbox_coll', 'type' => 'string']); - array_push($dataValue, ['column' => 'relation', 'value' => $relation, 'type' => 'integer']); - array_push($dataValue, ['column' => 'in_signature_book','value' => $inSignatureBook, 'type' => 'bool']); - - if (!empty($aArgs['origin_id'])) { - array_push($dataValue, ['column' => 'origin_id','value' => $aArgs['origin_id'], 'type' => 'integer']); - } - - $allDatas = [ - "encodedFile" => $aArgs['encodedFile'], - "data" => $dataValue, - "collId" => "letterbox_coll", - "table" => $table, - "fileFormat" => $aArgs['format'], - "status" => $status - ]; + $dataValue['resIdMaster'] = $aArgs['res_id_master']; + $dataValue['title'] = $aArgs['title']; + $dataValue['recipientId'] = $aArgs['recipient_id']; + $dataValue['recipientType'] = $aArgs['recipient_type']; + $dataValue['typist'] = $aArgs['typist']; + $dataValue['chrono'] = $aArgs['identifier']; + $dataValue['type'] = $aArgs['attachment_type']; + $dataValue['inSignatureBook'] = $aArgs['in_signature_book']; + $dataValue['encodedFile'] = $aArgs['encodedFile']; + $dataValue['format'] = $aArgs['format']; + $dataValue['status'] = $aArgs['status']; + $dataValue['originId'] = $aArgs['origin_id']; $opts = [ - CURLOPT_URL => $GLOBALS['applicationUrl'] . 'rest/res', + CURLOPT_URL => $GLOBALS['applicationUrl'] . 'rest/attachments', CURLOPT_HTTPHEADER => [ 'accept:application/json', 'content-type:application/json', @@ -236,7 +196,7 @@ function Bt_createAttachment($aArgs = []) ], CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, - CURLOPT_POSTFIELDS => json_encode($allDatas), + CURLOPT_POSTFIELDS => json_encode($dataValue), CURLOPT_POST => true ]; diff --git a/modules/visa/batch/process_mailsFromSignatoryBook.php b/modules/visa/batch/process_mailsFromSignatoryBook.php index 4aa1410247baf2a093e8e4a9f04e1c78223be264..7045ed50b31a818515ef5b7f5970172c831da3bb 100755 --- a/modules/visa/batch/process_mailsFromSignatoryBook.php +++ b/modules/visa/batch/process_mailsFromSignatoryBook.php @@ -234,7 +234,7 @@ if (file_exists($GLOBALS['errorLckFile'])) { Bt_getWorkBatch(); $GLOBALS['logger']->write('Retrieve attachments sent to remote signatory book', 'INFO'); -$query = "SELECT res_id, external_id->>'signatureBookId' as external_id, external_id->>'xparaphDepot' as xparaphdepot, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user, typist, origin_id, relation +$query = "SELECT res_id, external_id->>'signatureBookId' as external_id, external_id->>'xparaphDepot' as xparaphdepot, format, res_id_master, title, identifier, attachment_type, recipient_id, recipient_type, typist, origin_id, relation FROM res_attachments WHERE status = 'FRZ' AND external_id->>'signatureBookId' IS NOT NULL AND external_id->>'signatureBookId' <> ''"; $stmt = $GLOBALS['db']->query($query, []); @@ -259,8 +259,8 @@ if ($configRemoteSignatoryBook['id'] == 'ixbus') { } $GLOBALS['logger']->write('Retrieve mails sent to remote signatory book', 'INFO'); -$query = "SELECT res_id, external_signatory_book_id as external_id, subject, typist - FROM res_letterbox WHERE external_signatory_book_id IS NOT NULL"; +$query = "SELECT res_id, external_id->>'signatureBookId' as external_id, subject, typist, version + FROM res_letterbox WHERE external_id->>'signatureBookId' IS NOT NULL"; $stmt = $GLOBALS['db']->query($query, []); while ($reqResult = $stmt->fetchObject()) { @@ -286,18 +286,14 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) { 'res_id_master' => $value->res_id_master, 'title' => '[xParaph Log] ' . $value->title, 'identifier' => $value->identifier, - 'type_id' => $value->type_id, - 'dest_contact_id' => $value->dest_contact_id, - 'dest_address_id' => $value->dest_address_id, - 'dest_user' => $value->dest_user, + 'recipient_id' => $value->recipient_id, + 'recipient_type' => $value->recipient_type, 'typist' => $value->typist, 'format' => 'xml', 'attachment_type' => $value->attachment_type, - 'relation' => 1, - 'status' => 'TRA', - 'encodedFile' => $value->log, 'in_signature_book' => 'false', - 'table' => 'res_attachments' + 'encodedFile' => $value->log, + 'status' => 'TRA' ]); } $additionalHistoryInfo = ''; @@ -307,23 +303,26 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) { if ($value->status == 'validated') { if (!empty($value->encodedFile)) { + \SrcCore\models\DatabaseModel::delete([ + 'table' => 'res_attachments', + 'where' => ['res_id_master = ?', 'status = ?', 'relation = ?'], + 'data' => [$value->res_id_master, 'SIGN', $value->relation] + ]); + $GLOBALS['logger']->write('Create validated Attachment', 'INFO'); Bt_createAttachment([ 'res_id_master' => $value->res_id_master, 'title' => $value->title, 'identifier' => $value->identifier, - 'type_id' => $value->type_id, - 'dest_contact_id' => $value->dest_contact_id, - 'dest_address_id' => $value->dest_address_id, - 'dest_user' => $value->dest_user, + 'recipient_id' => $value->recipient_id, + 'recipient_type' => $value->recipient_type, 'typist' => $value->typist, 'format' => $value->format, 'attachment_type' => $value->attachment_type, - 'relation' => $value->relation + 1, - 'origin_id' => $resId, - 'status' => 'TRA', + 'in_signature_book' => 'true', + 'originId' => $resId, + 'status' => 'SIGN', 'encodedFile' => $value->encodedFile, - 'table' => 'res_attachments', 'noteContent' => $value->noteContent, 'noteCreatorId' => $value->noteCreatorId, 'noteCreatorName' => $value->noteCreatorName @@ -361,17 +360,14 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) { 'res_id_master' => $value->res_id_master, 'title' => '[REFUSE] ' . $value->title, 'identifier' => $value->identifier, - 'type_id' => $value->type_id, - 'dest_contact_id' => $value->dest_contact_id, - 'dest_address_id' => $value->dest_address_id, - 'dest_user' => $value->dest_user, + 'recipient_id' => $value->recipient_id, + 'recipient_type' => $value->recipient_type, 'typist' => $value->typist, 'format' => $value->format, 'attachment_type' => $value->attachment_type, 'status' => 'A_TRA', 'encodedFile' => $value->encodedFile, 'in_signature_book' => 'false', - 'table' => 'res_attachments', 'noteContent' => $value->noteContent, 'noteCreatorId' => $value->noteCreatorId, 'noteCreatorName' => $value->noteCreatorName @@ -393,42 +389,72 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) { } foreach ($retrievedMails['resLetterbox'] as $resId => $value) { - $GLOBALS['logger']->write('Update res_letterbox : ' . $resId . '. ExternalSignatoryBookId : ' . $value->external_id, 'INFO'); + $GLOBALS['logger']->write('Update res_letterbox : ' . $resId . '. SignatoryBookId : ' . $value->external_id, 'INFO'); if (!empty($value->encodedFile)) { - $GLOBALS['logger']->write('Create Attachment', 'INFO'); - Bt_createAttachment([ - 'res_id_master' => $value->res_id, - 'title' => $value->subject, - 'typist' => $value->typist, - 'format' => $value->format, - 'encodedFile' => $value->encodedFile, - 'noteContent' => $value->noteContent, - 'noteCreatorId' => $value->noteCreatorId, - 'noteCreatorName' => $value->noteCreatorName, - 'in_signature_book' => 'false', - 'attachment_type' => 'document_with_notes' + $GLOBALS['logger']->write('Create document in res_letterbox', 'INFO'); + if ($value->status =='validated') { + \SrcCore\models\DatabaseModel::delete([ + 'table' => 'adr_letterbox', + 'where' => ['res_id = ?', 'type in (?)', 'version = ?'], + 'data' => [$resId, ['SIGN', 'TNL'], $value->version] + ]); + } else { + \SrcCore\models\DatabaseModel::delete([ + 'table' => 'adr_letterbox', + 'where' => ['res_id = ?', 'type in (?)', 'version = ?'], + 'data' => [$resId, ['NOTE'], $value->version] + ]); + } + + $adrType = 'SIGN'; + if (in_array($value->status, ['refused', 'refusedNote', 'validatedNote'])) { + $adrType = 'NOTE'; + } + $storeResult = \Docserver\controllers\DocserverController::storeResourceOnDocServer([ + 'collId' => 'letterbox_coll', + 'docserverTypeId' => 'DOC', + 'encodedResource' => $value->encodedFile, + 'format' => 'pdf' + ]); + \SrcCore\models\DatabaseModel::insert([ + 'table' => 'adr_letterbox', + 'columnsValues' => [ + 'res_id' => $resId, + 'type' => $adrType, + 'docserver_id' => $storeResult['docserver_id'], + 'path' => $storeResult['destination_dir'], + 'filename' => $storeResult['file_destination_name'], + 'version' => $value->version, + 'fingerprint' => empty($storeResult['fingerPrint']) ? null : $storeResult['fingerPrint'] + ] ]); } $additionalHistoryInfo = ''; if (!empty($value->workflowInfo)) { $additionalHistoryInfo = ' : ' . $value->workflowInfo; } - if ($value->status == 'validatedNote') { + if (in_array($value->status, ['validatedNote', 'validated'])) { $GLOBALS['logger']->write('Document validated', 'INFO'); - Bt_validatedMail(['status' => $validatedStatusAnnot, 'resId' => $value->res_id]); - + $status = $validatedStatus; + if ($value->status == 'validatedNote') { + $status = $validatedStatusAnnot; + } + $GLOBALS['db']->query('UPDATE res_letterbox SET status = ? WHERE res_id = ? ', [$status, $resId]); Bt_history([ 'table_name' => 'res_letterbox', - 'record_id' => $value->res_id, + 'record_id' => $resId, 'info' => 'Le document '.$resId.' (res_letterbox) a été validé dans le parapheur externe' . $additionalHistoryInfo, 'event_type' => 'ACTION#1', 'event_id' => '1' ]); - } elseif ($value->status == 'refusedNote') { + } elseif (in_array($value->status, ['refusedNote', 'refused'])) { $GLOBALS['logger']->write('Document refused', 'INFO'); - $GLOBALS['db']->query("UPDATE res_letterbox SET status = '" . $refusedStatusAnnot . "' WHERE res_id = ?", [$resId]); - + $status = $refusedStatus; + if ($value->status == 'refusedNote') { + $status = $refusedStatusAnnot; + } + $GLOBALS['db']->query("UPDATE res_letterbox SET status = ? WHERE res_id = ?", [$status, $resId]); Bt_history([ 'table_name' => 'res_letterbox', 'record_id' => $resId, @@ -437,7 +463,7 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) { 'event_id' => '1' ]); } - $GLOBALS['db']->query("UPDATE res_letterbox SET external_signatory_book_id = null WHERE res_id = ?", [$resId]); + $GLOBALS['db']->query("UPDATE res_letterbox SET external_id = external_id - 'signatureBookId' WHERE res_id = ?", [$resId]); } $GLOBALS['logger']->write('End of process', 'INFO'); diff --git a/sql/index_creation.sql b/sql/index_creation.sql index edce9ca7dbcc91561a6ea29f40f3ca2ae2f1ceeb..2541f40f1848ad8d5cadad012a0f71ab326307cd 100755 --- a/sql/index_creation.sql +++ b/sql/index_creation.sql @@ -9,7 +9,6 @@ CREATE INDEX res_letterbox_docserver_id_idx ON res_letterbox (docserver_id); CREATE INDEX res_letterbox_filename_idx ON res_letterbox (filename); CREATE INDEX res_departure_date_idx ON res_letterbox (departure_date); CREATE INDEX res_barcode_idx ON res_letterbox (barcode); -CREATE INDEX external_signatory_book_id_idx ON res_letterbox (external_signatory_book_id); CREATE INDEX category_id_idx ON res_letterbox (category_id); -- res_attachments diff --git a/sql/sample.sql b/sql/sample.sql index 0ca9a83d189ee055c4bc9f6460cabffa42e357f8..b03d23e96bbe280980a30d7bdad479e5c621ef69 100644 --- a/sql/sample.sql +++ b/sql/sample.sql @@ -16,22 +16,22 @@ INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_da VALUES (6, 'Relance place en creche', 307, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'relance_place_creche.pdf', '0', 24877, 'ATT_MP', 'PE', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ssaporta', 'incoming', 'MAARCH/2019A/5', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -- to annotate documents -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (7, 'Pétition pour la survie du square Carré', 201, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'petition_square_carre.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', 7, 'incoming', 'MAARCH/2019A/6', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (8, 'Félicitations élections', 205, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'felicitations.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', 8, 'incoming', 'MAARCH/2019A/7', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (9, 'Demande place creche', 307, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'formulaire_place_creche.pdf', '0', 24877, 'ATT_MP', 'PE', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ssaporta', 9, 'incoming', 'MAARCH/2019A/8', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (10, 'Demande subvention jokkolabs', 406, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'demande_subvention.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', 10, 'incoming', 'MAARCH/2019A/9', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (11, 'Facture Maarch', 407, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'facture.pdf', '0', 24877, 'ATT_MP', 'FIN', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'sstar', 11, 'incoming', 'MAARCH/2019A/10', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (12, 'Demande état civil', 602, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'etat_civil.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', 12, 'incoming', 'MAARCH/2019A/11', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (13, 'Arret maladie vide', 701, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'arret_maladie.pdf', '0', 24877, 'ATT_MP', 'DRH', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ppruvost', 13, 'incoming', 'MAARCH/2019A/12', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_signatory_book_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) -VALUES (14, 'Inscription école', 307, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'inscription_ecole.pdf', '0', 24877, 'ATT_MP', 'PE', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ssaporta', 14, 'incoming', 'MAARCH/2019A/13', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (7, 'Pétition pour la survie du square Carré', 201, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'petition_square_carre.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', '{"signatureBookId": "7"}', 'incoming', 'MAARCH/2019A/6', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (8, 'Félicitations élections', 205, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'felicitations.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', '{"signatureBookId": "8"}', 'incoming', 'MAARCH/2019A/7', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (9, 'Demande place creche', 307, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'formulaire_place_creche.pdf', '0', 24877, 'ATT_MP', 'PE', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ssaporta', '{"signatureBookId": "9"}', 'incoming', 'MAARCH/2019A/8', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (10, 'Demande subvention jokkolabs', 406, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'demande_subvention.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', '{"signatureBookId": "10"}', 'incoming', 'MAARCH/2019A/9', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (11, 'Facture Maarch', 407, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'facture.pdf', '0', 24877, 'ATT_MP', 'FIN', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'sstar', '{"signatureBookId": "11"}', 'incoming', 'MAARCH/2019A/10', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (12, 'Demande état civil', 602, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'etat_civil.pdf', '0', 24877, 'ATT_MP', 'DGS', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'rrenaud', '{"signatureBookId": "12"}', 'incoming', 'MAARCH/2019A/11', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (13, 'Arret maladie vide', 701, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'arret_maladie.pdf', '0', 24877, 'ATT_MP', 'DRH', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ppruvost', '{"signatureBookId": "13"}', 'incoming', 'MAARCH/2019A/12', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); +INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, external_id, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) +VALUES (14, 'Inscription école', 307, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'inscription_ecole.pdf', '0', 24877, 'ATT_MP', 'PE', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ssaporta', '{"signatureBookId": "14"}', 'incoming', 'MAARCH/2019A/13', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); -- to qualify document INSERT INTO res_letterbox (res_id, subject, type_id, format, typist, creation_date, modification_date, doc_date, docserver_id, path, filename, fingerprint, filesize, status, destination, work_batch, origin, priority, policy_id, cycle_id, initiator, dest_user, category_id, alt_identifier, admission_date, process_limit_date, closing_date, alarm1_date, alarm2_date, flag_alarm1, flag_alarm2, model_id) VALUES (15, 'Demande intervention à qualifier', 505, 'pdf', 21, NOW(), NOW(), CURRENT_DATE, 'FASTHD_MAN', 'tests#', 'demande_intervention.pdf', '0', 24877, 'INIT', 'PTE', NULL, NULL, 'poiuytre1357nbvc', NULL, NULL, 'COU', 'ccharles', 'incoming', 'MAARCH/2019A/14', CURRENT_DATE, CURRENT_DATE + 21, NULL, NULL, NULL, 'N', 'N', 1); diff --git a/sql/structure.sql b/sql/structure.sql index 7c2d7999f933ecc06e91d28e37ca3a5ff17fa65e..741a560d485e69fe3d528af687c96acd7e114cb2 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -956,7 +956,6 @@ CREATE TABLE res_letterbox opinion_limit_date timestamp without time zone default NULL, department_number_id text, barcode text, - external_signatory_book_id integer, category_id character varying(32) NOT NULL, alt_identifier character varying(255), admission_date timestamp without time zone, @@ -1142,7 +1141,6 @@ SELECT r.res_id, r.opinion_limit_date, r.department_number_id, r.barcode, - r.external_signatory_book_id, r.initiator, r.destination, r.dest_user, diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index bbfdaf74460270f77d7172311387d298704b1be1..eeedcd0430f6c70a18afc66ce52e644a8c5570a8 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -406,9 +406,9 @@ class ActionMethodController if (!empty($attachmentToFreeze)) { ResModel::update([ - 'set' => ['external_signatory_book_id' => $attachmentToFreeze['letterbox_coll'][$args['resId']]], - 'where' => ['res_id = ?'], - 'data' => [$args['resId']] + 'postSet' => ['external_id' => "jsonb_set(external_id, '{signatureBookId}', '{$attachmentToFreeze['letterbox_coll'][$args['resId']]}'::text::jsonb)"], + 'where' => ['res_id = ?'], + 'data' => [$args['resId']] ]); } diff --git a/src/app/action/controllers/ExternalSignatoryBookTrait.php b/src/app/action/controllers/ExternalSignatoryBookTrait.php index 73c55b9ff760366ea8cbb40b59bbdd8dc25d4b9b..4027cec45320b18e62cbbf760bfe816102e6e1a3 100644 --- a/src/app/action/controllers/ExternalSignatoryBookTrait.php +++ b/src/app/action/controllers/ExternalSignatoryBookTrait.php @@ -55,7 +55,7 @@ trait ExternalSignatoryBookTrait $integratedResource = ResModel::get([ 'select' => [1], - 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_signatory_book_id is null', 'res_id = ?'], + 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_id->>\'signatureBookId\' is null', 'res_id = ?'], 'data' => [$args['resId']] ]); @@ -109,9 +109,9 @@ trait ExternalSignatoryBookTrait if (!empty($attachmentToFreeze)) { if (!empty($attachmentToFreeze['letterbox_coll'])) { ResModel::update([ - 'set' => ['external_signatory_book_id' => $attachmentToFreeze['letterbox_coll'][$args['resId']]], - 'where' => ['res_id = ?'], - 'data' => [$args['resId']] + 'postSet' => ['external_id' => "jsonb_set(external_id, '{signatureBookId}', '{$attachmentToFreeze['letterbox_coll'][$args['resId']]}'::text::jsonb)"], + 'where' => ['res_id = ?'], + 'data' => [$args['resId']] ]); } else { if (!empty($attachmentToFreeze['attachments_coll'])) { diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index eeaf856948291d03ea1cf70122730b72ce97ecf0..bf09b61f12687c71cb2d284fe7b5ed720bf2d45a 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -448,7 +448,7 @@ class PreProcessActionController $integratedResource = ResModel::get([ 'select' => [1], - 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_signatory_book_id is null', 'res_id = ?'], + 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_id->>\'signatureBookId\' is null', 'res_id = ?'], 'data' => [$resId] ]); @@ -628,13 +628,13 @@ class PreProcessActionController } foreach ($data['resources'] as $resId) { - $noAttachmentsResource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier', 'filename']]); + $noAttachmentsResource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier', 'filename', 'external_id->>\'signatureBookId\' as signaturebookid']]); if (empty($noAttachmentsResource['alt_identifier'])) { $noAttachmentsResource['alt_identifier'] = _UNDEFINED; } if (empty($noAttachmentsResource['filename'])) { - $additionalsInfos['noMail'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noDocument']; + $additionalsInfos['noMail'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noDocumentToSend']; continue; } $adrMainInfo = ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => 'letterbox_coll']); @@ -652,6 +652,10 @@ class PreProcessActionController $additionalsInfos['noMail'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'fileDoesNotExists']; continue; } + if (!empty($noAttachmentsResource['signaturebookid'])) { + $additionalsInfos['noMail'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'fileAlreadySendToSignatureBook']; + continue; + } $additionalsInfos['mails'][] = ['res_id' => $resId]; } } diff --git a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php index 735f1530061a24080cf9a30edd374bc0fb47a849..0704b1c4717e61ece0e9cb4e7cc3343665b01960 100755 --- a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php +++ b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php @@ -211,7 +211,7 @@ class MaarchParapheurController $integratedResource = ResModel::get([ 'select' => ['res_id', 'docserver_id', 'path', 'filename'], - 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_signatory_book_id is null', 'res_id = ?'], + 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_id->>\'signatureBookId\' is null', 'res_id = ?'], 'data' => [$aArgs['resIdMaster']] ]); @@ -493,12 +493,12 @@ class MaarchParapheurController if (!empty($state['note'])) { $aArgs['idsToRetrieve'][$version][$resId]->noteContent = $state['note']; $userInfos = UserModel::getByExternalId([ - 'select' => ['user_id'], + 'select' => ['id'], 'externalId' => $state['noteCreatorId'], 'externalName' => 'maarchParapheur' ]); if (!empty($userInfos)) { - $aArgs['idsToRetrieve'][$version][$resId]->noteCreatorId = $userInfos['user_id']; + $aArgs['idsToRetrieve'][$version][$resId]->noteCreatorId = $userInfos['id']; } else { $aArgs['idsToRetrieve'][$version][$resId]->noteCreatorName = $state['noteCreatorName']; } diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 64aa6bacc0065987913651b34149e5113ddf6cbe..665f1f528d48ef3d44896baa6b930908283644f2 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -1070,7 +1070,7 @@ class ResController { $body = $args['body']; - $resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['status', 'model_id', 'external_signatory_book_id']]); + $resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['status', 'model_id', 'external_id->>\'signatureBookId\' as signaturebookid']]); if (empty($resource['status'])) { return ['errors' => 'Resource status is empty. It can not be modified']; } @@ -1083,7 +1083,7 @@ class ResController return ['errors' => 'Body is not set or empty']; } elseif (!Validator::intVal()->notEmpty()->validate($body['doctype'])) { return ['errors' => 'Body doctype is empty or not an integer']; - } elseif (!empty($body['encodedFile']) && !empty($resource['external_signatory_book_id'])) { + } elseif (!empty($body['encodedFile']) && !empty($resource['signaturebookid'])) { return ['errors' => 'Resource is in external signature book, file can not be modified']; } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 7bafb362f747e04980ecd4bd8ebafaf8ceba8a67..63a664ab1d381e83284f7c2466ff489687ad7bb2 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1449,6 +1449,7 @@ export const LANG_EN = { "PRE": "Back absence", "RESETPSW": "Password reset", "ERROR": "Error", + "fileAlreadySentToSignatureBook": "File already send to signature book", "systemActions": "System action(s)", "viewAllHistory": "View all history", "viewActionsHistory": "View only actions in history", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 48de7b6793152d9c947aab9cff487667e7884cdf..2d72728f40d56178d38cc0756bb92728f3fe2155 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1488,6 +1488,7 @@ export const LANG_FR = { "PRE": "Retour d'absence", "RESETPSW": "Réinitialisation de mot de passe", "ERROR": "Erreur", + "fileAlreadySentToSignatureBook": "Fichier déjà envoyé au parapheur", "systemActions": "Événement(s) système", "viewAllHistory": "Afficher tout l'historique", "viewActionsHistory": "Afficher l'historique des actions", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index de53ba6406de7f0b3941a0a85ac2a69a4162f364..7597b8d180deb0001ce1605882b2cd5439d49288 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1474,6 +1474,7 @@ export const LANG_NL = { "PRE": "Back absence",//_TO_TRANSLATE "RESETPSW": "Password reset",//_TO_TRANSLATE "ERROR": "Error", //_TO_TRANSLATE + "fileAlreadySentToSignatureBook": "File already send to signature book", //_TO_TRANSLATE "systemActions": "System action(s)", //_TO_TRANSLATE "viewAllHistory": "View all history", //_TO_TRANSLATE "viewActionsHistory": "View only actions in history", //_TO_TRANSLATE