Fix: compatibility with edit in place
Qual: use generic function and remove unused Todo: Type of product combobox is not compatible with edit in place
This commit is contained in:
parent
00b7ad4a78
commit
68ce569d05
@ -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';
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -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 '<tr><td>'.$form->editfieldkey("Type",'producttype',$object->type,$object,$user->rights->produit->creer|$user->rights->service->creer,$typeformat).'</td><td colspan="2">';
|
||||
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 '<tr><td>'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">';
|
||||
print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -1145,13 +1141,13 @@ else
|
||||
}
|
||||
|
||||
// Accountancy sell code
|
||||
print '<tr><td>'.$form->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,$object,$user->rights->produit->creer|$user->rights->service->creer).'</td><td colspan="2">';
|
||||
print $form->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,$object,$user->rights->produit->creer|$user->rights->service->creer);
|
||||
print '<tr><td>'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer).'</td><td colspan="2">';
|
||||
print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer);
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy buy code
|
||||
print '<tr><td>'.$form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,$object,$user->rights->produit->creer|$user->rights->service->creer).'</td><td colspan="2">';
|
||||
print $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,$object,$user->rights->produit->creer|$user->rights->service->creer);
|
||||
print '<tr><td>'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer).'</td><td colspan="2">';
|
||||
print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer);
|
||||
print '</td></tr>';
|
||||
|
||||
// Status (to sell)
|
||||
@ -1742,8 +1738,6 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status)
|
||||
}
|
||||
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
llxFooter();
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user