Debug virtual product interface

This commit is contained in:
Laurent Destailleur 2015-03-11 14:55:45 +01:00
parent 958667ada0
commit e8e2f65ae5
5 changed files with 137 additions and 106 deletions

View File

@ -779,8 +779,21 @@ if (empty($reshook))
$desc = dol_concatdesc($desc, $product_desc); $desc = dol_concatdesc($desc, $product_desc);
// Add dimensions into product description
/*if (empty($conf->global->MAIN_PRODUCT_DISABLE_AUTOADD_DIM))
{
$text='';
if ($prod->weight) $text.=($text?"\n":"").$outputlangs->trans("Weight").': '.$prod->weight.' '.$prod->weight_units;
if ($prod->length) $text.=($text?"\n":"").$outputlangs->trans("Length").': '.$prod->length.' '.$prod->length_units;
if ($prod->surface) $text.=($text?"\n":"").$outputlangs->trans("Surface").': '.$prod->surface.' '.$prod->surface_units;
if ($prod->volume) $text.=($text?"\n":"").$outputlangs->trans("Volume").': '.$prod->volume.' '.$prod->volume_units;
$desc = dol_concatdesc($desc, $text);
}*/
// Add custom code and origin country into description // Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
{
$tmptxt = '('; $tmptxt = '(';
if (! empty($prod->customcode)) if (! empty($prod->customcode))
$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;

View File

@ -2804,12 +2804,7 @@ abstract class CommonObject
if ($line->fk_product > 0) if ($line->fk_product > 0)
{ {
$product_static = new Product($this->db); $product_static = new Product($this->db);
$product_static->fetch($line->fk_product);
$product_static->type=$line->fk_product_type;
$product_static->id=$line->fk_product;
$product_static->ref=$line->ref;
if (! empty($line->entity))
$product_static->entity=$line->entity;
$text=$product_static->getNomUrl(1); $text=$product_static->getNomUrl(1);
// Define output language and label // Define output language and label
@ -2842,7 +2837,7 @@ abstract class CommonObject
} }
$text.= ' - '.(! empty($line->label)?$line->label:$label); $text.= ' - '.(! empty($line->label)?$line->label:$label);
$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description)); $description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc.
} }
// Output template part (modules that overwrite templates must declare this into descriptor) // Output template part (modules that overwrite templates must declare this into descriptor)

View File

@ -1175,6 +1175,7 @@ else
print '</td></tr>'; print '</td></tr>';
// Stock // Stock
/*
if ($object->isproduct() && ! empty($conf->stock->enabled)) if ($object->isproduct() && ! empty($conf->stock->enabled))
{ {
print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>'; print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>';
@ -1189,7 +1190,7 @@ else
{ {
print '<input name="seuil_stock_alerte" type="hidden" value="'.$object->seuil_stock_alerte.'">'; print '<input name="seuil_stock_alerte" type="hidden" value="'.$object->seuil_stock_alerte.'">';
print '<input name="desiredstock" type="hidden" value="'.$object->desiredstock.'">'; print '<input name="desiredstock" type="hidden" value="'.$object->desiredstock.'">';
} }*/
// Nature // Nature
if($object->type!=1) if($object->type!=1)

View File

@ -2656,13 +2656,13 @@ class Product extends CommonObject
* @param int $level Init level * @param int $level Init level
* @return void * @return void
*/ */
function fetch_prod_arbo($prod, $compl_path="", $multiply=1, $level=1) function fetch_prod_arbo($prod, $compl_path="", $multiply=1, $level=1, $id_parent=0)
{ {
global $conf,$langs; global $conf,$langs;
$product = new Product($this->db); $product = new Product($this->db);
//var_dump($prod); //var_dump($prod);
foreach($prod as $id_product => $desc_pere) // $id_product is 0 (there is no mode sub_product) or an id of a sub_product foreach($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product
{ {
if (is_array($desc_pere)) // If desc_pere is an array, this means it's a child if (is_array($desc_pere)) // If desc_pere is an array, this means it's a child
{ {
@ -2679,6 +2679,7 @@ class Product extends CommonObject
$this->load_stock(); // Load stock $this->load_stock(); // Load stock
$this->res[]= array( $this->res[]= array(
'id'=>$id, // Id product 'id'=>$id, // Id product
'id_parent'=>$id_parent,
'ref'=>$this->ref, // Ref product 'ref'=>$this->ref, // Ref product
'nb'=>$nb, // Nb of units that compose parent product 'nb'=>$nb, // Nb of units that compose parent product
'nb_total'=>$nb*$multiply, // Nb of units for all nb of product 'nb_total'=>$nb*$multiply, // Nb of units for all nb of product
@ -2696,7 +2697,7 @@ class Product extends CommonObject
if (is_array($desc_pere['childs'])) if (is_array($desc_pere['childs']))
{ {
//print 'YYY We go down for '.$desc_pere[3]." -> \n"; //print 'YYY We go down for '.$desc_pere[3]." -> \n";
$this ->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1]*$multiply, $level+1); $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1]*$multiply, $level+1, $id);
} }
} }
} }
@ -2718,7 +2719,7 @@ class Product extends CommonObject
$this->res[]= array($desc_pere[1],$desc_pere[0]); $this->res[]= array($desc_pere[1],$desc_pere[0]);
if(count($desc_pere) >1) if(count($desc_pere) >1)
{ {
$this ->fetch_prods($desc_pere); $this->fetch_prods($desc_pere);
} }
} }
} }
@ -2736,7 +2737,7 @@ class Product extends CommonObject
{ {
foreach($this->sousprods as $prod_name => $desc_product) foreach($this->sousprods as $prod_name => $desc_product)
{ {
if (is_array($desc_product)) $this->fetch_prod_arbo($desc_product,"",$multiply); if (is_array($desc_product)) $this->fetch_prod_arbo($desc_product,"",$multiply,1,$this->id);
} }
} }
//var_dump($this->res); //var_dump($this->res);
@ -2751,13 +2752,11 @@ class Product extends CommonObject
function get_each_prod() function get_each_prod()
{ {
$this->res = array(); $this->res = array();
if(is_array($this -> sousprods)) if (is_array($this->sousprods))
{ {
foreach($this -> sousprods as $nom_pere => $desc_pere) foreach($this->sousprods as $nom_pere => $desc_pere)
{ {
if(count($desc_pere) >1) if (count($desc_pere) >1) $this->fetch_prods($desc_pere);
$this ->fetch_prods($desc_pere);
} }
sort($this->res); sort($this->res);
} }
@ -2769,10 +2768,10 @@ class Product extends CommonObject
* Return all Father products fo current product * Return all Father products fo current product
* *
* @return array prod * @return array prod
* @see getParent
*/ */
function getFather() function getFather()
{ {
$sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id,p.fk_product_type"; $sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id,p.fk_product_type";
$sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,";
$sql.= " ".MAIN_DB_PREFIX."product as p"; $sql.= " ".MAIN_DB_PREFIX."product as p";
@ -2803,10 +2802,10 @@ class Product extends CommonObject
* Return all direct parent products fo current product * Return all direct parent products fo current product
* *
* @return array prod * @return array prod
* @see getFather
*/ */
function getParent() function getParent()
{ {
$sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id,p.fk_product_type"; $sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id,p.fk_product_type";
$sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,";
$sql.= " ".MAIN_DB_PREFIX."product as p"; $sql.= " ".MAIN_DB_PREFIX."product as p";
@ -2833,10 +2832,11 @@ class Product extends CommonObject
/** /**
* Return childs of product $id * Return childs of product $id
* *
* @param int $id Id of product to search childs of * @param int $id Id of product to search childs of
* @return array Prod * @param int $firstlevelonly Return only direct child
* @return array Prod
*/ */
function getChildsArbo($id) function getChildsArbo($id, $firstlevelonly=0)
{ {
$sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec"; $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
@ -2861,10 +2861,13 @@ class Product extends CommonObject
); );
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']);
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
$listofchilds=$this->getChildsArbo($rec['id']); if (empty($firstlevelonly))
foreach($listofchilds as $keyChild => $valueChild)
{ {
$prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; $listofchilds=$this->getChildsArbo($rec['id']);
foreach($listofchilds as $keyChild => $valueChild)
{
$prods[$rec['rowid']]['childs'][$keyChild] = $valueChild;
}
} }
} }
@ -2910,6 +2913,7 @@ class Product extends CommonObject
function getNomUrl($withpicto=0,$option='',$maxlength=0) function getNomUrl($withpicto=0,$option='',$maxlength=0)
{ {
global $conf, $langs; global $conf, $langs;
include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$result=''; $result='';
$newref=$this->ref; $newref=$this->ref;
@ -2920,6 +2924,14 @@ class Product extends CommonObject
$label .= '<br><b>' . $langs->trans('ProductRef') . ':</b> ' . $this->ref; $label .= '<br><b>' . $langs->trans('ProductRef') . ':</b> ' . $this->ref;
if (! empty($this->label)) if (! empty($this->label))
$label .= '<br><b>' . $langs->trans('ProductLabel') . ':</b> ' . $this->label; $label .= '<br><b>' . $langs->trans('ProductLabel') . ':</b> ' . $this->label;
$tmptext='';
if ($this->weight) $tmptext.="<br>".$langs->trans("Weight").': '.$this->weight.' '.measuring_units_string($this->weight_units,"weight");
if ($this->length) $tmptext.="<br>".$langs->trans("Length").': '.$this->length.' '.measuring_units_string($this->length_units,'length');
if ($this->surface) $tmptext.="<br>".$langs->trans("Surface").': '.$this->surface.' '.measuring_units_string($this->surface_units,'surface');
if ($this->volume) $tmptext.="<br>".$langs->trans("Volume").': '.$this->volume.' '.measuring_units_string($this->volume_units,'volume');
if ($tmptext) $label .= $tmptext;
if (! empty($this->entity)) if (! empty($this->entity))
$label .= '<br>' . $this->show_photos($conf->product->multidir_output[$this->entity],1,1,0,0,0,80); $label .= '<br>' . $this->show_photos($conf->product->multidir_output[$this->entity],1,1,0,0,0,80);

View File

@ -50,13 +50,13 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype);
$product = new Product($db); $object = new Product($db);
$productid=0; $objectid=0;
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$result = $product->fetch($id,$ref); $result = $object->fetch($id,$ref);
$productid=$product->id; $objectid=$object->id;
$id=$product->id; $id=$object->id;
} }
@ -74,7 +74,7 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se
{ {
if ($_POST["prod_qty_".$i] > 0) if ($_POST["prod_qty_".$i] > 0)
{ {
if ($product->add_sousproduit($id, $_POST["prod_id_".$i], $_POST["prod_qty_".$i], $_POST["prod_incdec_".$i]) > 0) if ($object->add_sousproduit($id, $_POST["prod_id_".$i], $_POST["prod_qty_".$i], $_POST["prod_incdec_".$i]) > 0)
{ {
//var_dump($id.' - '.$_POST["prod_id_".$i].' - '.$_POST["prod_qty_".$i]);exit; //var_dump($id.' - '.$_POST["prod_id_".$i].' - '.$_POST["prod_qty_".$i]);exit;
$action = 'edit'; $action = 'edit';
@ -83,16 +83,16 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se
{ {
$error++; $error++;
$action = 're-edit'; $action = 're-edit';
if ($product->error == "isFatherOfThis") { if ($object->error == "isFatherOfThis") {
setEventMessage($langs->trans("ErrorAssociationIsFatherOfThis"), 'errors'); setEventMessage($langs->trans("ErrorAssociationIsFatherOfThis"), 'errors');
} else { } else {
setEventMessage($product->error, 'errors'); setEventMessage($object->error, 'errors');
} }
} }
} }
else else
{ {
if ($product->del_sousproduit($id, $_POST["prod_id_".$i]) > 0) if ($object->del_sousproduit($id, $_POST["prod_id_".$i]) > 0)
{ {
$action = 'edit'; $action = 'edit';
} }
@ -100,13 +100,13 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se
{ {
$error++; $error++;
$action = 're-edit'; $action = 're-edit';
setEventMessage($product->error, 'errors'); setEventMessage($object->error, 'errors');
} }
} }
} }
if (! $error) if (! $error)
{ {
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$product->id); header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
} }
@ -117,7 +117,8 @@ else if($action==='save_composed_product')
{ {
foreach ($TProduct as $id_product => $row) foreach ($TProduct as $id_product => $row)
{ {
$product->update_sousproduit($id, $id_product,$row['qty'], isset($row['incdec']) ? 1 : 0 ); if ($row['qty'] > 0) $object->update_sousproduit($id, $id_product, $row['qty'], isset($row['incdec']) ? 1 : 0 );
else $object->del_sousproduit($id, $id_product);
} }
} }
$action=''; $action='';
@ -171,11 +172,11 @@ if ($action == 'search')
//print $sql; //print $sql;
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$object->type));
$head=product_prepare_head($product, $user); $head=product_prepare_head($object, $user);
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($product->type==1?'service':'product'); $picto=($object->type==1?'service':'product');
dol_fiche_head($head, 'subproduct', $titre, 0, $picto); dol_fiche_head($head, 'subproduct', $titre, 0, $picto);
@ -191,20 +192,28 @@ if ($id > 0 || ! empty($ref))
print "<tr>"; print "<tr>";
$nblignes=6; $nblignes=6;
if ($product->isproduct() && ! empty($conf->stock->enabled)) $nblignes++; if ($object->isproduct() && ! empty($conf->stock->enabled)) $nblignes++;
if ($product->isservice()) $nblignes++; if ($object->isservice()) $nblignes++;
// Reference // Reference
print '<td width="25%">'.$langs->trans("Ref").'</td><td>'; print '<td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($product,'ref','',1,'ref'); print $form->showrefnav($object,'ref','',1,'ref');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>'; print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->libelle.'</td>';
print '</tr>'; print '</tr>';
// Nature
if($object->type!=1)
{
print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="2">';
print $object->getLibFinished();
print '</td></tr>';
}
if (empty($conf->global->PRODUIT_MULTIPRICES)) if (empty($conf->global->PRODUIT_MULTIPRICES))
{ {
// Price // Price
@ -232,28 +241,57 @@ if ($id > 0 || ! empty($ref))
print '</td></tr>'; print '</td></tr>';
} }
print '</table>';
dol_fiche_end();
$prodsfather = $object->getFather(); // Parent Products
$object->get_sousproduits_arbo(); // Load $object->sousprod
$prods_arbo=$object->get_arbo_each_prod();
$nbofsubsubproducts=count($prods_arbo); // This include sub sub product into nb
$prodschild = $object->getChildsArbo($id,1);
$nbofsubproducts=count($prodschild); // This include only first level of childs
// Number of parent virtual products
print $form->textwithpicto($langs->trans("ParentProductsNumber").': '.count($prodsfather), $langs->trans('IfZeroItIsNotUsedByVirtualProduct'));
if (count($prodsfather) > 0)
{
print $langs->trans("ProductParentList").'<br>';
print '<table class="nobordernopadding">';
foreach($prodsfather as $value)
{
$idprod= $value["id"];
$productstatic->id=$idprod;// $value["id"];
$productstatic->type=$value["fk_product_type"];
$productstatic->ref=$value['label'];
print '<tr>';
print '<td>'.$productstatic->getNomUrl(1,'composition').'</td>';;
print '</tr>';
}
print '</table>';
}
print '<br>'."\n";
// Number of subproducts // Number of subproducts
$prodsfather = $product->getFather(); //Parent Products print $form->textwithpicto($langs->trans("AssociatedProductsNumber").': '.(empty($conf->global->PRODUCT_SHOW_SUB_SUB_PRODUCTS)?$nbofsubproducts:$nbofsubsubproducts), $langs->trans('IfZeroItIsNotAVirtualProduct'));
$product->get_sousproduits_arbo(); // Defined $product->sousprod
$prods_arbo=$product->get_arbo_each_prod();
$nbofsubproducts=count($prods_arbo);
print '<tr><td>'.$langs->trans("AssociatedProductsNumber").'</td><td>';
print $form->textwithpicto($nbofsubproducts, $langs->trans('IfZeroItIsNotAVirtualProduct'));
print '</td>';
print '</tr>';
// List of subproducts // List of subproducts
if (count($prods_arbo) > 0) if (count($prods_arbo) > 0)
{ {
$atleastonenotdefined=0; $atleastonenotdefined=0;
print '<tr><td colspan="2">';
print $langs->trans("ProductAssociationList").'<br>'; print $langs->trans("ProductAssociationList").'<br>';
print '<form name="formComposedProduct" action="'.$_SERVER['PHP_SELF'].'" method="post">'; print '<form name="formComposedProduct" action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="action" value="save_composed_product" />'; print '<input type="hidden" name="action" value="save_composed_product" />';
print '<input type="hidden" name="id" value="'.$id.'" />'; print '<input type="hidden" name="id" value="'.$id.'" />';
print '<table class="centpercent nobordernopadding">'; print '<table class="centpercent noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('ComposedProduct').'</td>'; print '<td>'.$langs->trans('ComposedProduct').'</td>';
@ -262,7 +300,7 @@ if ($id > 0 || ! empty($ref))
if (! empty($conf->stock->enabled)) print '<td align="right">'.$langs->trans('Stock').'</td>'; if (! empty($conf->stock->enabled)) print '<td align="right">'.$langs->trans('Stock').'</td>';
print '<td align="center">'.$langs->trans('Qty').'</td>'; print '<td align="center">'.$langs->trans('Qty').'</td>';
print '<td align="center">'.$langs->trans('ComposedProductIncDecStock').'</td>'; print '<td align="center">'.$langs->trans('ComposedProductIncDecStock').'</td>';
print '</tr>'; print '</tr>'."\n";
foreach($prods_arbo as $value) foreach($prods_arbo as $value)
{ {
@ -270,11 +308,11 @@ if ($id > 0 || ! empty($ref))
$productstatic->type=$value['type']; $productstatic->type=$value['type'];
$productstatic->label=$value['label']; $productstatic->label=$value['label'];
$class=($class=='impair')?'pair':'impair';
print '<tr class="'.$class.'">';
if ($value['level'] <= 1) if ($value['level'] <= 1)
{ {
$class=($class=='impair')?'pair':'impair';
print '<tr class="'.$class.'">';
$notdefined=0; $notdefined=0;
$productstatic->ref=$value['ref']; $productstatic->ref=$value['ref'];
$nb_of_subproduct = $value['nb']; $nb_of_subproduct = $value['nb'];
@ -312,9 +350,17 @@ if ($id > 0 || ! empty($ref))
print '<td>'.$nb_of_subproduct.'</td>'; print '<td>'.$nb_of_subproduct.'</td>';
print '<td>'.($value['incdec']==1?'x':'' ).'</td>'; print '<td>'.($value['incdec']==1?'x':'' ).'</td>';
} }
print '</tr>'."\n";
} }
else else // By default, we do not show this. It makes screen very difficult to understand
{ {
$hide='';
if (empty($conf->global->PRODUCT_SHOW_SUB_SUB_PRODUCTS)) $hide=' hideobject';
$class=($class=='impair')?'pair':'impair';
print '<tr class="'.$class.$hide.'" id="sub-'.$value['id_parent'].'">';
//$productstatic->ref=$value['label']; //$productstatic->ref=$value['label'];
$productstatic->ref=$value['ref']; $productstatic->ref=$value['ref'];
print '<td>'; print '<td>';
@ -328,8 +374,9 @@ if ($id > 0 || ! empty($ref))
if (! empty($conf->stock->enabled)) print '<td></td>'; // Real stock if (! empty($conf->stock->enabled)) print '<td></td>'; // Real stock
print '<td align="center">'.$value['nb'].'</td>'; print '<td align="center">'.$value['nb'].'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'."\n";
} }
print '</tr>';
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="liste_total"></td>'; print '<td class="liste_total"></td>';
@ -348,19 +395,13 @@ if ($id > 0 || ! empty($ref))
// Stock // Stock
if (! empty($conf->stock->enabled)) print '<td class="liste_total" align="right">&nbsp;</td>'; if (! empty($conf->stock->enabled)) print '<td class="liste_total" align="right">&nbsp;</td>';
print '<td align="center">'; print '<td align="right" colspan="2">';
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer)
{ {
print '<input type="submit" class="button" value="'.$langs->trans('Save').'">'; print '<input type="submit" class="button" value="'.$langs->trans('Save').'">';
} }
print '</td>'; print '</td>';
print '<td align="center">'; print '</tr>'."\n";
if ($user->rights->produit->creer || $user->rights->service->creer)
{
print '<input type="submit" class="button" value="'.$langs->trans('Save').'">';
}
print '</td>';
print '</tr>';
print '</table>'; print '</table>';
/*if($user->rights->produit->creer || $user->rights->service->creer) { /*if($user->rights->produit->creer || $user->rights->service->creer) {
@ -368,39 +409,8 @@ if ($id > 0 || ! empty($ref))
}*/ }*/
print '</form>'; print '</form>';
print '</td></tr>';
} }
// Number of parent virtual products
print '<tr class="pair"><td>'.$langs->trans("ParentProductsNumber").'</td><td>';
print $form->textwithpicto(count($prodsfather), $langs->trans('IfZeroItIsNotUsedByVirtualProduct'));
print '</td></tr>';
if (count($prodsfather) > 0)
{
print '<tr><td colspan="2">';
print $langs->trans("ProductParentList").'<br>';
print '<table class="nobordernopadding">';
foreach($prodsfather as $value)
{
$idprod= $value["id"];
$productstatic->id=$idprod;// $value["id"];
$productstatic->type=$value["fk_product_type"];
$productstatic->ref=$value['label'];
print '<tr>';
print '<td>'.$productstatic->getNomUrl(1,'composition').'</td>';;
print '</tr>';
}
print '</table>';
print '</td></tr>';
}
print '</table>';
dol_fiche_end();
// Form with product to add // Form with product to add
if ((empty($action) || $action == 'view' || $action == 'edit' || $action == 'search' || $action == 're-edit') && ($user->rights->produit->creer || $user->rights->service->creer)) if ((empty($action) || $action == 'view' || $action == 'edit' || $action == 'search' || $action == 're-edit') && ($user->rights->produit->creer || $user->rights->service->creer))
{ {
@ -500,11 +510,11 @@ if ($id > 0 || ! empty($ref))
print '<td>'.$labeltoshow.'</td>'; print '<td>'.$labeltoshow.'</td>';
if($product->is_sousproduit($id, $objp->rowid)) if($object->is_sousproduit($id, $objp->rowid))
{ {
//$addchecked = ' checked="checked"'; //$addchecked = ' checked="checked"';
$qty=$product->is_sousproduit_qty; $qty=$object->is_sousproduit_qty;
$incdec=$product->is_sousproduit_incdec; $incdec=$object->is_sousproduit_incdec;
} }
else else
{ {