diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php index cbe8d6cc54a042cdbc855941807f4fd67be58040..86cee702a7c6632885422d4ee97b032e04c223f9 100755 --- a/apps/maarch_entreprise/actions/index_mlb.php +++ b/apps/maarch_entreprise/actions/index_mlb.php @@ -683,6 +683,20 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $c .'style="display:inline;"><i class="fa fa-star"></i></span> </td>'; $frmStr .= '</tr>'; + /*** Sender/Recipient ***/ + $frmStr .= '<tr id="sender_recipient_tr" style="display:' . $displayValue . ';">'; + $frmStr .= '<td><label for="sender_recipient" class="form_title" >'; + $frmStr .= '<span id="sr_sender_span">'._SHIPPER.'</span>'; + $frmStr .= '<span id="sr_recipient_span">'._DEST.'</span>'; + $frmStr .= '</label></td>'; + $frmStr .= '<td> </td>'; + $frmStr .= '<td class="indexing_field"><div class="typeahead__container"><div class="typeahead__field"><span class="typeahead__query">'; + $frmStr .= '<input name="sender_recipient" type="text" id="sender_recipient" autocomplete="off"/></span></div></div>'; + $frmStr .= '</td><td> </td>'; + $frmStr .= '<input type="hidden" id="sender_recipient_id" />'; + $frmStr .= '<input type="hidden" id="sender_recipient_type" />'; + $frmStr .= '</tr>'; + /*** Nature ***/ $frmStr .= '<tr id="nature_id_tr" style="display:'.$displayValue.';">'; $frmStr .= '<td><label for="nature_id" class="form_title" >'._NATURE @@ -1031,6 +1045,8 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $c . 'true&page=autocomplete_department_number\',' . ' \'Input\', \'2\', \'department_number_id\');'; + $frmStr .= 'initSenderRecipientAutocomplete();'; + $frmStr .= '$j(\'#baskets\').css(\'visibility\',\'hidden\');' .'var item = $j(\'#index_div\')[0]; if(item)' .'{item.style.display=\'block\';}</script>'; diff --git a/apps/maarch_entreprise/js/indexing.js b/apps/maarch_entreprise/js/indexing.js index 7b163a3a6545603493aaae8f01b8918c4b726170..816987297e1d9c06cedbf1022d4cd659e7909f37 100755 --- a/apps/maarch_entreprise/js/indexing.js +++ b/apps/maarch_entreprise/js/indexing.js @@ -407,120 +407,124 @@ function change_category(cat_id, display_value_tr, path_manage_script,get_js_scr if(cat_id == 'incoming') { var category = [ - {id:'doctype_mail', type:'label', state:'display'}, - {id:'doctype_res', type:'label', state:'hide'}, - {id:'priority_tr', type:'tr', state:'display'}, - {id:'external_id_tr', type:'tr', state:'display'}, - {id:'external_id_mandatory', type:'tr', state:'display'}, - {id:'doc_date_label', type:'label', state:'hide'}, - {id:'mail_date_label', type:'label', state:'display'}, - {id:'author_tr', type:'tr', state:'hide'}, - {id:'admission_date_tr', type:'tr', state:'display'}, - {id:'contact_check', type:'tr', state:'hide'}, - {id:'nature_id_tr', type:'tr', state:'display'}, - {id:'label_dep_dest', type:'label', state:'display'}, - {id:'label_dep_exp', type:'label', state:'hide'}, - {id:'label_dep_owner', type:'label', state:'hide'}, - {id:'process_limit_date_use_tr', type:'tr', state:'display'}, - {id:'process_limit_date_tr', type:'tr', state:'display'}, - {id:'department_tr', type:'tr', state:'display'}, - {id:'difflist_tr', type:'tr', state:'display'}, - {id:'box_id_tr', type:'tr', state:'display'}, - {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:'display'}, - {id:'contact_id_tr', type:'tr', state:'display'}, - {id:'dest_contact', type:'label', state:'hide'}, - {id:'exp_contact', type:'label', state:'display'}, - {id:'dest_multi_contact', type:'label', state:'hide'}, - {id:'exp_multi_contact', type:'label', state:'display'}, - {id:'author_contact', type:'label', state:'hide'}, - {id:'type_multi_contact_external_icon', type:'label', state:'display'}, - {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:'display'}, - {id:'category_id_mandatory', type:'label', state:'display'}, - {id:'type_id_mandatory', type:'label', state:'display'}, - {id:'priority_mandatory', type:'label', state:'display'}, - {id:'doc_date_mandatory', type:'label', state:'display'}, - {id:'departure_date_mandatory', type:'label', state:'hide'}, - {id:'departure_date_tr', type:'tr', state:'hide'}, - {id:'author_mandatory', type:'label', state:'hide'}, - {id:'admission_date_mandatory', type:'label', state:'display'}, - {id:'type_contact_mandatory', type:'label', state:'display'}, - {id:'contact_mandatory', type:'label', state:'display'}, - {id:'nature_id_mandatory', type:'label', state:'display'}, - {id:'subject_mandatory', type:'label', state:'display'}, - {id:'destination_mandatory', type:'label', state:'display'}, - {id:'process_limit_date_use_mandatory', type:'label', state:'display'}, - {id:'process_limit_date_mandatory', type:'label', state:'display'}, - {id:'chrono_number', type:'label', state:'hide'}, - {id:'chrono_number_mandatory', type:'label', state:'hide'}, - {id:'chrono_number_tr', type:'tr', state:'hide'}, - {id:'folder_mandatory', type:'label', state:'hide'} + {id:'doctype_mail', type:'label', state:'display'}, + {id:'doctype_res', type:'label', state:'hide'}, + {id:'priority_tr', type:'tr', state:'display'}, + {id:'external_id_tr', type:'tr', state:'display'}, + {id:'external_id_mandatory', type:'tr', state:'display'}, + {id:'doc_date_label', type:'label', state:'hide'}, + {id:'mail_date_label', type:'label', state:'display'}, + {id:'author_tr', type:'tr', state:'hide'}, + {id:'admission_date_tr', type:'tr', state:'display'}, + {id:'contact_check', type:'tr', state:'hide'}, + {id:'nature_id_tr', type:'tr', state:'display'}, + {id:'label_dep_dest', type:'label', state:'display'}, + {id:'label_dep_exp', type:'label', state:'hide'}, + {id:'label_dep_owner', type:'label', state:'hide'}, + {id:'process_limit_date_use_tr', type:'tr', state:'display'}, + {id:'process_limit_date_tr', type:'tr', state:'display'}, + {id:'department_tr', type:'tr', state:'display'}, + {id:'difflist_tr', type:'tr', state:'display'}, + {id:'box_id_tr', type:'tr', state:'display'}, + {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:'display'}, + {id:'contact_id_tr', type:'tr', state:'display'}, + {id:'dest_contact', type:'label', state:'hide'}, + {id:'exp_contact', type:'label', state:'display'}, + {id:'dest_multi_contact', type:'label', state:'hide'}, + {id:'exp_multi_contact', type:'label', state:'display'}, + {id:'author_contact', type:'label', state:'hide'}, + {id:'type_multi_contact_external_icon', type:'label', state:'display'}, + {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:'display'}, + {id:'category_id_mandatory', type:'label', state:'display'}, + {id:'type_id_mandatory', type:'label', state:'display'}, + {id:'priority_mandatory', type:'label', state:'display'}, + {id:'doc_date_mandatory', type:'label', state:'display'}, + {id:'departure_date_mandatory', type:'label', state:'hide'}, + {id:'departure_date_tr', type:'tr', state:'hide'}, + {id:'author_mandatory', type:'label', state:'hide'}, + {id:'admission_date_mandatory', type:'label', state:'display'}, + {id:'type_contact_mandatory', type:'label', state:'display'}, + {id:'contact_mandatory', type:'label', state:'display'}, + {id:'nature_id_mandatory', type:'label', state:'display'}, + {id:'subject_mandatory', type:'label', state:'display'}, + {id:'destination_mandatory', type:'label', state:'display'}, + {id:'process_limit_date_use_mandatory', type:'label', state:'display'}, + {id:'process_limit_date_mandatory', type:'label', state:'display'}, + {id:'chrono_number', type:'label', state:'hide'}, + {id:'chrono_number_mandatory', type:'label', state:'hide'}, + {id:'chrono_number_tr', type:'tr', state:'hide'}, + {id:'folder_mandatory', type:'label', state:'hide'}, + {id:'sr_sender_span', type:'label', state:'hide'}, + {id:'sr_recipient_span', type:'label', state:'display'} ]; } //Category = OUTGOING else if(cat_id == 'outgoing') { var category = [ - {id:'doctype_mail', type:'label', state:'display'}, - {id:'doctype_res', type:'label', state:'hide'}, - {id:'priority_tr', type:'tr', state:'display'}, - {id:'external_id_tr', type:'tr', state:'hide'}, - {id:'external_id_mandatory', type:'tr', state:'hide'}, - {id:'doc_date_label', type:'label', state:'hide'}, - {id:'mail_date_label', type:'label', state:'display'}, - {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:'display'}, - {id:'department_tr', type:'tr', state:'display'}, - {id:'label_dep_dest', type:'label', state:'hide'}, - {id:'label_dep_exp', type:'label', state:'display'}, - {id:'label_dep_owner', type:'label', state:'hide'}, - {id:'difflist_tr', type:'tr', state:'display'}, - {id:'process_limit_date_use_tr', type:'tr', state:'display'}, - {id:'process_limit_date_tr', type:'tr', state:'display'}, - {id:'box_id_tr', type:'tr', state:'display'}, - {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:'display'}, - {id:'exp_contact_choose_label', type:'label', state:'hide'}, - {id:'contact_id_tr', type:'tr', state:'display'}, - {id:'dest_contact', type:'label', state:'display'}, - {id:'exp_contact', type:'label', state:'hide'}, - {id:'dest_multi_contact', type:'label', state:'display'}, - {id:'exp_multi_contact', type:'label', state:'hide'}, - {id:'author_contact', type:'label', state:'hide'}, - {id:'type_multi_contact_external_icon', type:'label', state:'display'}, - {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:'display'}, - {id:'category_id_mandatory', type:'label', state:'display'}, - {id:'type_id_mandatory', type:'label', state:'display'}, - {id:'priority_mandatory', type:'label', state:'display'}, - {id:'doc_date_mandatory', type:'label', state:'display'}, - {id:'departure_date_mandatory', type:'label', state:'hide'}, - {id:'departure_date_tr', type:'tr', state:'hide'}, - {id:'author_mandatory', type:'label', state:'hide'}, - {id:'admission_date_mandatory', type:'label', state:'hide'}, - {id:'type_contact_mandatory', type:'label', state:'display'}, - {id:'contact_mandatory', type:'label', state:'display'}, - {id:'nature_id_mandatory', type:'label', state:'display'}, - {id:'subject_mandatory', type:'label', state:'display'}, - {id:'destination_mandatory', type:'label', state:'display'}, - {id:'process_limit_date_use_mandatory', type:'label', state:'display'}, - {id:'process_limit_date_mandatory', type:'label', state:'display'}, - {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:'doctype_mail', type:'label', state:'display'}, + {id:'doctype_res', type:'label', state:'hide'}, + {id:'priority_tr', type:'tr', state:'display'}, + {id:'external_id_tr', type:'tr', state:'hide'}, + {id:'external_id_mandatory', type:'tr', state:'hide'}, + {id:'doc_date_label', type:'label', state:'hide'}, + {id:'mail_date_label', type:'label', state:'display'}, + {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:'display'}, + {id:'department_tr', type:'tr', state:'display'}, + {id:'label_dep_dest', type:'label', state:'hide'}, + {id:'label_dep_exp', type:'label', state:'display'}, + {id:'label_dep_owner', type:'label', state:'hide'}, + {id:'difflist_tr', type:'tr', state:'display'}, + {id:'process_limit_date_use_tr', type:'tr', state:'display'}, + {id:'process_limit_date_tr', type:'tr', state:'display'}, + {id:'box_id_tr', type:'tr', state:'display'}, + {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:'display'}, + {id:'exp_contact_choose_label', type:'label', state:'hide'}, + {id:'contact_id_tr', type:'tr', state:'display'}, + {id:'dest_contact', type:'label', state:'display'}, + {id:'exp_contact', type:'label', state:'hide'}, + {id:'dest_multi_contact', type:'label', state:'display'}, + {id:'exp_multi_contact', type:'label', state:'hide'}, + {id:'author_contact', type:'label', state:'hide'}, + {id:'type_multi_contact_external_icon', type:'label', state:'display'}, + {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:'display'}, + {id:'category_id_mandatory', type:'label', state:'display'}, + {id:'type_id_mandatory', type:'label', state:'display'}, + {id:'priority_mandatory', type:'label', state:'display'}, + {id:'doc_date_mandatory', type:'label', state:'display'}, + {id:'departure_date_mandatory', type:'label', state:'hide'}, + {id:'departure_date_tr', type:'tr', state:'hide'}, + {id:'author_mandatory', type:'label', state:'hide'}, + {id:'admission_date_mandatory', type:'label', state:'hide'}, + {id:'type_contact_mandatory', type:'label', state:'display'}, + {id:'contact_mandatory', type:'label', state:'display'}, + {id:'nature_id_mandatory', type:'label', state:'display'}, + {id:'subject_mandatory', type:'label', state:'display'}, + {id:'destination_mandatory', type:'label', state:'display'}, + {id:'process_limit_date_use_mandatory', type:'label', state:'display'}, + {id:'process_limit_date_mandatory', type:'label', state:'display'}, + {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:'sr_sender_span', type:'label', state:'display'}, + {id:'sr_recipient_span', type:'label', state:'hide'} ]; } //Category = INTERNAL @@ -576,7 +580,9 @@ function change_category(cat_id, display_value_tr, path_manage_script,get_js_scr {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:'folder_mandatory', type:'label', state:'hide'}, + {id:'sr_sender_span', type:'label', state:'hide'}, + {id:'sr_recipient_span', type:'label', state:'display'} ]; } //Category = GED_DOC @@ -633,159 +639,11 @@ function change_category(cat_id, display_value_tr, path_manage_script,get_js_scr {id:'chrono_number_tr', type:'tr', state:'hide'}, {id:'folder_mandatory', type:'label', state:'hide'}, {id:'external_id_tr', type:'tr', state:'hide'}, - {id:'external_id_mandatory', type:'tr', state:'hide'} - ]; - } - //Category = FOLDER_DOCUMENT - else if(cat_id == 'folder_document') - { - var category = [ - {id:'doctype_mail', type:'label', state:'hide'}, - {id:'doctype_res', type:'label', state:'display'}, - {id:'priority_tr', type:'tr', state:'hide'}, - {id:'doc_date_label', type:'label', state:'display'}, - {id:'mail_date_label', type:'label', state:'hide'}, - {id:'author_tr', type:'tr', state:'display'}, - {id:'admission_date_tr', type:'tr', state:'hide'}, - {id:'nature_id_tr', type:'tr', state:'hide'}, - {id:'department_tr', type:'tr', state:'hide'}, - {id:'process_limit_date_use_tr', type:'tr', state:'hide'}, - {id:'process_limit_date_tr', type:'tr', state:'hide'}, - {id:'diff_list_tr', type:'tr', state:'hide'}, - {id:'box_id_tr', type:'tr', state:'display'}, - {id:'contact_choose_tr', type:'tr', state:'hide'}, - {id:'contact_id_tr', type:'tr', state:'hide'}, - {id:'folder_tr', type:'tr', state:'display'}, - {id:'category_id_mandatory', type:'label', state:'display'}, - {id:'type_id_mandatory', type:'label', state:'display'}, - {id:'priority_mandatory', type:'label', state:'hide'}, - {id:'doc_date_mandatory', type:'label', state:'display'}, - {id:'author_mandatory', type:'label', state:'display'}, - {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:'display'}, - {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'} - ]; - } - //Category = ENTERPRISE_DOCUMENT - else if(cat_id == 'enterprise_document') - { - var category = [ - {id:'category_img_purchase', type:'label', state:'hide'}, - {id:'category_img_sell', type:'label', state:'hide'}, - {id:'category_img_enterprise_document', type:'label', state:'display'}, - {id:'category_img_human_resources', type:'label', state:'hide'}, - - {id:'doctype_tr', type:'tr', state:'display'}, - {id:'box_id_tr', type:'tr', state:'display'}, - {id:'type_id_tr', type:'tr', state:'display'}, - {id:'appraisal_code_tr', type:'tr', state:'display'}, - {id:'appraisal_duration_tr', type:'tr', state:'display'}, - {id:'access_restriction_code_tr', type:'tr', state:'display'}, - {id:'project_tr', type:'tr', state:'display'}, - - {id:'contact_id_tr', type:'tr', state:'display'}, - {id:'contact_label_purchase', type:'label', state:'hide'}, - {id:'contact_label_sell', type:'label', state:'hide'}, - {id:'contact_label_enterprise_document', type:'label', state:'display'}, - {id:'contact_label_human_resources', type:'label', state:'hide'}, - {id:'contact_purchase_img', type:'label', state:'hide'}, - {id:'contact_sell_img', type:'label', state:'hide'}, - {id:'contact_enterprise_document_img', type:'label', state:'display'}, - {id:'contact_human_resources_img', type:'label', state:'hide'}, - - {id:'identifier_tr', type:'tr', state:'display'}, - {id:'doc_date_tr', type:'tr', state:'display'}, - {id:'currency_tr', type:'tr', state:'hide'}, - {id:'net_sum_tr', type:'tr', state:'hide'}, - {id:'tax_sum_tr', type:'tr', state:'hide'}, - {id:'total_sum_tr', type:'tr', state:'hide'}, - {id:'process_limit_date_use_tr', type:'tr', state:'display'}, - {id:'process_limit_date_tr', type:'tr', state:'display'}, - {id:'department_tr', type:'tr', state:'display'}, - {id:'folder_tr', type:'tr', state:'display'}, - {id:'difflist_tr', type:'tr', state:'hide'}, - - {id:'category_id_mandatory', type:'label', state:'display'}, - {id:'type_id_mandatory', type:'label', state:'display'}, - {id:'subject_mandatory', type:'label', state:'display'}, - {id:'contact_mandatory', type:'label', state:'hide'}, - {id:'identifier_mandatory', type:'label', state:'hide'}, - {id:'doc_date_mandatory', type:'label', state:'display'}, - {id:'currency_mandatory', type:'label', state:'hide'}, - {id:'tax_sum_mandatory', type:'label', state:'hide'}, - {id:'total_sum_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:'destination_mandatory', type:'label', state:'display'}, - {id:'difflist_mandatory', type:'label', state:'hide'}, - {id:'folder_mandatory', type:'label', state:'hide'} - ]; - } - //Category = HUMAN_RESOURCES - else if(cat_id == 'human_resources') - { - var category = [ - {id:'category_img_purchase', type:'label', state:'hide'}, - {id:'category_img_sell', type:'label', state:'hide'}, - {id:'category_img_enterprise_document', type:'label', state:'hide'}, - {id:'category_img_human_resources', type:'label', state:'display'}, - - {id:'doctype_tr', type:'tr', state:'display'}, - {id:'box_id_tr', type:'tr', state:'hide'}, - {id:'type_id_tr', type:'tr', state:'hide'}, - {id:'appraisal_code_tr', type:'tr', state:'hide'}, - {id:'appraisal_duration_tr', type:'tr', state:'hide'}, - {id:'access_restriction_code_tr', type:'tr', state:'hide'}, - {id:'project_tr', type:'tr', state:'hide'}, - - {id:'contact_id_tr', type:'tr', state:'display'}, - {id:'contact_label_purchase', type:'label', state:'hide'}, - {id:'contact_label_sell', type:'label', state:'hide'}, - {id:'contact_label_enterprise_document', type:'label', state:'hide'}, - {id:'contact_label_human_resources', type:'label', state:'display'}, - {id:'contact_purchase_img', type:'label', state:'hide'}, - {id:'contact_sell_img', type:'label', state:'hide'}, - {id:'contact_enterprise_document_img', type:'label', state:'hide'}, - {id:'contact_human_resources_img', type:'label', state:'display'}, - - {id:'identifier_tr', type:'tr', state:'display'}, - {id:'doc_date_tr', type:'tr', state:'display'}, - {id:'currency_tr', type:'tr', state:'hide'}, - {id:'net_sum_tr', type:'tr', state:'hide'}, - {id:'tax_sum_tr', type:'tr', state:'hide'}, - {id:'total_sum_tr', type:'tr', state:'hide'}, - {id:'process_limit_date_use_tr', type:'tr', state:'display'}, - {id:'process_limit_date_tr', type:'tr', state:'display'}, - {id:'department_tr', type:'tr', state:'display'}, - {id:'folder_tr', type:'tr', state:'display'}, - {id:'difflist_tr', type:'tr', state:'display'}, - - {id:'category_id_mandatory', type:'label', state:'display'}, - {id:'type_id_mandatory', type:'label', state:'display'}, - {id:'subject_mandatory', type:'label', state:'display'}, - {id:'contact_mandatory', type:'label', state:'hide'}, - {id:'identifier_mandatory', type:'label', state:'hide'}, - {id:'doc_date_mandatory', type:'label', state:'display'}, - {id:'currency_mandatory', type:'label', state:'hide'}, - {id:'tax_sum_mandatory', type:'label', state:'hide'}, - {id:'total_sum_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:'destination_mandatory', type:'label', state:'display'}, - {id:'difflist_mandatory', type:'label', state:'hide'}, - {id:'folder_mandatory', type:'label', state:'hide'} + {id:'external_id_mandatory', type:'tr', state:'hide'}, + {id:'sr_sender_span', type:'label', state:'hide'}, + {id:'sr_recipient_span', type:'label', state:'display'} ]; - } - else if(cat_id == 'attachment'){ // NCH01 + } else if(cat_id == 'attachment'){ // NCH01 var category = [ {id:'doctype_mail', type:'label', state:'display'}, {id:'doctype_res', type:'label', state:'hide'}, @@ -844,7 +702,9 @@ function change_category(cat_id, display_value_tr, path_manage_script,get_js_scr {id:'departure_date_mandatory', type:'label', state:'hide'}, {id:'departure_date_tr', type:'tr', state:'hide'}, {id:'add_multi_contact_tr', type:'tr', state:'hide'}, - {id:'show_multi_contact_tr', type:'tr', state:'hide'} + {id:'show_multi_contact_tr', type:'tr', state:'hide'}, + {id:'sr_sender_span', type:'label', state:'hide'}, + {id:'sr_recipient_span', type:'label', state:'display'} ]; } @@ -1232,26 +1092,6 @@ function getContacts(path_script, id, mode){ }); } -/** - * Get the type of the contact with the category_id - * - * @return String category_id - **/ -function get_contact_type (category_id) -{ - if (category_id == 'purchase') { - return 'supplier'; - } else if (category_id == 'sell') { - return 'purchaser'; - } else if (category_id == 'enterprise_document') { - return 'contact'; - } else if (category_id == 'human_resources') { - return 'employee'; - } else { - return 'letter'; - } -} - /** * Gets the parameters for the contacts : the table which must be use in the ajax script * @@ -1272,7 +1112,7 @@ function get_contacts_params(name_radio) cat = document.getElementById('category_id').value; } if (arr.length == 0) { - var contact_type = get_contact_type(cat); + var contact_type = 'letter'; params = 'table=contacts&contact_type=' + contact_type; } else { if (arr[0] == 'internal') { @@ -1593,7 +1433,7 @@ function update_contact_type_session(path) var params = ''; if (arr.length == 0) { - var contact_type = get_contact_type($('category_id').value); + var contact_type = 'letter'; params = 'table=contacts&contact_type=' + contact_type; } else { if (arr[0] == 'internal') { @@ -2101,3 +1941,34 @@ function delIndexingModel() { }); } } + +function initSenderRecipientAutocomplete() { + $j("#sender_recipient").typeahead({ + order: "asc", + display: "idToDisplay", + templateValue: "{{otherInfo}}", + minLength: 3, + dynamic: true, + source: { + ajax: function (query) { + return { + type: "GET", + url: "../../rest/autocomplete/contactsUsers", + data: { + search : query + } + } + } + }, + callback: { + onClickAfter: function (node, li, item) { + $j("#sender_recipient_id").val(item.id); + $j("#sender_recipient_type").val(item.type); + }, + onCancel: function () { + $j("#sender_recipient_id").val(''); + $j("#sender_recipient_type").val(''); + } + } + }); +} diff --git a/core/class/ExportControler.php b/core/class/ExportControler.php index c63d481c4f36f99561b78b9fc84260a4e1b5b055..0f5de287ccf0dd012becbd1955c9d0d8c094e754 100755 --- a/core/class/ExportControler.php +++ b/core/class/ExportControler.php @@ -371,17 +371,6 @@ class ExportFunctions $this->object_export->{$this->pos}->get_tags = implode(' ##Â ', $arr_tags); } - public function get_contact_type($libelle, $res_id) - { - $db = new Database(); - - $query = 'SELECT ct.label from contacts_v2 cont LEFT JOIN mlb_coll_ext mlb ON (mlb.exp_contact_id = cont.contact_id OR mlb.dest_contact_id = cont.contact_id) LEFT JOIN contact_types ct ON ct.id = cont.contact_type WHERE mlb.res_id = ?'; - $stmt = $db->query($query, array($res_id)); - $result = $stmt->fetchObject(); - - $this->object_export->{$this->pos}->get_contact_type = $result->label; - } - public function get_contact_civility($libelle, $res_id) { $db = new Database(); diff --git a/rest/index.php b/rest/index.php index 5f60079dab72827329d00d7c4f0c3731291faf18..0e7f357a31d7285e7ac7e710e26d70f40e373b11 100755 --- a/rest/index.php +++ b/rest/index.php @@ -67,6 +67,7 @@ $app->get('/administration', \SrcCore\controllers\CoreController::class . ':getA //AutoComplete $app->get('/autocomplete/contacts', \SrcCore\controllers\AutoCompleteController::class . ':getContacts'); $app->get('/autocomplete/users', \SrcCore\controllers\AutoCompleteController::class . ':getUsers'); +$app->get('/autocomplete/contactsUsers', \SrcCore\controllers\AutoCompleteController::class . ':getContactsAndUsers'); $app->get('/autocomplete/users/administration', \SrcCore\controllers\AutoCompleteController::class . ':getUsersForAdministration'); $app->get('/autocomplete/users/visa', \SrcCore\controllers\AutoCompleteController::class . ':getUsersForVisa'); $app->get('/autocomplete/entities', \SrcCore\controllers\AutoCompleteController::class . ':getEntities'); diff --git a/sql/develop.sql b/sql/develop.sql index c498d27092ce8e8efdf3c012115490d5d35f15a6..6faa7ff0f4931abc7a6b8f991059c6591fc48053 100644 --- a/sql/develop.sql +++ b/sql/develop.sql @@ -560,3 +560,16 @@ ALTER TABLE entities ADD COLUMN folder_import character varying(64); ALTER TABLE entities ADD UNIQUE (folder_import); ALTER TABLE user_abs DROP COLUMN IF EXISTS group_id; ALTER TABLE user_abs ADD COLUMN group_id int; + +/* Sender/Recipient */ +DROP TABLE IF EXISTS resource_contacts; +CREATE TABLE resource_contacts +( + id serial NOT NULL, + res_id int NOT NULL, + item_id int NOT NULL, + type character varying(32) NOT NULL, + mode character varying(32) NOT NULL, + CONSTRAINT resource_contacts_pkey PRIMARY KEY (id) +) +WITH (OIDS=FALSE); diff --git a/src/core/controllers/AutoCompleteController.php b/src/core/controllers/AutoCompleteController.php index feacf761f83d31846cd8cc6b93313e135914c825..594de72b19083dcab10cb3aff3bd4ccbf683b5a1 100644 --- a/src/core/controllers/AutoCompleteController.php +++ b/src/core/controllers/AutoCompleteController.php @@ -117,6 +117,75 @@ class AutoCompleteController return $response->withJson($data); } + public static function getContactsAndUsers(Request $request, Response $response) + { + $data = $request->getQueryParams(); + + $check = Validator::stringType()->notEmpty()->validate($data['search']); + if (!$check) { + return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); + } + + $searchItems = explode(' ', $data['search']); + + $fields = '(contact_firstname ilike ? OR contact_lastname ilike ? OR firstname ilike ? OR lastname ilike ? OR society ilike ? + OR address_num ilike ? OR address_street ilike ? OR address_town ilike ? OR address_postal_code ilike ?)'; + $where = []; + $requestData = []; + foreach ($searchItems as $item) { + if (strlen($item) >= 2) { + $where[] = $fields; + for ($i = 0; $i < 9; $i++) { + $requestData[] = "%{$item}%"; + } + } + } + + $contacts = ContactModel::getOnView([ + 'select' => [ + 'ca_id', 'firstname', 'lastname', 'contact_lastname', 'contact_firstname', 'society', 'address_num', + 'address_street', 'address_town', 'address_postal_code', 'is_corporate_person' + ], + 'where' => $where, + 'data' => $requestData, + 'limit' => self::LIMIT + ]); + + $autocompleteData = []; + foreach ($contacts as $contact) { + $autocompleteData[] = AutoCompleteController::getFormattedContact(['contact' => $contact])['contact']; + } + + $excludedUsers = ['superadmin']; + + $requestData = AutoCompleteController::getDataForRequest([ + 'search' => $data['search'], + 'fields' => '(firstname ilike ? OR lastname ilike ?)', + 'where' => ['enabled = ?', 'status != ?', 'user_id not in (?)'], + 'data' => ['Y', 'DEL', $excludedUsers], + 'fieldsNumber' => 2, + ]); + + $users = UserModel::get([ + 'select' => ['id', 'user_id', 'firstname', 'lastname'], + 'where' => $requestData['where'], + 'data' => $requestData['data'], + 'orderBy' => ['lastname'], + 'limit' => self::LIMIT + ]); + + foreach ($users as $value) { + $autocompleteData[] = [ + 'type' => 'user', + 'id' => $value['id'], + 'idToDisplay' => "{$value['firstname']} {$value['lastname']}", + 'otherInfo' => "{$value['firstname']} {$value['lastname']}" + ]; + } + + return $response->withJson($autocompleteData); + } + public static function getUsersForAdministration(Request $request, Response $response) { $data = $request->getQueryParams(); @@ -387,4 +456,67 @@ class AutoCompleteController return ['where' => $aArgs['where'], 'data' => $aArgs['data']]; } + + public static function getFormattedContact(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['contact']); + ValidatorModel::arrayType($aArgs, ['contact']); + + $address = ''; + if ($aArgs['contact']['is_corporate_person'] == 'Y') { + $address.= $aArgs['contact']['firstname']; + $address.= (empty($address) ? $aArgs['contact']['lastname'] : " {$aArgs['contact']['lastname']}"); + if (!empty($address)) { + $address.= ', '; + } + if (!empty($aArgs['contact']['address_num'])) { + $address.= $aArgs['contact']['address_num'] . ' '; + } + if (!empty($aArgs['contact']['address_street'])) { + $address.= $aArgs['contact']['address_street'] . ' '; + } + if (!empty($aArgs['contact']['address_town'])) { + $address.= $aArgs['contact']['address_town'] . ' '; + } + if (!empty($aArgs['contact']['address_postal_code'])) { + $address.= $aArgs['contact']['address_postal_code'] . ' '; + } + $contact = [ + 'type' => 'contact', + 'id' => $aArgs['contact']['ca_id'], + 'contact' => $aArgs['contact']['society'], + 'address' => $address, + 'idToDisplay' => "{$aArgs['contact']['society']}<br/>{$address}", + 'otherInfo' => "{$aArgs['contact']['society']} - {$address}" + ]; + } else { + if (!empty($aArgs['contact']['address_num'])) { + $address.= $aArgs['contact']['address_num'] . ' '; + } + if (!empty($aArgs['contact']['address_street'])) { + $address.= $aArgs['contact']['address_street'] . ' '; + } + if (!empty($aArgs['contact']['address_town'])) { + $address.= $aArgs['contact']['address_town'] . ' '; + } + if (!empty($aArgs['contact']['address_postal_code'])) { + $address.= $aArgs['contact']['address_postal_code'] . ' '; + } + $idToDisplay = "{$aArgs['contact']['contact_firstname']} {$aArgs['contact']['contact_lastname']}"; + if (!empty($aArgs['contact']['society'])) { + $idToDisplay .= " ({$aArgs['contact']['society']})"; + } + + $contact = [ + 'type' => 'contact', + 'id' => $aArgs['contact']['ca_id'], + 'contact' => "{$aArgs['contact']['contact_firstname']} {$aArgs['contact']['contact_lastname']} ({$aArgs['contact']['society']})", + 'address' => $address, + 'idToDisplay' => "{$idToDisplay}<br/>{$address}", + 'otherInfo' => "{$idToDisplay} - {$address}" + ]; + } + + return ['contact' => $contact]; + } }