From 74ac69fc5a27768c5644865933b3980109d483f6 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 27 Feb 2020 09:16:15 +0100 Subject: [PATCH 01/38] Add Entity in list_product_fournisseur_price() Select too the entity value to add const NOTMODIFYOTHERENTITYFOURNPRICE --- .../fourn/class/fournisseur.product.class.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 9f49fb31b83..f11f88464f3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1,12 +1,13 @@ - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2009-2014 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2020 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -590,7 +591,7 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; + $sql.= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; $sql.= " pfp.barcode, pfp.fk_barcode_type"; @@ -616,6 +617,7 @@ class ProductFournisseur extends Product $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; $prodfourn->product_fourn_id = $record["product_fourn_id"]; + $prodfourn->product_fourn_entity = $record["entity"]; $prodfourn->fourn_ref = $record["ref_fourn"]; $prodfourn->ref_supplier = $record["ref_fourn"]; $prodfourn->desc_supplier = $record["desc_fourn"]; From 84764771373f06b9fd62ea691ddac377bbdfe848 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 27 Feb 2020 09:19:39 +0100 Subject: [PATCH 02/38] add const NOTMODIFYOTHERENTITYFOURNPRICE if const NOTMODIFYOTHERENTITYFOURNPRICE, can't modify other shared fourn prices. --- htdocs/product/fournisseurs.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 0bda7d44564..797f350627e 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -1,14 +1,15 @@ - * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2012 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2014 Ion Agorria - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2014 Ion Agorria + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2020 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -933,7 +934,14 @@ SCRIPT; // Modify-Remove print ''; - if ($usercancreate) + + if (!empty($conf->global->NOTMODIFYOTHERENTITYFOURNPRICE) && $productfourn->product_fourn_entity!=$conf->entity) { + $canmodifyotherentityfournprice = 0; + }else{ + $canmodifyotherentityfournprice = 1; + } + + if ($usercancreate && $canmodifyotherentityfournprice == 1) { print ''.img_edit().""; print '   '; From 5dc403cb664fe3c1397fc3cbb9b7469dfc816466 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:19:24 +0100 Subject: [PATCH 03/38] FIX #13304 --- htdocs/expensereport/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index a05fd1393bb..03cafb6b60d 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -277,7 +277,9 @@ $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.tota $sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,"; $sql.= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo"; // Add fields from extrafields -foreach ($extrafields->attributes['expensereport']['type'] as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (is_array($extrafields->attributes['expensereport']['type'])) { + foreach ($extrafields->attributes['expensereport']['type'] as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook From 564f4129578cd1b5de730af0807ac3d673ef8a07 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 17 Mar 2020 10:04:43 +0100 Subject: [PATCH 04/38] correction due to comments @hregis and @eldy --- htdocs/product/fournisseurs.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 797f350627e..843a32c57a4 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -53,6 +53,7 @@ $socid=GETPOST('socid', 'int'); $cost_price=GETPOST('cost_price', 'alpha'); $backtopage=GETPOST('backtopage', 'alpha'); $error=0; +$canmodifyotherentityfournprice = 1 // If socid provided by ajax company selector if (! empty($_REQUEST['search_fourn_id'])) @@ -935,12 +936,6 @@ SCRIPT; // Modify-Remove print ''; - if (!empty($conf->global->NOTMODIFYOTHERENTITYFOURNPRICE) && $productfourn->product_fourn_entity!=$conf->entity) { - $canmodifyotherentityfournprice = 0; - }else{ - $canmodifyotherentityfournprice = 1; - } - if ($usercancreate && $canmodifyotherentityfournprice == 1) { print ''.img_edit().""; From 26f6f04486448c4071c8ac5c35fd63daebf5082e Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 17 Mar 2020 10:08:18 +0100 Subject: [PATCH 05/38] forgot ";" --- htdocs/product/fournisseurs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 843a32c57a4..d7238a72174 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -53,7 +53,7 @@ $socid=GETPOST('socid', 'int'); $cost_price=GETPOST('cost_price', 'alpha'); $backtopage=GETPOST('backtopage', 'alpha'); $error=0; -$canmodifyotherentityfournprice = 1 +$canmodifyotherentityfournprice = 1 ; // If socid provided by ajax company selector if (! empty($_REQUEST['search_fourn_id'])) From 4ce1665a1578b2a884b166c7c491d622dff3eec6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Mar 2020 17:31:09 +0100 Subject: [PATCH 06/38] Fix charset in RSS export --- htdocs/core/lib/xcal.lib.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 7e7cbd9672e..e3f53b7588d 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -330,7 +330,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) * @param string $format "rss" * @param string $title Title of export * @param string $desc Description of export - * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category") + * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category") or Array of WebsitePage * @param string $outputfile Output file * @param string $filter (optional) Filter * @return int < 0 if ko, Nb of events in file if ok @@ -355,7 +355,7 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt $date = date("r"); // Print header - fwrite($fichier, 'charset_output.""?>'); + fwrite($fichier, 'charset_output.'"?>'); fwrite($fichier, "\n"); fwrite($fichier, ''); @@ -363,11 +363,13 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt fwrite($fichier, "\n".$title."\n"); - $form = ""."\n". + /* + fwrite($fichier, ""."\n". // "fr"."\n". "Dolibarr"."\n". "".$date.""."\n". - "Dolibarr"."\n"; + "Dolibarr"."\n"); + */ // Define $urlwithroot $urlwithouturlroot = preg_replace("/".preg_quote(DOL_URL_ROOT, "/")."$/i", "", trim($dolibarr_main_url_root)); @@ -392,6 +394,19 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt if ($eventqualified) { + if (is_object($event) && get_class($event) == 'WebsitePage') { + // Convert object into an array + $tmpevent = array(); + $tmpevent['uid'] = $event->id; + $tmpevent['startdate'] = $event->date_creation; + $tmpevent['summary'] = $event->title; + $tmpevent['url'] = $event->urlpage.'.php'; + $tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown'; + //$tmpevent['category'] = ''; + + $event = $tmpevent; + } + $uid = $event["uid"]; $startdate = $event["startdate"]; $summary = $event["summary"]; From bcf17c79ef53d40799a626f5ee5c3ccf27e52109 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Mar 2020 02:44:00 +0100 Subject: [PATCH 07/38] FIX closing tags --- htdocs/core/lib/company.lib.php | 149 +++++++++++++++++--------------- 1 file changed, 77 insertions(+), 72 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index a3771d53cff..561cc0a02b3 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1317,6 +1317,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $sortfield_new = implode(',', $sortfield_new_list); + $sql = ''; + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm @@ -1468,85 +1470,88 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } //TODO Add limit in nb of results - $sql .= $db->order($sortfield_new, $sortorder); - dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) + if ($sql) { - $i = 0; - $num = $db->num_rows($resql); + $sql .= $db->order($sortfield_new, $sortorder); + dol_syslog("company.lib::show_actions_done", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if ($obj->type == 'action') { - $contactaction = new ActionComm($db); - $contactaction->id = $obj->id; - $result = $contactaction->fetchResources(); - if ($result < 0) { - dol_print_error($db); - setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); - } + if ($obj->type == 'action') { + $contactaction = new ActionComm($db); + $contactaction->id = $obj->id; + $result = $contactaction->fetchResources(); + if ($result < 0) { + dol_print_error($db); + setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); + } - //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone = ''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; + //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>$tododone, - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'percent'=>$obj->percent, + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>$tododone, + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'percent'=>$obj->percent, - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo, + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo, - 'contact_id'=>$obj->fk_contact, - 'socpeopleassigned' => $contactaction->socpeopleassigned, - 'lastname'=>$obj->lastname, - 'firstname'=>$obj->firstname, - 'fk_element'=>$obj->fk_element, - 'elementtype'=>$obj->elementtype, - // Type of event - 'acode'=>$obj->acode, - 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated - 'apicto'=>$obj->apicto - ); - } else { - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>'done', - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'percent'=>$obj->percent, - 'acode'=>$obj->acode, + 'contact_id'=>$obj->fk_contact, + 'socpeopleassigned' => $contactaction->socpeopleassigned, + 'lastname'=>$obj->lastname, + 'firstname'=>$obj->firstname, + 'fk_element'=>$obj->fk_element, + 'elementtype'=>$obj->elementtype, + // Type of event + 'acode'=>$obj->acode, + 'alabel'=>$obj->alabel, + 'libelle'=>$obj->alabel, // deprecated + 'apicto'=>$obj->apicto + ); + } else { + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>'done', + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'percent'=>$obj->percent, + 'acode'=>$obj->acode, - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo - ); - } + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo + ); + } - $numaction++; - $i++; - } - } - else - { - dol_print_error($db); + $numaction++; + $i++; + } + } + else + { + dol_print_error($db); + } } if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) @@ -1781,9 +1786,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $out .= "\n"; $out .= "\n"; - } - $out .= ''; + $out .= ''; + } if ($noprint) return $out; else print $out; From 61deab41f919f32aeda3532bec64d3a7a8eba7eb Mon Sep 17 00:00:00 2001 From: glu000 Date: Sat, 21 Mar 2020 17:55:10 +0100 Subject: [PATCH 08/38] Fix #13394 --- scripts/emailings/mailing-send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 4e5069b4fdc..eb5b794d3d1 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -328,7 +328,7 @@ if ($resql) { dol_syslog("error for emailing id " . $id . " #" . $i . ($mail->error ? ' - ' . $mail->error : ''), LOG_DEBUG); $sqlerror = "UPDATE " . MAIN_DB_PREFIX . "mailing_cibles"; - $sqlerror .= " SET statut=-1, date_envoi=" . $db->idate($now) . " WHERE rowid=" . $obj->rowid; + $sqlerror .= " SET statut=-1, date_envoi='" . $db->idate($now) . "' WHERE rowid=" . $obj->rowid; $resqlerror = $db->query($sqlerror); if (! $resqlerror) { dol_print_error($db); From 94b6fbb223e72f90eb3c413d11da8fb221076dab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Mar 2020 20:50:50 +0100 Subject: [PATCH 09/38] FIX #13300 --- htdocs/core/class/html.form.class.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 796011085dd..e4c81435752 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3509,11 +3509,11 @@ class Form /** * Return list of payment methods * - * @param string $selected Id du mode de paiement pre-selectionne - * @param string $htmlname Nom de la zone select + * @param string $selected Id or code or preselected payment mode + * @param string $htmlname Name of select field * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) - * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code - * @param int $empty 1=peut etre vide, 0 sinon + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int $empty 1=can be empty, 0 otherwise * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label * @param int $active Active or not, -1 = all @@ -3551,9 +3551,12 @@ class Form elseif ($format == 1) print '