From e957e0a945be76d6bcdb7d5657822b068d20864b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 25 Feb 2023 07:16:19 +0100 Subject: [PATCH 01/53] v17 Merge problem - Restore #22762 - Accountancy - Better warning for situation invoice in index --- htdocs/accountancy/index.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 628dceafd12..8cda6a5c6e5 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -83,12 +83,7 @@ $help_url = 'EN:Module_Double_Entry_Accounting#Setup'; llxHeader('', $langs->trans("AccountancyArea"), $help_url); -if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_SITUATION == 1) { - print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); - - print ''.$langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")."\n"; - print "
"; -} elseif (isModEnabled('accounting')) { +if (isModEnabled('accounting')) { $step = 0; $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) @@ -120,6 +115,11 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S print "
"; } + if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_SITUATION == 1) { + print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")); + print "
"; + } + print '
'; // hideobject is to start hidden print "
\n"; print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; From 15987bc46f660377fded7c86bb51353b7463aaac Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 25 Feb 2023 07:22:20 +0100 Subject: [PATCH 02/53] v17 Merge problem - Restore #22762 - Accountancy - Better warning for situation invoice in index --- htdocs/accountancy/index.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 8cda6a5c6e5..f5feef4a0f2 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -115,11 +115,6 @@ if (isModEnabled('accounting')) { print "
"; } - if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_SITUATION == 1) { - print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")); - print "
"; - } - print '
'; // hideobject is to start hidden print "
\n"; print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; From 4877c80c360c78f4bf85192948a44b0238de0a7e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 28 Feb 2023 16:44:32 +0100 Subject: [PATCH 03/53] FIX missing "authorid" for getNomUrl link right access --- htdocs/comm/action/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index b5ec104d02f..8a75dbe9337 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -412,7 +412,7 @@ if ($usergroup > 0) { } $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; $sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; -$sql .= ' a.fk_user_author,a.fk_user_action,'; +$sql .= ' a.fk_user_author, a.fk_user_action,'; $sql .= " a.fk_contact, a.note, a.percent as percent,"; $sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; $sql .= " c.code as type_code, c.libelle as type_label, c.color as type_color, c.type as type_type, c.picto as type_picto,"; @@ -916,6 +916,7 @@ while ($i < $imaxinloop) { $actionstatic->note_private = dol_htmlentitiesbr($obj->note); $actionstatic->datep = $db->jdate($obj->dp); $actionstatic->percentage = $obj->percent; + $actionstatic->authorid = $obj->fk_user_author; // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid // but only if we need it From 71fc59169ff8182f84d6cfce5814f027296c10f8 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 1 Mar 2023 10:44:20 +0100 Subject: [PATCH 04/53] 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 05/53] 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 06/53] 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 07/53] 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 08/53] 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 0ddb4eb9b267125b550658f35eeae31355380d83 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 2 Mar 2023 11:51:06 +0100 Subject: [PATCH 09/53] FIX: expense reports: error when selecting mileage fees expense type if MAIN_USE_EXPENSE_IK disabled --- htdocs/expensereport/card.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 20cd4f5227e..73bb84f5feb 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2594,8 +2594,8 @@ if ($action == 'create') { print ''; print '
'; - //var_dump($object); - print '