From a5a2d6075552e6244a2ca13ab4ee3870f7778faa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2020 00:20:39 +0100 Subject: [PATCH 1/7] Fix phpcs --- htdocs/core/lib/functions.lib.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 25a5ab85973..d9b22d096e5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1788,7 +1788,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang $format=str_replace('%A', '__A__', $format); } - + // Analyze date $reg=array(); if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 @@ -1822,8 +1822,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang $ret=adodb_strftime($format, $timetouse, $to_gmt); } else $ret='Bad value '.$time.' for date'; - - } if (preg_match('/__b__/i', $format)) From a98b65ad996f051084c10c5882328ab7a4011676 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2020 00:43:51 +0100 Subject: [PATCH 2/7] FIX #13274 cannot add or update 0 value for an int or double extrafield type --- htdocs/core/class/commonobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3a7375f7950..f4ae126f096 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5380,7 +5380,7 @@ abstract class CommonObject // Add field of attribute if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) { - if ($new_array_options[$key] != '') + if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') { $sql .= ",'".$this->db->escape($new_array_options[$key])."'"; } @@ -5482,7 +5482,7 @@ abstract class CommonObject $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } - elseif ($value == '') + elseif ($value === '') { $this->array_options["options_".$key] = null; } @@ -5495,7 +5495,7 @@ abstract class CommonObject $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } - elseif ($value == '') + elseif ($value === '') { $this->array_options["options_".$key] = null; } From 0123fa769675a8720d567e475b2bf6c33299e6f9 Mon Sep 17 00:00:00 2001 From: kamel Date: Thu, 5 Mar 2020 15:37:01 +0100 Subject: [PATCH 3/7] FIX subsitute lines dates values on doc generator (ODT, ...) --- htdocs/core/class/commondocgenerator.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 5eb833dc262..087d21f1b5e 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -562,12 +562,12 @@ abstract class CommonDocGenerator 'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs), 'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs), // Dates - 'line_date_start'=>dol_print_date($line->date_start, 'day', 'tzuser'), - 'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzuser', $outputlangs), - 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'), - 'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), - 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), - 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), + 'line_date_start'=>dol_print_date($line->date_start, 'day'), + 'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzserver', $outputlangs), + 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc'), + 'line_date_end'=>dol_print_date($line->date_end, 'day'), + 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzserver', $outputlangs), + 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc'), 'line_multicurrency_code' => price2num($line->multicurrency_code), 'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), From fff7ee3e9687fd4006d6a3397c3d90f54595fbac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2020 01:55:36 +0100 Subject: [PATCH 4/7] FIX #13285 SQL error during migration with pgsql --- htdocs/install/upgrade2.php | 56 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index b5cf6e4c9dd..05eeaba2d5f 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -5070,15 +5070,15 @@ function migrate_members_socialnetworks() print ''; $sql = 'SELECT rowid, socialnetworks'; $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'adherent WHERE '; - $sql .= ' skype IS NOT NULL OR skype!=""'; - $sql .= ' OR twitter IS NOT NULL OR twitter!=""'; - $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; - $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; - $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; - $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; - $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; - $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; - $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; + $sql .= " skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; //print $sql; $resql = $db->query($sql); if ($resql) { @@ -5160,16 +5160,16 @@ function migrate_contacts_socialnetworks() print ''; $sql = 'SELECT rowid, socialnetworks'; $sql .= ', jabberid, skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'socpeople WHERE '; - $sql .= ' jabberid IS NOT NULL OR jabberid!=""'; - $sql .= ' OR skype IS NOT NULL OR skype!=""'; - $sql .= ' OR twitter IS NOT NULL OR twitter!=""'; - $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; - $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; - $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; - $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; - $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; - $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; - $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; + $sql .= " jabberid IS NOT NULL OR jabberid <> ''"; + $sql .= " OR skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; //print $sql; $resql = $db->query($sql); if ($resql) { @@ -5255,15 +5255,15 @@ function migrate_thirdparties_socialnetworks() print ''; $sql = 'SELECT rowid, socialnetworks'; $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'societe WHERE '; - $sql .= ' skype IS NOT NULL OR skype!=""'; - $sql .= ' OR twitter IS NOT NULL OR twitter!=""'; - $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; - $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; - $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; - $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; - $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; - $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; - $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; + $sql .= " skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; //print $sql; $resql = $db->query($sql); if ($resql) { From a9d7bbc2edfa0e17fb1c3542637cc632240d855a Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Fri, 6 Mar 2020 09:52:19 +0100 Subject: [PATCH 5/7] FIX : Remove unexisting link --- htdocs/comm/propal/list.php | 2 -- htdocs/contrat/list.php | 2 -- htdocs/projet/list.php | 2 -- htdocs/societe/canvas/actions_card_common.class.php | 2 -- 4 files changed, 8 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 511166991bf..17b8f80df68 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -972,9 +972,7 @@ if ($resql) $nbofsalesrepresentative=count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { - print ''; print $nbofsalesrepresentative; - print ''; } else if ($nbofsalesrepresentative > 0) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 57d47402049..9e5f5c811b2 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -706,9 +706,7 @@ while ($i < min($num,$limit)) $nbofsalesrepresentative=count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { - print ''; print $nbofsalesrepresentative; - print ''; } else if ($nbofsalesrepresentative > 0) { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index a0e068c79f6..352140f9cb1 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -747,9 +747,7 @@ while ($i < min($num,$limit)) $nbofsalesrepresentative=count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { - print ''; print $nbofsalesrepresentative; - print ''; } else if ($nbofsalesrepresentative > 0) { diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index ffcd7c7a00f..e696f8596db 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -306,9 +306,7 @@ abstract class ActionsCardCommon $nbofsalesrepresentative=count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { - $this->tpl['sales_representatives'].= ''; $this->tpl['sales_representatives'].= $nbofsalesrepresentative; - $this->tpl['sales_representatives'].= ''; } else if ($nbofsalesrepresentative > 0) { From 5ff4b638a548af614c1278c29ef71bd89be876c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2020 11:59:06 +0100 Subject: [PATCH 6/7] FIX empty of series in graph of product distribution --- htdocs/core/boxes/box_graph_product_distribution.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index c61bc2569be..96f0a5ecb78 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -146,6 +146,7 @@ class box_graph_product_distribution extends ModeleBoxes $mode = 'customer'; $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); + if (empty($data1)) { $showpointvalue = 0; @@ -160,7 +161,7 @@ class box_graph_product_distribution extends ModeleBoxes if (!$mesg) { $i = 0; $tot = count($data1); $legend = array(); - while ($i <= $tot) + while ($i < $tot) { $data1[$i][0] = dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" $legend[] = $data1[$i][0]; @@ -218,7 +219,7 @@ class box_graph_product_distribution extends ModeleBoxes if (!$mesg) { $i = 0; $tot = count($data2); $legend = array(); - while ($i <= $tot) + while ($i < $tot) { $data2[$i][0] = dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" $legend[] = $data2[$i][0]; @@ -277,7 +278,7 @@ class box_graph_product_distribution extends ModeleBoxes if (!$mesg) { $i = 0; $tot = count($data3); $legend = array(); - while ($i <= $tot) + while ($i < $tot) { $data3[$i][0] = dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" $legend[] = $data3[$i][0]; From adc996ee0a1caf6ce66f9978245e92b75281a658 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2020 13:19:17 +0100 Subject: [PATCH 7/7] FIX #13194 --- htdocs/public/ticket/create_ticket.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 181973912e5..16978e06ee2 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -68,11 +68,12 @@ if (GETPOST('addfile', 'alpha') && !GETPOST('add', 'alpha')) { // Set tmp directory TODO Use a dedicated directory for temp mails files $vardir = $conf->ticket->dir_output; - $upload_dir_tmp = $vardir.'/temp'; + $upload_dir_tmp = $vardir.'/temp/'.session_id(); if (!dol_is_dir($upload_dir_tmp)) { dol_mkdir($upload_dir_tmp); } - dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile'); + + dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0); $action = 'create_ticket'; ////} } @@ -83,7 +84,7 @@ if (GETPOST('removedfile', 'alpha') && !GETPOST('add', 'alpha')) { // Set tmp directory $vardir = $conf->ticket->dir_output.'/'; - $upload_dir_tmp = $vardir.'/temp'; + $upload_dir_tmp = $vardir.'/temp/'.session_id(); // TODO Delete only files that was uploaded from email form dol_remove_file_process($_POST['removedfile'], 0, 0); @@ -170,7 +171,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { if (!$error && $id > 0) { if ($usertoassign > 0) { - $object->add_contact($usertoassign, "SUPPORTCLI", 'external', $notrigger = 0); + $object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0); } } @@ -304,7 +305,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { } // Copy files into ticket directory - $destdir = $conf->ticket->dir_output.'/'.$object->track_id; + $destdir = $conf->ticket->dir_output.'/'.$object->ref; if (!dol_is_dir($destdir)) { dol_mkdir($destdir); }