37 global $db, $langs, $conf, $user;
38 $langs->load(
"products");
40 $label = $langs->trans(
'Product');
41 if ($object->isService()) $label = $langs->trans(
'Service');
46 $head[$h][0] = DOL_URL_ROOT.
"/product/card.php?id=".$object->id;
47 $head[$h][1] = $label;
48 $head[$h][2] =
'card';
51 if (!empty($object->status))
53 $head[$h][0] = DOL_URL_ROOT.
"/product/price.php?id=".$object->id;
54 $head[$h][1] = $langs->trans(
"SellingPrices");
55 $head[$h][2] =
'price';
59 if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status)))
61 if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire)
62 || (!empty($conf->margin->enabled) && $user->rights->margin->liretous)
65 $head[$h][0] = DOL_URL_ROOT.
"/product/fournisseurs.php?id=".$object->id;
66 $head[$h][1] = $langs->trans(
"BuyingPrices");
67 $head[$h][2] =
'suppliers';
73 if (!empty($conf->global->MAIN_MULTILANGS))
75 $head[$h][0] = DOL_URL_ROOT.
"/product/traduction.php?id=".$object->id;
76 $head[$h][1] = $langs->trans(
"Translation");
77 $head[$h][2] =
'translation';
82 if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
84 $head[$h][0] = DOL_URL_ROOT.
"/product/composition/card.php?id=".$object->id;
85 $head[$h][1] = $langs->trans(
'AssociatedProducts');
87 $nbFatherAndChild = $object->hasFatherOrChild();
88 if ($nbFatherAndChild > 0) $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbFatherAndChild.
'</span>';
89 $head[$h][2] =
'subproduct';
93 if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
96 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
100 if ($prodcomb->fetchByFkProductChild($object->id) <= 0)
102 $head[$h][0] = DOL_URL_ROOT.
"/variants/combinations.php?id=".$object->id;
103 $head[$h][1] = $langs->trans(
'ProductCombinations');
104 $head[$h][2] =
'combinations';
105 $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
106 if ($nbVariant > 0) $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbVariant.
'</span>';
112 if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
114 if (!empty($conf->stock->enabled) && $user->rights->stock->lire)
116 $head[$h][0] = DOL_URL_ROOT.
"/product/stock/product.php?id=".$object->id;
117 $head[$h][1] = $langs->trans(
"Stock");
118 $head[$h][2] =
'stock';
124 if (!empty($conf->resource->enabled))
126 if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS))
128 $head[$h][0] = DOL_URL_ROOT.
'/resource/element_resource.php?element=product&ref='.$object->ref;
129 $head[$h][1] = $langs->trans(
"Resources");
130 $head[$h][2] =
'resources';
133 if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES))
135 $head[$h][0] = DOL_URL_ROOT.
'/resource/element_resource.php?element=service&ref='.$object->ref;
136 $head[$h][1] = $langs->trans(
"Resources");
137 $head[$h][2] =
'resources';
142 $head[$h][0] = DOL_URL_ROOT.
"/product/stats/facture.php?showmessage=1&id=".$object->id;
143 $head[$h][1] = $langs->trans(
'Referers');
144 $head[$h][2] =
'referers';
147 $head[$h][0] = DOL_URL_ROOT.
"/product/stats/card.php?id=".$object->id;
148 $head[$h][1] = $langs->trans(
'Statistics');
149 $head[$h][2] =
'stats';
159 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
162 if (!empty($object->note_private)) $nbNote++;
163 if (!empty($object->note_public)) $nbNote++;
164 $head[$h][0] = DOL_URL_ROOT.
'/product/note.php?id='.$object->id;
165 $head[$h][1] = $langs->trans(
'Notes');
166 if ($nbNote > 0) $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
167 $head[$h][2] =
'note';
172 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
173 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
176 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
177 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
178 if (!empty($conf->product->enabled) && ($object->type ==
Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].
'/'.
get_exdir($object->id, 2, 0, 0, $object,
'product').$object->id.
'/photos';
179 if (!empty($conf->service->enabled) && ($object->type ==
Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].
'/'.
get_exdir($object->id, 2, 0, 0, $object,
'product').$object->id.
'/photos';
180 $nbFiles += count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
182 $nbLinks =
Link::count($db, $object->element, $object->id);
183 $head[$h][0] = DOL_URL_ROOT.
'/product/document.php?id='.$object->id;
184 $head[$h][1] = $langs->trans(
'Documents');
185 if (($nbFiles + $nbLinks) > 0) $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
186 $head[$h][2] =
'documents';
192 $head[$h][0] = DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id;
193 $head[$h][1] = $langs->trans(
"Events");
194 if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
197 $head[$h][1] .= $langs->trans(
"Agenda");
199 $head[$h][2] =
'agenda';
213 global $db, $langs, $conf, $user;
216 $langs->loadLangs(array(
"products",
"productbatch"));
221 $head[$h][0] = DOL_URL_ROOT.
"/product/stock/productlot_card.php?id=".$object->id;
222 $head[$h][1] = $langs->trans(
"Lot");
223 $head[$h][2] =
'card';
227 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
228 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
229 $upload_dir = $conf->productbatch->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->ref);
230 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
231 $nbLinks =
Link::count($db, $object->element, $object->id);
232 $head[$h][0] = DOL_URL_ROOT.
"/product/stock/productlot_document.php?id=".$object->id;
233 $head[$h][1] = $langs->trans(
"Documents");
234 if (($nbFiles + $nbLinks) > 0) $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
235 $head[$h][2] =
'documents';
266 global $langs, $conf, $user;
271 $head[$h][0] = DOL_URL_ROOT.
"/product/admin/product.php";
272 $head[$h][1] = $langs->trans(
'Parameters');
273 $head[$h][2] =
'general';
276 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
279 0 => DOL_URL_ROOT.
"/product/admin/price_rules.php",
280 1 => $langs->trans(
'MultipriceRules'),
292 $head[$h][0] = DOL_URL_ROOT.
'/product/admin/product_extrafields.php';
293 $head[$h][1] = $langs->trans(
"ExtraFields");
294 $head[$h][2] =
'attributes';
297 $head[$h][0] = DOL_URL_ROOT.
'/product/admin/product_supplier_extrafields.php';
298 $head[$h][1] = $langs->trans(
"ProductSupplierExtraFields");
299 $head[$h][2] =
'supplierAttributes';
316 global $langs, $conf, $user;
327 $head[$h][0] = DOL_URL_ROOT.
'/product/admin/product_lot_extrafields.php';
328 $head[$h][1] = $langs->trans(
"ExtraFields");
329 $head[$h][2] =
'attributes';
348 global $conf, $langs, $user, $db;
349 $form =
new Form($db);
353 print '<tr class="liste_titre">';
354 print '<td class="left" width="25%">'.$langs->trans(
"Referers").
'</td>';
355 print '<td class="right" width="25%">'.$langs->trans(
"NbOfThirdParties").
'</td>';
356 print '<td class="right" width="25%">'.$langs->trans(
"NbOfObjectReferers").
'</td>';
357 print '<td class="right" width="25%">'.$langs->trans(
"TotalQuantity").
'</td>';
361 if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
364 $ret = $product->load_stats_propale($socid);
366 $langs->load(
"propal");
368 print '<a href="propal.php?id='.$product->id.
'">'.
img_object(
'',
'propal',
'class="paddingright"').$langs->trans(
"Proposals").
'</a>';
369 print '</td><td class="right">';
370 print $product->stats_propale[
'customers'];
371 print '</td><td class="right">';
372 print $product->stats_propale[
'nb'];
373 print '</td><td class="right">';
374 print $product->stats_propale[
'qty'];
379 if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
382 $ret = $product->load_stats_proposal_supplier($socid);
384 $langs->load(
"supplier_proposal");
386 print '<a href="supplier_proposal.php?id='.$product->id.
'">'.
img_object(
'',
'supplier_proposal',
'class="paddingright"').$langs->trans(
"SupplierProposals").
'</a>';
387 print '</td><td class="right">';
388 print $product->stats_proposal_supplier[
'suppliers'];
389 print '</td><td class="right">';
390 print $product->stats_proposal_supplier[
'nb'];
391 print '</td><td class="right">';
392 print $product->stats_proposal_supplier[
'qty'];
397 if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
400 $ret = $product->load_stats_commande($socid);
402 $langs->load(
"orders");
404 print '<a href="commande.php?id='.$product->id.
'">'.
img_object(
'',
'order',
'class="paddingright"').$langs->trans(
"CustomersOrders").
'</a>';
405 print '</td><td class="right">';
406 print $product->stats_commande[
'customers'];
407 print '</td><td class="right">';
408 print $product->stats_commande[
'nb'];
409 print '</td><td class="right">';
410 print $product->stats_commande[
'qty'];
415 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire)
418 $ret = $product->load_stats_commande_fournisseur($socid);
420 $langs->load(
"orders");
422 print '<a href="commande_fournisseur.php?id='.$product->id.
'">'.
img_object(
'',
'supplier_order',
'class="paddingright"').$langs->trans(
"SuppliersOrders").
'</a>';
423 print '</td><td class="right">';
424 print $product->stats_commande_fournisseur[
'suppliers'];
425 print '</td><td class="right">';
426 print $product->stats_commande_fournisseur[
'nb'];
427 print '</td><td class="right">';
428 print $product->stats_commande_fournisseur[
'qty'];
433 if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
436 $ret = $product->load_stats_facture($socid);
438 $langs->load(
"bills");
440 print '<a href="facture.php?id='.$product->id.
'">'.
img_object(
'',
'bill').
' '.$langs->trans(
"CustomersInvoices").
'</a>';
441 print '</td><td class="right">';
442 print $product->stats_facture[
'customers'];
443 print '</td><td class="right">';
444 print $product->stats_facture[
'nb'];
445 print '</td><td class="right">';
446 print $product->stats_facture[
'qty'];
451 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire)
454 $ret = $product->load_stats_facture_fournisseur($socid);
456 $langs->load(
"bills");
458 print '<a href="facture_fournisseur.php?id='.$product->id.
'">'.
img_object(
'',
'supplier_invoice',
'class="paddingright"').$langs->trans(
"SuppliersInvoices").
'</a>';
459 print '</td><td class="right">';
460 print $product->stats_facture_fournisseur[
'suppliers'];
461 print '</td><td class="right">';
462 print $product->stats_facture_fournisseur[
'nb'];
463 print '</td><td class="right">';
464 print $product->stats_facture_fournisseur[
'qty'];
470 if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
473 $ret = $product->load_stats_contrat($socid);
475 $langs->load(
"contracts");
477 print '<a href="contrat.php?id='.$product->id.
'">'.
img_object(
'',
'contract',
'class="paddingright"').$langs->trans(
"Contracts").
'</a>';
478 print '</td><td class="right">';
479 print $product->stats_contrat[
'customers'];
480 print '</td><td class="right">';
481 print $product->stats_contrat[
'nb'];
482 print '</td><td class="right">';
483 print $product->stats_contrat[
'qty'];
489 if (!empty($conf->bom->enabled) && $user->rights->bom->read)
492 $ret = $product->load_stats_bom($socid);
499 print '<a href="bom.php?id='.$product->id.
'">'.
img_object(
'',
'bom',
'class="paddingright"').$langs->trans(
"BOM").
'</a>';
500 print '</td><td class="right">';
502 print '</td><td class="right">';
503 print $form->textwithpicto($product->stats_bom[
'nb_toconsume'], $langs->trans(
"RowMaterial"));
504 print $form->textwithpicto($product->stats_bom[
'nb_toproduce'], $langs->trans(
"Finished"));
505 print '</td><td class="right">';
506 print $form->textwithpicto($product->stats_bom[
'qty_toconsume'], $langs->trans(
"RowMaterial"));
507 print $form->textwithpicto($product->stats_bom[
'qty_toproduce'], $langs->trans(
"Finished"));
513 if (!empty($conf->mrp->enabled) && $user->rights->mrp->read)
516 $ret = $product->load_stats_mo($socid);
522 print '<a href="mo.php?id='.$product->id.
'">'.
img_object(
'',
'mrp',
'class="paddingright"').$langs->trans(
"MO").
'</a>';
523 print '</td><td class="right">';
524 print $form->textwithpicto($product->stats_mo[
'customers_toconsume'], $langs->trans(
"ToConsume"));
525 print $form->textwithpicto($product->stats_mo[
'customers_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
526 print $form->textwithpicto($product->stats_mo[
'customers_toproduce'], $langs->trans(
"QtyToProduce"));
527 print $form->textwithpicto($product->stats_mo[
'customers_produced'], $langs->trans(
"QtyAlreadyProduced"));
528 print '</td><td class="right">';
529 print $form->textwithpicto($product->stats_mo[
'nb_toconsume'], $langs->trans(
"ToConsume"));
530 print $form->textwithpicto($product->stats_mo[
'nb_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
531 print $form->textwithpicto($product->stats_mo[
'nb_toproduce'], $langs->trans(
"QtyToProduce"));
532 print $form->textwithpicto($product->stats_mo[
'nb_produced'], $langs->trans(
"QtyAlreadyProduced"));
533 print '</td><td class="right">';
534 print $form->textwithpicto($product->stats_mo[
'qty_toconsume'], $langs->trans(
"ToConsume"));
535 print $form->textwithpicto($product->stats_mo[
'qty_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
536 print $form->textwithpicto($product->stats_mo[
'qty_toproduce'], $langs->trans(
"QtyToProduce"));
537 print $form->textwithpicto($product->stats_mo[
'qty_produced'], $langs->trans(
"QtyAlreadyProduced"));
557 function measuring_units_string($scale =
'', $measuring_style =
'', $unit = 0, $use_short_label = 0, $outputlangs = null)
559 return measuringUnitString($unit, $measuring_style, $scale, $use_short_label, $outputlangs);
573 function measuringUnitString($unit, $measuring_style =
'', $scale =
'', $use_short_label = 0, $outputlangs = null)
576 global $measuring_unit_cache;
578 if (empty($outputlangs)) {
579 $outputlangs = $langs;
582 if (empty($measuring_unit_cache[$unit.
'_'.$measuring_style.
'_'.$scale.
'_'.$use_short_label]))
584 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
585 $measuringUnits =
new CUnits($db);
587 if ($measuring_style ==
'' && $scale ==
'')
589 $arrayforfilter = array(
593 } elseif ($scale !==
'')
595 $arrayforfilter = array(
597 't.unit_type' => $measuring_style,
601 $arrayforfilter = array(
603 't.unit_type' => $measuring_style,
607 $result = $measuringUnits->fetchAll(
'',
'', 0, 0, $arrayforfilter);
612 if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
613 if ($use_short_label) $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
614 else $labeltoreturn = $outputlangs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
618 $measuring_unit_cache[$unit.
'_'.$measuring_style.
'_'.$scale.
'_'.$use_short_label] = $labeltoreturn;
619 return $labeltoreturn;
622 return $measuring_unit_cache[$unit.
'_'.$measuring_style.
'_'.$scale.
'_'.$use_short_label];
635 $measuring_units = array();
636 $measuring_units[0] = 0;
637 $measuring_units[-1] = -2;
638 $measuring_units[-2] = -4;
639 $measuring_units[-3] = -6;
640 $measuring_units[98] = 98;
641 $measuring_units[99] = 99;
642 return $measuring_units[$unit];
655 $measuring_units = array();
656 $measuring_units[0] = 0;
657 $measuring_units[-1] = -3;
658 $measuring_units[-2] = -6;
659 $measuring_units[-3] = -9;
660 $measuring_units[98] = 88;
661 $measuring_units[99] = 89;
662 return $measuring_units[$unit];
Class of dictionary type of thirdparty (used by imports)
product_lot_admin_prepare_head()
Return array head with list of tabs to view object informations.
productlot_prepare_head($object)
Prepare array with list of tabs.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
show_stats_for_company($product, $socid)
Show stats for company.
measuring_units_squared($unit)
Transform a given unit scale into the square of that unit, if known.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Class ProductCombination Used to represent a product combination.
static count($db, $objecttype, $objectid)
Return nb of links.
print
Draft customers invoices.
measuring_units_string($scale= '', $measuring_style= '', $unit=0, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
measuring_units_cubed($unit)
Transform a given unit scale into the cube of that unit, if known.
product_admin_prepare_head()
Return array head with list of tabs to view object informations.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.