From 6ce006f853053a5e24daad7a128f3403de9002e2 Mon Sep 17 00:00:00 2001 From: quentin Date: Mon, 16 Nov 2020 15:46:16 +0100 Subject: [PATCH 1/4] FIX cant empty action comm desc --- htdocs/comm/action/card.php | 1 - htdocs/comm/action/class/actioncomm.class.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 129696a60d9..0709a2571ad 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -469,7 +469,6 @@ if (empty($reshook) && $action == 'update') $object->note_private = trim(GETPOST("note", "none")); $object->fk_element = GETPOST("fk_element", "int"); $object->elementtype = GETPOST("elementtype", "alphanohtml"); - if (!$datef && $percentage == 100) { $error++; $donotclearsession = 1; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 3c060ffdc39..7355040e00c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -983,7 +983,7 @@ class ActionComm extends CommonObject // Clean parameters $this->label = trim($this->label); - $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); + $this->note_private = dol_htmlcleanlastbr(trim(!isset($this->note_private) ? $this->note : $this->note_private)); if (empty($this->percentage)) $this->percentage = 0; if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->transparency)) $this->transparency = 0; From 4ae121d870865ee5f8edba8b422fa59d94daf976 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Nov 2020 19:43:45 +0100 Subject: [PATCH 2/4] FIX Can't create shipment for virtual product. Add STOCK_EXCLUDE_VIRTUAL_PRODUCTS as a quick hack to solve this. --- htdocs/expedition/class/expedition.class.php | 31 +++++++------- htdocs/product/class/product.class.php | 43 ++++++++++++-------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index f3e9d5f26f8..d14a34515c4 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -954,33 +954,36 @@ class Expedition extends CommonObject { $fk_product = $orderline->fk_product; - if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) - { + if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) { $langs->load("errors"); $this->error = $langs->trans("ErrorWarehouseRequiredIntoShipmentLine"); return -1; } - if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) - { - // Check must be done for stock of product into warehouse if $entrepot_id defined + if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { $product = new Product($this->db); - $result = $product->fetch($fk_product); + $product->fetch($fk_product); + // Check must be done for stock of product into warehouse if $entrepot_id defined if ($entrepot_id > 0) { $product->load_stock('warehouseopen'); $product_stock = $product->stock_warehouse[$entrepot_id]->real; - } - else + } else { $product_stock = $product->stock_reel; + } $product_type = $product->type; - if ($product_type == 0 && $product_stock < $qty) - { - $langs->load("errors"); - $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref); - $this->db->rollback(); - return -3; + if ($product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $isavirtualproduct = ($product->hasFatherOrChild(1) > 0); + // The product is qualified for a check of quantity (must be enough in stock to be added into shipment). + if (!$isavirtualproduct || empty($conf->global->PRODUIT_SOUSPRODUITS) || ($isavirtualproduct && empty($conf->global->STOCK_EXCLUDE_VIRTUAL_PRODUCTS))) { // If STOCK_EXCLUDE_VIRTUAL_PRODUCTS is set, we do not manage stock for kits/virtual products. + if ($product_stock < $qty) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref); + $this->db->rollback(); + return -3; + } + } } } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 55cc67de4a5..3630155662e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4208,29 +4208,36 @@ class Product extends CommonObject } /** - * Return all parent products for current product (first level only) + * Count all parent and children products for current product (first level only) * - * @return int Nb of father + child + * @param int $mode 0=Both parent and child, -1=Parents only, 1=Children only + * @return int Nb of father + child + * @see getFather(), get_sousproduits_arbo() */ - public function hasFatherOrChild() + public function hasFatherOrChild($mode = 0) { - $nb = 0; + $nb = 0; - $sql = "SELECT COUNT(pa.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa"; - $sql .= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_object($resql); - if ($obj) { $nb = $obj->nb; - } - } - else - { - return -1; - } + $sql = "SELECT COUNT(pa.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa"; + if ($mode == 0) { + $sql .= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; + } elseif ($mode == -1) { + $sql .= " WHERE pa.fk_product_fils = ".$this->id; // We are a child, so we found lines that link to parents (can have several parents) + } elseif ($mode == 1) { + $sql .= " WHERE pa.fk_product_pere = ".$this->id; // We are a parent, so we found lines that link to children (can have several children) + } - return $nb; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj) { $nb = $obj->nb; + } + } else { + return -1; + } + + return $nb; } /** From f7228d96af13d800324f75d711ba05cc1df042b4 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 20 Nov 2020 19:12:59 +0100 Subject: [PATCH 3/4] FIX 12.0 - when the cronjob 'params' field is empty, the cron method is called with one empty string param instead of no params at all --- htdocs/cron/class/cronjob.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 39220f0cebe..ba7adfd320f 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1052,7 +1052,10 @@ class Cronjob extends CommonObject $object = new $this->objectname($this->db); if ($this->entity > 0) $object->entity = $this->entity; // We work on a dedicated entity - $params_arr = array_map('trim', explode(",", $this->params)); + $params_arr = array(); + if (!empty($this->params) || $this->params === '0'){ + $params_arr = array_map('trim', explode(",", $this->params)); + } if (!is_array($params_arr)) { @@ -1113,7 +1116,7 @@ class Cronjob extends CommonObject } dol_syslog(get_class($this)."::run_jobs ".$this->libname."::".$this->methodename."(".$this->params.");", LOG_DEBUG); - $params_arr = explode(", ", $this->params); + $params_arr = explode(", ", $this->params); if (!is_array($params_arr)) { $result = call_user_func($this->methodename, $this->params); From 6c75997b271821de38f0d81859812d944f09cd46 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 20 Nov 2020 19:15:15 +0100 Subject: [PATCH 4/4] FIX wrong tab --- htdocs/cron/class/cronjob.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index ba7adfd320f..e8b3fd8e96b 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1116,7 +1116,7 @@ class Cronjob extends CommonObject } dol_syslog(get_class($this)."::run_jobs ".$this->libname."::".$this->methodename."(".$this->params.");", LOG_DEBUG); - $params_arr = explode(", ", $this->params); + $params_arr = explode(", ", $this->params); if (!is_array($params_arr)) { $result = call_user_func($this->methodename, $this->params);