dolibarr 25.0.0-alpha
productMargins.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
3 * Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
4 * Copyright (C) 2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2025-2026 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
32require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
33require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
34
43// Load translation files required by the page
44$langs->loadLangs(array('companies', 'bills', 'products', 'margins'));
45
46$id = GETPOSTINT('id');
47$ref = GETPOST('ref', 'alpha');
48$action = GETPOST('action', 'aZ09');
49$confirm = GETPOST('confirm', 'alpha');
50$TSelectedCats = GETPOST('categories', 'array:int');
51$socid = 0;
52
53$mesg = '';
54
55// Load variable for pagination
56$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$sortorder = GETPOST('sortorder', 'aZ09comma');
59$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
60if (empty($page) || $page == -1) {
61 $page = 0;
62} // If $page is not defined, or '' or -1
63$offset = $limit * $page;
64$pageprev = $page - 1;
65$pagenext = $page + 1;
66if (!$sortfield) {
67 if ($id > 0) {
68 $sortfield = "f.datef";
69 $sortorder = "DESC";
70 } else {
71 $sortfield = "p.ref";
72 $sortorder = "ASC";
73 }
74}
75
76$startdate = $enddate = '';
77if (GETPOST('startdatemonth')) {
78 $startdate = dol_mktime(0, 0, 0, GETPOSTINT('startdatemonth'), GETPOSTINT('startdateday'), GETPOSTINT('startdateyear'));
79}
80if (GETPOST('enddatemonth')) {
81 $enddate = dol_mktime(23, 59, 59, GETPOSTINT('enddatemonth'), GETPOSTINT('enddateday'), GETPOSTINT('enddateyear'));
82}
83
84// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
85$object = new Product($db);
86$hookmanager->initHooks(array('marginproductlist'));
87
88// Security check
89$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
90$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
91if (!empty($user->socid)) {
92 $socid = $user->socid;
93}
94$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
95if (!$user->hasRight('margins', 'liretous')) {
97}
98
99
100/*
101 * View
102 */
103
104$product_static = new Product($db);
105$invoicestatic = new Facture($db);
106
107$form = new Form($db);
108
109llxHeader('', $langs->trans("Margins").' - '.$langs->trans("Products"), '', '', 0, 0, '', '', '', 'mod-margin page-productmargins');
110
111$text = $langs->trans("Margins");
112//print load_fiche_titre($text);
113
114// Show tabs
115$head = marges_prepare_head();
116
117$titre = $langs->trans("Margins");
118$picto = 'margin';
119
120print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
121print '<input type="hidden" name="token" value="'.newToken().'">';
122
123print dol_get_fiche_head($head, 'productMargins', $titre, 0, $picto);
124
125print '<table class="border centpercent">';
126
127// Product
128print '<tr><td class="titlefield">'.$langs->trans('ProductOrService').'</td>';
129print '<td class="maxwidthonsmartphone" colspan="4">';
130print img_picto('', 'product', 'class="pictofixedwidth"').$form->select_produits(($id > 0 ? $id : ''), 'id', '', 20, 0, 1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null, 1);
131print '</td></tr>';
132
133// Categories
134$TCats = $form->select_all_categories('product', 0, '', 64, 0, 3);
135
136print '<tr>';
137print '<td class="titlefield">'.$langs->trans('Category').'</td>';
138print '<td class="maxwidthonsmartphone" colspan="4">';
139print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $TCats, $TSelectedCats, 0, 0, 'quatrevingtpercent widthcentpercentminusx');
140print '</td>';
141print '</tr>';
142
143// Start date
144print '<tr>';
145print '<td class="titlefield">'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')</td>';
146print '<td>';
147print img_picto('', 'agenda', 'class="pictofixedwidth"').$form->selectDate($startdate, 'startdate', 0, 0, 1, "sel", 1, 1);
148print '</td>';
149print '<td>'.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')</td>';
150print '<td>';
151print img_picto('', 'agenda', 'class="pictofixedwidth"').$form->selectDate($enddate, 'enddate', 0, 0, 1, "sel", 1, 1);
152print '</td>';
153print '<td style="text-align: center;">';
154print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Refresh')).'" />';
155print '</td></tr>';
156
157print "</table>";
158
159print '<br>';
160
161print '<table class="border centpercent">';
162
163// Total Margin
164print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
165print '<span id="totalMargin" class="amount"></span> <span class="amount">'.$langs->getCurrencySymbol(getDolCurrency()).'</span>'; // set by jquery (see below)
166print '</td></tr>';
167
168// Margin Rate
169if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
170 print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
171 print '<span id="marginRate"></span>'; // set by jquery (see below)
172 print '</td></tr>';
173}
174
175// Mark Rate
176if (getDolGlobalString('DISPLAY_MARK_RATES')) {
177 print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
178 print '<span id="markRate"></span>'; // set by jquery (see below)
179 print '</td></tr>';
180}
181
182print "</table>";
183
184print dol_get_fiche_end();
185
186print '</form>';
187
188$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
189
190$sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,";
191if ($id > 0) {
192 $sql .= " d.fk_product,";
193}
194if ($id > 0) {
195 $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut as statut,";
196}
197// Special case for old situation mode: total_ht is stored cumulatively, use delta percent to avoid cumulating margins
198if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
199 $sql_delta_pct = 'CASE WHEN f.type = '.Facture::TYPE_SITUATION.' AND d.situation_percent > 0 THEN (d.situation_percent - COALESCE(prev_d.situation_percent, 0)) ELSE d.situation_percent END';
200 $sql_delta_ht = 'CASE WHEN f.type = '.Facture::TYPE_SITUATION.' AND d.situation_percent > 0 THEN d.total_ht * ((d.situation_percent - COALESCE(prev_d.situation_percent, 0)) / d.situation_percent) ELSE d.total_ht END';
201 $sql .= " SUM($sql_delta_ht) as selling_price,";
202 $sql .= " SUM(d.qty) as product_qty,";
203 // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
204 $sql .= " SUM(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', "-1 * d.qty * d.buy_price_ht * ($sql_delta_pct / 100)", "d.qty * d.buy_price_ht * ($sql_delta_pct / 100)").") as buying_price,";
205 $sql .= " SUM(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', "-1 * (abs($sql_delta_ht) - (d.buy_price_ht * d.qty * ($sql_delta_pct / 100)))", "$sql_delta_ht - (d.buy_price_ht * d.qty * ($sql_delta_pct / 100))").") as marge";
206} else {
207 $sql .= " SUM(d.total_ht) as selling_price,";
208 $sql .= " SUM(d.qty) as product_qty,";
209 // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
210 $sql .= " SUM(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * d.qty * d.buy_price_ht * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,";
211 $sql .= " SUM(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge";
212}
213
214$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
215$sql .= ", ".MAIN_DB_PREFIX."facture as f";
216$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
217$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = d.fk_product";
218if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
219 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet AS prev_d ON prev_d.rowid = d.fk_prev_id";
220}
221if (!empty($TSelectedCats)) {
222 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=p.rowid';
223}
224$sql .= " WHERE f.fk_soc = s.rowid";
225$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
226$sql .= " AND f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")";
227$sql .= " AND d.fk_facture = f.rowid";
228if ($id > 0) {
229 $sql .= " AND d.fk_product =".((int) $id);
230}
231if (!empty($TSelectedCats)) {
232 $sql .= ' AND cp.fk_categorie IN ('.$db->sanitize(implode(',', $TSelectedCats)).')';
233}
234if (!empty($startdate)) {
235 $sql .= " AND f.datef >= '".$db->idate($startdate)."'";
236}
237if (!empty($enddate)) {
238 $sql .= " AND f.datef <= '".$db->idate($enddate)."'";
239}
240$sql .= " AND d.buy_price_ht IS NOT NULL";
241// We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report.
242// We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredictable.
243if (getDolGlobalInt('ForceBuyingPriceIfNull') == 2) {
244 $sql .= " AND d.buy_price_ht <> 0";
245}
246if ($id > 0) {
247 $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut";
248} else {
249 $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity";
250}
251$sql .= $db->order($sortfield, $sortorder);
252// TODO: calculate total to display then restore pagination
253//$sql.= $db->plimit($conf->liste_limit +1, $offset);
254
255$param = '&id='.((int) $id);
256if (GETPOSTINT('startdatemonth')) {
257 $param .= '&startdateyear='.GETPOSTINT('startdateyear');
258 $param .= '&startdatemonth='.GETPOSTINT('startdatemonth');
259 $param .= '&startdateday='.GETPOSTINT('startdateday');
260}
261if (GETPOSTINT('enddatemonth')) {
262 $param .= '&enddateyear='.GETPOSTINT('enddateyear');
263 $param .= '&enddatemonth='.GETPOSTINT('enddatemonth');
264 $param .= '&enddateday='.GETPOSTINT('enddateday');
265}
266$listofcateg = GETPOST('categories', 'array:int');
267if (is_array($listofcateg)) {
268 foreach ($listofcateg as $val) {
269 $param .= '&categories[]='.$val;
270 }
271}
272
273$totalMargin = 0;
274$marginRate = '';
275$markRate = '';
276dol_syslog('margin::productMargins.php', LOG_DEBUG);
277$result = $db->query($sql);
278if ($result) {
279 $num = $db->num_rows($result);
280
281 print '<br>';
282 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition, PhanPluginSuspiciousParamOrder
283 print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
284
285 //var_dump($conf->global->MARGIN_TYPE);
286 if (getDolGlobalString('MARGIN_TYPE') == "1") {
287 $labelcostprice = 'BuyingPrice';
288 } else { // value is 'costprice' or 'pmp'
289 $labelcostprice = 'CostPrice';
290 }
291
292 $moreforfilter = '';
293
294 $i = 0;
295 print '<div class="div-table-responsive">';
296 print '<table class="tagtable noborder nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
297
298 print '<tr class="liste_titre">';
299 if ($id > 0) {
300 print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
301 print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder, 'center ');
302 } else {
303 print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
304 }
305 print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", $param, '', $sortfield, $sortorder, 'center ');
306 print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right ');
307 print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right ');
308 print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right ');
309 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
310 print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
311 }
312 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
313 print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
314 }
315 print "</tr>\n";
316
317 $cumul_achat = 0;
318 $cumul_vente = 0;
319 $cumul_qty = 0;
320
321 if ($num > 0) {
322 while ($i < $num /*&& $i < $conf->liste_limit*/) {
323 $objp = $db->fetch_object($result);
324 $qty = $objp->product_qty;
325 $pa = $objp->buying_price;
326 $pv = $objp->selling_price;
327 $marge = $objp->marge;
328
329 if ($pa != 0) {
330 $marginRate = (100 * $marge / $pa);
331 // We invert the sign if the margin is negative, regardless of the sign of the purchase price
332 if ($marge < 0) {
333 $marginRate = -$marginRate;
334 }
335 } else {
336 $marginRate = '';
337 }
338
339 if ($pv != 0) {
340 $markRate = (100 * $marge / $pv);
341 // We invert the sign if the margin is negative, as in the original logic
342 if ($marge < 0) {
343 $markRate = -$markRate;
344 }
345 } else {
346 $markRate = '';
347 }
348
349 print '<tr class="oddeven">';
350 if ($id > 0) {
351 print '<td>';
352 $invoicestatic->id = $objp->facid;
353 $invoicestatic->ref = $objp->ref;
354 print $invoicestatic->getNomUrl(1);
355 print "</td>\n";
356 print "<td class=\"center\">";
357 print dol_print_date($db->jdate($objp->datef), 'day')."</td>";
358 } else {
359 print '<td>';
360 if ($objp->rowid > 0) {
361 $product_static->type = $objp->fk_product_type;
362 $product_static->id = $objp->rowid;
363 $product_static->ref = $objp->ref;
364 $product_static->label = $objp->label;
365 $product_static->entity = $objp->pentity;
366 $text = $product_static->getNomUrl(1);
367 print $text .= ' - '.$objp->label;
368 } else {
369 print img_object('', 'product').' '.$langs->trans("NotPredefinedProducts");
370 }
371 print "</td>\n";
372 //print "<td>".$product_static->getNomUrl(1)."</td>\n";
373 }
374 print '<td class="center">'.$qty.'</td>';
375 print '<td class="nowrap right"><span class="amount">'.price(price2num($pv, 'MT')).'</span></td>';
376 print '<td class="nowrap right"><span class="amount">'.price(price2num($pa, 'MT')).'</span></td>';
377 print '<td class="nowrap right"><span class="amount">'.price(price2num($marge, 'MT')).'</span></td>';
378 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
379 print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
380 }
381 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
382 print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
383 }
384 print "</tr>\n";
385
386 $i++;
387 $cumul_achat += $objp->buying_price;
388 $cumul_vente += $objp->selling_price;
389 $cumul_qty += $objp->product_qty;
390 }
391 }
392
393 // affichage totaux marges
394
395 $totalMargin = $cumul_vente - $cumul_achat;
396
397 $marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : '';
398 $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : '';
399
400 print '<tr class="liste_total">';
401 if ($id > 0) {
402 print '<td colspan=2>';
403 } else {
404 print '<td>';
405 }
406 print $langs->trans('TotalMargin').'</td>';
407 print '<td class="center">'.$cumul_qty.'</td>';
408 print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>';
409 print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>';
410 print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>';
411 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
412 print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
413 }
414 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
415 print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
416 }
417 print "</tr>\n";
418
419 print "</table>";
420 print '</div>';
421} else {
423}
424$db->free($result);
425
426
427print '
428<script type="text/javascript">
429$(document).ready(function() {
430 console.log("Init some values");
431 $("#totalMargin").html("'.price(price2num($totalMargin, 'MT')).'");
432 $("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'");
433 $("#markRate").html("'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'");
434});
435</script>
436';
437
438// End of page
439llxFooter();
440$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const STATUS_ABANDONED
Classified abandoned and no payment done.
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
marges_prepare_head()
Return array of tabs to used on pages for third parties cards.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.