37 global $db, $langs, $conf, $user;
38 $langs->load(
"products");
40 $label = $langs->trans(
'Product');
41 if ($object->isService()) {
42 $label = $langs->trans(
'Service');
48 $head[$h][0] = DOL_URL_ROOT.
"/product/card.php?id=".$object->id;
49 $head[$h][1] = $label;
50 $head[$h][2] =
'card';
53 if (!empty($object->status)) {
54 $head[$h][0] = DOL_URL_ROOT.
"/product/price.php?id=".$object->id;
55 $head[$h][1] = $langs->trans(
"SellingPrices");
56 $head[$h][2] =
'price';
60 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->margins->liretous)
64 $head[$h][0] = DOL_URL_ROOT.
"/product/fournisseurs.php?id=".$object->id;
65 $head[$h][1] = $langs->trans(
"BuyingPrices");
66 $head[$h][2] =
'suppliers';
72 if (!empty($conf->global->MAIN_MULTILANGS)) {
73 $head[$h][0] = DOL_URL_ROOT.
"/product/traduction.php?id=".$object->id;
74 $head[$h][1] = $langs->trans(
"Translation");
75 $head[$h][2] =
'translation';
80 if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
81 $head[$h][0] = DOL_URL_ROOT.
"/product/composition/card.php?id=".$object->id;
82 $head[$h][1] = $langs->trans(
'AssociatedProducts');
84 $nbFatherAndChild = $object->hasFatherOrChild();
85 if ($nbFatherAndChild > 0) {
86 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbFatherAndChild.
'</span>';
88 $head[$h][2] =
'subproduct';
92 if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
95 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
99 if ($prodcomb->fetchByFkProductChild($object->id) <= 0) {
100 $head[$h][0] = DOL_URL_ROOT.
"/variants/combinations.php?id=".$object->id;
101 $head[$h][1] = $langs->trans(
'ProductCombinations');
102 $head[$h][2] =
'combinations';
103 $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
104 if ($nbVariant > 0) {
105 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbVariant.
'</span>';
112 if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
113 if (!empty($conf->stock->enabled) && $user->rights->stock->lire) {
114 $head[$h][0] = DOL_URL_ROOT.
"/product/stock/product.php?id=".$object->id;
115 $head[$h][1] = $langs->trans(
"Stock");
116 $head[$h][2] =
'stock';
122 if (!empty($conf->resource->enabled)) {
123 if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS)) {
124 $head[$h][0] = DOL_URL_ROOT.
'/resource/element_resource.php?element=product&ref='.$object->ref;
125 $head[$h][1] = $langs->trans(
"Resources");
126 $head[$h][2] =
'resources';
129 if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES)) {
130 $head[$h][0] = DOL_URL_ROOT.
'/resource/element_resource.php?element=service&ref='.$object->ref;
131 $head[$h][1] = $langs->trans(
"Resources");
132 $head[$h][2] =
'resources';
137 $head[$h][0] = DOL_URL_ROOT.
"/product/stats/facture.php?showmessage=1&id=".$object->id;
138 $head[$h][1] = $langs->trans(
'Referers');
139 $head[$h][2] =
'referers';
142 $head[$h][0] = DOL_URL_ROOT.
"/product/stats/card.php?id=".$object->id;
143 $head[$h][1] = $langs->trans(
'Statistics');
144 $head[$h][2] =
'stats';
154 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
156 if (!empty($object->note_private)) {
159 if (!empty($object->note_public)) {
162 $head[$h][0] = DOL_URL_ROOT.
'/product/note.php?id='.$object->id;
163 $head[$h][1] = $langs->trans(
'Notes');
165 $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';
175 $upload_dir = $conf->product->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->ref);
178 $upload_dir = $conf->service->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->ref);
180 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
181 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
183 $upload_dir = $conf->product->multidir_output[$object->entity].
'/'.
get_exdir($object->id, 2, 0, 0, $object,
'product').$object->id.
'/photos';
186 $upload_dir = $conf->service->multidir_output[$object->entity].
'/'.
get_exdir($object->id, 2, 0, 0, $object,
'product').$object->id.
'/photos';
188 $nbFiles += count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
190 $nbLinks =
Link::count($db, $object->element, $object->id);
191 $head[$h][0] = DOL_URL_ROOT.
'/product/document.php?id='.$object->id;
192 $head[$h][1] = $langs->trans(
'Documents');
193 if (($nbFiles + $nbLinks) > 0) {
194 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
196 $head[$h][2] =
'documents';
202 $head[$h][0] = DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id;
203 $head[$h][1] = $langs->trans(
"Events");
204 if (
isModEnabled(
'agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
206 $head[$h][1] .= $langs->trans(
"Agenda");
208 $head[$h][2] =
'agenda';
222 global $db, $langs, $conf, $user;
225 $langs->loadLangs(array(
"products",
"productbatch"));
230 $head[$h][0] = DOL_URL_ROOT.
"/product/stock/productlot_card.php?id=".$object->id;
231 $head[$h][1] = $langs->trans(
"Lot");
232 $head[$h][2] =
'card';
236 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
237 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
238 $upload_dir = $conf->productbatch->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->ref);
239 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
240 $nbLinks =
Link::count($db, $object->element, $object->id);
241 $head[$h][0] = DOL_URL_ROOT.
"/product/stock/productlot_document.php?id=".$object->id;
242 $head[$h][1] = $langs->trans(
"Documents");
243 if (($nbFiles + $nbLinks) > 0) {
244 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
246 $head[$h][2] =
'documents';
277 global $langs, $conf, $user;
282 $head[$h][0] = DOL_URL_ROOT.
"/product/admin/product.php";
283 $head[$h][1] = $langs->trans(
'Parameters');
284 $head[$h][2] =
'general';
287 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) {
289 0 => DOL_URL_ROOT.
"/product/admin/price_rules.php",
290 1 => $langs->trans(
'MultipriceRules'),
302 $head[$h][0] = DOL_URL_ROOT.
'/product/admin/product_extrafields.php';
303 $head[$h][1] = $langs->trans(
"ExtraFields");
304 $head[$h][2] =
'attributes';
307 $head[$h][0] = DOL_URL_ROOT.
'/product/admin/product_supplier_extrafields.php';
308 $head[$h][1] = $langs->trans(
"ProductSupplierExtraFields");
309 $head[$h][2] =
'supplierAttributes';
326 global $langs, $conf, $user;
331 $head[$h][0] = DOL_URL_ROOT.
"/product/admin/product_lot.php";
332 $head[$h][1] = $langs->trans(
'Parameters');
333 $head[$h][2] =
'settings';
342 $head[$h][0] = DOL_URL_ROOT.
'/product/admin/product_lot_extrafields.php';
343 $head[$h][1] = $langs->trans(
"ExtraFields");
344 $head[$h][2] =
'attributes';
363 global $conf, $langs, $user, $db, $hookmanager;
369 print
'<tr class="liste_titre">';
370 print
'<td class="left" width="25%">'.$langs->trans(
"Referers").
'</td>';
371 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfThirdParties").
'</td>';
372 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfObjectReferers").
'</td>';
373 print
'<td class="right" width="25%">'.$langs->trans(
"TotalQuantity").
'</td>';
377 if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
379 $ret = $product->load_stats_propale($socid);
383 $langs->load(
"propal");
385 print
'<a href="propal.php?id='.$product->id.
'">'.
img_object(
'',
'propal',
'class="pictofixedwidth"').$langs->trans(
"Proposals").
'</a>';
386 print
'</td><td class="right">';
387 print $product->stats_propale[
'customers'];
388 print
'</td><td class="right">';
389 print $product->stats_propale[
'nb'];
390 print
'</td><td class="right">';
391 print $product->stats_propale[
'qty'];
396 if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
398 $ret = $product->load_stats_proposal_supplier($socid);
402 $langs->load(
"supplier_proposal");
404 print
'<a href="supplier_proposal.php?id='.$product->id.
'">'.
img_object(
'',
'supplier_proposal',
'class="pictofixedwidth"').$langs->trans(
"SupplierProposals").
'</a>';
405 print
'</td><td class="right">';
406 print $product->stats_proposal_supplier[
'suppliers'];
407 print
'</td><td class="right">';
408 print $product->stats_proposal_supplier[
'nb'];
409 print
'</td><td class="right">';
410 print $product->stats_proposal_supplier[
'qty'];
415 if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
417 $ret = $product->load_stats_commande($socid);
421 $langs->load(
"orders");
423 print
'<a href="commande.php?id='.$product->id.
'">'.
img_object(
'',
'order',
'class="pictofixedwidth"').$langs->trans(
"CustomersOrders").
'</a>';
424 print
'</td><td class="right">';
425 print $product->stats_commande[
'customers'];
426 print
'</td><td class="right">';
427 print $product->stats_commande[
'nb'];
428 print
'</td><td class="right">';
429 print $product->stats_commande[
'qty'];
434 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) {
436 $ret = $product->load_stats_commande_fournisseur($socid);
440 $langs->load(
"orders");
442 print
'<a href="commande_fournisseur.php?id='.$product->id.
'">'.
img_object(
'',
'supplier_order',
'class="pictofixedwidth"').$langs->trans(
"SuppliersOrders").
'</a>';
443 print
'</td><td class="right">';
444 print $product->stats_commande_fournisseur[
'suppliers'];
445 print
'</td><td class="right">';
446 print $product->stats_commande_fournisseur[
'nb'];
447 print
'</td><td class="right">';
448 print $product->stats_commande_fournisseur[
'qty'];
453 if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
455 $ret = $product->load_stats_facture($socid);
459 $langs->load(
"bills");
461 print
'<a href="facture.php?id='.$product->id.
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CustomersInvoices").
'</a>';
462 print
'</td><td class="right">';
463 print $product->stats_facture[
'customers'];
464 print
'</td><td class="right">';
465 print $product->stats_facture[
'nb'];
466 print
'</td><td class="right">';
467 print $product->stats_facture[
'qty'];
472 if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
474 $ret = $product->load_stats_facturerec($socid);
478 $langs->load(
"bills");
480 print
'<a href="facturerec.php?id='.$product->id.
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"RecurringInvoiceTemplate").
'</a>';
481 print
'</td><td class="right">';
482 print $product->stats_facture[
'customers'];
483 print
'</td><td class="right">';
484 print $product->stats_facturerec[
'nb'];
485 print
'</td><td class="right">';
486 print $product->stats_facturerec[
'qty'];
491 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) {
493 $ret = $product->load_stats_facture_fournisseur($socid);
497 $langs->load(
"bills");
499 print
'<a href="facture_fournisseur.php?id='.$product->id.
'">'.
img_object(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"SuppliersInvoices").
'</a>';
500 print
'</td><td class="right">';
501 print $product->stats_facture_fournisseur[
'suppliers'];
502 print
'</td><td class="right">';
503 print $product->stats_facture_fournisseur[
'nb'];
504 print
'</td><td class="right">';
505 print $product->stats_facture_fournisseur[
'qty'];
511 if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
513 $ret = $product->load_stats_contrat($socid);
517 $langs->load(
"contracts");
519 print
'<a href="contrat.php?id='.$product->id.
'">'.
img_object(
'',
'contract',
'class="pictofixedwidth"').$langs->trans(
"Contracts").
'</a>';
520 print
'</td><td class="right">';
521 print $product->stats_contrat[
'customers'];
522 print
'</td><td class="right">';
523 print $product->stats_contrat[
'nb'];
524 print
'</td><td class="right">';
525 print $product->stats_contrat[
'qty'];
531 if (!empty($conf->bom->enabled) && $user->rights->bom->read) {
533 $ret = $product->load_stats_bom($socid);
540 print
'<a href="bom.php?id='.$product->id.
'">'.
img_object(
'',
'bom',
'class="pictofixedwidth"').$langs->trans(
"BOM").
'</a>';
541 print
'</td><td class="right">';
543 print
'</td><td class="right">';
544 print
$form->textwithpicto($product->stats_bom[
'nb_toconsume'], $langs->trans(
"RowMaterial"));
545 print
$form->textwithpicto($product->stats_bom[
'nb_toproduce'], $langs->trans(
"Finished"));
546 print
'</td><td class="right">';
547 print
$form->textwithpicto($product->stats_bom[
'qty_toconsume'], $langs->trans(
"RowMaterial"));
548 print
$form->textwithpicto($product->stats_bom[
'qty_toproduce'], $langs->trans(
"Finished"));
554 if (!empty($conf->mrp->enabled) && $user->rights->mrp->read) {
556 $ret = $product->load_stats_mo($socid);
562 print
'<a href="mo.php?id='.$product->id.
'">'.
img_object(
'',
'mrp',
'class="pictofixedwidth"').$langs->trans(
"MO").
'</a>';
563 print
'</td><td class="right">';
564 print
$form->textwithpicto($product->stats_mo[
'customers_toconsume'], $langs->trans(
"ToConsume"));
565 print
$form->textwithpicto($product->stats_mo[
'customers_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
566 print
$form->textwithpicto($product->stats_mo[
'customers_toproduce'], $langs->trans(
"QtyToProduce"));
567 print
$form->textwithpicto($product->stats_mo[
'customers_produced'], $langs->trans(
"QtyAlreadyProduced"));
568 print
'</td><td class="right">';
569 print
$form->textwithpicto($product->stats_mo[
'nb_toconsume'], $langs->trans(
"ToConsume"));
570 print
$form->textwithpicto($product->stats_mo[
'nb_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
571 print
$form->textwithpicto($product->stats_mo[
'nb_toproduce'], $langs->trans(
"QtyToProduce"));
572 print
$form->textwithpicto($product->stats_mo[
'nb_produced'], $langs->trans(
"QtyAlreadyProduced"));
573 print
'</td><td class="right">';
574 print
$form->textwithpicto($product->stats_mo[
'qty_toconsume'], $langs->trans(
"ToConsume"));
575 print
$form->textwithpicto($product->stats_mo[
'qty_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
576 print
$form->textwithpicto($product->stats_mo[
'qty_toproduce'], $langs->trans(
"QtyToProduce"));
577 print
$form->textwithpicto($product->stats_mo[
'qty_produced'], $langs->trans(
"QtyAlreadyProduced"));
581 $parameters = array(
'socid'=>$socid);
582 $reshook = $hookmanager->executeHooks(
'addMoreProductStat', $parameters, $product, $nblines);
583 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
585 print $hookmanager->resPrint;
603 function measuring_units_string($scale =
'', $measuring_style =
'', $unit = 0, $use_short_label = 0, $outputlangs =
null)
605 return measuringUnitString($unit, $measuring_style, $scale, $use_short_label, $outputlangs);
619 function measuringUnitString($unit, $measuring_style =
'', $scale =
'', $use_short_label = 0, $outputlangs =
null)
622 global $measuring_unit_cache;
624 if (empty($outputlangs)) {
625 $outputlangs = $langs;
628 if (empty($measuring_unit_cache[$unit.
'_'.$measuring_style.
'_'.$scale.
'_'.$use_short_label])) {
629 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
630 $measuringUnits =
new CUnits($db);
632 if ($measuring_style ==
'' && $scale ==
'') {
633 $arrayforfilter = array(
637 } elseif ($scale !==
'') {
638 $arrayforfilter = array(
640 't.unit_type' => $measuring_style,
644 $arrayforfilter = array(
646 't.unit_type' => $measuring_style,
650 $result = $measuringUnits->fetchAll(
'',
'', 0, 0, $arrayforfilter);
655 if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
656 if ($use_short_label) {
657 $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
659 $labeltoreturn = $outputlangs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
664 $measuring_unit_cache[$unit.
'_'.$measuring_style.
'_'.$scale.
'_'.$use_short_label] = $labeltoreturn;
665 return $labeltoreturn;
668 return $measuring_unit_cache[$unit.
'_'.$measuring_style.
'_'.$scale.
'_'.$use_short_label];
681 $measuring_units = array();
682 $measuring_units[0] = 0;
683 $measuring_units[-1] = -2;
684 $measuring_units[-2] = -4;
685 $measuring_units[-3] = -6;
686 $measuring_units[98] = 98;
687 $measuring_units[99] = 99;
688 return $measuring_units[$unit];
701 $measuring_units = array();
702 $measuring_units[0] = 0;
703 $measuring_units[-1] = -3;
704 $measuring_units[-2] = -6;
705 $measuring_units[-3] = -9;
706 $measuring_units[98] = 88;
707 $measuring_units[99] = 89;
708 return $measuring_units[$unit];