dolibarr 23.0.3
product.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2009-2010 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
6 * Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
7 * Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
8 * Copyright (C) 2024 Jean-Rémi TAPONIER <jean-remi@netlogic.fr>
9 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 Mélina Joum <melina.joum@altairis.fr>
11 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 * or see https://www.gnu.org/
26 */
27
41{
42 global $db, $langs, $conf, $user;
43 $langs->load("products");
44
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');
48
49 if ($object->isService()) {
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');
53 }
54
55 $h = 0;
56 $head = array();
57
58 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/product/card.php', ['id' => $object->id]);
59 $head[$h][1] = $label;
60 $head[$h][2] = 'card';
61 $h++;
62
63 // if (!empty($object->status)) {
64 if ($usercancreadprice) {
65 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/product/price.php', ['id' => $object->id]);
66 $head[$h][1] = $langs->trans("SellingPrices");
67 $head[$h][2] = 'price';
68 $h++;
69 } else {
70 $head[$h][0] = '#';
71 $head[$h][1] = $langs->trans("SellingPrices");
72 $head[$h][2] = 'price';
73 $head[$h][5] = 'disabled';
74 $h++;
75 }
76 // }
77
78 // if (!empty($object->status_buy) || (isModEnabled('margin') && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase
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"))
81 ) {
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';
86 $h++;
87 } else {
88 $head[$h][0] = '#';
89 $head[$h][1] = $langs->trans("BuyingPrices");
90 $head[$h][2] = 'suppliers';
91 $head[$h][5] = 'disabled';
92 $h++;
93 }
94 }
95 // }
96
97 // Multilangs
98 if (getDolGlobalInt('MAIN_MULTILANGS')) {
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>';
104 }
105 $head[$h][2] = 'translation';
106 $h++;
107 }
108
109 // Sub products
110 if (getDolGlobalString('PRODUIT_SOUSPRODUITS')) {
111 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/product/composition/card.php', ['id' => $object->id]);
112 $head[$h][1] = $langs->trans('AssociatedProducts');
113
114 $nbFather = $object->hasFatherOrChild(-1);
115 $nbChild = $object->hasFatherOrChild(1);
116 if ($nbFather > 0 || $nbChild > 0) {
117 $head[$h][1] .= '<span class="badge marginleftonlyshort">';
118 if ($nbFather) {
119 $head[$h][1] .= $nbFather;
120 }
121 $head[$h][1] .= ($nbFather && $nbChild) ? '+' : '';
122 if ($nbChild) {
123 $head[$h][1] .= $nbChild;
124 }
125 $head[$h][1] .= '</span>';
126 }
127 $head[$h][2] = 'subproduct';
128 $h++;
129 }
130
131 if (isModEnabled('variants') && ($object->isProduct() || $object->isService())) {
132 global $db;
133
134 require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
135
136 $prodcomb = new ProductCombination($db);
137
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>';
145 }
146 }
147
148 $h++;
149 }
150
151 if (($object->isProduct() || ($object->isService() && getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) && $object->stockable_product == Product::ENABLED_STOCK) { // If physical product we can stock (or service with option)
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';
156 $h++;
157 }
158 }
159
160 // Tab to link resources
161 if (isModEnabled('resource')) {
162 if ($object->isProduct() && getDolGlobalString('RESOURCE_ON_PRODUCTS')) {
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';
166 $h++;
167 }
168 if ($object->isService() && getDolGlobalString('RESOURCE_ON_SERVICES')) {
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';
172 $h++;
173 }
174 }
175 if (getDolGlobalString('MAIN_ENABLE_PRODUCTS_CONTACTS_TAB')) {
176 $objectsrc = $object;
177 if ($object->origin_type == 'product' && $object->origin_id > 0) {
178 $objectsrc = new Product($db);
179 $objectsrc->fetch($object->origin_id);
180 }
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>';
186 }
187 $head[$h][2] = 'contact';
188 $h++;
189 }
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';
193 $h++;
194
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';
198 $h++;
199
200 // Show more tabs from modules
201 // Entries must be declared in modules descriptor with line
202 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
203 // $this->tabs = array('entity:-tabname); to remove a tab
204 complete_head_from_modules($conf, $langs, $object, $head, $h, 'product', 'add', 'core');
205
206 // Notes
207 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
208 $nbNote = 0;
209 if (!empty($object->note_private)) {
210 $nbNote++;
211 }
212 if (!empty($object->note_public)) {
213 $nbNote++;
214 }
215 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/product/note.php', ['id' => $object->id]);
216 $head[$h][1] = $langs->trans('Notes');
217 if ($nbNote > 0) {
218 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
219 }
220 $head[$h][2] = 'note';
221 $h++;
222 }
223
224 // Attachments
225 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
226 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
227 $upload_dir = null;
228 $nbFiles = 0;
229 if (isModEnabled("product") && ($object->type == Product::TYPE_PRODUCT)) {
230 $upload_dir = $conf->product->multidir_output[$object->entity ?? $conf->entity].'/'.dol_sanitizeFileName($object->ref);
231 }
232 if (isModEnabled("service") && ($object->type == Product::TYPE_SERVICE)) {
233 $upload_dir = $conf->service->multidir_output[$object->entity ?? $conf->entity].'/'.dol_sanitizeFileName($object->ref);
234 }
235 if ($upload_dir !== null) {
236 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
237 }
238 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
239 if (isModEnabled("product") && ($object->type == Product::TYPE_PRODUCT)) {
240 $upload_dir = $conf->product->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
241 }
242 if (isModEnabled("service") && ($object->type == Product::TYPE_SERVICE)) {
243 $upload_dir = $conf->service->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
244 }
245 if ($upload_dir !== null) {
246 $nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
247 }
248 }
249 $nbLinks = Link::count($db, $object->element, $object->id);
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>';
254 }
255 $head[$h][2] = 'documents';
256 $h++;
257
258 // Log
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'))) {
262 $head[$h][1] .= '/';
263 $head[$h][1] .= $langs->trans("Agenda");
264 }
265 $head[$h][2] = 'agenda';
266 $h++;
267
268 complete_head_from_modules($conf, $langs, $object, $head, $h, 'product', 'add', 'external');
269
270 complete_head_from_modules($conf, $langs, $object, $head, $h, 'product', 'remove');
271
272 return $head;
273}
274
282{
283 global $db, $langs, $conf, $user;
284
285 // Load translation files required by the page
286 $langs->loadLangs(array("products", "productbatch"));
287
288 $h = 0;
289 $head = array();
290
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';
294 $h++;
295
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';
299 $h++;
300
301 // Attachments
302 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
303 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
304 $upload_dir = $conf->productbatch->multidir_output[$object->entity ?? $conf->entity].'/'.dol_sanitizeFileName($object->ref);
305 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
306 $nbLinks = Link::count($db, $object->element, $object->id);
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>';
311 }
312 $head[$h][2] = 'documents';
313 $h++;
314
315 // Notes
316 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
317 $nbNote = 0;
318 if (!empty($object->note_private)) {
319 $nbNote++;
320 }
321 if (!empty($object->note_public)) {
322 $nbNote++;
323 }
324 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT .'/product/stock/productlot_note.php', ['id' => $object->id]);
325 $head[$h][1] = $langs->trans('Notes');
326 if ($nbNote > 0) {
327 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>';
328 }
329 $head[$h][2] = 'note';
330 $h++;
331 }
332
333 // Show more tabs from modules
334 // Entries must be declared in modules descriptor with line
335 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
336 // $this->tabs = array('entity:-tabname); to remove a tab
337 complete_head_from_modules($conf, $langs, $object, $head, $h, 'productlot');
338
339 complete_head_from_modules($conf, $langs, $object, $head, $h, 'productlot', 'remove');
340
341 // Log
342 /*
343 $head[$h][0] = DOL_URL_ROOT.'/product/info.php', ['id' => $object->id]);
344 $head[$h][1] = $langs->trans("Info");
345 $head[$h][2] = 'info';
346 $h++;
347 */
348
349 return $head;
350}
351
352
353
360{
361 global $langs, $conf, $db;
362
363 $extrafields = new ExtraFields($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');
368
369 $h = 0;
370 $head = array();
371
372 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/product/admin/product.php");
373 $head[$h][1] = $langs->trans('Parameters');
374 $head[$h][2] = 'general';
375 $h++;
376
377 if (getDolGlobalString('PRODUIT_MULTIPRICES') && getDolGlobalString('PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL')) {
378 $head[$h] = array(
379 0 => dolBuildUrl(DOL_URL_ROOT."/product/admin/price_rules.php"),
380 1 => $langs->trans('MultipriceRules'),
381 2 => 'generator'
382 );
383 $h++;
384 }
385
386 // Show more tabs from modules
387 // Entries must be declared in modules descriptor with line
388 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
389 // $this->tabs = array('entity:-tabname); to remove a tab
390 complete_head_from_modules($conf, $langs, null, $head, $h, 'product_admin');
391
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>';
397 }
398 $head[$h][2] = 'attributes';
399 $h++;
400
401 // Extrafields for price levels
402 if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
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>';
408 }
409 $head[$h][2] = 'levelAttributes';
410 $h++;
411 }
412
413 //Extrafields for price per customer
414 if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
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>';
420 }
421 $head[$h][2] = 'customerAttributes';
422 $h++;
423 }
424
425 // Supplier prices
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>';
431 }
432 $head[$h][2] = 'supplierAttributes';
433 $h++;
434
435 complete_head_from_modules($conf, $langs, null, $head, $h, 'product_admin', 'remove');
436
437 return $head;
438}
439
440
441
448{
449 global $langs, $conf, $user, $db;
450
451 $extrafields = new ExtraFields($db);
452 $extrafields->fetch_name_optionals_label('product_lot');
453
454 $h = 0;
455 $head = array();
456
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';
460 $h++;
461
462 // Show more tabs from modules
463 // Entries must be declared in modules descriptor with line
464 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
465 // $this->tabs = array('entity:-tabname); to remove a tab
466 complete_head_from_modules($conf, $langs, null, $head, $h, 'product_lot_admin');
467
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>';
473 }
474 $head[$h][2] = 'attributes';
475 $h++;
476
477 complete_head_from_modules($conf, $langs, null, $head, $h, 'product_lot_admin', 'remove');
478
479 return $head;
480}
481
482
483
491function show_stats_for_company($product, $socid)
492{
493 global $langs, $user, $db, $hookmanager;
494
495 $form = new Form($db);
496
497 $nblines = 0;
498
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>';
504 print '</tr>';
505
506 // Customer proposals
507 if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
508 $nblines++;
509 $ret = $product->load_stats_propale($socid);
510 if ($ret < 0) {
511 dol_print_error($db);
512 }
513 $langs->load("propal");
514 print '<tr><td>';
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);
522 print '</td>';
523 print '</tr>';
524 }
525 // Supplier proposals
526 if (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire')) {
527 $nblines++;
528 $ret = $product->load_stats_proposal_supplier($socid);
529 if ($ret < 0) {
530 dol_print_error($db);
531 }
532 $langs->load("supplier_proposal");
533 print '<tr><td>';
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);
541 print '</td>';
542 print '</tr>';
543 }
544 // Sales orders
545 if (isModEnabled('order') && $user->hasRight('commande', 'lire')) {
546 $nblines++;
547 $ret = $product->load_stats_commande($socid);
548 if ($ret < 0) {
549 dol_print_error($db);
550 }
551 $langs->load("orders");
552 print '<tr><td>';
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);
560 print '</td>';
561 print '</tr>';
562 }
563 // Supplier orders
564 if ((isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire'))) {
565 $nblines++;
566 $ret = $product->load_stats_commande_fournisseur($socid);
567 if ($ret < 0) {
568 dol_print_error($db);
569 }
570 $langs->load("orders");
571 print '<tr><td>';
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);
579 print '</td>';
580 print '</tr>';
581 }
582 // Customer invoices
583 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
584 $nblines++;
585 $ret = $product->load_stats_facture($socid);
586 if ($ret < 0) {
587 dol_print_error($db);
588 }
589 $langs->load("bills");
590 print '<tr><td>';
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);
598 print '</td>';
599 print '</tr>';
600 }
601 // Customer template invoices
602 if (isModEnabled("invoice") && $user->hasRight('facture', 'lire')) {
603 $nblines++;
604 $ret = $product->load_stats_facturerec($socid);
605 if ($ret < 0) {
606 dol_print_error($db);
607 }
608 $langs->load("bills");
609 print '<tr><td>';
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'];
617 print '</td>';
618 print '</tr>';
619 }
620 // Supplier invoices
621 if ((isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) {
622 $nblines++;
623 $ret = $product->load_stats_facture_fournisseur($socid);
624 if ($ret < 0) {
625 dol_print_error($db);
626 }
627 $langs->load("bills");
628 print '<tr><td>';
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);
636 print '</td>';
637 print '</tr>';
638 }
639 // Supplier template invoices
640 /* TODO
641 if (isModEnabled("invoice") && $user->hasRight('fournisseur', 'facture', 'lire')) {
642 $nblines++;
643 $ret = $product->load_stats_facture_fournisseurrec($socid);
644 if ($ret < 0) {
645 dol_print_error($db);
646 }
647 $langs->load("bills");
648 print '<tr><td>';
649 print '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/product/stats/facture_facturerec.php', ['id' => $product->id]).'">'.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("RecurringInvoiceTemplate").'</a>';
650 print '</td><td class="right">';
651 print $product->stats_facturefournrec['customers'];
652 print '</td><td class="right">';
653 print $product->stats_facturefournrec['nb'];
654 print '</td><td class="right">';
655 print $product->stats_facturefournrec['qty'];
656 print '</td>';
657 print '</tr>';
658 }
659 */
660
661 // Shipments
662 if (isModEnabled('shipping') && $user->hasRight('shipping', 'lire')) {
663 $nblines++;
664 $ret = $product->load_stats_sending($socid);
665 if ($ret < 0) {
666 dol_print_error($db);
667 }
668 $langs->load("sendings");
669 print '<tr><td>';
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'];
677 print '</td>';
678 print '</tr>';
679 }
680
681 // Receptions
682 if ((isModEnabled("reception") && $user->hasRight('reception', 'lire'))) {
683 $nblines++;
684 $ret = $product->load_stats_reception($socid);
685 if ($ret < 0) {
686 dol_print_error($db);
687 }
688 $langs->load("receptions");
689 print '<tr><td>';
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'];
697 print '</td>';
698 print '</tr>';
699 }
700
701 // Contracts
702 if (isModEnabled('contract') && $user->hasRight('contrat', 'lire')) {
703 $nblines++;
704 $ret = $product->load_stats_contrat($socid);
705 if ($ret < 0) {
706 dol_print_error($db);
707 }
708 $langs->load("contracts");
709 print '<tr><td>';
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);
717 print '</td>';
718 print '</tr>';
719 }
720
721 // BOM
722 if (isModEnabled('bom') && $user->hasRight('bom', 'read')) {
723 $nblines++;
724 $ret = $product->load_stats_bom($socid);
725 if ($ret < 0) {
726 setEventMessage($product->error, 'errors');
727 }
728 $langs->load("mrp");
729
730 print '<tr><td>';
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">';
733
734 print '</td><td class="right">';
735 print $form->textwithpicto((string) $product->stats_bom['nb_toconsume'], $langs->trans("RowMaterial"));
736 print ' ';
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"));
740 print ' ';
741 print $form->textwithpicto((string) $product->stats_bom['qty_toproduce'], $langs->trans("Finished"));
742 print '</td>';
743 print '</tr>';
744 }
745
746 // MO
747 if (isModEnabled('mrp') && $user->hasRight('mrp', 'read')) {
748 $nblines++;
749 $ret = $product->load_stats_mo($socid);
750 if ($ret < 0) {
751 setEventMessages($product->error, $product->errors, 'errors');
752 }
753 $langs->load("mrp");
754 print '<tr><td>';
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"));
758 print ' ';
759 print $form->textwithpicto((string) $product->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed"));
760 print ' ';
761 print $form->textwithpicto((string) $product->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce"));
762 print ' ';
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"));
766 print ' ';
767 print $form->textwithpicto((string) $product->stats_mo['nb_consumed'], $langs->trans("QtyAlreadyConsumed"));
768 print ' ';
769 print $form->textwithpicto((string) $product->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce"));
770 print ' ';
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"));
774 print ' ';
775 print $form->textwithpicto((string) $product->stats_mo['qty_consumed'], $langs->trans("QtyAlreadyConsumed"));
776 print ' ';
777 print $form->textwithpicto((string) $product->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce"));
778 print ' ';
779 print $form->textwithpicto((string) $product->stats_mo['qty_produced'], $langs->trans("QtyAlreadyProduced"));
780 print '</td>';
781 print '</tr>';
782 }
783 $parameters = array('socid' => $socid);
784 $reshook = $hookmanager->executeHooks('addMoreProductStat', $parameters, $product, $nblines); // Note that $action and $object may have been modified by some hooks // TODO: Verify that $nblines is the correct value for argument $action
785 if ($reshook < 0) {
786 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
787 }
788
789 print $hookmanager->resPrint;
790
791
792 return $nblines++;
793}
794
802function show_stats_for_batch($batch, $socid)
803{
804 global $conf, $langs, $user, $db, $hookmanager;
805
806 $langs->LoadLangs(array('sendings', 'orders', 'receptions'));
807
808 $form = new Form($db);
809
810 $nblines = 0;
811
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>';
817 print '</tr>';
818
819 // Expeditions
820 if (isModEnabled('shipping') && $user->hasRight('expedition', 'lire')) {
821 $nblines++;
822 $ret = $batch->loadStatsExpedition($socid);
823 if ($ret < 0) {
824 dol_print_error($db);
825 }
826 $langs->load("bills");
827 print '<tr><td>';
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'];
835 print '</td>';
836 print '</tr>';
837 }
838
839 if (isModEnabled("reception") && $user->hasRight('reception', 'lire')) {
840 $nblines++;
841 $ret = $batch->loadStatsReception($socid);
842 if ($ret < 0) {
843 dol_print_error($db);
844 }
845 $langs->load("bills");
846 print '<tr><td>';
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'];
854 print '</td>';
855 print '</tr>';
856 } elseif (isModEnabled('supplier_order') && $user->hasRight('fournisseur', 'commande', 'lire')) {
857 $nblines++;
858 $ret = $batch->loadStatsSupplierOrder($socid);
859 if ($ret < 0) {
860 dol_print_error($db);
861 }
862 $langs->load("bills");
863 print '<tr><td>';
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'];
871 print '</td>';
872 print '</tr>';
873 }
874
875 if (isModEnabled('mrp') && $user->hasRight('mrp', 'read')) {
876 $nblines++;
877 $ret = $batch->loadStatsMo($socid);
878 if ($ret < 0) {
879 dol_print_error($db);
880 }
881 $langs->load("mrp");
882 print '<tr><td>';
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">';
885 // print $form->textwithpicto($batch->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number
886 print $form->textwithpicto((string) $batch->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed"));
887 // print $form->textwithpicto($batch->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number
888 print $form->textwithpicto((string) $batch->stats_mo['customers_produced'], $langs->trans("QtyAlreadyProduced"));
889 print '</td><td class="right">';
890 // print $form->textwithpicto($batch->stats_mo['nb_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number
891 print $form->textwithpicto((string) $batch->stats_mo['nb_consumed'], $langs->trans("QtyAlreadyConsumed"));
892 // print $form->textwithpicto($batch->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number
893 print $form->textwithpicto((string) $batch->stats_mo['nb_produced'], $langs->trans("QtyAlreadyProduced"));
894 print '</td><td class="right">';
895 // print $form->textwithpicto($batch->stats_mo['qty_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number
896 print $form->textwithpicto((string) $batch->stats_mo['qty_consumed'], $langs->trans("QtyAlreadyConsumed"));
897 // print $form->textwithpicto($batch->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number
898 print $form->textwithpicto((string) $batch->stats_mo['qty_produced'], $langs->trans("QtyAlreadyProduced"));
899 print '</td>';
900 print '</tr>';
901 }
902
903 $parameters = array('socid' => $socid);
904 $reshook = $hookmanager->executeHooks('addMoreBatchProductStat', $parameters, $batch, $nblines); // Note that $action and $object may have been modified by some hooks // TODO: Verify that $nblines is the correct value for argument $action
905 if ($reshook < 0) {
906 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
907 }
908
909 print $hookmanager->resPrint;
910
911
912 return $nblines++;
913}
914
927function measuring_units_string($unitscale = null, $measuring_style = '', $unitid = 0, $use_short_label = 0, $outputlangs = null)
928{
929 return measuringUnitString($unitid, $measuring_style, $unitscale, $use_short_label, $outputlangs);
930}
931
943function measuringUnitString($unitid, $measuring_style = '', $unitscale = null, $use_short_label = 0, $outputlangs = null)
944{
945 global $langs, $db;
946 global $measuring_unit_cache;
947
948 if (empty($outputlangs)) {
949 $outputlangs = $langs;
950 }
951
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);
955
956 if ($measuring_style == '' && $unitscale == '') {
957 $arrayforfilter = array(
958 't.rowid' => $unitid,
959 't.active' => 1
960 );
961 } elseif ($unitscale !== '') {
962 $arrayforfilter = array(
963 't.scale' => $unitscale,
964 't.unit_type' => $measuring_style,
965 't.active' => 1
966 );
967 } else {
968 $arrayforfilter = array(
969 't.rowid' => $unitid,
970 't.unit_type' => $measuring_style,
971 't.active' => 1
972 );
973 }
974 $result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter);
975
976 if ($result < 0) {
977 return -1;
978 } else {
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');
984 } else {
985 $labeltoreturn = $outputlangs->transnoentitiesnoconv((string) $measuringUnits->records[key($measuringUnits->records)]->label);
986 }
987 } else {
988 $labeltoreturn = '';
989 }
990 $measuring_unit_cache[$unitid.'_'.$measuring_style.'_'.$unitscale.'_'.$use_short_label] = $labeltoreturn;
991 return $labeltoreturn;
992 }
993 } else {
994 return $measuring_unit_cache[$unitid.'_'.$measuring_style.'_'.$unitscale.'_'.$use_short_label];
995 }
996}
997
1005function measuring_units_squared($unitscale)
1006{
1007 $measuring_units = array();
1008 $measuring_units[0] = 0; // m -> m3
1009 $measuring_units[-1] = -2; // dm-> dm2
1010 $measuring_units[-2] = -4; // cm -> cm2
1011 $measuring_units[-3] = -6; // mm -> mm2
1012 $measuring_units[98] = 98; // foot -> foot2
1013 $measuring_units[99] = 99; // inch -> inch2
1014 return $measuring_units[$unitscale];
1015}
1016
1017
1026{
1027 $measuring_units = array();
1028 $measuring_units[0] = 0; // m -> m2
1029 $measuring_units[-1] = -3; // dm-> dm3
1030 $measuring_units[-2] = -6; // cm -> cm3
1031 $measuring_units[-3] = -9; // mm -> mm3
1032 $measuring_units[98] = 88; // foot -> foot3
1033 $measuring_units[99] = 89; // inch -> inch3
1034 return $measuring_units[$unit];
1035}
1036
1044{
1045 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
1046 global $db, $conf;
1047
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);
1053
1054 $resql = $db->query($sql);
1055
1056 if ($resql) {
1057 $productarray = $db->fetch_array($resql);
1058 } else {
1059 dol_print_error($db);
1060 return -1;
1061 }
1062
1063 $object = new Product($db);
1064 $result = $object->fetch($id);
1065 if ($result < 0) {
1066 dol_print_error($db, $object->error, $object->errors);
1067 }
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, '');
1070 if ($object->nbphoto <= 0) {
1071 $productarray["image"] = "";
1072 }
1073 return $productarray;
1074}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class of dictionary type of thirdparty (used by imports)
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
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.
Definition files.lib.php:64
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.