diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index 20229cb33107f753e30e7ca6f349034a02e9a5c8..c0a5952dbf81c047739815ed6467a8cd84bdfb4b 100755 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -1624,19 +1624,40 @@ abstract class lists_Abstract extends Database if ($value['column'] == 'in_signature_book') { $inSignatureBook = $value['value']; } + if ($value['column'] == 'in_send_attach') { + $inSendAttach = $value['value']; + } + } + + + $isVersion = 'false'; + if ($resultTheLine[1]['value'] > 1) { + $isVersion = 'true'; } - $return = '<input type="checkbox" name="final" id="final" align="left"'; + $return = '<div>'; - if (!empty($inSignatureBook)) { + $return .= '<input type="checkbox" name="sendAttach" id="sendAttach" align="left"'; + + if (!empty($inSendAttach)) { $return .= 'checked '; } - $isVersion = 'false'; - if ($resultTheLine[1]['value'] > 1) { - $isVersion = 'true'; + $return .= 'onclick="setSendAttachment('.$resultTheLine[0]['value'].', '.$isVersion.');"/><label for="sendAttach">'._PUT_IN_SEND_ATTACH.'</label>'; + + $return .= '</div>'; + + $return .= '<div>'; + + $return .= '<input type="checkbox" name="final" id="final" align="left"'; + + if (!empty($inSignatureBook)) { + $return .= 'checked '; } - $return .= 'onclick="setAttachmentInSignatureBook('.$resultTheLine[0]['value'].', '.$isVersion.');"/>'._PUT_IN_SIGNATORY_BOOK; + + $return .= 'onclick="setAttachmentInSignatureBook('.$resultTheLine[0]['value'].', '.$isVersion.');"/><label for="final">'._PUT_IN_SIGNATORY_BOOK.'</label>'; + + $return .= '</div>'; return $return; } diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js index 70d4cf5ab3ab6047a7b73b8a5bfec9c1e468144f..c3068089d2a384961f864207e3c6a3aa05b07d72 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -3958,3 +3958,23 @@ function displayAddMailing() { $j("#addMailing").show(); } } + + +function setSendAttachment(id, isVersion) { + $j.ajax({ + url: '../../rest/attachments/' + id + '/inSendAttachment', + type: 'PUT', + dataType: 'json', + data: { + isVersion: isVersion + }, + success: function (answer) { + if (typeof window.parent['angularSignatureBookComponent'] !== "undefined") { + window.parent.angularSignatureBookComponent.componentAfterAttach("left"); + } + }, + error: function (err) { + alert("Une erreur s'est produite : " + err.responseJSON.exception[0].message); + } + }); +} \ No newline at end of file diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php index 9920ca3170762b8e057a2f7547600df94f345ed0..eff3e7247cac510aadb1b4afbc0765e65960594a 100755 --- a/apps/maarch_entreprise/lang/en.php +++ b/apps/maarch_entreprise/lang/en.php @@ -5079,3 +5079,6 @@ if (!defined('_ELECTRONIC')) { if (!defined('_ACKNOWLEDGEMENT_RECEIPTS')) { define('_ACKNOWLEDGEMENT_RECEIPTS', 'Acknowledgement of receipts'); } +if (!defined('_PUT_IN_SEND_ATTACH')) { + define('_PUT_IN_SEND_ATTACH', 'Put in send attachement'); +} diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index 0a81ce879c938840ab959ba54e5839bb72b4a36b..34af09290275f12239f7dc031bf8189f064be998 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -5241,3 +5241,6 @@ if (!defined('_ELECTRONIC')) { if (!defined('_ACKNOWLEDGEMENT_RECEIPTS')) { define('_ACKNOWLEDGEMENT_RECEIPTS', 'Accusés de réception'); } +if (!defined('_PUT_IN_SEND_ATTACH')) { + define('_PUT_IN_SEND_ATTACH', 'Intégrer aux envois'); +} diff --git a/apps/maarch_entreprise/lang/nl.php b/apps/maarch_entreprise/lang/nl.php index 3a1018814195ccabff793400b4bdb6dd61c5e104..d5c6608d6304ad7622744a1cddd79378313c211a 100755 --- a/apps/maarch_entreprise/lang/nl.php +++ b/apps/maarch_entreprise/lang/nl.php @@ -1725,4 +1725,7 @@ if (!defined('_ELECTRONIC')) { } if (!defined('_ACKNOWLEDGEMENT_RECEIPTS')) { define('_ACKNOWLEDGEMENT_RECEIPTS', 'Acknowledgement of receipts'); +} +if (!defined('_PUT_IN_SEND_ATTACH')) { + define('_PUT_IN_SEND_ATTACH', 'Put in send attachement'); } \ No newline at end of file diff --git a/apps/maarch_entreprise/template/documents_list_attachments.html b/apps/maarch_entreprise/template/documents_list_attachments.html index 73d25335436d103b16b8ff69af78c261f0b9f612..5c54d7e0eb7f55f1b55cf367cea31d023725494f 100755 --- a/apps/maarch_entreprise/template/documents_list_attachments.html +++ b/apps/maarch_entreprise/template/documents_list_attachments.html @@ -223,7 +223,7 @@ Mods <tbody> <tr> <td style="width:20%;text-align:right;">##func_modify## ##func_delete##</td> - <td style="width:10%;text-align:center;padding-bottom:5px;">##func_final_version##</td> + <td style="width:10%;text-align:left;padding-bottom:5px;">##func_final_version##</td> <td style="width:1%;text-align:right;" class="attachmentIcon">##visualizeIconDocument##</td> <td style="width:1%;text-align:right;" class="attachmentIcon">##downloadIconDocument##</td> </tr> diff --git a/modules/attachments/frame_list_attachments.php b/modules/attachments/frame_list_attachments.php index ac97c319857d6157416709e9e464378a5b469959..5e7ba2e0c6ad896bbc583615dac1b3d2c4c0fb90 100755 --- a/modules/attachments/frame_list_attachments.php +++ b/modules/attachments/frame_list_attachments.php @@ -97,7 +97,8 @@ array_push( 'updated_by', 'validation_date', 'format', - 'in_signature_book' + 'in_signature_book', + 'in_send_attach' ); $where = " (res_id_master = ? and coll_id = ? and status <> 'DEL' and status <> 'OBS' and (status <> 'TMP' or (typist = ? and status = 'TMP')))"; diff --git a/rest/index.php b/rest/index.php index c6e9cb5bf6b7254360f67cdcd1fa4b72e3bd3c50..574136dd65598d1df4a657a72fb0876b8e89d057 100755 --- a/rest/index.php +++ b/rest/index.php @@ -288,6 +288,7 @@ $app->get('/administration/shippings/{id}', \Shipping\controllers\ShippingContro $app->post('/administration/shippings', \Shipping\controllers\ShippingController::class . ':create'); $app->put('/administration/shippings/{id}', \Shipping\controllers\ShippingController::class . ':update'); $app->delete('/administration/shippings/{id}', \Shipping\controllers\ShippingController::class . ':delete'); +$app->put('/attachments/{id}/inSendAttachment', \Attachment\controllers\AttachmentController::class . ':setInSendAttachment'); //SignatureBook $app->get('/signatureBook/users/{userId}/groups/{groupId}/baskets/{basketId}/resources', \SignatureBook\controllers\SignatureBookController::class . ':getResources'); diff --git a/sql/develop.sql b/sql/develop.sql index 4efb26a7d3e803881af248776c1d875e0c749357..1f9ee6383f92c1115c8390807de857fa243625fd 100755 --- a/sql/develop.sql +++ b/sql/develop.sql @@ -170,6 +170,12 @@ UPDATE actions SET component = 'resMarkAsReadAction' WHERE action_page = 'mark_a UPDATE actions SET component = 'signatureBookAction' WHERE action_page = 'visa_mail'; UPDATE actions SET component = 'redirectAction' WHERE action_page = 'redirect'; +/*SHIPPING*/ +ALTER TABLE res_attachments DROP COLUMN IF EXISTS in_send_attach; +ALTER TABLE res_attachments ADD COLUMN in_send_attach boolean NOT NULL DEFAULT false; +ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS in_send_attach; +ALTER TABLE res_version_attachments ADD COLUMN in_send_attach boolean NOT NULL DEFAULT false; + /* Acknowledgement Receipts */ DROP TABLE IF EXISTS acknowledgement_receipts; CREATE TABLE acknowledgement_receipts @@ -239,7 +245,6 @@ DO $$ BEGIN END IF; END$$; - /* RE-CREATE VIEW*/ CREATE OR REPLACE VIEW res_view_letterbox AS SELECT r.tablename, @@ -427,3 +432,17 @@ CREATE OR REPLACE VIEW view_contacts AS RIGHT JOIN contact_addresses ca ON c.contact_id = ca.contact_id LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id LEFT JOIN contact_types ct ON c.contact_type = ct.id; + +DROP VIEW IF EXISTS res_view_attachments; +CREATE OR REPLACE VIEW res_view_attachments AS + SELECT '0' as res_id, res_id as res_id_version, title, subject, description, type_id, format, typist, + creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path, + filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id, + coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master, in_signature_book, in_send_attach, signatory_user_serial_id + FROM res_version_attachments + UNION ALL + SELECT res_id, '0' as res_id_version, title, subject, description, type_id, format, typist, + creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path, + filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id, + coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0', in_signature_book, in_send_attach, signatory_user_serial_id + FROM res_attachments; diff --git a/sql/structure.sql b/sql/structure.sql index 06e24d684d5bba395e695b42f302bbd9cb258eea..84e2d3267feb9f2e04599dbcdf2f42d9b61dafd9 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -286,6 +286,7 @@ CREATE TABLE res_attachments tnl_path character varying(255) DEFAULT NULL::character varying, tnl_filename character varying(255) DEFAULT NULL::character varying, in_signature_book boolean DEFAULT FALSE, + in_send_attach boolean DEFAULT FALSE, signatory_user_serial_id int, convert_result character varying(10) DEFAULT NULL::character varying, convert_attempts integer DEFAULT NULL::integer, @@ -1891,6 +1892,7 @@ CREATE TABLE res_version_attachments res_id_master bigint, attachment_id_master bigint, in_signature_book boolean DEFAULT FALSE, + in_send_attach boolean DEFAULT FALSE, signatory_user_serial_id int, convert_result character varying(10) DEFAULT NULL::character varying, convert_attempts integer DEFAULT NULL::integer, @@ -1925,13 +1927,13 @@ CREATE VIEW res_view_attachments AS SELECT '0' as res_id, res_id as res_id_version, title, subject, description, type_id, format, typist, creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path, filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id, - coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master, in_signature_book, signatory_user_serial_id + coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master, in_signature_book, in_send_attach, signatory_user_serial_id FROM res_version_attachments UNION ALL SELECT res_id, '0' as res_id_version, title, subject, description, type_id, format, typist, creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path, filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id, - coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0', in_signature_book, signatory_user_serial_id + coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0', in_signature_book, in_send_attach, signatory_user_serial_id FROM res_attachments; -- thesaurus diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index 6056b8fcbcf4d890ee84613e4fc7cf93dc7a9da9..7af5ec56aa083c89bef445b842ec456dfd07071b 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -98,6 +98,25 @@ class AttachmentController return $response->withJson(['success' => 'success']); } + public function setInSendAttachment(Request $request, Response $response, array $aArgs) + { + //TODO Controle de droit de modification de cet attachment + + $data = $request->getParams(); + + $data['isVersion'] = filter_var($data['isVersion'], FILTER_VALIDATE_BOOLEAN); + + $attachment = AttachmentModel::getById(['id' => $aArgs['id'], 'isVersion' => $data['isVersion']]); + + if (empty($attachment)) { + return $response->withStatus(400)->withJson(['errors' => 'Attachment not found']); + } + + AttachmentModel::setInSendAttachment(['id' => $aArgs['id'], 'isVersion' => $data['isVersion'], 'inSendAttachment' => !$attachment['in_send_attach']]); + + return $response->withJson(['success' => 'success']); + } + public function getThumbnailContent(Request $request, Response $response, array $aArgs) { if (!Validator::intVal()->validate($aArgs['resId']) || !Validator::intVal()->validate($aArgs['resIdMaster']) || !ResController::hasRightByResId(['resId' => [$aArgs['resIdMaster']], 'userId' => $GLOBALS['userId']])) { diff --git a/src/app/attachment/models/AttachmentModelAbstract.php b/src/app/attachment/models/AttachmentModelAbstract.php index e555c1a8292d53454916c2cea789517b4c30f668..1dd8ea05dd40ec4878335cac11a66decd91d52cf 100755 --- a/src/app/attachment/models/AttachmentModelAbstract.php +++ b/src/app/attachment/models/AttachmentModelAbstract.php @@ -212,6 +212,35 @@ abstract class AttachmentModelAbstract return true; } + public static function setInSendAttachment(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['id']); + ValidatorModel::intVal($aArgs, ['id']); + ValidatorModel::boolType($aArgs, ['inSendAttachment', 'isVersion']); + + if ($aArgs['isVersion'] == true) { + $table = 'res_version_attachments'; + } else { + $table = 'res_attachments'; + } + if ($aArgs['inSendAttachment']) { + $aArgs['inSendAttachment'] = 'true'; + } else { + $aArgs['inSendAttachment'] = 'false'; + } + + DatabaseModel::update([ + 'table' => $table, + 'set' => [ + 'in_send_attach' => $aArgs['inSendAttachment'] + ], + 'where' => ['res_id = ?'], + 'data' => [$aArgs['id']], + ]); + + return true; + } + public static function hasAttachmentsSignedForUserById(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['id', 'user_serial_id', 'isVersion']);