43 $langs->load(
"products");
45 $label = $langs->trans(
'Product');
46 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_prices') : $user->hasRight(
'product',
'read');
47 $usercancreadsupplierprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_supplier_prices') : $user->hasRight(
'product',
'read');
50 $label = $langs->trans(
'Service');
51 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'service',
'service_advance',
'read_prices') : $user->hasRight(
'service',
'read');
52 $usercancreadsupplierprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'service',
'service_advance',
'read_supplier_prices') : $user->hasRight(
'service',
'read');
59 $head[$h][1] = $label;
60 $head[$h][2] =
'card';
64 if ($usercancreadprice) {
66 $head[$h][1] = $langs->trans(
"SellingPrices");
67 $head[$h][2] =
'price';
71 $head[$h][1] = $langs->trans(
"SellingPrices");
72 $head[$h][2] =
'price';
73 $head[$h][5] =
'disabled';
79 if ((
isModEnabled(
"supplier_proposal") ||
isModEnabled(
"supplier_order") ||
isModEnabled(
"supplier_invoice")) && ($user->hasRight(
'fournisseur',
'lire') || $user->hasRight(
'supplier_order',
'read') || $user->hasRight(
'supplier_invoice',
'read'))
80 || (
isModEnabled(
'margin') && $user->hasRight(
"margin",
"liretous"))
82 if ($usercancreadsupplierprice) {
83 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/price_suppliers.php', [
'id' =>
$object->id]);
84 $head[$h][1] = $langs->trans(
"BuyingPrices");
85 $head[$h][2] =
'suppliers';
89 $head[$h][1] = $langs->trans(
"BuyingPrices");
90 $head[$h][2] =
'suppliers';
91 $head[$h][5] =
'disabled';
99 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/traduction.php', [
'id' =>
$object->id]);
100 $head[$h][1] = $langs->trans(
"Translations");
101 $nbTranslations = !empty(
$object->multilangs) ? count(
$object->multilangs) : 0;
102 if ($nbTranslations > 0) {
103 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbTranslations.
'</span>';
105 $head[$h][2] =
'translation';
111 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/composition/card.php', [
'id' =>
$object->id]);
112 $head[$h][1] = $langs->trans(
'AssociatedProducts');
114 $nbFather =
$object->hasFatherOrChild(-1);
115 $nbChild =
$object->hasFatherOrChild(1);
116 if ($nbFather > 0 || $nbChild > 0) {
117 $head[$h][1] .=
'<span class="badge marginleftonlyshort">';
119 $head[$h][1] .= $nbFather;
121 $head[$h][1] .= ($nbFather && $nbChild) ?
'+' :
'';
123 $head[$h][1] .= $nbChild;
125 $head[$h][1] .=
'</span>';
127 $head[$h][2] =
'subproduct';
134 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
138 if ($prodcomb->fetchByFkProductChild(
$object->id) <= 0) {
139 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/variants/combinations.php', [
'id' =>
$object->id]);
140 $head[$h][1] = $langs->trans(
'ProductCombinations');
141 $head[$h][2] =
'combinations';
142 $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent(
$object->id);
143 if ($nbVariant > 0) {
144 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbVariant.
'</span>';
152 if (
isModEnabled(
'stock') && $user->hasRight(
'stock',
'lire')) {
153 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/product.php', [
'id' =>
$object->id]);
154 $head[$h][1] = $langs->trans(
"Stock");
155 $head[$h][2] =
'stock';
163 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/resource/element_resource.php', [
'element' =>
'product',
'element_id' =>
$object->id]);
164 $head[$h][1] = $langs->trans(
"Resources");
165 $head[$h][2] =
'resources';
169 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/resource/element_resource.php', [
'element' =>
'service',
'element_id' =>
$object->id]);
170 $head[$h][1] = $langs->trans(
"Resources");
171 $head[$h][2] =
'resources';
177 if (
$object->origin_type ==
'product' &&
$object->origin_id > 0) {
179 $objectsrc->fetch(
$object->origin_id);
181 $nbContact = count($objectsrc->liste_contact(-1,
'internal')) + count($objectsrc->liste_contact(-1,
'external'));
182 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/contact.php', [
'id' =>
$object->id]);
183 $head[$h][1] = $langs->trans(
"ContactsAddresses");
184 if ($nbContact > 0) {
185 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
187 $head[$h][2] =
'contact';
190 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stats/facture.php', [
'showmessage' => 1,
'id' =>
$object->id]);
191 $head[$h][1] = $langs->trans(
'Referers');
192 $head[$h][2] =
'referers';
195 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stats/index.php', [
'id' =>
$object->id]);
196 $head[$h][1] = $langs->trans(
'Statistics');
197 $head[$h][2] =
'stats';
209 if (!empty(
$object->note_private)) {
212 if (!empty(
$object->note_public)) {
216 $head[$h][1] = $langs->trans(
'Notes');
218 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
220 $head[$h][2] =
'note';
225 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
226 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
235 if ($upload_dir !==
null) {
236 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
245 if ($upload_dir !==
null) {
246 $nbFiles += count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
250 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/document.php', [
'id' =>
$object->id]);
251 $head[$h][1] = $langs->trans(
'Documents');
252 if (($nbFiles + $nbLinks) > 0) {
253 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
255 $head[$h][2] =
'documents';
259 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/messaging.php', [
'id' =>
$object->id]);
260 $head[$h][1] = $langs->trans(
"Events");
261 if (
isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
264 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
265 $cachekey =
'count_events_product_'.$object->id;
267 if (!is_null($dataretrieved)) {
268 $nbEvent = $dataretrieved;
270 $sql =
"SELECT COUNT(id) as nb";
271 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
272 $sql .=
" WHERE fk_element = ".((int)
$object->id);
273 $sql .=
" AND elementtype = 'product'";
274 $resql =
$db->query($sql);
276 $obj =
$db->fetch_object($resql);
279 dol_syslog(
'Failed to count actioncomm '.
$db->lasterror(), LOG_ERR);
285 $head[$h][1] .= $langs->trans(
"Agenda");
287 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
290 $head[$h][2] =
'agenda';
311 $langs->loadLangs(array(
"products",
"productbatch"));
316 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/productlot_card.php', [
'id' =>
$object->id]);
317 $head[$h][1] = $langs->trans(
"Lot");
318 $head[$h][2] =
'card';
321 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/expedition.php', [
'showmessage' => 1,
'id' =>
$object->id]);
322 $head[$h][1] = $langs->trans(
'Referers');
323 $head[$h][2] =
'referers';
327 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
328 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
330 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
332 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/productlot_document.php', [
'id' =>
$object->id]);
333 $head[$h][1] = $langs->trans(
"Documents");
334 if (($nbFiles + $nbLinks) > 0) {
335 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
337 $head[$h][2] =
'documents';
343 if (!empty(
$object->note_private)) {
346 if (!empty(
$object->note_public)) {
349 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/product/stock/productlot_note.php', [
'id' =>
$object->id]);
350 $head[$h][1] = $langs->trans(
'Notes');
352 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>';
354 $head[$h][2] =
'note';
386 global $langs,
$conf, $extrafields;
388 $extrafields->fetch_name_optionals_label(
'product');
389 $extrafields->fetch_name_optionals_label(
'product_lang');
390 $extrafields->fetch_name_optionals_label(
'product_price');
391 $extrafields->fetch_name_optionals_label(
'product_customer_price');
392 $extrafields->fetch_name_optionals_label(
'product_fournisseur_price');
397 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/product/admin/product.php");
398 $head[$h][1] = $langs->trans(
'Parameters');
399 $head[$h][2] =
'general';
404 0 =>
dolBuildUrl(DOL_URL_ROOT.
"/product/admin/price_rules.php"),
405 1 => $langs->trans(
'MultipriceRules'),
417 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_extrafields.php');
418 $head[$h][1] = $langs->trans(
"ExtraFields");
419 $nbExtrafields = isset($extrafields->attributes[
'product'][
'count']) ? $extrafields->attributes[
'product'][
'count'] : 0;
420 if ($nbExtrafields > 0) {
421 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
423 $head[$h][2] =
'attributes';
428 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_lang_extrafields.php');
429 $head[$h][1] = $langs->trans(
"TranslationsExtrafields");
430 $nbExtrafields = isset($extrafields->attributes[
'product_lang'][
'count']) ? $extrafields->attributes[
'product_lang'][
'count'] : 0;
431 if ($nbExtrafields > 0) {
432 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
434 $head[$h][2] =
'translationAttributes';
440 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_price_extrafields.php');
441 $head[$h][1] = $langs->trans(
"ProductLevelExtraFields");
442 $nbExtrafields = isset($extrafields->attributes[
'product_price'][
'count']) ? $extrafields->attributes[
'product_price'][
'count'] : 0;
443 if ($nbExtrafields > 0) {
444 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
446 $head[$h][2] =
'levelAttributes';
452 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_customer_extrafields.php');
453 $head[$h][1] = $langs->trans(
"ProductCustomerExtraFields");
454 $nbExtrafields = isset($extrafields->attributes[
'product_customer_price'][
'count']) ? $extrafields->attributes[
'product_customer_price'][
'count'] : 0;
455 if ($nbExtrafields > 0) {
456 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
458 $head[$h][2] =
'customerAttributes';
463 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_supplier_extrafields.php');
464 $head[$h][1] = $langs->trans(
"ProductSupplierExtraFields");
465 $nbExtrafields = isset($extrafields->attributes[
'product_fournisseur_price'][
'count']) ? $extrafields->attributes[
'product_fournisseur_price'][
'count'] : 0;
466 if ($nbExtrafields > 0) {
467 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
469 $head[$h][2] =
'supplierAttributes';
486 global $langs,
$conf, $user, $extrafields;
488 $extrafields->fetch_name_optionals_label(
'product_lot');
493 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/product/admin/product_lot.php");
494 $head[$h][1] = $langs->trans(
'Parameters');
495 $head[$h][2] =
'settings';
504 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_lot_extrafields.php');
505 $head[$h][1] = $langs->trans(
"ExtraFields");
506 $nbExtrafields = $extrafields->attributes[
'product_lot'][
'count'];
507 if ($nbExtrafields > 0) {
508 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
510 $head[$h][2] =
'attributes';
529 global $langs, $user,
$db, $hookmanager;
535 print
'<tr class="liste_titre">';
536 print
'<td class="liste_titre left">';
537 print $form->textwithpicto($langs->trans(
"Referers"), $langs->trans(
"ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv(
"Referers")));
539 print
'<td class="liste_titre right">'.$langs->trans(
"NbOfThirdParties").
'</td>';
540 print
'<td class="liste_titre right">'.$langs->trans(
"NbOfObjectReferers").
'</td>';
541 print
'<td class="liste_titre right">'.$langs->trans(
"TotalQuantity").
'</td>';
545 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
547 $ret = $product->load_stats_propale($socid);
551 $langs->load(
"propal");
553 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/propal.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'propal',
'class="pictofixedwidth"').$langs->trans(
"Proposals").
'</a>';
554 print
'</td><td class="right">';
555 print $product->stats_propale[
'customers'];
556 print
'</td><td class="right">';
557 print $product->stats_propale[
'nb'];
558 print
'</td><td class="right">';
559 print
price($product->stats_propale[
'qty'], 1, $langs, 0, 0);
564 if (
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')) {
566 $ret = $product->load_stats_proposal_supplier($socid);
570 $langs->load(
"supplier_proposal");
572 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/supplier_proposal.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'supplier_proposal',
'class="pictofixedwidth"').$langs->trans(
"SupplierProposals").
'</a>';
573 print
'</td><td class="right">';
574 print $product->stats_proposal_supplier[
'suppliers'];
575 print
'</td><td class="right">';
576 print $product->stats_proposal_supplier[
'nb'];
577 print
'</td><td class="right">';
578 print
price($product->stats_proposal_supplier[
'qty'], 1, $langs, 0, 0);
583 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
585 $ret = $product->load_stats_commande($socid);
589 $langs->load(
"orders");
591 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/commande.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'order',
'class="pictofixedwidth"').$langs->trans(
"CustomersOrders").
'</a>';
592 print
'</td><td class="right">';
593 print $product->stats_commande[
'customers'];
594 print
'</td><td class="right">';
595 print $product->stats_commande[
'nb'];
596 print
'</td><td class="right">';
597 print
price($product->stats_commande[
'qty'], 1, $langs, 0, 0);
602 if ((
isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
'fournisseur',
'commande',
'lire')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire'))) {
604 $ret = $product->load_stats_commande_fournisseur($socid);
608 $langs->load(
"orders");
610 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/commande_fournisseur.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'supplier_order',
'class="pictofixedwidth"').$langs->trans(
"SuppliersOrders").
'</a>';
611 print
'</td><td class="right">';
612 print $product->stats_commande_fournisseur[
'suppliers'];
613 print
'</td><td class="right">';
614 print $product->stats_commande_fournisseur[
'nb'];
615 print
'</td><td class="right">';
616 print
price($product->stats_commande_fournisseur[
'qty'], 1, $langs, 0, 0);
621 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
623 $ret = $product->load_stats_facture($socid);
627 $langs->load(
"bills");
629 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/facture.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CustomersInvoices").
'</a>';
630 print
'</td><td class="right">';
631 print $product->stats_facture[
'customers'];
632 print
'</td><td class="right">';
633 print $product->stats_facture[
'nb'];
634 print
'</td><td class="right">';
635 print
price($product->stats_facture[
'qty'], 1, $langs, 0, 0);
640 if (
isModEnabled(
"invoice") && $user->hasRight(
'facture',
'lire')) {
642 $ret = $product->load_stats_facturerec($socid);
646 $langs->load(
"bills");
648 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/facturerec.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"RecurringInvoiceTemplate").
'</a>';
649 print
'</td><td class="right">';
650 print $product->stats_facturerec[
'customers'];
651 print
'</td><td class="right">';
652 print $product->stats_facturerec[
'nb'];
653 print
'</td><td class="right">';
654 print $product->stats_facturerec[
'qty'];
659 if ((
isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
'fournisseur',
'facture',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) {
661 $ret = $product->load_stats_facture_fournisseur($socid);
665 $langs->load(
"bills");
667 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/facture_fournisseur.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"SuppliersInvoices").
'</a>';
668 print
'</td><td class="right">';
669 print $product->stats_facture_fournisseur[
'suppliers'];
670 print
'</td><td class="right">';
671 print $product->stats_facture_fournisseur[
'nb'];
672 print
'</td><td class="right">';
673 print
price($product->stats_facture_fournisseur[
'qty'], 1, $langs, 0, 0);
700 if (
isModEnabled(
'shipping') && $user->hasRight(
'shipping',
'lire')) {
702 $ret = $product->load_stats_sending($socid);
706 $langs->load(
"sendings");
708 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/expedition.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'shipment',
'class="pictofixedwidth"').$langs->trans(
"Shipments").
'</a>';
709 print
'</td><td class="right">';
710 print $product->stats_expedition[
'customers'];
711 print
'</td><td class="right">';
712 print $product->stats_expedition[
'nb'];
713 print
'</td><td class="right">';
714 print $product->stats_expedition[
'qty'];
720 if ((
isModEnabled(
"reception") && $user->hasRight(
'reception',
'lire'))) {
722 $ret = $product->load_stats_reception($socid);
726 $langs->load(
"receptions");
728 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/reception.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'reception',
'class="pictofixedwidth"').$langs->trans(
"Receptions").
'</a>';
729 print
'</td><td class="right">';
730 print $product->stats_reception[
'suppliers'];
731 print
'</td><td class="right">';
732 print $product->stats_reception[
'nb'];
733 print
'</td><td class="right">';
734 print $product->stats_reception[
'qty'];
740 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
742 $ret = $product->load_stats_contrat($socid);
746 $langs->load(
"contracts");
748 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/contrat.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'contract',
'class="pictofixedwidth"').$langs->trans(
"Contracts").
'</a>';
749 print
'</td><td class="right">';
750 print $product->stats_contrat[
'customers'];
751 print
'</td><td class="right">';
752 print $product->stats_contrat[
'nb'];
753 print
'</td><td class="right">';
754 print
price($product->stats_contrat[
'qty'], 1, $langs, 0, 0);
760 if (
isModEnabled(
'bom') && $user->hasRight(
'bom',
'read')) {
762 $ret = $product->load_stats_bom($socid);
769 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/bom.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'bom',
'class="pictofixedwidth"').$langs->trans(
"BOM").
'</a>';
770 print
'</td><td class="right">';
772 print
'</td><td class="right">';
773 print $form->textwithpicto((
string) $product->stats_bom[
'nb_toconsume'], $langs->trans(
"RowMaterial"));
775 print $form->textwithpicto((
string) $product->stats_bom[
'nb_toproduce'], $langs->trans(
"Finished"));
776 print
'</td><td class="right">';
777 print $form->textwithpicto((
string) $product->stats_bom[
'qty_toconsume'], $langs->trans(
"RowMaterial"));
779 print $form->textwithpicto((
string) $product->stats_bom[
'qty_toproduce'], $langs->trans(
"Finished"));
785 if (
isModEnabled(
'mrp') && $user->hasRight(
'mrp',
'read')) {
787 $ret = $product->load_stats_mo($socid);
793 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/mo.php', [
'id' => $product->id],
false,
'anchorundermenu').
'">'.
img_object(
'',
'mrp',
'class="pictofixedwidth"').$langs->trans(
"MO").
'</a>';
794 print
'</td><td class="right">';
795 print $form->textwithpicto((
string) $product->stats_mo[
'customers_toconsume'], $langs->trans(
"ToConsume"));
797 print $form->textwithpicto((
string) $product->stats_mo[
'customers_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
799 print $form->textwithpicto((
string) $product->stats_mo[
'customers_toproduce'], $langs->trans(
"QtyToProduce"));
801 print $form->textwithpicto((
string) $product->stats_mo[
'customers_produced'], $langs->trans(
"QtyAlreadyProduced"));
802 print
'</td><td class="right">';
803 print $form->textwithpicto((
string) $product->stats_mo[
'nb_toconsume'], $langs->trans(
"ToConsume"));
805 print $form->textwithpicto((
string) $product->stats_mo[
'nb_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
807 print $form->textwithpicto((
string) $product->stats_mo[
'nb_toproduce'], $langs->trans(
"QtyToProduce"));
809 print $form->textwithpicto((
string) $product->stats_mo[
'nb_produced'], $langs->trans(
"QtyAlreadyProduced"));
810 print
'</td><td class="right">';
811 print $form->textwithpicto((
string) $product->stats_mo[
'qty_toconsume'], $langs->trans(
"ToConsume"));
813 print $form->textwithpicto((
string) $product->stats_mo[
'qty_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
815 print $form->textwithpicto((
string) $product->stats_mo[
'qty_toproduce'], $langs->trans(
"QtyToProduce"));
817 print $form->textwithpicto((
string) $product->stats_mo[
'qty_produced'], $langs->trans(
"QtyAlreadyProduced"));
821 $parameters = array(
'socid' => $socid);
822 $reshook = $hookmanager->executeHooks(
'addMoreProductStat', $parameters, $product, $nblines);
827 print $hookmanager->resPrint;
842 global
$conf, $langs, $user,
$db, $hookmanager;
844 $langs->LoadLangs(array(
'sendings',
'orders',
'receptions'));
850 print
'<tr class="liste_titre">';
851 print
'<td class="left" width="25%">'.$langs->trans(
"Referers").
'</td>';
852 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfThirdParties").
'</td>';
853 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfObjectReferers").
'</td>';
854 print
'<td class="right" width="25%">'.$langs->trans(
"TotalQuantity").
'</td>';
858 if (
isModEnabled(
'shipping') && $user->hasRight(
'expedition',
'lire')) {
860 $ret = $batch->loadStatsExpedition($socid);
864 $langs->load(
"bills");
866 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/expedition.php', [
'id' => $batch->id]).
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"Shipments").
'</a>';
867 print
'</td><td class="right">';
868 print $batch->stats_expedition[
'customers'];
869 print
'</td><td class="right">';
870 print $batch->stats_expedition[
'nb'];
871 print
'</td><td class="right">';
872 print $batch->stats_expedition[
'qty'];
877 if (
isModEnabled(
"reception") && $user->hasRight(
'reception',
'lire')) {
879 $ret = $batch->loadStatsReception($socid);
883 $langs->load(
"bills");
885 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/reception.php', [
'id' => $batch->id]).
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"Receptions").
'</a>';
886 print
'</td><td class="right">';
887 print $batch->stats_reception[
'customers'];
888 print
'</td><td class="right">';
889 print $batch->stats_reception[
'nb'];
890 print
'</td><td class="right">';
891 print $batch->stats_reception[
'qty'];
894 } elseif (
isModEnabled(
'supplier_order') && $user->hasRight(
'fournisseur',
'commande',
'lire')) {
896 $ret = $batch->loadStatsSupplierOrder($socid);
900 $langs->load(
"bills");
902 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/commande_fournisseur.php', [
'id' => $batch->id]).
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"SuppliersOrders").
'</a>';
903 print
'</td><td class="right">';
904 print $batch->stats_supplier_order[
'customers'];
905 print
'</td><td class="right">';
906 print $batch->stats_supplier_order[
'nb'];
907 print
'</td><td class="right">';
908 print $batch->stats_supplier_order[
'qty'];
913 if (
isModEnabled(
'mrp') && $user->hasRight(
'mrp',
'read')) {
915 $ret = $batch->loadStatsMo($socid);
921 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/mo.php', [
'id' => $batch->id]).
'">'.
img_object(
'',
'mrp',
'class="pictofixedwidth"').$langs->trans(
"MO").
'</a>';
922 print
'</td><td class="right">';
924 print $form->textwithpicto((
string) $batch->stats_mo[
'customers_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
926 print $form->textwithpicto((
string) $batch->stats_mo[
'customers_produced'], $langs->trans(
"QtyAlreadyProduced"));
927 print
'</td><td class="right">';
929 print $form->textwithpicto((
string) $batch->stats_mo[
'nb_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
931 print $form->textwithpicto((
string) $batch->stats_mo[
'nb_produced'], $langs->trans(
"QtyAlreadyProduced"));
932 print
'</td><td class="right">';
934 print $form->textwithpicto((
string) $batch->stats_mo[
'qty_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
936 print $form->textwithpicto((
string) $batch->stats_mo[
'qty_produced'], $langs->trans(
"QtyAlreadyProduced"));
941 $parameters = array(
'socid' => $socid);
942 $reshook = $hookmanager->executeHooks(
'addMoreBatchProductStat', $parameters, $batch, $nblines);
947 print $hookmanager->resPrint;
965function measuring_units_string($unitscale =
null, $measuring_style =
'', $unitid = 0, $use_short_label = 0, $outputlangs =
null)
967 return measuringUnitString($unitid, $measuring_style, $unitscale, $use_short_label, $outputlangs);
981function measuringUnitString($unitid, $measuring_style =
'', $unitscale =
null, $use_short_label = 0, $outputlangs =
null)
984 global $measuring_unit_cache;
986 if (empty($outputlangs)) {
987 $outputlangs = $langs;
990 if (empty($measuring_unit_cache[$unitid.
'_'.$measuring_style.
'_'.$unitscale.
'_'.$use_short_label])) {
991 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
994 if ($measuring_style ==
'' && $unitscale ==
'') {
995 $arrayforfilter = array(
996 't.rowid' => $unitid,
999 } elseif ($unitscale !==
'') {
1000 $arrayforfilter = array(
1001 't.scale' => $unitscale,
1002 't.unit_type' => $measuring_style,
1006 $arrayforfilter = array(
1007 't.rowid' => $unitid,
1008 't.unit_type' => $measuring_style,
1012 $result = $measuringUnits->fetchAll(
'',
'', 0, 0, $arrayforfilter);
1017 if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
1018 if ($use_short_label == 1) {
1019 $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
1020 } elseif ($use_short_label == 2) {
1021 $labeltoreturn = $outputlangs->transnoentitiesnoconv(ucfirst((
string) $measuringUnits->records[key($measuringUnits->records)]->label).
'Short');
1023 $labeltoreturn = $outputlangs->transnoentitiesnoconv((
string) $measuringUnits->records[key($measuringUnits->records)]->label);
1026 $labeltoreturn =
'';
1028 $measuring_unit_cache[$unitid.
'_'.$measuring_style.
'_'.$unitscale.
'_'.$use_short_label] = $labeltoreturn;
1029 return $labeltoreturn;
1032 return $measuring_unit_cache[$unitid.
'_'.$measuring_style.
'_'.$unitscale.
'_'.$use_short_label];
1045 $measuring_units = array();
1046 $measuring_units[0] = 0;
1047 $measuring_units[-1] = -2;
1048 $measuring_units[-2] = -4;
1049 $measuring_units[-3] = -6;
1050 $measuring_units[98] = 98;
1051 $measuring_units[99] = 99;
1052 return $measuring_units[$unitscale];
1065 $measuring_units = array();
1066 $measuring_units[0] = 0;
1067 $measuring_units[-1] = -3;
1068 $measuring_units[-2] = -6;
1069 $measuring_units[-3] = -9;
1070 $measuring_units[98] = 88;
1071 $measuring_units[99] = 89;
1072 return $measuring_units[$unit];
1083 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1086 $productarray = array();
1087 $sql =
"SELECT p.rowid as id, p.ref, p.label, p.description, p.entity";
1088 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
1089 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
1090 $sql .=
" AND p.rowid = ".((int)
$id);
1092 $resql =
$db->query($sql);
1095 $productarray =
$db->fetch_array($resql);
1107 $productarray[
"image"] =
$object->show_photos(
'product',
$conf->product->multidir_output[$entity], 1, 1, 0, 0, 0, 120, 160, 1,
'');
1109 $productarray[
"image"] =
"";
1111 return $productarray;
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Class of dictionary type of thirdparty (used by imports)
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $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', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_setcache($memoryid, $data, $expire=0, $filecache=0, $replace=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
measuring_units_squared($unitscale)
Transform a given unit scale into the square of that unit, if known.
show_stats_for_batch($batch, $socid)
Show stats for product batch.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
product_prepare_head($object)
Prepare array with list of tabs.
product_admin_prepare_head()
Return array head with list of tabs to view object information.
getProductForEmailTemplate($id)
Retrieve and return product for mail template.
show_stats_for_company($product, $socid)
Show stats for a product.
productlot_prepare_head($object)
Prepare array with list of tabs.
measuring_units_string($unitscale=null, $measuring_style='', $unitid=0, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
product_lot_admin_prepare_head()
Return array head with list of tabs to view object information.
measuring_units_cubed($unit)
Transform a given unit scale into the cube of that unit, if known.