From 59514376affa48c02eb1fd083052ef45edafb321 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Thu, 5 Dec 2019 11:59:40 +0100 Subject: [PATCH] FEAT #12510 TIME 1:10 Maileva fix + refactoring on view contacts --- .../admin/contacts/admin_contacts.php | 120 ---- .../contact_addresses_list.php | 295 -------- .../contact_addresses_up_db.php | 1 - .../contacts_v2/contacts_v2_confirm.php | 226 ------ .../contacts/contacts_v2/contacts_v2_up.php | 5 - .../contacts_v2/contacts_v2_up_db.php | 1 - .../class/class_contacts_v2_Abstract.php | 667 ------------------ .../class/class_lists_Abstract.php | 5 - .../class/class_multicontacts.php | 34 - .../class/class_multicontacts_Abstract.php | 72 -- .../definition_mail_categories.php | 498 ------------- .../indexing_searching/add_multi_contacts.php | 165 ----- .../indexing_searching/addresses_list.php | 338 --------- .../indexing_searching/details.php | 13 +- apps/maarch_entreprise/js/functions.js | 20 - apps/maarch_entreprise/loadContactsList.php | 127 ---- .../my_contacts/get_last_contact_address.php | 135 ---- .../my_contacts/my_contact_up_db.php | 1 - .../xml/IVS/requests_definitions.xml | 11 - core/class/LinkController.php | 2 +- core/class/PrintControler.php | 4 +- modules/attachments/attachments_content.php | 2 +- modules/avis/send_to_avis.php | 2 +- .../ReceiveMessageExchangeController.php | 2 +- .../SendMessageExchangeController.php | 4 +- .../sendmail/acknowledgementReceiptsList.php | 3 - modules/sendmail/mail_form.php | 8 +- modules/sendmail/sendmail_ajax_content.php | 6 +- .../PreProcessActionController.php | 21 +- src/app/action/controllers/ShippingTrait.php | 12 +- .../contact/controllers/ContactController.php | 70 +- src/app/contact/models/ContactModel.php | 73 +- .../resource/models/ResourceContactModel.php | 41 -- .../contact/ContactGroupControllerTest.php | 14 +- 34 files changed, 76 insertions(+), 2922 deletions(-) delete mode 100755 apps/maarch_entreprise/admin/contacts/admin_contacts.php delete mode 100755 apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list.php delete mode 100755 apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_confirm.php delete mode 100755 apps/maarch_entreprise/class/class_multicontacts.php delete mode 100755 apps/maarch_entreprise/class/class_multicontacts_Abstract.php delete mode 100755 apps/maarch_entreprise/indexing_searching/add_multi_contacts.php delete mode 100755 apps/maarch_entreprise/indexing_searching/addresses_list.php delete mode 100755 apps/maarch_entreprise/loadContactsList.php delete mode 100755 apps/maarch_entreprise/my_contacts/get_last_contact_address.php diff --git a/apps/maarch_entreprise/admin/contacts/admin_contacts.php b/apps/maarch_entreprise/admin/contacts/admin_contacts.php deleted file mode 100755 index 42449e8af12..00000000000 --- a/apps/maarch_entreprise/admin/contacts/admin_contacts.php +++ /dev/null @@ -1,120 +0,0 @@ -<?php -/* -* Copyright 2008,2009 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** - * @brief Architecture Administration summary Page - * - * Architecture Administration summary Page - * - * @file - * - * @author Claire Figueras <dev@maarch.org> - * @date $date$ - * - * @version $Revision$ - * @ingroup admin - */ -$admin = new core_tools(); -$admin->test_admin('admin_contacts', 'apps'); -/****************Management of the location bar ************/ -$init = false; -if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') { - $init = true; -} -$level = ''; -if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) { - $level = $_REQUEST['level']; -} -$page_path = $_SESSION['config']['businessappurl'].'index.php?page=admin_contacts&admin=contacts'; -$page_label = _ADMIN_CONTACTS; -$page_id = 'admin_contacts'; -$admin->manage_location_bar($page_path, $page_label, $page_id, $init, $level); -/***********************************************************/ -unset($_SESSION['m_admin']); -?> -<h1><i class="fa fa-book fa-2x"></i> <?php echo _ADMIN_CONTACTS_DESC; ?></h1> -<div id="inner_content" class="clearfix"> -<div class="block"> - <h2><?php echo _ADMIN_CONTACTS; ?></h2> - <div class="admin_item" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=contact_types';"> - <div> - <i class="fa fa-share-alt fa-4x" title="<?php echo _MANAGE_CONTACT_TYPES_DESC; ?>" ></i> - </div> - <div> - <strong><?php echo _MANAGE_CONTACT_TYPES; ?></strong> - </div> - </div> - - <div class="admin_item" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=contacts_v2';"> - <div> - <i class="fa fa-address-book fa-4x" title="<?php echo _MANAGE_CONTACTS_DESC; ?>" ></i> - </div> - <div> - <strong><?php echo _MANAGE_CONTACTS; ?></strong> - </div> - </div> - - <div class="admin_item" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=contact_purposes';"> - <div> - <i class="fa fa-tags fa-4x" title="<?php echo _MANAGE_CONTACT_PURPOSES_DESC; ?>" ></i> - </div> - <div> - <strong><?php echo _MANAGE_CONTACT_PURPOSES; ?></strong> - </div> - </div> - - <div class="admin_item" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=contact_addresses_list';"> - <div> - <i class="fa fa-home fa-4x" title="<?php echo _MANAGE_CONTACT_ADDRESSES_LIST_DESC; ?>" ></i> - </div> - <div> - <strong><?php echo _MANAGE_CONTACT_ADDRESSES_LIST; ?></strong> - </div> - </div> - - <div class="admin_item" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=view_tree_contacts';"> - <div> - <i class="fa fa-code-branch fa-4x" title="<?php echo _VIEW_TREE_CONTACTS_DESC; ?>" ></i> - </div> - <div> - <strong><?php echo _VIEW_TREE_CONTACTS; ?></strong> - </div> - </div> - - <div class="admin_item" onclick="triggerAngular('#/administration/contacts-groups')"> - <div> - <i class="fa fa-users fa-4x" title="<?php echo _VIEW_CONTACTS_GROUPS_DESC; ?>" ></i> - </div> - <div> - <strong><?php echo _VIEW_CONTACTS_GROUPS;?></strong> - </div> - </div> - <div class="admin_item" onclick="triggerAngular('#/administration/contacts-filling')"> - <div> - <i class="fas fa-address-card fa-4x"></i> - <i class="far fa-question-circle" style="position: absolute;font-size: 26px;margin-left: 5px;"></i> - </div> - <div> - <strong><?php echo _CONTACTS_FILLING;?></strong> - </div> - </div> - <div class="clearfix"></div> -</div> -</div> diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list.php deleted file mode 100755 index 987666a424c..00000000000 --- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_list.php +++ /dev/null @@ -1,295 +0,0 @@ -<?php -/* -* Copyright 2014 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** - * @file - * - * @author <dev@maarch.org> - * @date $date$ - * - * @version $Revision$ - * @ingroup admin - */ -require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_contacts_v2.php'; -$core_tools = new core_tools(); -$core_tools->load_lang(); -$func = new functions(); -$contact = new contacts_v2(); - -require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php'; -require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_list_show.php'; -$func = new functions(); - -$return = $core_tools->test_admin('admin_contacts', 'apps', false); -if (!$return) { - $return = $core_tools->test_admin('search_contacts', 'apps', false); -} -if (!$return) { - $return = $core_tools->test_admin('create_contacts', 'apps'); -} - - /****************Management of the location bar ************/ -$init = false; -if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') { - $init = true; -} -$level = ''; -if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) { - $level = $_REQUEST['level']; -} -$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contact_addresses_list'; -$page_label = _MANAGE_CONTACT_ADDRESSES_LIST; -$page_id = 'contact_addresses_list'; -$core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level); -/***********************************************************/ - -$select['view_contacts'] = array(); -array_push( - $select['view_contacts'], - 'ca_id', "contact_id - , case when view_contacts.is_corporate_person <> 'Y' then view_contacts.contact_id || ' - ' || view_contacts.contact_lastname || ' ' || view_contacts.contact_firstname|| ' - physique' else view_contacts.contact_id || ' - ' || view_contacts.society || ' - moral' end as \"society\"", 'contact_purpose_id', "departement - , case when view_contacts.contact_lastname <> '' then view_contacts.contact_lastname else view_contacts.lastname end as \"lastname\" - , case when view_contacts.contact_firstname <> '' then view_contacts.contact_firstname else view_contacts.firstname end as \"firstname\" - , case when view_contacts.contact_function <> '' then view_contacts.contact_function else view_contacts.function end as \"function\"", 'address_town', 'phone', 'email' -); -$what = ''; -$where = ''; - -$arrayPDO = array(); -if (isset($_REQUEST['selectedObject']) && !empty($_REQUEST['selectedObject'])) { - $where .= ' ca_id = ? '; - $arrayPDO = array($_REQUEST['selectedObject']); -} elseif (isset($_REQUEST['what']) && !empty($_REQUEST['what'])) { - $what = str_replace(' ', '', $_REQUEST['what']); - $what_table = explode(' ', $what); - - foreach ($what_table as $key => $what_a) { - $sql_lastname[] = ' lower(lastname) LIKE lower(:what_'.$key.')'; - $sql_firstname[] = ' lower(firstname) LIKE lower(:what_'.$key.')'; - $sql_society[] = ' lower(departement) LIKE lower(:what_'.$key.')'; - $sql_contact_firstname[] = ' lower(contact_firstname) LIKE lower(:what_'.$key.')'; - $sql_contact_lastname[] = ' lower(contact_lastname) LIKE lower(:what_'.$key.')'; - $arrayPDO = array_merge($arrayPDO, array(':what_'.$key => $what_a.'%')); - } - - $where .= ' ('.implode(' OR ', $sql_lastname).' '; - $where .= ' or '.implode(' OR ', $sql_firstname).' '; - $where .= ' or '.implode(' OR ', $sql_society).' '; - $where .= ' or '.implode(' OR ', $sql_contact_firstname).' '; - $where .= ' or '.implode(' OR ', $sql_contact_lastname).') '; -} -// var_dump($arrayPDO); -// var_dump($where); - -$list = new list_show(); -$order = 'asc'; -if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) { - $order = trim($_REQUEST['order']); -} - -//use to pass the next condition in order_field. Then we need to delete them. -array_push( - $select['view_contacts'], - 'lastname', 'firstname', 'function' -); - -$field = 'society'; -if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field']) && in_array($_REQUEST['order_field'], $select['view_contacts'])) { - $field = trim($_REQUEST['order_field']); -} - -array_pop($select['view_contacts']); -array_pop($select['view_contacts']); -array_pop($select['view_contacts']); - -$orderstr = $list->define_order($order, $field); - -if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) { - $parameters .= '&start='.$_REQUEST['start']; -} else { - $_REQUEST['start'] = 0; -} -if (isset($_REQUEST['lines'])) { - $limit = $_REQUEST['lines']; -} else { - $limit = 'default'; -} -$request = new request(); -$tab = $request->PDOselect( - $select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype'], $limit, false, '', '', '', true, false, false, $_REQUEST['start'] -); -// $request->show(); - -if (!empty($tab)) { - for ($i = 0; $i < count($tab); ++$i ) { - for ($j = 0; $j < count($tab[$i]); ++$j ) { - foreach (array_keys($tab[$i][$j]) as $value) { - if ($tab[$i][$j][$value] == 'ca_id') { - $tab[$i][$j]['id'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _ID; - $tab[$i][$j]['size'] = '30'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = false; - $tab[$i][$j]['order'] = 'id'; - } - if ($tab[$i][$j][$value] == 'contact_id') { - $tab[$i][$j]['contact_id'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _CONTACT_ID; - $tab[$i][$j]['size'] = '30'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = false; - $tab[$i][$j]['order'] = 'contact_id'; - } - if ($tab[$i][$j][$value] == 'society') { - $show_string = explode(' - ', $tab[$i][$j]['value']); - $show_string[2] = '<i style="font-size:10px;color:#135F7F;">'.$show_string[2].'</i>'; - $show_string = implode(' - ', $show_string); - $tab[$i][$j]['value'] = $show_string; - $tab[$i][$j]['society'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _LINKED_CONTACT; - $tab[$i][$j]['size'] = '30'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = true; - $tab[$i][$j]['order'] = 'society'; - } - if ($tab[$i][$j][$value] == 'contact_purpose_id') { - $tab[$i][$j]['value'] = $contact->get_label_contact($tab[$i][$j]['value'], $_SESSION['tablename']['contact_purposes']); - $tab[$i][$j]['contact_purpose_id'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _CONTACT_PURPOSE; - $tab[$i][$j]['size'] = '20'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = true; - $tab[$i][$j]['order'] = 'contact_purpose_id'; - } - if ($tab[$i][$j][$value] == 'departement') { - $tab[$i][$j]['value'] = $request->show_string( - $tab[$i][$j]['value'] - ); - $tab[$i][$j]['departement'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _SERVICE; - $tab[$i][$j]['size'] = '20'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = true; - $tab[$i][$j]['order'] = 'departement'; - } - if ($tab[$i][$j][$value] == 'lastname') { - $tab[$i][$j]['value'] = $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]['lastname'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _LASTNAME; - $tab[$i][$j]['size'] = '15'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = true; - $tab[$i][$j]['order'] = 'lastname'; - } - if ($tab[$i][$j][$value] == 'firstname') { - $tab[$i][$j]['firstname'] = $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]['label'] = _FIRSTNAME; - $tab[$i][$j]['size'] = '15'; - $tab[$i][$j]['label_align'] = 'center'; - $tab[$i][$j]['align'] = 'center'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = true; - $tab[$i][$j]['order'] = 'firstname'; - } - if ($tab[$i][$j][$value] == 'function') { - $tab[$i][$j]['value'] = $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]['function'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _FUNCTION; - $tab[$i][$j]['size'] = '15'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = true; - $tab[$i][$j]['order'] = 'function'; - } - if ($tab[$i][$j][$value] == 'address_town') { - $tab[$i][$j]['address_town'] = $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]['label'] = _TOWN; - $tab[$i][$j]['size'] = '10'; - $tab[$i][$j]['label_align'] = 'center'; - $tab[$i][$j]['align'] = 'center'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = true; - $tab[$i][$j]['order'] = 'address_town'; - } - if ($tab[$i][$j][$value] == 'phone') { - $tab[$i][$j]['value'] = $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]['phone'] = $tab[$i][$j]['value']; - $tab[$i][$j]['label'] = _PHONE; - $tab[$i][$j]['size'] = '15'; - $tab[$i][$j]['label_align'] = 'left'; - $tab[$i][$j]['align'] = 'left'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = false; - $tab[$i][$j]['order'] = 'phone'; - } - if ($tab[$i][$j][$value] == 'email') { - $tab[$i][$j]['email'] = $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]['label'] = _MAIL; - $tab[$i][$j]['size'] = '15'; - $tab[$i][$j]['label_align'] = 'center'; - $tab[$i][$j]['align'] = 'center'; - $tab[$i][$j]['valign'] = 'bottom'; - $tab[$i][$j]['show'] = false; - $tab[$i][$j]['order'] = 'email'; - } - } - } - } -} - -$pageName = 'contact_addresses_list'; -$pageNameUp = 'contact_addresses_up&fromContactAddressesList'; -$pageNameAdd = ''; -$pageNameDel = ''; -$pageNameVal = ''; -$tableName = 'view_contacts'; -$pageNameBan = ''; -$addLabel = ''; - -$autoCompletionArray = array(); -$autoCompletionArray['list_script_url'] = $_SESSION['config']['businessappurl'] - .'index.php?display=true&page=contact_addresses_list_by_name'; -$autoCompletionArray['number_to_begin'] = 1; -$autoCompletionArray['searchBoxAutoCompletionUpdate'] = true; - -$title = _ADDRESSES_LIST.' : '.$_SESSION['save_list']['full_count'].' '._ADDRESSES; - -$list->admin_list( - $tab, $_SESSION['save_list']['full_count'], $title, - 'contact_id', 'contact_addresses_list', 'contact_addresses', - 'id', true, $pageNameUp, $pageNameVal, $pageNameBan, - $pageNameDel, $pageNameAdd, $addLabel, false, false, _ALL_CONTACT_ADDRESSES, - _A_CONTACT_ADDRESS, 'home', false, true, true, true, - $what, true, $autoCompletionArray, false, true); - -$_SESSION['m_admin']['address'] = array(); diff --git a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php index d235183c990..d83e74b0bd3 100755 --- a/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php +++ b/apps/maarch_entreprise/admin/contacts/contact_addresses/contact_addresses_up_db.php @@ -81,4 +81,3 @@ if (isset($_REQUEST['fromContactAddressesList'])) { $_SESSION['contact_address']['fromContactAddressesList'] = "yes"; } -$contact->addupaddress($_POST['mode'], $admin, $iframe); diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_confirm.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_confirm.php deleted file mode 100755 index 64b4d2852c3..00000000000 --- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_confirm.php +++ /dev/null @@ -1,226 +0,0 @@ -<?php -/* -* Copyright 2014 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* -* -* @file -* @author <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup admin -*/ -$admin = new core_tools(); -$admin->load_lang(); -$return = $admin->test_admin('admin_contacts', 'apps', false); -if (!$return) { - $return = $admin->test_admin('create_contacts', 'apps', false); -} - -if (!$return) { - $return = $admin->test_admin('my_contacts', 'apps', false); -} - -if (!$return) { - $return = $admin->test_admin('my_contacts_menu', 'apps', false); -} - -if (!$return) { - $_SESSION['error'] = _SERVICE . ' ' . _UNKNOWN; - ?> - <script type="text/javascript">window.top.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php';</script> - <?php - exit(); -} - -$admin->load_html(); -$admin->load_header('', true, false); -$admin->load_js(); -require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_contacts_v2.php"); -require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_list_show.php"); -require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php'; -$contact = new contacts_v2(); -$db = new Database(); - -if (isset($_REQUEST['popup'])) { - echo '<div class="error" id="main_error">'; - functions::xecho($_SESSION['error']); - echo '</div>'; -} - -echo '<div class="info" id="main_info">'; -functions::xecho($_SESSION['info']); -echo '</div>'; - -$_SESSION['error'] = ''; -$_SESSION['info'] = ''; - -/****************Management of the location bar ************/ -$init = false; -if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") -{ - $init = true; -} -$level = ""; -if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) -{ - $level = $_REQUEST['level']; -} -$page_path = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_confirm'; -if($_GET['mode'] == 'up'){ - $page_label = _CONTACTS_CONFIRMATION_MODIFICATION; -} else { - $page_label = _CONTACTS_CONFIRMATION; -} -$page_id = "contacts_v2_confirm"; -$admin->manage_location_bar($page_path, $page_label, $page_id, $init, $level); -/***********************************************************/ -?> - -<h1><i class="fa fa-users fa-2x"></i> - <?php if($_GET['mode'] == 'up'){ - echo _CONTACTS_CONFIRMATION_MODIFICATION; - } else { - echo _CONTACTS_CONFIRMATION; - }?> -</h1> -<br/> - <?php $contact->get_contact_form();?> -<br/> - <?php echo _YOUR_CONTACT_LOOKS_LIKE_ANOTHER;?> -<br/> -<br/> -<?php - -$query = $contact->query_contact_exists($_GET['mode']); -$stmt = $db->query($query['query'], $query['params']); -$tab = array(); -while ($res = $stmt->fetch(PDO::FETCH_ASSOC)){ - $temp= array(); - foreach (array_keys($res) as $resval) - { - if (!is_int($resval)) - { - array_push($temp,array('column'=>$resval,'value'=>$res[$resval])); - } - } - array_push($tab, $temp); -} - -$list = new list_show(); - - for ($i=0;$i<count($tab);$i++) - { - for ($j=0;$j<count($tab[$i]);$j++) - { - foreach(array_keys($tab[$i][$j]) as $value) - { - if($tab[$i][$j][$value] == "contact_id"){ - $tab[$i][$j]["label"]=_ID; - $tab[$i][$j]["size"]="20"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["value"]=$tab[$i][$j]['value']; - } - if($tab[$i][$j][$value] == "contact_type"){ - $tab[$i][$j]["label"]=_CONTACT_TYPE; - $tab[$i][$j]["size"]="20"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["value"]=$contact->get_label_contact($tab[$i][$j]['value'], $_SESSION['tablename']['contact_types']); - } - if($tab[$i][$j][$value] == "society"){ - $tab[$i][$j]["label"]=_STRUCTURE_ORGANISM; - $tab[$i][$j]["size"]="20"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["value"]=$tab[$i][$j]['value']; - } - if($tab[$i][$j][$value] == "contact_firstname"){ - $tab[$i][$j]["label"]=_FIRSTNAME; - $tab[$i][$j]["size"]="20"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["value"]=$tab[$i][$j]['value']; - } - if($tab[$i][$j][$value] == "contact_lastname"){ - $tab[$i][$j]["label"]=_LASTNAME; - $tab[$i][$j]["size"]="20"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["value"]=$tab[$i][$j]['value']; - } - if($tab[$i][$j][$value]=="contact_enabled") - { - if ($tab[$i][$j]['value'] == "Y") { - $tab[$i][$j]['value'] = _ENABLED; - } else { - $tab[$i][$j]['value'] = _DISABLED; - } - $tab[$i][$j]["enabled"]= $tab[$i][$j]['value']; - $tab[$i][$j]["label"]=_STATUS; - $tab[$i][$j]["size"]="5"; - $tab[$i][$j]["label_align"]="center"; - $tab[$i][$j]["align"]="center"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["order"]= "contact_enabled"; - } - } - } - } - -?> -<div align="center"> - <?php $list->list_simple($tab, $i, '', 'contact_id', 'contact_id', false, "", 'listing spec', '', 400, 500);?> -</div> -<br/> -<br/> -<?php - if($_GET['mode'] == 'up'){ - echo _CONFIRM_EDIT_CONTACT; - } else { - echo _CONFIRM_CREATE_CONTACT; - } - - if($_GET['mycontact'] == 'N'){ ?> - <input class="button" type="button" value="<?php echo _YES;?>" name="Submit" onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?display=true&page=contacts_v2_up_db&confirm=Y&mode=<?php functions::xecho($_GET['mode']);?>';"> - <input class="button" type="button" value="<?php echo _NO;?>" name="Cancel" onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=contacts_v2';"> -<?php - } else if($_GET['mycontact'] == 'iframe'){?> - <input class="button" type="button" value="<?php echo _YES;?>" name="Submit" onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?display=true&page=my_contact_up_db&dir=my_contacts&confirm=Y&mode=<?php functions::xecho($_GET['mode']);?>&mycontact=iframe';"> - <input class="button" type="button" value="<?php echo _NO;?>" name="Cancel" onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?display=false&dir=my_contacts&page=create_contact_iframe';new Effect.toggle(parent.document.getElementById('create_contact_div'), 'blind', {delay:0.2});return false;"> -<?php - } else { ?> - <input class="button" type="button" value="<?php echo _YES;?>" name="Submit" onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?display=true&page=my_contact_up_db&dir=my_contacts&confirm=Y&mode=<?php functions::xecho($_GET['mode']);?>';"> - <input class="button" type="button" value="<?php echo _NO;?>" name="Cancel" onclick="javascript:window.location.href='<?php echo $_SESSION['config']['businessappurl'];?>index.php?page=my_contacts&dir=my_contacts&load';"> -<?php - } ?> - \ No newline at end of file diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php index f36bcbfc1e2..41a108cee58 100755 --- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php +++ b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up.php @@ -84,11 +84,6 @@ require_once "core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "cla require_once "apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_list_show.php"; $func = new functions(); -$select['view_contacts'] = array(); -array_push( - $select['view_contacts'], - "ca_id as id", "contact_id", "contact_purpose_id", "departement", "lastname", "firstname", "function", "address_num", "address_street", "address_postal_code", "address_town", "phone", "email", "enabled", "contact_purpose_label" -); $what = ""; $where = "contact_id = :contactid "; $arrayPDO = array(":contactid" => $id); diff --git a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php index 92266b379c5..207f893c428 100755 --- a/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php +++ b/apps/maarch_entreprise/admin/contacts/contacts_v2/contacts_v2_up_db.php @@ -53,5 +53,4 @@ if(isset($_GET['confirm']) && $_GET['confirm'] <> ''){ } else { $confirm = 'N'; } -$contact->addupcontact($_POST['mode'], true, $confirm); ?> diff --git a/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php b/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php index 6baace7b671..63d648d9b89 100755 --- a/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php +++ b/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php @@ -151,345 +151,6 @@ abstract class contacts_v2_Abstract extends Database $_SESSION['m_admin']['contact']['start'] = $_REQUEST['start']; } - public function is_exists($mode, $mycontact) - { - $query = $this->query_contact_exists($mode); - $db = new Database(); - $stmt = $db->query($query['query'], $query['params']); - if ($stmt->rowCount() > 0) { - if ($mode != 'up') { - $_SESSION['error'] = _THE_CONTACT.' '._ALREADY_EXISTS; - } - - if ($mycontact == 'iframe') { - $path_contacts_confirm = $_SESSION['config']['businessappurl'].'index.php?display=false&page=contacts_v2_confirm&popup'; - } else { - $path_contacts_confirm = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_confirm'; - } - header( - 'location: '.$path_contacts_confirm.'&body_loaded&mode='.$mode.'&mycontact='.$mycontact - ); - exit; - } - } - - public function query_contact_exists($mode) - { - $query = ''; - if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'N') { - $query = 'SELECT contact_id, contact_type, society, contact_firstname, contact_lastname, contact_enabled FROM view_contacts - WHERE lower(contact_firstname) = lower(?) - and lower(contact_lastname) = lower(?)'; - $arrayPDO = array($_SESSION['m_admin']['contact']['FIRSTNAME'], $_SESSION['m_admin']['contact']['LASTNAME']); - } elseif ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { - $query = 'SELECT contact_id, contact_type, society, contact_firstname, contact_lastname, contact_enabled FROM view_contacts - WHERE lower(society) = lower(?)'; - $arrayPDO = array($_SESSION['m_admin']['contact']['SOCIETY']); - } - if ($mode == 'up') { - $query .= ' and contact_id <> ?'; - $arrayPDO = array_merge($arrayPDO, array($_SESSION['m_admin']['contact']['ID'])); - } - - return array('query' => $query, 'params' => $arrayPDO); - } - - /** - * Add ou modify contact in the database. - * - * @param string $mode up or add - */ - public function addupcontact($mode, $admin = true, $confirm = 'N', $mycontact = 'N') - { - $db = new Database(); - - // add ou modify users in the database - if ($confirm == 'N') { - $this->contactinfo($mode); - } - if (empty($_SESSION['error']) && $confirm == 'N') { - $this->is_exists($mode, $mycontact); - } - $order = $_SESSION['m_admin']['contact']['order']; - $order_field = $_SESSION['m_admin']['contact']['order_field']; - $what = $_SESSION['m_admin']['contact']['what']; - $start = $_SESSION['m_admin']['contact']['start']; - - if ($mode == 'add') { - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?page=contact_addresses_add&order=' - .$order.'&order_field='.$order_field.'&start=' - .$start.'&what='.$what; - } else { - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?page=contacts_v2&order=' - .$order.'&order_field='.$order_field.'&start=' - .$start.'&what='.$what; - } - - $path_contacts_add_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=contacts_v2_add'; - $path_contacts_up_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=contacts_v2_up'; - if (!$admin) { - if ($mode == 'add') { - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?page=contact_addresses_add&mycontact=Y&order=' - .$order.'&order_field='.$order_field.'&start=' - .$start.'&what='.$what; - } else { - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?page=my_contacts&dir=my_contacts&load&order=' - .$order.'&order_field='.$order_field.'&start=' - .$start.'&what='.$what; - } - - $path_contacts_add_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=my_contact_add&dir=' - .'my_contacts&load'; - $path_contacts_up_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=my_contact_up&dir=' - .'my_contacts&load'; - } - if ($mycontact == 'iframe') { - if ($mode == 'add') { - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?display=false&dir=my_contacts&page=create_address_iframe'; - $path_contacts_add_errors = $_SESSION['config']['businessappurl'] - .'index.php?display=false&dir=my_contacts&page=create_contact_iframe'; - } elseif ($mode == 'up') { - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?display=false&dir=my_contacts&page=info_contact_iframe&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id'].'&created=Y'; - $path_contacts_up_errors = $_SESSION['config']['businessappurl'] - .'index.php?display=false&dir=my_contacts&page=info_contact_iframe&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; - } - } - if (!empty($_SESSION['error'])) { - if ($mode == 'up') { - if (!empty($_SESSION['m_admin']['contact']['ID'])) { - header( - 'location: '.$path_contacts_up_errors.'&id=' - .$_SESSION['m_admin']['contact']['ID'] - ); - exit; - } else { - header('location: '.$path_contacts); - exit; - } - } - if ($mode == 'add') { - header('location: '.$path_contacts_add_errors); - exit; - } - } else { - if ($mode == 'add') { - if ($_SESSION['user']['UserId'] == 'superadmin') { - $entity_id = 'SUPERADMIN'; - } else { - $entity_id = $_SESSION['user']['primaryentity']['id']; - } - $query = 'INSERT INTO '.$_SESSION['tablename']['contacts_v2'] - .' ( contact_type, lastname , firstname , society , society_short, function , ' - .'other_data,' - .' title, is_corporate_person, is_external_contact, user_id, entity_id, creation_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, current_timestamp)'; - - $db->query($query, array($_SESSION['m_admin']['contact']['CONTACT_TYPE'], $_SESSION['m_admin']['contact']['LASTNAME'], $_SESSION['m_admin']['contact']['FIRSTNAME'], $_SESSION['m_admin']['contact']['SOCIETY'], $_SESSION['m_admin']['contact']['SOCIETY_SHORT'], $_SESSION['m_admin']['contact']['FUNCTION'], $_SESSION['m_admin']['contact']['OTHER_DATA'], $_SESSION['m_admin']['contact']['TITLE'], $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'], $_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'], $_SESSION['user']['UserId'], $entity_id)); - if ($_SESSION['history']['contactadd']) { - $stmt = $db->query('SELECT contact_id, creation_date FROM '.$_SESSION['tablename']['contacts_v2'] - .' WHERE lastname = ? and firstname = ? and society = ? and function = ? and is_corporate_person = ? order by creation_date desc', array($_SESSION['m_admin']['contact']['LASTNAME'], $_SESSION['m_admin']['contact']['FIRSTNAME'], $_SESSION['m_admin']['contact']['SOCIETY'], $_SESSION['m_admin']['contact']['FUNCTION'], $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'])); - $res = $stmt->fetchObject(); - $id = $res->contact_id; - if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { - $msg = _CONTACT_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']); - } else { - $msg = _CONTACT_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['contact']['LASTNAME'].' '.$_SESSION['m_admin']['contact']['FIRSTNAME']); - } - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contacts_v2'], $id, 'ADD', 'contacts_v2_add', $msg, $_SESSION['config']['databasetype']); - } - - $sQueryString = ''; - $aQueryValues = []; - foreach (['lastname' => $_SESSION['m_admin']['contact']['LASTNAME'], - 'firstname' => $_SESSION['m_admin']['contact']['FIRSTNAME'], - 'society' => $_SESSION['m_admin']['contact']['SOCIETY'], - 'function' => $_SESSION['m_admin']['contact']['FUNCTION'], - 'is_corporate_person' => $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'], ] as $key => $value) { - if ($key != 'lastname') { - $sQueryString .= ' and '; - } - if (empty(trim($value))) { - $sQueryString .= ' ('.$key.' = \'\' or '.$key.' is null) '; - } else { - $sQueryString .= $key.' = ? '; - array_push($aQueryValues, $value); - } - } - - $stmt = $db->query('SELECT contact_id, creation_date FROM '.$_SESSION['tablename']['contacts_v2'] - .' WHERE '.$sQueryString.' order by creation_date desc', $aQueryValues); - - $res = $stmt->fetchObject(); - $id = $res->contact_id; - $_SESSION['contact']['current_contact_id'] = $id; - - if (!empty($_SESSION['m_admin']['communication']['TYPE']) && !empty($_SESSION['m_admin']['communication']['VALUE'])) { - $query = 'INSERT INTO '.$_SESSION['tablename']['contact_communication'] - .' ( contact_id, type, value) VALUES (?, ?, ?)'; - - $db->query($query, array($_SESSION['contact']['current_contact_id'], $_SESSION['m_admin']['communication']['TYPE'], $_SESSION['m_admin']['communication']['VALUE'])); - - if ($_SESSION['history']['contact_communication_add']) { - $stmt = $db->query('SELECT id FROM '.$_SESSION['tablename']['contact_communication'] - .' WHERE contact_id = ? and type = ? and value = ?', array($_SESSION['contact']['current_contact_id'], $_SESSION['m_admin']['communication']['TYPE'], $_SESSION['m_admin']['communication']['VALUE'])); - $res = $stmt->fetchObject(); - $id = $res->id; - $msg = _COMMUNICATION_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['communication']['TYPE'].' '.$_SESSION['m_admin']['communication']['VALUE']); - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contact_communication'], $id, 'ADD', 'contacts_communication_add', $msg, $_SESSION['config']['databasetype']); - } - } - - $_SESSION['info'] = _CONTACT_ADDED; - header('location: '.$path_contacts); - exit; - } elseif ($mode == 'up') { - $query = 'UPDATE '.$_SESSION['tablename']['contacts_v2'] - .' SET update_date = current_timestamp, contact_type = ?, lastname = ?, firstname = ?,society = ?,society_short = ?,function = ?, other_data = ?, title = ?, is_corporate_person = ?, is_external_contact = ?'; - $query .= ' WHERE contact_id = ?'; - $arrayPDO = array($_SESSION['m_admin']['contact']['CONTACT_TYPE'], $_SESSION['m_admin']['contact']['LASTNAME'], $_SESSION['m_admin']['contact']['FIRSTNAME'], $_SESSION['m_admin']['contact']['SOCIETY'], $_SESSION['m_admin']['contact']['SOCIETY_SHORT'], $_SESSION['m_admin']['contact']['FUNCTION'], $_SESSION['m_admin']['contact']['OTHER_DATA'], $_SESSION['m_admin']['contact']['TITLE'], $_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'], $_SESSION['m_admin']['contact']['IS_EXTERNAL_CONTACT'], $_SESSION['m_admin']['contact']['ID']); - - $db->query($query, $arrayPDO); - if ($_SESSION['history']['contactup']) { - if ($_SESSION['m_admin']['contact']['IS_CORPORATE_PERSON'] == 'Y') { - $msg = _CONTACT_MODIFIED.' : '.functions::protect_string_db($_SESSION['m_admin']['contact']['SOCIETY']); - } else { - $msg = _CONTACT_MODIFIED.' : '.functions::protect_string_db($_SESSION['m_admin']['contact']['LASTNAME'].' '.$_SESSION['m_admin']['contact']['FIRSTNAME']); - } - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contacts_v2'], $_SESSION['m_admin']['contact']['ID'], 'UP', 'contacts_v2_up', $msg, $_SESSION['config']['databasetype']); - } - - if (!empty($_SESSION['m_admin']['communication']['TYPE']) && !empty($_SESSION['m_admin']['communication']['VALUE'])) { - $stmt = $db->query('SELECT id FROM '.$_SESSION['tablename']['contact_communication'] - .' WHERE contact_id = ?', array($_SESSION['m_admin']['contact']['ID'])); - $res = $stmt->fetchObject(); - - if ($res) { - $query = 'UPDATE '.$_SESSION['tablename']['contact_communication'] - .' SET type = ?, value = ? WHERE contact_id = ?'; - - $db->query($query, array($_SESSION['m_admin']['communication']['TYPE'], $_SESSION['m_admin']['communication']['VALUE'], $_SESSION['m_admin']['contact']['ID'])); - if ($_SESSION['history']['contact_communication_up']) { - $stmt = $db->query('SELECT id FROM '.$_SESSION['tablename']['contact_communication'] - .' WHERE contact_id = ? AND type = ? AND value = ?', array($_SESSION['m_admin']['contact']['ID'], $_SESSION['m_admin']['communication']['TYPE'], $_SESSION['m_admin']['communication']['VALUE'])); - $res = $stmt->fetchObject(); - $id = $res->id; - $msg = _COMMUNICATION_MODIFIED.' : '.functions::protect_string_db($_SESSION['m_admin']['communication']['TYPE'].' '.$_SESSION['m_admin']['communication']['VALUE']); - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contact_communication'], $id, 'UP', 'contacts_communication_up', $msg, $_SESSION['config']['databasetype']); - } - } else { - $query = 'INSERT INTO '.$_SESSION['tablename']['contact_communication'] - .' ( contact_id, type, value) VALUES (?, ?, ?)'; - - $db->query($query, array($_SESSION['contact']['current_contact_id'], $_SESSION['m_admin']['communication']['TYPE'], $_SESSION['m_admin']['communication']['VALUE'])); - - if ($_SESSION['history']['contact_communication_add']) { - $stmt = $db->query('SELECT id FROM '.$_SESSION['tablename']['contact_communication'] - .' WHERE contact_id = ? and type = ? and value = ?', array($_SESSION['contact']['current_contact_id'], $_SESSION['m_admin']['communication']['TYPE'], $_SESSION['m_admin']['communication']['VALUE'])); - $res = $stmt->fetchObject(); - $id = $res->id; - $msg = _COMMUNICATION_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['communication']['TYPE'].' '.$_SESSION['m_admin']['communication']['VALUE']); - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contact_communication'], $id, 'ADD', 'contacts_communication_add', $msg, $_SESSION['config']['databasetype']); - } - } - } elseif (empty($_SESSION['m_admin']['communication']['TYPE']) && empty($_SESSION['m_admin']['communication']['VALUE'])) { - $query = 'DELETE FROM '.$_SESSION['tablename']['contact_communication'] - .' WHERE contact_id = ?'; - - $db->query($query, array($_SESSION['m_admin']['contact']['ID'])); - if ($_SESSION['history']['contact_communication_add']) { - $msg = _COMMUNICATION_DELETED; - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contact_communication'], '', 'DEL', 'contacts_communication_del', $msg, $_SESSION['config']['databasetype']); - } - } - - $contactToUpdate = \Contact\models\ContactModel::getOnView(['select' => ['external_id'], 'where' => ['contact_id = ?'], 'data' => [$_SESSION['m_admin']['contact']['ID']]]); - $externalId = []; - if (count($contactToUpdate) == 1) { - $externalId = json_decode($contactToUpdate[0]['external_id'], true); - } - - if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'updateContactToExternalApplication']) && !empty($externalId['localeoId'])) { - $bodyData = []; - $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'updateContactToExternalApplication']); - - if (!empty($config['inObject'])) { - foreach ($config['objects'] as $object) { - $select = []; - $tmpBodyData = []; - foreach ($object['rawData'] as $value) { - $select[] = $value; - } - - $select[] = 'ca_id'; - $select[] = 'firstname'; - $select[] = 'lastname'; - $document = \Contact\models\ContactModel::getOnView(['select' => $select, 'where' => ['contact_id = ?'], 'data' => [$_SESSION['m_admin']['contact']['ID']]]); - if (!empty($document[0])) { - foreach ($object['rawData'] as $key => $value) { - if ($value == 'external_id') { - $tmpBodyData[$key] = $externalId['localeoId']; - } else { - if ($value == 'contact_firstname' && empty($document[0][$value])) { - $value = 'firstname'; - } elseif ($value == 'contact_lastname' && empty($document[0][$value])) { - $value = 'lastname'; - } - $tmpBodyData[$key] = $document[0][$value]; - } - } - } - - if (!empty($object['data'])) { - $tmpBodyData = array_merge($tmpBodyData, $object['data']); - } - - $bodyData[$object['name']] = json_encode($tmpBodyData); - } - } - - $response = \SrcCore\models\CurlModel::execSimple([ - 'url' => $config['url'], - 'headers' => $config['header'], - 'method' => $config['method'], - 'body' => $bodyData, - ]); - } - - $this->clearcontactinfos(); - $_SESSION['info'] = _CONTACT_MODIFIED; - if (isset($_SESSION['fromContactTree']) && $_SESSION['fromContactTree'] == 'yes') { - unset($_SESSION['fromContactTree']); - header('location: '.$_SESSION['config']['businessappurl'].'index.php?page=view_tree_contacts'); - exit(); - } else { - header('location: '.$path_contacts); - exit(); - } - } - } - } - /** * Form to modify a contact v2. * @@ -2177,334 +1838,6 @@ abstract class contacts_v2_Abstract extends Database } - /** - * Add ou modify address in the database. - * - * @param string $mode up or add - */ - public function addupaddress($mode, $admin = true, $iframe = false) - { - $db = new Database(); - // add ou modify users in the database - $this->addressinfo($mode); - $order = $_SESSION['m_admin']['address']['order']; - $order_field = $_SESSION['m_admin']['address']['order_field']; - $what = $_SESSION['m_admin']['address']['what']; - $start = $_SESSION['m_admin']['address']['start']; - - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?page=contacts_v2_up&order=' - .$order.'&order_field='.$order_field.'&start=' - .$start.'&what='.$what; - $path_contacts_add_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=contact_addresses_add'; - $path_contacts_up_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=contact_addresses_up'; - if (!$admin) { - $path_contacts = $_SESSION['config']['businessappurl'] - .'index.php?dir=my_contacts&page=my_contact_up&load&order=' - .$order.'&order_field='.$order_field.'&start=' - .$start.'&what='.$what; - $path_contacts_add_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=contact_addresses_add&mycontact=Y'; - $path_contacts_up_errors = $_SESSION['config']['businessappurl'] - .'index.php?page=contact_addresses_up&mycontact=Y'; - } - if ($iframe) { - if ($mode == 'add') { - if ($iframe == 1) { - $path_contacts = 'index.php?display=false&dir=my_contacts&page=create_contact_iframe&created=Y'; - $path_contacts_add_errors = 'index.php?display=false&dir=my_contacts&page=create_address_iframe'; - } elseif ($iframe == 2) { - $path_contacts = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; - $path_contacts_add_errors = 'index.php?display=false&dir=my_contacts&page=create_address_iframe&iframe=iframe_up_add'; - } elseif ($iframe == 3) { - $path_contacts = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=add&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; - $path_contacts_add_errors = 'index.php?display=false&dir=my_contacts&page=create_address_iframe&iframe=iframe_up_add'; - } - } elseif ($mode == 'up') { - if ($iframe == 3) { - $path_contacts = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=Y&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; - } else { - $path_contacts = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=Y&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; - } - - $path_contacts_up_errors = 'index.php?display=false&dir=my_contacts&page=update_address_iframe'; - - if ($iframe == 4) { - $path_contacts = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=editDetail&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; - $path_contacts_up_errors = 'index.php?display=false&dir=my_contacts&page=update_address_iframe&editDetail'; - } elseif ($iframe == 5) { - $path_contacts = 'index.php?display=false&dir=my_contacts&page=info_contact_iframe&created=editDetailSender&contactid='.$_SESSION['contact']['current_contact_id'].'&addressid='.$_SESSION['contact']['current_address_id']; - $path_contacts_up_errors = 'index.php?display=false&dir=my_contacts&page=update_address_iframe&editDetailSender'; - } - - } - } - if (isset($_SESSION['contact_address']['fromContactAddressesList']) && $_SESSION['contact_address']['fromContactAddressesList'] != '') { - $path_contacts = $_SESSION['config']['businessappurl'].'index.php?page=contact_addresses_list'; - $path_contacts_up_errors = $_SESSION['config']['businessappurl'].'index.php?page=contact_addresses_up&fromContactAddressesList'; - $_SESSION['contact_address']['fromContactAddressesList'] = ''; - } - if (!empty($_SESSION['error'])) { - if ($mode == 'up') { - if (!empty($_SESSION['m_admin']['address']['ID'])) { - $_SESSION['address_up_error'] = 'true'; - header( - 'location: '.$path_contacts_up_errors.'&id=' - .$_SESSION['m_admin']['address']['ID'] - ); - exit; - } else { - header('location: '.$path_contacts); - exit; - } - } - if ($mode == 'add') { - header('location: '.$path_contacts_add_errors); - exit; - } - } else { - if ($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] == '') { - $stmt = $db->query('SELECT id FROM contact_purposes WHERE label = ?', array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); - if ($stmt->rowCount() == 0) { - $db->query('INSERT INTO contact_purposes (label) VALUES (?)', array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); - $stmt = $db->query('SELECT id FROM contact_purposes WHERE label = ?', array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); - } - - $res_purpose = $stmt->fetchObject(); - $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $res_purpose->id; - } elseif ($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] != '' && $_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'] != '') { - $stmt = $db->query('SELECT id FROM contact_purposes WHERE label = ?', array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); - $res_purpose = $stmt->fetchObject(); - if ($res_purpose->id != $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID']) { - $db->query('INSERT INTO contact_purposes (label) VALUES (?)', array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); - $stmt = $db->query('SELECT id FROM contact_purposes WHERE label = ?', array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_NAME'])); - $res_purpose = $stmt->fetchObject(); - $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'] = $res_purpose->id; - } - } - if ($mode == 'add') { - if ($_SESSION['user']['UserId'] == 'superadmin') { - $entity_id = 'SUPERADMIN'; - } else { - $entity_id = $_SESSION['user']['primaryentity']['id']; - } - $query = 'INSERT INTO '.$_SESSION['tablename']['contact_addresses'] - .' ( contact_id, contact_purpose_id, departement, lastname , firstname , function , ' - .'phone , email , address_num, address_street, ' - .'address_complement, address_town, ' - .'address_postal_code, address_country, other_data,' - .' title, is_private, website, occupancy, user_id, entity_id, salutation_header, salutation_footer, external_id, ban_id) VALUES (?, ?, - ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; - - $arrayPDO = array($_SESSION['contact']['current_contact_id'], $_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'], $_SESSION['m_admin']['address']['DEPARTEMENT'], - $_SESSION['m_admin']['address']['LASTNAME'], $_SESSION['m_admin']['address']['FIRSTNAME'], $_SESSION['m_admin']['address']['FUNCTION'], $_SESSION['m_admin']['address']['PHONE'], - $_SESSION['m_admin']['address']['MAIL'], $_SESSION['m_admin']['address']['ADD_NUM'], $_SESSION['m_admin']['address']['ADD_STREET'], $_SESSION['m_admin']['address']['ADD_COMP'], - $_SESSION['m_admin']['address']['ADD_TOWN'], $_SESSION['m_admin']['address']['ADD_CP'], $_SESSION['m_admin']['address']['ADD_COUNTRY'], $_SESSION['m_admin']['address']['OTHER_DATA'], - $_SESSION['m_admin']['address']['TITLE'], $_SESSION['m_admin']['address']['IS_PRIVATE'], $_SESSION['m_admin']['address']['WEBSITE'], $_SESSION['m_admin']['address']['OCCUPANCY'], - $_SESSION['user']['UserId'], $entity_id, $_SESSION['m_admin']['address']['SALUTATION_HEADER'], $_SESSION['m_admin']['address']['SALUTATION_FOOTER'], json_encode(['m2m' => $_SESSION['m_admin']['address']['M2M_ID']]), $_SESSION['m_admin']['address']['BAN_ID'], ); - - $db->query($query, $arrayPDO); - if ($_SESSION['history']['addressadd']) { - $stmt = $db->query('SELECT id FROM '.$_SESSION['tablename']['contact_addresses'].' WHERE - lastname = ? and firstname = ? and society = ? and function = ? and is_corporate_person = ?', - array($_SESSION['m_admin']['address']['LASTNAME'], $_SESSION['m_admin']['address']['FIRSTNAME'], $_SESSION['m_admin']['address']['SOCIETY'], $_SESSION['m_admin']['address']['FUNCTION'], $_SESSION['m_admin']['address']['IS_CORPORATE_PERSON'])); - $res = $stmt->fetchObject(); - $id = $res->contact_id; - if ($_SESSION['m_admin']['address']['IS_CORPORATE_PERSON'] == 'Y') { - $msg = _ADDRESS_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['address']['SOCIETY']); - } else { - $msg = _ADDRESS_ADDED.' : '.functions::protect_string_db($_SESSION['m_admin']['address']['LASTNAME'].' '.$_SESSION['m_admin']['address']['FIRSTNAME']); - } - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contact_addresses'], $id, 'ADD', 'contact_addresses_add', $msg, $_SESSION['config']['databasetype']); - } - - if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'sendContactToExternalApplication'])) { - $bodyData = []; - $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'sendContactToExternalApplication']); - - if (!empty($config['inObject'])) { - $multipleObject = true; - - foreach ($config['objects'] as $object) { - $select = []; - $tmpBodyData = []; - foreach ($object['rawData'] as $value) { - $select[] = $value; - } - - $select[] = 'ca_id'; - $select[] = 'firstname'; - $select[] = 'lastname'; - $select[] = 'title'; - $select[] = 'external_id'; - $document = \Contact\models\ContactModel::getOnView(['select' => $select, 'where' => ['contact_id = ?'], 'data' => [$_SESSION['contact']['current_contact_id']]]); - if (!empty($document[0])) { - foreach ($object['rawData'] as $key => $value) { - if ($value == 'contact_firstname' && empty($document[0][$value])) { - $value = 'firstname'; - } elseif ($value == 'contact_lastname' && empty($document[0][$value])) { - $value = 'lastname'; - } elseif ($value == 'contact_title' && empty($document[0][$value])) { - $value = 'title'; - } - $tmpBodyData[$key] = $document[0][$value]; - } - } - - if (!empty($object['data'])) { - $tmpBodyData = array_merge($tmpBodyData, $object['data']); - } - - $bodyData[$object['name']] = $tmpBodyData; - } - } else { - $multipleObject = false; - - $select = []; - foreach ($config['rawData'] as $value) { - $select[] = $value; - } - - $select[] = 'ca_id'; - $document = \Contact\models\ContactModel::getOnView(['select' => $select, 'where' => ['contact_id = ?'], 'data' => [$_SESSION['contact']['current_contact_id']]]); - if (!empty($document[0])) { - foreach ($config['rawData'] as $key => $value) { - $bodyData[$key] = $document[0][$value]; - } - } - - if (!empty($config['data'])) { - $bodyData = array_merge($bodyData, $config['data']); - } - } - - $response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendContactToExternalApplication', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]); - - if (!empty($response[$config['return']['key']])) { - $externalId = json_decode($document[0]['external_id'], true); - $externalId['localeoId'] = $response[$config['return']['key']]; - - \Contact\models\ContactModel::updateAddress(['set' => ['external_id' => json_encode($externalId)], 'where' => ['id = ?'], 'data' => [$document[0]['ca_id']]]); - } - } - - if ($iframe) { - $this->clearcontactinfos(); - } - - $this->clearaddressinfos(); - $_SESSION['info'] = _ADDRESS_ADDED; - header('location: '.$path_contacts); - exit; - } elseif ($mode == 'up') { - $contactToUpdate = \Contact\models\ContactModel::getByAddressId(['addressId' => $_SESSION['m_admin']['address']['ID'], 'select' => ['external_id']]); - $externalId = json_decode($contactToUpdate['external_id'], true); - $externalId['m2m'] = empty($_SESSION['m_admin']['address']['M2M_ID']) ? null : $_SESSION['m_admin']['address']['M2M_ID']; - - $query = 'UPDATE '.$_SESSION['tablename']['contact_addresses'].' - SET contact_purpose_id = ? - , departement = ? - , firstname = ? - , lastname = ? - , title = ? - , function = ? - , phone = ? - , email = ? - , occupancy = ? - , address_num = ? - , address_street = ? - , address_complement = ? - , address_town = ? - , address_postal_code = ? - , address_country = ? - , website = ? - , other_data = ? - , is_private = ? - , salutation_header = ? - , salutation_footer = ? - , external_id = ? - , ban_id = ? - '; - - $query .= ' WHERE id = ?'; - - $arrayPDO = array($_SESSION['m_admin']['address']['CONTACT_PURPOSE_ID'], $_SESSION['m_admin']['address']['DEPARTEMENT'], $_SESSION['m_admin']['address']['FIRSTNAME'], - $_SESSION['m_admin']['address']['LASTNAME'], $_SESSION['m_admin']['address']['TITLE'], $_SESSION['m_admin']['address']['FUNCTION'], $_SESSION['m_admin']['address']['PHONE'], - $_SESSION['m_admin']['address']['MAIL'], $_SESSION['m_admin']['address']['OCCUPANCY'], $_SESSION['m_admin']['address']['ADD_NUM'], $_SESSION['m_admin']['address']['ADD_STREET'], $_SESSION['m_admin']['address']['ADD_COMP'], - $_SESSION['m_admin']['address']['ADD_TOWN'], $_SESSION['m_admin']['address']['ADD_CP'], $_SESSION['m_admin']['address']['ADD_COUNTRY'], $_SESSION['m_admin']['address']['WEBSITE'], - $_SESSION['m_admin']['address']['OTHER_DATA'], $_SESSION['m_admin']['address']['IS_PRIVATE'], $_SESSION['m_admin']['address']['SALUTATION_HEADER'], $_SESSION['m_admin']['address']['SALUTATION_FOOTER'], json_encode($externalId), $_SESSION['m_admin']['address']['BAN_ID'], - $_SESSION['m_admin']['address']['ID'], ); - - $db->query($query, $arrayPDO); - if ($_SESSION['history']['contactup']) { - $msg = _ADDRESS_EDITED.' : '.functions::protect_string_db($_SESSION['m_admin']['address']['SOCIETY']).' '.functions::protect_string_db($_SESSION['m_admin']['address']['LASTNAME'].' '.$_SESSION['m_admin']['address']['FIRSTNAME']); - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'; - $hist = new history(); - $hist->add($_SESSION['tablename']['contacts_v2'], $_SESSION['m_admin']['address']['ID'], 'UP', 'contacts_v2_up', $msg, $_SESSION['config']['databasetype']); - } - - if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'updateContactToExternalApplication']) && !empty($externalId['localeoId'])) { - $bodyData = []; - $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'updateContactToExternalApplication']); - - if (!empty($config['inObject'])) { - foreach ($config['objects'] as $object) { - $select = []; - $tmpBodyData = []; - foreach ($object['rawData'] as $value) { - $select[] = $value; - } - - $select[] = 'ca_id'; - $select[] = 'firstname'; - $select[] = 'lastname'; - $select[] = 'title'; - $document = \Contact\models\ContactModel::getOnView(['select' => $select, 'where' => ['contact_id = ?'], 'data' => [$_SESSION['contact']['current_contact_id']]]); - if (!empty($document[0])) { - foreach ($object['rawData'] as $key => $value) { - if ($value == 'external_id') { - $tmpBodyData[$key] = $externalId['localeoId']; - } else { - if ($value == 'contact_firstname' && empty($document[0][$value])) { - $value = 'firstname'; - } elseif ($value == 'contact_lastname' && empty($document[0][$value])) { - $value = 'lastname'; - } elseif ($value == 'contact_title' && empty($document[0][$value])) { - $value = 'title'; - } - $tmpBodyData[$key] = $document[0][$value]; - } - } - } - - if (!empty($object['data'])) { - $tmpBodyData = array_merge($tmpBodyData, $object['data']); - } - - $bodyData[$object['name']] = json_encode($tmpBodyData); - } - } - - $response = \SrcCore\models\CurlModel::execSimple([ - 'url' => $config['url'], - 'headers' => $config['header'], - 'method' => $config['method'], - 'body' => $bodyData, - ]); - } - - $this->clearcontactinfos(); - $_SESSION['info'] = _ADDRESS_EDITED; - header('location: '.$path_contacts); - exit(); - } - } - } - /** * Return the address data in sessions vars. * diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index 571de453393..d14b0bc2db1 100755 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -1582,11 +1582,6 @@ abstract class lists_Abstract extends Database } } - if ($isMultiContacts == 'Y') { - $return .= '<i class="fa fa-book fa-2x" style="cursor: pointer;" title="' - ._VIEW_CONTACTS.'"onclick="loadContactsList('.$resMultiContacts.');" ></i>'; - } - return $return; } diff --git a/apps/maarch_entreprise/class/class_multicontacts.php b/apps/maarch_entreprise/class/class_multicontacts.php deleted file mode 100755 index 9f02e4f2518..00000000000 --- a/apps/maarch_entreprise/class/class_multicontacts.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/* -* -* Copyright 2012-2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* -* @file class_modules_tools.php -* @date $date$ -* @version $Revision$ -*/ - -require_once 'apps/'. $_SESSION['config']['app_id'] .'/class/class_multicontacts_Abstract.php'; - -class multicontacts extends multicontacts_Abstract -{ - // custom -} diff --git a/apps/maarch_entreprise/class/class_multicontacts_Abstract.php b/apps/maarch_entreprise/class/class_multicontacts_Abstract.php deleted file mode 100755 index 10383b996ab..00000000000 --- a/apps/maarch_entreprise/class/class_multicontacts_Abstract.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/* -* -* Copyright 2012-2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* -* @file class_multicontacts_Abstract.php -* @date $date$ -* @version $Revision$ -*/ - -// Loads the required class -try { - require_once("core/class/class_security.php"); -} catch (Exception $e) { - functions::xecho($e->getMessage()).' // '; -} - -abstract class multicontacts_Abstract extends Database -{ - public function updateContactsInputField($ajaxPath, $contactsArray, $inputField, $readOnly = false) - { - $content = '<div style="max-height: 350px;overflow-x: hidden;overflow-y: auto">'; - //Init with loading div - $content .= '<div id="loading_'.$inputField.'" style="display:none;"><img src="' - . $_SESSION['config']['businessappurl'] - . 'static.php?filename=loading.gif" width="12" ' - . 'height="12" style="vertical-align: middle;" alt=' - . '"loading..." title="loading..."></div>'; - // $content .= print_r($adressArray, true); - //Get info from session array and display tag - if (isset($contactsArray[$inputField]) && count($contactsArray[$inputField]) > 0) { - foreach ($contactsArray[$inputField] as $key => $contacts) { - if (!empty($contacts)) { - $rate['color'] = 'LightYellow'; - if (!empty($contactsArray['addressid'][$key])) { - $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$contactsArray['addressid'][$key]]]); - $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]); - } - $content .= '<div style="width:200px; background-color:'.$rate['color'].';" class="multicontact_element" id="'.$key.'_'.$contacts.'"><div style="display:table-cell;width:100%;vertical-align:middle;">'.$contacts.'</div>'; - if ($readOnly === false) { - $content .= '<div class="email_delete_button" style="display:table-cell;vertical-align:middle; background-color:'.$rate['color'].';" id="'.$key.'"' - . 'onclick="updateMultiContacts(\''.$ajaxPath - .'&mode=adress\', \'del\', \''.addslashes($contacts).'\', \'' - .$inputField.'\', this.id, \''.$contactsArray['addressid'][$key].'\', \''.$contactsArray['contactid'][$key].'\');" alt="'._DELETE.'" title="' - ._DELETE.'">x</div>'; - } - $content .= '</div>'; - } - } - } - $content .= "</div>"; - return $content; - } -} diff --git a/apps/maarch_entreprise/definition_mail_categories.php b/apps/maarch_entreprise/definition_mail_categories.php index ec3c9788977..75e1a468f65 100755 --- a/apps/maarch_entreprise/definition_mail_categories.php +++ b/apps/maarch_entreprise/definition_mail_categories.php @@ -786,504 +786,6 @@ if ($core->is_module_loaded('entities')) { /************************* END *************************************************************/ -/** - * Gets the index of a given res_id in an array. - * - * @param $coll_id string Collection identifier - * @param $res_id string Resource identifier - * @param $mode string 'full' : fills the array with maximum data (id, value, show_value,etc...), 'minimal' the array contains only the value or 'form" the array contains the data to be displayed in a form - * @param $params array optional parameters - * $params['img_'.field_id] = true (gets the img url in the 'full' mode array for the field_id), false (no img for the field_id ) - * - * @return array Structure different in 'full' mode, 'form' and 'minimal' mode - * mode 'full' : $data[field_id] field_id exemple: 'priority' - * ['value'] : value of the field in the database - * ['show_value'] : value to display - * ['label'] : label to display - * ['display'] : type of display (only 'textinput' and 'textarea' for the moment) - * ['img'] : url of an icon to display (optional) - * mode 'minimal' : $data[field_id] = value of the field in the database - * mode 'form' : $data[field_id] field_id exemple: 'priority' - * ['value'] : value of the field in the database - * ['show_value'] : value to display - * ['label'] : label to display - * ['display'] : type of display (only 'textinput' and 'textarea' for the moment) - * ['img'] : url of an icon to display (optional) - * ['readonly'] : true or false - * ['field_type'] : keyword 'date' = date input field with calendar - * 'textfield' = text input field - * 'select' = select field - * ['select'] : array of options items (only if field_type = 'select') - * [$i]['id'] : option value - * ['label'] : option text - */ -function get_general_data($coll_id, $res_id, $mode, $params = array()) -{ - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php'; - $sec = new security(); - $view = $sec->retrieve_view_from_coll_id($coll_id); - if (empty($view)) { - $view = $sec->retrieve_table_from_coll($coll_id); - } - $db = new Database(); - $stmt = $db->query('SELECT category_id FROM '.$view.' WHERE res_id = ?', array($res_id)); - $res = $stmt->fetchObject(); - $cat_id = $res->category_id; - $fields = ''; - $data = array(); - $arr = array(); - - // First we load the category_id - if ($mode == 'full' || 'form') { - $data['category_id'] = array( - 'value' => $res->category_id, - 'show_value' => $_SESSION['coll_categories']['letterbox_coll'][$res->category_id], - 'label' => _CATEGORY, - 'display' => 'textinput', - 'img' => 'arrows-alt', - ); - } else { - $data['category_id'] = $res->category_id; - } - if (!isset($cat_id) || empty($cat_id)) { - $cat_id = 'empty'; - } - //Then we browse the $_ENV['categories'] array to get the other indexes - foreach (array_keys($_ENV['categories'][$cat_id]) as $field) { - // Normal cases : fields are put in a string to make a query - if ($field != 'process_limit_date_use' && $field != 'other_cases' && $field != 'type_contact' && $field != 'img_cat') { - $fields .= $field.','; - if (($mode == 'full' || $mode == 'form') && (!isset($params['show_'.$field]) || $params['show_'.$field] == true)) { - $data[$field] = array( - 'value' => '', - 'show_value' => '', - 'label' => $_ENV['categories'][$cat_id][$field]['label'], - 'display' => 'textinput', - 'img' => $_ENV['categories'][$cat_id][$field]['img'], - ); - array_push($arr, $field); - if ($field == 'subject' || $field == 'description' || $field == 'destination') { - $data[$field]['display'] = 'textarea'; - } - $data[$field]['readonly'] = true; - if ($mode == 'form' && $_ENV['categories'][$cat_id][$field]['modify']) { - $data[$field]['readonly'] = false; - $data[$field]['field_type'] = $_ENV['categories'][$cat_id][$field]['form_show']; - if ($data[$field]['field_type'] == 'select') { - $data[$field]['select'] = array(); - if ($field == 'type_id') { - require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php'; - $type = new types(); - if ($_SESSION['features']['show_types_tree'] == 'true') { - $data[$field]['select'] = $type->getArrayStructTypes($coll_id); - } else { - $data[$field]['select'] = $type->getArrayTypes($coll_id); - } - } elseif ($field == 'destination') { - //require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_entities.php"); - // TO DO : get the entities list - } elseif ($field == 'priority') { - foreach (array_keys($_SESSION['mail_priorities']) as $prio) { - $data[$field]['select'][] = [ - 'ID' => $_SESSION['mail_priorities_id'][$prio], - 'LABEL' => $_SESSION['mail_priorities'][$prio], - ]; - } - } - } - } - } elseif ($mode == 'minimal' && (!isset($params['show_'.$field]) || $params['show_'.$field] == true)) { - $data[$field] = ''; - array_push($arr, $field); - } - } - } - // Special cases : fields are put in a string to make a query - // Special cases : fields are put in a string to make a query - //confidentiality - if (isset($_ENV['categories'][$cat_id]['confidentiality']) && count($_ENV['categories'][$cat_id]['confidentiality']) > 0) { - $data['confidentiality'] = array( - /* 'value' => '', - 'show_value' => '', - 'label' => $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['label'], - 'display' => 'textinput',*/ - 'img' => $_ENV['categories'][$cat_id]['confidentiality']['img'], - 'modify' => true, - 'label' => $_ENV['categories'][$cat_id]['confidentiality']['label'], - 'form_show' => 'radio', - 'field_type' => 'radio', - 'readonly' => true, - ); - - // ajout du test suivant pour permettre de rendre le champs non modifiable - if ($mode == 'form' && $_ENV['categories'][$cat_id]['confidentiality']['modify']) { - $data['confidentiality']['readonly'] = false; - } - $data['confidentiality']['radio'] = array(); - array_push($data['confidentiality']['radio'], array( - 'ID' => 'Y', - 'LABEL' => _YES, - )); - array_push($data['confidentiality']['radio'], array( - 'ID' => 'N', - 'LABEL' => _NO, - )); - } - // Process limit date - if (isset($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']) && count($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']) > 0 && (!isset($params['show_process_limit_date']) || $params['show_process_limit_date'] == true)) { - $fields .= 'process_limit_date,'; - if ($mode == 'full' || 'form') { - $data['process_limit_date'] = array( - 'value' => '', - 'show_value' => '', - 'label' => $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['label'], - 'display' => 'textinput', - 'img' => $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['img'], - 'modify' => $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['modify'], - 'form_show' => 'date', - 'field_type' => 'date', - ); - - if (isset($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['modify']) - && $mode == 'form' && $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['modify'] - ) { - $data['process_limit_date']['field_type'] = $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['form_show']; - $data['process_limit_date']['readonly'] = false; - } - } else { - $data['process_limit_date'] = ''; - $data['process_limit_date_use'] = false; - } - array_push($arr, 'process_limit_date'); - } - // Contact - if (isset($_ENV['categories'][$cat_id]['other_cases']['contact']) && count($_ENV['categories'][$cat_id]['other_cases']['contact']) > 0 && (!isset($params['show_contact']) || $params['show_contact'] == true)) { - $fields .= $_ENV['categories'][$cat_id]['other_cases']['contact']['special'].','; - if (preg_match('/,/', $_ENV['categories'][$cat_id]['other_cases']['contact']['special'])) { - $arr_tmp = preg_split('/,/', $_ENV['categories'][$cat_id]['other_cases']['contact']['special']); - } else { - $arr_tmp = array( - $_ENV['categories'][$cat_id]['other_cases']['contact']['special'], - ); - } - for ($i = 0; $i < count($arr_tmp); ++$i) { - if ($mode == 'full' || $mode == 'form') { - $data[$arr_tmp[$i]] = array( - 'value' => '', - 'show_value' => '', - 'label' => $_ENV['categories'][$cat_id]['other_cases']['contact']['label'], - 'display' => 'textarea', - 'img' => $_ENV['categories'][$cat_id]['other_cases']['contact']['img'], - 'field_type' => $_ENV['categories'][$cat_id]['other_cases']['contact']['form_show'], - ); - if (isset($_ENV['categories'][$cat_id]['other_cases']['contact']['modify']) - && $mode == 'form' && $_ENV['categories'][$cat_id]['other_cases']['contact']['modify'] - ) { - $data[$arr_tmp[$i]]['readonly'] = false; - } - } - array_push($arr, $arr_tmp[$i]); - } - - if ($mode == 'minimal') { - $data['contact'] = ''; - } - } - - if (!empty($_ENV['categories'][$cat_id]['other_cases']['resourceContact'])) { - $data['resourceContact'] = array( - 'value' => '', - 'show_value' => '', - 'label' => $_ENV['categories'][$cat_id]['other_cases']['resourceContact']['label'], - 'display' => 'textarea', - 'img' => $_ENV['categories'][$cat_id]['other_cases']['resourceContact']['img'], - 'field_type' => $_ENV['categories'][$cat_id]['other_cases']['resourceContact']['form_show'], - ); - if (isset($_ENV['categories'][$cat_id]['other_cases']['resourceContact']['modify']) - && $mode == 'form' && $_ENV['categories'][$cat_id]['other_cases']['resourceContact']['modify'] - ) { - $data['resourceContact']['readonly'] = false; - } - $arr[] = 'resourceContact'; - } - - if ($mode == 'full' || $mode == 'form') { - $fields = preg_replace('/,$/', ',type_label', $fields); - } else { - $fields = preg_replace('/,$/', '', $fields); - } - // Query - $stmt = $db->query('SELECT category_id,'.$fields.' FROM '.$view.' WHERE res_id = ?', array($res_id)); - - $line = $stmt->fetchObject(); - // We fill the array with the query result - for ($i = 0; $i < count($arr); ++$i) { - if ($mode == 'full' || $mode == 'form') { - // Normal Cases - if (isset($line->{$arr[$i]})) { - $data[$arr[$i]]['value'] = $line->{$arr[$i]}; - } - if ($arr[$i] <> 'description') { - $data[$arr[$i]]['show_value'] = functions::show_string($data[$arr[$i]]['value']); - } - if (isset($_ENV['categories'][$cat_id][$arr[$i]]['type_field']) - && $_ENV['categories'][$cat_id][$arr[$i]]['type_field'] == 'date' - ) { - $data[$arr[$i]]['show_value'] = functions::format_date_db($line->{$arr[$i]}, false); - } elseif (isset($_ENV['categories'][$cat_id]['other_cases'][$arr[$i]]['type_field']) - && $_ENV['categories'][$cat_id]['other_cases'][$arr[$i]]['type_field'] == 'date' - ) { - $data[$arr[$i]]['show_value'] = functions::format_date_db($line->{$arr[$i]}, false); - } elseif (isset($_ENV['categories'][$cat_id][$arr[$i]]['type_field']) - && $_ENV['categories'][$cat_id][$arr[$i]]['type_field'] == 'string' - ) { - $data[$arr[$i]]['show_value'] = functions::show_string($line->{$arr[$i]}, true, '', '', false); - } - // special cases : - if ($arr[$i] == 'priority') { - foreach ($_SESSION['mail_priorities_id'] as $key => $prioValue) { - if ($prioValue == $line->priority) { - $fakeId = $key; - } - } - $data[$arr[$i]]['show_value'] = $_SESSION['mail_priorities'][$fakeId]; - } else if ($arr[$i] == 'department_number_id') { - require_once("apps".DIRECTORY_SEPARATOR."maarch_entreprise".DIRECTORY_SEPARATOR."department_list.php"); - if (!empty($line->{$arr[$i]})) { - $data[$arr[$i]]['show_value'] = $line->{$arr[$i]} . ' - ' . $depts[$line->{$arr[$i]}]; - } - } else if ($arr[$i] == 'departure_date') { - if (!empty($line->{$arr[$i]})) { - $data[$arr[$i]]['show_value'] = functions::format_date_db($line->{$arr[$i]},false); - } - } elseif ($arr[$i] == 'destination') { - $stmt2 = $db->query('SELECT entity_label FROM '.$_SESSION['tablename']['ent_entities'].' WHERE entity_id = ?', array($line->{$arr[$i]})); - if ($stmt2->rowCount() == 1) { - $res2 = $stmt2->fetchObject(); - $data[$arr[$i]]['show_value'] = functions::show_string($res2->entity_label, true); - } - } elseif ($arr[$i] == 'type_id') { - $data[$arr[$i]]['show_value'] = functions::show_string($line->type_label); - } - // Contact - elseif ($arr[$i] == 'dest_user_id' || $arr[$i] == 'exp_user_id') { - if (!empty($line->{$arr[$i]})) { - $stmt2 = $db->query('SELECT lastname, firstname FROM '.$_SESSION['tablename']['users'].' WHERE user_id = ?', array($line->{$arr[$i]})); - $res = $stmt2->fetchObject(); - $data[$arr[$i]]['show_value'] = $res->lastname.' '.$res->firstname; - $pathScriptTab = $_SESSION['config']['businessappurl'].'index.php?display=true&page=user_info&id='.$line->{$arr[$i]}; - - $preAddon = '<a href="#" id="contact_card" title="'._CONTACT_CARD.'" onclick="'; - $postAddon = ' ><i class="fa fa-book fa-2x" title="'._CONTACT_CARD.'"></i></a>'; - - $data[$arr[$i]]['addon'] = $preAddon.'loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._CONTACT_CARD.'\',\''.$pathScriptTab.'\',\'contactInfo\');return false;"'.$postAddon; - } else { - unset($data[$arr[$i]]); - } - } elseif ($arr[$i] == 'dest_contact_id' || $arr[$i] == 'exp_contact_id') { - if (!empty($line->{$arr[$i]})) { - $stmt2 = $db->query('SELECT address_id FROM res_letterbox WHERE res_id = ?', array($res_id)); - $resAddress = $stmt2->fetchObject(); - $addressId = $resAddress->address_id; - $data[$arr[$i]]['address_value'] = $addressId; - $stmt2 = $db->query('SELECT is_corporate_person, is_private, contact_lastname, contact_firstname, society, society_short, contact_purpose_id, address_num, address_street, address_postal_code, address_town, lastname, firstname FROM view_contacts WHERE contact_id = ? and ca_id = ?', array($line->{$arr[$i]}, $addressId)); - $res = $stmt2->fetchObject(); - if ($res->is_corporate_person == 'Y') { - $data[$arr[$i]]['show_value'] = $res->society.' '; - if (!empty($res->society_short)) { - $data[$arr[$i]]['show_value'] .= '('.$res->society_short.') '; - } - } else { - $data[$arr[$i]]['show_value'] = $res->contact_lastname.' '.$res->contact_firstname.' '; - if (!empty($res->society)) { - $data[$arr[$i]]['show_value'] .= '('.$res->society.') '; - } - } - if ($res->is_private == 'Y') { - $data[$arr[$i]]['show_value'] .= '('._CONFIDENTIAL_ADDRESS.')'; - } else { - require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_contacts_v2.php'; - $contact = new contacts_v2(); - $data[$arr[$i]]['show_value'] .= '- '.$contact->get_label_contact($res->contact_purpose_id, $_SESSION['tablename']['contact_purposes']).' : '; - if (!empty($res->lastname) || !empty($res->firstname)) { - $data[$arr[$i]]['show_value'] .= $res->lastname.' '.$res->firstname.' '; - } - if (!empty($res->address_num) || !empty($res->address_street) || !empty($res->address_town) || !empty($res->address_postal_code)) { - $data[$arr[$i]]['show_value'] .= ', '.$res->address_num.' '.$res->address_street.' '.$res->address_postal_code.' '.strtoupper($res->address_town); - } - } - $pathScriptTab = 'index.php?display=true&dir=my_contacts&page=info_contact_iframe&mode=editDetail&editDetail&popup&contactid='.$line->{$arr[$i]}.'&addressid='.$addressId; - - $preAddon = '<a href="#" id="contact_card" title="'._CONTACT_CARD.'" onclick="'; - $postAddon = ' ><i class="fa fa-book fa-2x" title="'._CONTACT_CARD.'"></i></a>'; - - $data[$arr[$i]]['addon'] = $preAddon.'loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._CONTACT_CARD.'\',\''.$pathScriptTab.'\',\'contactInfo\');return false;"'.$postAddon; - } else { - unset($data[$arr[$i]]); - } - } elseif ($arr[$i] == 'is_multicontacts') { - $stmt2 = $db->query('SELECT contact_id, address_id, mode FROM contacts_res WHERE res_id = ?', array($res_id)); - - $data[$arr[$i]]['multi']['contact_id'] = []; - $data[$arr[$i]]['multi']['address_id'] = []; - - while ($contact_res = $stmt2->fetchObject()) { - $display_contact = ''; - $data[$arr[$i]][$contact_res->mode]['contact_id'][] = $contact_res->contact_id; - $data[$arr[$i]][$contact_res->mode]['address_id'][] = $contact_res->address_id; - - if (is_numeric($contact_res->contact_id)) { - $stmt3 = $db->query('SELECT is_corporate_person, is_private, contact_lastname, contact_firstname, society, society_short, contact_purpose_id, address_num, address_street, address_postal_code, address_town, lastname, firstname FROM view_contacts WHERE contact_id = ? and ca_id = ?', array($contact_res->contact_id, $contact_res->address_id)); - $res = $stmt3->fetchObject(); - if ($res->is_corporate_person == 'Y') { - $display_contact = $res->society.' '; - if (!empty($res->society_short)) { - $display_contact .= '('.$res->society_short.') '; - } - } else { - $display_contact = $res->contact_lastname.' '.$res->contact_firstname.' '; - if (!empty($res->society)) { - $display_contact .= '('.$res->society.') '; - } - } - if ($res->is_private == 'Y') { - $display_contact .= '('._CONFIDENTIAL_ADDRESS.')'; - } else { - require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_contacts_v2.php'; - $contact = new contacts_v2(); - $display_contact .= '- '.$contact->get_label_contact($res->contact_purpose_id, $_SESSION['tablename']['contact_purposes']).' : '; - if (!empty($res->lastname) || !empty($res->firstname)) { - $display_contact .= $res->lastname.' '.$res->firstname.' '; - } - if (!empty($res->address_num) || !empty($res->address_street) || !empty($res->address_town) || !empty($res->address_postal_code)) { - $display_contact .= ', '.$res->address_num.' '.$res->address_street.' '.$res->address_postal_code.' '.strtoupper($res->address_town); - } - } - $data[$arr[$i]][$contact_res->mode]['arr_values'][] = $display_contact; - } else { - $stmt3 = $db->query('SELECT firstname, lastname FROM users WHERE user_id = ?', array($contact_res->contact_id)); - $res = $stmt3->fetchObject(); - $data[$arr[$i]][$contact_res->mode]['arr_values'][] = "{$res->firstname} {$res->lastname}"; - } - } - } elseif ($arr[$i] == 'resourceContact') { - $resourceContacts = \Resource\models\ResourceContactModel::getFormattedByResId(['resId' => $res_id]); - foreach ($resourceContacts as $resourceContact) { - if ($resourceContact['mode'] == 'recipient' && $cat_id == 'incoming') { - $sr = $resourceContact; - } elseif ($resourceContact['mode'] == 'sender' && $cat_id == 'outgoing') { - $sr = $resourceContact; - } - } - - if (!empty($sr['format'])) { - $data[$arr[$i]]['show_value'] = functions::show_string($sr['format']); - } - - $resourceContacts = \Resource\models\ResourceContactModel::getByResId(['resId' => $res_id]); - foreach ($resourceContacts as $resourceContact) { - if ($resourceContact['mode'] == 'recipient' && $cat_id == 'incoming') { - $senderRecipientContact = $resourceContact; - } elseif ($resourceContact['mode'] == 'sender' && $cat_id == 'outgoing') { - $senderRecipientContact = $resourceContact; - } - } - - if (!empty($senderRecipientContact['type']) && $senderRecipientContact['type'] != 'entity') { - $pathScriptTab = 'index.php?display=true&dir=my_contacts&page=info_contact_iframe&mode=editDetailSender&editDetailSender&popup&sender_recipient_id='.$senderRecipientContact['item_id'].'&sender_recipient_type='.$senderRecipientContact['type']; - - $preAddon = '<a href="#" id="contact_card" title="'._CONTACT_CARD.'" onclick="'; - $postAddon = ' ><i class="fa fa-book fa-2x" title="'._CONTACT_CARD.'"></i></a>'; - - $data[$arr[$i]]['addon'] = $preAddon.'loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._CONTACT_CARD.'\',\''.$pathScriptTab.'\',\'contactInfo\');return false;"'.$postAddon; - if ($senderRecipientContact['type'] == 'contact') { - $data[$arr[$i]]['item_id'] = $senderRecipientContact['item_id']; - } - } - - } - } else { // 'mimimal' mode - // Normal cases - $data[$arr[$i]] = $line->{$arr[$i]}; - if ($_ENV['categories'][$cat_id][$arr[$i]]['type_field'] == 'date') { - $data[$arr[$i]] = functions::format_date_db($line->{$arr[$i]}, false); - } elseif ($_ENV['categories'][$cat_id]['other_cases'][$arr[$i]]['type_field'] == 'date') { - $data[$arr[$i]] = functions::format_date_db($line->{$arr[$i]}, false); - } elseif ($_ENV['categories'][$cat_id][$arr[$i]]['type_field'] == 'string') { - $data[$arr[$i]] = functions::show_string($line->{$arr[$i]}, true, '', '', false); - } - // special cases : - // Contact - if ($arr[$i] == 'dest_user_id' || $arr[$i] == 'exp_user_id') { - if (!empty($line->{$arr[$i]})) { - $data['type_contact'] = 'internal'; - $stmt2 = $db->query('SELECT lastname, firstname FROM '.$_SESSION['tablename']['users'].' WHERE user_id = ?', array($line->{$arr[$i]})); - $res = $stmt2->fetchObject(); - $data['contact'] = $res->lastname.' '.$res->firstname; - $data['contactId'] = $line->{$arr[$i]}; - } - unset($data[$arr[$i]]); - } elseif ($arr[$i] == 'dest_contact_id' || $arr[$i] == 'exp_contact_id') { - if (!empty($line->{$arr[$i]})) { - $data['type_contact'] = 'external'; - $stmt2 = $db->query('SELECT address_id FROM res_letterbox WHERE res_id = ?', array($res_id)); - $resAddress = $stmt2->fetchObject(); - $addressId = $resAddress->address_id; - $stmt2 = $db->query('SELECT is_corporate_person, is_private, contact_lastname, contact_firstname, society, society_short, contact_purpose_id, address_num, address_street, address_postal_code, address_town, lastname, firstname FROM view_contacts WHERE contact_id = ? and ca_id = ?', array($line->{$arr[$i]}, $addressId)); - $res = $stmt2->fetchObject(); - if ($res->is_corporate_person == 'Y') { - $data['contact'] = $res->society.' '; - if (!empty($res->society_short)) { - $data['contact'] .= '('.$res->society_short.') '; - } - } else { - $data['contact'] = $res->contact_lastname.' '.$res->contact_firstname.' '; - if (!empty($res->society)) { - $data['contact'] .= '('.$res->society.') '; - } - } - if ($res->is_private == 'Y') { - $data['contact'] .= '('._CONFIDENTIAL_ADDRESS.')'; - } else { - require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_contacts_v2.php'; - $contact = new contacts_v2(); - $data['contact'] .= '- '.$contact->get_label_contact($res->contact_purpose_id, $_SESSION['tablename']['contact_purposes']).' : '; - if (!empty($res->lastname) || !empty($res->firstname)) { - $data['contact'] .= $res->lastname.' '.$res->firstname.' '; - } - if (!empty($res->address_num) || !empty($res->address_street) || !empty($res->address_town) || !empty($res->address_postal_code)) { - $data['contact'] .= ', '.$res->address_num.' '.$res->address_street.' '.$res->address_postal_code.' '.strtoupper($res->address_town); - } - } - $data['contactId'] = $line->{$arr[$i]}; - $data['addressId'] = $addressId; - } - unset($data[$arr[$i]]); - } elseif ($arr[$i] == 'is_multicontacts') { - if (!empty(trim($line->{$arr[$i]}))) { - $data['type_contact'] = 'multi_external'; - } - unset($data[$arr[$i]]); - } - } - } - - if ($mode == 'minimal' && isset($data['process_limit_date']) && !empty($data['process_limit_date'])) { - $data['process_limit_date_use'] = true; - } - - //print_r($data); - foreach (array_keys($data) as $key) { - if (is_array($data[$key])) { - $data[$key]['value'] = functions::xssafe($data[$key]['value']); - $data[$key]['show_value'] = functions::xssafe($data[$key]['show_value']); - } else { - $data[$key] = functions::xssafe($data[$key]); - } - } - - return $data; -} /** * Returns the icon for the given category or the default icon. diff --git a/apps/maarch_entreprise/indexing_searching/add_multi_contacts.php b/apps/maarch_entreprise/indexing_searching/add_multi_contacts.php deleted file mode 100755 index 9d9f3e63037..00000000000 --- a/apps/maarch_entreprise/indexing_searching/add_multi_contacts.php +++ /dev/null @@ -1,165 +0,0 @@ -<?php -/* -* -* Copyright 2013 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Script to return ajax result -* -* @author Yves Christian Kpakpo <dev@maarch.org> -* @date $date$ -* @version $Revision$ -*/ - -require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"; -require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"; -require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR - . 'class_indexing_searching_app.php'; -require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR - . 'class_users.php'; -require_once 'modules/notifications/notifications_tables_definition.php'; -require_once "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR - . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php"; -require_once "apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR - . "class_multicontacts.php"; - -$core_tools = new core_tools(); -$request = new request(); -$sec = new security(); -$is = new indexing_searching_app(); -$users_tools = new class_users(); -$sendmail_tools = new sendmail(); -$multicontacts = new multicontacts(); -$db = new Database(); - -function _parse($text) -{ - $text = str_replace("\r\n", PHP_EOL, $text); - $text = str_replace("\r", PHP_EOL, $text); - $text = str_replace(PHP_EOL, "\\n ", $text); - return $text; -} -function _parse_error($text) -{ - $text = str_replace("###", "\\n ", $text); - return $text; -} - -$core_tools->load_lang(); - -$status = 0; -$error = $content = $js = $parameters = ''; - -$labels_array = array(); - -if (isset($_REQUEST['mode']) && !empty($_REQUEST['mode'])) { - $mode = $_REQUEST['mode']; -} else { - $error = _ERROR_IN_SENDMAIL_FORM_GENERATION; - $status = 1; -} - -//Path to actual script -$path_to_script = $_SESSION['config']['businessappurl'] - ."index.php?display=true&dir=indexing_searching&page=add_multi_contacts&coll_id=".$collId; - -switch ($mode) { - case 'adress': - if (isset($_REQUEST['for']) && isset($_REQUEST['field']) && isset($_REQUEST['contact'])) { - // - if (isset($_REQUEST['contactid']) && !empty($_REQUEST['contactid'])) { - //Clean up email - $email = trim($_REQUEST['contact']); - //Reset session adresses if necessary - if (!isset($_SESSION['adresses'][$_REQUEST['field']])) { - $_SESSION['adresses'][$_REQUEST['field']] = array(); - } - if (!isset($_SESSION['adresses']['contactid'])) { - $_SESSION['adresses']['contactid'] = array(); - } - if (!isset($_SESSION['adresses']['addressid'])) { - $_SESSION['adresses']['addressid'] = array(); - } - //For ADD - if ($_REQUEST['for'] == 'add') { - if ($_REQUEST['addressid'] == '0' && is_numeric($_REQUEST['contactid'])) { - $listContacts = \Contact\models\ContactGroupModel::getListById([ - 'id' => $_REQUEST['contactid'], - 'select' => ['contact_addresses_id'] - ]); - foreach ($listContacts as $contact) { - $email = ''; - if (in_array($contact['contact_addresses_id'], $_SESSION['adresses']['addressid'])) { - continue; - } - $contactInfos = \Contact\models\ContactModel::getByAddressId([ - 'addressId' => $contact['contact_addresses_id'], - 'select' => ['contact_id', 'firstname', 'lastname', 'address_num', 'address_street', 'address_postal_code', 'address_town'] - ]); - $contactSociety = \Contact\models\ContactModel::getById(['id' => $contactInfos['contact_id'], 'select' => ['society','firstname', 'lastname']]); - if (empty($contactSociety['society'])) { - $contactAddress = implode(' ', [$contactInfos['address_num'], $contactInfos['address_street'], $contactInfos['address_postal_code'], $contactInfos['address_town']]); - $email = trim($contactSociety['firstname'].' '.$contactSociety['lastname'].' - '.$contactAddress); - } else { - $contactAddress = implode(' ', [$contactInfos['firstname'], $contactInfos['lastname'].',', $contactInfos['address_num'], $contactInfos['address_street'], $contactInfos['address_postal_code'], $contactInfos['address_town']]); - $email = trim($contactSociety['society'].' - '.$contactAddress); - } - - array_push($_SESSION['adresses'][$_REQUEST['field']], $email); - array_push($_SESSION['adresses']['contactid'], $contactInfos['contact_id']); - array_push($_SESSION['adresses']['addressid'], $contact['contact_addresses_id']); - } - } else { - array_push($_SESSION['adresses'][$_REQUEST['field']], $email); - array_push($_SESSION['adresses']['contactid'], $_REQUEST['contactid']); - array_push($_SESSION['adresses']['addressid'], $_REQUEST['addressid']); - } - //For DEL - } elseif ($_REQUEST['for'] == 'del') { - //unset adress in array - //unset($_SESSION['adresses'][$_REQUEST['field']][$_REQUEST['index']]); - array_splice($_SESSION['adresses'][$_REQUEST['field']], $_REQUEST['index'], 1); - array_splice($_SESSION['adresses']['contactid'], $_REQUEST['index'], 1); - array_splice($_SESSION['adresses']['addressid'], $_REQUEST['index'], 1); - //If no adresse for field, unset the entire sub-array - if (count($_SESSION['adresses'][$_REQUEST['field']]) == 0) { - unset($_SESSION['adresses'][$_REQUEST['field']]); - unset($_SESSION['adresses']['contactid']); - unset($_SESSION['adresses']['addressid']); - //array_splice($_SESSION['adresses'], 0); - } - } - //Get content - $content = $multicontacts->updateContactsInputField($path_to_script, $_SESSION['adresses'], $_REQUEST['field']); - } else { - $error = $request->wash_html(_SENDER.' '._IS_EMPTY.'!', 'NONE'); - $status = 1; - } - } else { - $error = $request->wash_html(_UNKNOW_ERROR.'!', 'NONE'); - $status = 1; - } - break; -} - -echo "{status : " . $status . ", content : '" . addslashes(_parse($content)) . "', error : '" . addslashes(_parse_error($error)) . "', exec_js : '".addslashes($js)."'}"; -exit(); diff --git a/apps/maarch_entreprise/indexing_searching/addresses_list.php b/apps/maarch_entreprise/indexing_searching/addresses_list.php deleted file mode 100755 index 03c4d4c6f46..00000000000 --- a/apps/maarch_entreprise/indexing_searching/addresses_list.php +++ /dev/null @@ -1,338 +0,0 @@ -<?php -/* -* -* Copyright 2008,2012 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Contacts list of the current user -* -* @file my_contacts.php -* @author Yves Christian Kpakpo <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup apps -*/ - -require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"; -require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR - ."class".DIRECTORY_SEPARATOR."class_lists.php"; -require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR - ."class".DIRECTORY_SEPARATOR."class_list_show.php"; -require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR - ."class".DIRECTORY_SEPARATOR."class_contacts_v2.php"; - -$core_tools = new core_tools(); -$request = new request(); -$list = new lists(); -$contact = new contacts_v2(); -$db = new Database(); - - $parameters = ''; - if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) $parameters .= '&order='.$_REQUEST['order']; - if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) $parameters .= '&order_field='.$_REQUEST['order_field']; - if (isset($_REQUEST['what']) && !empty($_REQUEST['what'])) $parameters .= '&what='.$_REQUEST['what']; - if (isset($_REQUEST['selectedObject']) && !empty($_REQUEST['selectedObject'])) $parameters .= '&selectedObject='.$_REQUEST['selectedObject']; - if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $parameters .= '&start='.$_REQUEST['start']; - if (isset($_REQUEST['mode']) && !empty($_REQUEST['mode'])) $parameters .= '&mode='.$_REQUEST['mode']; - - $_SESSION['origin']="contacts_list"; - -$return = $core_tools->test_admin('admin_contacts', 'apps', false); -if (!$return) { - $return = $core_tools->test_admin('search_contacts', 'apps'); -} - - if (isset($_REQUEST['load'])) { - $_SESSION['m_admin'] = array(); - - /****************Management of the location bar ************/ - $init = false; - if(isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == "true") - { - $init = true; - } - $level = ""; - if(isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) - { - $level = $_REQUEST['level']; - } - $page_path = $_SESSION['config']['businessappurl'].'index.php?page=addresses_list&dir=indexing_searching&load'; - $page_label = _ADDRESSES_LIST; - $page_id = "addresses_list"; - $core_tools->manage_location_bar($page_path, $page_label, $page_id, $init, $level); - /***********************************************************/ - ?> - <div id="inner_content"> - <?php - //Load list - $target = $_SESSION['config']['businessappurl'].'index.php?page=addresses_list&dir=indexing_searching'.$parameters; - $listContent = $list->loadList($target, true, 'divList', 'false'); - echo $listContent; - ?> - </div> - <?php -} else { - //Table - $select["view_contacts"] = array(); - array_push( - $select["view_contacts"], - "ca_id", "contact_id", "society", "contact_purpose_id", "is_private", "departement - , case when view_contacts.contact_lastname <> '' then view_contacts.contact_lastname else view_contacts.lastname end as \"lastname\" - , case when view_contacts.contact_firstname <> '' then view_contacts.contact_firstname else view_contacts.firstname end as \"firstname\" - , case when view_contacts.contact_function <> '' then view_contacts.contact_function else view_contacts.function end as \"function\"" - , "address_town", "phone", "email", "contact_purpose_label" - ); - $what = ""; - $where = ""; - - $arrayPDO = array(); - if (isset($_REQUEST['selectedObject']) && ! empty($_REQUEST['selectedObject'])) { - $where .= " ca_id = ? "; - $arrayPDO = array_merge($arrayPDO, array($_REQUEST['selectedObject'])); - } elseif (isset($_REQUEST['what']) && ! empty($_REQUEST['what'])) { - $what = $_REQUEST['what']; - - $what = str_replace(" ", "", $_REQUEST['what']); - $what_table = explode(" ", $what); - - foreach($what_table as $key => $what_a){ - $sql_lastname[] = " lower(lastname) LIKE lower(:what_".$key.")"; - $sql_firstname[] = " lower(firstname) LIKE lower(:what_".$key.")"; - $sql_society[] = " lower(departement) LIKE lower(:what_".$key.")"; - $sql_contact_firstname[] = " lower(contact_firstname) LIKE lower(:what_".$key.")"; - $sql_contact_lastname[] = " lower(contact_lastname) LIKE lower(:what_".$key.")"; - $arrayPDO = array_merge($arrayPDO, array(":what_".$key => $what_a."%")); - } - - $where .= " (" . implode(' OR ', $sql_lastname) . " "; - $where .= " or " . implode(' OR ', $sql_firstname) . " "; - $where .= " or " . implode(' OR ', $sql_society) . " "; - $where .= " or " . implode(' OR ', $sql_contact_firstname) . " "; - $where .= " or " . implode(' OR ', $sql_contact_lastname) . ") "; - } - - $list_show = new list_show(); - - $order = 'asc'; - if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) { - $order = trim($_REQUEST['order']); - } - - //use to pass the next condition in order_field. Then we need to delete them. - array_push( - $select["view_contacts"], - "lastname", "firstname", "function" - ); - - $field = 'contact_purpose_id'; - if (isset($_REQUEST['order_field']) && ! empty($_REQUEST['order_field']) && in_array($_REQUEST['order_field'], $select["view_contacts"])) { - $field = trim($_REQUEST['order_field']); - } - - array_pop($select["view_contacts"]); - array_pop($select["view_contacts"]); - array_pop($select["view_contacts"]); - - $orderstr = $list_show->define_order($order, $field); - - $request = new request; - $tab = $request->PDOselect( - $select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype'] - ); - // $request->show(); - - if (!empty($tab)) { - for ($i = 0; $i < count($tab); $i ++) { - for ($j = 0; $j < count($tab[$i]); $j ++) { - foreach (array_keys($tab[$i][$j]) as $value) { - if ($tab[$i][$j][$value] == "ca_id") { - $tab[$i][$j]["id"] = $tab[$i][$j]['value']; - $tab[$i][$j]["label"] = _ID; - $tab[$i][$j]["size"] = "30"; - $tab[$i][$j]["label_align"] = "left"; - $tab[$i][$j]["align"] = "left"; - $tab[$i][$j]["valign"] = "bottom"; - $tab[$i][$j]["show"] = false; - $tab[$i][$j]["order"] = 'id'; - } - if ($tab[$i][$j][$value] == "contact_id") { - $tab[$i][$j]["contact_id"] = $tab[$i][$j]['value']; - $tab[$i][$j]["label"] = _CONTACT_ID; - $tab[$i][$j]["size"] = "30"; - $tab[$i][$j]["label_align"] = "left"; - $tab[$i][$j]["align"] = "left"; - $tab[$i][$j]["valign"] = "bottom"; - $tab[$i][$j]["show"] = false; - $tab[$i][$j]["order"] = 'contact_id'; - } - if ($tab[$i][$j][$value] == "society") { - $tab[$i][$j]["society"] = $tab[$i][$j]['value']; - $tab[$i][$j]["label"] = _STRUCTURE_ORGANISM; - $tab[$i][$j]["size"] = "30"; - $tab[$i][$j]["label_align"] = "left"; - $tab[$i][$j]["align"] = "left"; - $tab[$i][$j]["valign"] = "bottom"; - $tab[$i][$j]["show"] = true; - $tab[$i][$j]["order"] = 'society'; - } - if ($tab[$i][$j][$value] == "contact_purpose_id") { - $tab[$i][$j]["value"]= $contact->get_label_contact($tab[$i][$j]['value'], $_SESSION['tablename']['contact_purposes']); - $tab[$i][$j]["contact_purpose_id"] = $tab[$i][$j]['value']; - $tab[$i][$j]["label"] = _CONTACT_PURPOSE; - $tab[$i][$j]["size"] = "20"; - $tab[$i][$j]["label_align"] = "left"; - $tab[$i][$j]["align"] = "left"; - $tab[$i][$j]["valign"] = "bottom"; - $tab[$i][$j]["show"] = true; - $tab[$i][$j]["order"] = 'contact_purpose_label'; - } - if($tab[$i][$j][$value]=="is_private") - { - $is_private = $tab[$i][$j]['value']; - $tab[$i][$j]["show"]=false; - } - if ($tab[$i][$j][$value] == "departement") { - if ($is_private == "Y") { - $tab[$i][$j]['value'] = "Confidentiel"; - } else { - $tab[$i][$j]['value'] = $request->show_string($tab[$i][$j]['value']); - } - - $tab[$i][$j]["departement"] = $tab[$i][$j]['value']; - $tab[$i][$j]["label"] = _SERVICE; - $tab[$i][$j]["size"] = "20"; - $tab[$i][$j]["label_align"] = "left"; - $tab[$i][$j]["align"] = "left"; - $tab[$i][$j]["valign"] = "bottom"; - $tab[$i][$j]["show"] = true; - $tab[$i][$j]["order"] = 'departement'; - } - if($tab[$i][$j][$value]=="lastname") - { - $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]["lastname"]=$tab[$i][$j]['value']; - $tab[$i][$j]["label"]=_LASTNAME; - $tab[$i][$j]["size"]="15"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["order"]= "lastname"; - } - if($tab[$i][$j][$value]=="firstname") - { - $tab[$i][$j]["firstname"]= $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]["label"]=_FIRSTNAME; - $tab[$i][$j]["size"]="15"; - $tab[$i][$j]["label_align"]="center"; - $tab[$i][$j]["align"]="center"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["order"]= "firstname"; - } - if($tab[$i][$j][$value]=="function") - { - $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]["function"]=$tab[$i][$j]['value']; - $tab[$i][$j]["label"]=_FUNCTION; - $tab[$i][$j]["size"]="15"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["order"]= "function"; - } - if($tab[$i][$j][$value]=="address_town") - { - if ($is_private == "Y") { - $tab[$i][$j]['value'] = "Confidentiel"; - } else { - $tab[$i][$j]['value'] = $request->show_string($tab[$i][$j]['value']); - } - $tab[$i][$j]["address_town"]= $tab[$i][$j]['value']; - $tab[$i][$j]["label"]=_TOWN; - $tab[$i][$j]["size"]="10"; - $tab[$i][$j]["label_align"]="center"; - $tab[$i][$j]["align"]="center"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=true; - $tab[$i][$j]["order"]= "address_town"; - } - if($tab[$i][$j][$value]=="phone") - { - $tab[$i][$j]['value']=$request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]["phone"]=$tab[$i][$j]['value']; - $tab[$i][$j]["label"]=_PHONE; - $tab[$i][$j]["size"]="15"; - $tab[$i][$j]["label_align"]="left"; - $tab[$i][$j]["align"]="left"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=false; - $tab[$i][$j]["order"]= "phone"; - } - if($tab[$i][$j][$value]=="email") - { - $tab[$i][$j]["email"]= $request->show_string($tab[$i][$j]['value']); - $tab[$i][$j]["label"]=_MAIL; - $tab[$i][$j]["size"]="15"; - $tab[$i][$j]["label_align"]="center"; - $tab[$i][$j]["align"]="center"; - $tab[$i][$j]["valign"]="bottom"; - $tab[$i][$j]["show"]=false; - $tab[$i][$j]["order"]= "email"; - } - } - } - } - } - - //List parameters - $paramsTab = array(); - $paramsTab['bool_modeReturn'] = false; //Desactivation du mode return (vs echo) - $paramsTab['pageTitle'] = _ADDRESSES_LIST." : ".count($tab)." "._ADDRESSES; //Titre de la page - $paramsTab['urlParameters'] = '&dir=indexing_searching'; //parametre d'url supplementaire - if ($_REQUEST['mode'] == 'search') { - $paramsTab['urlParameters'] .= "&mode=search"; - } - $paramsTab['pagePicto'] = 'street-view'; //Image (pictogramme) de la page - $paramsTab['bool_sortColumn'] = true; //Affichage Tri - $paramsTab['bool_showSearchTools'] = true; //Afficle le filtre alphabetique et le champ de recherche - $paramsTab['searchBoxAutoCompletionUrl'] = $_SESSION['config']['businessappurl'] - ."index.php?display=true&page=contact_addresses_list_by_name"; //Script pour l'autocompletion - - $paramsTab['searchBoxAutoCompletionMinChars'] = 2; //Nombre minimum de caractere pour activer l'autocompletion (1 par defaut) - $paramsTab['searchBoxAutoCompletionUpdate'] = true; - //Action icons array - $paramsTab['actionIcons'] = array(); - //get start - $start = $list->getStart(); - - $view = array( - "script" => "window.top.location='".$_SESSION['config']['businessappurl'] - ."index.php?page=contact_addresses_up&fromSearchContacts&id=@@ca_id@@&what=".$what."&start=".$start."'", - "class" => "view", - "label" => _VIEW, - "tooltip" => _VIEW - ); - array_push($paramsTab['actionIcons'], $view); - - //Afficher la liste - echo '<br/>'; - $list->showList($tab, $paramsTab, 'contact_id'); -} \ No newline at end of file diff --git a/apps/maarch_entreprise/indexing_searching/details.php b/apps/maarch_entreprise/indexing_searching/details.php index ae4206c33c9..9f63f3b868d 100755 --- a/apps/maarch_entreprise/indexing_searching/details.php +++ b/apps/maarch_entreprise/indexing_searching/details.php @@ -333,7 +333,7 @@ if ($stmt->rowCount() == 0) { } $_SESSION['features']['further_informations'][$indexes[$key]['label']] = $indexes[$key]['value']; } - $data = get_general_data($coll_id, $s_id, $mode_data, $param_data); ?> + $data = []; ?> <div class="block"> <b> <p id="back_list"> @@ -634,7 +634,7 @@ if ($stmt->rowCount() == 0) { $rate = []; if ($key == 'exp_contact_id') { if (!empty($data[$key]['address_value'])) { - $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$data[$key]['address_value']]]); + $contactData = []; if (!empty($contactData[0])) { $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]); } else { @@ -663,9 +663,6 @@ if ($stmt->rowCount() == 0) { $_SESSION['adresses']['addressid'] = array(); $_SESSION['adresses']['contactid'] = array(); - $path_to_script = $_SESSION['config']['businessappurl'] - .'index.php?display=true&dir=indexing_searching&page=add_multi_contacts&coll_id='.$collId; - if (empty($disabledAttr)) { echo "<div id='input_multi_contact_add' style=''>"; echo "<input type='text' placeholder='"._CONTACTS_USERS_SEARCH."' name='{$key}' id='{$key}' value='' title='' alt='' size='40' style='width:140px;'/>"; @@ -689,7 +686,7 @@ if ($stmt->rowCount() == 0) { $_SESSION['adresses']['addressid'][] = $data[$key]['multi']['address_id'][$icontacts]; $_SESSION['adresses']['contactid'][] = $data[$key]['multi']['contact_id'][$icontacts]; - $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$data[$key]['multi']['address_id'][$icontacts]]]); + $contactData = []; if (!empty($contactData[0])) { $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]); } else { @@ -716,7 +713,7 @@ if ($stmt->rowCount() == 0) { echo "<input type='hidden' name='contactid' id='contactid' value='' title='' alt='' size='40' />"; echo "<input type='hidden' name='addressid' id='addressid' value='' title='' alt='' size='40' />"; } elseif ($key == 'resourceContact') { - $resourceContacts = \Resource\models\ResourceContactModel::getFormattedByResId(['resId' => $s_id]); + $resourceContacts = []; foreach ($resourceContacts as $resourceContact) { if ($resourceContact['mode'] == 'recipient' && ($data['category_id']['value'] == 'incoming' || $data['category_id']['value'] == 'internal')) { $sr = $resourceContact; @@ -726,7 +723,7 @@ if ($stmt->rowCount() == 0) { } $rate = []; if (!empty($sr['type']) && $sr['type'] == 'contact') { - $contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$sr['item_id']]]); + $contactData = []; if (!empty($contactData[0])) { $rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]); } diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js index 20e68a8036a..9e1b4155011 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -2724,26 +2724,6 @@ function loadDiffList(id) { } -function loadContactsList(id) { - new Effect.toggle('contactsList_' + id, 'appear', { - delay: 0.2 - }); - - var path_manage_script = 'index.php?page=loadContactsList&display=true'; - - - new Ajax.Request(path_manage_script, { - method: 'post', - parameters: { - res_id: id - }, - onSuccess: function (answer) { - eval("response = " + answer.responseText); - $('divContactsList_' + id).innerHTML = response.toShow; - } - }); -} - function loadNoteList(id) { new Effect.toggle('noteList_' + id, 'appear', { delay: 0.2 diff --git a/apps/maarch_entreprise/loadContactsList.php b/apps/maarch_entreprise/loadContactsList.php deleted file mode 100755 index 415fa329d9b..00000000000 --- a/apps/maarch_entreprise/loadContactsList.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php - -/* -* Copyright 2008-2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core/class/class_core_tools.php'; -$Core_Tools = new core_tools(); -$Core_Tools->load_lang(); - -$return = ''; - -if (isset($_REQUEST['res_id'])) { - $status = 0; - $return .= '<td>'; - $return .= '<div align="center">'; - $return .= '<table width="100%">'; - - $db = new Database(); - - $query = 'SELECT c.is_corporate_person, c.is_private, c.contact_firstname, c.contact_lastname, c.firstname, c.lastname, c.society, c.society_short, c.contact_purpose_label, c.address_num, c.address_street, c.address_complement, c.address_town, c.address_postal_code, c.address_country, cres.mode '; - $query .= 'FROM view_contacts c, contacts_res cres '; - $query .= "WHERE cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (c.contact_id as varchar(128)) = cres.contact_id AND c.ca_id = cres.address_id ORDER BY cres.mode ASC"; - $arrayPDO = array($_REQUEST['res_id']); - $stmt = $db->query($query, $arrayPDO); - - $fetch = ''; - while ($res = $stmt->fetchObject()) { - $return .= '<tr>'; - $return .= '<td style="background: transparent; border: 0px dashed rgb(200, 200, 200);">'; - - $return .= '<div style="text-align: left; background-color: rgb(230, 230, 230); padding: 3px; margin-left: 20px; margin-top: -6px;">'; - if ($res->mode == 'third') { - $return .= '<span style="font-size:10px;color:#135F7F;">'._THIRD_DEST.'</span> - '; - } else { - $return .= '<span style="font-size:10px;color:#135F7F;">'._CONTACT.'</span> - '; - } - - if ($res->is_corporate_person == 'Y') { - $return .= functions::xssafe($res->society).' '; - if (!empty($res->society_short)) { - $return .= '('.functions::xssafe($res->society_short).') '; - } - } else { - $return .= functions::xssafe($res->contact_lastname) - .' '.functions::xssafe($res->contact_firstname).' '; - if (!empty($res->society)) { - $return .= '('.functions::xssafe($res->society).') '; - } - } - if ($res->is_private == 'Y') { - $return .= '('._CONFIDENTIAL_ADDRESS.')'; - } else { - $return .= '- '.functions::xssafe($res->contact_purpose_label).' : '; - if (!empty($res->lastname) || !empty($res->firstname)) { - $return .= functions::xssafe($res->lastname) - .' '.functions::xssafe($res->firstname); - } - if (!empty($res->address_num) || !empty($res->address_street) || !empty($res->address_town) || !empty($res->address_postal_code)) { - $return .= ', '.functions::xssafe($res->address_num).' ' - .functions::xssafe($res->address_street).' ' - .functions::xssafe($res->address_postal_code).' ' - .functions::xssafe(strtoupper($res->address_town)); - } - } - - $return .= '</div>'; - - $return .= '</td>'; - $return .= '</tr>'; - } - - $query = 'SELECT u.firstname, u.lastname, u.user_id, cres.mode '; - $query .= 'FROM users u, contacts_res cres '; - $query .= "WHERE cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (u.user_id as varchar(128)) = cres.contact_id"; - $arrayPDO = array($_REQUEST['res_id']); - $stmt = $db->query($query, $arrayPDO); - - $fetch = ''; - while ($res = $stmt->fetchObject()) { - $return .= '<tr>'; - $return .= '<td style="background: transparent; border: 0px dashed rgb(200, 200, 200);">'; - - $return .= '<div style="text-align: left; background-color: rgb(230, 230, 230); padding: 3px; margin-left: 20px; margin-top: -6px;">'; - if ($res->mode == 'third') { - $return .= '<span style="font-size:10px;color:#135F7F;">'._THIRD_DEST.' (interne)</span> - '; - } else { - $return .= '<span style="font-size:10px;color:#135F7F;">'._CONTACT.' (interne)</span> - '; - } - $return .= functions::xssafe($res->firstname).' '.functions::xssafe($res->lastname); - - $return .= '</div>'; - //$return .= '<br />'; - - $return .= '</td>'; - $return .= '</tr>'; - } - $return .= '</table>'; - $return .= '<br />'; - $return .= '</div>'; - $return .= '</td>'; -} else { - $status = 1; - $return .= '<td colspan="6" style="background-color: red;">'; - $return .= '<p style="padding: 10px; color: black;">'; - $return .= 'Erreur lors du chargement des notes'; - $return .= '</p>'; - $return .= '</td>'; -} - -echo '{status : '.$status.", toShow : '".addslashes($return)."'}"; -exit(); diff --git a/apps/maarch_entreprise/my_contacts/get_last_contact_address.php b/apps/maarch_entreprise/my_contacts/get_last_contact_address.php deleted file mode 100755 index 97ac05f07f5..00000000000 --- a/apps/maarch_entreprise/my_contacts/get_last_contact_address.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/* -* Copyright 2014-2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* -* -* @file -* @author <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup admin -*/ - -require_once 'core/class/class_request.php'; -$db = new Database(); - -if (isset($_GET['mode']) && $_GET['mode'] == 'up') { - $extra = ' AND contact_id = ? and ca_id = ? '; - $arrayPDO = array($_SESSION['contact']['current_contact_id'], $_SESSION['contact']['current_address_id']); -} else if (isset($_GET['contactid']) && $_GET['contactid'] <> '' && isset($_GET['addressid']) && $_GET['addressid'] <> ''){ - $extra = ' AND contact_id = ? and ca_id = ? '; - $arrayPDO = array($_GET['contactid'], $_GET['addressid']); -} else { - $orderBy = "ORDER BY ca_id DESC"; - $arrayPDO = array(); - $specific = true; -} - -if ($specific) { - $select = "is_corporate_person, - contact_lastname, - contact_firstname, - society, - society_short, - contact_id, - ca_id, - lastname, - firstname, - address_num, - address_street, - address_town, - address_postal_code, - creation_date, - contact_purpose_label, - departement, - update_date"; - $query = $db->limit_select(0, 1, $select, 'view_contacts', '', '', '', $orderBy); - $stmt = $db->query($query); -} else { - $stmt = $db->query("SELECT is_corporate_person, - contact_lastname, - contact_firstname, - society, - society_short, - contact_id, - ca_id, - lastname, - firstname, - address_num, - address_street, - address_town, - address_postal_code, - creation_date, - contact_purpose_label, - departement, - update_date - FROM view_contacts - WHERE 1=1 " . $extra, $arrayPDO); -} - - -// $stmt->DebugDumpParams(); -$res = $stmt->fetchObject(); - -$address = ''; -$address = $res->address_num . ' ' . $res->address_street . ' ' . $res->address_postal_code . ' ' . strtoupper($res->address_town); - -if($res->is_corporate_person == 'N') { - $contact = $res->contact_lastname . ' ' . $res->contact_firstname; - if($res->society_short <> '') { - $contact .= ' (' . $res->society_short . ')'; - } else if($res->society <> '') { - $contact .= ' (' . $res->society . ')'; - } -} else { - $contact = $res->society; - if($res->society_short <> '') { - $contact .= ' (' . $res->society_short . ')'; - } -} - -$contact .= ' - '. $res->contact_purpose_label ; - -if ($res->departement <> '' || $res->lastname <> '' || $res->firstname <> '' || !empty($trimed)) { - $contact .= ' :'; -} - -if ($res->departement <> '') { - $contact .= ' ' . $res->departement . ' -'; -} - -if ($res->lastname <> '' || $res->firstname <> '') { - $contact .= ' ' . $res->lastname . ' ' . $res->firstname; -} - -$trimed = trim($address); -if (!empty($trimed)) { - $contact .= ', ' . $address; -} - -$contactId = $res->contact_id; -$addressId = $res->ca_id; - -$contactData = \Contact\models\ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$addressId]]); -$rate = \Contact\controllers\ContactController::getFillingRate(['contact' => (array)$contactData[0]]); - -echo "{ status: 1, contactName: '" . addslashes($contact) . "', contactId: '" . $contactId . "', addressId: '" . $addressId . "', rateColor: '". $rate['color']."'}"; -exit; \ No newline at end of file diff --git a/apps/maarch_entreprise/my_contacts/my_contact_up_db.php b/apps/maarch_entreprise/my_contacts/my_contact_up_db.php index 041cd22b361..c2df97e2512 100755 --- a/apps/maarch_entreprise/my_contacts/my_contact_up_db.php +++ b/apps/maarch_entreprise/my_contacts/my_contact_up_db.php @@ -36,5 +36,4 @@ if(isset($_GET['mycontact']) && $_GET['mycontact'] <> ''){ $mycontact = 'Y'; } -$contact->addupcontact($_POST['mode'], false, $confirm, $mycontact); ?> diff --git a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml index 6fd08e78f3e..7d9633187a9 100755 --- a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml +++ b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml @@ -177,12 +177,6 @@ </requestDefinition> <!-- indexing_searching --> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="multi_contacts" > - <parameter name="dir" value="indexing_searching"/> - <parameter name="page" value="add_multi_contacts"/> - <parameter name="display" value="true"/> - <parameter name="coll_id"/> - </requestDefinition> <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="addresses_list" > <parameter name="dir" value="indexing_searching"/> <parameter name="page" value="addresses_list"/> @@ -445,11 +439,6 @@ <parameter name="display" value="true"/> </requestDefinition> - <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="res_id_integer" > - <parameter name="page" value="loadContactsList"/> - <parameter name="display" value="true"/> - </requestDefinition> - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="id_identifier" > <parameter name="page" value="user_info"/> <parameter name="display" value="true"/> diff --git a/core/class/LinkController.php b/core/class/LinkController.php index 5e1e4ba9066..acc1f6a16a6 100755 --- a/core/class/LinkController.php +++ b/core/class/LinkController.php @@ -32,7 +32,7 @@ class LinkController foreach ($arrayToFormat as $key => $value) { //GET RES INFOS - $infos = get_general_data('letterbox_coll', $key, 'full'); + $infos = []; $stmt = $db->query('SELECT dest_user, status FROM res_letterbox WHERE res_id = ?', array($key)); $otherInfos = $stmt->fetchObject(); $chronoNumber = $this->getAltIdentifier($key); diff --git a/core/class/PrintControler.php b/core/class/PrintControler.php index 702fc23b79e..02798586807 100644 --- a/core/class/PrintControler.php +++ b/core/class/PrintControler.php @@ -604,8 +604,8 @@ class PrintFunctions $db = new Database(); - $query = "select * from view_contacts where contact_id = ? AND ca_id = ?"; - $stmt = $db->query($query, array($contactId, $addressId)); + $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 <> '') { diff --git a/modules/attachments/attachments_content.php b/modules/attachments/attachments_content.php index 09bffa10520..56c89c3a845 100755 --- a/modules/attachments/attachments_content.php +++ b/modules/attachments/attachments_content.php @@ -468,7 +468,7 @@ if (isset($_POST['add']) && $_POST['add']) { $document = \Attachment\models\AttachmentModel::get(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$id]]); } if ($object['name'] == 'citoyen') { - $contact = \Contact\models\ContactModel::getOnView(['select' => ['external_id', 'ca_id'], 'where' => ['ca_id = ?'], 'data' => [$resource[0]['address_id']]]); + $contact = \Contact\models\ContactModel::get(['select' => ['external_id', 'ca_id'], 'where' => ['ca_id = ?'], 'data' => [$resource[0]['address_id']]]); $externalId = json_decode($contact[0]['external_id'], true); } foreach ($object['rawData'] as $key => $value) { diff --git a/modules/avis/send_to_avis.php b/modules/avis/send_to_avis.php index f9a5e8094af..4837ead3985 100755 --- a/modules/avis/send_to_avis.php +++ b/modules/avis/send_to_avis.php @@ -31,7 +31,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $res_id = $values[0]; - $data = get_general_data($coll_id, $res_id, 'minimal'); +// $data = get_general_data($coll_id, $res_id, 'minimal'); //print_r($data); $avis = new avis_controler(); $ent = new entity(); diff --git a/modules/sendmail/Controllers/ReceiveMessageExchangeController.php b/modules/sendmail/Controllers/ReceiveMessageExchangeController.php index 515f16dc769..1db6a681752 100755 --- a/modules/sendmail/Controllers/ReceiveMessageExchangeController.php +++ b/modules/sendmail/Controllers/ReceiveMessageExchangeController.php @@ -287,7 +287,7 @@ class ReceiveMessageExchangeController array_push($aDataContact, ['column' => 'external_id', 'value' => $transferringAgency->Identifier->value, 'type' => 'string', 'table' => 'contact_addresses']); array_push($aDataContact, ['column' => 'departement', 'value' => $transferringAgencyMetadata->Name, 'type' => 'string', 'table' => 'contact_addresses']); - $contactAlreadyCreated = ContactModel::getOnView([ + $contactAlreadyCreated = ContactModel::get([ 'select' => ['contact_id', 'ca_id'], 'where' => ["external_id->>'m2m' = ?"], 'data' => [$transferringAgency->Identifier->value], diff --git a/modules/sendmail/Controllers/SendMessageExchangeController.php b/modules/sendmail/Controllers/SendMessageExchangeController.php index 9d34815ffb3..1952ea1abf6 100755 --- a/modules/sendmail/Controllers/SendMessageExchangeController.php +++ b/modules/sendmail/Controllers/SendMessageExchangeController.php @@ -116,9 +116,9 @@ class SendMessageExchangeController foreach ($_SESSION['adresses']['to'] as $key => $value) { /******** GET ARCHIVAl INFORMATIONs **************/ - $contactInfo = \Contact\models\ContactModel::getFullAddressById(['addressId' => $key]); +// $contactInfo = \Contact\models\ContactModel::getFullAddressById(['addressId' => $key]); //TODO $ArchivalAgencyCommunicationType = \Contact\models\ContactModel::getContactCommunication(['contactId' => $contactInfo[0]['contact_id']]); - $ArchivalAgencyContactInformations = \Contact\models\ContactModel::getFullAddressById(['addressId' => $key]); +// $ArchivalAgencyContactInformations = \Contact\models\ContactModel::getFullAddressById(['addressId' => $key]); //TODO /******** GENERATE MESSAGE EXCHANGE OBJECT *********/ $dataObject = self::generateMessageObject([ diff --git a/modules/sendmail/acknowledgementReceiptsList.php b/modules/sendmail/acknowledgementReceiptsList.php index 6b05563853a..5bb4a09959a 100644 --- a/modules/sendmail/acknowledgementReceiptsList.php +++ b/modules/sendmail/acknowledgementReceiptsList.php @@ -87,9 +87,6 @@ if (!empty($tab)) { if ($tab[$i][$j][$value]=="contact_address_id") { $tab[$i][$j]["label"] = _CONTACT; $contactInfo = _UNDEFINED; - if (!empty($tab[$i][$j]["value"])) { - $contactInfo = \Contact\models\ContactModel::getContactFullLabel(['addressId' => $tab[$i][$j]["value"]]); - } $tab[$i][$j]["value"] = $contactInfo; $tab[$i][$j]["size"] = "4"; $tab[$i][$j]["label_align"] = "left"; diff --git a/modules/sendmail/mail_form.php b/modules/sendmail/mail_form.php index 858fd52a089..4f29c2df44a 100755 --- a/modules/sendmail/mail_form.php +++ b/modules/sendmail/mail_form.php @@ -252,8 +252,8 @@ if ($mode == 'add') { } if ($formContent != 'messageExchange') { if ($address_id != null) { - $adr = \Contact\models\ContactModel::getFullAddressById(['select' => ['email'], 'addressId' => $address_id]); - $adress_mail = $adr[0]['email']; + $adr = \Contact\models\ContactModel::getById(['select' => ['email'], 'id' => $address_id]); + $adress_mail = $adr['email']; } elseif ($exp_user_id != null) { $stmt = $db->query('SELECT mail FROM users WHERE user_id = ?', array($exp_user_id)); $adr = $stmt->fetchObject(); @@ -273,10 +273,6 @@ if ($mode == 'add') { $communicationTypeModel = \Contact\models\ContactModel::getContactCommunication(['contactId' => $contact_id]); $contactInfo = \Contact\models\ContactModel::getByAddressId(['select' => ['external_id'], 'addressId' => $address_id]); $externalId = (array)json_decode($contactInfo['external_id']); - if (!empty($communicationTypeModel) && !empty($externalId['m2m'])) { - $adress_mail = \Contact\models\ContactModel::getContactFullLabel(['addressId' => $address_id]); - $adress_mail .= '. ('._COMMUNICATION_TYPE.' : '.$communicationTypeModel['value'].')'; - } } } if ($adress_mail != null and $_SESSION['user']['UserId'] != $exp_user_id and $_SESSION['user']['UserId'] != $dest_user_id) { diff --git a/modules/sendmail/sendmail_ajax_content.php b/modules/sendmail/sendmail_ajax_content.php index 8be3b8327eb..059d6a3aafa 100755 --- a/modules/sendmail/sendmail_ajax_content.php +++ b/modules/sendmail/sendmail_ajax_content.php @@ -550,9 +550,9 @@ switch ($mode) { } if ($_REQUEST['for'] == 'add') { - $contactLabel = \Contact\models\ContactModel::getContactFullLabel(['addressId' => $contactAddress]); - $contactInfo = \Contact\models\ContactModel::getFullAddressById(['addressId' => $contactAddress]); - $contactCommunication = \Contact\models\ContactModel::getContactCommunication(['contactId' => $contactInfo[0]['contact_id']]); +// $contactLabel = \Contact\models\ContactModel::getContactFullLabel(['addressId' => $contactAddress]); //TODO +// $contactInfo = \Contact\models\ContactModel::getFullAddressById(['addressId' => $contactAddress]); +// $contactCommunication = \Contact\models\ContactModel::getContactCommunication(['contactId' => $contactInfo[0]['contact_id']]); $_SESSION['adresses'][$_REQUEST['field']][$contactAddress] = $contactLabel.'. ('._COMMUNICATION_TYPE.' : '.$contactCommunication['value'].'))'; } elseif ($_REQUEST['for'] == 'del') { unset($_SESSION['adresses'][$_REQUEST['field']][$_REQUEST['index']]); diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index 5f119b76b44..a07e2c7dcef 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -709,18 +709,23 @@ class PreProcessActionController } if (!empty($aTemplates)) { - $aAttachments = AttachmentModel::getAttachmentToSend(['ids' => $data['resources']]); + $aAttachments = AttachmentModel::get([ + 'select' => ['max(relation) as relation', 'res_id_master', 'title', 'res_id', 'identifier', 'recipient_id', 'recipient_type'], + 'where' => ['res_id_master in (?)', 'status not in (?)', 'attachment_type not in (?)', 'in_send_attach = ?'], + 'data' => [$data['resources'], ['OBS', 'DEL', 'TMP', 'FRZ'], ['print_folder'], true], + 'groupBy' => ['res_id_master', 'title', 'res_id', 'identifier', 'dest_address_id'] + ]); + foreach ($data['resources'] as $valueResId) { $resIdFound = false; foreach ($aAttachments as $key => $attachment) { if ($attachment['res_id_master'] == $valueResId) { $resIdFound = true; $attachmentId = $attachment['res_id']; - $collId = 'attachments_coll'; $convertedDocument = ConvertPdfController::getConvertedPdfById([ 'select' => ['docserver_id','path', 'filename', 'fingerprint'], 'resId' => $attachmentId, - 'collId' => $collId, + 'collId' => 'attachments_coll', 'type' => 'PDF' ]); if (empty($convertedDocument['docserver_id'])) { @@ -729,26 +734,26 @@ class PreProcessActionController unset($aAttachments[$key]); break; } - if (empty($attachment['dest_address_id'])) { + if (empty($attachment['recipient_id']) || $attachment['recipient_type'] != 'contact') { $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noAttachmentContact', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; } - $contact = ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$attachment['dest_address_id']]]); - if (empty($contact[0])) { + $contact = ContactModel::getById(['select' => ['*'], 'id' => $attachment['recipient_id']]); + if (empty($contact)) { $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noAttachmentContact', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; } - if (!empty($contact[0]['address_country']) && strtoupper(trim($contact[0]['address_country'])) != 'FRANCE') { + if (!empty($contact['address_country']) && strtoupper(trim($contact['address_country'])) != 'FRANCE') { $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'noFranceContact', 'attachmentIdentifier' => $attachment['identifier']]; unset($aAttachments[$key]); break; } - $afnorAddress = ContactController::getContactAfnor($contact[0]); + $afnorAddress = ContactController::getContactAfnor($contact); if ((empty($afnorAddress[1]) && empty($afnorAddress[2])) || empty($afnorAddress[6]) || !preg_match("/^\d{5}\s/", $afnorAddress[6])) { $resInfo = ResModel::getById(['select' => ['alt_identifier'], 'resId' => $valueResId]); $canNotSend[] = ['resId' => $valueResId, 'chrono' => $resInfo['alt_identifier'], 'reason' => 'incompleteAddressForPostal', 'attachmentIdentifier' => $attachment['identifier']]; diff --git a/src/app/action/controllers/ShippingTrait.php b/src/app/action/controllers/ShippingTrait.php index 0121e87701d..01839cc28c6 100644 --- a/src/app/action/controllers/ShippingTrait.php +++ b/src/app/action/controllers/ShippingTrait.php @@ -55,7 +55,7 @@ trait ShippingTrait $shippingTemplate['fee'] = json_decode($shippingTemplate['fee'], true); $attachments = AttachmentModel::get([ - 'select' => ['res_id', 'title', 'dest_address_id', 'external_id'], + 'select' => ['res_id', 'title', 'recipient_id', 'recipient_type', 'external_id'], 'where' => ['res_id_master = ?', 'in_send_attach = ?', 'status not in (?)', 'attachment_type not in (?)'], 'data' => [$args['resId'], true, ['OBS', 'DEL', 'TMP', 'FRZ'], ['print_folder']] ]); @@ -76,17 +76,17 @@ trait ShippingTrait if (empty($convertedDocument)) { return ['errors' => ['No conversion for attachment']]; } - if (empty($attachment['dest_address_id'])) { + if (empty($attachment['recipient_id']) || $attachment['recipient_type'] != 'contact') { return ['errors' => ['Contact is empty for attachment']]; } - $contact = ContactModel::getOnView(['select' => ['*'], 'where' => ['ca_id = ?'], 'data' => [$attachment['dest_address_id']]]); - if (empty($contact[0])) { + $contact = ContactModel::getById(['select' => ['*'], 'id' => $attachment['recipient_id']]); + if (empty($contact)) { return ['errors' => ['Contact does not exist for attachment']]; } - if (!empty($contact[0]['address_country']) && strtoupper(trim($contact[0]['address_country'])) != 'FRANCE') { + if (!empty($contact['address_country']) && strtoupper(trim($contact['address_country'])) != 'FRANCE') { return ['errors' => ['Contact country is not France']]; } - $afnorAddress = ContactController::getContactAfnor($contact[0]); + $afnorAddress = ContactController::getContactAfnor($contact); if ((empty($afnorAddress[1]) && empty($afnorAddress[2])) || empty($afnorAddress[6]) || !preg_match("/^\d{5}\s/", $afnorAddress[6])) { return ['errors' => ['Contact is not fill enough for attachment']]; } diff --git a/src/app/contact/controllers/ContactController.php b/src/app/contact/controllers/ContactController.php index a88d70347d5..149c95d6eb8 100755 --- a/src/app/contact/controllers/ContactController.php +++ b/src/app/contact/controllers/ContactController.php @@ -496,7 +496,7 @@ class ContactController return $formattedAddress; } - public static function getContactAfnor(array $aArgs) + public static function getContactAfnor(array $args) { $afnorAddress = ['Afnor', '', @@ -507,67 +507,59 @@ class ContactController '' ]; - if ($aArgs['is_corporate_person'] == 'Y') { + if (!empty($args['company'])) { // Ligne 1 - $afnorAddress[1] = substr($aArgs['society'], 0, 38); + $afnorAddress[1] = substr($args['company'], 0, 38); + } - // Ligne 2 - if (!empty($aArgs['title']) || !empty($aArgs['firstname']) || !empty($aArgs['lastname'])) { - $afnorAddress[2] = ContactController::controlLengthNameAfnor([ - 'title' => $aArgs['title'], - 'fullName' => $aArgs['firstname'].' '.$aArgs['lastname'], - 'strMaxLength' => 38 - ]); - } - } else { - // Ligne 2 - if (!empty($aArgs['contact_title']) || !empty($aArgs['contact_firstname']) || !empty($aArgs['contact_lastname'])) { - $afnorAddress[2] = ContactController::controlLengthNameAfnor([ - 'title' => $aArgs['contact_title'], - 'fullName' => $aArgs['contact_firstname'].' '.$aArgs['contact_lastname'], - 'strMaxLength' => 38 - ]); - } + // Ligne 2 + if (!empty($args['civility']) || !empty($args['firstname']) || !empty($args['lastname'])) { + $afnorAddress[2] = ContactController::controlLengthNameAfnor([ + 'civility' => $args['civility'], + 'fullName' => $args['firstname'].' '.$args['lastname'], + 'strMaxLength' => 38 + ]); } + // Ligne 3 - if (!empty($aArgs['address_complement'])) { - $afnorAddress[3] = substr($aArgs['address_complement'], 0, 38); + if (!empty($args['address_additional1'])) { + $afnorAddress[3] = substr($args['address_additional1'], 0, 38); } // Ligne 4 - if (!empty($aArgs['address_num'])) { - $aArgs['address_num'] = TextFormatModel::normalize(['string' => $aArgs['address_num']]); - $aArgs['address_num'] = preg_replace('/[^\w]/s', ' ', $aArgs['address_num']); - $aArgs['address_num'] = strtoupper($aArgs['address_num']); + if (!empty($args['address_number'])) { + $args['address_number'] = TextFormatModel::normalize(['string' => $args['address_number']]); + $args['address_number'] = preg_replace('/[^\w]/s', ' ', $args['address_number']); + $args['address_number'] = strtoupper($args['address_number']); } - if (!empty($aArgs['address_street'])) { - $aArgs['address_street'] = TextFormatModel::normalize(['string' => $aArgs['address_street']]); - $aArgs['address_street'] = preg_replace('/[^\w]/s', ' ', $aArgs['address_street']); - $aArgs['address_street'] = strtoupper($aArgs['address_street']); + if (!empty($args['address_street'])) { + $args['address_street'] = TextFormatModel::normalize(['string' => $args['address_street']]); + $args['address_street'] = preg_replace('/[^\w]/s', ' ', $args['address_street']); + $args['address_street'] = strtoupper($args['address_street']); } - $afnorAddress[4] = substr($aArgs['address_num'].' '.$aArgs['address_street'], 0, 38); + $afnorAddress[4] = substr($args['address_number'].' '.$args['address_street'], 0, 38); // Ligne 5 $afnorAddress[5] = ''; // Ligne 6 - $aArgs['address_postal_code'] = strtoupper($aArgs['address_postal_code']); - $aArgs['address_town'] = strtoupper($aArgs['address_town']); - $afnorAddress[6] = substr($aArgs['address_postal_code'].' '.$aArgs['address_town'], 0, 38); + $args['address_postcode'] = strtoupper($args['address_postcode']); + $args['address_town'] = strtoupper($args['address_town']); + $afnorAddress[6] = substr($args['address_postcode'].' '.$args['address_town'], 0, 38); return $afnorAddress; } - public static function controlLengthNameAfnor(array $aArgs) + public static function controlLengthNameAfnor(array $args) { $aCivility = ContactModel::getCivilities(); - if (strlen($aArgs['title'].' '.$aArgs['fullName']) > $aArgs['strMaxLength']) { - $aArgs['title'] = $aCivility[$aArgs['title']]['abbreviation']; + if (strlen($args['civility'].' '.$args['fullName']) > $args['strMaxLength']) { + $args['civility'] = $aCivility[$args['civility']]['abbreviation']; } else { - $aArgs['title'] = $aCivility[$aArgs['title']]['label']; + $args['civility'] = $aCivility[$args['civility']]['label']; } - return substr($aArgs['title'].' '.$aArgs['fullName'], 0, $aArgs['strMaxLength']); + return substr($args['civility'].' '.$args['fullName'], 0, $args['strMaxLength']); } public function availableReferential() diff --git a/src/app/contact/models/ContactModel.php b/src/app/contact/models/ContactModel.php index 49326cde961..57e1eb073fb 100755 --- a/src/app/contact/models/ContactModel.php +++ b/src/app/contact/models/ContactModel.php @@ -21,24 +21,6 @@ use SrcCore\models\ValidatorModel; class ContactModel { - public static function getOnView(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['select']); - ValidatorModel::arrayType($aArgs, ['select', 'where', 'data', 'orderBy']); - ValidatorModel::intType($aArgs, ['limit']); - - $aContacts = DatabaseModel::select([ - 'select' => $aArgs['select'], - 'table' => ['view_contacts'], - 'where' => empty($aArgs['where']) ? [] : $aArgs['where'], - 'data' => empty($aArgs['data']) ? [] : $aArgs['data'], - 'order_by' => empty($aArgs['orderBy']) ? [] : $aArgs['orderBy'], - 'limit' => empty($aArgs['limit']) ? 0 : $aArgs['limit'] - ]); - - return $aContacts; - } - public static function get(array $args) { ValidatorModel::notEmpty($args, ['select']); @@ -122,59 +104,6 @@ class ContactModel return true; } - public static function getFullAddressById(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['addressId']); - ValidatorModel::intVal($aArgs, ['addressId']); - - $aReturn = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['view_contacts'], - 'where' => ['ca_id = ?'], - 'data' => [$aArgs['addressId']], - ]); - - return $aReturn; - } - - public static function getContactFullLabel(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['addressId']); - ValidatorModel::intVal($aArgs, ['addressId']); - - $fullAddress = ContactModel::getFullAddressById($aArgs); - $fullAddress = $fullAddress[0]; - $fullAddress['external_id'] = (array)json_decode($fullAddress['external_id']); - - if ($fullAddress['is_corporate_person'] == 'Y') { - $contactName = strtoupper($fullAddress['society']) . ' ' ; - if (!empty($fullAddress['society_short'])) { - $contactName .= '('.$fullAddress['society_short'].') '; - } - } else { - $contactName = strtoupper($fullAddress['contact_lastname']) . ' ' . $fullAddress['contact_firstname'] . ' '; - if (!empty($fullAddress['society'])) { - $contactName .= '(' . $fullAddress['society'] . ') '; - } - } - if (!empty($fullAddress['external_id']['m2m'])) { - $contactName .= ' - <b>' . $fullAddress['external_id']['m2m'] . '</b> '; - } - if ($fullAddress['is_private'] == 'Y') { - $contactName .= '('._CONFIDENTIAL_ADDRESS.')'; - } else { - $contactName .= '- ' . $fullAddress['contact_purpose_label'] . ' : '; - if (!empty($fullAddress['lastname']) || !empty($fullAddress['firstname'])) { - $contactName .= $fullAddress['lastname'] . ' ' . $fullAddress['firstname'] . ' '; - } - if (!empty($fullAddress['address_num']) || !empty($fullAddress['address_street']) || !empty($fullAddress['address_postal_code']) || !empty($fullAddress['address_town'])) { - $contactName .= ', '.$fullAddress['address_num'] .' ' . $fullAddress['address_street'] .' ' . $fullAddress['address_postal_code'] .' ' . strtoupper($fullAddress['address_town']); - } - } - - return $contactName; - } - public static function getContactCommunication(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['contactId']); @@ -353,7 +282,7 @@ class ContactModel try { $res = DatabaseModel::select([ 'select' => ['contact_id', 'ca_id'], - 'table' => ['view_contacts'], + 'table' => ['contacts'], 'where' => ["external_id->>'m2m' = ?", 'enabled = ?'], 'data' => [$value['value'], 'Y'], ]); diff --git a/src/app/resource/models/ResourceContactModel.php b/src/app/resource/models/ResourceContactModel.php index 5732d2c701f..75abaa8a76e 100755 --- a/src/app/resource/models/ResourceContactModel.php +++ b/src/app/resource/models/ResourceContactModel.php @@ -55,47 +55,6 @@ class ResourceContactModel return $contacts; } - public static function getFormattedByResId(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['resId']); - ValidatorModel::intVal($aArgs, ['resId']); - - $aContacts = DatabaseModel::select([ - 'select' => ['*'], - 'table' => ['resource_contacts'], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - ]); - - foreach ($aContacts as $key => $aContact) { - if ($aContact['type'] == 'user') { - $user = UserModel::getLabelledUserById(['id' => $aContact['item_id']]); - $aContacts[$key]['format'] = $user; - $aContacts[$key]['restrictedFormat'] = $user; - } elseif ($aContact['type'] == 'contact') { - $contact = ContactModel::getOnView([ - 'select' => [ - 'is_corporate_person', 'lastname', 'firstname', 'address_num', 'address_street', 'address_town', 'address_postal_code', - 'ca_id', 'society', 'contact_firstname', 'contact_lastname', 'address_country' - ], - 'where' => ['ca_id = ?'], - 'data' => [$aContact['item_id']] - ]); - if (isset($contact[0])) { - $contact = AutoCompleteController::getFormattedContact(['contact' => $contact[0]]); - $aContacts[$key]['format'] = $contact['contact']['otherInfo']; - $aContacts[$key]['restrictedFormat'] = $contact['contact']['contact']; - } - } elseif ($aContact['type'] == 'entity') { - $entity = EntityModel::getById(['id' => $aContact['item_id'], 'select' => ['entity_label']]); - $aContacts[$key]['format'] = $entity['entity_label']; - $aContacts[$key]['restrictedFormat'] = $entity['entity_label']; - } - } - - return $aContacts; - } - public static function create(array $args) { ValidatorModel::notEmpty($args, ['res_id', 'item_id', 'type', 'mode']); diff --git a/test/unitTests/app/contact/ContactGroupControllerTest.php b/test/unitTests/app/contact/ContactGroupControllerTest.php index ff86140e357..903995a35c8 100755 --- a/test/unitTests/app/contact/ContactGroupControllerTest.php +++ b/test/unitTests/app/contact/ContactGroupControllerTest.php @@ -106,8 +106,8 @@ class ContactGroupControllerTest extends TestCase { $contactGroupController = new \Contact\controllers\ContactGroupController(); - $contacts = \Contact\models\ContactModel::getOnView([ - 'select' => ['ca_id'], + $contacts = \Contact\models\ContactModel::get([ + 'select' => ['id'], 'limit' => 1 ]); @@ -117,7 +117,7 @@ class ContactGroupControllerTest extends TestCase $request = \Slim\Http\Request::createFromEnvironment($environment); $aArgs = [ - 'contacts' => [$contacts[0]['ca_id']] + 'contacts' => [$contacts[0]['id']] ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); @@ -127,7 +127,7 @@ class ContactGroupControllerTest extends TestCase $this->assertSame(self::$id, $responseBody->contactsGroup->id); $this->assertNotEmpty($responseBody->contactsGroup); $this->assertNotEmpty($responseBody->contactsGroup->contacts); - $this->assertSame($contacts[0]['ca_id'], $responseBody->contactsGroup->contacts[0]->addressId); + $this->assertSame($contacts[0]['id'], $responseBody->contactsGroup->contacts[0]->addressId); $this->assertSame(0, $responseBody->contactsGroup->contacts[0]->position); $this->assertInternalType('string', $responseBody->contactsGroup->contacts[0]->contact); $this->assertInternalType('string', $responseBody->contactsGroup->contacts[0]->address); @@ -138,8 +138,8 @@ class ContactGroupControllerTest extends TestCase { $contactGroupController = new \Contact\controllers\ContactGroupController(); - $contacts = \Contact\models\ContactModel::getOnView([ - 'select' => ['ca_id'], + $contacts = \Contact\models\ContactModel::get([ + 'select' => ['id'], 'limit' => 1 ]); @@ -148,7 +148,7 @@ class ContactGroupControllerTest extends TestCase $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'DELETE']); $request = \Slim\Http\Request::createFromEnvironment($environment); - $response = $contactGroupController->deleteContact($request, new \Slim\Http\Response(), ['id' => self::$id, 'addressId' => $contacts[0]['ca_id']]); + $response = $contactGroupController->deleteContact($request, new \Slim\Http\Response(), ['id' => self::$id, 'addressId' => $contacts[0]['id']]); $responseBody = json_decode((string)$response->getBody()); $this->assertSame('success', $responseBody->success); -- GitLab