From c3d774f4e37bc3f464a545c53bf2e4266ea7f40d Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Tue, 5 Nov 2019 10:08:08 +0100 Subject: [PATCH] FEAT #11691 TIME 2:30 remove view and version in V1 + external SB + export seda + search adv --- .../actions/sendToExternalSignatureBook.php | 9 - .../admin/contacts/fusionContact.php | 10 - .../class/class_lists_Abstract.php | 42 +--- .../indexing_searching/details.php | 13 -- .../documents_list_mlb_search_adv.php | 6 +- .../indexing_searching/search_adv_result.php | 38 ++-- .../view_resource_controler.php | 35 +--- apps/maarch_entreprise/loadRepList.php | 21 +- apps/maarch_entreprise/xml/config.xml.default | 15 +- core/class/ExportControler.php | 4 +- .../class/attachments_controler_Abstract.php | 30 +-- modules/attachments/del_attachment.php | 6 +- .../attachments/frame_list_attachments.php | 22 +-- modules/attachments/get_chrono_attachment.php | 10 +- .../get_other_chrono_attachment.php | 2 +- modules/attachments/previous_attachments.php | 8 +- modules/attachments/setFinalVersion.php | 53 ++--- modules/attachments/unsetTemporarySaved.php | 6 +- modules/attachments/view_attachment.php | 32 +-- modules/avis/xml/IVS/requests_definitions.xml | 8 - modules/avis/xml/IVS/validation_rules.xml | 5 - .../class_content_manager_tools_Abstract.php | 100 +++++----- .../retrieve_attachment_from_cm.php | 2 +- .../save_attachment_from_cm.php | 19 +- modules/export_seda/export_seda_list.php | 6 +- modules/life_cycle/batch/extract_data.php | 8 +- modules/life_cycle/batch/extract_data_2.php | 8 +- .../batch/process_garbage_collector.php | 4 +- .../ReadMessageExchangeController.php | 3 - .../SendMessageExchangeController.php | 16 +- .../class/class_modules_tools_Abstract.php | 184 +++++++++--------- modules/visa/batch/batch_tools.php | 2 +- .../batch/process_mailsFromSignatoryBook.php | 131 +------------ modules/visa/checkAllAnsSigned.php | 2 +- .../visa/class/FastParapheurController.php | 66 +------ modules/visa/class/IParapheurController.php | 73 +------ modules/visa/class/IxbusController.php | 19 +- .../class/class_modules_tools_Abstract.php | 70 +++---- modules/visa/retrieve_attachment_from_cm.php | 2 +- modules/visa/save_attach_res_from_cm.php | 11 +- modules/visa/send_signed_docs.php | 2 +- modules/visa/sign_file.php | 48 ++--- modules/visa/view_pdf_attachement.php | 157 --------------- modules/visa/xml/IVS/requests_definitions.xml | 8 - modules/visa/xml/IVS/validation_rules.xml | 4 - sql/delete_all_ressources.sql | 3 - sql/index_creation.sql | 6 - sql/structure.sql | 128 ------------ .../ExternalSignatoryBookTrait.php | 9 - .../controllers/MaarchParapheurController.php | 18 +- .../controllers/XParaphController.php | 26 +-- .../administration/privilege/privileges.ts | 8 +- src/frontend/service/privileges.service.ts | 8 +- 53 files changed, 337 insertions(+), 1189 deletions(-) delete mode 100755 modules/visa/view_pdf_attachement.php diff --git a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php index 189e6e7bd04..bf13abedaf5 100755 --- a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php +++ b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php @@ -280,15 +280,6 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col ]); } } - if (!empty($attachmentToFreeze['attachments_version_coll'])) { - foreach ($attachmentToFreeze['attachments_version_coll'] as $resId => $externalId) { - \Attachment\models\AttachmentModel::freezeAttachment([ - 'resId' => $resId, - 'table' => 'res_version_attachments', - 'externalId' => $externalId - ]); - } - } } } diff --git a/apps/maarch_entreprise/admin/contacts/fusionContact.php b/apps/maarch_entreprise/admin/contacts/fusionContact.php index 6ee27727f82..4bf81e63db9 100755 --- a/apps/maarch_entreprise/admin/contacts/fusionContact.php +++ b/apps/maarch_entreprise/admin/contacts/fusionContact.php @@ -30,11 +30,6 @@ foreach ($contacts_id as $key => $value) { $arrayPDO = array($master_contact_id,$value); $db->query($query, $arrayPDO); - //mise à jour des pièces jointes versionnée - $query = "UPDATE res_version_attachments SET dest_contact_id = ? WHERE dest_contact_id = ?"; - $arrayPDO = array($master_contact_id,$value); - $db->query($query, $arrayPDO); - //deplace adresse au master $query = "UPDATE contact_addresses SET contact_id = ? WHERE contact_id = ?"; $arrayPDO = array($master_contact_id,$value); @@ -58,11 +53,6 @@ foreach ($del_address_id as $key => $value) { $arrayPDO = array($master_address_id,$value); $db->query($query, $arrayPDO); - //mise à jour des pièces jointes versionnée - $query = "UPDATE res_version_attachments SET dest_address_id = ? WHERE dest_address_id = ?"; - $arrayPDO = array($master_address_id,$value); - $db->query($query, $arrayPDO); - //supression de l'adresse $query = "DELETE FROM contact_addresses WHERE id = ?"; $arrayPDO = array($value); diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index 4a5774c1e17..2a99a930c58 100755 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -1250,43 +1250,6 @@ abstract class lists_Abstract extends Database } } - protected function _tmplt_showActionBasketsFA($parameter, $resultTheLine) - { - $my_explode = explode('|', $parameter); - - if (!$my_explode[1]) { - return _WRONG_PARAM_FOR_LOAD_VALUE; - } else { - if (count($my_explode) >= 4) { - //Init - $actionIsDisabled = false; - - //Check if action is disabled - if (isset($my_explode[4]) && !empty($my_explode[4])) { - $actionIsDisabled = $this->_checkDisabledRules($my_explode[4], $resultTheLine); - } - //If disabled, return blank - if ($actionIsDisabled) { - return ' '; - } else { - $db = new Database(); - $stmt = $db->query("SELECT res_id_master FROM res_view_attachments WHERE status = 'EXP_RTURN' AND validation_date < CURRENT_TIMESTAMP AND res_id_master = ?", - [$resultTheLine[0]['res_id']]); - $color = ''; - if ($stmt->rowCount() >= 1) { - $color = 'style="color: red"'; - } - //return action icon - return '<a href="javascript://" onClick="'.$my_explode[3] - .'" title="'.$my_explode[1].'"><i class="fa fa-' - .$my_explode[2].' fa-2x" '.$color.' title="'.$my_explode[1].'"></i></a>'; - } - } else { - return _WRONG_PARAM_FOR_LOAD_VALUE; - } - } - } - protected function _tmplt_func_isConfidential($resultTheLine) { $db = new Database(); @@ -1326,7 +1289,7 @@ abstract class lists_Abstract extends Database } $db = new Database(); $stmt = $db->query( - "SELECT count(*) as total FROM res_view_attachments WHERE res_id_master = ? and status not in ('DEL','OBS','TMP') and lower(translate(title,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(?)", array($resultTheLine[0]['res_id'], $_SESSION['searching']['where_request_parameters'][':subject']) + "SELECT count(1) as total FROM res_attachments WHERE res_id_master = ? and status not in ('DEL','OBS','TMP') and lower(translate(title,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(?)", array($resultTheLine[0]['res_id'], $_SESSION['searching']['where_request_parameters'][':subject']) ); $res_attach = $stmt->fetchObject(); if ($res_attach->total > 0) { @@ -1736,9 +1699,6 @@ abstract class lists_Abstract extends Database //#showActionFA## : show action Font Awesome } elseif (preg_match("/^showActionFA\|/", $parameter)) { $var = $this->_tmplt_showActionFA($parameter, $resultTheLine); - //#showActionBasketsFA## : show action Font Awesome - } elseif (preg_match("/^showActionBasketsFA\|/", $parameter)) { - $var = $this->_tmplt_showActionBasketsFA($parameter, $resultTheLine); //#showActionAdvResultFA## : show action Font Awesome } elseif (preg_match("/^showActionAdvResultFA\|/", $parameter)) { $var = $this->_tmplt_showActionAdvResultFA($parameter, $resultTheLine); diff --git a/apps/maarch_entreprise/indexing_searching/details.php b/apps/maarch_entreprise/indexing_searching/details.php index 1e8904ceb13..f3077c23ecc 100755 --- a/apps/maarch_entreprise/indexing_searching/details.php +++ b/apps/maarch_entreprise/indexing_searching/details.php @@ -1046,17 +1046,4 @@ if ($stmt->rowCount() == 0) { <?php //INITIALIZE INDEX TABS -//OUTGOING CREATION MODE -if ($_SESSION['indexation'] == true && $category == 'outgoing') { - $_SESSION['indexation'] = false; - $is_outgoing_indexing_mode = false; - $selectAttachments = 'SELECT attachment_type FROM res_view_attachments' - ." WHERE res_id_master = ? and coll_id = ? and status <> 'DEL' and attachment_type in ('outgoing_mail', 'outgoing_mail_signed')"; - $stmt = $db->query($selectAttachments, array($_SESSION['doc_id'], $_SESSION['collection_id_choice'])); - if ($stmt->rowCount() == 0) { - //launch outgoing_mail creation - echo '<script type="text/javascript">document.getElementById(\'responses_tab\').click();showAttachmentsForm(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=attachments_content&fromDetail=create&cat=outgoing\',\'98%\',\'auto\');</script>'; - } -} - $_SESSION['info'] = ''; diff --git a/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php b/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php index 7c98408baca..e1c376a1fe3 100755 --- a/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php +++ b/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php @@ -687,10 +687,10 @@ if ($mode == 'normal') { if (!$core_tools->test_service('view_documents_with_notes', 'attachments', false)) { $excludeAttachmentTypes[] = 'document_with_notes'; } - $query = "SELECT count(res_id) as total FROM res_view_attachments + $query = "SELECT count(res_id) as total FROM res_attachments WHERE res_id_master = ? - AND status NOT IN ('DEL', 'OBS') AND attachment_type NOT IN (?) AND coll_id = ? AND (status <> 'TMP' or (typist = ? and status = 'TMP'))"; - $arrayPDO = array($tab[$i][0]['res_id'], $excludeAttachmentTypes, $_SESSION['collection_id_choice'], $_SESSION['user']['UserId']); + AND status NOT IN ('DEL', 'OBS') AND attachment_type NOT IN (?) AND (status <> 'TMP' or (typist = ? and status = 'TMP'))"; + $arrayPDO = array($tab[$i][0]['res_id'], $excludeAttachmentTypes, $_SESSION['user']['UserId']); $stmt2 = $db->query($query, $arrayPDO); $return_count = $stmt2->fetchObject(); diff --git a/apps/maarch_entreprise/indexing_searching/search_adv_result.php b/apps/maarch_entreprise/indexing_searching/search_adv_result.php index bdd6d03ad70..610b859be4d 100755 --- a/apps/maarch_entreprise/indexing_searching/search_adv_result.php +++ b/apps/maarch_entreprise/indexing_searching/search_adv_result.php @@ -141,7 +141,7 @@ if (count($_REQUEST['meta']) > 0) { ."or (lower(translate(alt_identifier,'/','')) like lower(:multifield) OR lower(alt_identifier) like lower(:multifield)) " ."or lower(barcode) LIKE lower(:multifield) " ."or res_id in (select identifier from notes where lower(translate(note_text,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:multifield)) " - ."or res_id in (select res_id_master from res_view_attachments where (lower(translate(identifier,'/','')) like lower(:multifield) OR lower(identifier) like lower(:multifield) AND status NOT IN ('DEL','OBS','TMP')))) "; + ."or res_id in (select res_id_master from res_attachments where (lower(translate(identifier,'/','')) like lower(:multifield) OR lower(identifier) like lower(:multifield) AND status NOT IN ('DEL','OBS','TMP')))) "; if (ctype_digit($_REQUEST['multifield'])) { $where_request .= "or res_id = :multifield2 "; $arrayPDO = array_merge($arrayPDO, array(":multifield2" => $multifield)); @@ -155,7 +155,7 @@ if (count($_REQUEST['meta']) > 0) { } elseif ($tab_id_fields[$j] == 'chrono' && !empty($_REQUEST['chrono'])) { $json_txt .= " 'chrono' : ['".addslashes(trim($_REQUEST['chrono']))."'],"; $chrono = $func->wash($_REQUEST['chrono'], "no", _CHRONO_NUMBER, "no"); - $where_request .= " (lower(alt_identifier) like lower(:chrono) or (res_id in (SELECT res_id_master FROM res_view_attachments WHERE coll_id = 'letterbox_coll' AND lower(identifier) like lower(:chrono) AND status NOT IN ('DEL','OBS','TMP'))))"; + $where_request .= " (lower(alt_identifier) like lower(:chrono) or (res_id in (SELECT res_id_master FROM res_attachments WHERE lower(identifier) like lower(:chrono) AND status NOT IN ('DEL','OBS','TMP'))))"; $arrayPDO = array_merge($arrayPDO, array(":chrono" => "%".$chrono."%")); $where_request .=" and "; } @@ -195,7 +195,7 @@ if (count($_REQUEST['meta']) > 0) { // TYPE D'ATTACHEMENT elseif ($tab_id_fields[$j] == 'attachment_types' && !empty($_REQUEST['attachment_types'])) { $json_txt .= " 'attachment_types' : ['".addslashes(trim($_REQUEST['attachment_types']))."'],"; - $where_request .= " (res_id in (SELECT res_id_master FROM res_view_attachments WHERE attachment_type = :attachmentTypes AND status NOT IN ('DEL','OBS','TMP')) )"; + $where_request .= " (res_id in (SELECT res_id_master FROM res_attachments WHERE attachment_type = :attachmentTypes AND status NOT IN ('DEL','OBS','TMP')) )"; $arrayPDO = array_merge($arrayPDO, array(":attachmentTypes" => $_REQUEST['attachment_types'])); $where_request .=" and "; } @@ -296,7 +296,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ $json_txt .= " 'subject' : ['".addslashes(trim($subject))."'],"; $where_request .= " (REGEXP_REPLACE(lower(translate(subject,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')),'( ){2,}', ' ') like lower(:subject) " - ."or (res_id in (SELECT res_id_master FROM res_view_attachments WHERE coll_id = 'letterbox_coll' AND lower(translate(title,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:subject) AND status NOT IN ('DEL','OBS','TMP') ))) and "; + ."or (res_id in (SELECT res_id_master FROM res_attachments WHERE lower(translate(title,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:subject) AND status NOT IN ('DEL','OBS','TMP') ))) and "; $arrayPDO = array_merge($arrayPDO, array(":subject" => "%".$subject."%")); } elseif ($tab_id_fields[$j] == 'fulltext' && !empty($_REQUEST['fulltext']) ) { @@ -334,7 +334,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ $_SESSION['search']['plain_text'] = $_REQUEST['fulltext']; - foreach (['letterbox_coll', 'attachments_coll', 'attachments_version_coll'] as $key => $tmpCollection) { + foreach (['letterbox_coll', 'attachments_coll'] as $key => $tmpCollection) { $fullTextDocserver = \Docserver\models\DocserverModel::getCurrentDocserver(['collId' => $tmpCollection, 'typeId' => 'FULLTEXT']); $path_to_lucene_index = $fullTextDocserver['path_template']; @@ -365,22 +365,6 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ $idMasterDatas[] = $tmp; } - $Liste_Ids = '0'; - foreach ($idMasterDatas as $tmpIdMaster) { - $Liste_Ids .= ", '{$tmpIdMaster->res_id_master}'"; - $_SESSION['fullTextAttachments']['letterbox'][] = $tmpIdMaster->res_id_master; - } - } elseif ($tmpCollection == 'attachments_version_coll') { - $tmpArray = preg_split("/[,' ]/", $Liste_Ids); - array_splice($tmpArray, 0, 1); - $_SESSION['fullTextAttachments']['versionAttachments'] = array_filter($tmpArray); - $db = new Database(); - $stmt = $db->query("SELECT DISTINCT res_id_master FROM res_version_attachments WHERE res_id IN ($Liste_Ids) AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('print_folder')"); - $idMasterDatas = []; - while ($tmp = $stmt->fetchObject()) { - $idMasterDatas[] = $tmp; - } - $Liste_Ids = '0'; foreach ($idMasterDatas as $tmpIdMaster) { $Liste_Ids .= ", '{$tmpIdMaster->res_id_master}'"; @@ -445,7 +429,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ ."or (lower(translate(alt_identifier,'/','')) like lower(:multifieldWelcome) OR lower(alt_identifier) like lower(:multifieldWelcome)) " ."or lower(barcode) LIKE lower(:multifieldWelcome) " ."or res_id in (select identifier from notes where lower(translate(note_text,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:multifieldWelcome)) " - ."or res_id in (select res_id_master from res_view_attachments where (lower(translate(identifier,'/','')) like lower(:multifieldWelcome) OR lower(identifier) like lower(:multifieldWelcome)) AND status NOT IN ('DEL','OBS','TMP')) " + ."or res_id in (select res_id_master from res_attachments where (lower(translate(identifier,'/','')) like lower(:multifieldWelcome) OR lower(identifier) like lower(:multifieldWelcome)) AND status NOT IN ('DEL','OBS','TMP')) " ."or contact_id in (select contact_id from view_contacts where society ilike :multifieldWelcome or contact_firstname ilike :multifieldWelcome or contact_lastname ilike :multifieldWelcome) or (exp_user_id in (select user_id from users where firstname ilike :multifieldWelcome or lastname ilike :multifieldWelcome )))"; $arrayPDO = array_merge($arrayPDO, array(":multifieldWelcomeReference" => "%".$welcome."%")); @@ -488,7 +472,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ if (preg_match($_ENV['date_pattern'], $_REQUEST['creation_date_pj_from'])==false) { $_SESSION['error'] .= _WRONG_DATE_FORMAT.' : '.$_REQUEST['creation_date_pj_from']; } else { - $where_request .= " res_id in (SELECT res_id_master FROM res_view_attachments WHERE (".$req->extract_date("creation_date")." >= :creationDatePjFrom) AND status NOT IN ('DEL','OBS','TMP') ) and "; + $where_request .= " res_id in (SELECT res_id_master FROM res_attachments WHERE (".$req->extract_date("creation_date")." >= :creationDatePjFrom) AND status NOT IN ('DEL','OBS','TMP') ) and "; $arrayPDO = array_merge($arrayPDO, array(":creationDatePjFrom" => $func->format_date_db($_REQUEST['creation_date_pj_from']))); $json_txt .= " 'creation_date_pj_from' : ['".trim($_REQUEST['creation_date_pj_from'])."'],"; } @@ -498,7 +482,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ if (preg_match($_ENV['date_pattern'], $_REQUEST['creation_date_pj_to'])==false) { $_SESSION['error'] .= _WRONG_DATE_FORMAT.' : '.$_REQUEST['creation_date_pj_to']; } else { - $where_request .= " res_id in (SELECT res_id_master FROM res_view_attachments WHERE (".$req->extract_date("creation_date")." <= :creationDatePjTo) AND status NOT IN ('DEL','OBS','TMP') ) and "; + $where_request .= " res_id in (SELECT res_id_master FROM res_attachments WHERE (".$req->extract_date("creation_date")." <= :creationDatePjTo) AND status NOT IN ('DEL','OBS','TMP') ) and "; $arrayPDO = array_merge($arrayPDO, array(":creationDatePjTo" => $func->format_date_db($_REQUEST['creation_date_pj_to']))); $json_txt .= " 'creation_date_pj_to' : ['".trim($_REQUEST['creation_date_pj_to'])."'],"; } @@ -684,7 +668,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ $arrayPDO = array_merge($arrayPDO, [":recipientType" => 'contact']); $where_request .= " or (dest_contact_id = :recipientId)"; $where_request .= " or (category_id = 'outgoing' and res_id in (select res_id from contacts_res where contact_id = '{$_REQUEST['recipient_id']}'))"; - $where_request .= " or (res_id in (SELECT res_id_master FROM res_view_attachments WHERE dest_contact_id = :recipientId AND status NOT IN ('DEL','OBS','TMP')))"; + $where_request .= " or (res_id in (SELECT res_id_master FROM res_attachments WHERE dest_contact_id = :recipientId AND status NOT IN ('DEL','OBS','TMP')))"; } else { $where_request .= " ((res_id in (select res_id from resource_contacts where item_id = :recipientId and type = :recipientType and mode = 'recipient'))"; $arrayPDO = array_merge($arrayPDO, [":recipientId" => $_REQUEST['recipient_id']]); @@ -696,7 +680,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ } $where_request .= " or (dest_contact_id is not null and address_id = :recipientId)"; $where_request .= " or (category_id = 'outgoing' and res_id in (select res_id from contacts_res where address_id = :recipientId))"; - $where_request .= " or (res_id in (SELECT res_id_master FROM res_view_attachments WHERE dest_address_id = :recipientId AND status NOT IN ('DEL','OBS','TMP')))"; + $where_request .= " or (res_id in (SELECT res_id_master FROM res_attachments WHERE dest_address_id = :recipientId AND status NOT IN ('DEL','OBS','TMP')))"; } } $where_request .= ') and '; @@ -707,7 +691,7 @@ where lower(translate(folders.label , 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓ $json_txt .= " 'contactid_external' : ['".addslashes(trim($_REQUEST['contactid_external']))."'], 'contactid' : ['".addslashes(trim($_REQUEST['contactid']))."'],"; $contact_id = $_REQUEST['contactid']; $where_request .= " (contact_id in (select contact_id from view_contacts where society ilike :contactId or contact_firstname ilike :contactId or contact_lastname ilike :contactId) ". - " or res_id in (SELECT res_id_master FROM res_view_attachments WHERE dest_contact_id in (select contact_id from view_contacts where society ilike :contactId or contact_firstname ilike :contactId or contact_lastname ilike :contactId) AND status NOT IN ('DEL','OBS','TMP') ) ) and "; + " or res_id in (SELECT res_id_master FROM res_attachments WHERE dest_contact_id in (select contact_id from view_contacts where society ilike :contactId or contact_firstname ilike :contactId or contact_lastname ilike :contactId) AND status NOT IN ('DEL','OBS','TMP') ) ) and "; $arrayPDO = array_merge($arrayPDO, array(":contactId" => "%".$contact_id."%")); } elseif ($tab_id_fields[$j] == 'addresses_id' && !empty($_REQUEST['addresses_id'])) diff --git a/apps/maarch_entreprise/indexing_searching/view_resource_controler.php b/apps/maarch_entreprise/indexing_searching/view_resource_controler.php index 7e866c84d76..9c919b43494 100755 --- a/apps/maarch_entreprise/indexing_searching/view_resource_controler.php +++ b/apps/maarch_entreprise/indexing_searching/view_resource_controler.php @@ -118,10 +118,9 @@ if ($s_id == '') { if ($res_outgoing->category_id == 'outgoing') { if(!empty($_REQUEST['editingMode'])){ - $stmt = $db->query("SELECT res_id FROM res_view_attachments WHERE status <> 'DEL' and status <> 'OBS' " - . "and res_id_master = ? and coll_id = ? " - . "and attachment_type = 'outgoing_mail' order by res_id desc", - array($s_id, $_SESSION['collection_id_choice'])); + $stmt = $db->query("SELECT res_id FROM res_attachments WHERE status <> 'DEL' and status <> 'OBS' " + . "and res_id_master = ? and attachment_type = 'outgoing_mail' order by res_id desc", + array($s_id)); $res_att = $stmt->fetchObject(); if ($stmt->rowCount() > 0) { ?> <script type="text/javascript"> @@ -130,11 +129,11 @@ if ($s_id == '') { <?php exit(); } } else { - $stmt = $db->query("SELECT res_id FROM res_view_attachments WHERE status <> 'DEL' and status <> 'OBS' " - . "and res_id_master = ? and coll_id = ? and ((attachment_type = 'converted_pdf' and type_id = 1) " + $stmt = $db->query("SELECT res_id FROM res_attachments WHERE status <> 'DEL' and status <> 'OBS' " + . "and res_id_master = ? and ((attachment_type = 'converted_pdf' and type_id = 1) " . "OR (attachment_type = 'outgoing_mail' and format = 'pdf')" . "OR (attachment_type = 'signed_response' and format = 'pdf')) order by res_id desc", - array($s_id, $_SESSION['collection_id_choice'])); + array($s_id)); $res_att = $stmt->fetchObject(); if ($stmt->rowCount() > 0) { if($_REQUEST['watermark_outgoing']=='true'){?> @@ -153,8 +152,8 @@ if ($s_id == '') { <?php exit(); exit(); } else { - $stmt = $db->query("SELECT res_id FROM res_view_attachments WHERE status <> 'DEL' and status <> 'OBS' " - . "and res_id_master = ? and coll_id = ? and ((attachment_type = 'converted_pdf' and (type_id = 1 or type_id = 0)) " + $stmt = $db->query("SELECT res_id FROM res_attachments WHERE status <> 'DEL' and status <> 'OBS' " + . "and res_id_master = ? and ((attachment_type = 'converted_pdf' and (type_id = 1 or type_id = 0)) " . "OR (attachment_type = 'outgoing_mail' and format = 'pdf')" . "OR (attachment_type = 'signed_response' and format = 'pdf')) order by res_id desc", array($s_id, $_SESSION['collection_id_choice'])); @@ -219,23 +218,7 @@ if ($s_id == '') { <?php exit(); } - if ( - $versionTable <> '' && $versionTable == 'res_version_attachments' - && !isset($_REQUEST['original']) - && !isset($_REQUEST['aVersion']) - ) { - $selectVersions = "SELECT res_id FROM " - . $versionTable . " WHERE res_id_master = ? and status <> 'DEL' order by res_id desc"; - $db = new Database(); - $stmt = $db->query($selectVersions, array($s_id)); - $lineLastVersion = $stmt->fetchObject(); - $lastVersion = $lineLastVersion->res_id; - if ($lastVersion <> '') { - $s_id = $lastVersion; - $table = $versionTable; - $adrTable = ''; - } - } elseif(isset($_REQUEST['aVersion'])) { + if(isset($_REQUEST['aVersion'])) { $table = $versionTable; } $docserverControler = new docservers_controler(); diff --git a/apps/maarch_entreprise/loadRepList.php b/apps/maarch_entreprise/loadRepList.php index 777e0bb6c4b..fb01c96df4d 100755 --- a/apps/maarch_entreprise/loadRepList.php +++ b/apps/maarch_entreprise/loadRepList.php @@ -59,18 +59,18 @@ if (isset($_REQUEST['res_id_master'])) { $excludeAttachmentTypes[] = 'document_with_notes'; } - $query = "SELECT * FROM res_view_attachments + $query = "SELECT * FROM res_attachments WHERE res_id_master = ? - AND status NOT IN ('DEL', 'OBS') AND attachment_type NOT IN (?) AND coll_id = ? AND (status <> 'TMP' or (typist = ? and status = 'TMP')) + AND status NOT IN ('DEL', 'OBS') AND attachment_type NOT IN (?) AND (status <> 'TMP' or (typist = ? and status = 'TMP')) ORDER BY creation_date desc"; - $arrayPDO = array($_REQUEST['res_id_master'], $excludeAttachmentTypes, $_SESSION['collection_id_choice'], $_SESSION['user']['UserId']); + $arrayPDO = array($_REQUEST['res_id_master'], $excludeAttachmentTypes, $_SESSION['user']['UserId']); $stmt = $db->query($query, $arrayPDO); while ($return_db = $stmt->fetchObject()) { if (!empty($_REQUEST['option']) && $_REQUEST['option'] == 'FT') { if ($return_db->format != 'pdf') { $stmtFullText = $db->query( - 'SELECT res_id FROM res_view_attachments WHERE filename = ? and attachment_type = ? and path = ? ORDER BY relation desc', + 'SELECT res_id FROM res_attachments WHERE filename = ? and attachment_type = ? and path = ? ORDER BY relation desc', [str_replace('.'.$return_db->format, '.pdf', $return_db->filename), 'converted_pdf', $return_db->path] ); $lineFullText = $stmtFullText->fetchObject(); @@ -79,14 +79,12 @@ if (isset($_REQUEST['res_id_master'])) { } } $stmt2 = $db->query( - "SELECT count(*) as total FROM res_view_attachments WHERE res_id = ? and status not in ('DEL','OBS','TMP') and lower(translate(title,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(?)", + "SELECT count(*) as total FROM res_attachments WHERE res_id = ? and status not in ('DEL','OBS','TMP') and lower(translate(title,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(?)", array($return_db->res_id, $_SESSION['searching']['where_request_parameters'][':subject']) ); $res_attach = $stmt2->fetchObject(); - if ((!empty($_SESSION['fullTextAttachments']['attachments']) && in_array($return_db->res_id, $_SESSION['fullTextAttachments']['attachments'])) || - (!empty($_SESSION['fullTextAttachments']['versionAttachments']) && in_array($return_db->res_id_version, $_SESSION['fullTextAttachments']['versionAttachments'])) - ) { + if (!empty($_SESSION['fullTextAttachments']['attachments']) && in_array($return_db->res_id, $_SESSION['fullTextAttachments']['attachments'])) { $return .= '<tr style="border: 1px solid;color: #135F7F;font-weight: bold" style="background-color: #FFF;">'; } elseif (!empty($resIdConverted) && !empty($_SESSION['fullTextAttachments']['attachments']) && in_array($resIdConverted, $_SESSION['fullTextAttachments']['attachments'])) { $return .= '<tr style="border: 1px solid;color: #135F7F;font-weight: bold" style="background-color: #FFF;">'; @@ -177,12 +175,7 @@ if (isset($_REQUEST['res_id_master'])) { $return .= ' '; $return .= '<a '; $return .= 'href="'; - if ($return_db->res_id != 0) { - $id = $return_db->res_id; - } else { - $id = $return_db->res_id_version; - } - $return .= 'index.php?display=true&module=attachments&page=view_attachment&id='.$id.'&res_id_master=' + $return .= 'index.php?display=true&module=attachments&page=view_attachment&id='.$return_db->res_id.'&res_id_master=' .functions::xssafe($_REQUEST['res_id_master']); $return .= '" '; $return .= 'target="_blank" '; diff --git a/apps/maarch_entreprise/xml/config.xml.default b/apps/maarch_entreprise/xml/config.xml.default index 43eb101e466..9cf6d7ead42 100755 --- a/apps/maarch_entreprise/xml/config.xml.default +++ b/apps/maarch_entreprise/xml/config.xml.default @@ -57,20 +57,7 @@ <label>_ATTACHMENTS_COLL</label> <table>res_attachments</table> <version_table>res_version_attachments</version_table> - <view>res_view_attachments</view> - <adr>adr_attachments</adr> - <index_file>index_attachments.xml</index_file> - <script_add>index_attachments.php</script_add> - <script_search>search_attachments.php</script_search> - <script_search_result>list_results_attachments.php</script_search_result> - <script_details>details_attachments.php</script_details> - </COLLECTION> - <COLLECTION> - <id>attachments_version_coll</id> - <label>_ATTACHMENTS_VERS_COLL</label> - <table>res_version_attachments</table> - <version_table>res_version_attachments</version_table> - <view>res_view_attachments</view> + <view>res_attachments</view> <adr>adr_attachments</adr> <index_file>index_attachments.xml</index_file> <script_add>index_attachments.php</script_add> diff --git a/core/class/ExportControler.php b/core/class/ExportControler.php index bda79856a24..46679dd4d0b 100755 --- a/core/class/ExportControler.php +++ b/core/class/ExportControler.php @@ -434,7 +434,7 @@ class ExportFunctions { $db = new Database(); - $query = 'SELECT DISTINCT u.lastname, u.firstname FROM res_view_attachments r LEFT JOIN users u ON u.user_id = r.typist WHERE r.attachment_type = ? AND r.status = ? AND r.res_id_master = ?'; + $query = 'SELECT DISTINCT u.lastname, u.firstname FROM res_attachments r LEFT JOIN users u ON u.user_id = r.typist WHERE r.attachment_type = ? AND r.status = ? AND r.res_id_master = ?'; $stmt = $db->query($query, array('signed_response', 'TRA', $res_id)); $arr_signatory = []; @@ -449,7 +449,7 @@ class ExportFunctions { $db = new Database(); - $query = 'SELECT creation_date FROM res_view_attachments r WHERE r.attachment_type = ? and r.status = ? and r.res_id_master = ?'; + $query = 'SELECT creation_date FROM res_attachments r WHERE r.attachment_type = ? and r.status = ? and r.res_id_master = ?'; $stmt = $db->query($query, array('signed_response', 'TRA', $res_id)); $arr_signatoryDate = []; diff --git a/modules/attachments/class/attachments_controler_Abstract.php b/modules/attachments/class/attachments_controler_Abstract.php index 36fb69fb9f6..8e79aecc7cc 100755 --- a/modules/attachments/class/attachments_controler_Abstract.php +++ b/modules/attachments/class/attachments_controler_Abstract.php @@ -32,7 +32,6 @@ abstract class attachments_controler_Abstract { - public function initAttachmentInfos($resId) { $db = new Database(); @@ -161,8 +160,8 @@ abstract class attachments_controler_Abstract $stmt = $db->query( "SELECT * - FROM res_view_attachments - WHERE (res_id = ? OR res_id_version = ?) and res_id_master = ? ORDER BY relation desc", + FROM res_attachments + WHERE res_id = ? and res_id_master = ? ORDER BY relation desc", array($resId, $resId, $_SESSION['doc_id']) ); @@ -210,16 +209,10 @@ abstract class attachments_controler_Abstract $infos['effective_date'] = $line->effective_date; $infos['res_id_master'] = $line->res_id_master; $infos['identifier'] = $line->identifier; - if (!empty($line->res_id_version)) { - $infos['is_version'] = true; - if (empty($infos['target_table_origin'])) { - $infos['target_table_origin'] = 'res_version_attachments'; - } - } else { - $infos['is_version'] = false; - if (empty($infos['target_table_origin'])) { - $infos['target_table_origin'] = 'res_attachments'; - } + + $infos['is_version'] = false; + if (empty($infos['target_table_origin'])) { + $infos['target_table_origin'] = 'res_attachments'; } //contact @@ -281,15 +274,12 @@ abstract class attachments_controler_Abstract $result = 0; $stmt2 = $db2->query( "SELECT res_id - FROM res_view_attachments + FROM res_attachments WHERE path = ? AND filename = ? and attachment_type = 'converted_pdf' ORDER BY relation desc", array($infos['path'],pathinfo($infos['pathfile_pdf'], PATHINFO_BASENAME)) ); $line = $stmt2->fetchObject(); - - if ($line->res_id != 0) { - $result = $line->res_id; - } + return $result; } @@ -305,8 +295,8 @@ abstract class attachments_controler_Abstract $db = new Database(); $stmt = $db->query( "SELECT docserver_id, path, filename, fingerprint - FROM res_view_attachments - WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? AND status = 'TMP' AND typist = ? ORDER BY relation desc", + FROM res_attachments + WHERE res_id = ? AND res_id_master = ? AND status = 'TMP' AND typist = ? ORDER BY relation desc", array($resIdAttachment, $resIdAttachment, $resIdMaster, $userId) ); diff --git a/modules/attachments/del_attachment.php b/modules/attachments/del_attachment.php index f85e4a6c067..0fba67cab63 100755 --- a/modules/attachments/del_attachment.php +++ b/modules/attachments/del_attachment.php @@ -46,9 +46,9 @@ if ($pdf_id != 0) { // IS VERSION ATTACHMENT ? if ($info_doc['is_version'] == true && $info_doc['status'] != 'TMP') { //DEL PREVIOUS ATTACHMENT VERSION - $stmt = $db->query('SELECT attachment_id_master FROM res_version_attachments WHERE res_id = ?', array($_REQUEST['id'])); + $stmt = $db->query('SELECT attachment_id_master FROM res_attachments WHERE res_id = ?', array($_REQUEST['id'])); $res = $stmt->fetchObject(); - $stmt = $db->query("UPDATE res_version_attachments SET status = 'DEL' WHERE attachment_id_master = ?", array($res->attachment_id_master)); + $stmt = $db->query("UPDATE res_attachments SET status = 'DEL' WHERE attachment_id_master = ?", array($res->attachment_id_master)); $stmt = $db->query("UPDATE res_attachments SET status = 'DEL' WHERE res_id = ?", array($res->attachment_id_master)); } @@ -88,7 +88,7 @@ if (!empty($_REQUEST['rest'])) { //REFRESH TABS if (empty($_REQUEST['rest'])) { - $query = "SELECT count(1) as total FROM res_view_attachments WHERE status NOT IN ('DEL','OBS','TMP') and res_id_master = ?"; + $query = "SELECT count(1) as total FROM res_attachments WHERE status NOT IN ('DEL','OBS','TMP') and res_id_master = ?"; if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') { $query .= " and (attachment_type <> 'response_project' and attachment_type <> 'outgoing_mail_signed' and attachment_type <> 'signed_response' and attachment_type <> 'converted_pdf' and attachment_type <> 'outgoing_mail' and attachment_type <> 'print_folder' and attachment_type <> 'aihp')"; } elseif (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response') { diff --git a/modules/attachments/frame_list_attachments.php b/modules/attachments/frame_list_attachments.php index d137fa6d263..d52216b8f1b 100755 --- a/modules/attachments/frame_list_attachments.php +++ b/modules/attachments/frame_list_attachments.php @@ -77,13 +77,12 @@ $template_list = array(); array_push($template_list, $template_select); -$select['res_view_attachments'] = array(); +$select['res_attachments'] = array(); // Important de laisser cet ordre : 'res_id', 'res_id_version', 'relation', 'status' array_push( - $select['res_view_attachments'], + $select['res_attachments'], 'res_id', - 'res_id_version', 'relation', 'status', 'identifier', @@ -101,13 +100,13 @@ array_push( 'in_send_attach' ); -$where = " (res_id_master = ? and coll_id = ? and status <> 'DEL' and status <> 'OBS' and (status <> 'TMP' or (typist = ? and status = 'TMP')))"; +$where = " (res_id_master = ? and status <> 'DEL' and status <> 'OBS' and (status <> 'TMP' or (typist = ? and status = 'TMP')))"; if (!$core->test_service('view_documents_with_notes', 'attachments', false)) { $where .= ' AND attachment_type <> \'document_with_notes\''; } -$arrayPDO = array($resId, $_SESSION['collection_id_choice'], $_SESSION['user']['UserId']); +$arrayPDO = array($resId, $_SESSION['user']['UserId']); //Filtre sur le type if (isset($whereAttach) && $whereAttach <> '') { $where .= $whereAttach; @@ -121,7 +120,7 @@ if (!empty($order_field) && !empty($order)) { if ($_REQUEST['order_field'] == 'identifier') { $orderstr = "order by order_alphanum(identifier)"." ".$order; } elseif ($_REQUEST['order_field'] == 'priority') { - $where .= ' and res_view_attachments.priority = priorities.id'; + $where .= ' and res_attachments.priority = priorities.id'; $select['priorities'] = ['order', 'id']; $orderstr = 'order by priorities.order '.$order; } else { @@ -212,17 +211,6 @@ if (isset($_REQUEST['load'])) { false, $_REQUEST['start'] ); - // $request->show(); - - foreach ($attachArr as $key => $value) { - if ($attachArr[$key][0]["value"] == "0") { - array_shift($attachArr[$key]); - $attachArr[$key][0]["column"] = "res_id"; - } else { - unset($attachArr[$key][1]); - $attachArr[$key] = array_values($attachArr[$key]); - } - } for ($i = 0; $i < count($attachArr); $i ++) { //$modifyValue = false; diff --git a/modules/attachments/get_chrono_attachment.php b/modules/attachments/get_chrono_attachment.php index 04035fc4a30..f0a61edaad4 100755 --- a/modules/attachments/get_chrono_attachment.php +++ b/modules/attachments/get_chrono_attachment.php @@ -28,11 +28,7 @@ $category_id = $resMaster->category_id; $nb_attachment = 0; // Check if reponse project was already attached to this outgoing document. -if ($category_id == "outgoing") { - $stmt = $db->query("SELECT res_id FROM res_view_attachments WHERE res_id_master = ? and (attachment_type = 'response_project' or attachment_type = 'outgoing_mail') and status <> 'DEL' and status <> 'OBS'", array($_SESSION['doc_id'])); - $nb_attachment = $stmt->rowCount(); -} -if ($category_id == "incoming" || $category_id == 'attachment' || ($category_id == "outgoing" && $nb_attachment > 0) || (isset($_POST['type_id']) && $_POST['type_id'] == 'attachment')) { +if ($category_id == "incoming" || $category_id == 'attachment' || (isset($_POST['type_id']) && $_POST['type_id'] == 'attachment')) { if (isset($_SESSION['save_chrono_number']) && $_SESSION['save_chrono_number'][$index] <> "") { echo "{status: 1, chronoNB: '".$_SESSION['save_chrono_number'][$index]."'}"; } else { @@ -47,8 +43,4 @@ if ($category_id == "incoming" || $category_id == 'attachment' || ($category_id $_SESSION['save_chrono_number'][$index] = $myChrono; echo "{status: 1, chronoNB: '".functions::xssafe($myChrono)."'}"; } -} elseif ($category_id == "outgoing" && $nb_attachment == 0) { - $stmt = $db->query("SELECT alt_identifier FROM res_letterbox WHERE res_id = ?", array($_SESSION['doc_id'])); - $chronoMaster = $stmt->fetchObject(); - echo "{status: 1, chronoNB: '".functions::xssafe($chronoMaster->alt_identifier)."'}"; } diff --git a/modules/attachments/get_other_chrono_attachment.php b/modules/attachments/get_other_chrono_attachment.php index 7fd4b560b6c..78c48160598 100755 --- a/modules/attachments/get_other_chrono_attachment.php +++ b/modules/attachments/get_other_chrono_attachment.php @@ -27,7 +27,7 @@ $core->test_user(); $db = new Database(); $array_attachment_types_get_chrono = "'".implode("','", $_SESSION['attachment_types_get_chrono'][$_REQUEST['type_id']])."'"; -$stmt = $db->query("SELECT distinct identifier FROM res_view_attachments WHERE res_id_master = ? and attachment_type IN (".$array_attachment_types_get_chrono.") and status <> 'DEL' and status <> 'OBS'", array($_SESSION['doc_id'])); +$stmt = $db->query("SELECT distinct identifier FROM res_attachments WHERE res_id_master = ? and attachment_type IN (".$array_attachment_types_get_chrono.") and status <> 'DEL' and status <> 'OBS'", array($_SESSION['doc_id'])); $listIdentifier = array(); diff --git a/modules/attachments/previous_attachments.php b/modules/attachments/previous_attachments.php index f601eb88786..6f7082eb2aa 100755 --- a/modules/attachments/previous_attachments.php +++ b/modules/attachments/previous_attachments.php @@ -58,12 +58,12 @@ if (isset($_REQUEST['res_id_version'])) { $db = new Database(); - $query = "SELECT attachment_id_master, res_id_master FROM res_view_attachments WHERE res_id_version = ? "; - $stmt = $db->query($query,array($_REQUEST['res_id_version'])); + $query = "SELECT origin_id FROM res_attachments WHERE res_id = ? "; + $stmt = $db->query($query, array($_REQUEST['res_id_version'])); $attach = $stmt->fetchObject(); - $query = "SELECT status, '1' as relation, creation_date, title, typist, res_id FROM res_attachments WHERE res_id = ? UNION ALL SELECT status, relation, creation_date, title, typist, res_id_version FROM res_view_attachments WHERE attachment_id_master = ? AND status = 'OBS' ORDER BY relation desc"; - $stmt = $db->query($query,array($attach->attachment_id_master,$attach->attachment_id_master)); + $query = "SELECT status, relation, creation_date, title, typist, res_id FROM res_attachments WHERE (res_id = ? or origin_id = ?) AND status = 'OBS' ORDER BY relation desc"; + $stmt = $db->query($query, array($attach->origin_id)); while ($return_db = $stmt->fetchObject()) { $return .= '<tr style="border: 1px solid;" style="background-color: #FFF;">'; diff --git a/modules/attachments/setFinalVersion.php b/modules/attachments/setFinalVersion.php index 5e12d8e4932..6ab2c1ad8b9 100755 --- a/modules/attachments/setFinalVersion.php +++ b/modules/attachments/setFinalVersion.php @@ -24,50 +24,37 @@ require_once 'core/class/class_request.php'; $db = new Database(); $js = ""; -if ((int)$_REQUEST['relation'] > 1) { - $column_res = 'res_id_version'; -} else { - $column_res = 'res_id'; -} - $stmt = $db->query("SELECT relation, status - FROM res_view_attachments - WHERE ".$column_res." = ? and res_id_master = ? - ORDER BY relation desc",array($_REQUEST['id'],$_SESSION['doc_id'])); + FROM res_attachments + WHERE res_id = ? and res_id_master = ? + ORDER BY relation desc", array($_REQUEST['id'],$_SESSION['doc_id'])); $res = $stmt->fetchObject(); -if($res->status == 'A_TRA' || $res->status == 'TRA'){ - if ($res->status == 'A_TRA') { - $status = 'TRA'; - } else { - $status = 'A_TRA'; - } - - if ($_REQUEST['relation'] == 1) { - $table = 'res_attachments'; - } else { - $table = 'res_version_attachments'; - } - - $db->query("UPDATE ".$table." set status = '".$status."' WHERE res_id = ?", array($_REQUEST['id'])); - $status_ajax = 0; +if ($res->status == 'A_TRA' || $res->status == 'TRA') { + if ($res->status == 'A_TRA') { + $status = 'TRA'; + } else { + $status = 'A_TRA'; + } + $db->query("UPDATE res_attachments set status = '".$status."' WHERE res_id = ?", array($_REQUEST['id'])); + $status_ajax = 0; } else { - $js .= "alert('Ce courrier a déjà été traité');"; - $status_ajax = 1; + $js .= "alert('Ce courrier a déjà été traité');"; + $status_ajax = 1; } $js .= 'var eleframe1 = window.top.document.getElementsByName(\'list_attach\');'; if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') { - $js .= 'eleframe1[0].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load'; - $js .= '&attach_type_exclude=response_project,outgoing_mail_signed,converted_pdf,print_folder&fromDetail=attachments\';'; -} else if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response'){ - $js .= 'eleframe1[1].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load'; - $js .= '&attach_type=response_project,outgoing_mail_signed&fromDetail=response\';'; + $js .= 'eleframe1[0].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load'; + $js .= '&attach_type_exclude=response_project,outgoing_mail_signed,converted_pdf,print_folder&fromDetail=attachments\';'; +} elseif (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response') { + $js .= 'eleframe1[1].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load'; + $js .= '&attach_type=response_project,outgoing_mail_signed&fromDetail=response\';'; } else { - $js .= 'eleframe1[0].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&template_selected=documents_list_attachments_simple&attach_type_exclude=converted_pdf,print_folder\';'; + $js .= 'eleframe1[0].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&template_selected=documents_list_attachments_simple&attach_type_exclude=converted_pdf,print_folder\';'; } echo "{status: ".$status_ajax.", exec_js : '".addslashes($js)."'}"; -exit; \ No newline at end of file +exit; diff --git a/modules/attachments/unsetTemporarySaved.php b/modules/attachments/unsetTemporarySaved.php index 642b69c88e7..70fdb415903 100755 --- a/modules/attachments/unsetTemporarySaved.php +++ b/modules/attachments/unsetTemporarySaved.php @@ -34,11 +34,7 @@ $core->test_user(); $db = new Database(); -if ($_REQUEST['mode'] == 'add') { - $tableName = "res_attachments"; -} else if($_REQUEST['mode'] == 'edit'){ - $tableName = "res_version_attachments"; -} +$tableName = "res_attachments"; $stmt = $db->query( "SELECT docserver_id, path, filename FROM ".$tableName." WHERE res_id_master = ? AND status = 'TMP' AND typist = ?", diff --git a/modules/attachments/view_attachment.php b/modules/attachments/view_attachment.php index e38ad99910f..b8178eb2bbf 100755 --- a/modules/attachments/view_attachment.php +++ b/modules/attachments/view_attachment.php @@ -52,20 +52,7 @@ if (! empty($_SESSION['error'])) { header("location: " . $_SESSION['config']['businessappurl'] . "index.php"); exit(); } else { - if (!empty($_REQUEST['isVersion'])) { - if ($_REQUEST['isVersion'] == 'false') { - $stmt = $db->query("SELECT coll_id, res_id_master FROM res_attachments WHERE res_id = ? AND res_id_master = ?", [$sId, $_REQUEST['res_id_master']]); - } else { - $stmt = $db->query("SELECT coll_id, res_id_master FROM res_version_attachments WHERE res_id = ? AND res_id_master = ?", [$sId, $_REQUEST['res_id_master']]); - } - } else { - $stmt = $db->query( - "SELECT coll_id, res_id_master - FROM res_view_attachments - WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? ORDER BY relation desc", - [$sId,$sId,$_REQUEST['res_id_master']] - ); - } + $stmt = $db->query("SELECT coll_id, res_id_master FROM res_attachments WHERE res_id = ? AND res_id_master = ?", [$sId, $_REQUEST['res_id_master']]); $res = $stmt->fetchObject(); $collId = $res->coll_id; $resIdMaster = $res->res_id_master; @@ -105,20 +92,7 @@ if (! empty($_SESSION['error'])) { ); exit(); } else { - if (!empty($_REQUEST['isVersion'])) { - if ($_REQUEST['isVersion'] == 'false') { - $stmt = $db->query("SELECT docserver_id, path, filename, format, title FROM res_attachments WHERE res_id = ? AND res_id_master = ?", [$sId, $_REQUEST['res_id_master']]); - } else { - $stmt = $db->query("SELECT docserver_id, path, filename, format, title FROM res_version_attachments WHERE res_id = ? AND res_id_master = ?", [$sId, $_REQUEST['res_id_master']]); - } - } else { - $stmt = $db->query( - "SELECT docserver_id, path, filename, format, title - FROM res_view_attachments - WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? ORDER BY relation desc", - array($sId,$sId,$_REQUEST['res_id_master']) - ); - } + $stmt = $db->query("SELECT docserver_id, path, filename, format, title FROM res_attachments WHERE res_id = ? AND res_id_master = ?", [$sId, $_REQUEST['res_id_master']]); if ($stmt->rowCount() == 0) { $_SESSION['error'] = _NO_DOC_OR_NO_RIGHTS; header( @@ -135,7 +109,7 @@ if (! empty($_SESSION['error'])) { ); $stmtPdf = $db->query( "SELECT docserver_id, path, filename, format, title - FROM res_view_attachments + FROM res_attachments WHERE filename=? AND (status = 'TRA' or status = 'A_TRA')", array(substr($line->filename, 0, strrpos($line->filename, ".")).'.pdf') ); diff --git a/modules/avis/xml/IVS/requests_definitions.xml b/modules/avis/xml/IVS/requests_definitions.xml index 3adddb6adde..a23ecd8a60c 100755 --- a/modules/avis/xml/IVS/requests_definitions.xml +++ b/modules/avis/xml/IVS/requests_definitions.xml @@ -53,13 +53,5 @@ <parameter name="page" value="update_AvisPage"/> <parameter name="module" value="Avis"/> </requestDefinition> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="view_pdf_attachement" > - <parameter name="page" value="view_pdf_attachement"/> - <parameter name="module" value="Avis"/> - </requestDefinition> - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="view_pdf_attachement" > - <parameter name="page" value="view_pdf_attachement"/> - <parameter name="module" value="Avis"/> - </requestDefinition> </requestDefinitions> </inputValidation> \ No newline at end of file diff --git a/modules/avis/xml/IVS/validation_rules.xml b/modules/avis/xml/IVS/validation_rules.xml index c9f0dc684fa..7ddce25234e 100755 --- a/modules/avis/xml/IVS/validation_rules.xml +++ b/modules/avis/xml/IVS/validation_rules.xml @@ -42,10 +42,5 @@ <parameter name="coll_id" type="collection_list" /> <parameter name="action" type="string" /> </validationRule> - <validationRule name="view_pdf_attachement" extends="standardForm" mode="error"> - <parameter name="res_id_master" type="integer" /> - <parameter name="id" type="integer" /> - </validationRule> - </validationRules> diff --git a/modules/content_management/class/class_content_manager_tools_Abstract.php b/modules/content_management/class/class_content_manager_tools_Abstract.php index ea18599f011..75a3e26a6d6 100755 --- a/modules/content_management/class/class_content_manager_tools_Abstract.php +++ b/modules/content_management/class/class_content_manager_tools_Abstract.php @@ -47,8 +47,9 @@ abstract class content_management_tools_Abstract public function __construct() { - if (!isset($_SESSION) OR count($_SESSION) == 0) + if (!isset($_SESSION) or count($_SESSION) == 0) { return null; + } $this->db = new Database(); //TODO: PUT IT AN CONFIG FILE WITH 30 @@ -62,15 +63,15 @@ abstract class content_management_tools_Abstract { if (file_exists( $_SESSION['config']['corepath'] . 'custom/' - . $_SESSION['custom_override_id'] + . $_SESSION['custom_override_id'] . '/modules/content_management/xml/content_management_features.xml' ) ) { $path = $_SESSION['config']['corepath'] . 'custom/' - . $_SESSION['custom_override_id'] + . $_SESSION['custom_override_id'] . '/modules/content_management/xml/content_management_features.xml'; } else { - $path = $_SESSION['config']['corepath'] + $path = $_SESSION['config']['corepath'] . 'modules/content_management/xml/content_management_features.xml'; } $cMFeatures = array(); @@ -104,7 +105,6 @@ abstract class content_management_tools_Abstract $stmt = $this->db->query($query, array($charTofind, $timeLimit)); if ($res = $stmt->fetchObject()) { - $arrayUser = array(); $arrayUser = explode("#", $res->id); if ($arrayUser[1] <> '') { @@ -163,7 +163,7 @@ abstract class content_management_tools_Abstract . " where id like ?" . " and param_value_string = ?"; $stmt = $this->db->query( - $query, + $query, array($timeLimit, $charTofind, $CMId) ); } @@ -219,7 +219,9 @@ abstract class content_management_tools_Abstract { $query = "delete from " . PARAM_TABLE . " where id like ?"; - $stmt = $this->db->query($query, array('content_management_reservation#' + $stmt = $this->db->query( + $query, + array('content_management_reservation#' . $_SESSION['user']['UserId'] . '%') ); } @@ -232,16 +234,24 @@ abstract class content_management_tools_Abstract */ protected function deleteDirectory($dir) { - if (!file_exists($dir)) return true; - if (!is_dir($dir) || is_link($dir)) return unlink($dir); - foreach (scandir($dir) as $item) { - if ($item == '.' || $item == '..') continue; - if (!$this->deleteDirectory($dir . "/" . $item)) { - chmod($dir . "/" . $item, 0777); - if (!$this->deleteDirectory($dir . "/" . $item)) return false; - }; + if (!file_exists($dir)) { + return true; + } + if (!is_dir($dir) || is_link($dir)) { + return unlink($dir); + } + foreach (scandir($dir) as $item) { + if ($item == '.' || $item == '..') { + continue; } - return rmdir($dir); + if (!$this->deleteDirectory($dir . "/" . $item)) { + chmod($dir . "/" . $item, 0777); + if (!$this->deleteDirectory($dir . "/" . $item)) { + return false; + } + }; + } + return rmdir($dir); } /** @@ -261,7 +271,7 @@ abstract class content_management_tools_Abstract $stmt = $this->db->query($query, array($charTofind, $CMId)); if ($res = $stmt->fetchObject()) { $secBeforeExpiration = $res->time - $now; - if ($secBeforeExpiration < 0) { + if ($secBeforeExpiration < 0) { return 0; } else { return $secBeforeExpiration; @@ -277,7 +287,8 @@ abstract class content_management_tools_Abstract * @param string $mimeType mime type of the resource * @return array the program and status ok if mime type allowed for content_management */ - public function isMimeTypeAllowedForCM($mimeType, $ext) { + public function isMimeTypeAllowedForCM($mimeType, $ext) + { $typeState = 'ko'; $programPath = ''; if ($mimeType <> '' && $ext <> '') { @@ -340,7 +351,7 @@ abstract class content_management_tools_Abstract /** * Generate JLNP file to launch the JNLP * - * + * */ public function generateJNLP( $jar_url, @@ -355,7 +366,6 @@ abstract class content_management_tools_Abstract $convertPdf = "false", $onlyConvert = "false" ) { - $docXML = new DomDocument('1.0', "UTF-8"); //create unique id for APPLET @@ -374,8 +384,8 @@ abstract class content_management_tools_Abstract if ($objectType == 'attachmentUpVersion') { $dbAttachment = new Database(); $query = "SELECT relation, docserver_id, path, filename, format - FROM res_view_attachments - WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? ORDER BY relation desc"; + FROM res_attachments + WHERE res_id = ? AND res_id_master = ? ORDER BY relation desc"; $stmt = $dbAttachment->query($query, array($objectId, $objectId, $_SESSION['doc_id'])); @@ -400,13 +410,13 @@ abstract class content_management_tools_Abstract 'a' ); fwrite( - $inF, + $inF, '------------------' . PHP_EOL . 'CREATE JNLP------------------' . $_SERVER['SERVER_NAME'] . ' ' . $_SESSION['user']['UserId'] . ' ' . date('D, j M Y H:i:s O') .PHP_EOL ); fwrite($inF, '|||||||||||||||||SERVER DETAILS BEGIN FOR CREATE JNLP|||||||||||||||||' . PHP_EOL); - foreach($_SERVER as $key => $value) { + foreach ($_SERVER as $key => $value) { fwrite($inF, $key . " : " . $value . PHP_EOL); } fwrite($inF, '|||||||||||||||||SERVER DETAILS END FOR CREATE JNLP|||||||||||||||||' . PHP_EOL); @@ -440,13 +450,13 @@ abstract class content_management_tools_Abstract } $jnlp_balise=$docXML->createElement("jnlp"); - $jnlp_attribute1 = $docXML->createAttribute('spec'); + $jnlp_attribute1 = $docXML->createAttribute('spec'); $jnlp_attribute1->value = '6.0+'; - $jnlp_balise->appendChild($jnlp_attribute1); + $jnlp_balise->appendChild($jnlp_attribute1); $pathUrl = trim($_SESSION['config']['coreurl'], '/'); - $jnlp_attribute2 = $docXML->createAttribute('codebase'); + $jnlp_attribute2 = $docXML->createAttribute('codebase'); $jnlp_attribute2->value = $pathUrl . '/rest/jnlp/'; $jnlp_balise->appendChild($jnlp_attribute2); @@ -458,18 +468,18 @@ abstract class content_management_tools_Abstract $info_balise=$docXML->createElement("information"); - $title_balise=$docXML->createElement("title","Editeur de modèle de document"); + $title_balise=$docXML->createElement("title", "Editeur de modèle de document"); - $vendor_balise=$docXML->createElement("vendor","MAARCH"); + $vendor_balise=$docXML->createElement("vendor", "MAARCH"); $homepage_balise=$docXML->createElement("homepage"); $homepage_attribute = $docXML->createAttribute('href'); $homepage_attribute->value = 'http://maarch.com'; $homepage_balise->appendChild($homepage_attribute); - $desc_balise=$docXML->createElement("description","Génère votre document avec méta-données associées au courrier grâce à des champs de fusion."); + $desc_balise=$docXML->createElement("description", "Génère votre document avec méta-données associées au courrier grâce à des champs de fusion."); - $descshort_balise=$docXML->createElement("description","Génère votre document avec méta-données."); + $descshort_balise=$docXML->createElement("description", "Génère votre document avec méta-données."); $descshort_attribute = $docXML->createAttribute('kind'); $descshort_attribute->value = 'short'; $descshort_balise->appendChild($descshort_attribute); @@ -588,20 +598,20 @@ abstract class content_management_tools_Abstract $param12_balise=$docXML->createElement("argument", $hashFile); - $jnlp_balise->appendChild($info_balise); - $info_balise->appendChild($title_balise); - $info_balise->appendChild($vendor_balise); - $info_balise->appendChild($homepage_balise); - $info_balise->appendChild($desc_balise); - $info_balise->appendChild($descshort_balise); - $info_balise->appendChild($offline_balise); + $jnlp_balise->appendChild($info_balise); + $info_balise->appendChild($title_balise); + $info_balise->appendChild($vendor_balise); + $info_balise->appendChild($homepage_balise); + $info_balise->appendChild($desc_balise); + $info_balise->appendChild($descshort_balise); + $info_balise->appendChild($offline_balise); - $jnlp_balise->appendChild($security_balise); - $security_balise->appendChild($permission_balise); + $jnlp_balise->appendChild($security_balise); + $security_balise->appendChild($permission_balise); - $jnlp_balise->appendChild($resources_balise); - $resources_balise->appendChild($j2se_balise); - $resources_balise->appendChild($jar_balise); + $jnlp_balise->appendChild($resources_balise); + $resources_balise->appendChild($j2se_balise); + $resources_balise->appendChild($jar_balise); $resources_balise->appendChild($jar_balise_1); $resources_balise->appendChild($jar_balise_2); $resources_balise->appendChild($jar_balise_3); @@ -623,11 +633,11 @@ abstract class content_management_tools_Abstract $applet_balise->appendChild($param11_balise); $applet_balise->appendChild($param12_balise); - $docXML->appendChild($jnlp_balise); + $docXML->appendChild($jnlp_balise); $filename = $_SESSION['config']['tmppath'].$jnlp_name; - $docXML->save($filename); + $docXML->save($filename); $fp = fopen($_SESSION['config']['tmppath'].$uid_applet_name.".lck", 'w+'); diff --git a/modules/content_management/retrieve_attachment_from_cm.php b/modules/content_management/retrieve_attachment_from_cm.php index caed63a94aa..c06c6832fe2 100755 --- a/modules/content_management/retrieve_attachment_from_cm.php +++ b/modules/content_management/retrieve_attachment_from_cm.php @@ -3,7 +3,7 @@ require_once 'modules/attachments/attachments_tables.php'; $dbAttachment = new Database(); $query = "SELECT relation, docserver_id, path, filename, format - FROM res_view_attachments + FROM res_attachments WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? ORDER BY relation desc"; $stmt = $dbAttachment->query($query, array($objectId, $objectId, $_SESSION['doc_id'])); diff --git a/modules/content_management/save_attachment_from_cm.php b/modules/content_management/save_attachment_from_cm.php index b3c4c482143..fe2832c7f08 100755 --- a/modules/content_management/save_attachment_from_cm.php +++ b/modules/content_management/save_attachment_from_cm.php @@ -122,11 +122,7 @@ if ($arrayIsAllowed['status'] == false) { $docserverTypeObject = $docserverTypeControler->get($docserver->docserver_type_id); $fingerprint = Ds_doFingerprint($filetmp, $docserverTypeObject->fingerprint_mode); - if ($_SESSION['targetAttachment'] == 'add') { - $tableName = 'res_attachments'; - } else if ($_SESSION['targetAttachment'] == 'edit') { - $tableName = 'res_version_attachments'; - } + $tableName = 'res_attachments'; //UPDATE NEW FILE PATH $db->query('UPDATE '.$tableName.' SET fingerprint = ?, filesize = ?, path = ?, filename = ? WHERE res_id = ?', @@ -182,16 +178,9 @@ if ($arrayIsAllowed['status'] == false) { $TableName = RES_ATTACHMENTS_TABLE; } else if ($_SESSION['targetAttachment'] == 'edit') { - - if ((int)$_SESSION['relationAttachment'] > 1) { - $column_res = 'res_id_version'; - } else { - $column_res = 'res_id'; - } - $stmt = $db->query("SELECT attachment_type, identifier, relation, attachment_id_master - FROM res_view_attachments - WHERE ".$column_res." = ? and res_id_master = ? + FROM res_attachments + WHERE res_id = ? and res_id_master = ? ORDER BY relation desc", array($_SESSION['resIdVersionAttachment'], $_SESSION['doc_id'])); $previous_attachment = $stmt->fetchObject(); @@ -203,7 +192,7 @@ if ($arrayIsAllowed['status'] == false) { $identifier = null; } $attachmentType = $previous_attachment->attachment_type; - $TableName = 'res_version_attachments'; + $TableName = 'res_attachments'; if ((int)$previous_attachment->attachment_id_master == 0) { $attachmentIdMaster = $_SESSION['resIdVersionAttachment']; diff --git a/modules/export_seda/export_seda_list.php b/modules/export_seda/export_seda_list.php index 778e3c1f077..4344c523193 100755 --- a/modules/export_seda/export_seda_list.php +++ b/modules/export_seda/export_seda_list.php @@ -465,10 +465,10 @@ for ($i = 0; $i < $tabI; ++$i) { $tab[$i][$j]['order'] = 'category_id'; } if ($tab[$i][$j][$value] == 'count_attachment') { - $query = "SELECT count(*) as total FROM res_view_attachments + $query = "SELECT count(1) as total FROM res_attachments WHERE res_id_master = ? - AND status NOT IN ('DEL', 'OBS') AND attachment_type NOT IN ('converted_pdf', 'print_folder') AND coll_id = ? AND (status <> 'TMP' or (typist = ? and status = 'TMP'))"; - $arrayPDO = array($tab[$i][0]['res_id'], $_SESSION['collection_id_choice'], $_SESSION['user']['UserId']); + AND status NOT IN ('DEL', 'OBS') AND attachment_type NOT IN ('converted_pdf', 'print_folder') AND (status <> 'TMP' or (typist = ? and status = 'TMP'))"; + $arrayPDO = array($tab[$i][0]['res_id'], $_SESSION['user']['UserId']); $stmt2 = $db->query($query, $arrayPDO); $return_count = $stmt2->fetchObject(); diff --git a/modules/life_cycle/batch/extract_data.php b/modules/life_cycle/batch/extract_data.php index 17a5a94fc25..9cacf76d7af 100755 --- a/modules/life_cycle/batch/extract_data.php +++ b/modules/life_cycle/batch/extract_data.php @@ -306,7 +306,7 @@ try { #### Projet de réponse #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT identifier, typist, creation_date FROM res_view_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date desc", array($selectedFile->res_id) + "SELECT identifier, typist, creation_date FROM res_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date desc", array($selectedFile->res_id) ); $arrayAttachments = array(); @@ -324,7 +324,7 @@ try { #### Nombre de Projet de réponse #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT count(*) as total FROM res_view_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) + "SELECT count(1) as total FROM res_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) ); $NbResponseProject = $stmt2->fetchObject(); @@ -333,7 +333,7 @@ try { #### Nb Transmission #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT count(*) as total FROM res_view_attachments WHERE attachment_type = 'transfer' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) + "SELECT count(1) as total FROM res_attachments WHERE attachment_type = 'transfer' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) ); $NbTransmission = $stmt2->fetchObject(); @@ -342,7 +342,7 @@ try { #### Transmission #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT identifier, dest_contact_id, validation_date FROM res_view_attachments WHERE attachment_type = 'transfer' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date DESC LIMIT 4", array($selectedFile->res_id) + "SELECT identifier, dest_contact_id, validation_date FROM res_attachments WHERE attachment_type = 'transfer' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date DESC LIMIT 4", array($selectedFile->res_id) ); $arrayTransmission = array(); diff --git a/modules/life_cycle/batch/extract_data_2.php b/modules/life_cycle/batch/extract_data_2.php index 67bd77a9d05..fb9058a8d9a 100755 --- a/modules/life_cycle/batch/extract_data_2.php +++ b/modules/life_cycle/batch/extract_data_2.php @@ -392,7 +392,7 @@ try { #### Projet de réponse #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT identifier, typist, creation_date FROM res_view_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date desc", array($selectedFile->res_id) + "SELECT identifier, typist, creation_date FROM res_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date desc", array($selectedFile->res_id) ); $arrayAttachments = array(); @@ -427,7 +427,7 @@ try { #### Nombre de Projet de réponse #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT count(*) as total FROM res_view_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) + "SELECT count(1) as total FROM res_attachments WHERE attachment_type = 'response_project' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) ); $NbResponseProject = $stmt2->fetchObject(); @@ -436,7 +436,7 @@ try { #### Nb Transmission #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT count(*) as total FROM res_view_attachments WHERE attachment_type = 'transmission' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) + "SELECT count(1) as total FROM res_attachments WHERE attachment_type = 'transmission' and res_id_master = ? and status <> 'DEL' and status <> 'OBS'", array($selectedFile->res_id) ); $NbTransmission = $stmt2->fetchObject(); @@ -445,7 +445,7 @@ try { #### Transmission #### $stmt2 = Bt_doQuery( $GLOBALS['db'], - "SELECT identifier, dest_contact_id, validation_date, effective_date, dest_address_id FROM res_view_attachments WHERE attachment_type = 'transmission' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date DESC LIMIT 4", array($selectedFile->res_id) + "SELECT identifier, dest_contact_id, validation_date, effective_date, dest_address_id FROM res_attachments WHERE attachment_type = 'transmission' and res_id_master = ? and status <> 'DEL' and status <> 'OBS' ORDER BY creation_date DESC LIMIT 4", array($selectedFile->res_id) ); $arrayTransmission = array(); diff --git a/modules/life_cycle/batch/process_garbage_collector.php b/modules/life_cycle/batch/process_garbage_collector.php index dac59502f4d..c7659d01eb0 100644 --- a/modules/life_cycle/batch/process_garbage_collector.php +++ b/modules/life_cycle/batch/process_garbage_collector.php @@ -76,7 +76,7 @@ while ($GLOBALS['state'] <> "END") { echo 'attach turn' . PHP_EOL; //SECOND SELECT THE ATTACH IN DEL STATUS $GLOBALS['table'] = 'res_attachments'; - $GLOBALS['versionTable'] = 'res_version_attachments'; + $GLOBALS['versionTable'] = ''; $GLOBALS['adrTable'] = 'adr_attachments'; $GLOBALS['attachAlreadyDone'] = true; $GLOBALS['dateToPurgeDEL'] = ''; @@ -98,7 +98,7 @@ while ($GLOBALS['state'] <> "END") { //THIRD SELECT THE ATTACH IN OBS STATUS $where_clause = "STATUS = 'OBS' and creation_date <= '" . $GLOBALS['dateToPurgeOBS'] . "'"; $GLOBALS['table'] = 'res_attachments'; - $GLOBALS['versionTable'] = 'res_version_attachments'; + $GLOBALS['versionTable'] = ''; $GLOBALS['adrTable'] = 'adr_attachments'; $GLOBALS['obsAlreadyDone'] = true; $GLOBALS['dateToPurgeOBS'] = ''; diff --git a/modules/sendmail/Controllers/ReadMessageExchangeController.php b/modules/sendmail/Controllers/ReadMessageExchangeController.php index 50e51df0215..fba0832dcf8 100755 --- a/modules/sendmail/Controllers/ReadMessageExchangeController.php +++ b/modules/sendmail/Controllers/ReadMessageExchangeController.php @@ -83,9 +83,6 @@ class ReadMessageExchangeController if ($value->tablename == 'res_attachments') { $aDataForm['attachments'][] = $value->res_id; } - if ($value->tablename == 'res_version_attachments') { - $aDataForm['attachments_version'][] = $value->res_id; - } if ($value->tablename == 'res_letterbox') { $aDataForm['resMasterAttached'] = 'Y'; } diff --git a/modules/sendmail/Controllers/SendMessageExchangeController.php b/modules/sendmail/Controllers/SendMessageExchangeController.php index 1b4ec36f879..8fa71d9d4f0 100755 --- a/modules/sendmail/Controllers/SendMessageExchangeController.php +++ b/modules/sendmail/Controllers/SendMessageExchangeController.php @@ -65,9 +65,6 @@ class SendMessageExchangeController if ($MainExchangeDoc['tablename'] == 'res_attachments') { $aArgs['join_attachment'][] = $MainExchangeDoc['res_id']; } - if ($MainExchangeDoc['tablename'] == 'res_version_attachments') { - $aArgs['join_version_attachment'][] = $MainExchangeDoc['res_id']; - } /**************** GET ATTACHMENTS INFOS ***************/ $AttachmentsInfo = []; @@ -80,18 +77,7 @@ class SendMessageExchangeController $AttachmentsInfo[$key]['tablenameExchangeMessage'] = 'res_attachments'; } } - $AttVersionInfo = []; - if (!empty($aArgs['join_version_attachment'])) { - $AttVersionInfo = \Attachment\models\AttachmentModel::getOnView(['select' => ['*'], 'where' => ['res_id_version in (?)'], 'data' => [$aArgs['join_version_attachment']]]); - foreach ($AttVersionInfo as $key => $value) { - $AttVersionInfo[$key]['res_id'] = $value['res_id_version']; - $AttVersionInfo[$key]['Title'] = $value['title']; - $AttVersionInfo[$key]['OriginatingAgencyArchiveUnitIdentifier'] = $value['identifier']; - $AttVersionInfo[$key]['DocumentType'] = $_SESSION['attachment_types'][$value['attachment_type']]; - $AttVersionInfo[$key]['tablenameExchangeMessage'] = 'res_version_attachments'; - } - } - $aAllAttachment = array_merge($AttachmentsInfo, $AttVersionInfo); + $aAllAttachment = $AttachmentsInfo; /******************* GET NOTE INFOS **********************/ $aComments = self::generateComments([ diff --git a/modules/sendmail/class/class_modules_tools_Abstract.php b/modules/sendmail/class/class_modules_tools_Abstract.php index 1374c99e68b..2c983b9fd06 100755 --- a/modules/sendmail/class/class_modules_tools_Abstract.php +++ b/modules/sendmail/class/class_modules_tools_Abstract.php @@ -78,97 +78,97 @@ abstract class SendmailAbstract extends Database public function getJoinedFiles($coll_id, $table, $id, $from_res_attachment = false) { - $joinedFiles = array(); - $db = new Database(); - if ($from_res_attachment === false) { - $stmt = $db->query( - "select res_id, description, subject, title, format, filesize, relation from " - . $table . " where res_id = ? and status <> 'DEL'", - array($id) - ); - } else { - include_once 'modules/attachments/attachments_tables.php'; - $stmt = $db->query( - "SELECT rva.res_id, rva.res_id_version, rva.description, rva.subject, rva.title, rva.format, rva.filesize, rva.res_id_master, rva.attachment_type, rva.identifier, cv2.society, cv2.firstname, cv2.lastname, rva.filename, rva.path - FROM res_view_attachments rva LEFT JOIN contacts_v2 cv2 ON rva.dest_contact_id = cv2.contact_id WHERE rva.res_id_master = ? and rva.coll_id = ? and rva.status <> 'DEL' and rva.status <> 'OBS' and rva.attachment_type NOT IN ('converted_pdf','print_folder') ORDER BY rva.attachment_type, rva.description", - array($id, $coll_id) - ); - } - - while ($res = $stmt->fetchObject()) { - $pdf_exist = true; - if ($from_res_attachment) { - require_once 'modules/attachments/class/attachments_controler.php'; - $ac = new attachments_controler(); - if ($res->res_id != 0) { - $idFile = $res->res_id; - $isVersion = false; - } else { - $idFile = $res->res_id_version; - $isVersion = true; - } - $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'attachments_coll', 'isVersion' => $isVersion]); - $viewLink = $_SESSION['config']['businessappurl'] - .'index.php?display=true&module=attachments&page=view_attachment&res_id_master=' - .$id.'&id='.$res->res_id; + // $joinedFiles = array(); + // $db = new Database(); + // if ($from_res_attachment === false) { + // $stmt = $db->query( + // "select res_id, description, subject, title, format, filesize, relation from " + // . $table . " where res_id = ? and status <> 'DEL'", + // array($id) + // ); + // } else { + // include_once 'modules/attachments/attachments_tables.php'; + // $stmt = $db->query( + // "SELECT rva.res_id, rva.res_id_version, rva.description, rva.subject, rva.title, rva.format, rva.filesize, rva.res_id_master, rva.attachment_type, rva.identifier, cv2.society, cv2.firstname, cv2.lastname, rva.filename, rva.path + // FROM res_view_attachments rva LEFT JOIN contacts_v2 cv2 ON rva.dest_contact_id = cv2.contact_id WHERE rva.res_id_master = ? and rva.coll_id = ? and rva.status <> 'DEL' and rva.status <> 'OBS' and rva.attachment_type NOT IN ('converted_pdf','print_folder') ORDER BY rva.attachment_type, rva.description", + // array($id, $coll_id) + // ); + // } + + // while ($res = $stmt->fetchObject()) { + // $pdf_exist = true; + // if ($from_res_attachment) { + // require_once 'modules/attachments/class/attachments_controler.php'; + // $ac = new attachments_controler(); + // if ($res->res_id != 0) { + // $idFile = $res->res_id; + // $isVersion = false; + // } else { + // $idFile = $res->res_id_version; + // $isVersion = true; + // } + // $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'attachments_coll', 'isVersion' => $isVersion]); + // $viewLink = $_SESSION['config']['businessappurl'] + // .'index.php?display=true&module=attachments&page=view_attachment&res_id_master=' + // .$id.'&id='.$res->res_id; - if (!empty($convertedDocument)) { - $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $convertedDocument['docserver_id'], 'select' => ['path_template']]); - $pathToDocument = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $convertedDocument['path']) . $convertedDocument['filename']; + // if (!empty($convertedDocument)) { + // $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $convertedDocument['docserver_id'], 'select' => ['path_template']]); + // $pathToDocument = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $convertedDocument['path']) . $convertedDocument['filename']; - if (!file_exists($pathToDocument)) { - $pdf_exist = false; - } - } else { - $pdf_exist = false; - } - } else { - $idFile = $res->res_id; - $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'letterbox_coll', 'isVersion' => $isVersion]); - $viewLink = $_SESSION['config']['businessappurl'] - .'index.php?display=true&dir=indexing_searching&page=view_resource_controler&id=' - .$id; - if (!empty($convertedDocument)) { - $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $convertedDocument['docserver_id'], 'select' => ['path_template']]); - $pathToDocument = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $convertedDocument['path']) . $convertedDocument['filename']; + // if (!file_exists($pathToDocument)) { + // $pdf_exist = false; + // } + // } else { + // $pdf_exist = false; + // } + // } else { + // $idFile = $res->res_id; + // $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'letterbox_coll', 'isVersion' => $isVersion]); + // $viewLink = $_SESSION['config']['businessappurl'] + // .'index.php?display=true&dir=indexing_searching&page=view_resource_controler&id=' + // .$id; + // if (!empty($convertedDocument)) { + // $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $convertedDocument['docserver_id'], 'select' => ['path_template']]); + // $pathToDocument = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $convertedDocument['path']) . $convertedDocument['filename']; - if (!file_exists($pathToDocument)) { - $pdf_exist = false; - } - } else { - $pdf_exist = false; - } - } - $label = ''; - //Tile, or subject or description - if (strlen(trim($res->title)) > 0) { - $label = $res->title; - } elseif (strlen(trim($res->subject)) > 0) { - $label = $res->subject; - } elseif (strlen(trim($res->description)) > 0) { - $label = $res->description; - } - - array_push( - $joinedFiles, - array('id' => $idFile, //ID - 'label' => $this->show_string($label), //Label - 'format' => $res->format, //Format - 'filesize' => $res->filesize, //Filesize - 'is_version' => $isVersion, - 'pdf_exist' => $pdf_exist, - 'version' => '', - 'attachment_type' => $res->attachment_type, - 'identifier' => $res->identifier, - 'society' => $res->society, - 'firstname' => $res->firstname, - 'lastname' => $res->lastname, - ) - ); - } - - return $joinedFiles; + // if (!file_exists($pathToDocument)) { + // $pdf_exist = false; + // } + // } else { + // $pdf_exist = false; + // } + // } + // $label = ''; + // //Tile, or subject or description + // if (strlen(trim($res->title)) > 0) { + // $label = $res->title; + // } elseif (strlen(trim($res->subject)) > 0) { + // $label = $res->subject; + // } elseif (strlen(trim($res->description)) > 0) { + // $label = $res->description; + // } + + // array_push( + // $joinedFiles, + // array('id' => $idFile, //ID + // 'label' => $this->show_string($label), //Label + // 'format' => $res->format, //Format + // 'filesize' => $res->filesize, //Filesize + // 'is_version' => $isVersion, + // 'pdf_exist' => $pdf_exist, + // 'version' => '', + // 'attachment_type' => $res->attachment_type, + // 'identifier' => $res->identifier, + // 'society' => $res->society, + // 'firstname' => $res->firstname, + // 'lastname' => $res->lastname, + // ) + // ); + // } + + // return $joinedFiles; } public function rawToHtml($text) @@ -305,15 +305,11 @@ abstract class SendmailAbstract extends Database $viewAttachmentArr = array(); $db = new Database(); - if (!$isVersion) { - $table = "res_attachments"; - } else { - $table = "res_version_attachments"; - } + $table = "res_attachments"; $stmt = $db->query( "select description, subject, title, docserver_id, path, filename, format from " - . $table . " where res_id = ? and coll_id = ? and res_id_master = ? ", - array($res_attachment, $coll_id, $res_id_master) + . $table . " where res_id = ? and res_id_master = ? ", + array($res_attachment, $res_id_master) ); if ($stmt->rowCount() > 0) { $line = $stmt->fetchObject(); diff --git a/modules/visa/batch/batch_tools.php b/modules/visa/batch/batch_tools.php index 5e1fcceb527..73f02031822 100755 --- a/modules/visa/batch/batch_tools.php +++ b/modules/visa/batch/batch_tools.php @@ -292,7 +292,7 @@ function Bt_refusedSignedMail($aArgs = []) function Bt_validatedMail($aArgs = []) { - $req = "SELECT count(1) as nbresult FROM res_view_attachments WHERE res_id_master = ? AND status = ?"; + $req = "SELECT count(1) as nbresult FROM res_attachments WHERE res_id_master = ? AND status = ?"; $stmt = $GLOBALS['db']->query($req, array($aArgs['resId'], 'FRZ')); $reqResult = $stmt->fetchObject(); if ($reqResult->nbresult == 0) { diff --git a/modules/visa/batch/process_mailsFromSignatoryBook.php b/modules/visa/batch/process_mailsFromSignatoryBook.php index d2b3f281ca1..0271a463676 100755 --- a/modules/visa/batch/process_mailsFromSignatoryBook.php +++ b/modules/visa/batch/process_mailsFromSignatoryBook.php @@ -234,18 +234,14 @@ if (file_exists($GLOBALS['errorLckFile'])) { Bt_getWorkBatch(); $GLOBALS['logger']->write('Retrieve attachments sent to remote signatory book', 'INFO'); -$query = "SELECT res_id, res_id_version, 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, attachment_id_master, relation - FROM res_view_attachments WHERE status = 'FRZ' AND external_id->>'signatureBookId' IS NOT NULL AND external_id->>'signatureBookId' <> ''"; +$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, attachment_id_master, relation + FROM res_attachments WHERE status = 'FRZ' AND external_id->>'signatureBookId' IS NOT NULL AND external_id->>'signatureBookId' <> ''"; $stmt = $GLOBALS['db']->query($query, []); -$idsToRetrieve = ['noVersion' => [], 'isVersion' => [], 'resLetterbox' => []]; +$idsToRetrieve = ['noVersion' => [], 'resLetterbox' => []]; while ($reqResult = $stmt->fetchObject()) { - if (!empty($reqResult->res_id)) { - $idsToRetrieve['noVersion'][$reqResult->res_id] = $reqResult; - } else { - $idsToRetrieve['isVersion'][$reqResult->res_id_version] = $reqResult; - } + $idsToRetrieve['noVersion'][$reqResult->res_id] = $reqResult; } // On récupère les pj signés dans le parapheur distant @@ -281,121 +277,6 @@ if (!empty($retrievedMails['error'])) { } // On dégele les pj et on créé une nouvelle ligne si le document a été signé -foreach ($retrievedMails['isVersion'] as $resId => $value) { - $GLOBALS['logger']->write('Update res_version_attachments : ' . $resId . '. ExternalId : ' . $value->external_id, 'INFO'); - - if (!empty($value->log)) { - $GLOBALS['logger']->write('Create log Attachment', 'INFO'); - Bt_createAttachment([ - '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, - 'typist' => $value->typist, - 'format' => 'xml', - 'attachment_type' => $value->attachment_type, - 'relation' => 1, - 'status' => 'TRA', - 'encodedFile' => $value->log, - 'in_signature_book' => 'false', - 'table' => 'res_attachments' - ]); - } - $additionalHistoryInfo = ''; - if (!empty($value->workflowInfo)) { - $additionalHistoryInfo = ' : ' . $value->workflowInfo; - } - - if ($value->status == 'validated') { - if (!empty($value->encodedFile)) { - $GLOBALS['logger']->write('Create validated version 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, - 'typist' => $value->typist, - 'format' => $value->format, - 'attachment_type' => $value->attachment_type, - 'relation' => $value->relation + 1, - 'attachment_id_master' => $value->attachment_id_master, - 'status' => 'TRA', - 'encodedFile' => $value->encodedFile, - 'table' => 'res_version_attachments', - 'noteContent' => $value->noteContent, - 'noteCreatorId' => $value->noteCreatorId, - 'noteCreatorName' => $value->noteCreatorName - ]); - } - - $GLOBALS['logger']->write('Document validated', 'INFO'); - $GLOBALS['db']->query("UPDATE res_version_attachments set status = 'OBS', external_id = external_id - 'signatureBookId' WHERE res_id = ?", [$resId]); - if (!empty($value->onlyVisa) && $value->onlyVisa) { - $status = $validatedStatusOnlyVisa; - } else { - $status = $validatedStatus; - } - - Bt_validatedMail(['status' => $status, 'resId' => $value->res_id_master]); - $historyInfo = 'La signature de la pièce jointe '.$resId.' (res_version_attachments) a été validée dans le parapheur externe' . $additionalHistoryInfo; - Bt_history([ - 'table_name' => 'res_version_attachments', - 'record_id' => $resId, - 'info' => $historyInfo, - 'event_type' => 'UP', - 'event_id' => 'attachup' - ]); - Bt_history([ - 'table_name' => 'res_letterbox', - 'record_id' => $value->res_id_master, - 'info' => $historyInfo, - 'event_type' => 'ACTION#1', - 'event_id' => '1' - ]); - } elseif ($value->status == 'refused') { - if (!empty($value->encodedFile)) { - $GLOBALS['logger']->write('Create refused version Attachment', 'INFO'); - Bt_createAttachment([ - '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, - '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 - ]); - $value->noteContent = ''; - } - $GLOBALS['logger']->write('Document refused', 'INFO'); - Bt_refusedSignedMail([ - 'tableAttachment' => 'res_version_attachments', - 'resIdAttachment' => $resId, - 'refusedStatus' => $refusedStatus, - 'resIdMaster' => $value->res_id_master, - 'noteContent' => $value->noteContent, - 'noteCreatorId' => $value->noteCreatorId, - 'noteCreatorName' => $value->noteCreatorName, - 'additionalHistoryInfo' => $additionalHistoryInfo - ]); - } -} - foreach ($retrievedMails['noVersion'] as $resId => $value) { $GLOBALS['logger']->write('Update res_attachments : ' . $resId . '. ExternalId : ' . $value->external_id, 'INFO'); @@ -442,7 +323,7 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) { 'attachment_id_master' => $resId, 'status' => 'TRA', 'encodedFile' => $value->encodedFile, - 'table' => 'res_version_attachments', + 'table' => 'res_attachments', 'noteContent' => $value->noteContent, 'noteCreatorId' => $value->noteCreatorId, 'noteCreatorName' => $value->noteCreatorName @@ -560,7 +441,7 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) { } $GLOBALS['logger']->write('End of process', 'INFO'); -$nbMailsRetrieved = count($retrievedMails['noVersion']) + count($retrievedMails['isVersion']) + count($retrievedMails['resLetterbox']); +$nbMailsRetrieved = count($retrievedMails['noVersion']) + count($retrievedMails['resLetterbox']); $GLOBALS['logger']->write($nbMailsRetrieved.' document(s) retrieved', 'INFO'); Bt_logInDataBase( diff --git a/modules/visa/checkAllAnsSigned.php b/modules/visa/checkAllAnsSigned.php index 2a55d50a25a..363eb140aa2 100755 --- a/modules/visa/checkAllAnsSigned.php +++ b/modules/visa/checkAllAnsSigned.php @@ -30,7 +30,7 @@ $core_tools->test_user(); $db = new Database(); - $stmt = $db->query("SELECT status from res_view_attachments where attachment_type= ? and res_id_master = ? ", array('response_project', $_REQUEST['res_id'])); + $stmt = $db->query("SELECT status from res_attachments where attachment_type= ? and res_id_master = ? ", array('response_project', $_REQUEST['res_id'])); while($line = $stmt->fetchObject()){ if ($line->status == 'TRA' || $line->status == 'A_TRA' ){ echo "{status:0}"; diff --git a/modules/visa/class/FastParapheurController.php b/modules/visa/class/FastParapheurController.php index ae5c924726f..71541127c9b 100755 --- a/modules/visa/class/FastParapheurController.php +++ b/modules/visa/class/FastParapheurController.php @@ -71,60 +71,6 @@ class FastParapheurController } } } - foreach($aArgs['idsToRetrieve']['isVersion'] as $isVersion){ - $xmlPostString = '<?xml version="1.0" encoding="utf-8"?> - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sei="http://sei.ws.fast.cdc.com/"> - <soapenv:Header/> - <soapenv:Body> - <sei:history> - <documentId>' . $isVersion->external_id . '</documentId> - </sei:history> - </soapenv:Body> - </soapenv:Envelope>'; - - $curlReturn = \SrcCore\models\CurlModel::execSOAP([ - 'xmlPostString' => $xmlPostString, - 'url' => $aArgs['config']['data']['url'], - 'options' => [ - CURLOPT_SSLCERT => $aArgs['config']['data']['certPath'], - CURLOPT_SSLCERTPASSWD => $aArgs['config']['data']['certPass'], - CURLOPT_SSLCERTTYPE => $aArgs['config']['data']['certType'] - ] - ]); - - $isError = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body; - if(!empty($isError ->Fault[0])){ - // TODO gestion des erreurs - echo _PJ_NUMBER . $isVersion->res_id . ' ' . _AND_DOC_ORIG . $isVersion->res_id_master . ' : ' . (string)$curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->Fault[0]->children()->faultstring . PHP_EOL; - continue; - } - - $response = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://sei.ws.fast.cdc.com/')->historyResponse->children(); - foreach ($response->return as $res){ // Loop on all steps of the documents (prepared, send to signature, signed etc...) - $state = (string) $res->stateName; - if($state == $aArgs['config']['data']['validatedState']){ - $response = self::download(['config' => $aArgs['config'], 'documentId' => $isVersion->external_id]); - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->status = 'validated'; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->format = 'pdf'; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->encodedFile = $response['b64FileContent']; - break; - }else if($state == $aArgs['config']['data']['refusedState']){ - $GLOBALS['db'] = new \SrcCore\models\DatabasePDO(['customId' => $GLOBALS['CustomId']]); - $query = $GLOBALS['db']->query( - "SELECT user_id, firstname, lastname FROM listinstance LEFT JOIN users ON item_id = user_id WHERE res_id = ? AND item_mode = ?", - [$aArgs['idsToRetrieve']['noVersion'][$noVersion->res_id]->res_id_master, 'sign'] - ); - $res = $query->fetchObject(); - - $response = self::getRefusalMessage(['config' => $aArgs['config'], 'documentId' => $isVersion->external_id]); - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->status = 'refused'; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->noteContent = $res->lastname . ' ' . $res->firstname . ' : ' . $response; - break; - }else{ - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->status = 'waiting'; - } - } - } return $aArgs['idsToRetrieve']; } @@ -162,20 +108,16 @@ class FastParapheurController // END annexes $attachments = \Attachment\models\AttachmentModel::getOnView([ - 'select' => ['res_id', 'res_id_version', 'title', 'attachment_type','path', 'res_id_master', 'format'], + 'select' => ['res_id', 'title', 'attachment_type','path', 'res_id_master', 'format'], 'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status not in ('DEL', 'OBS')", 'in_signature_book = TRUE'], 'data' => [$aArgs['resIdMaster'], ['converted_pdf', 'incoming_mail_attachment', 'print_folder', 'signed_response']] ]); $attachmentToFreeze = []; for($i = 0; $i < count($attachments); $i++){ - if (!empty($attachments[$i]['res_id'])) { - $resId = $attachments[$i]['res_id']; - $collId = 'attachments_coll'; - } else { - $resId = $attachments[$i]['res_id_master']; - $collId = 'attachments_version_coll'; - } + $resId = $attachments[$i]['res_id']; + $collId = 'attachments_coll'; + $adrInfo = \Convert\models\AdrModel::getConvertedDocumentById(['resId' => $resId, 'collId' => $collId, 'type' => 'PDF']); $attachmentPath = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id'], 'select' => ['path_template']]); diff --git a/modules/visa/class/IParapheurController.php b/modules/visa/class/IParapheurController.php index a0a08e40459..79d79c56b67 100755 --- a/modules/visa/class/IParapheurController.php +++ b/modules/visa/class/IParapheurController.php @@ -88,22 +88,17 @@ class IParapheurController // END annexes $attachments = \Attachment\models\AttachmentModel::getOnView([ - 'select' => ['res_id', 'res_id_version', 'title', 'attachment_type','path'], + 'select' => ['res_id', 'title', 'attachment_type','path'], 'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status not in ('DEL', 'OBS', 'FRZ', 'TMP')", 'in_signature_book = TRUE'], 'data' => [$aArgs['resIdMaster'], ['converted_pdf', 'incoming_mail_attachment', 'print_folder', 'signed_response']] ]); for ($i = 0; $i < count($attachments); $i++) { - if (!empty($attachments[$i]['res_id'])) { - $resId = $attachments[$i]['res_id']; - $collId = 'attachments_coll'; - $is_version = false; - } else { - $resId = $attachments[$i]['res_id_master']; - $collId = 'attachments_version_coll'; - $is_version = true; - } - $attachmentInfo = \Convert\controllers\ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId, 'isVersion' => $is_version]); + $resId = $attachments[$i]['res_id']; + $collId = 'attachments_coll'; + $is_version = false; + + $attachmentInfo = \Convert\controllers\ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId]); $attachmentPath = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $attachmentInfo['docserver_id'], 'select' => ['path_template']]); $attachmentFilePath = $attachmentPath['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $attachmentInfo['path']) . $attachmentInfo['filename']; @@ -271,62 +266,6 @@ class IParapheurController echo _EXTERNAL_ID_EMPTY; } } - foreach ($aArgs['idsToRetrieve']['isVersion'] as $isVersion) { - if (!empty($noVersion->external_id)) { - $xmlPostString = '<?xml version="1.0" encoding="utf-8"?> - <?xml version="1.0" encoding="utf-8"?> - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.adullact.org/spring-ws/iparapheur/1.0"> - <soapenv:Header/> - <soapenv:Body> - <ns:GetHistoDossierRequest>' . $isVersion->external_id . '</ns:GetHistoDossierRequest> - </soapenv:Body> - </soapenv:Envelope>'; - - $curlReturn = self::returnCurl($xmlPostString, $aArgs['config']); - - if (!empty($curlReturn['response'])) { - // TODO gestin d'une erreur - echo $curlReturn['error']; - return false; - } - - $response = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://www.adullact.org/spring-ws/iparapheur/1.0')->GetHistoDossierResponse[0]; - - if ($response->MessageRetour->codeRetour == $aArgs['config']['data']['errorCode']) { - // TODO gestion d'une potentielle erreur - echo 'retrieveSignedMails isVersion : [' . $response->MessageRetour->severite . ']' . $response->MessageRetour->message; - return false; - } else { - $noteContent = ''; - foreach ($response->LogDossier as $res) { // Loop on all steps of the documents (prepared, send to signature, signed etc...) - $status = $res->status; - if ($status == $aArgs['config']['data']['visaState'] || $status == $aArgs['config']['data']['signState']) { - $noteContent .= $res->nom . ' : ' . $res->annotation . PHP_EOL; - $response = self::download([ - 'config' => $aArgs['config'], - 'documentId' => $isVersion->external_id - ]); - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->status = 'validated'; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->format = 'pdf'; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->encodedFile = $response['b64FileContent']; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->noteContent = $noteContent; - if ($status == $aArgs['config']['data']['signState']) { - break; - } - } elseif ($status == $aArgs['config']['data']['refusedVisa'] || $status == $aArgs['config']['data']['refusedSign']) { - $noteContent .= $res->nom . ' : ' . $res->annotation . PHP_EOL; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->status = 'refused'; - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->noteContent = $noteContent; - break; - } else { - $aArgs['idsToRetrieve']['isVersion'][$isVersion->res_id]->status = 'waiting'; - } - } - } - } else { - echo _EXTERNAL_ID_EMPTY; - } - } return $aArgs['idsToRetrieve']; } diff --git a/modules/visa/class/IxbusController.php b/modules/visa/class/IxbusController.php index f8f9bb84966..8a0979b931d 100755 --- a/modules/visa/class/IxbusController.php +++ b/modules/visa/class/IxbusController.php @@ -274,7 +274,7 @@ class IxbusController $attachments = \Attachment\models\AttachmentModel::getOnView([ 'select' => [ - 'res_id', 'res_id_version', 'title', 'identifier', 'attachment_type', + 'res_id', 'title', 'identifier', 'attachment_type', 'status', 'typist', 'docserver_id', 'path', 'filename', 'creation_date', 'validation_date', 'relation', 'attachment_id_master' ], @@ -285,16 +285,11 @@ class IxbusController $attachmentToFreeze = []; foreach ($attachments as $value) { - if (!empty($value['res_id'])) { - $resId = $value['res_id']; - $collId = 'attachments_coll'; - $is_version = false; - } else { - $resId = $value['res_id_version']; - $collId = 'attachments_version_coll'; - $is_version = true; - } - $adrInfo = \Convert\controllers\ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId, 'isVersion' => $is_version]); + $resId = $value['res_id']; + $collId = 'attachments_coll'; + $is_version = false; + + $adrInfo = \Convert\controllers\ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId]); $docserverInfo = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id']]); $filePath = $docserverInfo['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename']; @@ -388,7 +383,7 @@ class IxbusController if (!empty($sessionId['error'])) { return ['error' => $sessionId['error']]; } - foreach (['noVersion', 'isVersion'] as $version) { + foreach (['noVersion'] as $version) { foreach ($aArgs['idsToRetrieve'][$version] as $resId => $value) { $etatDossier = IxbusController::getEtatDossier(['config' => $aArgs['config'], 'sessionId' => $sessionId['cookie'], 'dossier_id' => $value->external_id]); diff --git a/modules/visa/class/class_modules_tools_Abstract.php b/modules/visa/class/class_modules_tools_Abstract.php index edaadb2b5ed..96fa00f5080 100755 --- a/modules/visa/class/class_modules_tools_Abstract.php +++ b/modules/visa/class/class_modules_tools_Abstract.php @@ -106,9 +106,9 @@ abstract class visa_Abstract extends Database $db = new Database(); if (empty($noSignableAttachments)) { - $stmt = $db->query("SELECT * FROM res_view_attachments WHERE res_id_master = ? AND coll_id = ? AND status NOT IN ('DEL','OBS','TMP') AND in_signature_book = ?", [$res_id, $coll_id, true]); + $stmt = $db->query("SELECT * FROM res_attachments WHERE res_id_master = ? AND status NOT IN ('DEL','OBS','TMP') AND in_signature_book = ?", [$res_id, true]); } else { - $stmt = $db->query("SELECT * FROM res_view_attachments WHERE res_id_master = ? AND coll_id = ? AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN (?) AND in_signature_book = ? ", [$res_id, $coll_id, $noSignableAttachments, true]); + $stmt = $db->query("SELECT * FROM res_attachments WHERE res_id_master = ? AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN (?) AND in_signature_book = ? ", [$res_id, $noSignableAttachments, true]); } if ($stmt->rowCount() <= 0) { $this->errorMessageVisa = _NO_RESPONSE_PROJECT_VISA; @@ -760,7 +760,7 @@ abstract class visa_Abstract extends Database if ($from_res_attachment === false) { $stmt = $db->query( 'select res_id, description, subject, title, format, filesize, relation, creation_date from ' - .$table." where res_id = ? and status <> 'DEL'", + . " res_letterbox where res_id = ? and status <> 'DEL'", array($id) ); } else { @@ -768,17 +768,16 @@ abstract class visa_Abstract extends Database if ($filter_attach_type == 'all') { $stmt = $db->query( 'select res_id, description, subject, title, format, filesize, res_id_master, attachment_type, creation_date, typist from ' - .RES_ATTACHMENTS_TABLE - ." where res_id_master = ? and coll_id = ? and attachment_type <> 'converted_pdf' and attachment_type <> 'print_folder' and status <> 'DEL' order by attachment_type, creation_date", - array($id, $coll_id) + ." res_attachments where res_id_master = ? and attachment_type <> 'converted_pdf' and attachment_type <> 'print_folder' and status <> 'DEL' order by attachment_type, creation_date", + array($id) ); } else { $stmt = $db->query( - 'select res_id, res_id_version, description, subject, title, format, filesize, res_id_master, attachment_type, creation_date, typist from ' - .' res_view_attachments ' - ." where res_id_master = ? and coll_id = ? and attachment_type = '" + 'select res_id, description, subject, title, format, filesize, res_id_master, attachment_type, creation_date, typist from ' + .' res_attachments ' + ." where res_id_master = ? and attachment_type = '" .$filter_attach_type."' and status not in ('DEL', 'OBS') order by creation_date", - array($id, $coll_id) + array($id) ); } } @@ -788,14 +787,8 @@ abstract class visa_Abstract extends Database if ($from_res_attachment) { require_once 'modules/attachments/class/attachments_controler.php'; $ac = new attachments_controler(); - if ($res->res_id != 0) { - $idFile = $res->res_id; - $isVersion = false; - } else { - $idFile = $res->res_id_version; - $isVersion = true; - } - $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'attachments_coll', 'isVersion' => $isVersion]); + $idFile = $res->res_id; + $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'attachments_coll']); $viewLink = $_SESSION['config']['businessappurl'] .'index.php?display=true&module=attachments&page=view_attachment&res_id_master=' .$id.'&id='.$res->res_id; @@ -813,7 +806,7 @@ abstract class visa_Abstract extends Database } } else { $idFile = $res->res_id; - $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'letterbox_coll', 'isVersion' => $isVersion]); + $convertedDocument = \Convert\models\AdrModel::getConvertedDocumentById(['select' => ['docserver_id', 'path', 'filename'], 'type' => 'PDF', 'resId' => $idFile, 'collId' => 'letterbox_coll']); $viewLink = $_SESSION['config']['businessappurl'] .'index.php?display=true&dir=indexing_searching&page=view_resource_controler&id=' .$id; @@ -851,10 +844,9 @@ abstract class visa_Abstract extends Database } if ($pdf_exist == false) { - $isVersionString = ($isVersion) ? 'true' : 'false'; $collIdConv = ($from_res_attachment) ? 'attachments_coll' : 'letterbox_coll'; - $viewLinkHtml = '<a id="gen_'.$idFile.'" style="cursor:pointer;" title="'._GENERATE_PDF .'" target="_blank" onclick="generatePdf(\''.$idFile.'\',\''.$collIdConv.'\',\''.$isVersionString.'\')">' + $viewLinkHtml = '<a id="gen_'.$idFile.'" style="cursor:pointer;" title="'._GENERATE_PDF .'" target="_blank" onclick="generatePdf(\''.$idFile.'\',\''.$collIdConv.'\',\'false\')">' .'<i id="spinner_'.$idFile.'" class="fa fa-sync-alt fa-2x" title="'._GENERATE_PDF.'"></i>' .'</a>'; } else { @@ -869,7 +861,6 @@ abstract class visa_Abstract extends Database 'creation_date' => $res->creation_date, //Filesize 'attachment_type' => $attachment_type, //attachment_type 'typist' => $typist, //attachment_type - 'is_version' => $isVersion, 'pdf_exist' => $pdf_exist, 'version' => '', 'viewLink' => $viewLinkHtml, @@ -932,21 +923,10 @@ abstract class visa_Abstract extends Database $check = ' disabled title="'._NO_PDF_FILE.'"'; } //Show data - if ($joined_files[$i]['is_version'] === true) { - //Version - $version = ' - '._VERSION.' '.$joined_files[$i]['version']; - $str .= '<tr><td>' - .'</td><td>'.$description.$version.'</td><td>'.$contact['firstname'].' ' - .$contact['lastname'].'</td><td>'.$creation_date - .'</td><td><input id="join_file_'.$id_doc.'_V'.$joined_files[$i]['version'] - .'" type="checkbox" name="join_version[]" value="'.$id_doc - .'"/>'.$joined_files[$i]['viewLink'].'</td></tr>'; - } else { - $str .= '<tr><td></td><td>'.$description.'</td><td>'.$res->contact_society + $str .= '<tr><td></td><td>'.$description.'</td><td>'.$res->contact_society .'</td><td>'.$creation_date.'</td><td><input id="join_file_' .$id_doc.'" type="checkbox" name="join_file[]" value="'.$id_doc.'" '.$check .'/>'.$joined_files[$i]['viewLink'].'</td></tr>'; - } } } //ATTACHMENTS TYPES LOOP @@ -967,17 +947,11 @@ abstract class visa_Abstract extends Database } else { $check = ' disabled title="'._NO_PDF_FILE.'"'; } - if ($joined_files[$i]['is_version'] == true) { - $str .= '<tr><td></td><td>'.$description.'</td><td>'.$contact['firstname'].' ' - .$contact['lastname'].'</td><td>'.$creation_date.'</td><td><input id="join_file_' - .$id_doc.'" type="checkbox" name="join_version[]" value="'.$id_doc.'" '.$check - .'/>'.$joined_files[$i]['viewLink'].'</td></tr>'; - } else { - $str .= '<tr><td></td><td>'.$description.'</td><td>'.$contact['firstname'].' ' - .$contact['lastname'].'</td><td>'.$creation_date.'</td><td><input id="join_file_' - .$id_doc.'" type="checkbox" name="join_attachment[]" value="'.$id_doc.'" '.$check - .'/>'.$joined_files[$i]['viewLink'].'</td></tr>'; - } + + $str .= '<tr><td></td><td>'.$description.'</td><td>'.$contact['firstname'].' ' + .$contact['lastname'].'</td><td>'.$creation_date.'</td><td><input id="join_file_' + .$id_doc.'" type="checkbox" name="join_attachment[]" value="'.$id_doc.'" '.$check + .'/>'.$joined_files[$i]['viewLink'].'</td></tr>'; } } } @@ -1032,9 +1006,9 @@ abstract class visa_Abstract extends Database public function isAllAttachementSigned($res_id) { $db = new Database(); - $stmt2 = $db->query("SELECT count(1) as nb from res_view_attachments WHERE in_signature_book = true AND signatory_user_serial_id IS NULL AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('converted_pdf','print_folder','signed_response') AND res_id_master = ?", array($res_id)); + $stmt2 = $db->query("SELECT count(1) as nb from res_attachments WHERE in_signature_book = true AND signatory_user_serial_id IS NULL AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('converted_pdf','print_folder','signed_response') AND res_id_master = ?", array($res_id)); $res2 = $stmt2->fetchObject(); - $stmt3 = $db->query("SELECT count(1) as nb from res_view_attachments WHERE in_signature_book = true AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('converted_pdf','print_folder','signed_response') AND res_id_master = ?", array($res_id)); + $stmt3 = $db->query("SELECT count(1) as nb from res_attachments WHERE in_signature_book = true AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('converted_pdf','print_folder','signed_response') AND res_id_master = ?", array($res_id)); $res3 = $stmt3->fetchObject(); if ($res3->nb == 0) { return 'noAttachment'; @@ -1054,7 +1028,7 @@ abstract class visa_Abstract extends Database $db = new Database(); $stmt = $db->query("SELECT count(listinstance_id) as nb from listinstance l where l.res_id=? AND l.item_id=? AND l.difflist_type='VISA_CIRCUIT' AND l.requested_signature='true'", array($res_id, $user_id)); $res = $stmt->fetchObject(); - $stmt2 = $db->query("SELECT count(1) as nb from res_view_attachments r where r.res_id_master=? AND r.signatory_user_serial_id = (select id from users where user_id = ?) AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('converted_pdf','print_folder')", array($res_id, $user_id)); + $stmt2 = $db->query("SELECT count(1) as nb from res_attachments r where r.res_id_master=? AND r.signatory_user_serial_id = (select id from users where user_id = ?) AND status NOT IN ('DEL','OBS','TMP') AND attachment_type NOT IN ('converted_pdf','print_folder')", array($res_id, $user_id)); $res2 = $stmt2->fetchObject(); if ($res->nb > 0 && $res2->nb == 0) { diff --git a/modules/visa/retrieve_attachment_from_cm.php b/modules/visa/retrieve_attachment_from_cm.php index 91c27ee5691..47fe6771ea2 100755 --- a/modules/visa/retrieve_attachment_from_cm.php +++ b/modules/visa/retrieve_attachment_from_cm.php @@ -7,7 +7,7 @@ if (!empty($objectResIdMaster)) { } else { $data = [$objectId, $objectId, $_SESSION['doc_id']]; } -$stmt = $db->query("SELECT relation, docserver_id, path, filename, format FROM res_view_attachments +$stmt = $db->query("SELECT relation, docserver_id, path, filename, format FROM res_attachments WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? ORDER BY relation desc", $data); if ($stmt->rowCount() == 0) { diff --git a/modules/visa/save_attach_res_from_cm.php b/modules/visa/save_attach_res_from_cm.php index 8a0757900b8..767fb469cad 100755 --- a/modules/visa/save_attach_res_from_cm.php +++ b/modules/visa/save_attach_res_from_cm.php @@ -57,13 +57,10 @@ if (empty($docserver)) { require_once "core/class/class_request.php"; $db = new Database(); $signatoryUser = \User\models\UserModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['id']]); - if ($_SESSION['visa']['repSignRel'] > 1) { - $target_table = 'res_version_attachments'; - $db->query("UPDATE res_version_attachments set status = 'SIGN', signatory_user_serial_id = ? WHERE res_id = ?", [$signatoryUser['id'], $_SESSION['visa']['repSignId']]); - } else { - $target_table = 'res_attachments'; - $db->query("UPDATE res_attachments set status = 'SIGN', signatory_user_serial_id = ? WHERE res_id = ?", [$signatoryUser['id'], $_SESSION['visa']['repSignId']]); - } + + $target_table = 'res_attachments'; + $db->query("UPDATE res_attachments set status = 'SIGN', signatory_user_serial_id = ? WHERE res_id = ?", [$signatoryUser['id'], $_SESSION['visa']['repSignId']]); + unset($_SESSION['visa']['repSignRel']); if (isset($_SESSION['visa']['repSignId'])) { unset($_SESSION['visa']['repSignId']); diff --git a/modules/visa/send_signed_docs.php b/modules/visa/send_signed_docs.php index 5322c5cf6a6..0ca1be3541b 100755 --- a/modules/visa/send_signed_docs.php +++ b/modules/visa/send_signed_docs.php @@ -14,7 +14,7 @@ require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'cla function checkAllSigned($id) { $db = new Database(); - $stmt = $db->query("SELECT status from res_view_attachments where attachment_type= ? and res_id_master = ?", array('response_project', $id)); + $stmt = $db->query("SELECT status from res_attachments where attachment_type= ? and res_id_master = ?", array('response_project', $id)); while ($line = $stmt->fetchObject()) { if ($line->status == 'TRA' || $line->status == 'A_TRA' ) { return false; diff --git a/modules/visa/sign_file.php b/modules/visa/sign_file.php index a237567294f..fe2c66aa885 100755 --- a/modules/visa/sign_file.php +++ b/modules/visa/sign_file.php @@ -21,7 +21,9 @@ require_once 'core/class/class_resource.php'; function writeLogIndex($EventInfo) { $logFileOpened = fopen($_SESSION['config']['corepath'].'/modules/visa/log/signFile_'.date('Y').'_'.date('m').'_'.date('d').'.log', 'a'); - fwrite($logFileOpened, '['.date('d').'/'.date('m').'/'.date('Y') + fwrite( + $logFileOpened, + '['.date('d').'/'.date('m').'/'.date('Y') .' '.date('H').':'.date('i').':'.date('s').'] '.$EventInfo ."\r\n" ); @@ -55,28 +57,11 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) { } $objectId = $_REQUEST['id']; - $tableName = 'res_view_attachments'; - if (isset($_REQUEST['isOutgoing'])) { - if (isset($_REQUEST['isVersion'])) { - $stmt = $db->query("select relation, res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " - . $tableName - . " where attachment_type = ? and res_id_version = ?", ['outgoing_mail', $objectId]); - } else { - $stmt = $db->query("select relation, res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " - . $tableName - . " where attachment_type = ? and res_id = ?", ['outgoing_mail', $objectId]); - } - } else { - if (isset($_REQUEST['isVersion'])) { - $stmt = $db->query("select relation, res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " - . $tableName - . " where attachment_type NOT IN ('converted_pdf','print_folder') and res_id_version = ?", array($objectId)); - } else { - $stmt = $db->query("select relation, res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " - . $tableName - . " where (attachment_type NOT IN ('converted_pdf','print_folder')) and res_id = ?", array($objectId)); - } - } + $tableName = 'res_attachments'; + + $stmt = $db->query("select relation, res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from " + . $tableName + . " where (attachment_type NOT IN ('converted_pdf','print_folder')) and res_id = ?", array($objectId)); if ($stmt->rowCount() < 1) { echo '{"status":1, "error" : "'._FILE.' '._UNKNOWN.'"}'; @@ -91,20 +76,16 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) { $_SESSION['visa']['last_resId_signed']['dest_address'] = $line->dest_address_id; $_SESSION['visa']['last_resId_signed']['dest_user'] = $line->dest_user; - if (isset($_REQUEST['isOutgoing']) || $line->attachment_type == 'response_project') { + if ($line->attachment_type == 'response_project') { //Update outgoing date $date = date("Y-m-d"); $db->query("update res_letterbox SET departure_date = ? where res_id = ?", array($date,$line->res_id_master)); } - if (isset($_REQUEST['isVersion'])) { - $isVersion = true; - $attachResId = $line->res_id_version; - } else { - $isVersion = false; - $attachResId = $line->res_id; - } - $convertedAttachment = \Convert\controllers\ConvertPdfController::getConvertedPdfById(['select' => ['docserver_id', 'path', 'filename'], 'resId' => $attachResId, 'collId' => 'attachments_coll', 'isVersion' => $isVersion]); + $isVersion = false; + $attachResId = $line->res_id; + + $convertedAttachment = \Convert\controllers\ConvertPdfController::getConvertedPdfById(['select' => ['docserver_id', 'path', 'filename'], 'resId' => $attachResId, 'collId' => 'attachments_coll']); if (!empty($convertedAttachment['errors'])) { echo "{\"status\":1, \"error\" : \""._ATTACH_PDF_NOT_FOUND . ": {$attachResId}, version : {$isVersion}\"}"; exit; @@ -154,7 +135,8 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) { $stmt = $db->query( 'select city from entities' - ." where (parent_entity_id IS NULL or parent_entity_id = '') and (city IS NOT NULL or city <> '')", array() + ." where (parent_entity_id IS NULL or parent_entity_id = '') and (city IS NOT NULL or city <> '')", + array() ); $res = $stmt->fetchObject(); if (!empty($res->city)) { diff --git a/modules/visa/view_pdf_attachement.php b/modules/visa/view_pdf_attachement.php deleted file mode 100755 index 0437d7d136b..00000000000 --- a/modules/visa/view_pdf_attachement.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php -/** -* File : view_attachement.php -&page=view_attachment&res_id_master=194&id=387 -*/ - -require_once "core/class/class_security.php"; -require_once 'modules/attachments/attachments_tables.php'; -require_once 'core/core_tables.php'; -require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR - . 'class_indexing_searching_app.php'; -require_once "core/class/class_history.php"; - -$core = new core_tools(); -$core->test_user(); -$core->load_lang(); -$function = new functions(); -$sec = new security(); -$_SESSION['error'] = ""; -if (isset($_GET['id'])) { - if ($_GET['id'] == "last"){ - $sId = $_SESSION['new_id']; - unset($_SESSION['new_id']); - } - else $sId = $_GET['id']; -} else { - $sId = ""; -} -$sId = $function->wash($_GET['id'], "num", _THE_DOC); -if (! empty($_SESSION['error'])) { - header("location: " . $_SESSION['config']['businessappurl'] . "index.php"); - exit(); -} else { - $db = new Database(); - - $stmt = $db->query( - "SELECT coll_id, res_id_master - FROM res_view_attachments - WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? ORDER BY relation desc",array($sId, $sId, $_REQUEST['res_id_master']) - ); - $res = $stmt->fetchObject(); - $collId = $res->coll_id; - $resIdMaster = $res->res_id_master; - - $where2 = ""; - foreach (array_keys($_SESSION['user']['security']) as $key) { - if ($collId == $key) { - $where2 = " and ( " . $_SESSION['user']['security'][$key]['DOC']['where'] - . " ) "; - } - } - - $table = $sec->retrieve_table_from_coll($collId); - $stmt = $db->query( - "SELECT res_id FROM $table WHERE res_id = ?", array($resIdMaster) - ); - //$db->show(); - if ($stmt->rowCount() == 0) { - $_SESSION['error'] = _THE_DOC . " " . _EXISTS_OR_RIGHT; - header( - "location: " . $_SESSION['config']['businessappurl'] . "index.php" - ); - exit(); - } else { - $stmt = $db->query( - "SELECT docserver_id, path, filename, format - FROM res_view_attachments - WHERE (res_id = ? OR res_id_version = ?) AND res_id_master = ? ORDER BY relation desc", array($sId, $sId, $_REQUEST['res_id_master']) - ); - - if ($stmt->rowCount() == 0) { - $_SESSION['error'] = _THE_DOC . " " . _EXISTS_OR_RIGHT; - header( - "location: " . $_SESSION['config']['businessappurl'] - . "index.php" - ); - exit(); - } else { - $line = $stmt->fetchObject(); - $docserver = $line->docserver_id; - $path = $line->path; - $filename = $line->filename; - $format = "pdf"; - $pdfFilename = str_ireplace($line->format, $format, $filename); - - $stmt = $db->query( - "select path_template from " . _DOCSERVERS_TABLE_NAME - . " where docserver_id = ?",array($docserver) - ); - //$db->show(); - $lineDoc = $stmt->fetchObject(); - $docserver = $lineDoc->path_template; - $file = $docserver . $path . $pdfFilename; - $file = str_replace("#", DIRECTORY_SEPARATOR, $file); - - //$file = str_replace(pathinfo($file, PATHINFO_EXTENSION), "pdf",$file); - - if (strtoupper($format) == "MAARCH") { - if (file_exists($file)) { - $myfile = fopen($file, "r"); - - $data = fread($myfile, filesize($file)); - fclose($myfile); - $content = stripslashes($data); - $core->load_html(); - $core->load_header(); - ?> - <body id="validation_page" onload="javascript:moveTo(0,0);resizeTo(screen.width, screen.height);"> - <div id="model_content" style="width:100%;" > - - <?php functions::xecho($content);?> - - </div> - </body> - </html> <?php - } else { - $_SESSION['error'] = _NO_DOC_OR_NO_RIGHTS . "..."; - ?><script type="text/javascript">window.opener.top.location.href='index.php';self.close();</script><?php - } - } else { - require_once 'core/docservers_tools.php'; - $arrayIsAllowed = array(); - $arrayIsAllowed = Ds_isFileTypeAllowed($file); - if ($arrayIsAllowed['status']) { - if ($_SESSION['history']['attachview'] == "true") { - $hist = new history(); - $hist->add( - $table, $sId, "VIEW", 'attachview', _VIEW_DOC_NUM . "" . $sId, - $_SESSION['config']['databasetype'], 'apps' - ); - } - header("Pragma: public"); - header("Expires: 0"); - header( - "Cache-Control: must-revalidate, post-check=0, pre-check=0" - ); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - header("Content-Type: " . $arrayIsAllowed['mime_type']); - header( - "Content-Disposition: inline; filename=" - . basename('maarch.' . $format) . ";" - ); - header("Content-Transfer-Encoding: binary"); - readfile($file); - exit(); - } else { - echo _FORMAT . ' ' . _UNKNOWN; - exit(); - } - } - } - } -} - -?> \ No newline at end of file diff --git a/modules/visa/xml/IVS/requests_definitions.xml b/modules/visa/xml/IVS/requests_definitions.xml index 58c7c29cbb3..7979de938ee 100755 --- a/modules/visa/xml/IVS/requests_definitions.xml +++ b/modules/visa/xml/IVS/requests_definitions.xml @@ -80,12 +80,4 @@ <parameter name="page" value="update_visaPage"/> <parameter name="module" value="visa"/> </requestDefinition> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="vi_view_pdf_attachement" > - <parameter name="page" value="view_pdf_attachement"/> - <parameter name="module" value="visa"/> - </requestDefinition> - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="vi_view_pdf_attachement" > - <parameter name="page" value="view_pdf_attachement"/> - <parameter name="module" value="visa"/> - </requestDefinition> </requestDefinitions> \ No newline at end of file diff --git a/modules/visa/xml/IVS/validation_rules.xml b/modules/visa/xml/IVS/validation_rules.xml index 80f400c464b..b432af22898 100755 --- a/modules/visa/xml/IVS/validation_rules.xml +++ b/modules/visa/xml/IVS/validation_rules.xml @@ -78,8 +78,4 @@ <parameter name="coll_id" type="collection_list" /> <parameter name="action" type="string" /> </validationRule> - <validationRule name="vi_view_pdf_attachement" extends="standardForm" mode="error"> - <parameter name="res_id_master" type="integer" /> - <parameter name="id" type="integer" /> - </validationRule> </validationRules> \ No newline at end of file diff --git a/sql/delete_all_ressources.sql b/sql/delete_all_ressources.sql index e4a8ec39aec..d25a4e60b64 100755 --- a/sql/delete_all_ressources.sql +++ b/sql/delete_all_ressources.sql @@ -40,9 +40,6 @@ ALTER SEQUENCE res_id_mlb_seq restart WITH 1; TRUNCATE TABLE res_attachments; ALTER SEQUENCE res_attachment_res_id_seq restart WITH 1; -TRUNCATE TABLE res_version_attachments; -ALTER SEQUENCE res_id_version_attachments_seq restart WITH 1; - TRUNCATE TABLE adr_letterbox; ALTER SEQUENCE adr_letterbox_id_seq restart WITH 1; diff --git a/sql/index_creation.sql b/sql/index_creation.sql index 2a768c2c011..b850272c025 100755 --- a/sql/index_creation.sql +++ b/sql/index_creation.sql @@ -17,12 +17,6 @@ CREATE INDEX res_id_idx ON res_attachments (res_id); CREATE INDEX res_id_master_idx ON res_attachments (res_id_master); CREATE INDEX res_att_external_id_idx ON res_attachments (external_id); --- res_version_attachments -CREATE INDEX res_id_version_attachments_idx ON res_version_attachments (res_id); -CREATE INDEX res_id_master_version_attachments_idx ON res_version_attachments (res_id_master); -CREATE INDEX attachment_id_master_idx ON res_version_attachments (attachment_id_master); -CREATE INDEX res_vers_external_id_idx ON res_version_attachments (external_id); - -- listinstance CREATE INDEX res_id_listinstance_idx ON listinstance (res_id); CREATE INDEX listinstance_coll_id_idx ON listinstance (coll_id); diff --git a/sql/structure.sql b/sql/structure.sql index 8473f8b8b9f..59a4bb57184 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -1394,134 +1394,6 @@ CREATE OR REPLACE VIEW view_contacts AS LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id LEFT JOIN contact_types ct ON c.contact_type = ct.id; -DROP TABLE IF EXISTS res_version_attachments; -DROP SEQUENCE IF EXISTS res_id_version_attachments_seq; - - CREATE SEQUENCE res_id_version_attachments_seq - INCREMENT 1 - MINVALUE 1 - MAXVALUE 9223372036854775807 - START 100 - CACHE 1; - -CREATE TABLE res_version_attachments -( - res_id bigint NOT NULL DEFAULT nextval('res_id_version_attachments_seq'::regclass), - title character varying(255) DEFAULT NULL::character varying, - subject text, - description text, - type_id bigint NOT NULL, - format character varying(50) NOT NULL, - typist character varying(128) NOT NULL, - creation_date timestamp without time zone NOT NULL, - author character varying(255) DEFAULT NULL::character varying, - identifier character varying(255) DEFAULT NULL::character varying, - source character varying(255) DEFAULT NULL::character varying, - relation bigint, - doc_date timestamp without time zone, - docserver_id character varying(32) NOT NULL, - path character varying(255) DEFAULT NULL::character varying, - filename character varying(255) DEFAULT NULL::character varying, - offset_doc character varying(255) DEFAULT NULL::character varying, - fingerprint character varying(255) DEFAULT NULL::character varying, - filesize bigint, - status character varying(10) NOT NULL, - destination character varying(50) DEFAULT NULL::character varying, - validation_date timestamp without time zone, - effective_date timestamp without time zone, - work_batch bigint, - origin character varying(50) DEFAULT NULL::character varying, - priority character varying(16), - policy_id character varying(32), - cycle_id character varying(32), - is_multi_docservers character(1) NOT NULL DEFAULT 'N'::bpchar, - custom_t1 text, - custom_n1 bigint, - custom_f1 numeric, - custom_d1 timestamp without time zone, - custom_t2 character varying(255) DEFAULT NULL::character varying, - custom_n2 bigint, - custom_f2 numeric, - custom_d2 timestamp without time zone, - custom_t3 character varying(255) DEFAULT NULL::character varying, - custom_n3 bigint, - custom_f3 numeric, - custom_d3 timestamp without time zone, - custom_t4 character varying(255) DEFAULT NULL::character varying, - custom_n4 bigint, - custom_f4 numeric, - custom_d4 timestamp without time zone, - custom_t5 character varying(255) DEFAULT NULL::character varying, - custom_n5 bigint, - custom_f5 numeric, - custom_d5 timestamp without time zone, - custom_t6 character varying(255) DEFAULT NULL::character varying, - custom_d6 timestamp without time zone, - custom_t7 character varying(255) DEFAULT NULL::character varying, - custom_d7 timestamp without time zone, - custom_t8 character varying(255) DEFAULT NULL::character varying, - custom_d8 timestamp without time zone, - custom_t9 character varying(255) DEFAULT NULL::character varying, - custom_d9 timestamp without time zone, - custom_t10 character varying(255) DEFAULT NULL::character varying, - custom_d10 timestamp without time zone, - custom_t11 character varying(255) DEFAULT NULL::character varying, - custom_t12 character varying(255) DEFAULT NULL::character varying, - custom_t13 character varying(255) DEFAULT NULL::character varying, - custom_t14 character varying(255) DEFAULT NULL::character varying, - custom_t15 character varying(255) DEFAULT NULL::character varying, - tablename character varying(32) DEFAULT 'res_version_attachments'::character varying, - initiator character varying(50) DEFAULT NULL::character varying, - dest_user character varying(128) DEFAULT NULL::character varying, - coll_id character varying(32) NOT NULL, - attachment_type character varying(255) DEFAULT NULL::character varying, - dest_contact_id bigint, - dest_address_id bigint, - updated_by character varying(128) DEFAULT NULL::character varying, - is_multicontacts character(1), - 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, - fulltext_result character varying(10) DEFAULT NULL::character varying, - external_id jsonb DEFAULT '{}', - CONSTRAINT res_version_attachments_pkey PRIMARY KEY (res_id) -) -WITH ( - OIDS=FALSE -); - -CREATE TABLE adr_attachments_version -( - id serial NOT NULL, - res_id bigint NOT NULL, - type character varying(32) NOT NULL, - docserver_id character varying(32) NOT NULL, - path character varying(255) NOT NULL, - filename character varying(255) NOT NULL, - fingerprint character varying(255) DEFAULT NULL::character varying, - CONSTRAINT adr_attachments_version_pkey PRIMARY KEY (id), - CONSTRAINT adr_attachments_version_unique_key UNIQUE (res_id, type) -) -WITH (OIDS=FALSE); - --- view for attachments -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, type_id, format, typist, - creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_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, 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; - - CREATE FUNCTION order_alphanum(text) RETURNS text AS $$ SELECT regexp_replace(regexp_replace(regexp_replace(regexp_replace($1, E'(^|\\D)(\\d{1,3}($|\\D))', E'\\1000\\2', 'g'), diff --git a/src/app/action/controllers/ExternalSignatoryBookTrait.php b/src/app/action/controllers/ExternalSignatoryBookTrait.php index ad7f76dfeea..4232c409ab3 100644 --- a/src/app/action/controllers/ExternalSignatoryBookTrait.php +++ b/src/app/action/controllers/ExternalSignatoryBookTrait.php @@ -115,15 +115,6 @@ trait ExternalSignatoryBookTrait ]); } } - if (!empty($attachmentToFreeze['attachments_version_coll'])) { - foreach ($attachmentToFreeze['attachments_version_coll'] as $resId => $externalId) { - AttachmentModel::freezeAttachment([ - 'resId' => $resId, - 'table' => 'res_version_attachments', - 'externalId' => $externalId - ]); - } - } } } diff --git a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php index ba4d5b44fdd..0575a49a742 100755 --- a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php +++ b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php @@ -197,7 +197,7 @@ class MaarchParapheurController $attachments = AttachmentModel::getOnView([ 'select' => [ - 'res_id', 'res_id_version', 'title', 'identifier', 'attachment_type', + 'res_id', 'title', 'identifier', 'attachment_type', 'status', 'typist', 'docserver_id', 'path', 'filename', 'creation_date', 'validation_date', 'relation', 'attachment_id_master' ], @@ -209,17 +209,11 @@ class MaarchParapheurController return ['error' => 'No attachment to send']; } else { foreach ($attachments as $value) { - if (!empty($value['res_id'])) { - $resId = $value['res_id']; - $collId = 'attachments_coll'; - $is_version = false; - } else { - $resId = $value['res_id_version']; - $collId = 'attachments_version_coll'; - $is_version = true; - } + $resId = $value['res_id']; + $collId = 'attachments_coll'; + $is_version = false; - $adrInfo = ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId, 'isVersion' => $is_version]); + $adrInfo = ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId]); if (empty($adrInfo['docserver_id'])) { return ['error' => 'Attachment ' . $resId . ' is not converted in pdf']; } @@ -384,7 +378,7 @@ class MaarchParapheurController public static function retrieveSignedMails(array $aArgs) { - foreach (['noVersion', 'isVersion', 'resLetterbox'] as $version) { + foreach (['noVersion', 'resLetterbox'] as $version) { foreach ($aArgs['idsToRetrieve'][$version] as $resId => $value) { $documentWorkflow = MaarchParapheurController::getDocumentWorkflow(['config' => $aArgs['config'], 'documentId' => $value->external_id]); $state = MaarchParapheurController::getState(['workflow' => $documentWorkflow]); diff --git a/src/app/external/externalSignatoryBook/controllers/XParaphController.php b/src/app/external/externalSignatoryBook/controllers/XParaphController.php index 95e75fa9ac2..fb74be482bb 100755 --- a/src/app/external/externalSignatoryBook/controllers/XParaphController.php +++ b/src/app/external/externalSignatoryBook/controllers/XParaphController.php @@ -34,7 +34,7 @@ class XParaphController { $attachments = AttachmentModel::getOnView([ 'select' => [ - 'res_id', 'res_id_version', 'title', 'docserver_id', 'path', 'filename'], + 'res_id', 'title', 'docserver_id', 'path', 'filename'], 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP', 'SEND_MASS')", "in_signature_book = 'true'"], 'data' => [$aArgs['resIdMaster'], ['converted_pdf', 'print_folder', 'signed_response']] ]); @@ -60,17 +60,11 @@ class XParaphController } foreach ($attachments as $value) { - if (!empty($value['res_id'])) { - $resId = $value['res_id']; - $collId = 'attachments_coll'; - $is_version = false; - } else { - $resId = $value['res_id_version']; - $collId = 'attachments_version_coll'; - $is_version = true; - } - - $adrInfo = ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId, 'isVersion' => $is_version]); + $resId = $value['res_id']; + $collId = 'attachments_coll'; + $is_version = false; + + $adrInfo = ConvertPdfController::getConvertedPdfById(['resId' => $resId, 'collId' => $collId]); $docserverInfo = DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id']]); $filePath = $docserverInfo['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename']; @@ -140,8 +134,7 @@ class XParaphController $aAttachment = AttachmentModel::getById([ 'select' => ['external_id'], - 'id' => $resId, - 'isVersion' => $is_version + 'id' => $resId ]); $externalId = json_decode($aAttachment[0]['external_id'], true); @@ -150,8 +143,7 @@ class XParaphController AttachmentModel::update([ 'set' => ['external_id' => json_encode($externalId)], 'where' => ['res_id = ?'], - 'data' => [$resId], - 'isVersion' => $is_version + 'data' => [$resId] ]); } } @@ -382,7 +374,7 @@ class XParaphController { $tmpPath = CoreConfigModel::getTmpPath(); - foreach (['noVersion', 'isVersion'] as $version) { + foreach (['noVersion'] as $version) { $depotsBySiret = []; foreach ($aArgs['idsToRetrieve'][$version] as $resId => $value) { $externalId = json_decode($value->xparaphdepot, true); diff --git a/src/frontend/app/administration/privilege/privileges.ts b/src/frontend/app/administration/privilege/privileges.ts index 157a92c3f4e..2e09327b55f 100644 --- a/src/frontend/app/administration/privilege/privileges.ts +++ b/src/frontend/app/administration/privilege/privileges.ts @@ -16,7 +16,7 @@ export const PRIVILEGES = [ "label2" : "_ADV_SEARCH_MLB", "label" : lang.search, "comment" : lang.search, - "route" : "index.php?page=search_adv&dir=indexing_searching", + "route" : "index.php?page=search_adv&dir=indexing_searching", "type" : "menu", "style" : "fa fa-search", "angular" : false @@ -37,7 +37,7 @@ export const PRIVILEGES = [ "comment2" : "_REPORTS_DESC", "label" : lang.reports, "comment" : lang.reports, - "route" : "index.php?page=reports&module=reports", + "route" : "index.php?page=reports&module=reports", "type" : "menu", "style" : "fa fa-chart-area", "angular" : false @@ -119,7 +119,7 @@ export const PRIVILEGES = [ "label" : lang.tags, "comment2" : "_ADMIN_TAGS_DESC", "comment" : lang.adminTagsDesc, - "route" : "index.php?page=manage_tag_list_controller&module=tags", + "route" : "index.php?page=manage_tag_list_controller&module=tags", "type" : "admin", "unit" : "classement", "style" : "fa fa-tags", @@ -167,7 +167,7 @@ export const PRIVILEGES = [ "label" : lang.contacts, "comment2" : "_ADMIN_CONTACTS_DESC", "comment" : lang.contactsAdmin, - "route" : "index.php?page=admin_contacts&admin=contacts", + "route" : "index.php?page=admin_contacts&admin=contacts", "type" : "admin", "unit" : "production", "style" : "fa fa-book", diff --git a/src/frontend/service/privileges.service.ts b/src/frontend/service/privileges.service.ts index 68b8b4a9b10..a913e41fb60 100644 --- a/src/frontend/service/privileges.service.ts +++ b/src/frontend/service/privileges.service.ts @@ -85,7 +85,7 @@ export class PrivilegeService { "id": "admin_tag", "label": this.lang.tags, "comment": this.lang.adminTagsDesc, - "route": "index.php?page=manage_tag_list_controller&module=tags", + "route": "index.php?page=manage_tag_list_controller&module=tags", "unit": "classement", "style": "fa fa-tags", "angular" : false @@ -121,7 +121,7 @@ export class PrivilegeService { "id": "admin_contacts", "label": this.lang.contacts, "comment": this.lang.contactsAdmin, - "route": "index.php?page=admin_contacts&admin=contacts", + "route": "index.php?page=admin_contacts&admin=contacts", "unit": "production", "style": "fa fa-book", "angular" : false @@ -419,7 +419,7 @@ export class PrivilegeService { "id": "adv_search_mlb", "label": this.lang.search, "comment": this.lang.search, - "route": "index.php?page=search_adv&dir=indexing_searching", + "route": "index.php?page=search_adv&dir=indexing_searching", "style": "fa fa-search", "unit": "application", "angular": false, @@ -439,7 +439,7 @@ export class PrivilegeService { "id": "reports", "label": this.lang.reports, "comment": this.lang.reports, - "route": "index.php?page=reports&module=reports", + "route": "index.php?page=reports&module=reports", "style": "fa fa-chart-area", "unit": "reports", "angular": false, -- GitLab