dolibarr 25.0.0-alpha
customerMargins.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) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
31require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
32require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
33
42// Load translation files required by the page
43$langs->loadLangs(array('companies', 'bills', 'products', 'margins'));
44
45// Load variable for pagination
46$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
47$sortfield = GETPOST('sortfield', 'aZ09comma');
48$sortorder = GETPOST('sortorder', 'aZ09comma');
49$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
50if (empty($page) || $page == -1) {
51 $page = 0;
52} // If $page is not defined, or '' or -1
53$offset = $limit * $page;
54$pageprev = $page - 1;
55$pagenext = $page + 1;
56if (!$sortfield) {
57 $sortfield = "s.nom"; // Set here default search field
58}
59if (!$sortorder) {
60 $sortorder = "ASC";
61}
62
63$startdate = $enddate = '';
64if (GETPOST('startdatemonth')) {
65 $startdate = dol_mktime(0, 0, 0, GETPOSTINT('startdatemonth'), GETPOSTINT('startdateday'), GETPOSTINT('startdateyear'));
66}
67if (GETPOST('enddatemonth')) {
68 $enddate = dol_mktime(23, 59, 59, GETPOSTINT('enddatemonth'), GETPOSTINT('enddateday'), GETPOSTINT('enddateyear'));
69}
70
71// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
72$object = new Societe($db);
73$hookmanager->initHooks(array('margincustomerlist'));
74
75// Security check
76$socid = GETPOSTINT('socid');
77$TSelectedProducts = GETPOST('products', 'array');
78$TSelectedCats = GETPOST('categories', 'array:int');
79
80if (!empty($user->socid)) {
81 $socid = $user->socid;
82}
83$result = restrictedArea($user, 'societe', '', '');
84$result = restrictedArea($user, 'margins');
85
86
87/*
88 * View
89 */
90
91$companystatic = new Societe($db);
92$invoicestatic = new Facture($db);
93
94$form = new Form($db);
95
96llxHeader('', $langs->trans("Margins").' - '.$langs->trans("ThirdPartyCustomers"), '', '', 0, 0, '', '', '', 'mod-margin page-customermargins');
97
98$text = $langs->trans("Margins");
99//print load_fiche_titre($text);
100
101// Show tabs
102$head = marges_prepare_head();
103
104$titre = $langs->trans("Margins");
105$picto = 'margin';
106
107
108print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
109print '<input type="hidden" name="token" value="'.newToken().'">';
110
111print dol_get_fiche_head($head, 'customerMargins', $titre, 0, $picto);
112
113print '<table class="border centpercent">';
114
115$client = false;
116if ($socid > 0) {
117 $soc = new Societe($db);
118 $soc->fetch($socid);
119
120 if ($soc->client) {
121 print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>';
122 print '<td class="maxwidthonsmartphone" colspan="4">';
123 $filter = '(client:IN:1,3)';
124 print img_picto('', 'company').$form->select_company($socid, 'socid', $filter, 1, 0, 0);
125 print '</td></tr>';
126
127 $client = true;
128 if (!$sortorder) {
129 $sortorder = "DESC";
130 }
131 if (!$sortfield) {
132 $sortfield = "f.datef";
133 }
134 }
135} else {
136 print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>';
137 print '<td class="maxwidthonsmartphone" colspan="4">';
138 print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company(0, 'socid', '((client:=:1) OR (client:=:3))', 1, 0, 0);
139 print '</td></tr>';
140}
141
142$sortfield = GETPOST('sortfield', 'aZ09comma');
143$sortorder = GETPOST('sortorder', 'aZ09comma');
144if (!$sortorder) {
145 $sortorder = "ASC";
146}
147if (!$sortfield) {
148 if ($client) {
149 $sortfield = "f.datef";
150 $sortorder = "DESC";
151 } else {
152 $sortfield = "s.nom";
153 $sortorder = "ASC";
154 }
155}
156
157// Products
158$TRes = $form->select_produits_list(0, '', '', 0, 0, '', 1, 2, 1, 0, '', 1);
159
160$TProducts = array();
161foreach ($TRes as $prod) {
162 $TProducts[$prod['key']] = $prod['label'];
163}
164
165print '<tr><td class="titlefield">'.$langs->trans('ProductOrService').'</td>';
166print '<td class="maxwidthonsmartphone" colspan="4">';
167print img_picto('', 'product', 'class="pictofixedwidth"').$form->multiselectarray('products', $TProducts, $TSelectedProducts, 0, 0, 'minwidth500');
168print '</td></tr>';
169
170// Categories
171$TCats = $form->select_all_categories('product', 0, '', 64, 0, 3);
172
173print '<tr>';
174print '<td class="titlefield">'.$langs->trans('Category').'</td>';
175print '<td class="maxwidthonsmartphone" colspan="4">';
176print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $TCats, $TSelectedCats, 0, 0, 'quatrevingtpercent widthcentpercentminusx');
177print '</td>';
178print '</tr>';
179
180// Start date
181print '<td>'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')</td>';
182print '<td>';
183print img_picto('', 'agenda', 'class="pictofixedwidth"').$form->selectDate($startdate, 'startdate', 0, 0, 1, "sel", 1, 1);
184print '</td>';
185print '<td>'.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')</td>';
186print '<td>';
187print img_picto('', 'agenda', 'class="pictofixedwidth"').$form->selectDate($enddate, 'enddate', 0, 0, 1, "sel", 1, 1);
188print '</td>';
189print '<td style="text-align: center;">';
190print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Refresh')).'" />';
191print '</td></tr>';
192
193print "</table>";
194
195print '<br>';
196
197print '<table class="border centpercent">';
198
199// Total Margin
200print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
201print '<span id="totalMargin" class="amount"></span> <span class="amount">'.$langs->getCurrencySymbol(getDolCurrency()).'</span>'; // set by jquery (see below)
202print '</td></tr>';
203
204// Margin Rate
205if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
206 print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
207 print '<span id="marginRate"></span>'; // set by jquery (see below)
208 print '</td></tr>';
209}
210
211// Mark Rate
212if (getDolGlobalString('DISPLAY_MARK_RATES')) {
213 print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
214 print '<span id="markRate"></span>'; // set by jquery (see below)
215 print '</td></tr>';
216}
217
218print "</table>";
219
220print dol_get_fiche_end();
221
222print '</form>';
223
224$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
225
226$sql = "SELECT";
227$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
228if ($client) {
229 $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.type, f.fk_statut as statut,";
230}
231// Special case for old situation mode: total_ht is stored cumulatively, use delta percent to avoid cumulating margins
232if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
233 $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';
234 $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';
235 $sql .= " sum($sql_delta_ht) as selling_price,";
236 // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this)
237 $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,";
238 $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";
239} else {
240 $sql .= " sum(d.total_ht) as selling_price,";
241 // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this)
242 $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,";
243 $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";
244}
245
246$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
247$sql .= ", ".MAIN_DB_PREFIX."facture as f";
248$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
249if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
250 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet AS prev_d ON prev_d.rowid = d.fk_prev_id";
251}
252if (!empty($TSelectedCats)) {
253 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product';
254}
255
256if (!$user->hasRight('societe', 'client', 'voir')) {
257 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
258}
259$sql .= " WHERE f.fk_soc = s.rowid";
260if ($socid > 0) {
261 $sql .= ' AND s.rowid = '.((int) $socid);
262}
263if (!$user->hasRight('societe', 'client', 'voir')) {
264 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
265}
266$sql .= " AND f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")";
267$sql .= ' AND s.entity IN ('.getEntity('societe').')';
268$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
269$sql .= " AND d.fk_facture = f.rowid";
270$sql .= " AND (d.product_type = 0 OR d.product_type = 1)";
271if (!empty($TSelectedProducts)) {
272 $sql .= ' AND d.fk_product IN ('.$db->sanitize(implode(',', $TSelectedProducts)).')';
273}
274if (!empty($TSelectedCats)) {
275 $sql .= ' AND cp.fk_categorie IN ('.$db->sanitize(implode(',', $TSelectedCats)).')';
276}
277if (!empty($startdate)) {
278 $sql .= " AND f.datef >= '".$db->idate($startdate)."'";
279}
280if (!empty($enddate)) {
281 $sql .= " AND f.datef <= '".$db->idate($enddate)."'";
282}
283$sql .= " AND d.buy_price_ht IS NOT NULL";
284// 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.
285// We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredictable.
286if (getDolGlobalInt('ForceBuyingPriceIfNull') == 2) {
287 $sql .= " AND d.buy_price_ht <> 0";
288}
289if ($client) {
290 $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.type, f.fk_statut";
291} else {
292 $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client";
293}
294$sql .= $db->order($sortfield, $sortorder);
295// TODO: calculate total to display then restore pagination
296//$sql.= $db->plimit($conf->liste_limit +1, $offset);
297
298$param = '&socid='.((int) $socid);
299if (GETPOSTINT('startdatemonth')) {
300 $param .= '&startdateyear='.GETPOSTINT('startdateyear');
301 $param .= '&startdatemonth='.GETPOSTINT('startdatemonth');
302 $param .= '&startdateday='.GETPOSTINT('startdateday');
303}
304if (GETPOSTINT('enddatemonth')) {
305 $param .= '&enddateyear='.GETPOSTINT('enddateyear');
306 $param .= '&enddatemonth='.GETPOSTINT('enddatemonth');
307 $param .= '&enddateday='.GETPOSTINT('enddateday');
308}
309$listofproducts = GETPOST('products', 'array:int');
310if (is_array($listofproducts)) {
311 foreach ($listofproducts as $val) {
312 $param .= '&products[]='.$val;
313 }
314}
315$listofcateg = GETPOST('categories', 'array:int');
316if (is_array($listofcateg)) {
317 foreach ($listofcateg as $val) {
318 $param .= '&categories[]='.$val;
319 }
320}
321
322$totalMargin = 0;
323$marginRate = '';
324$markRate = '';
325dol_syslog('margin::customerMargins.php', LOG_DEBUG);
326$result = $db->query($sql);
327if ($result) {
328 $num = $db->num_rows($result);
329
330 print '<br>';
331 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition, PhanPluginSuspiciousParamOrder
332 print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
333
334 if (getDolGlobalString('MARGIN_TYPE') == "1") {
335 $labelcostprice = 'BuyingPrice';
336 } else { // value is 'costprice' or 'pmp'
337 $labelcostprice = 'CostPrice';
338 }
339
340 $moreforfilter = '';
341
342 $i = 0;
343 print '<div class="div-table-responsive">';
344 print '<table class="tagtable noborder nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
345
346 print '<tr class="liste_titre">';
347 if (!empty($client)) {
348 print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
349 print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center"', $sortfield, $sortorder);
350 } else {
351 print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
352 }
353 print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder);
354 print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, 'align="right"', $sortfield, $sortorder);
355 print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder);
356 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
357 print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
358 }
359 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
360 print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
361 }
362 print "</tr>\n";
363
364 $cumul_achat = 0;
365 $cumul_vente = 0;
366
367 if ($num > 0) {
368 while ($i < $num /*&& $i < $conf->liste_limit*/) {
369 $objp = $db->fetch_object($result);
370
371 $pa = $objp->buying_price;
372 $pv = $objp->selling_price;
373 $marge = $objp->marge;
374
375 if ($marge < 0) {
376 $marginRate = ($pa != 0) ? -1 * (100 * $marge / $pa) : '';
377 $markRate = ($pv != 0) ? -1 * (100 * $marge / $pv) : '';
378 } else {
379 $marginRate = ($pa != 0) ? (100 * $marge / $pa) : '';
380 $markRate = ($pv != 0) ? (100 * $marge / $pv) : '';
381 }
382
383 print '<tr class="oddeven">';
384 if ($client) {
385 $invoicestatic->id = $objp->facid;
386 $invoicestatic->ref = $objp->ref;
387 $invoicestatic->statut = $objp->statut;
388 $invoicestatic->status = $objp->statut;
389 $invoicestatic->type = $objp->type;
390
391 print '<td>';
392 print $invoicestatic->getNomUrl(1);
393 print '</td>';
394 print '<td class="center">';
395 print dol_print_date($db->jdate($objp->datef), 'day').'</td>';
396 } else {
397 $companystatic->id = $objp->socid;
398 $companystatic->name = $objp->name;
399 $companystatic->client = $objp->client;
400
401 print '<td>'.$companystatic->getNomUrl(1, 'margin').'</td>';
402 }
403
404 print '<td class="nowrap right"><span class="amount">'.price(price2num($pv, 'MT')).'</span></td>';
405 print '<td class="nowrap right"><span class="amount">'.price(price2num($pa, 'MT')).'</span></td>';
406 print '<td class="nowrap right"><span class="amount">'.price(price2num($marge, 'MT')).'</span></td>';
407 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
408 print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
409 }
410 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
411 print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
412 }
413 print "</tr>\n";
414
415 $i++;
416 $cumul_achat += $objp->buying_price;
417 $cumul_vente += $objp->selling_price;
418 }
419 }
420
421 // affichage totaux marges
422
423 $totalMargin = $cumul_vente - $cumul_achat;
424 /*if ($totalMargin < 0)
425 {
426 $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
427 $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
428 }
429 else
430 {*/
431 $marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : '';
432 $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : '';
433 //}
434
435 print '<tr class="liste_total">';
436 if ($client) {
437 print '<td colspan="2">';
438 } else {
439 print '<td>';
440 }
441 print $langs->trans('TotalMargin')."</td>";
442 print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>';
443 print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>';
444 print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>';
445 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
446 print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
447 }
448 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
449 print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
450 }
451 print '</tr>';
452
453 print '</table>';
454 print '</div>';
455} else {
457}
458$db->free($result);
459
460print '<script type="text/javascript">
461$(document).ready(function() {
462 console.log("Init some values");
463 $("#totalMargin").html("'.price(price2num($totalMargin, 'MT')).'");
464 $("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'");
465 $("#markRate").html("'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'");
466});
467</script>
468';
469
470// End of page
471llxFooter();
472$db->close();
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 third parties objects (customers, suppliers, prospects...)
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.
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.