diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 26b8a0c5826..9058350747f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2141,7 +2141,7 @@ abstract class CommonObject
$attributeKey = substr($key,8); // Remove 'options_' prefix
// Add field of attribut
if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate
- $sql.=",".$attributeKey;
+ $sql.=",".$attributeKey;
}
$sql .= ") VALUES (".$this->id;
foreach($this->array_options as $key => $value)
@@ -2695,7 +2695,8 @@ abstract class CommonObject
global $form,$bc,$bcdd;
$element=$this->element;
- $text='';
+
+ $text=''; $description=''; $type=0;
// Show product and description
$type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type);
@@ -2703,27 +2704,25 @@ abstract class CommonObject
if (! empty($line->date_start)) $type=1; // deprecated
if (! empty($line->date_end)) $type=1; // deprecated
- if ($line->fk_product > 0)
- {
- $product_static = new Product($this->db);
-
- $product_static->type=$line->fk_product_type;
- $product_static->id=$line->fk_product;
- $product_static->ref=$line->ref;
- $text=$product_static->getNomUrl(1);
- }
-
// Ligne en mode visu
if ($action != 'editline' || $selected != $line->id)
{
- // Produit
+ // Product
if ($line->fk_product > 0)
{
- // Define output language
+ $product_static = new Product($this->db);
+
+ $product_static->type=$line->fk_product_type;
+ $product_static->id=$line->fk_product;
+ $product_static->ref=$line->ref;
+ $text=$product_static->getNomUrl(1);
+
+ // Define output language (TODO Does this works ?)
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
$this->fetch_thirdparty();
$prod = new Product($this->db);
+ $prod->fetch($line->fk_product);
$outputlangs = $langs;
$newlang='';
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index abaef7a1910..051f4f98071 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -16,6 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
+ * To use this template, the following var must be defined
+ * $type, $text, $description, $line
*/
?>
@@ -38,59 +40,59 @@
description)
{
- if ($line->description == '(CREDIT_NOTE)')
- {
- $discount=new DiscountAbsolute($this->db);
- $discount->fetch($line->fk_remise_except);
- echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
- }
- elseif ($line->description == '(DEPOSIT)')
- {
- $discount=new DiscountAbsolute($this->db);
- $discount->fetch($line->fk_remise_except);
- echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
- // Add date of deposit
- if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
- }
- else
- {
- echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
- }
+ if ($line->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
+ {
+ $discount=new DiscountAbsolute($this->db);
+ $discount->fetch($line->fk_remise_except);
+ echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
+ }
+ elseif ($line->description == '(DEPOSIT)' && $objp->fk_remise_except > 0)
+ {
+ $discount=new DiscountAbsolute($this->db);
+ $discount->fetch($line->fk_remise_except);
+ echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
+ // Add date of deposit
+ if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
+ }
+ else
+ {
+ echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
}
}
- else
- {
- if ($line->fk_product > 0) {
+ }
+ else
+ {
+ if ($line->fk_product > 0) {
- echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
+ echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
- // Show range
- print_date_range($line->date_start, $line->date_end);
+ // Show range
+ echo get_date_range($line->date_start, $line->date_end);
- // Add description in form
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
- {
- print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):'';
- }
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):'';
+ }
+ } else {
+
+ if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
+ if ($type==1) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
+
+ if (! empty($line->label)) {
+ $text.= ' '.$line->label.'';
+ echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
} else {
-
- if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
- if ($type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
-
- if (! empty($line->label)) {
- $text.= ' '.$line->label.'';
- echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
- } else {
- echo $text.' '.dol_htmlentitiesbr($line->description);
- }
-
- // Show range
- print_date_range($line->date_start,$line->date_end);
+ echo $text.' '.dol_htmlentitiesbr($line->description);
}
+
+ // Show range
+ echo get_date_range($line->date_start,$line->date_end);
}
- ?>
+ }
+ ?>
tva_tx,'%',$line->info_bits); ?> |
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index 733b8ee84ce..4f61d24a4aa 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -193,9 +193,9 @@ if ($type_element == 'supplier_invoice')
}
$sql = $sql_select;
-$sql.= ' d.fk_product as product_id, d.description as prod_descr, ';
-$sql.= ' d.qty as prod_qty, p.rowid as prod_id, p.fk_product_type as prod_type,';
-$sql.= " s.rowid as socid, p.ref as prod_ref, p.label as prod_label";
+$sql.= ' d.fk_product as product_id, d.fk_product as fk_product, d.label, d.description as description, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,';
+$sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type,';
+$sql.= " s.rowid as socid, p.ref as prod_ref, p.label as product_label";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from;
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
$sql.= $where;
@@ -272,23 +272,144 @@ if ($sql_select)
print $documentstatic->getNomUrl(1);
print '';
print ''.dol_print_date($db->jdate($objp->datePrint),'day').' | ';
+
+ print '';
+
+ // Define text, description and type
+ $text=''; $description=''; $type=0;
+
+ // Code to show product duplicated from commonobject->printObjectLine
+ if ($objp->fk_product > 0)
+ {
+ $product_static = new Product($db);
+
+ $product_static->type=$objp->fk_product_type;
+ $product_static->id=$objp->fk_product;
+ $product_static->ref=$objp->ref;
+ $text=$product_static->getNomUrl(1);
+ }
+
+ // Product
+ if ($objp->fk_product > 0)
+ {
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
+ $this->fetch_thirdparty();
+ $prod = new Product($db);
+ $prod->fetch($objp->fk_product);
+
+ $outputlangs = $langs;
+ $newlang='';
+ if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
+ if (empty($newlang)) $newlang=$this->client->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
+ }
+ else
+ {
+ $label = $objp->product_label;
+ }
+
+ $text.= ' - '.(! empty($objp->label)?$objp->label:$label);
+ $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description));
+ }
+
+ if (($objp->info_bits & 2) == 2) { ?>
+
+ trans("ShowReduc"),'reduc').' ';
+ if ($objp->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
+ //else $txt=$langs->trans("Discount");
+ print $txt;
+ ?>
+
+ description)
+ {
+ if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
+ {
+ $discount=new DiscountAbsolute($db);
+ $discount->fetch($objp->fk_remise_except);
+ echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
+ }
+ elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0)
+ {
+ $discount=new DiscountAbsolute($db);
+ $discount->fetch($objp->fk_remise_except);
+ echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
+ // Add date of deposit
+ if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
+ }
+ else
+ {
+ echo ($txt?' - ':'').dol_htmlentitiesbr($objp->description);
+ }
+ }
+ }
+ else
+ {
+ if ($objp->fk_product > 0) {
+
+ echo $form->textwithtooltip($text,$description,3,'','',$i,0,'');
+
+ // Show range
+ echo get_date_range($objp->date_start, $objp->date_end);
+
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print (! empty($objp->description) && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
+ }
+
+ } else {
+
+ //if (! empty($objp->fk_parent_line)) echo img_picto('', 'rightarrow');
+ if ($type==1) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
+
+ if (! empty($objp->label)) {
+ $text.= ' '.$objp->label.'';
+ echo $form->textwithtooltip($text,dol_htmlentitiesbr($objp->description),3,'','',$i,0,'');
+ } else {
+ echo $text.' '.dol_htmlentitiesbr($objp->description);
+ }
+
+ // Show range
+ echo get_date_range($objp->date_start,$objp->date_end);
+ }
+ }
+
+ /*
$prodreftxt='';
- if(!empty($objp->prod_id)) {
+ if ($objp->prod_id > 0)
+ {
$productstatic->id = $objp->prod_id;
$productstatic->ref = $objp->prod_ref;
$productstatic->status = $objp->prod_type;
$prodreftxt = $productstatic->getNomUrl(0);
- if(!empty($objp->prod_label)) $prodreftxt .= ' - '.$objp->prod_label;
+ if(!empty($objp->product_label)) $prodreftxt .= ' - '.$objp->product_label;
}
- if(!empty($objp->prod_descr)) {
- if(!empty($prodreftxt)) {
- $prodreftxt .= ' '.$objp->prod_descr;
- } else {
- $prodreftxt .= $objp->prod_descr;
- }
+ // Show range
+ $prodreftxt .= get_date_range($objp->date_start, $objp->date_end);
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ $prodreftxt .= (! empty($objp->description) && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
}
- print ' | '.$prodreftxt.' | ';
+ */
+ print '';
+
+ //print ''.$prodreftxt.' | ';
+
print ''.$objp->prod_qty.' | ';
+
print "\n";
$i++;
}