Skip to content

Commit

Permalink
New: Update product type with update method
Browse files Browse the repository at this point in the history
  • Loading branch information
c3do committed Oct 14, 2019
1 parent 2257706 commit 3429cb7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions htdocs/product/class/product.class.php
Expand Up @@ -787,13 +787,14 @@ public function check_barcode($valuetotest, $typefortest)
* 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;

Expand Down Expand Up @@ -939,6 +940,11 @@ public function update($id, $user, $notrigger = false, $action = 'update')

$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");
Expand Down

0 comments on commit 3429cb7

Please sign in to comment.