From 23e4cd57f33f8575f2a52912569063e091ae9c7e Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 12 Oct 2018 23:27:38 +0200 Subject: [PATCH 1/9] Fix warnings PHP7 --- htdocs/product/reassort.php | 1 + htdocs/product/reassortlot.php | 1 + htdocs/product/stock/productlot_list.php | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 70dce7470cd..b1b612d1a39 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -54,6 +54,7 @@ $fourn_id = GETPOST("fourn_id",'int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); +if (empty($page) || $page < 0) $page = 0; if (! $sortfield) $sortfield="p.ref"; if (! $sortorder) $sortorder="ASC"; $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 490986b155e..e1b6c82c8f3 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -58,6 +58,7 @@ $fourn_id = GETPOST("fourn_id",'int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); +if (empty($page) || $page < 0) $page = 0; if (! $sortfield) $sortfield="p.ref"; if (! $sortorder) $sortorder="ASC"; $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 325ddd5f796..8e5e5d925e9 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -47,6 +47,7 @@ $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); $backtopage = GETPOST('backtopage'); $myparam = GETPOST('myparam','alpha'); +$toselect = GETPOST('toselect', 'array'); $search_entity=GETPOST('search_entity','int'); @@ -152,7 +153,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_import_key=''; $search_date_creation=''; $search_date_update=''; - $toselect=''; + $toselect=array(); $search_array_options=array(); } From 7b17b453bf38b0864cb7772effd1e1f25ef9026b Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 12 Oct 2018 23:29:35 +0200 Subject: [PATCH 2/9] Fix sort and switch page --- htdocs/product/reassort.php | 35 ++++++++++++++------------- htdocs/product/reassortlot.php | 43 +++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b1b612d1a39..fe087fd16a3 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -92,11 +92,15 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $sref=""; $snom=""; $sall=""; + $tosell=""; + $tobuy=""; $search_sale=""; $search_categ=""; $type=""; $catid=''; $toolowstock=''; + $fourn_id=''; + $sbarcode=''; } @@ -183,6 +187,20 @@ if ($resql) } $texte.=' ('.$langs->trans("Stocks").')'; + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $param.="&sall=".$sall; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; + if ($search_sale) $param.="&search_sale=".$search_sale; + if ($search_categ) $param.="&search_categ=".$search_categ; + if ($toolowstock) $param.="&toolowstock=".$toolowstock; + if ($sbarcode) $param.="&sbarcode=".$sbarcode; + if ($catid) $param.="&catid=".$catid; llxHeader("", $texte, $helpurl); @@ -193,14 +211,7 @@ if ($resql) print ''; print ''; - if ($sref || $snom || $sall || GETPOST('search')) - { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy.(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_products', 0, '', '', $limit); - } - else - { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":"").(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_products', 0, '', '', $limit); - } + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_products', 0, '', '', $limit); if (! empty($catid)) { @@ -236,14 +247,6 @@ if ($resql) print ''; } - $param=''; - if ($tosell) $param.="&tosell=".$tosell; - if ($tobuy) $param.="&tobuy=".$tobuy; - if ($type) $param.="&type=".$type; - if ($fourn_id) $param.="&fourn_id=".$fourn_id; - if ($snom) $param.="&snom=".$snom; - if ($sref) $param.="&sref=".$sref; - $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); $warehouses_list = $formProduct->cache_warehouses; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index e1b6c82c8f3..7cedbcd3981 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -89,6 +89,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $sref=""; $snom=""; $sall=""; + $tosell=""; + $tobuy=""; $search_sale=""; $search_categ=""; $type=""; @@ -96,6 +98,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $toolowstock=''; $search_batch=''; $search_warehouse=''; + $fourn_id=''; + $sbarcode=''; } @@ -194,6 +198,24 @@ if ($resql) } $texte.=' ('.$langs->trans("StocksByLotSerial").')'; + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $param.="&sall=".$sall; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; + if ($search_batch) $param.="&search_batch=".$search_batch; + if ($sbarcode) $param.="&sbarcode=".$sbarcode; + if ($search_warehouse) $param.="&search_warehouse=".$search_warehouse; + if ($catid) $param.="&catid=".$catid; + if ($toolowstock) $param.="&toolowstock=".$toolowstock; + if ($search_sale) $param.="&search_sale=".$search_sale; + if ($search_categ) $param.="&search_categ=".$search_categ; + /*if ($eatby) $param.="&eatby=".$eatby; + if ($sellby) $param.="&sellby=".$sellby;*/ llxHeader("",$title,$helpurl,$texte); @@ -204,14 +226,8 @@ if ($resql) print ''; print ''; - if ($sref || $snom || $sall || GETPOST('search')) - { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_products', 0, '', '', $limit); - } - else - { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_products', 0, '', '', $limit); - } + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_products', 0, '', '', $limit); + if (! empty($catid)) { @@ -245,17 +261,6 @@ if ($resql) } - $param=''; - if ($tosell) $param.="&tosell=".$tosell; - if ($tobuy) $param.="&tobuy=".$tobuy; - if ($type) $param.="&type=".$type; - if ($fourn_id) $param.="&fourn_id=".$fourn_id; - if ($snom) $param.="&snom=".$snom; - if ($sref) $param.="&sref=".$sref; - if ($search_batch) $param.="&search_batch=".$search_batch; - /*if ($eatby) $param.="&eatby=".$eatby; - if ($sellby) $param.="&sellby=".$sellby;*/ - print '
'; print ''; From 1f1a614b47d7a0e8a37f496920a2f15f2ab8a189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 Oct 2018 10:21:06 +0200 Subject: [PATCH 3/9] Update import.lib.php --- htdocs/core/lib/import.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/import.lib.php b/htdocs/core/lib/import.lib.php index 89847d69c11..ea700c38845 100644 --- a/htdocs/core/lib/import.lib.php +++ b/htdocs/core/lib/import.lib.php @@ -1,8 +1,9 @@ - * Copyright (C) 2007 Rodolphe Quiedeville - * Copyright (C) 2010 Regis Houssin - * Copyright (C) 2010 Juanjo Menent +/* Copyright (C) 2006-2009 Laurent Destailleur + * Copyright (C) 2007 Rodolphe Quiedeville + * Copyright (C) 2010 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2018 Frédéric France * * 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 @@ -20,10 +21,9 @@ */ /** - * \file htdocs/core/lib/order.lib.php - * \brief Ensemble de fonctions de base pour le module commande - * \ingroup commande - */ + * \file htdocs/core/lib/import.lib.php + * \brief Ensemble de fonctions de base pour le module import + * \ingroup import /** * Function to return list of tabs for import pages From 70a98743e807a819fc8ec01fa92e5085f2d082c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 Oct 2018 10:48:06 +0200 Subject: [PATCH 4/9] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9cbd8562949..cff0ef2b8ef 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13,6 +13,7 @@ * Copyright (C) 2014 Cédric GROSS * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2018 Frédéric France * * 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 @@ -5975,11 +5976,12 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= // No need to make a return $head. Var is modified as a reference if (! empty($hookmanager)) { - $parameters=array('object' => $object, 'mode' => $mode, 'head'=>$head); - $reshook=$hookmanager->executeHooks('completeTabsHead',$parameters); + $parameters=array('object' => $object, 'mode' => $mode, 'head' => $head); + $reshook=$hookmanager->executeHooks('completeTabsHead', $parameters); if ($reshook > 0) { $head = $hookmanager->resArray; + $h = count($head); } } } From 4d6d3afbea46a3873f37fd0972888c2a7c0f7cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 15 Oct 2018 08:39:46 +0200 Subject: [PATCH 5/9] code comment --- htdocs/accountancy/class/accountancycategory.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index a7bab16b30d..db148cbac67 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016-2017 Alexandre Spangaro + * Copyright (C) 2018 Frédéric France * * 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 @@ -539,9 +540,9 @@ class AccountancyCategory /** * get cpts of category * - * @param int $cat_id Id accounting account category + * @param int $cat_id Id accounting account category * - * @return array Result in table + * @return array|int Result in table or -1 if error */ public function getCptsCat($cat_id) { global $mysoc; From 06477b40a093f57a3e41d180f97604a7e4bb1b9e Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 15 Oct 2018 12:34:14 +0200 Subject: [PATCH 6/9] modify parenting before task deletion --- htdocs/core/actions_massactions.inc.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 32d80bef672..b7bbc402b09 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -598,6 +598,17 @@ if (! $error && $massaction == 'delete' && $permtodelete) $result=$objecttmp->fetch($toselectid); if ($result > 0) { + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; + $res = $db->query($sql); + + if (!$res) + { + setEventMessage('ErrorRecordParentingNotModified', 'errors'); + $error++; + } + } + if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); if ($result <= 0) From b462e7b2170e7de3114a4e12548f1f89ae17c2ca Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 17 Oct 2018 10:01:02 +0200 Subject: [PATCH 7/9] FIX When delete a product, llx_product_association rows are not deleted --- htdocs/product/class/product.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f33029d368a..56227bc5266 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2014 Henry Florian * Copyright (C) 2014-2016 Philippe Grand * Copyright (C) 2014 Ion agorria - * Copyright (C) 2016-2017 Ferran Marcet + * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2017 Gustavo Novaro * * This program is free software; you can redistribute it and/or modify @@ -1114,6 +1114,19 @@ class Product extends CommonObject } } + // Delete from product_association + if (!$error){ + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; + $sql.= " WHERE fk_product_pere = ".$this->rowid." OR fk_product_fils = ".$this->rowid; + dol_syslog(get_class($this).'::delete', LOG_DEBUG); + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + // Delete product if (! $error) { From bdae4e1c4dae0369ef3d0051cf5e8c53572bf7c3 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 17 Oct 2018 10:04:42 +0200 Subject: [PATCH 8/9] FIX When delete a product, llx_product_association rows are not deleted --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 56227bc5266..9a52722a3c9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1117,7 +1117,7 @@ class Product extends CommonObject // Delete from product_association if (!$error){ $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; - $sql.= " WHERE fk_product_pere = ".$this->rowid." OR fk_product_fils = ".$this->rowid; + $sql.= " WHERE fk_product_pere = ".$this->id." OR fk_product_fils = ".$this->id; dol_syslog(get_class($this).'::delete', LOG_DEBUG); $result = $this->db->query($sql); if (! $result) From ffde3534419f28f37f57028405074b7b3a7fb5c2 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 17 Oct 2018 10:06:06 +0200 Subject: [PATCH 9/9] FIX When delete a product, llx_product_association rows are not deleted --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9a52722a3c9..ce3658c9a72 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1117,7 +1117,7 @@ class Product extends CommonObject // Delete from product_association if (!$error){ $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; - $sql.= " WHERE fk_product_pere = ".$this->id." OR fk_product_fils = ".$this->id; + $sql.= " WHERE fk_product_pere = ".$id." OR fk_product_fils = ".$id; dol_syslog(get_class($this).'::delete', LOG_DEBUG); $result = $this->db->query($sql); if (! $result)