From 2257706a3026edc8908941bbb87d2ce6d6868e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 14 Oct 2019 22:22:20 +0200 Subject: [PATCH 1/4] New: Update product type with update method --- htdocs/product/class/api_products.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2a9f407bf54..81e2659d918 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -246,8 +246,13 @@ class Products extends DolibarrApi } $this->product->$field = $value; } + + $updatetype = false; + if ($this->product->type != $oldproduct->type && ($this->product->isProduct() || $this->product->isService())) { + $updatetype = true; + } - $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update'); + $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update', $updatetype); // If price mode is 1 price per product if ($result > 0 && ! empty($conf->global->PRODUCT_PRICE_UNIQ)) { From 3429cb7c1d8dc4d4a43b4372b077a1e998ea6ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 14 Oct 2019 22:42:38 +0200 Subject: [PATCH 2/4] New: Update product type with update method --- htdocs/product/class/product.class.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1b46a656511..aa0c575d8d7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -787,13 +787,14 @@ class Product extends CommonObject * Update a record into database. * If batch flag is set to on, we create records into llx_product_batch * - * @param int $id Id of product - * @param User $user Object user making update - * @param int $notrigger Disable triggers - * @param string $action Current action for hookmanager ('add' or 'update') + * @param int $id Id of product + * @param User $user Object user making update + * @param int $notrigger Disable triggers + * @param string $action Current action for hookmanager ('add' or 'update') + * @param int $updatetype Update product type * @return int 1 if OK, -1 if ref already exists, -2 if other error */ - public function update($id, $user, $notrigger = false, $action = 'update') + public function update($id, $user, $notrigger = false, $action = 'update', $updatetype = false) { global $langs, $conf, $hookmanager; @@ -939,6 +940,11 @@ class Product extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."product"; $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; + + if ($updatetype && ($this->isProduct() || $this->isService())) { + $sql.= ", fk_product_type = " . $this->type; + } + $sql.= ", ref = '" . $this->db->escape($this->ref) ."'"; $sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); From b77d2f2ff2d71ac8c1948ee25db8e2b63804f78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Oct 2019 23:27:37 +0200 Subject: [PATCH 3/4] Update box_task.php --- htdocs/core/boxes/box_task.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 59b31086db5..dbe1757d55d 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -134,7 +134,13 @@ class box_task extends ModeleBoxes }); }); '; - + // set cookie by js + $boxcontent.=''; + $this->info_box_contents[0][] = array( + 'tr'=>'class="nohover"', + 'td' => 'class="nohover"', + 'textnoformat' => $boxcontent, + ); $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; @@ -163,7 +169,7 @@ class box_task extends ModeleBoxes $sql.= $this->db->plimit($max, 0); $result = $this->db->query($sql); - $i = 0; + $i = 1; if ($result) { $num = $this->db->num_rows($result); while ($objp = $this->db->fetch_object($result)) { @@ -183,8 +189,12 @@ class box_task extends ModeleBoxes $label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - $boxcontent.= getTaskProgressView($taskstatic, $label, true, false, true); + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, true); + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => $boxcontent, + ); $i++; } } else { @@ -192,15 +202,6 @@ class box_task extends ModeleBoxes } } - // set cookie by js - if(empty($i)){ - $boxcontent.=''; - } - - $this->info_box_contents[0][] = array( - 'td' => '', - 'text' => $boxcontent, - ); } /** From 4ca9fddfcc93ecc829f2ffc5e3710ae87824ba38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 14:26:49 +0200 Subject: [PATCH 4/4] Update product.class.php --- htdocs/product/class/product.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index aa0c575d8d7..2b3fc3ece65 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -787,12 +787,12 @@ class Product extends CommonObject * Update a record into database. * If batch flag is set to on, we create records into llx_product_batch * - * @param int $id Id of product - * @param User $user Object user making update - * @param int $notrigger Disable triggers - * @param string $action Current action for hookmanager ('add' or 'update') - * @param int $updatetype Update product type - * @return int 1 if OK, -1 if ref already exists, -2 if other error + * @param int $id Id of product + * @param User $user Object user making update + * @param int $notrigger Disable triggers + * @param string $action Current action for hookmanager ('add' or 'update') + * @param boolean $updatetype Update product type + * @return int 1 if OK, -1 if ref already exists, -2 if other error */ public function update($id, $user, $notrigger = false, $action = 'update', $updatetype = false) {