diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 4e70f4a5a92..fe577d54347 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -62,6 +62,7 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) if ($element == 'propal') $element = 'propale'; else if ($element == 'fichinter') $element = 'ficheinter'; + else if ($element == 'product') $element = 'produit'; else if ($element == 'order_supplier') { $element = 'fournisseur'; $subelement = 'commande'; diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 7462e66283b..b9c2f7dbfec 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -69,6 +69,7 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) if ($element == 'propal') $element = 'propale'; else if ($element == 'fichinter') $element = 'ficheinter'; + else if ($element == 'product') $element = 'produit'; else if ($element == 'order_supplier') { $element = 'fournisseur'; $subelement = 'commande'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 34baaf8b6ca..7b153182b93 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -80,8 +80,9 @@ class Form global $conf,$langs; $ret=''; - - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + + // TODO change for compatibility + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;/',$typeofdata)) { if ($perm) { @@ -128,7 +129,8 @@ class Form $ret=''; // When option to edit inline is activated - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + // TODO change for compatibility + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;/',$typeofdata)) { $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $success); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index abff74ca484..95471deea91 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2813,85 +2813,6 @@ class Product extends CommonObject } } - /** - * Update product/service type - * - * @param User $user Utilisateur qui fait la modification - * @return void - * TODO Replace this by a method update_field into common - */ - function update_type($user) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET fk_product_type = '".$this->type."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::update_type sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } - - /** - * Mise a jour du code barre - * - * @param User $user Utilisateur qui fait la modification - * @return void - * TODO Replace this by a method update_field into common - */ - function update_barcode($user) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET barcode = '".$this->barcode."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::update_barcode sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } - - /** - * Mise a jour du type de code barre - * - * @param User $user Utilisateur qui fait la modification - * @return void - * TODO Replace this by a method update_field into common - */ - function update_barcode_type($user) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET fk_barcode_type = '".$this->barcode_type."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::update_barcode_type sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } - - /** * Return if object is a product * diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 52ca1c8b68e..0b71179b475 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -88,12 +88,10 @@ $error=$hookmanager->error; $errors=$hookmanager->errors; if (empty($reshook)) { // Type - if ($action == 'setproducttype' && $user->rights->produit->creer) + if ($action == 'setfk_product_type' && $user->rights->produit->creer) { - var_dump($action); $object->fetch($id); - $object->type = $_POST['producttype']; - $result = $object->update_type($user); + $result = $object->setValueFrom('fk_product_type', $_POST['fk_product_type']); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } @@ -102,8 +100,7 @@ if (empty($reshook)) if ($action == 'setbarcodetype' && $user->rights->barcode->creer) { $object->fetch($id); - $object->barcode_type = $_POST['barcodetype_id']; - $result = $object->update_barcode_type($user); + $result = $object->setValueFrom('fk_barcode_type', $_POST['barcodetype_id']); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } @@ -112,18 +109,16 @@ if (empty($reshook)) if ($action == 'setbarcode' && $user->rights->barcode->creer) { $object->fetch($id); - $object->barcode = $_POST['barcode']; //Todo: ajout verification de la validite du code barre en fonction du type - $result = $object->update_barcode($user); + //Todo: ajout verification de la validite du code barre en fonction du type + $result = $object->setValueFrom('barcode', $_POST['barcode']); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - if ($action == 'setproductaccountancycodebuy') + if ($action == 'setaccountancy_code_buy') { - $product = new Product($db); - $result=$product->fetch($id,$ref); - $product->accountancy_code_buy=$_POST["productaccountancycodebuy"]; - $result=$product->update($product->id,$user,1,0,1); + $object->fetch($id,$ref); + $result = $object->setValueFrom('accountancy_code_buy', $_POST['productaccountancycodebuy']); if ($result < 0) { $mesg=join(',',$product->errors); @@ -131,12 +126,12 @@ if (empty($reshook)) $action=""; } - if ($action == 'setproductaccountancycodesell') + if ($action == 'setaccountancy_code_buy') { - $product = new Product($db); - $result=$product->fetch($id,$ref); + $object->fetch($id,$ref); $product->accountancy_code_sell=$_POST["productaccountancycodesell"]; $result=$product->update($product->id,$user,1,0,1); + $result = $object->setValueFrom('accountancy_code_sell', $_POST['productaccountancycodesell']); if ($result < 0) { $mesg=join(',',$product->errors); @@ -1092,9 +1087,10 @@ else // Type if ($conf->produit->enabled && $conf->service->enabled) { - $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); - print ''.$form->editfieldkey("Type",'producttype',$object->type,$object,$user->rights->produit->creer|$user->rights->service->creer,$typeformat).''; - print $form->editfieldval("Type",'producttype',$object->type,$object,$user->rights->produit->creer|$user->rights->service->creer,$typeformat); + // TODO change for compatibility with edit in place + $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); + print ''.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).''; + print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); print ''; } @@ -1145,13 +1141,13 @@ else } // Accountancy sell code - print ''.$form->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,$object,$user->rights->produit->creer|$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,$object,$user->rights->produit->creer|$user->rights->service->creer); + print ''.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer).''; + print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer); print ''; // Accountancy buy code - print ''.$form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,$object,$user->rights->produit->creer|$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,$object,$user->rights->produit->creer|$user->rights->service->creer); + print ''.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer).''; + print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer); print ''; // Status (to sell) @@ -1742,8 +1738,6 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status) } - -llxFooter(); - $db->close(); +llxFooter(); ?>