42 global $db, $langs, $conf, $user;
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] = 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/card.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)$'));
240 $upload_dir = $conf->product->multidir_output[
$object->entity ?? $conf->entity].
'/'.
get_exdir(
$object->id, 2, 0, 0,
$object,
'product').$object->id.
'/photos';
243 $upload_dir = $conf->service->multidir_output[
$object->entity ?? $conf->entity].
'/'.
get_exdir(
$object->id, 2, 0, 0,
$object,
'product').$object->id.
'/photos';
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'))) {
263 $head[$h][1] .= $langs->trans(
"Agenda");
265 $head[$h][2] =
'agenda';
283 global $db, $langs, $conf, $user;
286 $langs->loadLangs(array(
"products",
"productbatch"));
291 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/productlot_card.php', [
'id' =>
$object->id]);
292 $head[$h][1] = $langs->trans(
"Lot");
293 $head[$h][2] =
'card';
296 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/expedition.php', [
'showmessage' => 1,
'id' =>
$object->id]);
297 $head[$h][1] = $langs->trans(
'Referers');
298 $head[$h][2] =
'referers';
302 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
303 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
305 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
307 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/productlot_document.php', [
'id' =>
$object->id]);
308 $head[$h][1] = $langs->trans(
"Documents");
309 if (($nbFiles + $nbLinks) > 0) {
310 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
312 $head[$h][2] =
'documents';
318 if (!empty(
$object->note_private)) {
321 if (!empty(
$object->note_public)) {
324 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/product/stock/productlot_note.php', [
'id' =>
$object->id]);
325 $head[$h][1] = $langs->trans(
'Notes');
327 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>';
329 $head[$h][2] =
'note';
361 global $langs, $conf, $db;
364 $extrafields->fetch_name_optionals_label(
'product');
365 $extrafields->fetch_name_optionals_label(
'product_price');
366 $extrafields->fetch_name_optionals_label(
'product_customer_price');
367 $extrafields->fetch_name_optionals_label(
'product_fournisseur_price');
372 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/product/admin/product.php");
373 $head[$h][1] = $langs->trans(
'Parameters');
374 $head[$h][2] =
'general';
379 0 =>
dolBuildUrl(DOL_URL_ROOT.
"/product/admin/price_rules.php"),
380 1 => $langs->trans(
'MultipriceRules'),
392 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_extrafields.php');
393 $head[$h][1] = $langs->trans(
"ExtraFields");
394 $nbExtrafields = isset($extrafields->attributes[
'product'][
'count']) ? $extrafields->attributes[
'product'][
'count'] : 0;
395 if ($nbExtrafields > 0) {
396 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
398 $head[$h][2] =
'attributes';
403 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_price_extrafields.php');
404 $head[$h][1] = $langs->trans(
"ProductLevelExtraFields");
405 $nbExtrafields = isset($extrafields->attributes[
'product_price'][
'count']) ? $extrafields->attributes[
'product_price'][
'count'] : 0;
406 if ($nbExtrafields > 0) {
407 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
409 $head[$h][2] =
'levelAttributes';
415 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_customer_extrafields.php');
416 $head[$h][1] = $langs->trans(
"ProductCustomerExtraFields");
417 $nbExtrafields = isset($extrafields->attributes[
'product_customer_price'][
'count']) ? $extrafields->attributes[
'product_customer_price'][
'count'] : 0;
418 if ($nbExtrafields > 0) {
419 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
421 $head[$h][2] =
'customerAttributes';
426 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_supplier_extrafields.php');
427 $head[$h][1] = $langs->trans(
"ProductSupplierExtraFields");
428 $nbExtrafields = isset($extrafields->attributes[
'product_fournisseur_price'][
'count']) ? $extrafields->attributes[
'product_fournisseur_price'][
'count'] : 0;
429 if ($nbExtrafields > 0) {
430 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
432 $head[$h][2] =
'supplierAttributes';
449 global $langs, $conf, $user, $db;
452 $extrafields->fetch_name_optionals_label(
'product_lot');
457 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/product/admin/product_lot.php");
458 $head[$h][1] = $langs->trans(
'Parameters');
459 $head[$h][2] =
'settings';
468 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/product/admin/product_lot_extrafields.php');
469 $head[$h][1] = $langs->trans(
"ExtraFields");
470 $nbExtrafields = $extrafields->attributes[
'product_lot'][
'count'];
471 if ($nbExtrafields > 0) {
472 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
474 $head[$h][2] =
'attributes';
493 global $langs, $user, $db, $hookmanager;
495 $form =
new Form($db);
499 print
'<tr class="liste_titre">';
500 print
'<td class="left" width="25%">'.$langs->trans(
"Referers").
'</td>';
501 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfThirdParties").
'</td>';
502 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfObjectReferers").
'</td>';
503 print
'<td class="right" width="25%">'.$langs->trans(
"TotalQuantity").
'</td>';
507 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
509 $ret = $product->load_stats_propale($socid);
513 $langs->load(
"propal");
515 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/propal.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'propal',
'class="pictofixedwidth"').$langs->trans(
"Proposals").
'</a>';
516 print
'</td><td class="right">';
517 print $product->stats_propale[
'customers'];
518 print
'</td><td class="right">';
519 print $product->stats_propale[
'nb'];
520 print
'</td><td class="right">';
521 print
price($product->stats_propale[
'qty'], 1, $langs, 0, 0);
526 if (
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')) {
528 $ret = $product->load_stats_proposal_supplier($socid);
532 $langs->load(
"supplier_proposal");
534 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/supplier_proposal.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'supplier_proposal',
'class="pictofixedwidth"').$langs->trans(
"SupplierProposals").
'</a>';
535 print
'</td><td class="right">';
536 print $product->stats_proposal_supplier[
'suppliers'];
537 print
'</td><td class="right">';
538 print $product->stats_proposal_supplier[
'nb'];
539 print
'</td><td class="right">';
540 print
price($product->stats_proposal_supplier[
'qty'], 1, $langs, 0, 0);
545 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
547 $ret = $product->load_stats_commande($socid);
551 $langs->load(
"orders");
553 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/commande.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'order',
'class="pictofixedwidth"').$langs->trans(
"CustomersOrders").
'</a>';
554 print
'</td><td class="right">';
555 print $product->stats_commande[
'customers'];
556 print
'</td><td class="right">';
557 print $product->stats_commande[
'nb'];
558 print
'</td><td class="right">';
559 print
price($product->stats_commande[
'qty'], 1, $langs, 0, 0);
564 if ((
isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
'fournisseur',
'commande',
'lire')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire'))) {
566 $ret = $product->load_stats_commande_fournisseur($socid);
570 $langs->load(
"orders");
572 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/commande_fournisseur.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'supplier_order',
'class="pictofixedwidth"').$langs->trans(
"SuppliersOrders").
'</a>';
573 print
'</td><td class="right">';
574 print $product->stats_commande_fournisseur[
'suppliers'];
575 print
'</td><td class="right">';
576 print $product->stats_commande_fournisseur[
'nb'];
577 print
'</td><td class="right">';
578 print
price($product->stats_commande_fournisseur[
'qty'], 1, $langs, 0, 0);
583 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
585 $ret = $product->load_stats_facture($socid);
589 $langs->load(
"bills");
591 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/facture.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CustomersInvoices").
'</a>';
592 print
'</td><td class="right">';
593 print $product->stats_facture[
'customers'];
594 print
'</td><td class="right">';
595 print $product->stats_facture[
'nb'];
596 print
'</td><td class="right">';
597 print
price($product->stats_facture[
'qty'], 1, $langs, 0, 0);
602 if (
isModEnabled(
"invoice") && $user->hasRight(
'facture',
'lire')) {
604 $ret = $product->load_stats_facturerec($socid);
608 $langs->load(
"bills");
610 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/facturerec.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"RecurringInvoiceTemplate").
'</a>';
611 print
'</td><td class="right">';
612 print $product->stats_facturerec[
'customers'];
613 print
'</td><td class="right">';
614 print $product->stats_facturerec[
'nb'];
615 print
'</td><td class="right">';
616 print $product->stats_facturerec[
'qty'];
621 if ((
isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
'fournisseur',
'facture',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) {
623 $ret = $product->load_stats_facture_fournisseur($socid);
627 $langs->load(
"bills");
629 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/facture_fournisseur.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'supplier_invoice',
'class="pictofixedwidth"').$langs->trans(
"SuppliersInvoices").
'</a>';
630 print
'</td><td class="right">';
631 print $product->stats_facture_fournisseur[
'suppliers'];
632 print
'</td><td class="right">';
633 print $product->stats_facture_fournisseur[
'nb'];
634 print
'</td><td class="right">';
635 print
price($product->stats_facture_fournisseur[
'qty'], 1, $langs, 0, 0);
662 if (
isModEnabled(
'shipping') && $user->hasRight(
'shipping',
'lire')) {
664 $ret = $product->load_stats_sending($socid);
668 $langs->load(
"sendings");
670 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/expedition.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'shipment',
'class="pictofixedwidth"').$langs->trans(
"Shipments").
'</a>';
671 print
'</td><td class="right">';
672 print $product->stats_expedition[
'customers'];
673 print
'</td><td class="right">';
674 print $product->stats_expedition[
'nb'];
675 print
'</td><td class="right">';
676 print $product->stats_expedition[
'qty'];
682 if ((
isModEnabled(
"reception") && $user->hasRight(
'reception',
'lire'))) {
684 $ret = $product->load_stats_reception($socid);
688 $langs->load(
"receptions");
690 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/reception.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'reception',
'class="pictofixedwidth"').$langs->trans(
"Receptions").
'</a>';
691 print
'</td><td class="right">';
692 print $product->stats_reception[
'suppliers'];
693 print
'</td><td class="right">';
694 print $product->stats_reception[
'nb'];
695 print
'</td><td class="right">';
696 print $product->stats_reception[
'qty'];
702 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
704 $ret = $product->load_stats_contrat($socid);
708 $langs->load(
"contracts");
710 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/contrat.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'contract',
'class="pictofixedwidth"').$langs->trans(
"Contracts").
'</a>';
711 print
'</td><td class="right">';
712 print $product->stats_contrat[
'customers'];
713 print
'</td><td class="right">';
714 print $product->stats_contrat[
'nb'];
715 print
'</td><td class="right">';
716 print
price($product->stats_contrat[
'qty'], 1, $langs, 0, 0);
722 if (
isModEnabled(
'bom') && $user->hasRight(
'bom',
'read')) {
724 $ret = $product->load_stats_bom($socid);
731 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/bom.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'bom',
'class="pictofixedwidth"').$langs->trans(
"BOM").
'</a>';
732 print
'</td><td class="right">';
734 print
'</td><td class="right">';
735 print $form->textwithpicto((
string) $product->stats_bom[
'nb_toconsume'], $langs->trans(
"RowMaterial"));
737 print $form->textwithpicto((
string) $product->stats_bom[
'nb_toproduce'], $langs->trans(
"Finished"));
738 print
'</td><td class="right">';
739 print $form->textwithpicto((
string) $product->stats_bom[
'qty_toconsume'], $langs->trans(
"RowMaterial"));
741 print $form->textwithpicto((
string) $product->stats_bom[
'qty_toproduce'], $langs->trans(
"Finished"));
747 if (
isModEnabled(
'mrp') && $user->hasRight(
'mrp',
'read')) {
749 $ret = $product->load_stats_mo($socid);
755 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stats/mo.php', [
'id' => $product->id]).
'">'.
img_object(
'',
'mrp',
'class="pictofixedwidth"').$langs->trans(
"MO").
'</a>';
756 print
'</td><td class="right">';
757 print $form->textwithpicto((
string) $product->stats_mo[
'customers_toconsume'], $langs->trans(
"ToConsume"));
759 print $form->textwithpicto((
string) $product->stats_mo[
'customers_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
761 print $form->textwithpicto((
string) $product->stats_mo[
'customers_toproduce'], $langs->trans(
"QtyToProduce"));
763 print $form->textwithpicto((
string) $product->stats_mo[
'customers_produced'], $langs->trans(
"QtyAlreadyProduced"));
764 print
'</td><td class="right">';
765 print $form->textwithpicto((
string) $product->stats_mo[
'nb_toconsume'], $langs->trans(
"ToConsume"));
767 print $form->textwithpicto((
string) $product->stats_mo[
'nb_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
769 print $form->textwithpicto((
string) $product->stats_mo[
'nb_toproduce'], $langs->trans(
"QtyToProduce"));
771 print $form->textwithpicto((
string) $product->stats_mo[
'nb_produced'], $langs->trans(
"QtyAlreadyProduced"));
772 print
'</td><td class="right">';
773 print $form->textwithpicto((
string) $product->stats_mo[
'qty_toconsume'], $langs->trans(
"ToConsume"));
775 print $form->textwithpicto((
string) $product->stats_mo[
'qty_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
777 print $form->textwithpicto((
string) $product->stats_mo[
'qty_toproduce'], $langs->trans(
"QtyToProduce"));
779 print $form->textwithpicto((
string) $product->stats_mo[
'qty_produced'], $langs->trans(
"QtyAlreadyProduced"));
783 $parameters = array(
'socid' => $socid);
784 $reshook = $hookmanager->executeHooks(
'addMoreProductStat', $parameters, $product, $nblines);
789 print $hookmanager->resPrint;
804 global $conf, $langs, $user, $db, $hookmanager;
806 $langs->LoadLangs(array(
'sendings',
'orders',
'receptions'));
808 $form =
new Form($db);
812 print
'<tr class="liste_titre">';
813 print
'<td class="left" width="25%">'.$langs->trans(
"Referers").
'</td>';
814 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfThirdParties").
'</td>';
815 print
'<td class="right" width="25%">'.$langs->trans(
"NbOfObjectReferers").
'</td>';
816 print
'<td class="right" width="25%">'.$langs->trans(
"TotalQuantity").
'</td>';
820 if (
isModEnabled(
'shipping') && $user->hasRight(
'expedition',
'lire')) {
822 $ret = $batch->loadStatsExpedition($socid);
826 $langs->load(
"bills");
828 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/expedition.php', [
'id' => $batch->id]).
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"Shipments").
'</a>';
829 print
'</td><td class="right">';
830 print $batch->stats_expedition[
'customers'];
831 print
'</td><td class="right">';
832 print $batch->stats_expedition[
'nb'];
833 print
'</td><td class="right">';
834 print $batch->stats_expedition[
'qty'];
839 if (
isModEnabled(
"reception") && $user->hasRight(
'reception',
'lire')) {
841 $ret = $batch->loadStatsReception($socid);
845 $langs->load(
"bills");
847 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/reception.php', [
'id' => $batch->id]).
'">'.
img_object(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"Receptions").
'</a>';
848 print
'</td><td class="right">';
849 print $batch->stats_reception[
'customers'];
850 print
'</td><td class="right">';
851 print $batch->stats_reception[
'nb'];
852 print
'</td><td class="right">';
853 print $batch->stats_reception[
'qty'];
856 } elseif (
isModEnabled(
'supplier_order') && $user->hasRight(
'fournisseur',
'commande',
'lire')) {
858 $ret = $batch->loadStatsSupplierOrder($socid);
862 $langs->load(
"bills");
864 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>';
865 print
'</td><td class="right">';
866 print $batch->stats_supplier_order[
'customers'];
867 print
'</td><td class="right">';
868 print $batch->stats_supplier_order[
'nb'];
869 print
'</td><td class="right">';
870 print $batch->stats_supplier_order[
'qty'];
875 if (
isModEnabled(
'mrp') && $user->hasRight(
'mrp',
'read')) {
877 $ret = $batch->loadStatsMo($socid);
883 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stats/mo.php', [
'id' => $batch->id]).
'">'.
img_object(
'',
'mrp',
'class="pictofixedwidth"').$langs->trans(
"MO").
'</a>';
884 print
'</td><td class="right">';
886 print $form->textwithpicto((
string) $batch->stats_mo[
'customers_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
888 print $form->textwithpicto((
string) $batch->stats_mo[
'customers_produced'], $langs->trans(
"QtyAlreadyProduced"));
889 print
'</td><td class="right">';
891 print $form->textwithpicto((
string) $batch->stats_mo[
'nb_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
893 print $form->textwithpicto((
string) $batch->stats_mo[
'nb_produced'], $langs->trans(
"QtyAlreadyProduced"));
894 print
'</td><td class="right">';
896 print $form->textwithpicto((
string) $batch->stats_mo[
'qty_consumed'], $langs->trans(
"QtyAlreadyConsumed"));
898 print $form->textwithpicto((
string) $batch->stats_mo[
'qty_produced'], $langs->trans(
"QtyAlreadyProduced"));
903 $parameters = array(
'socid' => $socid);
904 $reshook = $hookmanager->executeHooks(
'addMoreBatchProductStat', $parameters, $batch, $nblines);
909 print $hookmanager->resPrint;
927function measuring_units_string($unitscale =
null, $measuring_style =
'', $unitid = 0, $use_short_label = 0, $outputlangs =
null)
929 return measuringUnitString($unitid, $measuring_style, $unitscale, $use_short_label, $outputlangs);
943function measuringUnitString($unitid, $measuring_style =
'', $unitscale =
null, $use_short_label = 0, $outputlangs =
null)
946 global $measuring_unit_cache;
948 if (empty($outputlangs)) {
949 $outputlangs = $langs;
952 if (empty($measuring_unit_cache[$unitid.
'_'.$measuring_style.
'_'.$unitscale.
'_'.$use_short_label])) {
953 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
954 $measuringUnits =
new CUnits($db);
956 if ($measuring_style ==
'' && $unitscale ==
'') {
957 $arrayforfilter = array(
958 't.rowid' => $unitid,
961 } elseif ($unitscale !==
'') {
962 $arrayforfilter = array(
963 't.scale' => $unitscale,
964 't.unit_type' => $measuring_style,
968 $arrayforfilter = array(
969 't.rowid' => $unitid,
970 't.unit_type' => $measuring_style,
974 $result = $measuringUnits->fetchAll(
'',
'', 0, 0, $arrayforfilter);
979 if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
980 if ($use_short_label == 1) {
981 $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
982 } elseif ($use_short_label == 2) {
983 $labeltoreturn = $outputlangs->transnoentitiesnoconv(ucfirst((
string) $measuringUnits->records[key($measuringUnits->records)]->label).
'Short');
985 $labeltoreturn = $outputlangs->transnoentitiesnoconv((
string) $measuringUnits->records[key($measuringUnits->records)]->label);
990 $measuring_unit_cache[$unitid.
'_'.$measuring_style.
'_'.$unitscale.
'_'.$use_short_label] = $labeltoreturn;
991 return $labeltoreturn;
994 return $measuring_unit_cache[$unitid.
'_'.$measuring_style.
'_'.$unitscale.
'_'.$use_short_label];
1007 $measuring_units = array();
1008 $measuring_units[0] = 0;
1009 $measuring_units[-1] = -2;
1010 $measuring_units[-2] = -4;
1011 $measuring_units[-3] = -6;
1012 $measuring_units[98] = 98;
1013 $measuring_units[99] = 99;
1014 return $measuring_units[$unitscale];
1027 $measuring_units = array();
1028 $measuring_units[0] = 0;
1029 $measuring_units[-1] = -3;
1030 $measuring_units[-2] = -6;
1031 $measuring_units[-3] = -9;
1032 $measuring_units[98] = 88;
1033 $measuring_units[99] = 89;
1034 return $measuring_units[$unit];
1045 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1048 $productarray = array();
1049 $sql =
"SELECT p.rowid as id, p.ref, p.label, p.description, p.entity";
1050 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
1051 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
1052 $sql .=
" AND p.rowid = ".((int)
$id);
1054 $resql = $db->query($sql);
1057 $productarray = $db->fetch_array($resql);
1068 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
1069 $productarray[
"image"] =
$object->show_photos(
'product', $conf->product->multidir_output[$entity], 1, 1, 0, 0, 0, 120, 160, 1,
'');
1071 $productarray[
"image"] =
"";
1073 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)
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.
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.