diff --git a/apps/maarch_entreprise/indexing_searching/search_adv.php b/apps/maarch_entreprise/indexing_searching/search_adv.php index 14a42ba6589df241aad75ee1fa44625c22cdaaae..5fc3dacb3a9efa75300219bf490ac4ff8aea5902 100755 --- a/apps/maarch_entreprise/indexing_searching/search_adv.php +++ b/apps/maarch_entreprise/indexing_searching/search_adv.php @@ -574,11 +574,10 @@ if ($core_tools->is_module_loaded('basket') == true) { <label for="sender" class="bold"><?php echo _SENDER; ?></label> </div> <div class="adv_search_field indexing_field"> - <i id="sender_icon_contactsUsers" class="fa fa-user" onclick="switchAutoCompleteType('sender','contactsUsers', true);" style="color:#135F7F;display: inline-block;cursor:pointer;" title="<?php echo _CONTACTS_USERS_LIST; ?>" ></i> <i id="sender_icon_entities" class="fa fa-sitemap" onclick="switchAutoCompleteType('sender','entities');" style="display: inline-block;cursor:pointer;" title="<?php echo _ENTITIES_LIST; ?>" ></i> <span style="position:relative;"> <div class="typeahead__container"><div class="typeahead__field"> <span class="typeahead__query"> - <input name="sender" type="text" id="sender" autocomplete="off" placeholder="<?php echo _CONTACTS_USERS_SEARCH; ?>"/> + <input name="sender" type="text" id="sender" autocomplete="off" placeholder="<?php echo _CONTACTS_USERS_SEARCH; ?>" title="<?php echo _CONTACTS_USERS_SEARCH; ?>"/> <input type="hidden" name="meta[]" value="sender#sender#input_text" /> </span> </div></div> @@ -598,11 +597,10 @@ if ($core_tools->is_module_loaded('basket') == true) { <label for="recipient" class="bold"><?php echo _DEST; ?></label> </div> <div class="adv_search_field indexing_field"> - <i id="recipient_icon_contactsUsers" class="fa fa-user" onclick="switchAutoCompleteType('recipient','contactsUsers', true);" style="color:#135F7F;display: inline-block;cursor:pointer;" title="<?php echo _CONTACTS_USERS_LIST; ?>" ></i> <i id="recipient_icon_entities" class="fa fa-sitemap" onclick="switchAutoCompleteType('recipient','entities');" style="display: inline-block;cursor:pointer;" title="<?php echo _ENTITIES_LIST; ?>" ></i> <span style="position:relative;"> <div class="typeahead__container"><div class="typeahead__field"> <span class="typeahead__query"> - <input name="recipient" type="text" id="recipient" autocomplete="off" placeholder="<?php echo _CONTACTS_USERS_SEARCH; ?>"/> + <input name="recipient" type="text" id="recipient" autocomplete="off" placeholder="<?php echo _CONTACTS_USERS_SEARCH; ?>" title="<?php echo _CONTACTS_USERS_SEARCH; ?>"/> <span class="green_asterisk" style="position: absolute;right: -10px;top: 0px;"><i class="fa fa-star"></i></span> <input type="hidden" name="meta[]" value="recipient#recipient#input_text" /> </span> diff --git a/apps/maarch_entreprise/js/indexing.js b/apps/maarch_entreprise/js/indexing.js index 7dd901911195fcab5f6448583771787b8481f6fb..116a206f72d28650ef3e328190e1bd741c4a26c3 100755 --- a/apps/maarch_entreprise/js/indexing.js +++ b/apps/maarch_entreprise/js/indexing.js @@ -592,12 +592,7 @@ function loadInfoContact(){ } function initSenderRecipientAutocomplete(inputId, mode, alternateVersion, cardId) { - var route = ''; - if (mode == 'contactsUsers') { - route = '../../rest/autocomplete/contactsUsers'; - } else { - route = '../../rest/autocomplete/entities'; - } + var route = '../../rest/autocomplete/all'; $j("#" + inputId).typeahead({ // order: "asc", @@ -613,9 +608,9 @@ function initSenderRecipientAutocomplete(inputId, mode, alternateVersion, cardId type: "GET", url: route, data: { - search : query, - onlyContacts : alternateVersion, - color : !alternateVersion + search : query, + noContactsGroups : true, + color : !alternateVersion } } } diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php index b78f012436a6aa165c6ff34d2f2e9bf2ebe69eff..a9169bbf60c5a14ab571ecc71a1b420b5c4ecd46 100755 --- a/apps/maarch_entreprise/lang/en.php +++ b/apps/maarch_entreprise/lang/en.php @@ -4439,7 +4439,7 @@ if (!defined('_ENTITIES_LIST')) { define('_ENTITIES_LIST', 'Entities list'); } if (!defined('_CONTACTS_USERS_SEARCH')) { - define('_CONTACTS_USERS_SEARCH', 'Contacts / users search'); + define('_CONTACTS_USERS_SEARCH', 'Contacts / users / entities search'); } if (!defined('_CONTACTS_USERS_GROUPS_SEARCH')) { define('_CONTACTS_USERS_GROUPS_SEARCH', 'Contacts / users / contacts groups search'); diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index c9ed8056d2009e2e7b090daf535320686741746c..a6fffa9e674c99177fbc14ced1059d69ddc830b9 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -4651,7 +4651,7 @@ if (!defined('_ENTITIES_LIST')) { define('_ENTITIES_LIST', 'Répertoire entités'); } if (!defined('_CONTACTS_USERS_SEARCH')) { - define('_CONTACTS_USERS_SEARCH', 'Rechercher un contact / utilisateur'); + define('_CONTACTS_USERS_SEARCH', 'Rechercher un contact / utilisateur / entité'); } if (!defined('_CONTACTS_USERS_GROUPS_SEARCH')) { define('_CONTACTS_USERS_GROUPS_SEARCH', 'Rechercher un contact / utilisateur / groupement de contacts'); diff --git a/apps/maarch_entreprise/lang/nl.php b/apps/maarch_entreprise/lang/nl.php index 63f4b5b00cb45113b3aac36656a65d1aec0e6e2b..f573d3532cc0bec4b807c18c1c362e06aa4bb2f3 100755 --- a/apps/maarch_entreprise/lang/nl.php +++ b/apps/maarch_entreprise/lang/nl.php @@ -1517,7 +1517,7 @@ if (!defined('_REDACTOR')) { define('_REDACTOR', 'Opsteller');} if (!defined('_ASSIGNEE')) { define('_ASSIGNEE', 'Toegekende persoon');} if (!defined('_CONTACTS_USERS_LIST')) { define('_CONTACTS_USERS_LIST', 'Directory contacten / gebruikers');} if (!defined('_ENTITIES_LIST')) { define('_ENTITIES_LIST', 'Directory eenheden');} -if (!defined('_CONTACTS_USERS_SEARCH')) { define('_CONTACTS_USERS_SEARCH', 'Een contact / gebruiker zoeken');} +if (!defined('_CONTACTS_USERS_SEARCH')) { define('_CONTACTS_USERS_SEARCH', 'Contacts / users / entities search');} // _TO_TRANSLATE if (!defined('_CONTACTS_USERS_GROUPS_SEARCH')) { define('_CONTACTS_USERS_GROUPS_SEARCH', 'Een contact / gebruiker / contactgroepering zoeken');} if (!defined('_USER_MAARCH_PARAPHEUR')) { define('_USER_MAARCH_PARAPHEUR', 'Maarch vloeiboek gebruiker');} if (!defined('_DOCUMENT_WITH_NOTES')) { define('_DOCUMENT_WITH_NOTES', 'Document met opmerkingen');} diff --git a/apps/maarch_entreprise/print.php b/apps/maarch_entreprise/print.php deleted file mode 100644 index 322deb9ec8cd83f1cb4e2bfda8a2f289c5482b82..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/print.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -require_once('core/class/PrintControler.php'); - -if (isset($_REQUEST['id']) && $_REQUEST['id'] <> '') { - $print = new PrintControler($_REQUEST['id']); -} else { - $print = new PrintControler(); -} - -if (!empty($_SESSION['error'])) { - - ?> - <script language="javascript" > - window.opener.location.reload(); - window.close(); - </script> - <?php - -} else { - if ( - file_exists($_SESSION['config']['tmppath'] . $_SESSION['print']['filename']) - && $_SESSION['print']['filename'] <> '' - ) { - header('Pragma: public'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - //header('Cache-Control: public'); - //header('Content-Description: File Transfer'); - header('Content-Type: application/pdf'); - header('Content-Disposition: inline; filename=print_maarch.pdf;'); - //header('Content-Transfer-Encoding: binary'); - readfile($_SESSION['config']['tmppath'] . $_SESSION['print']['filename']); - unlink($_SESSION['config']['tmppath'] . $_SESSION['print']['filename']); - } else { - echo _NO_DOC_OR_NO_RIGHTS; - } - exit; -} diff --git a/apps/maarch_entreprise/xml/print.xml b/apps/maarch_entreprise/xml/print.xml deleted file mode 100644 index 08a97907f4d53e0e768f0c385df53410155e4e6a..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/xml/print.xml +++ /dev/null @@ -1,125 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ROOT> - <!-- - letterbox_coll - --> - <letterbox_coll> - <FIELD> - <LIBELLE>Num GED</LIBELLE> - <DATABASE_FIELD>res_view_letterbox.res_id</DATABASE_FIELD> - </FIELD> - <!-- line 1 --> - <FIELD> - <LIBELLE>Catégorie du courrier</LIBELLE> - <DATABASE_FIELD>category_id</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Priorité</LIBELLE> - <DATABASE_FIELD>priority</DATABASE_FIELD> - </FIELD> - <!-- line 2 --> - <FIELD> - <LIBELLE>Date d'arrivée</LIBELLE> - <DATABASE_FIELD>admission_date</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Date limite de traitement</LIBELLE> - <DATABASE_FIELD>process_limit_date</DATABASE_FIELD> - </FIELD> - <!-- line 3 --> - <FIELD> - <LIBELLE>Date de création</LIBELLE> - <DATABASE_FIELD>creation_date</DATABASE_FIELD> - </FIELD> - <!-- line 4 --> - <FIELD> - <LIBELLE>Date du document</LIBELLE> - <DATABASE_FIELD>doc_date</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Type de courrier</LIBELLE> - <DATABASE_FIELD>type_label</DATABASE_FIELD> - </FIELD> - <!-- line 5 --> - <FIELD> - <LIBELLE>Dossier</LIBELLE> - <DATABASE_FIELD>folder_name</DATABASE_FIELD> - </FIELD> - <!-- line 6 --> - <FIELD> - <LIBELLE>Statut</LIBELLE> - <DATABASE_FIELD>status</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Num chrono</LIBELLE> - <DATABASE_FIELD>alt_identifier</DATABASE_FIELD> - </FIELD> - <!-- other infos--> - <FIELD> - <LIBELLE>Nom de l'entité primaire de l'utilisateur ayant enregistré le courrier</LIBELLE> - <DATABASE_FIELD>initiator</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>ID de l'expéditeur</LIBELLE> - <DATABASE_FIELD>contact_id</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Prénom de l'expéditeur</LIBELLE> - <DATABASE_FIELD>contact_firstname</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Nom de l'expéditeur</LIBELLE> - <DATABASE_FIELD>contact_lastname</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Société de l'expéditeur</LIBELLE> - <DATABASE_FIELD>contact_society</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Nom du contact interne</LIBELLE> - <DATABASE_FIELD>user_lastname</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Prénom du contact interne</LIBELLE> - <DATABASE_FIELD>user_firstname</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Service destinataire</LIBELLE> - <DATABASE_FIELD>entity_label</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Destinataire principal</LIBELLE> - <DATABASE_FIELD>dest_user</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Objet</LIBELLE> - <DATABASE_FIELD>subject</DATABASE_FIELD> - </FIELD> - <FIELD> - <LIBELLE>Responsable de versement</LIBELLE> - <DATABASE_FIELD>typist</DATABASE_FIELD> - </FIELD> - <FUNCTIONS> - <FUNCTION> - <LIBELLE>Contacts multiples</LIBELLE> - <CALL>retrieve_multi_contacts</CALL> - </FUNCTION> - <FUNCTION> - <LIBELLE>Services en copie</LIBELLE> - <CALL>retrieve_copies</CALL> - </FUNCTION> - <FUNCTION> - <LIBELLE>Notes libres</LIBELLE> - <CALL>free_notes</CALL> - </FUNCTION> - <FUNCTION> - <LIBELLE>Notes</LIBELLE> - <CALL>retrieve_notes</CALL> - </FUNCTION> - <FUNCTION> - <LIBELLE>Circuit visa</LIBELLE> - <CALL>retrieve_VisaWorkflow</CALL> - </FUNCTION> - </FUNCTIONS> - </letterbox_coll> -</ROOT> diff --git a/core/class/PrintControler.php b/core/class/PrintControler.php deleted file mode 100644 index 02798586807ab0c327ee40fe5eaa84268c87f22e..0000000000000000000000000000000000000000 --- a/core/class/PrintControler.php +++ /dev/null @@ -1,861 +0,0 @@ -<?php -/*------------------------------------------------------------------------------ -- Require needed classes -------------------------------------------------------------------------------*/ -require_once('core/class/class_functions.php'); -require_once('core/class/class_core_tools.php'); -require_once('core/class/class_db.php'); -require_once('core/class/class_history.php'); -require_once('apps/maarch_entreprise/class/class_business_app_tools.php'); -require_once('core/class/class_security.php'); - -require_once('apps/maarch_entreprise/tools/pdfb/fpdf_1_7/fpdf.php'); -require_once('apps/maarch_entreprise/tools/pdfb/fpdf_1_7/fpdi.php'); -require_once('apps/maarch_entreprise/tools/phpqrcode/qrlib.php'); - -class EmptyObject { - function __construct() - { - $test = ''; - } -} - -/*------------------------------------------------------------------------------ -- PrintControler -------------------------------------------------------------------------------*/ -class PrintControler extends PrintFunctions -{ - /*-------------------------------------------------------------------------- - - Attributes - --------------------------------------------------------------------------*/ - // Public - // Private - public $collection = false; - public $configuration = false; - - public $object_print = false; - public $array_print = false; - - /*-------------------------------------------------------------------------- - - Methods - --------------------------------------------------------------------------*/ - // Public - function __construct($resId = '') - { - $core = new core_tools(); - $core->load_lang(); - $this->collection = $_SESSION['collection_id_choice']; - $this->load_configuration(); - if ($resId <> '') { - $this->retrieve_datas($resId); - } else { - $this->retrieve_datas($resId); - } - $this->process_functions(); - $_SESSION['print']['filename'] = $this->make_pdf($resId); - } - - // Private - private function load_configuration() - { - // Retrieve id to create paths (app & custom) - $id_app = $_SESSION['config']['app_id']; - $id_custom = false; - if (!empty($_SESSION['custom_override_id'])) - $id_custom = $_SESSION['custom_override_id']; - $collection = $this->collection; - - // Retrieve name for print configuration file - $fileName = 'print.xml'; - - // Make paths to xml dir - $pathToDir_app = 'apps/' . $id_app . '/xml/'; - $pathToDir_custom = 'custom/' . $id_custom . '/' . $pathToDir_app; - - $pathToFile_app = $pathToDir_app . $fileName; - $pathToFile_custom = $pathToDir_custom . $fileName; - - // Load the configuration file - if ($id_custom && file_exists($pathToFile_custom)) - $configuration = simplexml_load_file($pathToFile_custom); - else - $configuration = simplexml_load_file($pathToFile_app); - - // Store interesting part of the configuration - $this->configuration = $configuration->{$collection}; - } - - private function retrieve_datas($resId = '') - { - // Retrieve the query - if ($resId <> '') { - $query = $this->make_query($resId); - } else { - $query = $this->make_query(); - } - // Retrieve datas - $db = new Database(); - if ($resId <> '') { - $stmt = $db->query($query); - } else { - $stmt = $db->query($query, $_SESSION['last_select_query_parameters']); - } - - $i = 0; - $this->object_print = new EmptyObject(); - while($line = $stmt->fetchObject()) { - $this->object_print->{$i} = $line; - $i++; - } - //var_dump($this->object_print);exit; - } - - private function make_query($resId = '') - { - // Retrieve the end of last select query on the list - $endLastQuery = substr( - $_SESSION['last_select_query'], - strpos( - $_SESSION['last_select_query'], - 'FROM' - ) - ); - - if ($resId <> '') { - $security = new security(); - // retrieve view name - $view = $security->retrieve_view_from_coll_id($this->collection); - $endLastQuery = 'FROM ' . $view . ' where res_id = ' . $resId; - // TEST SECURITY ACCESS !!!! - $right = $security->test_right_doc($this->collection, $resId); - if (!$right) { - $endLastQuery .= ' and 1=-1'; - } - } - // Create template for the new query - $query_template = 'SELECT '; - $query_template .= '##DATABASE_FIELDS## '; - $query_template .= $endLastQuery; - - // Retrieve ##DATABASE_FIELDS## - $fields = $this->configuration->FIELD; - $i_max = count($fields); - $database_fields = false; - for($i=0; $i<$i_max; $i++) { - $field = $fields[$i]; - $database_fields .= $field->DATABASE_FIELD; - if ($i != ($i_max-1)) - $database_fields .= ', '; - } - - // Return query - return str_replace( - '##DATABASE_FIELDS##', - $database_fields, - $query_template - ); - } - - private function retrieve_encoding($string) - { - return mb_detect_encoding($string, 'UTF-8', true); - } - - private function unprotect_string($string) - { - return str_replace("\'", "'", $string); - } - - private function process_functions() - { - $functions = $this->configuration->FUNCTIONS->FUNCTION; - $functions_max = count($functions); - for($i=0; $i<$functions_max; $i++) { - $function = $functions[$i]; - $call = $function->CALL; - if (method_exists($this, $call)) - eval('$this->' . $call . '(\'' . $function->LIBELLE . '\');'); - } - } - - private function make_pdf($resId) - { - $functions = new functions(); - $db = new Database(); - - $this->array_print = $functions->object2array($this->object_print); - //var_dump($this->array_print);exit; - - if (count((array)$this->array_print) == 0) { - return false; - } - - $pdf= new fpdi();//create a new document PDF - - $cptResToPrint = count($this->array_print); - - for ($cpt=0;$cpt<$cptResToPrint;$cpt++) { - $y = 0; - - //$pdf->addPage(); //Add a blank page - - // Retrieve id to create paths (app & custom) - $id_app = $_SESSION['config']['app_id']; - $id_custom = false; - if (!empty($_SESSION['custom_override_id'])) - $id_custom = $_SESSION['custom_override_id']; - - // Retrieve name for template file - $fileName_pdfTemplate = 'TemplatePrint.pdf'; - - // Make paths to pdf dir - $pathToDir_pdfTemplate = 'apps/' . $id_app . '/indexing_searching/'; - $pathToDir_custom_pdfTemplate = 'custom/' . $id_custom . '/' . $pathToDir_pdfTemplate; - - $pathToFile_pdfTemplate = $pathToDir_pdfTemplate . $fileName_pdfTemplate; - $pathToFile_custom_pdfTemplate = $pathToDir_custom_pdfTemplate . $fileName_pdfTemplate; - - // Load the pdf template file - if ($id_custom && file_exists($pathToFile_custom_pdfTemplate)) - $pdfTemplate = $pathToFile_custom_pdfTemplate; - else - $pdfTemplate = $pathToFile_pdfTemplate; - - $pageCount = $pdf->setSourceFile($pdfTemplate); - $tplIdx = $pdf->importPage(1); - - $pdf->addPage(); - $pdf->useTemplate($tplIdx); - - /**********************************************************************/ - //PRINT DATE - $pdf->SetFont('Arial','',10); - $pdf->Cell(40,5,utf8_decode(_PRINT_DATE . ' : ') . date('d-m-Y'),0,0, 'L', false); - - //APPLICATION NAME - $pdf->SetFont('Arial','B',11); - $pdf->Cell(110,5, utf8_decode($_SESSION['config']['applicationname']),0,1, 'C', false); - - $pdf->SetFont('Arial','B',10); - - //INITIATOR - if (!empty($resId)) { - $filename_QR = $_SESSION['config']['tmppath'].DIRECTORY_SEPARATOR.$_SESSION['user']['UserId'] . time() . rand() ."_QRCODE.png"; - $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => 'QrCodePrefix']); - $prefix = ''; - if ($parameter['param_value_int'] == 1) { - $prefix = 'Maarch_'; - } - QRcode::png($prefix . $resId, $filename_QR, 0, 10); - - $pdf->Image($filename_QR, 158, 5, 40, 40); - } - $pdf->Cell(50, 5, "", 0, 0, 'L', false); - if ($this->array_print[$cpt]['initiator'] <> '') { - $stmt = $db->query( - "select entity_label from entities where entity_id = ?", - array($this->array_print[$cpt]['initiator']) - ); - $resultEntity = $stmt->fetchObject(); - $pdf->MultiCell(90, 5, utf8_decode(_INITIATOR . ' : ' - . $resultEntity->entity_label . " (" . $this->array_print[$cpt]['initiator'] . ")"), 0, 'C', false); - } elseif($this->array_print[$cpt]['typist'] <> '') { - $primaryEntity = \User\models\UserModel::getPrimaryEntityById(['id' => $this->array_print[$cpt]['typist'], 'select' => ['users_entities.entity_id', 'entities.entity_label']]); - $pdf->MultiCell(90, 5, utf8_decode(_INITIATOR . ' : ' - . $primaryEntity['entity_label'] . " (" . $primaryEntity['entity_id'] . ")"), 0, 'C', false); - } - $pdf->SetFont('Arial', 'B', 14); - - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - //TITLE - if($this->array_print[$cpt]['alt_identifier'] <> '' && _ID_TO_DISPLAY == 'chrono_number'){ - $fileNumber = $this->array_print[$cpt]['alt_identifier']; - } else { - $fileNumber = $this->array_print[$cpt]['res_id']; - } - $pdf->Cell(150,5,utf8_decode(_PRINTED_FILE_NUMBER . ' : ') . $fileNumber, 1, 1, 'C', false); - - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',10); - - /**********************************************************************/ - - //TITLE DOCUMENT - $pdf->Cell(36,5,utf8_decode(_INFORMATIONS_OF_THE_DOCUMENT),0,1, 'L', false); - - $pdf->SetFont('Arial','',9); - - //LINE 1 - if ($this->array_print[$cpt]['category_id'] <> '' || $this->array_print[$cpt]['priority'] <> '') { - if (count($_SESSION['coll_categories']) == 0) { - $categoryLabel = $_SESSION['mail_categories'][$this->array_print[$cpt]['category_id']]; - } else { - $categoryLabel = $_SESSION['coll_categories']['letterbox_coll'][$this->array_print[$cpt]['category_id']]; - } - //CATEGORY - $pdf->Cell(91,5,utf8_decode(_PRINT_CATEGORY . ' : ' - . html_entity_decode($categoryLabel)),1,0, 'L', false); - //PRIORITY - foreach ($_SESSION['mail_priorities_id'] as $key => $prioValue) { - if ($prioValue == $this->array_print[$cpt]['priority']) { - $fakeId = $key; - } - } - - $pdf->Cell(91,5,utf8_decode(_PRINT_PRIORITY . ' : ' . $_SESSION['mail_priorities'][$fakeId]),1,1, 'L', false); - } - - //LINE 2 - if ($this->array_print[$cpt]['admission_date'] <> '' || $this->array_print[$cpt]['process_limit_date'] <> '') { - //ADMISSION DATE - $pdf->Cell(91,5,utf8_decode(_PRINT_ADMISSION_DATE . ' : ') - . $functions->format_date_db($this->array_print[$cpt]['admission_date'], false),1,0, 'L', false); - //PROCESS_LIMIT_DATE - $pdf->Cell(91,5,utf8_decode(_PRINT_PROCESS_LIMIT_DATE . ' : ') - . $functions->format_date_db($this->array_print[$cpt]['process_limit_date'], false),1,1, 'L', false); - } - - //LINE 3, 4 - if ($this->array_print[$cpt]['doc_date'] <> '') { - //CREATION DATE - $pdf->Cell(91,5,utf8_decode(_CREATED_ON . ' : ') - . $functions->format_date_db($this->array_print[$cpt]['creation_date'], false),1,0, 'L', false); - - //DOC DATE - $pdf->Cell(91,5,utf8_decode(_PRINT_DOC_DATE . ' : ') - . $functions->format_date_db($this->array_print[$cpt]['doc_date'], false),1,0, 'L', false); - - //DOCTYPE - $pdf->Cell(91,5,utf8_decode(_DOCTYPE . ' : ' . $this->array_print[$cpt]['type_label']),1,1, 'L', false); - } else { - //CREATION DATE - $pdf->Cell(91,5,utf8_decode(_CREATED_ON . ' : ') - . $functions->format_date_db($this->array_print[$cpt]['creation_date'], false),1,0, 'L', false); - - //DOCTYPE - $pdf->Cell(91,5,utf8_decode(_DOCTYPE . ' : ' . $this->array_print[$cpt]['type_label']),1,1, 'L', false); - } - - //LINE 5 - if ($this->array_print[$cpt]['folder_name'] <> '') { - //FOLDER - $pdf->Cell(91,5,utf8_decode(_PRINT_FOLDER . ' : ' . $this->array_print[$cpt]['folder_name']),1,0, 'L', false); - } - - //LINE 6 - if ($this->array_print[$cpt]['status'] <> '' || $this->array_print[$cpt]['alt_identifier'] <> '') { - require_once('core/class/class_manage_status.php'); - $status_obj = new manage_status(); - $res_status = $status_obj->get_status_data($this->array_print[$cpt]['status'], ''); - //STATUS - $pdf->Cell(91,5,utf8_decode(_PRINT_STATUS . ' : ' . $res_status['LABEL']),1,0, 'L', false); - //ALT IDENTIFIER - $pdf->Cell(91,5,utf8_decode(_PRINT_ALT_IDENTIFIER . ' : ' . $this->array_print[$cpt]['alt_identifier']),1,1, 'L', false); - } - - /**********************************************************************/ - //UNIQUE CONTACT - if ($this->array_print[$cpt]['contact_id'] <> '') { - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - $stmt = $db->query( - "SELECT address_id FROM res_view_letterbox WHERE res_id = ?", - array($this->array_print[$cpt]['res_id']) - ); - $resultAddressId = $stmt->fetchObject(); - - $contactInfos = $this->getContactInfos($this->array_print[$cpt]['contact_id'], $resultAddressId->address_id); - //CONTACT - $pdf->Cell(182,5,utf8_decode(_PRINT_CONTACT),0,1, 'C', false); - - $pdf->SetFont('Arial','',11); - - $pdf->MultiCell(182,5,utf8_decode($contactInfos),1, 'C', false); - } - - //UNIQUE INTERNAL CONTACT - if ($this->array_print[$cpt]['user_lastname'] <> '') { - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - //CONTACT - $pdf->Cell(182,5,utf8_decode(_PRINT_CONTACT),0,1, 'C', false); - - $pdf->SetFont('Arial','',11); - - $pdf->MultiCell(182,5,utf8_decode($this->array_print[$cpt]['user_firstname'] . " " . $this->array_print[$cpt]['user_lastname']),1, 'C', false); - } - - /**********************************************************************/ - //MULTI CONTACT - if ($this->array_print[$cpt]['retrieve_multi_contacts'] <> '') { - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - $pdf->Cell(182,5,utf8_decode(_MULTI_CONTACTS),0,1, 'C', false); - - $pdf->SetFont('Arial','',11); - - $pdf->MultiCell(182,5,utf8_decode($this->array_print[$cpt]['retrieve_multi_contacts']),1, 'L', false); - } - - /**********************************************************************/ - - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - //SUBJECT - $pdf->Cell(182,5,utf8_decode(_PRINT_SUBJECT),0,1, 'C', false); - - $pdf->SetFont('Arial','',11); - - $pdf->MultiCell(182,5, iconv('UTF-8', 'windows-1252', $this->unprotect_string($this->array_print[$cpt]['subject'])),1, 'L', false); - - /**********************************************************************/ - - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - $userInfos = $this->getUserInfo($this->array_print[$cpt]['dest_user']); - - //DESTINATION - $pdf->Cell(182,5,utf8_decode(_PRINT_PROCESS_ENTITY),0,1, 'C', false); - - $pdf->SetFont('Arial','B',11); - - $pdf->MultiCell(182,5,utf8_decode($this->array_print[$cpt]['entity_label']. "\r\n" . $userInfos),1, 'C', false); - - /**********************************************************************/ - - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - //COPIES - if ($this->array_print[$cpt]['retrieve_copies'] <> '') { - $pdf->Cell(182,5,utf8_decode(_PRINT_COPIES),0,1, 'C', false); - - $pdf->SetFont('Arial','',11); - - $pdf->MultiCell(182,5,utf8_decode($this->array_print[$cpt]['retrieve_copies']),1, 'L', false); - } - - /**********************************************************************/ - - //VISA WORKFLOW - if ($this->array_print[$cpt]['retrieve_VisaWorkflow'] <> '') { - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - $pdf->Cell(182,5,utf8_decode(strtoupper(_VISA_WORKFLOW)),0,1, 'C', false); - - $pdf->Cell(140,5,_ADMIN_USERS,1,0, 'C', false); - $pdf->Cell(42,5,_PROCESS_DATE,1,1, 'C', false); - $pdf->SetFont('Arial','',11); - foreach ($this->array_print[$cpt]['retrieve_VisaWorkflow'] as $key => $value) { - $signatory = ''; - if($value['signatory'] || ($value['requested_signature'] && empty($value['process_date']))){ - $signatory = ' ('._SIGNATORY.')'; - } else { - $signatory = ' ('._VISA_USER_SEARCH_MIN.')'; - } - $pdf->Cell(140,5,utf8_decode($key+1 . '. ' .$value['firstname']. ' ' . $value['lastname'] . $signatory),1,0, 'L', false); - $pdf->Cell(42,5,functions::format_date_db($value['process_date'], true, '', true),1,1, 'C', false); - } - - } - - /**********************************************************************/ - - //NOTES - if ($this->array_print[$cpt]['retrieve_notes'] <> '') { - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - $pdf->Cell(182,5,utf8_decode(_PRINT_NOTES),0,1, 'C', false); - - $pdf->SetFont('Arial','',11); - - $pdf->MultiCell(182,5,utf8_decode($this->array_print[$cpt]['retrieve_notes']),1, 'L', false); - } - - /**********************************************************************/ - - //FREE NOTES - if ($this->array_print[$cpt]['free_notes'] <> '') { - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - $pdf->SetFont('Arial','B',11); - - $pdf->Cell(182,5,utf8_decode(_PRINT_FREE_NOTES),0,1, 'C', false); - - $pdf->SetFont('Arial','',11); - - $pdf->MultiCell(182,5,utf8_decode($this->array_print[$cpt]['free_notes']),1, 'L', false); - } - - /**********************************************************************/ - - if (!empty($_SESSION['features']['further_informations'])) { - $pdf->SetFont('Arial', 'B', 11); - - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - //FURTHER INFORMATION - $pdf->Cell(182,5,utf8_decode(_PRINT_FURTHER_INFORMATIONS),0,1, 'C', false); - $pdf->SetFont('Arial', '', 11); - foreach ($_SESSION['features']['further_informations'] as $key => $value) { - $pdf->MultiCell(182, 5, utf8_decode($key . ' : ' . $value), 1, 'L', false); - } - } - - /**********************************************************************/ - - $pdf->SetFont('Arial','B',11); - - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - //BREAK A LINE - $pdf->SetY($pdf->GetY()+4); - - //TYPIST - $userInfos = $this->getUserInfo($this->array_print[$cpt]['typist']); - $pdf->Cell(150,5,utf8_decode(_PRINT_TYPIST . " : " . $userInfos),0,0, 'L', false); - /**********************************************************************/ - } - - //$pdf->AutoPrint(true); - - $printNameInTmp = "print_" - . $_SESSION['user']['UserId'] . '_' . rand() . ".pdf"; - $_SESSION['printNameInTmp'] = $printNameInTmp; - $pdfPath = $_SESSION['config']['tmppath'] . $printNameInTmp; - - $pdf->Output($pdfPath); - - return $printNameInTmp; - } -} - -class PrintFunctions -{ - /* ------------------------------------------------------------------------- - - Functions - - - - All the functions must have only one argument - - This argument is the name of the column for the header of the print - - - - Toutes les fonctions doivent avoir un argument et un seul - - Cette argument est le libelle de la colonne à afficher dans l'en-tête du - - fichier d'print - ------------------------------------------------------------------------- */ - function getContactInfos($contactId, $addressId = "") - { - $business = new business_app_tools(); - $tmp = $business->get_titles(); - $titles = $tmp['titles']; - - $contactInfos = ''; - - $db = new Database(); - - $query = "select * from contacts where id = ?"; - $stmt = $db->query($query, array($contactId)); - while($result = $stmt->fetchObject()) { - if ($result->society <> '' || $result->society_short <> '') { - if ($result->society <> '') { - $contactInfos = $result->society . ""; - } - if ($result->society_short <> '') { - $contactInfos .= ' ('.$result->society_short . ")"; - } - $contactInfos .= "\r\n"; - } - - if ($result->contact_title <> '' && $result->contact_lastname <> '') { - foreach(array_keys($titles) as $key) { - if($result->contact_title == $key) { - $result->contact_title = $titles[$key]; - } - } - $contactInfos .= $result->contact_title . ' '; - } - if ($result->contact_firstname <> '') { - $contactInfos .= $result->contact_firstname . ' '; - } - if ($result->contact_lastname <> '') { - $contactInfos .= $result->contact_lastname ."\r\n"; - } - if ($result->contact_purpose_label <> '') { - $contactInfos .= $result->contact_purpose_label . ' '; - } - if ($result->title <> '' && $result->lastname <> '') { - foreach(array_keys($titles) as $key) { - if($result->title == $key) { - $result->title = $titles[$key]; - } - } - $contactInfos .= $result->title . ' '; - } - if ($result->firstname <> '') { - $contactInfos .= $result->firstname . ' '; - } - if ($result->lastname <> '') { - $contactInfos .= $result->lastname; - } - if ($result->departement <> '') { - $contactInfos .= ', ' .$result->departement . ' '; - } - $contactInfos .= "\r\n"; - if ($result->address_num <> '') { - $contactInfos .= $result->address_num . ' '; - } - if ($result->address_street <> '') { - $contactInfos .= $result->address_street . ' '; - } - if ($result->address_complement <> '') { - $contactInfos .= $result->address_complement; - } - if ($result->address_postal_code <> '') { - $contactInfos .= $result->address_postal_code . ' '; - } - if ($result->address_town <> '') { - $contactInfos .= $result->address_town . ' '; - } - if ($result->address_country <> '') { - $contactInfos .= $result->address_country; - } - $contactInfos .= "\r\n"; - $contactInfos .= "\r\n"; - } - return $contactInfos; - } - - function getUserInfo($userId) - { - if ($userId <> '') { - $db = new Database(); - $stmt = $db->query("select firstname, lastname from users where user_id = ?", array($userId)); - $resultUsers = $stmt->fetchObject(); - if ($resultUsers->firstname <> '' && $resultUsers->lastname <> '') { - return $resultUsers->firstname . ' ' . $resultUsers->lastname; - } - } else { - return false; - } - } - - function retrieve_multi_contacts($libelle) - { - $db = new Database(); - $queryContacts = "select c.firstname, c.lastname, c.society, c.contact_id, cres.address_id "; - $queryContacts .= "from view_contacts c, contacts_res cres "; - $queryContacts .= "where cres.coll_id = 'letterbox_coll' AND cres.res_id = ##res_id## AND cast (c.contact_id as varchar(128)) = cres.contact_id AND ca_id = cres.address_id "; - $queryContacts .= "GROUP BY c.firstname, c.lastname, c.society, c.contact_id, cres.address_id"; - - $queryUsers = "select u.firstname, u.lastname, u.user_id "; - $queryUsers .= "from users u, contacts_res cres "; - $queryUsers .= "where cres.coll_id = 'letterbox_coll' AND cres.res_id = ##res_id## AND cast (u.user_id as varchar(128)) = cres.contact_id "; - $queryUsers .= "GROUP BY u.firstname, u.lastname, u.user_id"; - - $i = 0; - foreach($this->object_print as $line_name => $line_value) { - $return = false; - $res_id = $line_value->res_id; - $queryContacts_tmp = str_replace('##res_id##', '?', $queryContacts); - $stmt = $db->query($queryContacts_tmp, array($res_id)); - while($result = $stmt->fetchObject()) { - $return .= "Contact : " . $this->getContactInfos($result->contact_id, $result->address_id); - } - $queryUsers_tmp = str_replace('##res_id##', '?', $queryUsers); - $stmt = $db->query($queryUsers_tmp, array($res_id)); - while($result = $stmt->fetchObject()) { - $return .= "Utilisateur : " . $this->getUserInfo($result->user_id) . "\r\n"; - } - if (strlen($return) > 3) - $return = substr($return, 0, -2); - - $line_value->retrieve_multi_contacts = $return; - $i++; - } - } - - function retrieve_copies($libelle) - { - $db = new Database(); - - $collection = $this->collection; - - $query_template = 'SELECT '; - $query_template .= 'item_id, '; - $query_template .= 'item_type '; - $query_template .= 'FROM '; - $query_template .= 'listinstance '; - $query_template .= 'WHERE '; - $query_template .= "res_id = ##res_id## "; - $query_template .= "AND "; - $query_template .= "item_mode = 'cc'"; - - $query_template2 = 'SELECT '; - $query_template2 .= 'entity_id '; - $query_template2 .= 'FROM '; - $query_template2 .= 'users_entities '; - $query_template2 .= 'WHERE '; - $query_template2 .= "user_id = ##item_id## "; - $query_template2 .= "AND "; - $query_template2 .= "primary_entity = 'Y'"; - - $i = 0; - foreach($this->object_print as $line_name => $line_value) { - $return = false; - $res_id = $line_value->res_id; - $query = str_replace('##res_id##', '?', $query_template); - $stmt1 = $db->query($query, array($res_id)); - while($result = $stmt1->fetchObject()) { - if ($result->item_type == 'user_id') { - $query = str_replace('##item_id##', '?', $query_template2); - $stmt2 = $db->query($query, array($result->item_id)); - while ($result2 = $stmt2->fetchObject()) { - $stmt3 = $db->query( - "select entity_label from entities where entity_id = ?", - array($result2->entity_id) - ); - $resultEntity = $stmt3->fetchObject(); - $userInfos = $this->getUserInfo($result->item_id); - $usersEntities = "- " . $resultEntity->entity_label . ' : ' . $userInfos; - } - } else { - $stmt3 = $db->query( - "select entity_label from entities where entity_id = ?", - array($result->item_id) - ); - $resultEntity = $stmt3->fetchObject(); - $usersEntities = "- " . $resultEntity->entity_label . ' (' . $result->item_id . ") "; - } - $return .= $usersEntities . "\r\n"; - } - if (strlen($return) > 3) - $return = substr($return, 0, -2); - - $line_value->retrieve_copies = $return; - $i++; - } - } - - function free_notes($libelle) - { - foreach($this->object_print as $line_name => $line_value) { - $return = ""; - $line = ""; - foreach($_SESSION['features']['notes_in_print_page'] as $value) { - $return .= $line . $value."\r\n\r\n\r\n"; - $line = "__________________________________" - . "__________________________________" - . "_______________\r\n"; - } - $line_value->free_notes = $return; - } - } - - function retrieve_notes($libelle) - { - $db = new Database(); - - $query_template = 'SELECT '; - $query_template .= 'id, '; - $query_template .= 'user_id, '; - $query_template .= 'creation_date, '; - $query_template .= 'note_text '; - $query_template .= 'FROM '; - $query_template .= 'notes '; - $query_template .= 'WHERE '; - $query_template .= "identifier = ##res_id## "; - //EXCLUDE PRIVATE NOTES - $query_template .= "AND id not in (select note_id from note_entities) "; - $query_template .= "order by id"; - - $i = 0; - foreach($this->object_print as $line_name => $line_value) { - $return = false; - $res_id = $line_value->res_id; - $query = str_replace('##res_id##', '?', $query_template); - $stmt = $db->query($query, array($res_id)); - while($result = $stmt->fetchObject()) { - $userInfos = $this->getUserInfo($result->user_id); - $return .= "- " - //. $result->id . " " - . _PRINT_THE . " " - . functions::format_date_db($result->creation_date, false) - . " " . _BY . " " . $userInfos . " : " . $result->note_text . "\r\n" - . "__________________________________" - . "__________________________________" - . "_______________\r\n"; - } - if (strlen($return) > 3) - $return = substr($return, 0, -85); - - $line_value->retrieve_notes = $return; - $i++; - } - } - - function retrieve_VisaWorkflow() - { - foreach($this->object_print as $line_value) { - $visaWorkflow = \SrcCore\models\DatabaseModel::select([ - 'select' => ['u.firstname', 'u.lastname', 'l.process_date', 'l.process_comment', 'l.signatory', 'l.requested_signature'], - 'table' => ['listinstance l, users u'], - 'where' => ['l.res_id = ?', 'l.difflist_type = ?', 'u.user_id = l.item_id'], - 'data' => [$line_value->res_id, 'VISA_CIRCUIT'], - 'order_by' => ['l.listinstance_id asc'] - ]); - - $line_value->retrieve_VisaWorkflow = $visaWorkflow; - } - } -} diff --git a/rest/index.php b/rest/index.php index 5bef194c4d891d9afb3e76c3b615df615f9afb45..a4225c361c1dd016caa6697370e249e0df3413a0 100755 --- a/rest/index.php +++ b/rest/index.php @@ -79,7 +79,7 @@ $app->get('/attachmentsTypes', \Attachment\controllers\AttachmentController::cla $app->get('/autocomplete/contacts', \SrcCore\controllers\AutoCompleteController::class . ':getContacts'); $app->get('/autocomplete/users', \SrcCore\controllers\AutoCompleteController::class . ':getUsers'); $app->get('/autocomplete/maarchParapheurUsers', \SrcCore\controllers\AutoCompleteController::class . ':getMaarchParapheurUsers'); -$app->get('/autocomplete/contactsUsers', \SrcCore\controllers\AutoCompleteController::class . ':getContactsAndUsers'); +$app->get('/autocomplete/all', \SrcCore\controllers\AutoCompleteController::class . ':getAll'); $app->get('/autocomplete/contacts/groups', \SrcCore\controllers\AutoCompleteController::class . ':getContactsForGroups'); $app->get('/autocomplete/users/administration', \SrcCore\controllers\AutoCompleteController::class . ':getUsersForAdministration'); $app->get('/autocomplete/users/visa', \SrcCore\controllers\AutoCompleteController::class . ':getUsersForVisa'); diff --git a/src/app/contact/controllers/ContactController.php b/src/app/contact/controllers/ContactController.php index c7be64de672d482d1f549aa39fbc7106f5d7607b..ea66bb62ffa38942dd49d8dd29bae170c4813807 100755 --- a/src/app/contact/controllers/ContactController.php +++ b/src/app/contact/controllers/ContactController.php @@ -919,11 +919,11 @@ class ContactController $company = $args['contact']['company']; if (!empty($contactName)) { - $company = '(' . $company . ') '; + $company = '(' . $company . ')'; } } - $contactToDisplay = $contactName . $company; + $contactToDisplay = trim($contactName . $company); $otherInfo = empty($address) ? "{$contactToDisplay}" : "{$contactToDisplay} - {$address}"; $contact = [ diff --git a/src/app/contact/models/ContactGroupModelAbstract.php b/src/app/contact/models/ContactGroupModelAbstract.php index 5c36e243e214cd0067652923e71e01d13fe23f61..d79690832814078af8bc2a7cd2ca215de75ce4a1 100755 --- a/src/app/contact/models/ContactGroupModelAbstract.php +++ b/src/app/contact/models/ContactGroupModelAbstract.php @@ -18,19 +18,21 @@ use SrcCore\models\DatabaseModel; abstract class ContactGroupModelAbstract { - public static function get(array $aArgs = []) + public static function get(array $args = []) { - ValidatorModel::arrayType($aArgs, ['select', 'where', 'data', 'orderBy']); + ValidatorModel::arrayType($args, ['select', 'where', 'data', 'orderBy']); + ValidatorModel::intType($args, ['limit']); - $aReturn = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + $contactGroups = DatabaseModel::select([ + 'select' => empty($args['select']) ? ['*'] : $args['select'], 'table' => ['contacts_groups'], - 'where' => $aArgs['where'], - 'data' => $aArgs['data'], - 'order_by' => $aArgs['orderBy'] + 'where' => empty($args['where']) ? [] : $args['where'], + 'data' => empty($args['data']) ? [] : $args['data'], + 'order_by' => empty($args['orderBy']) ? [] : $args['orderBy'], + 'limit' => empty($args['limit']) ? 0 : $args['limit'] ]); - return $aReturn; + return $contactGroups; } public static function getById(array $aArgs) diff --git a/src/app/contentManagement/controllers/MergeController.php b/src/app/contentManagement/controllers/MergeController.php index 2d6cab1f94dbc35d0eb0fe039f036a80bd780424..ca845fc73a24c9a3cc5eb04f46c68ce584649d73 100644 --- a/src/app/contentManagement/controllers/MergeController.php +++ b/src/app/contentManagement/controllers/MergeController.php @@ -143,11 +143,6 @@ class MergeController if (!empty($resource['initiator'])) { $initiator = EntityModel::getByEntityId(['entityId' => $resource['initiator'], 'select' => ['*']]); - if (!empty($initiator)) { - foreach ($initiator as $key => $value) { - $resource["initiator_{$key}"] = $value; - } - } $initiator['path'] = EntityModel::getEntityPathByEntityId(['entityId' => $resource['initiator'], 'path' => '']); if (!empty($initiator['parent_entity_id'])) { $parentInitiator = EntityModel::getByEntityId(['entityId' => $initiator['parent_entity_id'], 'select' => ['*']]); @@ -228,26 +223,6 @@ class MergeController } } - //Contact -// $contact = ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$args['contactAddressId']]])[0]; -// $contact['postal_address'] = ContactController::formatContactAddressAfnor($contact); -// $contact['title'] = ContactModel::getCivilityLabel(['civilityId' => $contact['title']]); -// if (empty($contact['title'])) { -// $contact['title'] = ContactModel::getCivilityLabel(['civilityId' => $contact['contact_title']]); -// } -// if (empty($contact['firstname'])) { -// $contact['firstname'] = $contact['contact_firstname']; -// } -// if (empty($contact['lastname'])) { -// $contact['lastname'] = $contact['contact_lastname']; -// } -// if (empty($contact['function'])) { -// $contact['function'] = $contact['contact_function']; -// } -// if (empty($contact['other_data'])) { -// $contact['other_data'] = $contact['contact_other_data']; -// } - //Notes $mergedNote = ''; if (!empty($args['resId'])) { diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 87e4f0e6cd620038591cbdc12712d1a368efa918..2ea624583d3c19b2fab334538ec090f2ba74c420 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -213,11 +213,11 @@ class ResController ]); $entities = array_column($entities, 'id'); $folders = FolderModel::getWithEntitiesAndResources([ - 'select' => ['resources_folders.id'], + 'select' => ['resources_folders.folder_id'], 'where' => ['resources_folders.res_id = ?', '(entities_folders.entity_id in (?) OR folders.user_id = ?)'], 'data' => [$args['resId'], $entities, $GLOBALS['id']] ]); - $formattedData['folders'] = array_column($folders, 'id'); + $formattedData['folders'] = array_column($folders, 'folder_id'); $tags = TagResModel::get(['select' => ['tag_id'], 'where' => ['res_id = ?'], 'data' => [$args['resId']]]); $formattedData['tags'] = array_column($tags, 'tag_id'); diff --git a/src/core/controllers/AutoCompleteController.php b/src/core/controllers/AutoCompleteController.php index 166157cb6af7e05712ace8ac75f976f9489b29ee..a64c8d884775c4a603c985089b573dfe4fbc6e31 100755 --- a/src/core/controllers/AutoCompleteController.php +++ b/src/core/controllers/AutoCompleteController.php @@ -15,6 +15,7 @@ namespace SrcCore\controllers; use Contact\controllers\ContactController; +use Contact\models\ContactGroupModel; use Contact\models\ContactModel; use Entity\models\EntityModel; use Respect\Validation\Validator; @@ -38,36 +39,30 @@ class AutoCompleteController public static function getContacts(Request $request, Response $response) { - $data = $request->getQueryParams(); + $queryParams = $request->getQueryParams(); - $check = Validator::stringType()->notEmpty()->validate($data['search']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); + if (!Validator::stringType()->notEmpty()->validate($queryParams['search'])) { + return $response->withStatus(400)->withJson(['errors' => 'Query params search is empty']); } - $searchItems = explode(' ', $data['search']); - - $fields = '(firstname ilike ? OR lastname ilike ? OR company ilike ? - OR address_number ilike ? OR address_street ilike ? OR address_town ilike ? OR address_postalcode ilike ?)'; - $where = []; - $requestData = []; - foreach ($searchItems as $item) { - if (strlen($item) >= 2) { - $where[] = $fields; - for ($i = 0; $i < 7; $i++) { - $requestData[] = "%{$item}%"; - } - } - } + $fields = ['firstname', 'lastname', 'company', 'address_number', 'address_street', 'address_town', 'address_postcode']; + $fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]); + $requestData = AutoCompleteController::getDataForRequest([ + 'search' => $queryParams['search'], + 'fields' => $fields, + 'where' => ['enabled = ?'], + 'data' => [true], + 'fieldsNumber' => 7, + ]); $contacts = ContactModel::get([ 'select' => ['*'], - 'where' => $where, - 'data' => $requestData, + 'where' => $requestData['where'], + 'data' => $requestData['data'], 'limit' => self::TINY_LIMIT ]); - $color = (!empty($data['color']) && $data['color'] == 'true'); + $color = isset($queryParams['color']) && filter_var($queryParams['color'], FILTER_VALIDATE_BOOLEAN); $autocompleteData = []; foreach ($contacts as $contact) { $autocompleteData[] = AutoCompleteController::getFormattedContact(['contact' => $contact, 'color' => $color])['contact']; @@ -182,79 +177,144 @@ class AutoCompleteController } } - public static function getContactsAndUsers(Request $request, Response $response) + public static function getAll(Request $request, Response $response) { - $data = $request->getQueryParams(); + $queryParams = $request->getQueryParams(); - if (!Validator::stringType()->notEmpty()->validate($data['search'])) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); + if (!Validator::stringType()->notEmpty()->validate($queryParams['search'])) { + return $response->withStatus(400)->withJson(['errors' => 'Query params search is empty']); } - $searchItems = explode(' ', $data['search']); + //Contacts + $autocompleteContacts = []; + if (empty($queryParams['noContacts'])) { + $fields = ['firstname', 'lastname', 'company', 'address_number', 'address_street', 'address_town', 'address_postcode']; + $fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]); + $requestData = AutoCompleteController::getDataForRequest([ + 'search' => $queryParams['search'], + 'fields' => $fields, + 'where' => ['enabled = ?'], + 'data' => [true], + 'fieldsNumber' => 7, + ]); - $fields = ['firstname', 'lastname', 'company', 'address_number', 'address_street', 'address_town', 'address_postcode']; - $fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]); + $contacts = ContactModel::get([ + 'select' => ['*'], + 'where' => $requestData['where'], + 'data' => $requestData['data'], + 'orderBy' => ['company', 'lastname'], + 'limit' => self::TINY_LIMIT + ]); - $where = []; - $requestData = []; - foreach ($searchItems as $item) { - if (strlen($item) >= 2) { - $where[] = $fields; - for ($i = 0; $i < 7; $i++) { - $requestData[] = "%{$item}%"; - } + $color = isset($queryParams['color']) && filter_var($queryParams['color'], FILTER_VALIDATE_BOOLEAN); + + foreach ($contacts as $contact) { + $autocompleteContacts[] = ContactController::getFormattedContactWithAddress(['contact' => $contact, 'color' => $color])['contact']; } } - $contacts = ContactModel::get([ - 'select' => ['*'], - 'where' => $where, - 'data' => $requestData, - 'orderBy' => ["company, lastname"], - 'limit' => self::TINY_LIMIT - ]); + //Users + $autocompleteUsers = []; + if (empty($queryParams['noUsers'])) { + $fields = ['firstname', 'lastname']; + $fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]); + $requestData = AutoCompleteController::getDataForRequest([ + 'search' => $queryParams['search'], + 'fields' => $fields, + 'where' => ['status not in (?)', 'user_id not in (?)'], + 'data' => [['DEL', 'SPD'], ['superadmin']], + 'fieldsNumber' => 2, + ]); - $color = (!empty($data['color']) && $data['color'] == 'true'); + $users = UserModel::get([ + 'select' => ['id', 'firstname', 'lastname'], + 'where' => $requestData['where'], + 'data' => $requestData['data'], + 'orderBy' => ['lastname'], + 'limit' => self::TINY_LIMIT + ]); - $onlyContacts = []; - $autocompleteData = []; - foreach ($contacts as $contact) { - if (!empty($data['onlyContacts']) && $data['onlyContacts'] == 'true' && !in_array($contact['contact_id'], $onlyContacts)) { - $autocompleteData[] = ContactController::getFormattedOnlyContact(['contact' => $contact])['contact']; - $onlyContacts[] = $contact['contact_id']; + foreach ($users as $user) { + $autocompleteUsers[] = [ + 'type' => 'user', + 'id' => $user['id'], + 'idToDisplay' => "{$user['firstname']} {$user['lastname']}", + 'otherInfo' => "{$user['firstname']} {$user['lastname']}" + ]; } - $autocompleteData[] = ContactController::getFormattedContactWithAddress(['contact' => $contact, 'color' => $color])['contact']; } - $excludedUsers = ['superadmin']; + //Entities + $autocompleteEntities = []; + if (empty($queryParams['noEntities'])) { + $fields = ['entity_label']; + $fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]); + $requestData = AutoCompleteController::getDataForRequest([ + 'search' => $queryParams['search'], + 'fields' => $fields, + 'where' => ['enabled = ?'], + 'data' => ['Y'], + 'fieldsNumber' => 1, + ]); - $fields = ['firstname', 'lastname']; - $fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]); + $entities = EntityModel::get([ + 'select' => ['id', 'entity_id', 'entity_label', 'short_label'], + 'where' => $requestData['where'], + 'data' => $requestData['data'], + 'orderBy' => ['entity_label'], + 'limit' => self::TINY_LIMIT + ]); - $requestData = AutoCompleteController::getDataForRequest([ - 'search' => $data['search'], - 'fields' => $fields, - 'where' => ['status not in (?)', 'user_id not in (?)'], - 'data' => [['DEL', 'SPD'], $excludedUsers], - 'fieldsNumber' => 2, - ]); + foreach ($entities as $value) { + $autocompleteEntities[] = [ + 'type' => 'entity', + 'id' => $value['id'], + 'idToDisplay' => $value['entity_label'], + 'otherInfo' => $value['short_label'] + ]; + } + } - $users = UserModel::get([ - 'select' => ['id', 'user_id', 'firstname', 'lastname'], - 'where' => $requestData['where'], - 'data' => $requestData['data'], - 'orderBy' => ['lastname'], - 'limit' => self::TINY_LIMIT - ]); + //Contacts Groups + $autocompleteContactsGroups = []; + if (empty($queryParams['noContactsGroups'])) { + $fields = ['label']; + $fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]); + $requestData = AutoCompleteController::getDataForRequest([ + 'search' => $queryParams['search'], + 'fields' => $fields, + 'where' => ['(public = ? OR owner = ?)'], + 'data' => [true, $GLOBALS['id']], + 'fieldsNumber' => 1, + ]); - foreach ($users as $value) { - $autocompleteData[] = [ - 'type' => 'user', - 'id' => $value['id'], - 'idToDisplay' => "{$value['firstname']} {$value['lastname']}", - 'otherInfo' => "{$value['firstname']} {$value['lastname']}" - ]; + $contactsGroups = ContactGroupModel::get([ + 'select' => ['id', 'label'], + 'where' => $requestData['where'], + 'data' => $requestData['data'], + 'orderBy' => ['label'], + 'limit' => self::TINY_LIMIT + ]); + + foreach ($contactsGroups as $value) { + $autocompleteContactsGroups[] = [ + 'type' => 'contactGroup', + 'id' => $value['id'], + 'idToDisplay' => $value['label'], + 'otherInfo' => $value['label'] + ]; + } + } + + $total = count($autocompleteContacts) + count($autocompleteUsers) + count($autocompleteEntities) + count($autocompleteContactsGroups); + if ($total > self::TINY_LIMIT) { + $divider = $total / self::TINY_LIMIT; + $autocompleteContacts = array_slice($autocompleteContacts, 0, round(count($autocompleteContacts) / $divider)); + $autocompleteUsers = array_slice($autocompleteUsers, 0, round(count($autocompleteUsers) / $divider)); + $autocompleteEntities = array_slice($autocompleteEntities, 0, round(count($autocompleteEntities) / $divider)); + $autocompleteContactsGroups = array_slice($autocompleteContactsGroups, 0, round(count($autocompleteContactsGroups) / $divider)); } + $autocompleteData = array_merge($autocompleteContacts, $autocompleteUsers, $autocompleteEntities, $autocompleteContactsGroups); return $response->withJson($autocompleteData); } diff --git a/src/frontend/app/app-material.module.ts b/src/frontend/app/app-material.module.ts index cc3451f667d44928eb490c2e277f9ec28fa21e36..3ab7f4e65f64ccad8d5519e0dac7a701c62baa45 100755 --- a/src/frontend/app/app-material.module.ts +++ b/src/frontend/app/app-material.module.ts @@ -1,6 +1,8 @@ +import { LANG } from '../app/translate.component'; import { NativeDateAdapter, DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from "@angular/material/core"; export class AppDateAdapter extends NativeDateAdapter { + lang: any = LANG; parse(value: any): Date | null { if ((typeof value === 'string') && (value.indexOf('/') > -1)) { const str = value.split('/'); @@ -21,7 +23,7 @@ export class AppDateAdapter extends NativeDateAdapter { return this._to2digit(day) + '/' + this._to2digit(month) + '/' + year; } else { const options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' }; - return date.toLocaleDateString('fr-FR', options); + return date.toLocaleDateString(this.lang.langISO, options); } } @@ -166,7 +168,7 @@ import { getFrenchPaginatorIntl } from './french-paginator-intl'; ], providers: [ { provide: MatPaginatorIntl, useValue: getFrenchPaginatorIntl() }, - { provide: MAT_DATE_LOCALE, useValue: 'fr-FR' }, + { provide: MAT_DATE_LOCALE, useValue: LANG.langISO }, { provide: DateAdapter, useClass: AppDateAdapter }, { provide: MAT_DATE_FORMATS, useValue: APP_DATE_FORMATS }, ] diff --git a/src/frontend/app/home/home.component.ts b/src/frontend/app/home/home.component.ts index ec9b55e5e0ba94be55e35d5b5941885859ceb759..6abdac938ee5af8958f39930abacd119f5c08b6a 100644 --- a/src/frontend/app/home/home.component.ts +++ b/src/frontend/app/home/home.component.ts @@ -62,7 +62,7 @@ export class HomeComponent implements OnInit { let event = new Date(); let options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; - this.currentDate = event.toLocaleDateString('fr-FR', options); + this.currentDate = event.toLocaleDateString(this.lang.langISO, options); this.http.get("../../rest/home") .subscribe((data: any) => { diff --git a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts index c8ced3dc78e5a58cb8c62534e1b706154c619516..8d86c1ef491fbbf6af346eb352cd96464ea07ef0 100644 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts @@ -315,7 +315,7 @@ export class IndexingFormComponent implements OnInit { this.http.put(`../../rest/resources/${this.resId}?userId=${userId}&groupId=${groupId}&basketId=${basketId}`, formatdatas ).pipe( tap(() => { - this.currentResourceValues = this.getDatas(); + this.currentResourceValues = this.getDatas(false); this.notify.success(this.lang.dataUpdated); }), catchError((err: any) => { diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html index 1dd09ea695af5567179052fe3c401b43cb9caaf0..cc5c6f0706eb6477318d427fc207035acfb44ebd 100644 --- a/src/frontend/app/process/process.component.html +++ b/src/frontend/app/process/process.component.html @@ -92,6 +92,9 @@ </app-attachments-list> <app-indexing-form *ngIf="currentTool === 'info' && !loading" #indexingForm [groupId]="currentGroupId" [resId]="currentResourceInformations.resId" [indexingFormId]="currentResourceInformations.modelId" [mode]="'process'"></app-indexing-form> + <button mat-raised-button *ngIf="indexingForm !== undefined && currentTool === 'info'" [disabled]="!indexingForm.isResourceModified()" (click)="confirmModification()" color="primary" [title]="lang.openInExternalModal" style="position:absolute;top:0px;"> + {{lang.save}} + </button> </ng-container> <ng-template #elseTemplate> <div class="openedModal"> @@ -225,6 +228,9 @@ </button> </div> <div class="modal-module-content"> + <button mat-raised-button *ngIf="indexingForm !== undefined && currentTool === 'info'" [disabled]="!indexingForm.isResourceModified()" (click)="confirmModification()" color="primary" [title]="lang.openInExternalModal"> + {{lang.save}} + </button> <app-notes-list *ngIf="modal.id === 'notes' && !loading" #appNotesList [editMode]="true" [resId]="currentResourceInformations.resId"> </app-notes-list> diff --git a/src/frontend/app/process/process.component.scss b/src/frontend/app/process/process.component.scss index da9e351569a0939cc8b912379027d6ccf195f24e..468b6bb537d9b5857e266f0cf4121be612a2cff4 100644 --- a/src/frontend/app/process/process.component.scss +++ b/src/frontend/app/process/process.component.scss @@ -44,6 +44,7 @@ } .indexing-form-container { + position: relative; height: 100%; overflow: auto; padding-left: 20px; diff --git a/src/frontend/app/translate.component.ts b/src/frontend/app/translate.component.ts index c9df5cd26aa8d2a703dd167631ac2c3b56ac58e1..a8485ccd6d1c9ca19984cffd39adbe2a92020314 100755 --- a/src/frontend/app/translate.component.ts +++ b/src/frontend/app/translate.component.ts @@ -17,4 +17,4 @@ if (angularGlobals.customLanguage != null) { dictionary = {...dictionary, ...angularGlobals.customLanguage}; } -export const LANG = dictionary; \ No newline at end of file +export const LANG: any = dictionary; \ No newline at end of file diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 3fb22ea63cff8b840d8f82ce86721dc1e144b9a3..974059daa1c4c155bf16889e9d2336a474b5f56e 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1328,4 +1328,5 @@ export const LANG_EN = { "newVersion": "New version", "information": "Information", "mustEditDocument": "You must <b>edit</b> document in order to <b>validate</b> modifications.", + "langISO": "en-US", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 063250a56d8b80141a21bce3139f4e858b83d8f7..944f5b16da54ce0b823ee08203668aeeff7967b9 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1360,4 +1360,5 @@ export const LANG_FR = { "autocompletionSearchable": "Recherchable dans l'autocomplétion", "autocompletionDisplayable": "Affichable dans l'autocompletion", "contactsParameters": "Paramétrage des contacts", + "langISO": "fr-FR", }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 1ada013416901be6a29c6728f5713586b9ddf7a3..2f71ec3cef010d3ce4d8480278eb5fcea2c6c977 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1353,4 +1353,5 @@ export const LANG_NL = { "newVersion": "New version", //_TO_TRANSLATE "information": "Information", //_TO_TRANSLATE "mustEditDocument": "You must <b>edit</b> document in order to <b>validate</b> modifications.", //_TO_TRANSLATE + "langISO": "nl-FR", }; diff --git a/src/frontend/plugins/fullDate.pipe.ts b/src/frontend/plugins/fullDate.pipe.ts index bcda977f131f482730309efd605348fd548d37c4..63c9d86eee279956b65b489166bf9ae15e7bb0c1 100755 --- a/src/frontend/plugins/fullDate.pipe.ts +++ b/src/frontend/plugins/fullDate.pipe.ts @@ -11,6 +11,6 @@ export class FullDatePipe implements PipeTransform { transform(value: string) { const date = new Date(value); const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' }; - return this.lang.onRange[0].toUpperCase() + this.lang.onRange.substr(1).toLowerCase() + ' ' + date.toLocaleDateString('fr-FR', options); + return this.lang.onRange[0].toUpperCase() + this.lang.onRange.substr(1).toLowerCase() + ' ' + date.toLocaleDateString(this.lang.langISO, options); } } \ No newline at end of file