From 7be92bb2c198fecb0e75066b2054533778e88e7d Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Thu, 13 Feb 2020 14:59:05 +0100 Subject: [PATCH] FEAT #12072 TIME 0:40 re add outgoing mail + clean attachments module --- .../class/class_list_show_Abstract.php | 135 -- .../class/class_lists_Abstract.php | 18 +- apps/maarch_entreprise/xml/entreprise.xml | 10 +- modules/attachments/README.md | 304 --- modules/attachments/add_attachments.php | 253 --- modules/attachments/ajaxDelAttachment.php | 44 - modules/attachments/attachments_content.php | 1663 ----------------- modules/attachments/choose_attachment.php | 186 -- .../class/attachments_controler_Abstract.php | 250 --- modules/attachments/del_attachment.php | 115 -- modules/attachments/get_chrono_attachment.php | 46 - modules/attachments/js/functions.js | 30 - modules/attachments/remove_letterbox.php | 48 - modules/attachments/setFinalVersion.php | 60 - .../show_attachments_details_tab.php | 5 - modules/attachments/show_attachments_tab.php | 6 - .../xml/IVS/requests_definitions.xml | 37 - .../attachments/xml/IVS/validation_rules.xml | 47 - src/app/email/controllers/EmailController.php | 6 +- src/frontend/app/signature-book.component.ts | 12 +- 20 files changed, 18 insertions(+), 3257 deletions(-) delete mode 100755 modules/attachments/README.md delete mode 100755 modules/attachments/add_attachments.php delete mode 100755 modules/attachments/ajaxDelAttachment.php delete mode 100755 modules/attachments/attachments_content.php delete mode 100755 modules/attachments/choose_attachment.php delete mode 100755 modules/attachments/del_attachment.php delete mode 100755 modules/attachments/get_chrono_attachment.php delete mode 100755 modules/attachments/remove_letterbox.php delete mode 100755 modules/attachments/setFinalVersion.php diff --git a/apps/maarch_entreprise/class/class_list_show_Abstract.php b/apps/maarch_entreprise/class/class_list_show_Abstract.php index 2b247c36364..b6685932e68 100755 --- a/apps/maarch_entreprise/class/class_list_show_Abstract.php +++ b/apps/maarch_entreprise/class/class_list_show_Abstract.php @@ -1411,139 +1411,4 @@ class list_show_Abstract extends functions echo $str; } } - - public function list_attachments( - $result, - $nb_total, - $title, - $what, - $key, - $bool_view_document, - $page_view = '', - $used_css = 'listing spec', - $page_modify = '', - $height_page_modify = 400, - $width_page_modify = 500, - $page_del = '', - $modeString = false - ) { - //self::show_array($result); - $listcolumn = array(); - $listshow = array(); - $listformat = array(); - $start = 0; - $end = $nb_total; - $str = ''; - // put in tab the different label of the column - if (isset($result[0])) { - for ($j = 0; $j < count($result[0]); ++$j ) { - if (isset($result[0][$j]['label'])) { - array_push($listcolumn, $result[0][$j]['label']); - } else { - array_push($listcolumn, ''); - } - if (isset($result[0][$j]['show'])) { - array_push($listshow, $result[0][$j]['show']); - } else { - array_push($listshow, false); - } - } - } - //self::show_array($listcolumn); - //self::show_array($listshow); - $func = new functions(); - $nb_show = $_SESSION['config']['nblinetoshow']; - $str .= '<b>'; - if (!empty($picto_path)) { - $str .= '<img src="'.$picto_path.'" alt="" class="title_img" /> '; - } - $str .= $title.'</b>'; - $str .= ' <div align="center">'; - $str .= '<input type="hidden" id="category_id" value="outgoing"/>'; - $str .= '<table border="0" cellspacing="0" class="'.$used_css.'">'; - $str .= '<thead>'; - $str .= '<tr>'; - if ($bool_view_document) { - $str .= '<th style="width:3%;"> </th>'; - } - for ($count_column = 0; $count_column < count($listcolumn); ++$count_column) { - if ($listshow[$count_column] == true) { - $str .= '<th style="width:'.$result[0][$count_column]['size'] - .'%;" valign="'.$result[0][$count_column]['valign'] - .'" align="'.$result[0][$count_column]['label_align'] - .'" ><span>'.$listcolumn[$count_column].'</span>'; - } - } - $str .= '<th style="width:4%;" valign="bottom" > </th>'; - $str .= '</tr>'; - $str .= '</thead>'; - $str .= '<tbody>'; - $color = ''; - for ($theline = $start; $theline < $end; ++$theline) { - if ($color == ' class="col"') { - $color = ''; - } else { - $color = ' class="col"'; - } - $str .= '<tr '.$color.'>'; - if ($bool_view_document) { - $str .= " <td><a href='".$page_view.'&id=' - .$result[$theline][0][$key] - ."' target=\"_blank\" title='"._VIEW_DOC."'>" - .'<i class="fa fa-download fa-2x" title="'._VIEW_DOC.'"></i>' - .'</a></td>'; - } - $bool_modify = false; - $bool_del = false; - for ($count_column = 0; $count_column < count($listcolumn); ++$count_column ) { - if (isset($result[$theline][$count_column]['show']) - && $result[$theline][$count_column]['show'] == true - ) { - $str .= '<td style="width:' - .$result[$theline][$count_column]['size'] - .'%;" align="' - .$result[$theline][$count_column]['align'] - .'">' - .functions::show_str(self::thisword($result[$theline][$count_column]['value'], $what)) - .'</td>'; - } else { - if ($result[$theline][$count_column]['column'] == 'modify_item' && $result[$theline][$count_column]['value'] == true) { - $bool_modify = true; - } - if ($result[$theline][$count_column]['column'] == 'delete_item' && $result[$theline][$count_column]['value'] == true) { - $bool_del = true; - } - } - } - if ($bool_modify) { - $str .= '<td class="action">'; - $str .= '<a href="javascript://" class="change" onclick="modifyAttachmentsForm(\''.$_SESSION['config']['businessappurl'] - .'index.php?display=true&module=attachments&page=attachments_content'; - $str .= '&id='.$result[$theline][0][$key].'\',\'98%\',\'auto\');">' - ._MODIFY.'</a>'; - $str .= '</td>'; - } else { - $str .= '<td class="action"> </td>'; - } - if ($bool_del) { - $str .= '<td class="action">'; - $str .= '<a href="'.$page_del.'&id='.$result[$theline][0][$key].'" class="delete"' - .'onclick="return(confirm(\''._REALLY_DELETE.' ?\n\r\n\r' - ._DEFINITIVE_ACTION.'\'));">' - ._DELETE.'</a>'; - $str .= '</td>'; - } else { - $str .= '<td class="action"> </td>'; - } - $str .= '</tr>'; - } - $str .= '</tbody>'; - $str .= '</table>'; - $str .= '</div>'; - if ($modeString) { - return $str; - } else { - echo $str; - } - } } diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index 3112ee74c25..8d74f448890 100755 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -1455,15 +1455,7 @@ abstract class lists_Abstract extends Database } } - $core_tools = new core_tools(); - if (($core_tools->test_service('delete_attachments', 'attachments', false) || $typist == $_SESSION['user']['UserId']) && $status != 'FRZ') { - $return = '<a href="index.php?display=true' - .'&module=attachments&page=del_attachment&docId='.$_SESSION['doc_id'].'&relation='.$resultTheLine[1]['value'].'&id='.$resultTheLine[0]['value'].'&fromDetail='.$fromDetail.'"' - .'onclick="return(confirm(\''._REALLY_DELETE.' ?\n\r\n\r' - ._DEFINITIVE_ACTION.'\'));"><i class="tooltip fa fa-trash-alt fa-2x visaPjDel" style="color:white;font-size: 21px;padding-right: 12px;padding-bottom: 12px;padding-top:11px;margin-right:10px;" title="'._DELETE.'"></i></a>'; - } else { - $return = '<a href="" class="delete" style="visibility:hidden;"><i class="tooltip fa fa-trash-alt fa-2x" title="'._DELETE.'"></i></a>'; - } + $return = '<a href="" class="delete" style="visibility:hidden;"><i class="tooltip fa fa-trash-alt fa-2x" title="'._DELETE.'"></i></a>'; $return .= '<script>titleWithTooltipsterClass("tooltip");</script>'; return $return; @@ -1488,14 +1480,8 @@ abstract class lists_Abstract extends Database } } - $core_tools = new core_tools(); - if (($core_tools->test_service('modify_attachments', 'attachments', false) || $typist == $_SESSION['user']['UserId']) && !in_array($status, ['TRA', 'FRZ'])) { - $return = '<i style="font-size: 21px;padding-bottom: 11px;padding-left: 13px;margin-right:10px;padding-top:12px" class="tooltip fa fa-edit fa-2x visaPjUp" title="'._MODIFY.'" onclick="modifyAttachmentsForm(\''.$_SESSION['config']['businessappurl'] - .'index.php?display=true&module=attachments&page=attachments_content&id='.$resultTheLine[0]['value'].'&relation='.$relation.'&fromDetail='.$fromDetail.'\',\'98%\',\'auto\');"></i>'; - } else { - $return = '<a href="javascript://" disabled="disabled" class="change" style="visibility:hidden;"> + $return = '<a href="javascript://" disabled="disabled" class="change" style="visibility:hidden;"> <i class="tooltip fa fa-edit fa-2x" title="'._MODIFY.'"></i></a>'; - } return $return; } diff --git a/apps/maarch_entreprise/xml/entreprise.xml b/apps/maarch_entreprise/xml/entreprise.xml index 4909b2d0423..c3f9df7a902 100755 --- a/apps/maarch_entreprise/xml/entreprise.xml +++ b/apps/maarch_entreprise/xml/entreprise.xml @@ -39,6 +39,11 @@ <id>routing</id> <label>_ROUTING</label> <process_mode/> + </type> + <type show="true" with_chrono="true" icon="DS" sign="true"> + <id>outgoing_mail</id> + <label>_OUTGOING_MAIL</label> + <process_mode/> </type> <type show="false" with_chrono="false" icon="" sign="false"> <id>converted_pdf</id> @@ -60,11 +65,6 @@ <label>_SVR</label> <process_mode>SVR</process_mode> </type> - <type show="false" with_chrono="false" icon="" sign="false"> - <id>document_with_notes</id> - <label>_DOCUMENT_WITH_NOTES</label> - <process_mode/> - </type> </attachment_types> <contact_check> <check_days_before>5</check_days_before> <!-- 0 if you want to disabled --> diff --git a/modules/attachments/README.md b/modules/attachments/README.md deleted file mode 100755 index 7bd3094a7ee..00000000000 --- a/modules/attachments/README.md +++ /dev/null @@ -1,304 +0,0 @@ -**Récap des fonctionnalités :** - - Possibilité de rattacher un document à un courrier sans projet de réponse (activable via le config.xml) - Possibilité de rattacher un document à plusieurs courriers (activable via le config.xml) - Possibilité de clore le courrier cible (activable via le config.xml) - Possibilité de supprimer le projet de réponse du courrier cible (activable via le config.xml) - Si le courrier cible à plusieurs projet de réponses et/ou plusieurs courriers cible sont selectionnés il est possible de choisir le numéro de chrono attribué au document - (le titre et les contacts sont automatiquement attribué en fonction du choix) - - -# INSTALLATION DU MODULE RECONCILIATION -# ===================================== - -**Copier le répertoire reconciliation dans modules.** - -**Les fichiers suivants seront à modifier** - - custom/modules/templates/datasources/letterbox_attachment.php - custom/core/xml/actions_pages.xml - custom/apps/maarch_entreprise/definition_mail_categories.php - custom/apps/maarch_entreprise/xml/IVS/data_types.xml - custom/apps/maarch_entreprise/js/indexing.js - custom/modules/attachments/get_chrono_attachment.php - custom/modules/attachments/xml/IVS/validation_rules.xml - custom/modules/entities/js/functions.js - apps/maarch_entreprise/lang/fr.php - apps/maarch_entreprise/lang/en.php - - -**Modifier le fichier modules/template/datasources/letterbox_attachment.php** -Remplacement de la ligne 192 à 208 par : - - $res_id_master = $doc['res_id']; - $data = ''.$res_id_master.'#'.$chronoAttachment; - require_once('apps/maarch_entreprise/tools/phpqrcode/qrlib.php'); - QRcode::png($data,$img_file_name, QR_ECLEVEL_L, 1); - $myAttachment['chronoBarCode'] = $img_file_name; - $datasources['attachments'][] = $myAttachment; - -**Modifier le fichier custom/apps/maarch_entreprise/xml/config.xml** - -Ajout de la catégorie suivante: - - <category> - <id>attachment</id> - <label>_ATTACHMENT</label> - </category> - -Ajout du module suivant: - - <MODULES> - <moduleid>reconciliation</moduleid> - <comment>_RECONCILIATION_COMMENT</comment> - </MODULES> - -**Modifier le fichier custom/apps/maarch_entreprise/xml/IVS/data_types.xml** - -Ajout de l'énumération suivante ligne 83 : - - <dataType name="category_list" base="string"> - <enumeration value="incoming" /> - <enumeration value="outgoing" /> - <enumeration value="internal" /> - <enumeration value="attachment" /> <-- Ligne à rajouter - </dataType> - -**Modifier le fichier custom/apps/maarch_entreprise/definitions_mail_categories.php** - -Ajout du tableau de la catégorie attachment - - $_ENV['categories']['attachment'] = array (); - $_ENV['categories']['attachment']['img_cat'] = '<i class="fa fa-paperclip fa-2x"></i>'; - $_ENV['categories']['attachment']['other_cases'] = array (); - $_ENV['categories']['attachment']['other_cases']['chrono_number'] = array ( - 'type_form' => 'integer', - 'type_field' => 'integer', - 'mandatory' => true, - 'label' => _CHRONO_NUMBER, - 'table' => 'none', - 'img' => 'compass', - 'modify' => false, - 'form_show' => 'textfield' - ); - $_ENV['categories']['attachment']['type_id'] = array ( - 'type_form' => 'integer', - 'type_field' => 'integer', - 'mandatory' => true, - 'label' => _DOCTYPE_MAIL, - 'table' => 'res', - 'img' => 'file', - 'modify' => true, - 'form_show' => 'select' - ); - $_ENV['categories']['attachment']['destination'] = array ( - 'type_form' => 'string', - 'type_field' => 'string', - 'mandatory' => true, - 'label' => _DEPARTMENT_EXP, - 'table' => 'res', - 'img' => 'sitemap', - 'modify' => false, - 'form_show' => 'textarea' - ); - -**Modifier le fichier custom/apps/maarch_entreprise/js/indexing.js** - -Affichage des éléments de liaison de fichier (à la fin de la fonction change_category) - - if(cat_id == 'attachment'){ - document.getElementById("attachment_tr").style.display='table-row'; - document.getElementById("attach_show").style.display='table-row'; - } - -Ajout du tableau contenant les champs à afficher pour la catégorie attachment (fonction change_category) - - else if(cat_id == 'attachment'){ - var category = [ - {id:'doctype_mail', type:'label', state:'display'}, - {id:'doctype_res', type:'label', state:'hide'}, - {id:'priority_tr', type:'tr', state:'hide'}, - {id:'doc_date_label', type:'label', state:'hide'}, - {id:'doc_date_tr', type:'label', state:'hide'}, - {id:'mail_date_label', type:'label', state:'hide'}, - {id:'author_tr', type:'tr', state:'hide'}, - {id:'admission_date_tr', type:'tr', state:'hide'}, - {id:'contact_check', type:'tr', state:'hide'}, - {id:'nature_id_tr', type:'tr', state:'hide'}, - {id:'department_tr', type:'tr', state:'hide'}, - {id:'label_dep_dest', type:'label', state:'hide'}, - {id:'label_dep_exp', type:'label', state:'hide'}, - {id:'process_limit_date_use_tr', type:'tr', state:'hide'}, - {id:'process_limit_date_tr', type:'tr', state:'hide'}, - {id:'box_id_tr', type:'tr', state:'hide'}, - {id:'confidentiality_tr', type:'tr', state:'hide'}, - {id:'contact_choose_tr', type:'tr', state:'hide'}, - {id:'contact_choose_2_tr', type:'tr', state:'hide'}, - {id:'contact_choose_3_tr', type:'tr', state:'hide'}, - {id:'dest_contact_choose_label', type:'label', state:'hide'}, - {id:'exp_contact_choose_label', type:'label', state:'hide'}, - {id:'contact_id_tr', type:'tr', state:'hide'}, - {id:'dest_contact', type:'label', state:'display'}, - {id:'exp_contact', type:'label', state:'hide'}, - {id:'author_contact', type:'label', state:'hide'}, - {id:'type_multi_contact_external_icon', type:'label', state:'hide'}, - {id:'type_contact_internal', type:'radiobutton', state:typeContactInternal}, - {id:'type_contact_external', type:'radiobutton', state:typeContactExternal}, - {id:'type_multi_contact_external', type:'radiobutton', state:typeMultiContactExternal}, - {id:'folder_tr', type:'tr', state:'hide'}, - {id:'category_id_mandatory', type:'label', state:'hide'}, - {id:'type_id_mandatory', type:'label', state:'hide'}, - {id:'type_id_tr', type:'tr', state:'hide'}, - {id:'diff_list_tr', type:'tr', state:'hide'}, - {id:'priority_mandatory', type:'label', state:'hide'}, - {id:'doc_date_mandatory', type:'label', state:'hide'}, - {id:'author_mandatory', type:'label', state:'hide'}, - {id:'admission_date_mandatory', type:'label', state:'hide'}, - {id:'type_contact_mandatory', type:'label', state:'hide'}, - {id:'contact_mandatory', type:'label', state:'hide'}, - {id:'nature_id_mandatory', type:'label', state:'hide'}, - {id:'subject_mandatory', type:'label', state:'hide'}, - //{id:'subject_tr', type:'label', state:'hide'}, - {id:'destination_mandatory', type:'label', state:'hide'}, - {id:'process_limit_date_use_mandatory', type:'label', state:'hide'}, - {id:'process_limit_date_mandatory', type:'label', state:'hide'}, - {id:'chrono_number', type:'label', state:'hide'}, - {id:'chrono_number_tr', type:'tr', state:'hide'}, - {id:'chrono_number_mandatory', type:'label', state:'hide'}, - {id:'folder_mandatory', type:'label', state:'hide'}, - {id:'res_id_link', type:'label', state:'hide'}, - {id:'status', type:'tr', state:'hide'}, - {id:'add_multi_contact_tr', type:'tr', state:'hide'}, - {id:'show_multi_contact_tr', type:'tr', state:'hide'} - ]; - } - -Suppression à l'écran de certains champs inutiles au module Reconciliation - - if(cat_id == 'ged_doc'){ - document.getElementById("diff_list_tr").style.display = 'none'; - }else if(cat_id == 'attachment'){ - document.getElementById("subject_tr").style.display = 'none'; - document.getElementById("diff_list_tr").style.display = 'none'; - }else{ - document.getElementById("diff_list_tr").style.display = 'table-row'; - document.getElementById("subject_tr").style.display = 'table-row'; - } - -Modification de la fonction change_contact_type ligne 1430. Il faut remplacer : - - Element.setStyle(contact_id_tr, {display : 'table-row'}); - -Par : - - var cat_id = $(category_id).options[$(category_id).selectedIndex].value; - if(cat_id != 'attachment') Element.setStyle(contact_id_tr, {display : 'table-row'}); - -**Modifier le fichier custom/modules/attachments/get_chrono_attachment.php - Ligne 65** - - if ($category_id == "incoming" || ($category_id == "outgoing" && $nb_attachment > 0)) - ==> - if ($category_id == "incoming" || $category_id == 'attachment' || ($category_id == "outgoing" && $nb_attachment > 0) || (isset($_POST['type_id']) && $_POST['type_id'] == 'attachment')) - -**Modifier le fichier custom/modules/attachments/xml/IVS/validation_rules.xml - Ligne 29** - - <validationRule name="get_chrono_attachment" extends="standardForm" mode="error"> - <parameter name="module" type="identifier" /> - <parameter name="type_id" type="identifier" /> <-- Ligne à rajouter - </validationRule> - -**Modifier le fichier custom/core/xml/action_pages.xml** - -Rajout de la page d'action Reconciliation - - <ACTIONPAGE> - <ID>reconciliation</ID> - <LABEL>_RECONCILIATION</LABEL> - <NAME>reconciliation</NAME> - <ORIGIN>module</ORIGIN> - <MODULE>reconciliation</MODULE> - <FLAG_CREATE>false</FLAG_CREATE> - <COLLECTIONS> - <COLL_ID>letterbox_coll</COLL_ID> - </COLLECTIONS> - </ACTIONPAGE> - -**Modifier le fichier apps/maarch_entreprise/lang/fr.php** - - if (!defined("_ATTACHMENT")) define("_ATTACHMENT", "Pièce jointe"); - -**Modifier le fichier apps/maarch_entreprise/lang/en.php** - - if (!defined("_ATTACHMENT")) define("_ATTACHMENT", "Attachment"); - -**Modifier le fichier custom/modules/entities/js/functions.js** - -Rajouter après la ligne 55 : - - if(category === 'attachment'){ - diff_list_tr.style.display = 'none'; - } - - - -**Coté fonctionnel** - - Créer une nouvelle action - Description : Rattacher une réponse à un courrier - Statut associé : Supprimé - Page de résultat de l'action : Réconciliation - Mot clé (paramètres système): Indexation - Tracer l'action : Oui - Action de dossier : Non - Choisissez une ou plusieurs catégories associées : - (Si aucune catégorie sélectionnée alors l'action est valable pour toutes les catégories) - Aucune - -**Créer une nouvelle bannette** - - Collection : Collection des courriers - Identifiant : AttBasket - Bannette : Courriers à rapprocher - Description : Bannette des courriers à rapprocher - Vue sur la table : status = 'PJQUAL' - -**Ajouter un groupe** - - Liste de résultats: Liste avec filtre et réponses - Action par défaut sur la ligne; Rattacher une réponse à un courrier - -**Editer un nouveau modèle et insérer une nouvelle image avec les dimensions voulues et mettre dans la description de cette dernière** - - [attachments.chronoBarCode;ope=changepic;tagpos=inside;adjust;unique] - - -# Installation du watcher -# ======================= - - cd /opt/maarch - git clone https://github.com/splitbrain/Watcher.git - sudo apt-get install python python-pyinotify - -**Création du service** - - sudo vi /etc/systemd/system/watcher.service - [Unit] - Description=Files watcher for maarch - After=apache2.service - - [Service] - User=edissyum - ExecStart=/opt/maarch/Watcher/watcher.py -c /opt/maarch/Watcher/watcher.ini start - ExecStop=/opt/maarch/Watcher/watcher.py stop - ExecRestart=/opt/maarch/Watcher/watcher.py -c /opt/maarch/Watcher/watcher.ini restart - - [Install] - WantedBy=default.target - - sudo systemctl start watcher - sudo systemctl enable watcher - -**Installation de paquets supplémentaires** - - sudo apt install python-lxml - sudo pip install beautifulsoup4 diff --git a/modules/attachments/add_attachments.php b/modules/attachments/add_attachments.php deleted file mode 100755 index 3df6f1ca425..00000000000 --- a/modules/attachments/add_attachments.php +++ /dev/null @@ -1,253 +0,0 @@ -<?php -/** - *​ ​Copyright​ ​Maarch​ since ​2008​ under licence ​GPLv3. - *​ ​See​ LICENCE​.​txt file at the root folder ​for​ more details. - *​ ​This​ file ​is​ part of ​Maarch​ software. - * - */ - -$core = new core_tools(); -$core->test_user(); -$db = new Database(); - -// Retrieve the parent res_id (the document which receive the attachment) and the res_id of the attachment we will inject -$parentResId = $_SESSION['stockCheckbox']; -$childResId = $_SESSION['doc_id']; - -// Retrieve the data of the form (title, chrono number, recipient etc...) -$formValues = get_values_in_array($_REQUEST['form_values']); -$tabFormValues = array(); - -// NCH01 new modifs -$allowValues = array('title', 'chrono_number', 'contactid','addressid','close_incoming_mail', 'attachment_type', 'back_date'); -foreach($formValues as $tmpTab){ - if(in_array($tmpTab['ID'], $allowValues)){ - if($tmpTab['ID'] == 'chrono_number') // Check if the identifier is empty. if true, set it at NULL - if(empty($tmpTab['VALUE'])) $tmpTab ['VALUE'] = NULL; - if(trim($tmpTab['VALUE']) != '') // Case of some empty value, that cause some errors - $tabFormValues[$tmpTab['ID']] = $tmpTab['VALUE']; - } -} -// END NCH01 new modifs - -$_SESSION['modules_loaded']['attachments']['reconciliation']['tabFormValues'] = $tabFormValues; // declare SESSION var, used in remove_letterbox - -// Remove chrono number depends on attachment type ("with chrono" param) // new modifs -if($_SESSION['attachment_types_with_chrono'][$tabFormValues['attachment_type']] == 'false'){ - $tabFormValues['chrono_number'] = NULL; -} - -// Retrieve the informations of the newly scanned document (the one to attach as an attachment) -$queryChildInfos = \Resource\models\ResModel::getById(['resId' => $childResId]); - -$aArgs['data'] = array(); -foreach ($queryChildInfos as $key => $value) { - if ($value != '' - && $key != 'modification_date' - && $key != 'tablename' - && $key != 'locker_user_id' - && $key != 'locker_time' - && $key != 'confidentiality' - && substr($key, 0, 7) != 'custom_') { - if (is_numeric($value)) { - array_push( - $aArgs['data'], - array( - 'column' => $key, - 'value' => $value, - 'type' => 'integer', - ) - ); - } else { - array_push( - $aArgs['data'], - array( - 'column' => $key, - 'value' => $value, - 'type' => 'string', - ) - ); - } - } -} - -// The column 'relation' need to be set at 1. Otherwise, the suppression of the attachment isn't possible -array_push( - $aArgs['data'], - array( - 'column' => 'relation', - 'value' => 1, - 'type' => 'integer', - ) -); - -// The status need to be TRA -array_push( - $aArgs['data'], - array( - 'column' => 'status', - 'value' => 'TRA', - 'type' => 'string', - ) -); - -// Attachment type -array_push( - $aArgs['data'], - array( - 'column' => 'attachment_type', - 'value' => $tabFormValues['attachment_type'], // NEW MODIFS - 'type' => 'string', - ) -); - -// The title is retrieve from the validate page -array_push( - $aArgs['data'], - array( - 'column' => 'title', - 'value' => $tabFormValues['title'], - 'type' => 'string', - ) -); - -// Same for chrono number -if (isset($tabFormValues['chrono_number'])) { - array_push( - $aArgs['data'], - array( - 'column' => 'identifier', - 'value' => $tabFormValues['chrono_number'], - 'type' => 'string', - ) - ); -} - -// Same for recipient informations -if (isset($tabFormValues['addressid'])) { - array_push( - $aArgs['data'], - array( - 'column' => 'dest_address_id', - 'value' => $tabFormValues['addressid'], - 'type' => 'integer', - ) - ); -} -if (is_numeric($tabFormValues['contactid'])) { // usefull to avoid user contact id (e.g : bblier instead of 1) - array_push( - $aArgs['data'], - array( - 'column' => 'dest_contact_id', - 'value' => $tabFormValues['contactid'], - 'type' => 'integer', - ) - ); -} -//collId's -$aArgs['collId'] = 'letterbox_coll'; -$aArgs['collIdMaster'] = 'letterbox_coll'; - -//table -$aArgs['table'] = 'res_attachments'; - -//fileFormat -for ($i = 0; $i <= count($aArgs['data']); $i++) { - if ($aArgs['data'][$i]['column'] == 'format') { - if ($aArgs['data'][$i]['value'] != null) { - $aArgs['fileFormat'] = $aArgs['data'][$i]['value']; - } - } - if ($aArgs['data'][$i]['column'] == 'creation_date') { - $aArgs['data'][$i]['value'] = $db->current_datetime(); - } - if ($aArgs['data'][$i]['column'] == 'path') { - if ($aArgs['data'][$i]['value'] != null) { - $aArgs['path'] = $aArgs['data'][$i]['value']; - } - } - if ($aArgs['data'][$i]['column'] == 'filename') { - if ($aArgs['data'][$i]['value'] != null) { - $aArgs['filename'] = $aArgs['data'][$i]['value']; - } - } - - if ($aArgs['data'][$i]['column'] == 'docserver_id') { - // Retrieve the PATH TEMPLATE - $docserverPath = \Docserver\models\DocserverModel::getByDocserverId([ - 'select' => ['path_template'], - 'docserverId' => $aArgs['data'][$i]['value'] - ]); - - $aArgs['docserverPath'] = $docserverPath['path_template']; - $aArgs['docserverId'] = $aArgs['data'][$i]['value']; - } -} - -$file = file_get_contents($aArgs['docserverPath'] . str_replace('#', '/', $aArgs['path']) . $aArgs['filename']); -$aArgs['encodedFile'] = base64_encode($file); -$aArgs['status'] = 'TRA'; - -// Add offset to empty (loadIntoDb function needed it) - -array_push( - $aArgs['data'], - array( - 'column' => 'offset_doc', - 'value' => '', - 'type' => 'integer', - ) -); - -array_push( - $aArgs['data'], - array( - 'column' => 'typist', - 'value' => $_SESSION['user']['UserId'], - 'type' => 'string', - ) -); - -array_push( - $aArgs['data'], - array( - 'column' => 'coll_id', - 'value' => 'letterbox_coll', - 'type' => 'string', - ) -); - -array_push( - $aArgs['data'], - array( - 'column' => 'res_id_master', - 'value' => $aArgs['resIdMaster'], - 'type' => 'string', - ) -); - -// res_attachment insertion -if (count($parentResId) == 1) { - array_push( - $aArgs['data'], - array( - 'column' => 'res_id_master', - 'value' => $parentResId[0], - 'type' => 'string', - ) - ); - $insertResAttach = \Resource\controllers\StoreController::storeResourceRes($aArgs); -} else { - for ($i = 0; $i < count($parentResId); $i++) { - array_push( - $aArgs['data'], - array( - 'column' => 'res_id_master', - 'value' => $parentResId[$i], - 'type' => 'string', - ) - ); - $insertResAttach = \Resource\controllers\StoreController::storeResourceRes($aArgs); - } -} -unset($_SESSION['save_chrono_number']); // Usefull to avoid duplicate chrono number diff --git a/modules/attachments/ajaxDelAttachment.php b/modules/attachments/ajaxDelAttachment.php deleted file mode 100755 index c56c37ff80c..00000000000 --- a/modules/attachments/ajaxDelAttachment.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/* -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. - -* @brief ajaxDelAttachment -* @author dev <dev@maarch.org> -* @ingroup attachments -*/ -if (isset($_POST['index'])) { - if (!empty($_SESSION['upfile'][$_POST['index']])) { - //RESET UPFILE SESSION - $tmpUpfile = $_SESSION['upfile']; - unset($_SESSION['upfile']); - - $_SESSION['upfile']['error'] = 0; - $j = 0; - for ($i = 0; $i < count($tmpUpfile); ++$i) { - if ($i != $_POST['index'] && !empty($tmpUpfile[$i])) { - $_SESSION['upfile'][$j] = $tmpUpfile[$i]; - ++$j; - } - } - } - //RESET CHRONO SESSION - $tmpSaveChonoNumber = $_SESSION['save_chrono_number']; - unset($_SESSION['save_chrono_number']); - $j = 0; - for ($i = 0; $i < count($tmpSaveChonoNumber); ++$i) { - if ($i != $_POST['index']) { - $_SESSION['save_chrono_number'][$j] = $tmpSaveChonoNumber[$i]; - ++$j; - } - } - - $status = 0; - $error = ''; -} else { - $status = 0; - $error = 'no index'; -} -echo '{"status" : "'.$status.'", "content" : "", "error" : "'.addslashes($error).'", "exec_js" : ""}'; -exit(); diff --git a/modules/attachments/attachments_content.php b/modules/attachments/attachments_content.php deleted file mode 100755 index ceb838e560d..00000000000 --- a/modules/attachments/attachments_content.php +++ /dev/null @@ -1,1663 +0,0 @@ -<?php -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. - -* -* @brief attachments_content -* -* @author dev <dev@maarch.org> -* @ingroup attachments -*/ -require_once 'core/class/class_security.php'; -require_once 'core/class/class_request.php'; -require_once 'core/class/class_resource.php'; -require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'] - .DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR - .'class_indexing_searching_app.php'; -require_once 'core/class/docservers_controler.php'; -require_once 'modules/attachments/attachments_tables.php'; -require_once 'core/class/class_history.php'; -require_once 'modules/attachments/class/attachments_controler.php'; - -$core = new core_tools(); -$core->load_lang(); -$sec = new security(); -$func = new functions(); -$db = new Database(); -$req = new request(); -$docserverControler = new docservers_controler(); -$ac = new attachments_controler(); - -$_SESSION['error'] = ''; - -$status = 0; -$error = $content = $js = $parameters = ''; -$_SESSION['cm_applet'][$_SESSION['user']['UserId']] = []; - -function _parse($text) -{ - $text = str_replace("\r\n", "\n", $text); - $text = str_replace("\r", "\n", $text); - $text = str_replace("\n", '\\n ', $text); - - return $text; -} - -if (!empty($_REQUEST['docId'])) { - $_SESSION['doc_id'] = $_REQUEST['docId']; -} - -//BEGIN SAVE ATTACHMENT VALIDATE BUTTTON -if (isset($_POST['add']) && $_POST['add']) { - //CHECK FORM ERRORS - if ((count($_SESSION['upfile']) - 1) != count($_REQUEST['attachNum'])) { - $error = _MODEL_NOT_EDITED; - $status = 1; - } else { - for ($numAttach = 0; $numAttach < count($_SESSION['upfile']) - 1; ++$numAttach) { - //EMPTY ATTACHMENTS FILE ? - if (empty($_SESSION['upfile'][$numAttach]['tmp_name'])) { - $error = _FILE_MISSING; - } elseif ($_SESSION['upfile'][$numAttach]['size'] == 0) { - $error = _FILE_EMPTY; - } - //MAX SIZE FILE ? - if ($_SESSION['upfile'][$numAttach]['error'] == 1) { - $filesize = $func->return_bytes(ini_get('upload_max_filesize')); - $error = _ERROR_FILE_UPLOAD_MAX.'('.round($filesize / 1024, 2).'Ko Max)'; - } - - //EMPTY ATTACHMENT TYPE ? - $attachment_types = ''; - if (!isset($_REQUEST['attachment_types'][$numAttach]) || empty($_REQUEST['attachment_types'][$numAttach])) { - $error = _ATTACHMENT_TYPES.' '._MANDATORY; - } else { - $attachment_types = $func->protect_string_db($_REQUEST['attachment_types'][$numAttach]); - } - - //EMPTY TITLE ? - $title = ''; - if (!isset($_REQUEST['title'][$numAttach]) || empty($_REQUEST['title'][$numAttach])) { - $error = _OBJECT.' '._MANDATORY; - } else { - $title = $_REQUEST['title'][$numAttach]; - $title = str_replace(''', "'", $title); - } - - //PROCESS ATTACHMENT - if (empty($error)) { - $back_date = $_REQUEST['back_date'][$numAttach]; - $contactidAttach = $_REQUEST['contactidAttach'][$numAttach]; - $addressidAttach = $_REQUEST['addressidAttach'][$numAttach]; - $chrono = $_REQUEST['chrono'][$numAttach]; - $attachStatus = $_REQUEST['effectiveDateStatus'][$numAttach]; - - require_once 'core/docservers_tools.php'; - $arrayIsAllowed = array(); - $arrayIsAllowed = Ds_isFileTypeAllowed( - $_SESSION['config']['tmppath'].$_SESSION['upfile'][$numAttach]['fileNameOnTmp'] - ); - if ($arrayIsAllowed['status'] == false) { - $error = _WRONG_FILE_TYPE.' '.$arrayIsAllowed['mime_type']; - $_SESSION['upfile'] = array(); - } else { - if (!isset($_SESSION['collection_id_choice']) - || empty($_SESSION['collection_id_choice']) - ) { - $_SESSION['collection_id_choice'] = $_SESSION['user']['collections'][0]; - } - - //CHECK DOCSERVER FOR ATTACHMENT - $docserver = $docserverControler->getDocserverToInsert( - $_SESSION['collection_id_choice'] - ); - if (empty($docserver)) { - $error = _DOCSERVER_ERROR.' : '._NO_AVAILABLE_DOCSERVER.'. '._MORE_INFOS; - $location = ''; - } else { - //CHECK DOCSERVER SPACE - $newSize = $docserverControler->checkSize( - $docserver, - $_SESSION['upfile'][$numAttach]['size'] - ); - if ($newSize == 0) { - $error = _DOCSERVER_ERROR.' : '._NOT_ENOUGH_DISK_SPACE.'. '._MORE_INFOS; ?> - <script type="text/javascript"> - var eleframe1 = window.parent.top.document.getElementById('list_attach'); - eleframe1.location.href = '<?php - echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&module=attachments&page=frame_list_attachments&attach_type_exclude=converted_pdf,print_folder&mode=normal&load'; - </script> - <?php - exit(); - } else { - //GET FILE INFOS - $path_parts = pathinfo($_SESSION['upfile'][$numAttach]['fileNameOnTmp']); - $fileInfos = array( - 'tmpDir' => $_SESSION['config']['tmppath'], - 'size' => $_SESSION['upfile'][$numAttach]['size'], - 'format' => $path_parts['extension'], - 'tmpFileName' => $_SESSION['upfile'][$numAttach]['fileNameOnTmp'], - ); - if ($contactidAttach != 'mailing') { - - //SAVE FILE ON DOCSERVER - $storeResult = array(); - $storeResult = $docserverControler->storeResourceOnDocserver( - $_SESSION['collection_id_choice'], - $fileInfos - ); - if ($attachment_types == 'outgoing_mail' && strpos($fileInfos['format'], 'xl') === false && strpos($fileInfos['format'], 'ppt') === false) { - $_SESSION['upfile'][$numAttach]['outgoingMail'] = true; - } - } - - if (isset($storeResult['error']) && $storeResult['error'] != '') { - $error = $storeResult['error']; - } else { - $resAttach = new resource(); - $_SESSION['data'] = array(); - array_push( - $_SESSION['data'], - array( - 'column' => 'typist', - 'value' => $_SESSION['user']['UserId'], - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'format', - 'value' => $fileInfos['format'], - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'res_id_master', - 'value' => $_SESSION['doc_id'], - 'type' => 'integer', - ) - ); - if ($contactidAttach != 'mailing') { - array_push( - $_SESSION['data'], - array( - 'column' => 'docserver_id', - 'value' => $storeResult['docserver_id'], - 'type' => 'string', - ) - ); - if (isset($contactidAttach) && $contactidAttach != '' && is_numeric($contactidAttach)) { - array_push( - $_SESSION['data'], - array( - 'column' => 'dest_contact_id', - 'value' => $contactidAttach, - 'type' => 'integer', - ) - ); - } elseif (isset($contactidAttach) && $contactidAttach != '' && !is_numeric($contactidAttach)) { - $_SESSION['data'][] = [ - 'column' => 'dest_user', - 'value' => $contactidAttach, - 'type' => 'string', - ]; - } - - if (isset($addressidAttach) && $addressidAttach != '' && is_numeric($addressidAttach)) { - array_push( - $_SESSION['data'], - array( - 'column' => 'dest_address_id', - 'value' => $addressidAttach, - 'type' => 'integer', - ) - ); - } - } - array_push( - $_SESSION['data'], - array( - 'column' => 'status', - 'value' => $attachStatus, - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'offset_doc', - 'value' => ' ', - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'title', - 'value' => $title, - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'attachment_type', - 'value' => $attachment_types, - 'type' => 'string', - ) - ); - //GET SIGN PROPERTY FOR CURRENT ATTACHMENT TYPE - $attachmentTypesList = \Attachment\models\AttachmentModel::getAttachmentsTypesByXML(); - foreach ($attachmentTypesList as $keyAttachment => $valueAttachment) { - if ($keyAttachment == $attachment_types && $valueAttachment['sign']) { - array_push( - $_SESSION['data'], - array( - 'column' => 'in_signature_book', - 'value' => 1, - 'type' => 'bool', - ) - ); - } - } - - array_push( - $_SESSION['data'], - array( - 'column' => 'coll_id', - 'value' => $_SESSION['collection_id_choice'], - 'type' => 'string', - ) - ); - if (isset($back_date) && $back_date != '') { - array_push( - $_SESSION['data'], - array( - 'column' => 'validation_date', - 'value' => $func->format_date_db($back_date), - 'type' => 'date', - ) - ); - } - - if (!empty($chrono)) { - array_push( - $_SESSION['data'], - array( - 'column' => 'identifier', - 'value' => $chrono, - 'type' => 'string', - ) - ); - } - array_push( - $_SESSION['data'], - array( - 'column' => 'type_id', - 'value' => 0, - 'type' => 'int', - ) - ); - - array_push( - $_SESSION['data'], - array( - 'column' => 'relation', - 'value' => 1, - 'type' => 'int', - ) - ); - - if ($contactidAttach == 'mailing') { - if (empty($_REQUEST['mailing'])) { - $fileInfos = [ - 'tmpDir' => $_SESSION['config']['tmppath'], - 'size' => $_SESSION['upfile'][$numAttach]['size'], - 'format' => $path_parts['extension'], - 'tmpFileName' => $_SESSION['upfile'][$numAttach]['fileNameOnTmp'], - ]; - $storeResult = $docserverControler->storeResourceOnDocserver($_SESSION['collection_id_choice'], $fileInfos); - - foreach ($_SESSION['data'] as $dataKey => $dataValue) { - if (in_array($dataValue['column'], ['status'])) { - unset($_SESSION['data'][$dataKey]); - } - } - $_SESSION['data'][] = [ - 'column' => 'status', - 'value' => 'SEND_MASS', - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'docserver_id', - 'value' => $storeResult['docserver_id'], - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'dest_contact_id', - 'value' => null, - 'type' => 'integer' - ]; - $_SESSION['data'][] = [ - 'column' => 'dest_address_id', - 'value' => null, - 'type' => 'integer' - ]; - - $id = $resAttach->load_into_db( - 'res_attachments', - $storeResult['destination_dir'], - $storeResult['file_destination_name'], - $storeResult['path_template'], - $storeResult['docserver_id'], - $_SESSION['data'], - $_SESSION['config']['databasetype'] - ); - } else { - $contactsForMailing = \SrcCore\models\DatabaseModel::select([ - 'select' => ['*'], - 'table' => ['contacts_res'], - 'where' => ['res_id = ?', 'address_id != ?'], - 'data' => [$_SESSION['doc_id'], 0] - ]); - foreach ($contactsForMailing as $key => $contactForMailing) { - $chronoPubli = $chrono.'-'.chr(ord('A')+$key); - $pathToAttachmentToCopy = $_SESSION['config']['tmppath'] . $_SESSION['upfile'][$numAttach]['fileNameOnTmp']; - $params = [ - 'userId' => $_SESSION['user']['UserId'], - 'res_id' => $_SESSION['doc_id'], - 'coll_id' => 'letterbox_coll', - 'res_view' => 'res_view_attachments', - 'res_table' => 'res_attachments', - 'res_contact_id' => $contactForMailing['contact_id'], - 'res_address_id' => $contactForMailing['address_id'], - 'pathToAttachment' => $pathToAttachmentToCopy, - 'chronoAttachment' => $chronoPubli, - ]; - - $fileInfos = [ - 'tmpDir' => $_SESSION['config']['tmppath'], - 'size' => $_SESSION['upfile'][$numAttach]['size'], - 'format' => $path_parts['extension'], - 'tmpFileName' => str_replace($_SESSION['config']['tmppath'], '', $filePathOnTmp) - ]; - - $storeResult = $docserverControler->storeResourceOnDocserver($_SESSION['collection_id_choice'], $fileInfos); - foreach ($_SESSION['data'] as $dataKey => $dataValue) { - if (in_array($dataValue['column'], ['docserver_id', 'dest_contact_id', 'dest_address_id', 'identifier'])) { - unset($_SESSION['data'][$dataKey]); - } - } - $_SESSION['data'][] = [ - 'column' => 'docserver_id', - 'value' => $storeResult['docserver_id'], - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'dest_contact_id', - 'value' => $contactForMailing['contact_id'], - 'type' => 'integer' - ]; - $_SESSION['data'][] = [ - 'column' => 'dest_address_id', - 'value' => $contactForMailing['address_id'], - 'type' => 'integer' - ]; - - $_SESSION['data'][] = [ - 'column' => 'identifier', - 'value' => $chronoPubli, - 'type' => 'string' - ]; - - $id = $resAttach->load_into_db( - 'res_attachments', - $storeResult['destination_dir'], - $storeResult['file_destination_name'], - $storeResult['path_template'], - $storeResult['docserver_id'], - $_SESSION['data'], - $_SESSION['config']['databasetype'] - ); - } - } - - } else { - //SAVE META DATAS IN DB - $id = $resAttach->load_into_db( - RES_ATTACHMENTS_TABLE, - $storeResult['destination_dir'], - $storeResult['file_destination_name'], - $storeResult['path_template'], - $storeResult['docserver_id'], - $_SESSION['data'], - $_SESSION['config']['databasetype'] - ); - } - - //copie de la version PDF de la pièce si mode de conversion sur le client - if ($_SESSION['upfile'][$numAttach]['fileNamePdfOnTmp'] != '' && empty($templateOffice)) { - //case onlyConvert - $query = "select template_id from templates where template_type = 'OFFICE' and template_target = 'attachments'"; - $stmt = $db->query($query); - $templateOffice = $stmt->fetchObject()->template_id; - } - if ($_SESSION['upfile'][$numAttach]['fileNamePdfOnTmp'] != '' && isset($templateOffice) && empty($_REQUEST['mailing'])) { - $_SESSION['new_id'] = $id; - - $resource = file_get_contents($_SESSION['config']['tmppath'].$_SESSION['upfile'][$numAttach]['fileNamePdfOnTmp']); - $pathInfo = pathinfo($_SESSION['config']['tmppath'].$_SESSION['upfile'][$numAttach]['fileNamePdfOnTmp']); - $storeResult = \Docserver\controllers\DocserverController::storeResourceOnDocServer([ - 'collId' => 'attachments_coll', - 'docserverTypeId' => 'CONVERT', - 'encodedResource' => base64_encode($resource), - 'format' => $pathInfo['extension'] - ]); - - $result = \Convert\models\AdrModel::createAttachAdr([ - 'resId' => $id, - 'isVersion' => false, - 'type' => 'PDF', - 'docserverId' => $storeResult['docserver_id'], - 'path' => $storeResult['destination_dir'], - 'filename' => $storeResult['file_destination_name'], - 'fingerprint' => $storeResult['fingerPrint'], - ]); - - unset($_SESSION['upfile'][$attachNum]['fileNamePdfOnTmp']); - } - - $customId = \SrcCore\models\CoreConfigModel::getCustomId(); - if (empty($customId)) { - $customId = 'null'; - } - $user = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $_SESSION['user']['UserId']]); - exec("php src/app/convert/scripts/FullTextScript.php --customId {$customId} --resId {$id} --collId 'attachments_coll' --userId {$user['id']} > /dev/null &"); - - if ($id == false) { - $error = $resAttach->get_error(); - } else { - // Delete temporary backup - $stmt = $db->query( - "SELECT docserver_id, path, filename FROM res_attachments WHERE res_id = ? AND status = 'TMP' AND typist = ?", - [$_SESSION['attachmentInfo'][$numAttach]['inProgressResId'], $_SESSION['user']['UserId']] - ); - if ($stmt->rowCount() !== 0) { - $line = $stmt->fetchObject(); - $stmt = $db->query("SELECT path_template FROM docservers WHERE docserver_id = ?", array($line->docserver_id)); - $lineDoc = $stmt->fetchObject(); - $file = $lineDoc->path_template . $line->path . $line->filename; - $file = str_replace("#", DIRECTORY_SEPARATOR, $file); - unlink($file); - - $db->query( - "DELETE FROM res_attachments WHERE res_id = ? and status = 'TMP' and typist = ?", - array($_SESSION['attachmentInfo'][$numAttach]['inProgressResId'], $_SESSION['user']['UserId']) - ); - } - - if ($_SESSION['history']['attachadd'] == 'true') { - $hist = new history(); - $view = $sec->retrieve_view_from_coll_id( - $_SESSION['collection_id_choice'] - ); - $hist->add( - $view, - $_SESSION['doc_id'], - 'ADD', - 'attachadd', - ucfirst(_DOC_NUM).$id.' ' - ._NEW_ATTACH_ADDED.' '._TO_MASTER_DOCUMENT - .$_SESSION['doc_id'], - $_SESSION['config']['databasetype'], - 'apps' - ); - $content = _NEW_ATTACH_ADDED; - $hist->add( - RES_ATTACHMENTS_TABLE, - $id, - 'ADD', - 'attachadd', - $content.' ('.$title - .') ', - $_SESSION['config']['databasetype'], - 'attachments' - ); - } - } - } - } - } - //IF SUCCESS EXTRA JS FOR UPDATE TABS - if (empty($error) || $content == _NEW_ATTACH_ADDED) { - $new_nb_attach = 0; - $stmt = $db->query('select res_id from ' - .$_SESSION['tablename']['attach_res_attachments'] - ." where status <> 'DEL' and attachment_type <> 'converted_pdf' and attachment_type <> 'print_folder' and res_id_master = ?", array($_SESSION['doc_id'])); - if ($stmt->rowCount() > 0) { - $new_nb_attach = $stmt->rowCount(); - } - if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'create') { - //Redirection vers bannette MyBasket s'il s'agit d'un courrier spontané et que l'utilisateur connecté est le destinataire du courrier - if (isset($_SESSION['upfile'][$attachNum]['outgoingMail']) && $_SESSION['upfile'][$attachNum]['outgoingMail'] && $_SESSION['user']['UserId'] == $_SESSION['details']['diff_list']['dest']['users'][0]['user_id']) { - $js .= "window.parent.top.location.href = 'index.php?page=view_baskets&module=basket&baskets=MyBasket&resid=".$_SESSION['doc_id']."&directLinkToAction';"; - } else { - if ($attachment_types == 'response_project' || $attachment_types == 'outgoing_mail' || $attachment_types == 'signed_response' || $attachment_types == 'aihp') { - $js .= '$j(\'#responses_tab\').click();loadSpecificTab(\'uniqueDetailsIframe\',\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&view_only=true&load&fromDetail=response&attach_type=response_project,outgoing_mail_signed,signed_response,outgoing_mail,aihp\');'; - } else { - $js .= '$j(\'#attachments_tab\').click();loadSpecificTab(\'uniqueDetailsIframe\',\''.$_SESSION['config']['businessappurl'].'index.php?display=true&page=show_attachments_details_tab&module=attachments&resId='.$_SESSION['doc_id'].'&collId=letterbox_coll&fromDetail=attachments&attach_type_exclude=response_project,signed_response,outgoing_mail_signed,converted_pdf,outgoing_mail,print_folder,aihp\');'; - } - } - } else { - $js .= 'var eleframe1 = window.parent.top.document.getElementById(\'list_attach\');'; - $js .= 'eleframe1.src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&attach_type_exclude=converted_pdf,print_folder&load\';'; - } - } else { - $status = 1; - } - } - } else { - $status = 1; - } - } - } - - if (!isset($_SESSION['new_id'])) { - $_SESSION['new_id'] = 0; - } - - echo '{"status" : "'.$status.'", "content" : "'.addslashes(_parse($content)).'", "error" : "'.addslashes($error).'", "majFrameId" : "'.functions::xssafe($_SESSION['new_id']).'", "exec_js" : "'.addslashes($js).'", "type" : "'.$attachment_types.'"}'; - //RAZ SESSIONS FILE - if (empty($error)) { - unset($_SESSION['new_id']); - unset($_SESSION['attachmentInfo']); - unset($_SESSION['transmissionContacts']); - unset($_SESSION['resIdVersionAttachment']); - unset($_SESSION['targetAttachment']); - } - exit(); - -//BEGIN EDIT ATTACHMENT VALIDATE BUTTTON -} elseif (isset($_POST['edit']) && $_POST['edit']) { - $resAttach = new resource(); - $status = 0; - $error = ''; - - //EMPTY TITLE ? - $title = ''; - if (!isset($_REQUEST['title'][0]) || empty($_REQUEST['title'][0])) { - $error .= _OBJECT.' '._MANDATORY.'. '; - } else { - $title = $_REQUEST['title'][0]; - $title = str_replace(''', "'", $title); - } - - //CURRENT ATTACHMENT IS A VERSION OF OLD ATTACHMENT ? - if ((int) $_REQUEST['relation'] > 1) { - $column_res = 'res_id_version'; - } else { - $column_res = 'res_id'; - } - - //IS NEW VERSION ? - if ($_REQUEST['new_version'] == 'yes') { - $is_new_version = true; - - //RETRIEVE PREVIOUS ATTACHMENT - $stmt = $db->query('SELECT res_id, res_id_version, attachment_type, identifier, relation, attachment_id_master, status - FROM res_view_attachments - WHERE '.$column_res.' = ? and res_id_master = ? - ORDER BY relation desc', array($_REQUEST['res_id'], $_SESSION['doc_id'])); - $previous_attachment = $stmt->fetchObject(); - - $path_parts = pathinfo($_SESSION['upfile'][0]['fileNameOnTmp']); - $fileInfos = array( - 'tmpDir' => $_SESSION['config']['tmppath'], - 'size' => $_SESSION['upfile'][0]['size'], - 'format' => $path_parts['extension'], - 'tmpFileName' => $_SESSION['upfile'][0]['fileNameOnTmp'], - ); - $storeResult = array(); - - $storeResult = $docserverControler->storeResourceOnDocserver( - $_SESSION['collection_id_choice'], - $fileInfos - ); - - if (isset($storeResult['error']) && $storeResult['error'] != '') { - $error = $storeResult['error']; - } - //SET META DATAS OF NEW ATTACHMENT - if (empty($error)) { - $_SESSION['data'] = array(); - array_push( - $_SESSION['data'], - array( - 'column' => 'typist', - 'value' => $_SESSION['user']['UserId'], - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'format', - 'value' => $fileInfos['format'], - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'docserver_id', - 'value' => $storeResult['docserver_id'], - 'type' => 'string', - ) - ); - if (!empty($_REQUEST['effectiveDateStatus'][0])) { - $_SESSION['data'][] = [ - 'column' => 'status', - 'value' => $_REQUEST['effectiveDateStatus'][0], - 'type' => 'string', - ]; - } else { - array_push( - $_SESSION['data'], - array( - 'column' => 'status', - 'value' => $previous_attachment->status, - 'type' => 'string', - ) - ); - } - array_push( - $_SESSION['data'], - array( - 'column' => 'offset_doc', - 'value' => ' ', - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'title', - 'value' => $title, - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'attachment_type', - 'value' => $_REQUEST['attachment_types'][0], - 'type' => 'string', - ) - ); - $attachmentTypesList = \Attachment\models\AttachmentModel::getAttachmentsTypesByXML(); - foreach ($attachmentTypesList as $keyAttachment => $valueAttachment) { - if ($keyAttachment == $previous_attachment->attachment_type && $valueAttachment['sign']) { - array_push( - $_SESSION['data'], - array( - 'column' => 'in_signature_book', - 'value' => 1, - 'type' => 'bool', - ) - ); - } - } - array_push( - $_SESSION['data'], - array( - 'column' => 'coll_id', - 'value' => $_SESSION['collection_id_choice'], - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'res_id_master', - 'value' => $_SESSION['doc_id'], - 'type' => 'integer', - ) - ); - if ((int) $previous_attachment->attachment_id_master == 0) { - array_push( - $_SESSION['data'], - array( - 'column' => 'attachment_id_master', - 'value' => $_REQUEST['res_id'], - 'type' => 'integer', - ) - ); - } else { - array_push( - $_SESSION['data'], - array( - 'column' => 'attachment_id_master', - 'value' => (int) $previous_attachment->attachment_id_master, - 'type' => 'integer', - ) - ); - } - if (isset($_REQUEST['back_date'][0]) && $_REQUEST['back_date'][0] != '') { - array_push( - $_SESSION['data'], - array( - 'column' => 'validation_date', - 'value' => $func->format_date_db($_REQUEST['back_date'][0]), - 'type' => 'date', - ) - ); - } - - if (!empty($_REQUEST['effectiveDate'][0])) { - $_SESSION['data'][] = [ - 'column' => 'effective_date', - 'value' => $func->format_date_db($_REQUEST['effectiveDate'][0]), - 'type' => 'date', - ]; - } - - if (isset($_REQUEST['contactidAttach'][0]) && $_REQUEST['contactidAttach'][0] != '' && is_numeric($_REQUEST['contactidAttach'][0])) { - $_SESSION['data'][] = [ - 'column' => 'dest_contact_id', - 'value' => $_REQUEST['contactidAttach'][0], - 'type' => 'integer', - ]; - } elseif (isset($_REQUEST['contactidAttach'][0]) && $_REQUEST['contactidAttach'][0] != '' && !is_numeric($_REQUEST['contactidAttach'][0])) { - $_SESSION['data'][] = [ - 'column' => 'dest_user', - 'value' => $_REQUEST['contactidAttach'][0], - 'type' => 'string', - ]; - } - - if (isset($_REQUEST['addressidAttach'][0]) && $_REQUEST['addressidAttach'][0] != '') { - array_push( - $_SESSION['data'], - array( - 'column' => 'dest_address_id', - 'value' => $_REQUEST['addressidAttach'][0], - 'type' => 'integer', - ) - ); - } - array_push( - $_SESSION['data'], - array( - 'column' => 'identifier', - 'value' => $_REQUEST['chrono'][0], - 'type' => 'string', - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => 'type_id', - 'value' => 0, - 'type' => 'int', - ) - ); - - $relation = (int) $previous_attachment->relation; - ++$relation; - - array_push( - $_SESSION['data'], - array( - 'column' => 'relation', - 'value' => $relation, - 'type' => 'int', - ) - ); - - //SAVE META DATAS IN DB - $id = $resAttach->load_into_db( - 'res_version_attachments', - $storeResult['destination_dir'], - $storeResult['file_destination_name'], - $storeResult['path_template'], - $storeResult['docserver_id'], - $_SESSION['data'], - $_SESSION['config']['databasetype'] - ); - - //DEPRECATED OLD ATTACHMENT FILE - if ((int) $_REQUEST['relation'] == 1) { - $stmt = $db->query("UPDATE res_attachments SET status = 'OBS' WHERE res_id = ?", array($previous_attachment->res_id)); - } else { - $stmt = $db->query("UPDATE res_version_attachments SET status = 'OBS' WHERE res_id = ?", array($previous_attachment->res_id_version)); - } - } - } else { - $is_new_version = false; - $set_update = ''; - $arrayPDO = array(); - - //CREATE SQL UPDATE - $set_update = ' title = :title'; - $arrayPDO = array_merge($arrayPDO, array(':title' => $title)); - if (!empty($_REQUEST['attachment_types'][0])) { - $set_update .= ", attachment_type = :attachmentType"; - $arrayPDO = array_merge($arrayPDO, array(':attachmentType' => $_REQUEST['attachment_types'][0])); - } - if (!empty($_REQUEST['chrono'][0])) { - $set_update .= ", identifier = :identifier"; - $arrayPDO = array_merge($arrayPDO, array(':identifier' => $_REQUEST['chrono'][0])); - } - if (isset($_REQUEST['back_date'][0]) && $_REQUEST['back_date'][0] != '') { - $set_update .= ", validation_date = '".$req->format_date_db($_REQUEST['back_date'][0])."'"; - } else { - $set_update .= ', validation_date = null'; - } - if (!empty($_REQUEST['effectiveDate'][0])) { - $set_update .= ", effective_date = '".$req->format_date_db($_REQUEST['effectiveDate'][0])."'"; - } - if (isset($_REQUEST['contactidAttach'][0]) && $_REQUEST['contactidAttach'][0] != '' && is_numeric($_REQUEST['contactidAttach'][0])) { - $set_update .= ', dest_user = null, dest_contact_id = '.$_REQUEST['contactidAttach'][0].', dest_address_id = '.$_REQUEST['addressidAttach'][0]; - } elseif (isset($_REQUEST['contactidAttach'][0]) && $_REQUEST['contactidAttach'][0] != '' && !is_numeric($_REQUEST['contactidAttach'][0])) { - $set_update .= ", dest_user = '".$_REQUEST['contactidAttach'][0]."', dest_contact_id = null, dest_address_id = null"; - } else { - $set_update .= ', dest_user = null, dest_contact_id = null, dest_address_id = null'; - } - if ((int) $_REQUEST['relation'] > 1) { - $column_res = 'res_id_version'; - } else { - $column_res = 'res_id'; - } - - //IF FILE IS EDITED - if ($_SESSION['upfile'][0]['upAttachment'] != false) { - //RETRIEVE CURRENT ATTACHMENT FILE - $stmt = $db->query('SELECT fingerprint, docserver_id, status FROM res_view_attachments WHERE '.$column_res." = ? and res_id_master = ? and status <> 'OBS'", array($_REQUEST['res_id'], $_SESSION['doc_id'])); - $res = $stmt->fetchObject(); - - require_once 'core/class/docserver_types_controler.php'; - require_once 'core/docservers_tools.php'; - $docserverTypeControler = new docserver_types_controler(); - $docserver = $docserverControler->get($res->docserver_id); - $docserverTypeObject = $docserverTypeControler->get($docserver->docserver_type_id); - - //HASH OLD AND NEW ATTACHMENT FILE - $NewHash = Ds_doFingerprint($_SESSION['upfile'][0]['tmp_name'], $docserverTypeObject->fingerprint_mode); - $OriginalHash = $res->fingerprint; - - //SAVE NEW ATTACHMENT FILE (IF <> HASH) - if ($OriginalHash != $NewHash) { - $path_parts = pathinfo($_SESSION['upfile'][0]['fileNameOnTmp']); - $fileInfos = array( - 'tmpDir' => $_SESSION['config']['tmppath'], - 'size' => $_SESSION['upfile'][0]['size'], - 'format' => $path_parts['extension'], - 'tmpFileName' => $_SESSION['upfile'][0]['fileNameOnTmp'], - ); - $storeResult = array(); - $storeResult = $docserverControler->storeResourceOnDocserver( - $_SESSION['collection_id_choice'], - $fileInfos - ); - if (isset($storeResult['error']) && $storeResult['error'] != '') { - $error = $storeResult['error']; - } else { - $filetmp = $storeResult['path_template']; - $tmp = $storeResult['destination_dir']; - $tmp = str_replace('#', DIRECTORY_SEPARATOR, $tmp); - $filetmp .= $tmp; - $filetmp .= $storeResult['file_destination_name']; - $docserverTypeControler = new docserver_types_controler(); - $docserver = $docserverControler->get($storeResult['docserver_id']); - $docserverTypeObject = $docserverTypeControler->get($docserver->docserver_type_id); - $fingerprint = Ds_doFingerprint($filetmp, $docserverTypeObject->fingerprint_mode); - $filesize = filesize($filetmp); - - //CREATE SQL UPDATE (FOR METAS DATA FILE) - $set_update .= ', fingerprint = :fingerprint'; - $set_update .= ', filesize = :filesize'; - $set_update .= ', path = :path'; - $set_update .= ', filename = :filename'; - $set_update .= ', docserver_id = :docserver_id'; - $arrayPDO = array_merge( - $arrayPDO, - array(':fingerprint' => $fingerprint, - ':filesize' => $filesize, - ':path' => $storeResult['destination_dir'], - ':filename' => $storeResult['file_destination_name'], - ':docserver_id' => $storeResult['docserver_id'], ) - ); - } - } - } - - $set_update .= ', doc_date = '.$req->current_datetime().', updated_by = :updated_by'; - $arrayPDO = array_merge($arrayPDO, array(':updated_by' => $_SESSION['user']['UserId'])); - if (!empty($_REQUEST['effectiveDateStatus'])) { - $set_update .= ', status = :effectiveStatus'; - $arrayPDO = array_merge($arrayPDO, array(':effectiveStatus' => $_REQUEST['effectiveDateStatus'][0])); - } elseif ($res->status == 'TMP') { - $set_update .= ", status = 'A_TRA'"; - } - $arrayPDO = array_merge($arrayPDO, array(':res_id' => $_REQUEST['res_id'])); - - //UPDATE QUERY - if ((int) $_REQUEST['relation'] == 1) { - $stmt = $db->query('UPDATE res_attachments SET '.$set_update.' WHERE res_id = :res_id', $arrayPDO); - if ($_SESSION['upfile'][0]['fileNamePdfOnTmp'] != '' && $_SESSION['upfile'][0]['upAttachment'] != false) { - \Convert\models\AdrModel::deleteAttachAdr([ - 'resId' => $_REQUEST['res_id'], - ]); - } - } else { - $stmt = $db->query('UPDATE res_version_attachments SET '.$set_update.' WHERE res_id = :res_id', $arrayPDO); - if ($_SESSION['upfile'][0]['fileNamePdfOnTmp'] != '' && $_SESSION['upfile'][0]['upAttachment'] != false) { - \Convert\models\AdrModel::deleteAttachAdr([ - 'resId' => $_REQUEST['res_id'], - ]); - } - } - } - if (!empty($_REQUEST['mailing'])) { - $select = [ - 'typist', 'format', 'status', 'title', 'attachment_type', 'in_signature_book', 'res_id_master', - 'validation_date', 'effective_date', 'identifier', 'docserver_id', 'path', 'filename' - ]; - if ($is_new_version || $_REQUEST['relation'] != 1) { - if ($_REQUEST['relation'] != 1) { - $id = $_REQUEST['res_id']; - } - $attachmentToProcess = \Attachment\models\AttachmentModel::getById([ - 'select' => $select, - 'id' => $id - ]); - \Attachment\models\AttachmentModel::update([ - 'set' => ['status' => 'DEL'], - 'where' => ['res_id = ?'], - 'data' => [$id] - ]); - } else { - $attachmentToProcess = \Attachment\models\AttachmentModel::getById([ - 'select' => $select, - 'id' => $_REQUEST['res_id'] - ]); - \Attachment\models\AttachmentModel::update([ - 'set' => ['status' => 'DEL'], - 'where' => ['res_id = ?'], - 'data' => [$_REQUEST['res_id']] - ]); - } - - $_SESSION['data'] = []; - $_SESSION['data'][] = [ - 'column' => 'typist', - 'value' => $attachmentToProcess['typist'], - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'format', - 'value' => $attachmentToProcess['format'], - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'status', - 'value' => 'A_TRA', - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'title', - 'value' => $attachmentToProcess['title'], - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'attachment_type', - 'value' => $attachmentToProcess['attachment_type'], - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'coll_id', - 'value' => 'letterbox_coll', - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'res_id_master', - 'value' => $attachmentToProcess['res_id_master'], - 'type' => 'integer' - ]; - $_SESSION['data'][] = [ - 'column' => 'type_id', - 'value' => 0, - 'type' => 'integer' - ]; - $_SESSION['data'][] = [ - 'column' => 'relation', - 'value' => 1, - 'type' => 'integer' - ]; - if (!empty($attachmentToProcess['validation_date'])) { - $_SESSION['data'][] = [ - 'column' => 'validation_date', - 'value' => $attachmentToProcess['validation_date'], - 'type' => 'date' - ]; - } - if (!empty($attachmentToProcess['effective_date'])) { - $_SESSION['data'][] = [ - 'column' => 'effective_date', - 'value' => $attachmentToProcess['effective_date'], - 'type' => 'date' - ]; - } - if (!empty($attachmentToProcess['in_signature_book'])) { - $_SESSION['data'][] = [ - 'column' => 'in_signature_book', - 'value' => 1, - 'type' => 'bool' - ]; - } - - $contactsForMailing = \SrcCore\models\DatabaseModel::select([ - 'select' => ['*'], - 'table' => ['contacts_res'], - 'where' => ['res_id = ?', 'address_id != ?'], - 'data' => [$_SESSION['doc_id'], 0] - ]); - $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $attachmentToProcess['docserver_id'], 'select' => ['path_template']]); - $pathToAttachmentToCopy = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $attachmentToProcess['path']) . $attachmentToProcess['filename']; - - foreach ($contactsForMailing as $key => $contactForMailing) { - $chronoPubli = $attachmentToProcess['identifier'] . '-' . chr(ord('A') + $key); - $params = [ - 'userId' => $_SESSION['user']['UserId'], - 'res_id' => $_SESSION['doc_id'], - 'coll_id' => 'letterbox_coll', - 'res_view' => 'res_view_attachments', - 'res_table' => 'res_attachments', - 'res_contact_id' => $contactForMailing['contact_id'], - 'res_address_id' => $contactForMailing['address_id'], - 'pathToAttachment' => $pathToAttachmentToCopy, - 'chronoAttachment' => $chronoPubli, - ]; - - $fileInfos = [ - 'tmpDir' => $_SESSION['config']['tmppath'], - 'size' => filesize($filePathOnTmp), - 'format' => $attachmentToProcess['format'], - 'tmpFileName' => str_replace($_SESSION['config']['tmppath'], '', $filePathOnTmp) - ]; - - $storeResult = $docserverControler->storeResourceOnDocserver($_SESSION['collection_id_choice'], $fileInfos); - foreach ($_SESSION['data'] as $dataKey => $dataValue) { - if (in_array($dataValue['column'], ['docserver_id', 'dest_contact_id', 'dest_address_id', 'identifier'])) { - unset($_SESSION['data'][$dataKey]); - } - } - $_SESSION['data'][] = [ - 'column' => 'docserver_id', - 'value' => $storeResult['docserver_id'], - 'type' => 'string' - ]; - $_SESSION['data'][] = [ - 'column' => 'dest_contact_id', - 'value' => $contactForMailing['contact_id'], - 'type' => 'integer' - ]; - $_SESSION['data'][] = [ - 'column' => 'dest_address_id', - 'value' => $contactForMailing['address_id'], - 'type' => 'integer' - ]; - $_SESSION['data'][] = [ - 'column' => 'identifier', - 'value' => $chronoPubli, - 'type' => 'string' - ]; - - $id = $resAttach->load_into_db( - 'res_attachments', - $storeResult['destination_dir'], - $storeResult['file_destination_name'], - $storeResult['path_template'], - $storeResult['docserver_id'], - $_SESSION['data'], - $_SESSION['config']['databasetype'] - ); - } - } - - if ((int) $_REQUEST['relation'] == 1 && $is_new_version == false) { - $targetCollId = 'attachments_coll'; - $targetAdrVersion = false; - } else { - $targetCollId = 'attachments_version_coll'; - $targetAdrVersion = true; - } - - //copie de la version PDF de la pièce si mode de conversion sur le client - if ($_SESSION['upfile'][0]['fileNamePdfOnTmp'] != '' && empty($error) && $_SESSION['upfile'][0]['upAttachment'] != false && empty($_REQUEST['mailing'])) { - if ($id != null) { - $_SESSION['new_id'] = $id; - } else { - $_SESSION['new_id'] = $_REQUEST['res_id']; - } - - $resource = file_get_contents($_SESSION['config']['tmppath'] . $_SESSION['upfile'][0]['fileNamePdfOnTmp']); - $pathInfo = pathinfo($_SESSION['config']['tmppath'] . $_SESSION['upfile'][0]['fileNamePdfOnTmp']); - $storeResult = \Docserver\controllers\DocserverController::storeResourceOnDocServer([ - 'collId' => $targetCollId, - 'docserverTypeId' => 'CONVERT', - 'encodedResource' => base64_encode($resource), - 'format' => $pathInfo['extension'] - ]); - - $result = \Convert\models\AdrModel::createAttachAdr([ - 'resId' => $_SESSION['new_id'], - 'isVersion' => $targetAdrVersion, - 'type' => 'PDF', - 'docserverId' => $storeResult['docserver_id'], - 'path' => $storeResult['destination_dir'], - 'filename' => $storeResult['file_destination_name'], - 'fingerprint' => $storeResult['fingerPrint'], - ]); - } - - $customId = \SrcCore\models\CoreConfigModel::getCustomId(); - if (empty($customId)) { - $customId = 'null'; - } - $user = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $_SESSION['user']['UserId']]); - exec("php src/app/convert/scripts/FullTextScript.php --customId {$customId} --resId {$id} --collId {$targetCollId} --userId {$user['id']} > /dev/null &"); - - if (empty($error)) { - //DELETE TEMPORARY BACKUP - $stmt = $db->query("SELECT attachment_id_master - FROM res_version_attachments - WHERE res_id = ? and status = 'TMP' and res_id_master = ?", array($_SESSION['attachmentInfo']['inProgressResId'], $_SESSION['doc_id'])); - $previous_attachment = $stmt->fetchObject(); - - $db->query("DELETE FROM res_version_attachments WHERE attachment_id_master = ? and status = 'TMP'", array($previous_attachment->attachment_id_master)); - - //ADD ACTION IN HISTORY - if ($_SESSION['history']['attachup'] == 'true') { - $hist = new history(); - $view = $sec->retrieve_view_from_coll_id( - $_SESSION['collection_id_choice'] - ); - $hist->add( - $view, - $_SESSION['doc_id'], - 'UP', - 'attachup', - ucfirst(_DOC_NUM).$id.' ' - ._ATTACH_UPDATED, - $_SESSION['config']['databasetype'], - 'apps' - ); - $content = _ATTACH_UPDATED; - $hist->add( - RES_ATTACHMENTS_TABLE, - $id, - 'UP', - 'attachup', - $_SESSION['info'].' ('.$title - .') ', - $_SESSION['config']['databasetype'], - 'attachments' - ); - } - - //EXTRAS JS FOR TABS - if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') { - $js .= 'eleframe1 = parent.document.getElementsByName(\'uniqueDetailsIframe\');'; - $js .= 'eleframe1[0].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=show_attachments_details_tab&load'; - $js .= '&attach_type_exclude=response_project,signed_response,outgoing_mail_signed,converted_pdf,outgoing_mail,print_folder,aihp&fromDetail=attachments&collId=letterbox_coll&resId='.$_SESSION['doc_id']; - } elseif (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response') { - $js .= 'eleframe1 = parent.document.getElementsByName(\'uniqueDetailsIframe\');'; - $js .= 'eleframe1[0].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=show_attachments_details_tab&load'; - $js .= '&attach_type=response_project,outgoing_mail_signed,signed_response,outgoing_mail,aihp&fromDetail=response&collId=letterbox_coll&resId='.$_SESSION['doc_id']; - } else { - $js .= 'var eleframe1 = parent.document.getElementsByName(\'list_attach\');'; - $js .= 'eleframe1[0].src = \''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&attach_type_exclude=converted_pdf,print_folder&load'; - } - $js .= '\';'; - - //RAZ SESSIONS - if (!isset($_SESSION['new_id'])) { - $_SESSION['new_id'] = 0; - } - unset($_SESSION['upfile'][0]['fileNamePdfOnTmp']); - unset($_SESSION['new_id']); - unset($_SESSION['attachmentInfo']); - unset($_SESSION['resIdVersionAttachment']); - unset($_SESSION['targetAttachment']); - } - - echo '{"status" : "'.$status.'", "content" : "'.addslashes(_parse($content)).'", "title" : "'.addslashes($title).'", "isVersion" : "'.$isVersion.'", "error" : "'.addslashes($error).'", "majFrameId" : "'.$_SESSION['new_id'].'", "exec_js" : "'.addslashes($js).'", "cur_id" : "'.$_REQUEST['res_id'].'"}'; - - exit(); -} - -//INITIALIZE EDIT MODE -if (isset($_REQUEST['id'])) { - $mode = 'edit'; - $title = _MODIFY_ANSWER; - $_SESSION['targetAttachment'] = 'edit'; - $resId = $_REQUEST['id']; - unset($_SESSION['upfile']); - - //GET DATAS attachment - $infoAttach = (object) $ac->getAttachmentInfos($resId); - if (!file_exists($infoAttach->pathfile)) { - $status = 1; - $error = _FILE_NOT_EXISTS_ON_THE_SERVER; - - echo '{"status" : "'.$status.'", "content" : "'.addslashes(_parse($content)).'", "title" : "'.addslashes($title).'", "isVersion" : "'.$isVersion.'", "error" : "'.addslashes($error).'", "majFrameId" : "'.$_SESSION['new_id'].'", "exec_js" : "'.addslashes($js).'", "cur_id" : "'.$_REQUEST['res_id'].'"}'; - exit; - } else { - //RETRIEVE ATTACHMENT FILE - $_SESSION['upfile'][0]['upAttachment'] = false; - $_SESSION['upfile'][0]['size'] = filesize($infoAttach->pathfile); - $_SESSION['upfile'][0]['format'] = $infoAttach->format; - $_SESSION['upfile'][0]['fileNamePdfOnTmp'] = $infoAttach->pathfile_pdf; - - $viewResourceArr = $docserverControler->viewResource( - $resId, - $infoAttach->target_table_origin, - 'adr_attachments', - false - ); - $_SESSION['upfile'][0]['fileNameOnTmp'] = str_replace($viewResourceArr['tmp_path'].DIRECTORY_SEPARATOR, '', $viewResourceArr['file_path']); - } -} else { - //INITIALIZE ADD MODE - $mode = 'add'; - $title = _ATTACH_ANSWER; - - $_SESSION['targetAttachment'] = 'add'; - unset($_SESSION['upfile']); - unset($_SESSION['transmissionContacts']); - - //GET DATAS attachment - $infoAttach = (object) $ac->initAttachmentInfos($_SESSION['doc_id']); - - //On recherche le type de document attaché à ce courrier -} - $stmt = $db->query('SELECT type_id, creation_date, category_id FROM res_letterbox WHERE res_id = ?', array($_SESSION['doc_id'])); - $mail_doctype = $stmt->fetchObject(); - $type_id = $mail_doctype->type_id; - $category_id = $mail_doctype->category_id; - $dataForDate = $mail_doctype->creation_date; - //On recherche le sve_type - $sve = \Doctype\models\DoctypeModel::getById(['id' => $type_id]); - $sve_type = $sve['process_mode']; - //On met tous les attachments ayant le type_sve attaché au courrier dans un tableau - $attachments_types_for_process = array(); - foreach ($_SESSION['attachment_types_with_process'] as $key => $value) { - if ($sve_type == $value or $value == '') { - $attachments_types_for_process[$key] = $_SESSION['attachment_types'][$key]; - } - } - -//BEGIN FORM ATTACHMENT -//INITIALIZE -unset($_SESSION['adresses']); -unset($_SESSION['cm_applet'][$_SESSION['user']['UserId']]); -$objectTable = 'res_letterbox'; - -//BEDING HEADER -$content .= '<h2> '.$title; - -//multicontact - -if (!empty($infoAttach->multi_contact)) { - $content .= ' pour le contact : <select style="background-color: #FFF;border: 1px solid #999;color: #666;text-align: left;" id="selectContactIdRes" onchange="loadSelectedContact()">'; - - $content .= '<option value="mailing">Publipostage</option>'; - foreach ($infoAttach->multi_contact as $key => $value) { - $content .= '<option value="'.$value['contact_id'].'#'.$value['address_id'].'#'.$value['format_contact'].'">'.$value['format_contact'].'</option>'; - } - - $content .= '</select>'; - $content .= '<script>$j("#selectContactIdRes", window.top.document).change();</script>'; -} -$content .= '</h2>'; -//END HEADER - -//BEGIN FORM -$content .= '<form enctype="multipart/form-data" method="post" name="formAttachment" id="formAttachment" action="#" class="forms" style="width:35%;float:left;margin-left:-5px;background-color:#F2F2F2">'; -$content .= '<div class="transmissionDiv" id="addAttach1">'; - - if ($infoAttach->status != 'SEND_MASS') { - $hideMailing = 'display:none;'; - } - - $content .= '<div id="mailingInfo" style="'.$hideMailing.'background: #F8BB30;border-radius: 5px;padding: 10px;">'._MAILING_INFO_1.'<ul style="padding-left: 30px;"><li style="list-style: initial;padding: 5px;">'._MAILING_INFO_2.'</li><li style="list-style: initial;padding: 5px;">'._MAILING_INFO_3.'</li><li style="list-style: initial;padding: 5px;">'._MAILING_INFO_4.'</li></div>'; - $content .= '<hr style="width:85%;margin-left:0px">'; - $content .= '<input type="hidden" id="category_id" value="outgoing"/>'; - - if ($mode == 'edit') { - $content .= '<input type="hidden" name="res_id" id="res_id" value="'.$_REQUEST['id'].'"/>'; - $content .= '<input type="hidden" name="relation" id="relation" value="'.$_REQUEST['relation'].'"/>'; - $_SESSION['relationAttachment'] = $_REQUEST['relation']; - $_SESSION['resIdVersionAttachment'] = $_REQUEST['id']; - } - $content .= '<input type="hidden" name="fromDetail" id="fromDetail" value="'.$_REQUEST['fromDetail'].'"/>'; - - //ATTACHMENT TYPE - $content .= '<p>'; - $content .= '<label>'._ATTACHMENT_TYPES.'</label>'; - if ($mode == 'add') { - $content .= '<select name="attachment_types[]" id="attachment_types" onchange="affiche_chrono(this);select_template(\''.$_SESSION['config']['businessappurl'] - .'index.php?display=true&module=templates&page=' - .'select_templates\', this);"/>'; - $content .= '<option value="">'._CHOOSE_ATTACHMENT_TYPE.'</option>'; - foreach (array_keys($attachments_types_for_process) as $attachmentType) { - if (empty($_SESSION['attachment_types_get_chrono'][$attachmentType][0])) { - $_SESSION['attachment_types_get_chrono'][$attachmentType] = ''; - } - if (empty($_SESSION['attachment_types_with_delay'][$attachmentType][0])) { - $_SESSION['attachment_types_with_delay'][$attachmentType] = ''; - } - if ($_SESSION['attachment_types_show'][$attachmentType] == 'true') { - $content .= '<option value="'.$attachmentType.'" width_delay="'.$_SESSION['attachment_types_with_delay'][$attachmentType].'" with_chrono = "'.$_SESSION['attachment_types_with_chrono'][$attachmentType].'" get_chrono = "'.$_SESSION['attachment_types_get_chrono'][$attachmentType].'"'; - - if (isset($_GET['cat']) && $_GET['cat'] == 'outgoing' && $attachmentType == 'outgoing_mail') { - $content .= ' selected = "selected"'; - $content .= '<script>$("attachment_types").onchange();</script>'; - } - $content .= '>'; - $content .= $_SESSION['attachment_types'][$attachmentType]; - $content .= '</option>'; - } - } - $content .= '</select> <span class="red_asterisk" id="attachment_types_mandatory"><i class="fa fa-star"></i></span>'; - } else { - $content .= '<select name="attachment_types[]" id="attachment_types" onchange="affiche_chrono(this);select_template(\''.$_SESSION['config']['businessappurl'] - .'index.php?display=true&module=templates&page=select_templates\', this, \'edit\');"/>'; - $content .= '<option value="">'._CHOOSE_ATTACHMENT_TYPE.'</option>'; - foreach (array_keys($attachments_types_for_process) as $attachmentType) { - if (empty($_SESSION['attachment_types_get_chrono'][$attachmentType][0])) { - $_SESSION['attachment_types_get_chrono'][$attachmentType] = ''; - } - if (empty($_SESSION['attachment_types_with_delay'][$attachmentType][0])) { - $_SESSION['attachment_types_with_delay'][$attachmentType] = ''; - } - if ($_SESSION['attachment_types_show'][$attachmentType] == 'true') { - $content .= '<option value="'.$attachmentType.'" width_delay="'.$_SESSION['attachment_types_with_delay'][$attachmentType].'" with_chrono = "'.$_SESSION['attachment_types_with_chrono'][$attachmentType].'" get_chrono = "'.$_SESSION['attachment_types_get_chrono'][$attachmentType].'"'; - - if ($_SESSION['attachment_types'][$attachmentType] == $_SESSION['attachment_types'][$infoAttach->attachment_type]) { - $content .= ' selected = "selected"'; - } - $content .= '>'; - $content .= $_SESSION['attachment_types'][$attachmentType]; - $content .= '</option>'; - } - } - $content .= '</select> <span class="red_asterisk" id="attachment_types_mandatory"><i class="fa fa-star"></i></span>'; - -// $content .= '<input type="text" name="attachment_types_show[]" id="attachment_types_show" value="'.$_SESSION['attachment_types'][$infoAttach->attachment_type].'" disabled class="readonly"/>'; - $content .= '<input type="hidden" name="attachment_types[]" id="attachment_types" value="'.$infoAttach->attachment_type.'" readonly class="readonly"/>'; - } - $content .= '</p>'; - - //PJ CHRONO - $content .= '<p>'; - $content .= '<label id="chrono_label" name="chrono_label[]" style="display:none">'._CHRONO_NUMBER.'</label>'; - $content .= '<input type="text" name="chrono_display[]" id="chrono_display" value="'.$infoAttach->identifier.'" style="display:none" disabled class="readonly"/>'; - if ($mode == 'add') { - $content .= '<select name="get_chrono_display[]" id="get_chrono_display" style="display:none" onchange="$(\'chrono\').value=this.options[this.selectedIndex].value"/>'; - } elseif (!empty($infoAttach->identifier)) { - $js .= '$j("#chrono_label,#chrono_display", window.top.document).show();'; - } - $content .= '<input type="hidden" name="chrono[]" id="chrono" value="'.$infoAttach->identifier.'"/>'; - $content .= '</p>'; - - $content .= '<p style="text-align:left;margin-left:74.5%;"></p>'; - //FILE - if ($mode == 'add') { - $content .= '<p>'; - $content .= '<label id="file_label">'._FILE.' <span id="templateOfficeTool"><i class="fa fa-paperclip fa-lg" title="'._LOADED_FILE.'" style="cursor:pointer;" id="attachment_type_icon" onclick="$j(\'#add\').css(\'display\', \'inline\');$(\'attachment_type_icon\').setStyle({color: \'#135F7F\'});$(\'attachment_type_icon2\').setStyle({color: \'#666\'});$(\'templateOffice\').setStyle({display: \'none\'});$(\'templateOffice\').disabled=true;$(\'templateOffice_edit\').setStyle({display: \'none\'});$(\'choose_file\').setStyle({display: \'inline-block\'});document.getElementById(\'choose_file\').contentDocument.getElementById(\'file\').click();displayAddMailing()"></i> <i class="fa fa-file-alt fa-lg" title="'._GENERATED_FILE.'" style="cursor:pointer;color:#135F7F;" id="attachment_type_icon2" onclick="$(\'attachment_type_icon2\').setStyle({color: \'#135F7F\'});$(\'attachment_type_icon\').setStyle({color: \'#666\'});$(\'templateOffice\').setStyle({display: \'inline-block\'});$(\'templateOffice\').disabled=false;$(\'choose_file\').setStyle({display: \'none\'});"></i></span></label>'; - $content .= '<select name="templateOffice[]" id="templateOffice" style="display:inline-block;" onchange="showEditButton(this);">'; - $content .= '<option value="">'._CHOOSE_MODEL.'</option>'; - - $content .= '</select>'; - $content .= ' <input type="button" value="'; - $content .= _EDIT_MODEL; - $content .= '" name="templateOffice_edit[]" id="templateOffice_edit" style="display:none;margin-top: 0" class="button" ' - .'onclick="$j(\'#addMailing\').hide();$j(\'#add\').css(\'display\',\'inline\');showAppletLauncher(this, \''.$_SESSION['doc_id'].'\',\''.$objectTable.'\',\'attachmentVersion\',\'attachment\');$(\'add\').value=\'Edition en cours ...\';editingDoc(this,\''.$_SESSION['user']['UserId'].'\');$(\'add\').disabled=\'disabled\';$(\'add\').style.opacity=\'0.5\';this.hide();$j(\'#\'+this.id).parent().find(\'[name=templateOffice\\\\[\\\\]]\').css(\'width\',\'206px\');"/>'; - $content .= '<iframe style="display:none; width:210px" name="choose_file" id="choose_file" frameborder="0" scrolling="no" height="25" src="'.$_SESSION['config']['businessappurl'] - .'index.php?display=true&module=attachments&page=choose_attachment"></iframe>'; - - $content .= ' <span class="red_asterisk" id="templateOffice_mandatory"><i class="fa fa-star"></i></span>'; - $content .= '</p>'; - } - - if (isset($statusEditAttachment) && $statusEditAttachment == 'TMP') { - $content .= '<p align="middle"><span style="color:green">'._RETRIEVE_BACK_UP.'</span></p>'; - } - - //PJ SUBJECT - $content .= '<p>'; - $content .= '<label>'._OBJECT.'</label>'; - $content .= "<input type='text' name='title[]' id='title' maxlength='250' value=\"".htmlentities(substr($infoAttach->title, 0, 250)).'"/> '; - $content .= ' <span class="red_asterisk" id="templateOffice_mandatory"><i class="fa fa-star"></i></span>'; - $content .= '</p>'; - - //BACK DATE - if ($mode == 'add' || ($mode == 'edit' && (($infoAttach->attachment_type == 'transmission' && $infoAttach->status != 'NO_RTURN') || $infoAttach->attachment_type != 'transmission'))) { - $content .= '<p>'; - $content .= '<label>'._BACK_DATE.'</label>'; - $content .= "<input type='text' name='back_date[]' id='back_date' onClick='showCalender(this);' onfocus='checkBackDate(this);' onchange='checkBackDate(this);' value='{$req->format_date_db($infoAttach->validation_date)}'/>"; - if ($mode == 'add') { - $content .= '<select name="effectiveDateStatus[]" id="effectiveDateStatus" style="display:none;margin-left: 20px;width: 105px" onchange="checkEffectiveDateStatus(this);"/>'; - $content .= '<option value="A_TRA">A traiter</option>'; - $content .= '</select>'; - } - $content .= '</p>'; - } - - //EFFECTIVE BACK DATE (for transmission) - if ($mode == 'edit' && $infoAttach->attachment_type == 'transmission') { - $content .= '<p>'; - $content .= '<label>'._EFFECTIVE_DATE.'</label>'; - $content .= "<input type='text' name='effectiveDate[]' id='effectiveDate' onblur='setRturnForEffectiveDate();' onClick='showCalender(this);' onfocus='checkBackDate(this);' onchange='checkBackDate(this);' style='width: 75px' value='{$req->format_date_db($infoAttach->effective_date)}'"; - if ($infoAttach->status == 'NO_RTURN') { - $content .= ' disabled="disabled" class="readonly"'; - } - $content .= '/>'; - $content .= '<select name="effectiveDateStatus[]" id="effectiveDateStatus" style="margin-left: 20px;width: 105px" />'; - - if ($infoAttach->status == 'EXP_RTURN' || $infoAttach->status == 'RTURN') { - $content .= '<option value="EXP_RTURN">Attente retour</option>'; - if ($infoAttach->status == 'RTURN') { - $content .= '<option selected="selected" value="RTURN">Retourné</option>'; - } else { - $content .= '<option value="RTURN">Retourné</option>'; - } - } else { - $content .= '<option selected="selected" value="NO_RTURN">Pas de retour</option>'; - } - - $content .= '</select>'; - $content .= '</p>'; - } - $content .= "<input type='hidden' name='dataCreationDate' id='dataCreationDate' value='{$dataForDate}' />"; - - //CONTACT - if ($infoAttach->status != 'SEND_MASS') { - $content .= '<div id="contactDiv" style="margin-bottom:10px;">'; - $content .= '<label>'._DEST_USER_PJ; - if ($core->test_admin('my_contacts', 'apps', false)) { - $content .= ' <a id="create_multi_contact" title="'._CREATE_CONTACT - .'" onclick="new Effect.toggle(\'create_contact_div_attach\', ' - .'\'blind\', {delay:0.2});return false;" ' - .'style="display:inline;" ><i class="fa fa-pencil-alt fa-lg" title="'._CREATE_CONTACT.'"></i></a>'; - } - $content .= '</label>'; - $content .= '<span style="position:relative;"><input type="text" name="contact_attach[]" onblur="display_contact_card(\'visible\', \'contact_card_attach\');" onkeyup="erase_contact_external_id(\'contact_attach\', \'contactidAttach\');erase_contact_external_id(\'contact_attach\', \'addressidAttach\');" id="contact_attach" onchange="saveContactToSession(this);" value="'; - $content .= $infoAttach->contact_show; - $content .= '"/><div id="show_contacts_attach" class="autocomplete autocompleteIndex" style="width: 100%;left: 0px;"></div><div class="autocomplete autocompleteIndex" id="searching_autocomplete" style="display: none;text-align:left;padding:5px;width: 100%;left: 0px;"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> chargement ...</div></span>'; - $content .= '<a id="contact_card_attach" name="contact_card_attach" title="'._CONTACT_CARD.'" onclick="showContactInfo(this,document.getElementById(\'contactidAttach\'),document.getElementById(\'addressidAttach\'));" style="cursor:pointer;"> <i class="fa fa-book fa-lg"></i></a>'; - $content .= '</div>'; - $content .= "<input type='hidden' id='contactidAttach' name='contactidAttach[]' value='{$infoAttach->contact_id}' />"; - $content .= "<input type='hidden' id='addressidAttach' name='addressidAttach[]' value='{$infoAttach->address_id}' />"; - - $canCreateContact = $core->test_admin('my_contacts', 'apps', false); - if (!$canCreateContact) { - $canCreateContact = 0; - } - } - - - if ($mode == 'add' && $_GET['cat'] != 'outgoing') { - $content .= '<p>'; - - $content .= '<div id="newAttachDiv" style="float: left">'; - - //ADD ATTACH OTHER ATTACHEMENT - $content .= '<input type="button" class="button readonly" id="newAttachButton" value="'._NEW_ATTACH_ADDED.'" title="'._NEW_ATTACH_ADDED.'" onclick="addNewAttach();" disabled="disabled"></input>'; - $content .= ' '; - //DEL ATTACH (HIDDEN DEFAULT) - $content .= '<input type="button" class="button readonly" style="background:#d14836;color:white;display:none;" name="delAttachButton[]" id="delAttachButton" value="'._DELETE.'" title="'._DELETE.'" disabled="disabled"></input>'; - - $content .= '</div>'; - - $content .= '</p>'; - } - - $content .= "<input type='hidden' id='attachNum' name='attachNum[]' value='0' />"; - - //NEW VERSION IN EDIT MODE - if ($mode == 'edit' && ($infoAttach->status != 'TMP' || ($infoAttach->status == 'TMP' && $infoAttach->relation > 1))) { - $content .= '<p>'; - $content .= '<label>'._CREATE_NEW_ATTACHMENT_VERSION.'</label>'; - $content .= '<input type="radio" name="new_version" id="new_version_yes" value="yes" onclick="'; - if (!in_array($infoAttach->format, ['pdf', 'jpg', 'jpeg', 'png'])) { - $content .= '$j(\'#edit\').css(\'visibility\',\'hidden\');'; - } - $content .= '$j(\'#editModel\').css(\'display\',\'inline-block\');$j(\'#editMailing\').hide();"/>'._YES; - $content .= ' '; - $content .= '<input type="radio" name="new_version" id="new_version_no" checked value="no" onclick="$j(\'#edit\').css(\'visibility\',\'visible\');"/>'._NO; - $content .= '</p>'; - } -$content .= '</div>'; - -$content .= '<div id="transmission"></div>'; - $content .= '<p class="buttons">'; - //EDIT MODEL BUTTON - if ($mode == 'edit' && !in_array($infoAttach->format, ['pdf', 'jpg', 'jpeg', 'png'])) { - $content .= '<input type="button" value="'; - $content .= _EDIT_MODEL; - $content .= '" name="editModel" id="editModel" class="button" onclick="$j(\'#editMailing\').hide();$(\'edit\').style.visibility=\'visible\';showAppletLauncher(this, \''.$_SESSION['doc_id'].'\',\''.$objectTable.'\',\'attachmentUpVersion\',\'attachment\');$(\'edit\').value=\'Edition en cours ...\';editingDoc(this,\''.$_SESSION['user']['UserId'].'\');$(\'edit\').disabled=\'disabled\';$(\'edit\').style.opacity=\'0.5\';this.hide();"/>'; - } - - if (!isset($_REQUEST['id']) || (isset($_REQUEST['id']) && $infoAttach->status == 'SEND_MASS')) { - $content .= ' '; - $content .= ' '; - - $content .= '<input type="button" value="'; - $content .= 'Publipostage'; - if (isset($_REQUEST['id'])) { - $content .= '" name="editMailing" id="editMailing" class="button" onclick="if(confirm(\'' . _MAILING_CONFIRMATION .'\')){ValidAttachmentsForm(\''.$_SESSION['config']['businessappurl']; - } else { - $content .= '" name="addMailing" id="addMailing" class="button" style="display:none;" onclick="if(confirm(\'' . _MAILING_CONFIRMATION .'\')){simpleAjax(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=unsetReservedChronoNumber\');ValidAttachmentsForm(\''.$_SESSION['config']['businessappurl']; - } - - $content .= 'index.php?display=true&module=attachments&page=attachments_content&mailing=true\', \'formAttachment\''; - - //SIGNATURE BOOK - if (!empty($_REQUEST['docId'])) { - $content .= ", '{$mode}'"; - } - - $content .= ');simpleAjax(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=unsetTemporarySaved&mode='.$mode.'\')}"/>'; - } - $content .= ' '; - $content .= ' '; - - //VALIDATE BUTTON - $content .= '<input type="button" value="'; - $content .= _VALIDATE; - if (isset($_REQUEST['id'])) { - $content .= '" name="edit" id="edit" class="button" onclick="ValidAttachmentsForm(\''.$_SESSION['config']['businessappurl']; - } else { - $content .= '" name="add" id="add" class="button" onclick="simpleAjax(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=unsetReservedChronoNumber\');ValidAttachmentsForm(\''.$_SESSION['config']['businessappurl']; - } - $content .= 'index.php?display=true&module=attachments&page=attachments_content\', \'formAttachment\''; - - //SIGNATURE BOOK - if (!empty($_REQUEST['docId'])) { - $content .= ", '{$mode}'"; - } - - $content .= ');simpleAjax(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=unsetTemporarySaved&mode='.$mode.'\')"/>'; - - $content .= ' '; - $content .= ' '; - $content .= '<label> </label>'; - - //CANCEL BUTTON - $content .= '<input id="cancelpj" type="button" value="'; - $content .= _CANCEL; - $content .= '" name="cancel" class="button" onclick="simpleAjax(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=unsetReservedChronoNumber\');'; - $content .= 'simpleAjax(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=unsetTemporarySaved&mode='.$mode.'\');destroyModal(\'form_attachments\');"/>'; - - $content .= '</p>'; -$content .= '</form>'; - -//EXTRA JS -$content .= '<script>launch_autocompleter2_contacts_v2("'.$_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts", "contact_attach", "show_contacts_attach", "", "contactidAttach", "addressidAttach")</script>'; -$content .= '<script>display_contact_card(\'visible\', \'contact_card_attach\');</script>'; - -//IFRAME CREATE CONTACT -if ($core->test_admin('my_contacts', 'apps', false)) { - $content .= '<div id="create_contact_div_attach" style="display:none;float:right;width:65%;background-color:#F2F2F2">'; - $content .= '<iframe width="100%" height="550" src="'.$_SESSION['config']['businessappurl'] - .'index.php?display=false&dir=my_contacts&page=create_contact_iframe&fromAttachmentContact=Y&transmissionInput=0" name="contact_iframe_attach" id="contact_iframe_attach"' - .' scrolling="auto" frameborder="0" style="display:block;">' - .'</iframe>'; - $content .= '</div>'; -} -//IFRAME INFO CONTACT -$content .= '<div id="info_contact_div_attach" style="display:none;float:right;width:65%;background-color:#F2F2F2">'; - $content .= '<iframe width="100%" height="800" name="contact_card_attach_iframe" id="contact_card_attach_iframe"' - .' scrolling="auto" frameborder="0" style="display:block;">' - .'</iframe>'; -$content .= '</div>'; - -$content .= '<div style="float: right; width: 65%">'; - -//TABS -$content .= '<div id="menuOnglet">'; - $content .= '<ul id="ongletAttachement" style="cursor:pointer;width:auto;">'; - $content .= '<li id="MainDocument" onclick="activePjTab(this)"><span> '._MAIN_DOCUMENT.' </span></li>'; - if ($mode == 'edit') { - $content .= '<li id="PjDocument_0" onclick="activePjTab(this)"><span> PJ n°1 </span></li>'; - } - $content .= '</ul>'; -$content .= '</div>'; - -// ATTACHMENT IFRAME -if ($mode == 'edit') { - $srcAttachment = '../../rest/attachments/'.$_REQUEST['id'] . '/content'; - $content .= '<iframe src="'.$srcAttachment.'" name="iframePjDocument_0" id="iframePjDocument_0" scrolling="auto" frameborder="0" style="width:100% !important;height:85vh;display:none" onmouseover="this.focus()"></iframe>'; -} - -// MAIN DOCUMENT IFRAME -$content .= '<iframe src="../../rest/resources/'.functions::xssafe($_SESSION['doc_id']).'/content" name="iframeMainDocument" id="iframeMainDocument" scrolling="auto" frameborder="0" style="width:100% !important;height:85vh;display:none" onmouseover="this.focus()"></iframe>'; - -$content .= '</div>'; - -if ($mode == 'add') { - $js .= 'setTimeout(function(){window.parent.document.getElementById(\'MainDocument\').click()}, 1000);'; -} else { - $js .= 'setTimeout(function(){window.top.document.getElementById(\'PjDocument_0\').click()}, 1000);'; -} - -echo '{status : '.$status.", content : '".addslashes(_parse($content))."', error : '".addslashes($error)."', exec_js : '".addslashes($js)."'}"; -exit(); diff --git a/modules/attachments/choose_attachment.php b/modules/attachments/choose_attachment.php deleted file mode 100755 index c73040abb0e..00000000000 --- a/modules/attachments/choose_attachment.php +++ /dev/null @@ -1,186 +0,0 @@ -<?php -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. - -* -* @brief choose_attachment -* -* @author dev <dev@maarch.org> -* @ingroup core -*/ -$core_tools = new core_tools(); -$core_tools->load_lang(); -$func = new functions(); -$core_tools->load_html(); -$core_tools->load_header('', true, true); -$upFileOK = false; - -$_SESSION['upfile']['error'] = 0; -$_SESSION['error'] = ''; - -if (isset($_FILES) && $_FILES['file']['error'] == 1) { - $_SESSION['upfile'][0]['error'] = $value; - $error = 'La taille excede la valeur de upload_max_filesize'; - echo '<script>$j("#main_error",window.parent.document).html(\''.$error.'\').show().delay(5000).fadeOut();</script>'; -} elseif (!empty($_FILES['file']['tmp_name']) && $_FILES['file']['error'] != 1) { - unset($_SESSION['upfile'][0]['fileNamePdfOnTmp']); - $_SESSION['upfile'][0]['tmp_name'] = $_FILES['file']['tmp_name']; - $extension = explode('.', $_FILES['file']['name']); - $name_without_ext = substr($_FILES['file']['name'], 0, strrpos($_FILES['file']['name'], '.')); - echo '<script>window.parent.document.getElementById(\'title\').value=\''.$name_without_ext.'\';</script>'; - $count_level = count($extension) - 1; - $the_ext = $extension[$count_level]; - $fileNameOnTmp = 'tmp_file_'.$_SESSION['user']['UserId'] - .'_'.rand().'.'.strtolower($the_ext); - $_SESSION['upfile'][0]['fileNameOnTmp'] = $fileNameOnTmp; - $filePathOnTmp = $_SESSION['config']['tmppath'].$fileNameOnTmp; - - if (!is_uploaded_file($_FILES['file']['tmp_name'])) { - $_SESSION['error'] = _FILE_NOT_SEND.'. '._TRY_AGAIN - .'. '._MORE_INFOS.' (<a href="mailto:' - .$_SESSION['config']['adminmail'].'">' - .$_SESSION['config']['adminname'].'</a>)'; - } else { - include_once 'core/docservers_tools.php'; - $arrayIsAllowed = array(); - $arrayIsAllowed = Ds_isFileTypeAllowed($_FILES['file']['tmp_name'], strtolower($the_ext)); - if ($arrayIsAllowed['status'] == false) { - $_SESSION['error'] = _WRONG_FILE_TYPE.' '.$arrayIsAllowed['mime_type']; - $_SESSION['upfile'] = array(); - } elseif (!@move_uploaded_file($_FILES['file']['tmp_name'], $filePathOnTmp)) { - $_SESSION['error'] = _FILE_NOT_SEND.'. '._TRY_AGAIN.'. ' - ._MORE_INFOS.' (<a href="mailto:' - .$_SESSION['config']['adminmail'].'">' - .$_SESSION['config']['adminname'].'</a>)'; - } else { - $_SESSION['upfile'][0]['size'] = $_FILES['file']['size']; - $_SESSION['upfile'][0]['mime'] = $_FILES['file']['type']; - $_SESSION['upfile'][0]['local_path'] = $filePathOnTmp; - //$_SESSION['upfile']['name'] = $_FILES['file']['name']; - $_SESSION['upfile'][0]['name'] = $fileNameOnTmp; - $_SESSION['upfile'][0]['format'] = $the_ext; - $upFileOK = true; - - //CONSTRUCT TAB (IF PDF) - if (in_array(strtolower($_SESSION['upfile'][0]['format']), ['pdf', 'jpg', 'jpeg', 'png'])) { - echo '<script>if($j("#ongletAttachement #PjDocument_0",window.parent.document).length) {$j("#ongletAttachement #PjDocument_0",window.parent.document).remove();$j("div #iframePjDocument_0",window.parent.document).remove();}</script>'; - echo '<script>$j("#MainDocument",window.parent.document).after($j("#MainDocument",window.parent.document).clone());</script>'; - echo '<script>$j("#iframeMainDocument",window.parent.document).after($j("#iframeMainDocument",window.parent.document).clone());</script>'; - echo '<script>$j("div #iframeMainDocument",window.parent.document).eq(1).attr("id","iframePjDocument_0");</script>'; - echo '<script>$j("div #iframePjDocument_0",window.parent.document).attr("src","index.php?display=true&dir=indexing_searching&page=file_iframe&num=0&#navpanes=0'.$_SESSION['upfile'][0]['local_path'].'");</script>'; - echo '<script>$j("#ongletAttachement #MainDocument",window.parent.document).eq(1).attr("id","PjDocument_0");</script>'; - echo '<script>$j("#ongletAttachement #PjDocument_0",window.parent.document).html("<span>PJ n°1</span>");</script>'; - echo '<script>$j("#ongletAttachement #PjDocument_0",window.parent.document).click();</script>'; - } - } - } -} -?> -<body> -<form name="select_file_form" id="select_file_form" method="get" enctype="multipart/form-data" action="<?php - echo $_SESSION['config']['businessappurl']; - ?>index.php?display=true&module=attachments&page=choose_attachment" class="forms"> - <input type="hidden" name="display" value="true" /> - <input type="hidden" name="dir" value="indexing_searching" /> - <input type="hidden" name="page" value="choose_attachment" /> - <?php - if (!empty($_SESSION['upfile'][0]['local_path']) && empty($_SESSION['error'])) { - ?> - <i class="fa fa-check-square fa-2x" title="<?php echo _DOWNLOADED_FILE; ?>"></i> - <input type="button" id="fileButton" onclick="$j('#file').click();" class="button" - value="<?php if ($_REQUEST['with_file'] == 'true') { - echo _WITHOUT_FILE; - } else { - echo $_FILES['file']['name']; - } ?>" - title="<?php if ($_REQUEST['with_file'] == 'true') { - echo _WITHOUT_FILE; - } else { - echo $_FILES['file']['name']; - } ?>" - style="width: 85%;margin: 0px;margin-top: -10px;font-size: 12px;text-align: center;text-overflow: ellipsis;overflow: hidden;"> - <?php - } elseif (!empty($_SESSION['error'])) { - ?> - <i class="fa fa-times fa-2x" title="<?php echo $_SESSION['error']; ?>"></i> - <input type="button" id="fileButton" onclick="$j('#file').click();" class="button" value="<?php echo $_SESSION['error']; ?>" style="width: 85%;margin: 0px;margin-top: -10px;font-size: 12px;text-align: center;text-overflow: ellipsis;overflow: hidden;"> - <?php - } else { - ?> - <i class="fa fa-times fa-2x" title="<?php echo _NO_FILE_SELECTED; ?>"></i> - <input type="button" id="fileButton" onclick="$j('#file').click();" class="button" value="<?php echo _CHOOSE_FILE; ?>" style="width: 85%;margin: 0px;margin-top: -10px;font-size: 12px;text-align: center;text-overflow: ellipsis;overflow: hidden;"> - <?php - } ?> - <p style="display:none"> - <input type="file" name="file" id="file" onchange="$('with_file').value='false';this.form.method = 'post';this.form.submit();" value="<?php - if (isset($_SESSION['file_path'])) { - echo $_SESSION['file_path']; - } ?>" style="width:200px" /> - </p> - <p style="display:none"> - <div align="center"> - <input type="radio" name="with_file" id="with_file" value="false" onclick="this.form.method = 'post';this.form.submit();" /> - </div> - </p> -</form> -<?php -if (!empty($_SESSION['upfile'][0]['local_path']) && empty($_SESSION['error'])) { - //launch auto convert in PDF - $_SESSION['upfile'][0]['error'] = 0; - $_SESSION['upfile'][0]['tmp_name'] = $_SESSION['upfile'][0]['local_path']; - if (in_array(strtolower($_SESSION['upfile'][0]['format']), array('odt', 'docx', 'doc', 'docm')) && $_SESSION['modules_loaded']['attachments']['convertPdf'] == "true") { - echo "<script>window.parent.$('add').value='Edition en cours ...';window.parent.editingDoc(this,'superadmin');window.parent.$('add').disabled='disabled';window.parent.$('add').style.opacity='0.5';</script>"; - include_once 'modules/content_management/class/class_content_manager_tools.php'; - - $cM = new content_management_tools(); - if ( - file_exists('custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'] - .DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'content_management' - .DIRECTORY_SEPARATOR.'applet_controller.php' - ) - ) { - $path = 'custom/'.$_SESSION['custom_override_id'].'/modules/content_management/applet_controller.php'; - } else { - $path = 'modules/content_management/applet_controller.php'; - } - $path_appli = explode('/', $_SESSION['config']['coreurl']); - if (count($path_appli) != 5) { - $path_appli = array_slice($path_appli, 0, 4); - $path_appli = implode('/', $path_appli); - } else { - $path_appli = implode('/', $path_appli); - } - - $cookieKey = $_SESSION['sessionName'].'='.$_COOKIE[$_SESSION['sessionName']]; - - $onlyConvert = 'true'; - $cM->generateJNLP( - $path_appli, - $path_appli.'/'.$path, - 'newAttachment', - 'res_letterbox', - $_SESSION['doc_id'], - '0', - $cookieKey, - $_SESSION['user']['UserId'], - $_SESSION['clientSideCookies'], - $_SESSION['modules_loaded']['attachments']['convertPdf'], - $onlyConvert - ); - } else { - echo '<script>if($j("#ongletAttachement #PjDocument_0",window.parent.document).length) {$j("#ongletAttachement #PjDocument_0",window.parent.document).remove();$j("div #iframePjDocument_0",window.parent.document).remove();}</script>'; - echo '<script>$j("#MainDocument",window.parent.document).after($j("#MainDocument",window.parent.document).clone());</script>'; - echo '<script>$j("#iframeMainDocument",window.parent.document).after($j("#iframeMainDocument",window.parent.document).clone());</script>'; - echo '<script>$j("div #iframeMainDocument",window.parent.document).eq(1).attr("id","iframePjDocument_0");</script>'; - echo '<script>$j("div #iframePjDocument_0",window.parent.document).attr("src","index.php?display=true&dir=indexing_searching&page=file_iframe&num=0&#navpanes=0");</script>'; - echo '<script>$j("#ongletAttachement #MainDocument",window.parent.document).eq(1).attr("id","PjDocument_0");</script>'; - echo '<script>$j("#ongletAttachement #PjDocument_0",window.parent.document).html("<span>PJ n°1</span>");</script>'; - echo '<script>$j("#ongletAttachement #PjDocument_0",window.parent.document).click();</script>'; - } -} -?> -</body> -</html> - diff --git a/modules/attachments/class/attachments_controler_Abstract.php b/modules/attachments/class/attachments_controler_Abstract.php index e36e7af8973..9516620d007 100755 --- a/modules/attachments/class/attachments_controler_Abstract.php +++ b/modules/attachments/class/attachments_controler_Abstract.php @@ -32,256 +32,6 @@ abstract class attachments_controler_Abstract { - public function initAttachmentInfos($resId) - { - $db = new Database(); - $stmt = $db->query("SELECT subject, exp_contact_id, dest_contact_id, exp_user_id, address_id, dest_user_id, alt_identifier FROM res_view_letterbox WHERE res_id = ?", array($resId)); - $data_attachment = $stmt->fetchObject(); - - $infos['title'] = $data_attachment->subject; - - if ($data_attachment->dest_contact_id <> "") { - $infos['contact_id'] = $data_attachment->dest_contact_id; - $infos['address_id'] = $data_attachment->address_id; - - $stmt = $db->query('SELECT is_corporate_person, is_private, contact_lastname, contact_firstname, society, society_short, address_num, address_street, address_town, lastname, firstname - FROM view_contacts - WHERE contact_id = ? and ca_id = ?', array($data_attachment->dest_contact_id,$data_attachment->address_id)); - } elseif ($data_attachment->exp_contact_id <> "") { - $infos['contact_id'] = $data_attachment->exp_contact_id; - $infos['address_id'] = $data_attachment->address_id; - $stmt = $db->query('SELECT is_corporate_person, is_private, contact_lastname, contact_firstname, society, society_short, address_num, address_street, address_town, lastname, firstname - FROM view_contacts - WHERE contact_id = ? and ca_id = ?', array($data_attachment->exp_contact_id,$data_attachment->address_id)); - } elseif ($data_attachment->dest_user != '') { - $infos['contact_id'] = $data_attachment->dest_user; - $infos['address_id'] = $data_attachment->address_id; - $stmt = $db->query('SELECT lastname, firstname FROM users WHERE user_id = ?', [$data_attachment->dest_user]); - } elseif ($data_attachment->exp_user_id != '') { - $infos['contact_id'] = $data_attachment->exp_user_id; - $infos['address_id'] = $data_attachment->address_id; - $stmt = $db->query('SELECT lastname, firstname FROM users WHERE user_id = ?', [$data_attachment->exp_user_id]); - } elseif ($data_attachment->dest_user_id != '') { - $infos['contact_id'] = $data_attachment->dest_user_id; - $infos['address_id'] = $data_attachment->address_id; - $stmt = $db->query('SELECT lastname, firstname FROM users WHERE user_id = ?', [$data_attachment->dest_user_id]); - } - - if ($data_attachment->exp_contact_id <> '' || $data_attachment->dest_contact_id <> '') { - $res = $stmt->fetchObject(); - if ($res->is_corporate_person == 'Y') { - $data_contact = $res->society; - if (!empty($res->society_short)) { - $data_contact .= ' ('.$res->society_short.')'; - } - if (!empty($res->lastname) || !empty($res->firstname)) { - $data_contact .= ' - ' . $res->lastname . ' ' . $res->firstname; - } - $data_contact .= ', '; - } else { - $data_contact .= $res->contact_lastname . ' ' . $res->contact_firstname; - if (!empty($res->society)) { - $data_contact .= ' (' .$res->society . ')'; - } - $data_contact .= ', '; - } - if ($res->is_private == 'Y') { - $data_contact .= '(' . _CONFIDENTIAL_ADDRESS . ')'; - } else { - $data_contact .= $res->address_num . ' ' . $res->address_street . ' ' . strtoupper($res->address_town); - } - $infos['contact_show'] = $data_contact; - } elseif ($data_attachment->exp_user_id != '' || $data_attachment->dest_user != '' || $data_attachment->dest_user_id != '') { - $res = $stmt->fetchObject(); - if (!empty($res->lastname) || !empty($res->firstname)) { - $data_contact .= $res->lastname . ' ' . $res->firstname; - } - $infos['contact_show'] = $data_contact; - //si multicontact - } else { - $stmt = $db->query("SELECT cr.address_id, c.contact_id, c.is_corporate_person, c.society, c.society_short, c.firstname, c.lastname,ca.is_private,ca.address_street, ca.address_num, ca.address_town - FROM contacts_res cr, contacts_v2 c, contact_addresses ca - WHERE cr.res_id = ? and cast(c.contact_id as char) = cast(cr.contact_id as char) and ca.contact_id=c.contact_id and ca.id=cr.address_id", array($_SESSION['doc_id'])); - $i=0; - while ($multi_contacts_attachment = $stmt->fetchObject()) { - if (is_numeric($multi_contacts_attachment->contact_id)) { - $format_contact=''; - $stmt2 = $db->query('SELECT is_corporate_person, is_private, contact_lastname, contact_firstname, society, society_short, address_num, address_street, address_town, lastname, firstname - FROM view_contacts - WHERE contact_id = ? and ca_id = ?', array($multi_contacts_attachment->contact_id,$multi_contacts_attachment->address_id)); - - $res = $stmt2->fetchObject(); - if ($res->is_corporate_person == 'Y') { - $format_contact = $res->society; - if (!empty($res->society_short)) { - $format_contact .= ' ('.$res->society_short.')'; - } - if (!empty($res->lastname) || !empty($res->firstname)) { - $format_contact .= ' - ' . $res->lastname . ' ' . $res->firstname; - } - $format_contact .= ', '; - } else { - $format_contact .= $res->contact_lastname . ' ' . $res->contact_firstname; - if (!empty($res->society)) { - $format_contact .= ' (' .$res->society . ')'; - } - $format_contact .= ', '; - } - if ($res->is_private == 'Y') { - $format_contact .= '('._CONFIDENTIAL_ADDRESS.')'; - } else { - $format_contact .= $res->address_num .' ' . $res->address_street .' ' . strtoupper($res->address_town); - } - $contacts[] = array( - 'contact_id' => $multi_contacts_attachment->contact_id, - 'firstname' => $multi_contacts_attachment->firstname, - 'lastname' => $multi_contacts_attachment->lastname, - 'society' => $multi_contacts_attachment->society, - 'address_id' => $multi_contacts_attachment->address_id, - 'format_contact' => $format_contact - ); - - if ($i==0) { - $data_contact = $format_contact; - $data_attachment->exp_contact_id = $multi_contacts_attachment->contact_id; - } - $i++; - } - } - $infos['multi_contact'] = $contacts; - } - - return $infos; - } - - public function getAttachmentInfos($resId) - { - $db = new Database(); - - $stmt = $db->query( - "SELECT * - FROM res_attachments - WHERE res_id = ? and res_id_master = ? ORDER BY relation desc", - array($resId, $resId, $_SESSION['doc_id']) - ); - - $infos = array(); - 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 = $line->format; - $stmt = $db->query( - "select path_template from docservers where docserver_id = ?", - array($docserver) - ); - - $lineDoc = $stmt->fetchObject(); - $docserver = $lineDoc->path_template; - $file = $docserver . $path . $filename; - $file = str_replace("#", DIRECTORY_SEPARATOR, $file); - $origin = explode(',', $line->origin); - $target_table_origin = $origin[1]; - $res_id_origin = $origin[0]; - - $file_pdf = str_replace(pathinfo($filename, PATHINFO_EXTENSION), 'pdf', $file); - $infos['pathfile'] = $file; - $infos['path'] = $path; - $infos['format'] = $format; - $infos['pathfile_pdf'] = $file_pdf; - $infos['res_id_origin'] = $res_id_origin; - $infos['target_table_origin'] = $target_table_origin; - $infos['status'] = $line->status; - $infos['attachment_type'] = $line->attachment_type; - $infos['creation_date'] = $line->creation_date; - $infos['type_id'] = $line->type_id; - $infos['title'] = $line->title; - $infos['typist'] = $line->typist; - $infos['validation_date'] = $line->validation_date; - $infos['effective_date'] = $line->effective_date; - $infos['res_id_master'] = $line->res_id_master; - $infos['identifier'] = $line->identifier; - - if (empty($infos['target_table_origin'])) { - $infos['target_table_origin'] = 'res_attachments'; - } - - //contact - if (!empty($line->dest_user)) { - $stmt = $db->query( - "SELECT user_id,lastname,firstname - FROM users - WHERE user_id = ?", - array($line->dest_user) - ); - $res = $stmt->fetchObject(); - $data_contact = $res->lastname . ' ' . $res->firstname; - $infos['contact_id'] = $res->user_id; - $infos['contact_show'] = $data_contact; - } else { - $stmt = $db->query( - "SELECT * - FROM view_contacts - WHERE contact_id = ? and ca_id = ?", - array($line->dest_contact_id,$line->dest_address_id) - ); - $res = $stmt->fetchObject(); - if ($res->is_corporate_person == 'Y') { - $data_contact = $res->society; - if (!empty($res->society_short)) { - $data_contact .= ' ('.$res->society_short.')'; - } - if (!empty($res->lastname) || !empty($res->firstname)) { - $data_contact .= ' - ' . $res->lastname . ' ' . $res->firstname; - } - $data_contact .= ', '; - } else { - $data_contact .= $res->contact_lastname . ' ' . $res->contact_firstname; - if (!empty($res->society)) { - $data_contact .= ' (' .$res->society . ')'; - } - $data_contact .= ', '; - } - if ($res->is_private == 'Y') { - $data_contact .= '(' . _CONFIDENTIAL_ADDRESS . ')'; - } else { - $data_contact .= $res->address_num . ' ' . $res->address_street . ' ' . strtoupper($res->address_town); - } - $infos['contact_id'] = $line->dest_contact_id; - $infos['address_id'] = $line->dest_address_id; - $infos['contact_show'] = $data_contact; - } - } - return $infos; - } - - public function getCorrespondingPdf($resId) - { - $infos = $this->getAttachmentInfos($resId); - if ($infos['format'] == 'pdf') { - return $resId; - } - $db2 = new Database(); - $result = 0; - $stmt2 = $db2->query( - "SELECT res_id - 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(); - - return $result; - } - /** * Remove temporary attachment file on docserver * @param bigint $resIdAttachment id of the attachment resource diff --git a/modules/attachments/del_attachment.php b/modules/attachments/del_attachment.php deleted file mode 100755 index 5e15ec28efa..00000000000 --- a/modules/attachments/del_attachment.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. - -* -* @brief del_attachment -* -* @author dev <dev@maarch.org> -* @ingroup attachments -*/ -require_once 'core/class/class_security.php'; -require_once 'core/class/class_request.php'; -require_once 'core/class/class_resource.php'; -require_once 'core/class/class_history.php'; -require_once 'modules/attachments/attachments_tables.php'; -require_once 'modules/attachments/class/attachments_controler.php'; -$core = new core_tools(); -$core->load_lang(); - -if (empty($_REQUEST['rest'])) { - $core->load_js(); -} - -$func = new functions(); -$ac = new attachments_controler(); -$db = new Database(); - -if (!empty($_REQUEST['docId'])) { - $_SESSION['doc_id'] = $_REQUEST['docId']; -} - -//RETRIEVE INFO CURRENT ATTACHMENT -$info_doc = $ac->getAttachmentInfos($_REQUEST['id']); -$pdf_id = $ac->getCorrespondingPdf($_REQUEST['id']); - -//DEL CURRENT ATTACHMENT -$stmt = $db->query("UPDATE {$info_doc['target_table_origin']} SET status = 'DEL' WHERE res_id = ?", array($_REQUEST['id'])); - -//DEL CONVERTED PDF -if ($pdf_id != 0) { - $stmt = $db->query('UPDATE '.RES_ATTACHMENTS_TABLE." SET status = 'DEL' WHERE res_id = ?", array($pdf_id)); -} - -$stmt = $db->query("UPDATE res_attachments SET status = 'DEL' WHERE origin_id = ? or res_id = ?", array($res->origin_id, $res->origin_id)); - -//LOG DELETE ACTION IN HISTORY -if ($_SESSION['history']['attachdel'] == 'true') { - $hist = new history(); - $hist->add( - $view, - $resIdMaster, - 'DEL', - 'attachdel', - _ATTACH_DELETED.' '._ON_DOC_NUM - .$info_doc['res_id_master'].' ('.$_REQUEST['id'].')', - $_SESSION['config']['databasetype'], - 'attachments' - ); - $hist->add( - RES_ATTACHMENTS_TABLE, - $_REQUEST['id'], - 'DEL', - 'attachdel', - _ATTACH_DELETED.' : ' - .$_REQUEST['id'], - $_SESSION['config']['databasetype'], - 'attachments' - ); - if (empty($_REQUEST['rest'])) { - echo '<script>$j("#main_error",window.parent.document).html(\''._ATTACH_DELETED.' : '.$_REQUEST['id'].'\').show().delay(5000).fadeOut();</script>'; - } -} - -//SIGNATURE BOOK -if (!empty($_REQUEST['rest'])) { - echo '{"status" : "ok"}'; - exit; -} - -//REFRESH TABS -if (empty($_REQUEST['rest'])) { - $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') { - $query .= " and (attachment_type = 'response_project' or attachment_type = 'outgoing_mail_signed' or attachment_type = 'outgoing_mail' or attachment_type = 'signed_response' or attachment_type = 'aihp')"; - } else { - $query .= " and attachment_type NOT IN ('converted_pdf','print_folder')"; - } - $stmt = $db->query($query, array($info_doc['res_id_master'])); - $new_nb_attach = $stmt->total; ?> -<script type="text/javascript"> - var eleframe1 = parent.document.getElementsByName('list_attach'); - if (eleframe1[0] === undefined) { - eleframe1 = parent.document.getElementsByName('uniqueDetailsIframe'); - } - var nb_attach = '<?php functions::xecho($new_nb_attach); ?>'; - <?php if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') { - ?> - eleframe1[0].src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&attach_type_exclude=response_project,signed_response,outgoing_mail_signed,converted_pdf,outgoing_mail,print_folder,aihp&fromDetail=attachments'; ?>"; - <?php - } elseif (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response') { - ?> - eleframe1[0].src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&attach_type=response_project,outgoing_mail_signed,signed_response,outgoing_mail,aihp&fromDetail=response'; ?>"; - <?php - } else { - ?> - parent.document.getElementById('list_attach').src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&template_selected=documents_list_attachments_simple&page=frame_list_attachments&load&attach_type_exclude=converted_pdf,print_folder'; ?>"; - <?php - } ?> -</script> -<?php -} diff --git a/modules/attachments/get_chrono_attachment.php b/modules/attachments/get_chrono_attachment.php deleted file mode 100755 index f0a61edaad4..00000000000 --- a/modules/attachments/get_chrono_attachment.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. - -* @brief get_chrono_attachment -* @author dev <dev@maarch.org> -* @ingroup attachments -*/ - -require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php'; -require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_chrono.php'; -require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); - -$core = new core_tools(); -$core->test_user(); -$db = new Database(); - -$index = $_REQUEST['index']; - -//RETRIEVE CATEGORY OF DOCUMENT -$stmt = $db->query("SELECT category_id FROM res_letterbox WHERE res_id = ? ", array($_SESSION['doc_id'])); -$resMaster = $stmt->fetchObject(); -$category_id = $resMaster->category_id; - -$nb_attachment = 0; - -// Check if reponse project was already attached to this outgoing document. -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 { - //GENERATE NEW CHRONO - $chronoX = new chrono(); - $myVars = array( - 'category_id' => 'outgoing', - 'entity_id' => $_SESSION['user']['primaryentity']['id'] - ); - - $myChrono = $chronoX->generate_chrono('outgoing', $myVars); - $_SESSION['save_chrono_number'][$index] = $myChrono; - echo "{status: 1, chronoNB: '".functions::xssafe($myChrono)."'}"; - } -} diff --git a/modules/attachments/js/functions.js b/modules/attachments/js/functions.js index 6aa60a8a9f5..1805388ee30 100755 --- a/modules/attachments/js/functions.js +++ b/modules/attachments/js/functions.js @@ -1,33 +1,3 @@ -// Date + 60 jours, utile pour les transmissions -function defineBackDate(delay) { - var date1 = new Date(); - date1.setDate(date1.getDate() + Number(delay)); - var str_date = date1.toLocaleDateString(); - var t = str_date.split('/'); - if(t[1].length == 1){ - t[1] = '0'+t[1]; - } - if(t[0].length == 1){ - t[0] = '0'+t[0]; - } - str_date = t.join('-'); - return str_date; -} - -function hideEditAndAddButton(editParagraph) { - $(editParagraph).style.display = "none"; -} - - -function hideInput(target) { - if ($j('#'+target.id).val() == "NO_RTURN") { - $j('#'+target.id).parent().parent().find('[name=back_date\\[\\]]').val(""); - } else { - var delay = $j('#'+target.id).parent().parent().find('[name=attachment_types\\[\\]] option:selected').attr("width_delay"); - var delay_date = defineBackDate(delay); - $j('#'+target.id).parent().parent().find('[name=back_date\\[\\]]').val(delay_date); - } -} function showAttachmentsForm(path, width, height) { if(typeof(width)==='undefined'){ diff --git a/modules/attachments/remove_letterbox.php b/modules/attachments/remove_letterbox.php deleted file mode 100755 index 923c7b02b49..00000000000 --- a/modules/attachments/remove_letterbox.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - *​ ​Copyright​ ​Maarch​ since ​2008​ under licence ​GPLv3. - *​ ​See​ LICENCE​.​txt file at the root folder ​for​ more details. - *​ ​This​ file ​is​ part of ​Maarch​ software. - * - */ - - -$core = new core_tools(); -$core->test_user(); - -// Variable declaration -$res_id = $_SESSION['doc_id']; -$res_id_master = $_SESSION['stockCheckbox']; -$delete_response_project = $_SESSION['modules_loaded']['attachments']['reconciliation']['delete_response_project']; -$close_incoming = $_SESSION['modules_loaded']['attachments']['reconciliation']['close_incoming']; - -// Modification of the incoming document, as deleted -\Resource\models\ResModel::update([ - 'set' => ['status' => 'DEL'], - 'where' => ['res_id = ?'], - 'data' => [$res_id] -]); - -$tabFormValues = $_SESSION['modules_loaded']['attachments']['reconciliation']['tabFormValues']; - -// Deletion of the response project, with his chrono number and the res_id_master -if($delete_response_project == 'true'){ - \SrcCore\models\DatabaseModel::update([ - 'set' => ['status' => 'DEL'], - 'table' => 'res_attachments', - 'where' => ["res_id_master = ? AND identifier = ? AND status NOT IN ('DEL','TMP') AND attachment_type = 'response_project'"], - 'data' => [$res_id_master[0], $tabFormValues['chrono_number']], - ]); - -} - -// End the incoming mail after the reconciliation of the attachment -if($close_incoming == 'true' && $tabFormValues['close_incoming_mail'] == 'true'){ - for($i = 0; $i < count($res_id_master); $i++){ - \Resource\models\ResModel::update([ - 'set' => ['status' => 'END'], - 'where' => ['res_id = ?'], - 'data' => [$res_id_master[$i]] - ]); - } -} \ No newline at end of file diff --git a/modules/attachments/setFinalVersion.php b/modules/attachments/setFinalVersion.php deleted file mode 100755 index 6ab2c1ad8b9..00000000000 --- a/modules/attachments/setFinalVersion.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -/* -* Copyright 2008-2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core/class/class_request.php'; - -$db = new Database(); -$js = ""; - -$stmt = $db->query("SELECT relation, status - 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'; - } - - $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 .= '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\';'; -} 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\';'; -} - -echo "{status: ".$status_ajax.", exec_js : '".addslashes($js)."'}"; -exit; diff --git a/modules/attachments/show_attachments_details_tab.php b/modules/attachments/show_attachments_details_tab.php index d3ae50a8119..9fca6e4ca8d 100755 --- a/modules/attachments/show_attachments_details_tab.php +++ b/modules/attachments/show_attachments_details_tab.php @@ -40,11 +40,6 @@ $core_tools->load_js(); $frm_str .= '<div class="ref-unit">'; $frm_str .= '<center>'; -if ($core_tools->is_module_loaded('templates') && ($core_tools->test_service('edit_attachments_from_detail', 'attachments', false))) { - $frm_str .= '<input type="button" name="attach" id="attach" class="button" value="'. _CREATE_PJ.'" - onclick="showAttachmentsForm(\''. $_SESSION['config']['businessappurl'] - . 'index.php?display=true&module=attachments&page=attachments_content&fromDetail=create\',\'98%\',\'auto\')" />'; -} $frm_str .= '</center><iframe name="list_attach" id="list_attach" src="'.$_SESSION['config']['businessappurl'] . 'index.php?display=true&module=attachments&page=frame_list_attachments&view_only=true&load&fromDetail='.$from_detail.$extraParam.'" ' . 'frameborder="0" width="100%" height="550px"></iframe>'; $frm_str .= '</div>'; diff --git a/modules/attachments/show_attachments_tab.php b/modules/attachments/show_attachments_tab.php index e96afe9699d..7857910bc1c 100755 --- a/modules/attachments/show_attachments_tab.php +++ b/modules/attachments/show_attachments_tab.php @@ -31,12 +31,6 @@ $core_tools->load_js(); $frm_str .= '<div class="ref-unit">'; $frm_str .= '<center>'; -if ($core_tools->is_module_loaded('templates')) { - $frm_str .= '<input type="button" name="attach" id="attach" class="button" value="' - . _CREATE_PJ - . '" onclick="showAttachmentsForm(\'' . $_SESSION['config']['businessappurl'] - . 'index.php?display=true&module=attachments&page=attachments_content\')" />'; -} $frm_str .= '</center><iframe name="list_attach" id="list_attach" src="' . $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=attachments&page=frame_list_attachments&load&attach_type_exclude=converted_pdf,print_folder" ' diff --git a/modules/attachments/xml/IVS/requests_definitions.xml b/modules/attachments/xml/IVS/requests_definitions.xml index bb38be84536..64b6467edff 100755 --- a/modules/attachments/xml/IVS/requests_definitions.xml +++ b/modules/attachments/xml/IVS/requests_definitions.xml @@ -1,23 +1,5 @@ <requestDefinitions> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="attachments_content" > - <parameter name="module" type="identifier" /> - <parameter name="display" value="true"/> - <parameter name="page" value="attachments_content"/> - </requestDefinition> - - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="get_chrono_attachment" > - <parameter name="module" type="identifier" /> - <parameter name="display" value="true"/> - <parameter name="page" value="get_chrono_attachment"/> - </requestDefinition> - - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="get_chrono_attachment" > - <parameter name="module" type="identifier" /> - <parameter name="display" value="true"/> - <parameter name="page" value="get_chrono_attachment"/> - </requestDefinition> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="frame_list_attachments" > <parameter name="module" type="identifier" /> <parameter name="display" value="true"/> @@ -30,30 +12,11 @@ <parameter name="page" value="frame_list_attachments"/> </requestDefinition> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="choose_attachment" > - <parameter name="module" type="identifier" /> - <parameter name="display" value="true"/> - <parameter name="page" value="choose_attachment"/> - </requestDefinition> - - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="choose_attachment" > - <parameter name="module" type="identifier" /> - <parameter name="display" value="true"/> - <parameter name="page" value="choose_attachment"/> - </requestDefinition> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="previous_attachments" > <parameter name="module" type="identifier" /> <parameter name="display" value="true"/> <parameter name="page" value="previous_attachments"/> </requestDefinition> - - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="del_attachment" > - <parameter name="module" type="identifier" /> - <parameter name="display" value="true"/> - <parameter name="page" value="del_attachment"/> - </requestDefinition> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="get_other_chrono_attachment"> <parameter name="module" type="identifier" /> <parameter name="display" value="true"/> diff --git a/modules/attachments/xml/IVS/validation_rules.xml b/modules/attachments/xml/IVS/validation_rules.xml index ea075a9a5f3..fc5ba7af425 100755 --- a/modules/attachments/xml/IVS/validation_rules.xml +++ b/modules/attachments/xml/IVS/validation_rules.xml @@ -1,38 +1,6 @@ <?xml version="1.0" encoding="UTF-8" ?> <inputValidation xmlns:xi="http://www.w3.org/2001/XInclude"> <validationRules> - - <validationRule name="attachments_content" extends="standardForm" mode="lax"> - <parameter name="module" type="identifier" /> - <parameter name="fromDetail" type="identifier" /> - <parameter name="url" type="string" /> - <parameter name="id" type="integer" /> - <parameter name="relation" type="identifier" /> - <parameter name="add" type="string" /> - <parameter name="attachment_types" type="identifier" /> - <parameter name="back_date" type="arrayOfStrings" /> - <parameter name="cancel" type="string" /> - <parameter name="chrono" type="string" /> - <parameter name="contact_attach" type="string" /> - <parameter name="contactidAttach" type="arrayOfStrings" /> - <parameter name="editModel" type="string" /> - <parameter name="edit" type="string" /> - <parameter name="fromDetail" type="string" /> - <parameter name="templateOffice" type="string" /> - <parameter name="title" type="string" /> - <parameter name="new_version" type="YesNO" /> - <parameter name="relation" type="integer" /> - <parameter name="res_id" type="integer" /> - <parameter name="get_chrono_display" type="string" /> - </validationRule> - - <validationRule name="get_chrono_attachment" extends="standardForm" mode="error"> - <parameter name="module" type="identifier" /> - <parameter name="index" type="integer" /> - <parameter name="type_id" type="string" /> - <parameter name="attachment" type="string" /> - </validationRule> - <validationRule name="frame_list_attachments" extends="standardForm" mode="error"> <parameter name="module" type="identifier" /> <parameter name="fromDetail" type="identifier" /> @@ -46,26 +14,11 @@ <parameter name="view_only" type="string" /> </validationRule> - <validationRule name="choose_attachment" extends="standardForm" mode="error"> - <parameter name="module" type="identifier" /> - <parameter name="dir" type="string" /> - <parameter name="file" type="YN" /> - </validationRule> - <validationRule name="previous_attachments" extends="standardForm" mode="error"> <parameter name="module" type="identifier" /> <parameter name="res_id" type="integer" /> </validationRule> - <validationRule name="del_attachment" extends="standardForm" mode="error"> - <parameter name="module" type="identifier" /> - <parameter name="fromDetail" type="identifier" /> - <parameter name="id" type="integer" /> - <parameter name="relation" type="integer" /> - <parameter name="docId" type="integer" /> - <parameter name="rest" type="boolean" /> - </validationRule> - <validationRule name="get_other_chrono_attachment" extends="standardForm" mode="error"> <parameter name="module" type="identifier" /> <parameter name="type_id" type="identifier" /> diff --git a/src/app/email/controllers/EmailController.php b/src/app/email/controllers/EmailController.php index 197a48bfe7f..5a57bce2bd8 100644 --- a/src/app/email/controllers/EmailController.php +++ b/src/app/email/controllers/EmailController.php @@ -144,7 +144,11 @@ class EmailController } } - return ($isSent['success'] ?? $id); + if (!empty($isSent['errors'])) { + return $isSent; + } + + return $id; } public function getById(Request $request, Response $response, array $args) diff --git a/src/frontend/app/signature-book.component.ts b/src/frontend/app/signature-book.component.ts index 4653506c6ec..ca726336165 100755 --- a/src/frontend/app/signature-book.component.ts +++ b/src/frontend/app/signature-book.component.ts @@ -345,7 +345,7 @@ export class SignatureBookComponent implements OnInit { } addAttachmentIframe() { - showAttachmentsForm('index.php?display=true&module=attachments&page=attachments_content&docId=' + this.resId); + // showAttachmentsForm('index.php?display=true&module=attachments&page=attachments_content&docId=' + this.resId); } editAttachmentIframe(attachment: any) { @@ -353,7 +353,7 @@ export class SignatureBookComponent implements OnInit { var resId: number; resId = attachment.res_id; - modifyAttachmentsForm('index.php?display=true&module=attachments&page=attachments_content&id=' + resId + '&relation=' + attachment.relation + '&docId=' + this.resId, '98%', 'auto'); + // modifyAttachmentsForm('index.php?display=true&module=attachments&page=attachments_content&id=' + resId + '&relation=' + attachment.relation + '&docId=' + this.resId, '98%', 'auto'); } } @@ -368,10 +368,10 @@ export class SignatureBookComponent implements OnInit { var resId: number; resId = attachment.res_id; - this.http.get('index.php?display=true&module=attachments&page=del_attachment&id=' + resId + '&relation=' + attachment.relation + '&docId=' + this.resId + '&rest=true') - .subscribe(() => { - this.refreshAttachments('del'); - }); + // this.http.get('index.php?display=true&module=attachments&page=del_attachment&id=' + resId + '&relation=' + attachment.relation + '&docId=' + this.resId + '&rest=true') + // .subscribe(() => { + // this.refreshAttachments('del'); + // }); } } } -- GitLab