From 7e9d6dc153eaf7fc3b1eeed225af1cb1d6467a35 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 24 Oct 2019 10:58:29 +0200 Subject: [PATCH 1/4] Fix With pagination it is possible that the searched product does not appear if there are many open supplier orders --- htdocs/product/stock/replenishorders.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 942ca82bc04..34dfc2d9d6e 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -2,6 +2,7 @@ /* * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Regis Houssin + * Copyright (C) 2019 Juanjo Menent * * 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 @@ -152,7 +153,9 @@ if (GETPOST('statut', 'int')) { $sql .= ' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut'; $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= $db->order($sortfield, $sortorder); -$sql .= $db->plimit($limit+1, $offset); +if (! $sproduct) { + $sql .= $db->plimit($limit+1, $offset); +} $resql = $db->query($sql); if ($resql) @@ -268,7 +271,7 @@ if ($resql) $userstatic = new User($db); - while ($i < min($num,$conf->liste_limit)) + while ($i < min($num,$sproduct?$num:$conf->liste_limit)) { $obj = $db->fetch_object($resql); From 5e06fe0712f345035f92a28c28a42d12b7fd3826 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Oct 2019 11:11:13 +0100 Subject: [PATCH 2/4] FIX Avoid fatal error when creating thumb from PDF --- htdocs/core/lib/files.lib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 6b965a28f0e..e003b74f3e6 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1843,10 +1843,15 @@ function dol_convert_file($fileinput, $ext='png', $fileoutput='') if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext; $count = $image->getNumberImages(); - if (! dol_is_file($fileoutput) || is_writeable($fileoutput)) { - $ret = $image->writeImages($fileoutput, true); + try { + $ret = $image->writeImages($fileoutput, true); + } + catch(Exception $e) + { + dol_syslog($e->getMessage(), LOG_WARNING); + } } else { From 21d15c3bcbf5883091f792e9890c079b23af3f98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Oct 2019 11:35:33 +0100 Subject: [PATCH 3/4] FIX Set unpaid of expense report --- .../class/expensereport.class.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 9bbf6617369..b9e60ed50d5 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -106,6 +106,11 @@ class ExpenseReport extends CommonObject */ const STATUS_VALIDATED = 2; + /** + * Classified canceled + */ + const STATUS_CANCELED = 4; + /** * Classified approved */ @@ -1205,10 +1210,10 @@ class ExpenseReport extends CommonObject $this->date_debut = $this->db->jdate($objp->date_debut); - if ($this->fk_statut != 2) + if ($this->fk_statut != self::STATUS_VALIDATED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_statut = 2"; + $sql.= " SET fk_statut = ".self::STATUS_VALIDATED; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_save_from_refuse sql=".$sql, LOG_DEBUG); @@ -1243,12 +1248,12 @@ class ExpenseReport extends CommonObject // date approval $this->date_approve = $now; - if ($this->fk_statut != 5) + if ($this->fk_statut != self::STATUS_APPROVED) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 5, fk_user_approve = ".$fuser->id.","; + $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".$fuser->id.","; $sql.= " date_approve='".$this->db->idate($this->date_approve)."'"; $sql.= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) @@ -1304,10 +1309,10 @@ class ExpenseReport extends CommonObject $error = 0; // date de refus - if ($this->fk_statut != 99) + if ($this->fk_statut != self::STATUS_REFUSED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 99, fk_user_refuse = ".$fuser->id.","; + $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.","; $sql.= " date_refuse='".$this->db->idate($now)."',"; $sql.= " detail_refuse='".$this->db->escape($details)."',"; $sql.= " fk_user_approve = NULL"; @@ -1371,7 +1376,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET paid = 0"; + $sql.= " SET paid = 0, fk_statut = ".self::STATUS_APPROVED; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); @@ -1426,12 +1431,12 @@ class ExpenseReport extends CommonObject { $error = 0; $this->date_cancel = $this->db->idate(gmmktime()); - if ($this->fk_statut != 4) + if ($this->fk_statut != self::STATUS_CANCELED) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_statut = 4, fk_user_cancel = ".$fuser->id; + $sql.= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; $sql.= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; $sql.= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql.= ' WHERE rowid = '.$this->id; From 149d63757fa6fa67db0701a4d6abf811816d4573 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Oct 2019 11:43:56 +0100 Subject: [PATCH 4/4] Space --- htdocs/product/stock/replenishorders.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index ea8a4536be6..111f4c17678 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -272,7 +272,7 @@ if ($resql) $userstatic = new User($db); - while ($i < min($num, $sproduct?$num:$conf->liste_limit)) + while ($i < min($num,$sproduct?$num:$conf->liste_limit)) { $obj = $db->fetch_object($resql);