diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index ee667706f941342a433cfdc594aa396dcdce39f0..6b74b5abc1b1d30f5d5c69cc21828d80cf5c3ea5 100755 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -1651,25 +1651,24 @@ abstract class lists_Abstract extends Database public function tmplt_func_final_version($resultTheLine) { - $nbresult_I = count($resultTheLine); - for($iresults=0;$iresults<$nbresult_I;$iresults++){ - if($resultTheLine[$iresults]['relation']){ - $relation = $resultTheLine[$iresults]['relation']; - } - if($resultTheLine[$iresults]['fromDetail']){ - $fromDetail = $resultTheLine[$iresults]['fromDetail']; + foreach ($resultTheLine as $value){ + if ($value['column'] == 'in_signature_book') { + $inSignatureBook = $value['value']; } } + $return = '<input type="checkbox" name="final" id="final" align="left"'; - - if ($resultTheLine[2]['value_bis'] == "TRA") { + if (!empty($inSignatureBook)) { $return .= 'checked '; } - $return .= 'onclick="setFinalVersion(\'' . $_SESSION['config']['businessappurl'] - . 'index.php?display=true&module=attachments&page=setFinalVersion&relation='.$resultTheLine[1]['value'].'&id=' . $resultTheLine[0]['value'] . '&relation='.$relation.'&fromDetail='.$fromDetail.'\');"/>' - . _FINAL_VERSION; + $isVersion = 'false'; + if ($resultTheLine[1]['value'] > 1) { + $isVersion = 'true'; + } + $return .= 'onclick="setAttachmentInSignatureBook(' . $resultTheLine[0]['value'] . ', ' . $isVersion . ');"/>Intégrer dans le parapheur'; + return $return; } diff --git a/apps/maarch_entreprise/js/angularFunctions.js b/apps/maarch_entreprise/js/angularFunctions.js index 8f8ba2a2baa876cd931fd4821f1571f0068eed07..b8f05660a79a54e3f8f19bc72301d6de38d6be62 100755 --- a/apps/maarch_entreprise/js/angularFunctions.js +++ b/apps/maarch_entreprise/js/angularFunctions.js @@ -167,9 +167,23 @@ function duplicateTemplate(id) { success: function(answer) { location.href = "index.php?page=templates_management_controler&mode=up&module=templates&id=" + answer.id + "&start=0&order=asc&order_field=&what="; }, error: function(err) { - alert(err); + alert("Une erreur s'est produite"); } }); } } +function setAttachmentInSignatureBook(id, isVersion) { + $j.ajax({ + url : '../../rest/attachments/' + id + '/inSignatureBook', + type : 'PUT', + dataType : 'json', + data: { + isVersion : isVersion + }, + success: function(answer) { + }, error: function(err) { + alert("Une erreur s'est produite"); + } + }); +} diff --git a/modules/attachments/Controllers/AttachmentsController.php b/modules/attachments/Controllers/AttachmentsController.php index e0f1d75710f6676d986791a484f2776eeff018ba..c555870a2f98dcf059c56b2a2b8b338b85944164 100755 --- a/modules/attachments/Controllers/AttachmentsController.php +++ b/modules/attachments/Controllers/AttachmentsController.php @@ -416,4 +416,20 @@ class AttachmentsController return $transmissionDataPdf; } -} \ No newline at end of file + public function setInSignatureBook(RequestInterface $request, ResponseInterface $response, $aArgs) + { + //TODO Controle de droit de modification de cet attachment + + $data = $request->getParams(); + + $attachment = AttachmentsModel::getById(['id' => $aArgs['id'], 'isVersion' => $data['isVersion']]); + + if (empty($attachment)) { + return $response->withStatus(400)->withJson(['errors' => 'Attachment not found']); + } + + AttachmentsModel::setInSignatureBook(['id' => $aArgs['id'], 'isVersion' => $data['isVersion'], 'inSignatureBook' => !$attachment['in_signature_book']]); + + return $response->withJson(['success' => 'success']); + } +} diff --git a/modules/attachments/Models/AttachmentsModelAbstract.php b/modules/attachments/Models/AttachmentsModelAbstract.php index babfb7104a4a08fc533746adfdc7b2b634d225bc..567c60fcaf903eef6f031d4259b44a8e960c1c7b 100755 --- a/modules/attachments/Models/AttachmentsModelAbstract.php +++ b/modules/attachments/Models/AttachmentsModelAbstract.php @@ -15,6 +15,32 @@ use Core\Models\ValidatorModel; class AttachmentsModelAbstract { + public static function getById(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['id']); + ValidatorModel::intVal($aArgs, ['id']); + ValidatorModel::stringType($aArgs, ['isVersion']); + + if ($aArgs['isVersion'] == 'true') { + $table = 'res_version_attachments'; + } else { + $table = 'res_attachments'; + } + + $aAttachment = DatabaseModel::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => [$table], + 'where' => ['res_id = ?'], + 'data' => [$aArgs['id']], + ]); + + if (empty($aAttachment[0])) { + return []; + } + + return $aAttachment[0]; + } + public static function getAttachmentsTypesByXML() { $customId = CoreConfigModel::getCustomId(); @@ -87,7 +113,7 @@ class AttachmentsModelAbstract $select = [ 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], 'table' => ['res_view_attachments'], - 'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status not in ('DEL', 'OBS')"], + 'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status not in ('DEL', 'OBS')", 'in_signature_book = TRUE'], 'data' => [$aArgs['resIdMaster'], $aArgs['notIn']], ]; if (!empty($aArgs['orderBy'])) { @@ -138,4 +164,34 @@ class AttachmentsModelAbstract return true; } + + public static function setInSignatureBook(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['id']); + ValidatorModel::intVal($aArgs, ['id']); + ValidatorModel::stringType($aArgs, ['isVersion']); + ValidatorModel::boolType($aArgs, ['inSignatureBook']); + + if ($aArgs['isVersion'] == 'true') { + $table = 'res_version_attachments'; + } else { + $table = 'res_attachments'; + } + if ($aArgs['inSignatureBook']) { + $aArgs['inSignatureBook'] = 'true'; + } else { + $aArgs['inSignatureBook'] = 'false'; + } + + DatabaseModel::update([ + 'table' => $table, + 'set' => [ + 'in_signature_book' => $aArgs['inSignatureBook'] + ], + 'where' => ['res_id = ?'], + 'data' => [$aArgs['id']], + ]); + + return true; + } } diff --git a/modules/attachments/frame_list_attachments.php b/modules/attachments/frame_list_attachments.php index 5d35464ae3b569574424e614223a42dfbc5047cf..bcd3e51e685843331fae1070a35fe2aeb3e00c6d 100755 --- a/modules/attachments/frame_list_attachments.php +++ b/modules/attachments/frame_list_attachments.php @@ -90,7 +90,7 @@ $select['res_view_attachments'] = array(); // Important de laisser cet ordre : 'res_id', 'res_id_version', 'relation', 'status' array_push( - $select['res_view_attachments'], 'res_id', 'res_id_version', 'relation', 'status', 'identifier', 'attachment_type', 'title', 'dest_user', 'dest_contact_id', 'creation_date', 'typist', 'doc_date', 'updated_by', 'validation_date', 'format'); + $select['res_view_attachments'], 'res_id', 'res_id_version', 'relation', 'status', 'identifier', 'attachment_type', 'title', 'dest_user', 'dest_contact_id', 'creation_date', 'typist', 'doc_date', 'updated_by', 'validation_date', 'format', 'in_signature_book'); $where = " (res_id_master = ? and coll_id = ? and status <> 'DEL' and status <> 'OBS' and (status <> 'TMP' or (typist = ? and status = 'TMP')))"; $arrayPDO = array($resId, $_SESSION['collection_id_choice'], $_SESSION['user']['UserId']); diff --git a/rest/index.php b/rest/index.php index 3bd9281e0fd629499e9628bde0fcb45a6c6d824d..b642738003ff046f6b20ceb6957a11c7b6931483 100755 --- a/rest/index.php +++ b/rest/index.php @@ -113,13 +113,6 @@ $app->get('/administration/users/{id}', \Core\Controllers\UserController::class $app->get('/administration/notifications/new', \Notifications\Controllers\NotificationController::class . ':getNewNotificationForAdministration'); $app->get('/administration/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':getNotificationForAdministration'); -//notifications -$app->get('/notifications', \Notifications\Controllers\NotificationController::class . ':get'); -$app->get('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':getById'); -$app->delete('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':delete'); -$app->post('/notifications', \Notifications\Controllers\NotificationController::class . ':create'); -$app->put('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':update'); - //status $app->get('/administration/status', \Core\Controllers\StatusController::class . ':getList'); $app->get('/administration/status/new', \Core\Controllers\StatusController::class . ':getNewInformations'); @@ -158,6 +151,7 @@ $app->get('/groups/{groupId}/baskets/{basketId}/signatureBook/{resId}', \Visa\Co $app->get('/signatureBook/{resId}/attachments', \Visa\Controllers\VisaController::class . ':getAttachmentsById'); $app->get('/signatureBook/{resId}/incomingMailAttachments', \Visa\Controllers\VisaController::class . ':getIncomingMailAndAttachmentsById'); $app->put('/{collId}/{resId}/unsign', \Visa\Controllers\VisaController::class . ':unsignFile'); +$app->put('/attachments/{id}/inSignatureBook', \Attachments\Controllers\AttachmentsController::class . ':setInSignatureBook'); //resource $app->post('/res', \Core\Controllers\ResController::class . ':create'); @@ -227,6 +221,13 @@ $app->post('/actions', \Core\Controllers\ActionsController::class . ':create'); $app->put('/actions/{id}', \Core\Controllers\ActionsController::class . ':update'); $app->delete('/actions/{id}', \Core\Controllers\ActionsController::class . ':delete'); +//Notifications +$app->get('/notifications', \Notifications\Controllers\NotificationController::class . ':get'); +$app->post('/notifications', \Notifications\Controllers\NotificationController::class . ':create'); +$app->get('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':getById'); +$app->put('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':update'); +$app->delete('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':delete'); + //Reports $app->get('/reports/groups/{groupId}', \Core\Controllers\ReportController::class . ':getByGroupId'); $app->put('/reports/groups/{groupId}', \Core\Controllers\ReportController::class . ':updateForGroupId'); diff --git a/sql/17_xx.sql b/sql/17_xx.sql index 17b476464a5cf9f9c8df069a3b075a6cae0b8462..c290985a8b4a0d1c20b749e964eb7f1cd08399d6 100755 --- a/sql/17_xx.sql +++ b/sql/17_xx.sql @@ -110,3 +110,28 @@ ALTER TABLE baskets ADD color character varying(16); /*ENTITIES FULL NAME*/ ALTER TABLE entities DROP COLUMN IF EXISTS entity_full_name; ALTER TABLE entities ADD entity_full_name text; + +/*IN SIGNATURE BOOK*/ +ALTER TABLE res_attachments DROP COLUMN IF EXISTS in_signature_book; +ALTER TABLE res_attachments ADD in_signature_book boolean default false; +ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS in_signature_book; +ALTER TABLE res_version_attachments ADD in_signature_book boolean default false; +DROP VIEW IF EXISTS res_view_attachments; +CREATE VIEW res_view_attachments AS + SELECT '0' as res_id, res_id as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist, + creation_date, fulltext_result, ocr_result, author, author_name, identifier, source, + doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path, + filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count, + scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark, + envelop_id, status, destination, approver, validation_date, effective_date, work_batch, origin, is_ingoing, priority, initiator, dest_user, + 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 + FROM res_version_attachments + UNION ALL + SELECT res_id, '0' as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist, + creation_date, fulltext_result, ocr_result, author, author_name, identifier, source, + doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path, + filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count, + scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark, + envelop_id, status, destination, approver, validation_date, effective_date, work_batch, origin, is_ingoing, priority, initiator, dest_user, + coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0', in_signature_book + FROM res_attachments;