New: Can convert a product/service into service/product.
This commit is contained in:
parent
e45bbb622a
commit
00b7ad4a78
@ -57,6 +57,7 @@ For users:
|
||||
- New: All professional id can contains up to 128 chars instead of 32.
|
||||
- New: [ task #176 ] Allow to use ODT templates for proposals and orders like it's done for invoices
|
||||
- New: Add hidden option MAIN_ADD_PDF_BACKGROUND to add a PDF as background of invoice/order generated PDF.
|
||||
- New: Can convert a product/service into service/product.
|
||||
- Fix: Can use POS module with several concurrent users.
|
||||
- Fix: Installer don't fails with Mysql version that added a ssl_cypher field.
|
||||
- Fix: Sanitize input parameters.
|
||||
|
||||
@ -156,6 +156,16 @@ class Form
|
||||
{
|
||||
$ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname);
|
||||
}
|
||||
else if (preg_match('/^select;/',$typeofdata))
|
||||
{
|
||||
$arraydata=explode(',',preg_replace('/^select;/','',$typeofdata));
|
||||
foreach($arraydata as $val)
|
||||
{
|
||||
$tmp=explode(':',$val);
|
||||
$arraylist[$tmp[0]]=$tmp[1];
|
||||
}
|
||||
$ret.=$this->selectarray($htmlname,$arraylist,$value);
|
||||
}
|
||||
else if (preg_match('/^ckeditor/',$typeofdata))
|
||||
{
|
||||
$tmp=explode(':',$typeofdata);
|
||||
@ -173,6 +183,16 @@ class Form
|
||||
if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1);
|
||||
elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day');
|
||||
elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value);
|
||||
else if (preg_match('/^select;/',$typeofdata))
|
||||
{
|
||||
$arraydata=explode(',',preg_replace('/^select;/','',$typeofdata));
|
||||
foreach($arraydata as $val)
|
||||
{
|
||||
$tmp=explode(':',$val);
|
||||
$arraylist[$tmp[0]]=$tmp[1];
|
||||
}
|
||||
$ret.=$arraylist[$value];
|
||||
}
|
||||
else if (preg_match('/^ckeditor/',$typeofdata))
|
||||
{
|
||||
$tmpcontent=dol_htmlentitiesbr($value);
|
||||
@ -196,7 +216,7 @@ class Form
|
||||
* @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx')
|
||||
* @param string $editvalue When in edit mode, use this value as $value instead of value
|
||||
* @param object $extObject External object
|
||||
* @param string $success Success message
|
||||
* @param string $success Success message
|
||||
* @return string HTML edit in place
|
||||
*/
|
||||
private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $editvalue=null, $extObject=null, $success=null)
|
||||
@ -284,7 +304,7 @@ class Form
|
||||
if (! empty($success)) $out.= '<input id="success_'.$htmlname.'" value="'.$success.'" type="hidden"/>'."\n";
|
||||
//$out.= '<input id="ext_table_element_'.$htmlname.'" value="'.$ext_table_element.'" type="hidden"/>'."\n";
|
||||
//$out.= '<input id="ext_fk_element_'.$htmlname.'" value="'.$ext_fk_element.'" type="hidden"/>'."\n";
|
||||
|
||||
|
||||
$out.= '<div id="viewval_'.$htmlname.'" class="viewval_'.$inputType.($button_only ? ' inactive' : ' active').'">'.$value.'</div>'."\n";
|
||||
$out.= '<div id="editval_'.$htmlname.'" class="editval_'.$inputType.($button_only ? ' inactive' : ' active').' hideobject">'.(! empty($editvalue) ? $editvalue : $value).'</div>'."\n";
|
||||
}
|
||||
|
||||
@ -2813,11 +2813,38 @@ 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)
|
||||
{
|
||||
@ -2843,6 +2870,7 @@ class Product extends CommonObject
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
@ -2871,14 +2899,7 @@ class Product extends CommonObject
|
||||
*/
|
||||
function isproduct()
|
||||
{
|
||||
if ($this->type != 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ($this->type != 1 ? true : false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2888,14 +2909,7 @@ class Product extends CommonObject
|
||||
*/
|
||||
function isservice()
|
||||
{
|
||||
if ($this->type==1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ($this->type == 1 ? true : false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -87,6 +87,17 @@ $error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
// Type
|
||||
if ($action == 'setproducttype' && $user->rights->produit->creer)
|
||||
{
|
||||
var_dump($action);
|
||||
$object->fetch($id);
|
||||
$object->type = $_POST['producttype'];
|
||||
$result = $object->update_type($user);
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Barcode type
|
||||
if ($action == 'setbarcodetype' && $user->rights->barcode->creer)
|
||||
{
|
||||
@ -1078,6 +1089,15 @@ else
|
||||
|
||||
print '</tr>';
|
||||
|
||||
// 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);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($showbarcode)
|
||||
{
|
||||
// Barcode type
|
||||
|
||||
Loading…
Reference in New Issue
Block a user