From 71fc59169ff8182f84d6cfce5814f027296c10f8 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 1 Mar 2023 10:44:20 +0100 Subject: [PATCH 01/14] add a new function inside ticket.class to remove the closed contact from the receiver list of contact --- htdocs/langs/en_US/ticket.lang | 1 + htdocs/ticket/class/ticket.class.php | 37 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index c0ca780ee06..d48b2c9beb2 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -223,6 +223,7 @@ TicketUpdated=Ticket updated SendMessageByEmail=Send message by email TicketNewMessage=New message ErrorMailRecipientIsEmptyForSendTicketMessage=Recipient is empty. No email send +WarningMailNotSendContactIsClosed=E-mail to %s refused for shipment as this contact is closed TicketGoIntoContactTab=Please go into "Contacts" tab to select them TicketMessageMailIntro=Message header TicketMessageMailIntroHelp=This text is added only at the beginning of the email and will not be saved. diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 6f309b7656f..f1f84fb8a9b 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2812,6 +2812,7 @@ class Ticket extends CommonObject $from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM; $is_sent = false; + $array_receiver = $this->removeClosedContact($array_receiver); if (is_array($array_receiver) && count($array_receiver) > 0) { foreach ($array_receiver as $key => $receiver) { $deliveryreceipt = 0; @@ -3028,6 +3029,42 @@ class Ticket extends CommonObject $return .= ''; return $return; } + + /** + * Remove the closed contact + * + * @param array $to Array of receiver. exemple array('john@doe.com' => 'John Doe ', etc...) + * @return array array of email => name + */ + public function removeClosedContact($to) + { + global $db, $langs; + $langs->load("ticket"); + + if (isset($this->id)) { + $sql = "SELECT IF(tc.source = 'external', sc.email, u.email)"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_contact ec"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_type_contact tc on (ec.element_id = ". $this->id ." AND ec.fk_c_type_contact = tc.rowid)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sc on (ec.fk_socpeople = sc.rowid AND tc.source = 'external')"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u on (ec.fk_socpeople = u.rowid AND tc.source = 'internal')"; + $sql .= " WHERE IF(tc.source = 'external', sc.statut = 1, u.statut = 1)"; + $resql = $db->query($sql); + if ($resql) { + for ($i = 0; $db->num_rows($resql) > $i; $i++) { + $non_closed_contacts[] = $db->fetch_row($resql); + } + } + $to = array_filter($to, function($v, $k) use($non_closed_contacts, $langs) { + foreach($non_closed_contacts as $non_closed_contact) { + if ($k == $non_closed_contact[0]) + return true; + } + setEventMessages($langs->trans('WarningMailNotSendContactIsClosed', str_replace(array('>', '<'), '', $v)), null, 'warnings'); + return false; + }, ARRAY_FILTER_USE_BOTH); + } + return $to; + } } From 233d737a89270f48ee82b961feb9fff23787010d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 1 Mar 2023 09:57:09 +0000 Subject: [PATCH 02/14] Fixing style errors. --- htdocs/ticket/class/ticket.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index f1f84fb8a9b..45e3cf361b3 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -3054,8 +3054,8 @@ class Ticket extends CommonObject $non_closed_contacts[] = $db->fetch_row($resql); } } - $to = array_filter($to, function($v, $k) use($non_closed_contacts, $langs) { - foreach($non_closed_contacts as $non_closed_contact) { + $to = array_filter($to, function ($v, $k) use ($non_closed_contacts, $langs) { + foreach ($non_closed_contacts as $non_closed_contact) { if ($k == $non_closed_contact[0]) return true; } From d1b5fc6bc1b0fda806db5a94eaf3729f1404d18b Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 1 Mar 2023 11:04:00 +0100 Subject: [PATCH 03/14] removed function from FOR loop test part --- htdocs/ticket/class/ticket.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 45e3cf361b3..ce0997c7a02 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -3050,11 +3050,12 @@ class Ticket extends CommonObject $sql .= " WHERE IF(tc.source = 'external', sc.statut = 1, u.statut = 1)"; $resql = $db->query($sql); if ($resql) { - for ($i = 0; $db->num_rows($resql) > $i; $i++) { + $num = $db->num_rows($resql); + for ($i = 0; $num > $i; $i++) { $non_closed_contacts[] = $db->fetch_row($resql); } } - $to = array_filter($to, function ($v, $k) use ($non_closed_contacts, $langs) { + $to = array_filter($to, function($v, $k) use($non_closed_contacts, $langs) { foreach ($non_closed_contacts as $non_closed_contact) { if ($k == $non_closed_contact[0]) return true; From 1bd49ca07a23f7e45b07e4dc4a79eeaedf10762c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 1 Mar 2023 10:04:30 +0000 Subject: [PATCH 04/14] Fixing style errors. --- htdocs/ticket/class/ticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index ce0997c7a02..9f9a2b702aa 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -3055,7 +3055,7 @@ class Ticket extends CommonObject $non_closed_contacts[] = $db->fetch_row($resql); } } - $to = array_filter($to, function($v, $k) use($non_closed_contacts, $langs) { + $to = array_filter($to, function ($v, $k) use ($non_closed_contacts, $langs) { foreach ($non_closed_contacts as $non_closed_contact) { if ($k == $non_closed_contact[0]) return true; From f362c66b28967a1da925edfa4204285c9eeb2aa1 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 1 Mar 2023 16:54:49 +0100 Subject: [PATCH 05/14] changed by ->db inside ticket.class.php --- htdocs/ticket/class/ticket.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index ce0997c7a02..09c9c07977f 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -3038,7 +3038,7 @@ class Ticket extends CommonObject */ public function removeClosedContact($to) { - global $db, $langs; + global $langs; $langs->load("ticket"); if (isset($this->id)) { @@ -3048,11 +3048,11 @@ class Ticket extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sc on (ec.fk_socpeople = sc.rowid AND tc.source = 'external')"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u on (ec.fk_socpeople = u.rowid AND tc.source = 'internal')"; $sql .= " WHERE IF(tc.source = 'external', sc.statut = 1, u.statut = 1)"; - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); for ($i = 0; $num > $i; $i++) { - $non_closed_contacts[] = $db->fetch_row($resql); + $non_closed_contacts[] = $this->db->fetch_row($resql); } } $to = array_filter($to, function($v, $k) use($non_closed_contacts, $langs) { From f24a2608d2da74d878742e131171eb9497dd0252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 3 Mar 2023 14:04:16 +0100 Subject: [PATCH 06/14] add pictos --- htdocs/comm/propal/card.php | 1 + htdocs/commande/card.php | 1 + htdocs/compta/facture/card.php | 12 ++++++++---- htdocs/contrat/card.php | 2 ++ htdocs/fourn/commande/card.php | 1 + htdocs/fourn/facture/card.php | 13 +++++++++---- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 93cc8e52c77..f504cf84cd9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1943,6 +1943,7 @@ if ($action == 'create') { print ''; print ''; print ''; + print img_picto('', 'incoterm', 'class="pictofixedwidth"'); print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : '')); print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 2decb49f58c..97b3e017505 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1913,6 +1913,7 @@ if ($action == 'create' && $usercancreate) { $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms); $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms); } + print img_picto('', 'incoterm', 'class="pictofixedwidth"'); print $form->select_incoterms($incoterm_id, $incoterm_location); print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d2117f426ca..1b9b3671db7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -14,7 +14,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014-2019 Ferran Marcet * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -3200,7 +3200,7 @@ if ($action == 'create') { } else { print ''.$langs->trans('Customer').''; print ''; - print img_picto('', 'company').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); + print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); // Option to reload page to retrieve customer informations. if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { print '