From 59144104e10f550547f5be09d98cc0a411226688 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Tue, 13 Mar 2018 15:25:21 +0100 Subject: [PATCH] FEAT #202 fusion M2M indexing --- apps/maarch_entreprise/actions/index_mlb.php | 5 +- apps/maarch_entreprise/js/functions.js | 52 +++++++++++++++++++ apps/maarch_entreprise/lang/en.php | 15 ++++++ apps/maarch_entreprise/lang/fr.php | 18 ++++++- apps/maarch_entreprise/xml/IVS/data_types.xml | 2 + .../xml/IVS/validation_rules.xml | 5 ++ apps/maarch_entreprise/xml/config.xml.default | 9 ++++ apps/maarch_entreprise/xml/entreprise.xml | 4 ++ apps/maarch_entreprise/xml/extensions.xml | 5 ++ apps/maarch_entreprise/xml/m2m_config.xml | 19 +++++++ rest/index.php | 1 + .../contact/controllers/ContactController.php | 23 ++++++++ .../contact/models/ContactModelAbstract.php | 17 ++++++ 13 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 apps/maarch_entreprise/xml/m2m_config.xml diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php index 95de8fe7515..84cc3838fa7 100755 --- a/apps/maarch_entreprise/actions/index_mlb.php +++ b/apps/maarch_entreprise/actions/index_mlb.php @@ -604,9 +604,10 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .=' <i class="fa fa-user" title="'._SINGLE_CONTACT.'" style="cursor:pointer;color:#009DC5;" id="type_contact_external_icon" onclick="$j(\'#type_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#009DC5\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#666\');"></i>'; $frmStr .=' <i class="fa fa-users" title="'._MULTI_CONTACT.'" style="cursor:pointer;" id="type_multi_contact_external_icon" onclick="$j(\'#type_multi_contact_external\')[0].click();$j(\'#type_contact_internal_icon\').css(\'color\',\'#666\');$j(\'#type_contact_external_icon\').css(\'color\',\'#666\');$j(\'#type_multi_contact_external_icon\').css(\'color\',\'#009DC5\');"></i>'; + $frmStr .=' <i class="fa fa-tty" title="'. _CONTACT_COMMUNICATION_DEFINE. '"style="visibility:hidden;display:inline;"" id="type_contact_communication_icon"></i>'; $frmStr .=' <span style="position:relative;"><input type="text" name="contact" onkeyup="erase_contact_external_id(\'contact\', \'contactid\');erase_contact_external_id(\'contact\', \'addressid\');"' - . 'id="contact" onblur="clear_error(\'frm_error_' . $actionId . '\');' - . 'display_contact_card(\'visible\');if(document.getElementById(\'type_contact_external\').checked == true){check_date_exp(\''.$path_to_script.'\', \''.$path_check_date_link.'\');}" /><div id="show_contacts" ' + . 'id="contact" onblur="clear_error(\'frm_error_' . $actionId . '\');' + . 'display_contact_card(\'visible\');checkCommunication(document.getElementById(\'contactid\').value);if(document.getElementById(\'type_contact_external\').checked == true){check_date_exp(\''.$path_to_script.'\', \''.$path_check_date_link.'\');}" /><div id="show_contacts" ' . 'class="autocomplete autocompleteIndex" style="width:100%;left:0px;top:17px;"></div><div class="autocomplete autocompleteIndex" id="searching_autocomplete" style="display: none;text-align:left;padding:5px;left:0px;width:100%;top:17px;"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> chargement ...</div></span></td>'; $frmStr .= '<td><span class="red_asterisk" id="contact_mandatory" ' . 'style="display:inline;"><i class="fa fa-star"></i></span> </td>'; diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js index 4c0886e4a1c..e8452832344 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -1806,6 +1806,28 @@ function unlock(path_script, id, coll) // A FAIRE }); } } +function checkCommunication(contactId){ + if (!contactId || !Number.isInteger(parseInt(contactId))) { + Element.setStyle($('type_contact_communication_icon'), {visibility : 'hidden'}); + return false; + } + + $j.ajax({ + url : '../../rest/contact/checkCommunication', + type : 'get', + data: { + contactId : contactId + }, + success: function(answer) { + if(answer[0]) { + Element.setStyle($('type_contact_communication_icon'), {visibility : 'visible'}); + } else { + Element.setStyle($('type_contact_communication_icon'), {visibility : 'hidden'}); + } + + } + }); +} function setContactType(mode, creation){ new Ajax.Request("index.php?dir=my_contacts&page=setContactType", @@ -1919,6 +1941,36 @@ function show_admin_contacts( is_corporate, display) //society_mandatory.style.display = 'none'; society_mandatory.css('display', 'none'); +/** +* Show or hide the data related to a person in the external contacts admin +* +* @param is_external Bool True the contact is external contact +**/ +function show_admin_external_contact( is_external, display) +{ + var display_value = display || 'inline'; + var searchDirectory = $("search_directory"); + var externalContactLabel = $("external_contact_id"); + if(is_external === false) + { + if(searchDirectory) + { + searchDirectory.style.display = "none"; + } + if(externalContactLabel) + { + externalContactLabel.style.display = "none"; + } + } + else + { + if(searchDirectory) + { + searchDirectory.style.display = display_value; + } + if(externalContactLabel) + { + externalContactLabel.style.display = display_value; } } } diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php index 2198c2426b2..47123b8f7e5 100755 --- a/apps/maarch_entreprise/lang/en.php +++ b/apps/maarch_entreprise/lang/en.php @@ -155,6 +155,7 @@ if (!defined("_EMAIL")) define("_EMAIL", "Email"); if (!defined("_DOCTYPE")) define("_DOCTYPE", "Document type"); if (!defined("_DOCTYPES_MAIL")) define("_DOCTYPES_MAIL", "Mail type"); if (!defined("_TYPE")) define("_TYPE", "Type"); +if (!defined("_URL")) define("_URL", "URL"); if (!defined("_WARNING_MESSAGE_DEL_TYPE")) define("_WARNING_MESSAGE_DEL_TYPE", "Warning :<br> The deletion of a document type leads to documents reallocation to a new type."); if (!defined("_WARNING_MESSAGE_DEL_GROUP")) @@ -915,6 +916,10 @@ if (!defined("_CONTACT_MODIFIED")) define("_CONTACT_MODIFIED", "Modified contact if (!defined("_CONTACT_DELETED")) define("_CONTACT_DELETED", "Deleted contact"); if (!defined("_MODIFY_CONTACT")) define("_MODIFY_CONTACT", "Modify a contact"); if (!defined("_IS_CORPORATE_PERSON")) define("_IS_CORPORATE_PERSON", "Corporate body"); +if (!defined("_IS_INTERNAL_CONTACT")) define("_IS_INTERNAL_CONTACT","Internal contact"); +if (!defined("_IS_EXTERNAL_CONTACT")) define("_IS_EXTERNAL_CONTACT","External contact"); +if (!defined("_SEARCH_DIRECTORY")) define("_SEARCH_DIRECTORY","Directory search"); +if (!defined("_EXTERNAL_CONTACT_ID")) define("_EXTERNAL_CONTACT_ID","External contact ID"); if (!defined("_INDIVIDUAL")) define("_INDIVIDUAL", "Private individual"); if (!defined("_CONTACT_TARGET")) define("_CONTACT_TARGET", "For what contact is that possible to use this type?"); if (!defined("_CONTACT_TARGET_LIST")) define("_CONTACT_TARGET_LIST", "Target of the contact type"); @@ -1097,6 +1102,14 @@ if (!defined("_CHOOSE_A_CONTACT")) define("_CHOOSE_A_CONTACT","Choose a contact" if (!defined("_CREATE_CONTACTS")) define("_CREATE_CONTACTS","All the contacts"); if (!defined("_LINKED_CONTACT")) define("_LINKED_CONTACT","Linked to a contact"); +if (!defined("_COMMUNICATION_TYPE")) define("_COMMUNICATION_TYPE","Communication type"); +if (!defined("_COMMUNICATION_VALUE")) define("_COMMUNICATION_VALUE","Value"); +if (!defined("_COMMUNICATION_ADDED")) define("_COMMUNICATION_ADDED","Communication added"); +if (!defined("_COMMUNICATION_MODIFIED")) define("_COMMUNICATION_MODIFIED","Communication modified"); +if (!defined("_COMMUNICATION_DELETED")) define("_COMMUNICATION_DELETED","Communication deleted"); +if (!defined("_CHOOSE_COMMUNICATION_TYPES")) define("_CHOOSE_COMMUNICATION_TYPES","Choose communication types"); +if (!defined("_CONTACT_COMMUNICATION_DEFINE")) define("_CONTACT_COMMUNICATION_DEFINE","Communication define"); + //// INDEXING SEARCHING if (!defined("_NO_COLLECTION_ACCESS_FOR_THIS_USER")) define("_NO_COLLECTION_ACCESS_FOR_THIS_USER", "No access to the documentary collections for this user"); if (!defined("_CREATION_DATE")) define("_CREATION_DATE", "Creation date"); @@ -2024,6 +2037,8 @@ if (!defined('_UPDATE_DESC_END')) if (!defined('_NO_AVAILABLE_TAG_TO_UPDATE')) define('_NO_AVAILABLE_TAG_TO_UPDATE', 'No available tag to update'); if (!defined("_ADDRESS_NB")) define("_ADDRESS_NB","Address number"); +if (!defined('_SAVE_NUMERIC_PACKAGE')) + define('_SAVE_NUMERIC_PACKAGE', 'Save numeric package'); if (!defined('_INVALID')) define('_INVALID', 'n\'est pas valide'); if (!defined('_STATUS_UPDATED')) diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index 9d8ede39b77..5dd2ddf8895 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -153,6 +153,7 @@ if (!defined("_EMAIL")) define("_EMAIL", "Courriel"); if (!defined("_DOCTYPE")) define("_DOCTYPE", "Type de document"); if (!defined("_DOCTYPES_MAIL")) define("_DOCTYPES_MAIL", "Type(s) de courrier"); if (!defined("_TYPE")) define("_TYPE", "Type"); +if (!defined("_URL")) define("_URL", "URL"); if (!defined("_WARNING_MESSAGE_DEL_TYPE")) define("_WARNING_MESSAGE_DEL_TYPE", "Avertissement :<br> La suppression d'un type de document entraine la réaffectation des documents à un nouveau type."); if (!defined("_WARNING_MESSAGE_DEL_GROUP")) @@ -926,7 +927,11 @@ if (!defined("_CONTACT_MODIFIED")) define("_CONTACT_MODIFIED", "Contact modifié if (!defined("_CONTACT_DELETED")) define("_CONTACT_DELETED", "Contact supprimé"); if (!defined("_MODIFY_CONTACT")) define("_MODIFY_CONTACT", "Modifier un contact"); if (!defined("_IS_CORPORATE_PERSON")) define("_IS_CORPORATE_PERSON", "Personne morale"); -if (!defined("_INDIVIDUAL")) define("_INDIVIDUAL", "Personne physique"); +if (!defined("_IS_INTERNAL_CONTACT")) define("_IS_INTERNAL_CONTACT","Contact interne"); +if (!defined("_IS_EXTERNAL_CONTACT")) define("_IS_EXTERNAL_CONTACT","Contact externe"); +if (!defined("_SEARCH_DIRECTORY")) define("_SEARCH_DIRECTORY","Recherche annuaire"); +if (!defined("_EXTERNAL_CONTACT_ID")) define("_EXTERNAL_CONTACT_ID","Identifiant contact externe"); +if (!defined("_INDIVIDUAL")) define("_INDIVIDUAL", "Particulier"); if (!defined("_CONTACT_TARGET")) define("_CONTACT_TARGET", "Pour quel contact est il possible d'utiliser ce type ?"); if (!defined("_CONTACT_TARGET_LIST")) define("_CONTACT_TARGET_LIST", "Cible du type de contact"); if (!defined("_CONTACT_TYPE_CREATION")) define("_CONTACT_TYPE_CREATION", "Possibilité de créer un contact de ce type hors panneau d'administration ?"); @@ -1109,6 +1114,14 @@ if (!defined("_CHOOSE_A_CONTACT")) define("_CHOOSE_A_CONTACT","Choisissez un con if (!defined("_CREATE_CONTACTS")) define("_CREATE_CONTACTS","Tous les contacts"); if (!defined("_LINKED_CONTACT")) define("_LINKED_CONTACT","Lié au contact"); +if (!defined("_COMMUNICATION_TYPE")) define("_COMMUNICATION_TYPE","Moyen de communication"); +if (!defined("_COMMUNICATION_VALUE")) define("_COMMUNICATION_VALUE","Valeur"); +if (!defined("_COMMUNICATION_ADDED")) define("_COMMUNICATION_ADDED","Communication ajoutée"); +if (!defined("_COMMUNICATION_MODIFIED")) define("_COMMUNICATION_MODIFIED","Communication modifiée"); +if (!defined("_COMMUNICATION_DELETED")) define("_COMMUNICATION_DELETED","Communication supprimée"); +if (!defined("_CHOOSE_COMMUNICATION_TYPES")) define("_CHOOSE_COMMUNICATION_TYPES","Choissisez le moyen de communication"); +if (!defined("_CONTACT_COMMUNICATION_DEFINE")) define("_CONTACT_COMMUNICATION_DEFINE","Moyen de communication défini"); + //// INDEXING SEARCHING if (!defined("_NO_COLLECTION_ACCESS_FOR_THIS_USER")) define("_NO_COLLECTION_ACCESS_FOR_THIS_USER", "Aucun accès aux collections documentaires pour cet utilisateur"); if (!defined("_CREATION_DATE")) define("_CREATION_DATE", "Date de création"); @@ -2067,7 +2080,8 @@ if (!defined('_UPDATE_DESC_END')) define('_UPDATE_DESC_END', 'Mise à jour réussie'); if (!defined('_NO_AVAILABLE_TAG_TO_UPDATE')) define('_NO_AVAILABLE_TAG_TO_UPDATE', 'Aucune version disponible pour une mise à jour'); - +if (!defined('_SAVE_NUMERIC_PACKAGE')) + define('_SAVE_NUMERIC_PACKAGE', 'Enregistrer un pli numérique'); //PARAMETERS if(!defined('_ID_IS_EMPTY_CONTROLLER')) define('_ID_IS_EMPTY_CONTROLLER',' L\'identifiant est vide'); diff --git a/apps/maarch_entreprise/xml/IVS/data_types.xml b/apps/maarch_entreprise/xml/IVS/data_types.xml index 84329872e49..0cc8d8d093f 100755 --- a/apps/maarch_entreprise/xml/IVS/data_types.xml +++ b/apps/maarch_entreprise/xml/IVS/data_types.xml @@ -53,6 +53,8 @@ <enumeration value="set" /> <enumeration value="mass" /> <enumeration value="search" /> + <enumeration value="destUser" /> + <enumeration value="download" /> </dataType> <dataType name="size" base="string"> <enumeration value="full" /> diff --git a/apps/maarch_entreprise/xml/IVS/validation_rules.xml b/apps/maarch_entreprise/xml/IVS/validation_rules.xml index a2a46e38f44..bb5738f53d8 100755 --- a/apps/maarch_entreprise/xml/IVS/validation_rules.xml +++ b/apps/maarch_entreprise/xml/IVS/validation_rules.xml @@ -224,6 +224,7 @@ <parameter name="website" type="string" /> <parameter name="mycontact" type="string" /> <parameter name="dir" type="identifier" /> + <parameter name="external_contact_id" type="string" /> </validationRule> <validationRule name="admin_action" extends="standardForm" mode="error"> @@ -349,12 +350,16 @@ <parameter name="firstname" type="string" /> <parameter name="function" type="string" /> <parameter name="is_corporate" type="YN" /> + <parameter name="is_external" type="YN" /> + <parameter name="external_contact_id" type="string" /> <parameter name="lastname" type="personname" /> <parameter name="society" type="string" /> <parameter name="society_short" type="string" /> <parameter name="title" type="string" /> <parameter name="dir" type="identifier" /> <parameter name="mycontact" type="identifier" /> + <parameter name="communication_type" type="string" /> + <parameter name="communication_value" type="string" /> </validationRule> <validationRule name="contactConfirm" extends="standardForm" mode="error"> diff --git a/apps/maarch_entreprise/xml/config.xml.default b/apps/maarch_entreprise/xml/config.xml.default index 75cf629ec53..d32812bb142 100755 --- a/apps/maarch_entreprise/xml/config.xml.default +++ b/apps/maarch_entreprise/xml/config.xml.default @@ -38,6 +38,7 @@ <contact_types>contact_types</contact_types> <contact_purposes>contact_purposes</contact_purposes> <contact_addresses>contact_addresses</contact_addresses> + <contact_communication>contact_communication</contact_communication> <tags>tags</tags> </TABLENAME> <WORKBATCH> @@ -131,6 +132,11 @@ <default_category>incoming</default_category> </categories> </COLLECTION> + <COLLECTION> + <id>archive_transfer_coll</id> + <label>_ARCHVIE_TRANSFER_COLL</label> + <table>message_exchange</table> + </COLLECTION> <HISTORY> <usersdel>true</usersdel> <usersban>true</usersban> @@ -190,6 +196,9 @@ <contact_addresses_del>true</contact_addresses_del> <contact_addresses_add>true</contact_addresses_add> <contact_addresses_up>true</contact_addresses_up> + <contact_communication_del>true</contact_communication_del> + <contact_communication_add>true</contact_communication_add> + <contact_communication_up>true</contact_communication_up> </HISTORY> <KEYWORDS> <id>ERR</id> diff --git a/apps/maarch_entreprise/xml/entreprise.xml b/apps/maarch_entreprise/xml/entreprise.xml index 80bc6ab04df..948681f3dbd 100755 --- a/apps/maarch_entreprise/xml/entreprise.xml +++ b/apps/maarch_entreprise/xml/entreprise.xml @@ -29,6 +29,10 @@ <id>courier</id> <label>_COURIER</label> </nature> + <nature with_reference="true"> + <id>message_exchange</id> + <label>_NUMERIC_PACKAGE</label> + </nature> <nature with_reference="false"> <id>other</id> <label>_OTHER</label> diff --git a/apps/maarch_entreprise/xml/extensions.xml b/apps/maarch_entreprise/xml/extensions.xml index adc2241b4b1..bf5c3cfa834 100755 --- a/apps/maarch_entreprise/xml/extensions.xml +++ b/apps/maarch_entreprise/xml/extensions.xml @@ -155,6 +155,11 @@ <mime>application/octet-stream</mime> <index_frame_show>false</index_frame_show> </FORMAT> + <FORMAT> + <name>XML</name> + <mime>application/xml</mime> + <index_frame_show>true</index_frame_show> + </FORMAT> <FORMAT> <name>TXT</name> <mime>text/plain</mime> diff --git a/apps/maarch_entreprise/xml/m2m_config.xml b/apps/maarch_entreprise/xml/m2m_config.xml new file mode 100644 index 00000000000..ba15eaff609 --- /dev/null +++ b/apps/maarch_entreprise/xml/m2m_config.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<ROOT> + <res_letterbox> + <type_id>101</type_id> + <status>INIT</status> + <priority>2</priority> + </res_letterbox> + <res_attachments> + <attachment_type>simple_attachment</attachment_type> + </res_attachments> + <contacts_v2> + <contact_type>100</contact_type> + </contacts_v2> + <contact_addresses> + <contact_purpose_id>1</contact_purpose_id> + </contact_addresses> + <basketRedirection_afterUpload>InitBasket</basketRedirection_afterUpload><!--basketId--> + <m2m_communication>http://bblier:maarch@192.168.1.202/maarch_v2</m2m_communication><!--moyen de communication de l'instance : email ou uri --> +</ROOT> diff --git a/rest/index.php b/rest/index.php index fa49e26f030..c7ef7e21f57 100755 --- a/rest/index.php +++ b/rest/index.php @@ -298,6 +298,7 @@ $app->get('/listinstance/{id}', \Entity\controllers\ListInstanceController::clas //Contacts $app->post('/contacts', \Contact\controllers\ContactController::class . ':create'); +$app->get('/contact/checkCommunication', \Core\Controllers\ContactController::class . ':getCheckCommunication'); //Templates $app->post('/templates/{id}/duplicate', \Template\controllers\TemplateController::class . ':duplicate'); diff --git a/src/app/contact/controllers/ContactController.php b/src/app/contact/controllers/ContactController.php index e3efedee7e3..30155b33020 100644 --- a/src/app/contact/controllers/ContactController.php +++ b/src/app/contact/controllers/ContactController.php @@ -71,4 +71,27 @@ class ContactController return $response->withJson(['contactId' => $contactId, 'addressId' => $addressId]); } + + public function getCheckCommunication(Request $request, Response $response, $aArgs) { + $data = $request->getParams(); + + if (isset($data['contactId'])) { + $contactId = $data['contactId']; + $obj = ContactModel::getCommunicationByContactId([ + 'contactId' => $contactId + ]); + } else { + return $response + ->withStatus(500) + ->withJson(['errors' => _ID . ' ' . _IS_EMPTY]); + } + + $data = [ + $obj, + ]; + + return $response->withJson($data); + } + + } diff --git a/src/app/contact/models/ContactModelAbstract.php b/src/app/contact/models/ContactModelAbstract.php index 5b4c42f2d01..29d77be0b45 100644 --- a/src/app/contact/models/ContactModelAbstract.php +++ b/src/app/contact/models/ContactModelAbstract.php @@ -207,4 +207,21 @@ class ContactModelAbstract ]); } } + + public static function getCommunicationByContactId(array $aArgs = []) + { + ValidatorModel::notEmpty($aArgs, ['contactId']); + ValidatorModel::stringType($aArgs, ['contactId']); + + $aReturn = DatabaseModel::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['contact_communication'], + 'where' => ['contact_id = ?'], + 'data' => [$aArgs['contactId']], + ]); + + return $aReturn[0]; + } + + } -- GitLab