New: Can use personalized fields of products/services.

This commit is contained in:
Laurent Destailleur 2012-03-03 19:02:44 +01:00
parent 2de1ff11e2
commit f5c551d725
3 changed files with 54 additions and 20 deletions

View File

@ -5,9 +5,10 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.2 compared to 3.1 *****
WARNING: PHP lower than 5.x are no more supported.
WARNING: Because of a major datastructure change onto supplier prices tabkes, be aware
to make a backup of your datbase before making upgrade.
to make a backup of your database before making upgrade.
For users:
- New: Can use personalized fields of products/services.
- New: Can attach files on social contributions.
- New: Show payments terms and conditions onto muscadet template.
- New: Can open back a closed commercial proposal.

View File

@ -463,7 +463,7 @@ class Product extends CommonObject
$sql.= ",accountancy_code_sell= '" . $this->accountancy_code_sell."'";
$sql.= " WHERE rowid = " . $id;
dol_syslog("Product::update sql=".$sql);
dol_syslog(get_class($this)."update sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
@ -479,7 +479,23 @@ class Product extends CommonObject
}
}
if (! $notrigger)
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
@ -735,7 +751,7 @@ class Product extends CommonObject
$sql.= " ".$this->localtax1_tx.",".$this->localtax2_tx.",".$this->price_min.",".$this->price_min_ttc;
$sql.= ")";
dol_syslog("Product::_log_price sql=".$sql);
dol_syslog(get_class($this)."_log_price sql=".$sql);
$resql=$this->db->query($sql);
if(! $resql)
{
@ -762,7 +778,7 @@ class Product extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price";
$sql.= " WHERE rowid=".$rowid;
dol_syslog("Product::log_price_delete sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."log_price_delete sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -796,7 +812,7 @@ class Product extends CommonObject
$sql.= " WHERE pfp.rowid = ".$prodfournprice;
$sql.= " AND pfp.quantity <= ".$qty;
dol_syslog("Product::get_buyprice sql=".$sql);
dol_syslog(get_class($this)."get_buyprice sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@ -821,7 +837,7 @@ class Product extends CommonObject
$sql.= " ORDER BY pfp.quantity DESC";
$sql.= " LIMIT 1";
dol_syslog("Product::get_buyprice sql=".$sql);
dol_syslog(get_class($this)."get_buyprice sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@ -873,7 +889,7 @@ class Product extends CommonObject
{
global $conf,$langs;
dol_syslog("Product::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level." npr=".$newnpr);
dol_syslog(get_class($this)."update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level." npr=".$newnpr);
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
@ -943,7 +959,7 @@ class Product extends CommonObject
$sql.= " recuperableonly='".$newnpr."'";
$sql.= " WHERE rowid = ".$id;
dol_syslog("Product::update_price sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."update_price sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -1783,7 +1799,7 @@ class Product extends CommonObject
$sql.= ", ".$user->id;
$sql.= ")";
dol_syslog("Product::add_fournisseur sql=".$sql);
dol_syslog(get_class($this)."add_fournisseur sql=".$sql);
if ($this->db->query($sql))
{
$this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");

View File

@ -118,8 +118,6 @@ if (empty($reshook))
$mesg=join(',',$product->errors);
}
$action="";
$id=$_POST["id"];
$_GET["id"]=$_POST["id"];
}
if ($action == 'setproductaccountancycodesell')
@ -214,6 +212,15 @@ if (empty($reshook))
}
}
// Get extra fields
foreach($_POST as $key => $value)
{
if (preg_match("/^options_/",$key))
{
$product->array_options[$key]=$_POST[$key];
}
}
$id = $product->create($user);
if ($id > 0)
@ -265,6 +272,15 @@ if (empty($reshook))
$product->finished = $_POST["finished"];
$product->hidden = $_POST["hidden"]=='yes'?1:0;
// Get extra fields
foreach($_POST as $key => $value)
{
if (preg_match("/^options_/",$key))
{
$product->array_options[$key]=$_POST[$key];
}
}
if ($product->check())
{
if ($product->update($product->id, $user) > 0)
@ -628,7 +644,7 @@ if (empty($reshook))
if (GETPOST("cancel") == $langs->trans("Cancel"))
{
$action = '';
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]);
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
@ -847,7 +863,9 @@ else
else if ($id || $ref)
{
$object=new Product($db);
$object->fetch($id,$ref);
$res=$object->fetch($id,$ref);
if ($res < 0) { dol_print_error($db,$object->error); exit; }
$res=$object->fetch_optionals($id,$extralabels);
/*
* Fiche en mode edition
@ -1046,7 +1064,7 @@ else
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->libelle.'</td>';
$nblignes=9;
$nblignes=8;
if ($object->type!=1) $nblignes++;
if ($object->isservice()) $nblignes++;
else $nblignes+=4;
@ -1212,7 +1230,7 @@ else
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($object->country_id,0,$db).'</td>';
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
@ -1220,13 +1238,13 @@ else
{
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
print '<tr><td>'.$label.'</td><td colspan="3">';
print $extrafields->showInputField($key,$value);
print $extrafields->showOutputField($key,$value);
print '</td></tr>'."\n";
}
}
// Note
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'</td></tr>';
print "</table>\n";
@ -1709,8 +1727,7 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status)
$db->close();
llxFooter();
$db->close();
?>