dolibarr 25.0.0-alpha
thirdpartyMargins.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
37require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
38
39$langs->loadLangs(array("companies", "bills", "products", "margins"));
40
41$action = GETPOST('action');
42$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
43
44// Security check
45$socid = GETPOSTINT('socid');
46if (!empty($user->socid)) {
47 $socid = $user->socid;
48}
49
50$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
51$sortfield = GETPOST('sortfield', 'aZ09comma');
52$sortorder = GETPOST('sortorder', 'aZ09comma');
53$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
54if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
55 // If $page is not defined, or '' or -1 or if we click on clear filters
56 $page = 0;
57}
58$offset = $limit * $page;
59$pageprev = $page - 1;
60$pagenext = $page + 1;
61if (!$sortorder) {
62 $sortorder = "DESC";
63}
64if (!$sortfield) {
65 $sortfield = "f.datef";
66}
67
68$object = new Societe($db);
69if ($socid > 0) {
70 $object->fetch($socid);
71}
72
73// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
74$hookmanager->initHooks(array('thirdpartymargins', 'globalcard'));
75
76$result = restrictedArea($user, 'societe', $object->id, '');
77
78if (!$user->hasRight('margins', 'liretous')) {
80}
81
82
83/*
84 * Actions
85 */
86
87$parameters = array('id' => $socid);
88$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
89if ($reshook < 0) {
90 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
91}
92
93$search_invoice_date_start = '';
94$search_invoice_date_end = '';
95if (GETPOSTINT('search_invoice_date_start_month')) {
96 $search_invoice_date_start = dol_mktime(0, 0, 0, GETPOSTINT('search_invoice_date_start_month'), GETPOSTINT('search_invoice_date_start_day'), GETPOSTINT('search_invoice_date_start_year'));
97}
98if (GETPOSTINT('search_invoice_date_end_month')) {
99 $search_invoice_date_end = dol_mktime(23, 59, 59, GETPOSTINT('search_invoice_date_end_month'), GETPOSTINT('search_invoice_date_end_day'), GETPOSTINT('search_invoice_date_end_year'));
100}
101
102// Purge search criteria
103if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
104 $search_invoice_date_start = '';
105 $search_invoice_date_end = '';
106}
107
108// set default dates from fiscal year
109if (empty($search_invoice_date_start) && empty($search_invoice_date_end) && !GETPOSTISSET('restore_lastsearch_values')) {
110 $query = "SELECT date_start, date_end";
111 $query .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear";
112 $query .= " WHERE date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
113 $res = $db->query($query);
114
115 if ($res && $db->num_rows($res) > 0) {
116 $fiscalYear = $db->fetch_object($res);
117 $search_invoice_date_start = strtotime($fiscalYear->date_start);
118 $search_invoice_date_end = strtotime($fiscalYear->date_end);
119 } else {
120 $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
121 $year_start = (int) dol_print_date(dol_now(), '%Y');
122 if (dol_print_date(dol_now(), '%m') < $month_start) {
123 $year_start--; // If current month is lower that starting fiscal month, we start last year
124 }
125 $year_end = $year_start + 1;
126 $month_end = $month_start - 1;
127 if ($month_end < 1) {
128 $month_end = 12;
129 $year_end--;
130 }
131 $search_invoice_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
132 $search_invoice_date_end = dol_get_last_day($year_end, $month_end);
133 }
134}
135
136
137/*
138 * View
139 */
140
141$invoicestatic = new Facture($db);
142$form = new Form($db);
143
144$title = $langs->trans("ThirdParty").' - '.$langs->trans("Margins");
145if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
146 $title = $object->name.' - '.$langs->trans("Files");
147}
148$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
149llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-margin page-tabs_thirdpartymargins');
150
151$param = "&socid=".$socid;
152if ($limit > 0 && $limit != $conf->liste_limit) {
153 $param .= '&limit='.((int) $limit);
154}
155if ($dol_openinpopup) {
156 $param .= '&dol_openinpopup='.urlencode($dol_openinpopup);
157}
158if ($search_invoice_date_start) {
159 $param .= '&search_invoice_date_start_day='.dol_print_date($search_invoice_date_start, '%d').'&search_invoice_date_start_month='.dol_print_date($search_invoice_date_start, '%m').'&search_invoice_date_start_year='.dol_print_date($search_invoice_date_start, '%Y');
160}
161if ($search_invoice_date_end) {
162 $param .= '&search_invoice_date_end_day='.dol_print_date($search_invoice_date_end, '%d').'&search_invoice_date_end_month='.dol_print_date($search_invoice_date_end, '%m').'&search_invoice_date_end_year='.dol_print_date($search_invoice_date_end, '%Y');
163}
164
165$totalMargin = 0;
166$marginRate = '';
167$markRate = '';
168
169if ($socid > 0) {
170 $object = new Societe($db);
171 $object->fetch($socid);
172
173 if (empty($dol_openinpopup)) {
174 // Show tabs
175
176 $head = societe_prepare_head($object);
177
178 print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company');
179
180 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
181
182 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
183
184 print '<div class="fichecenter">';
185
186 print '<div class="underbanner clearboth"></div>';
187 print '<table class="border tableforfield centpercent">';
188
189 // Type Prospect/Customer/Supplier
190 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
191 print $object->getTypeUrl(1);
192 print '</td></tr>';
193
194 if ($object->client) {
195 print '<tr><td class="titlefield">';
196 print $langs->trans('CustomerCode').'</td><td colspan="3">';
198 $tmpcheck = $object->check_codeclient();
199 if ($tmpcheck != 0 && $tmpcheck != -5) {
200 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
201 }
202 print '</td></tr>';
203 }
204
205 if (((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) && $object->fournisseur) {
206 print '<tr><td class="titlefield">';
207 print $langs->trans('SupplierCode').'</td><td colspan="3">';
209 $tmpcheck = $object->check_codefournisseur();
210 if ($tmpcheck != 0 && $tmpcheck != -5) {
211 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
212 }
213 print '</td></tr>';
214 }
215
216 // Total Margin
217 print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="3">';
218 print '<span id="totalMargin" class="amount"></span>'; // set by jquery (see below)
219 print '</td></tr>';
220
221 // Margin Rate
222 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
223 print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="3">';
224 print '<span id="marginRate"></span>'; // set by jquery (see below)
225 print '</td></tr>';
226 }
227
228 // Mark Rate
229 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
230 print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="3">';
231 print '<span id="markRate"></span>'; // set by jquery (see below)
232 print '</td></tr>';
233 }
234
235 print "</table>";
236
237 print '</div>';
238 print '<div class="clearboth"></div>';
239
240 print dol_get_fiche_end();
241
242 print '<br>';
243 }
244
245 $sql = "SELECT s.nom, s.rowid as socid, s.code_client,";
246 $sql .= " f.rowid as facid, f.ref, f.total_ht,";
247 $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,";
248 // Special case for old situation mode: total_ht is stored cumulatively, use delta percent to avoid cumulating margins
249 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
250 $sql .= " sum(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) as selling_price,"; // may be negative or positive
251 $sql .= " sum(CASE WHEN f.type = ".Facture::TYPE_SITUATION." AND d.situation_percent > 0 THEN d.qty * d.buy_price_ht * ((d.situation_percent - COALESCE(prev_d.situation_percent, 0)) / 100) ELSE d.qty * d.buy_price_ht * (d.situation_percent / 100) END) as buying_price,"; // always positive
252 $sql .= " sum(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)) - (d.buy_price_ht * d.qty * ((d.situation_percent - COALESCE(prev_d.situation_percent, 0)) / 100)) ELSE abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)) END) as marge"; // always positive
253 } else {
254 $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive
255 $sql .= " sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // always positive
256 $sql .= " sum(abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100))) as marge"; // always positive
257 }
258 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
259 $sql .= ", ".MAIN_DB_PREFIX."facture as f";
260 $sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
261 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
262 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet AS prev_d ON prev_d.rowid = d.fk_prev_id";
263 }
264 $sql .= " WHERE f.fk_soc = s.rowid";
265 $sql .= " AND f.fk_statut > 0";
266 $sql .= " AND f.entity IN (".getEntity('invoice').")";
267 $sql .= " AND d.fk_facture = f.rowid";
268 $sql .= " AND f.fk_soc = ".((int) $socid);
269 $sql .= " AND d.buy_price_ht IS NOT NULL";
270 // 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.
271 // We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredictable.
272 if (getDolGlobalInt('ForceBuyingPriceIfNull') == 2) {
273 $sql .= " AND d.buy_price_ht <> 0";
274 }
275 if (!empty($search_invoice_date_start)) {
276 $sql .= " AND f.datef >= '".$db->idate($search_invoice_date_start)."'";
277 }
278 if (!empty($search_invoice_date_end)) {
279 $sql .= " AND f.datef <= '".$db->idate($search_invoice_date_end)."'";
280 }
281 $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut, f.type";
282
283
284 // TODO: calculate total to display then restore pagination
285
286 $sql .= $db->order($sortfield, $sortorder);
287 if ($limit) {
288 $sql .= $db->plimit($limit + 1, $offset);
289 }
290
291 dol_syslog('margin:tabs:thirdpartyMargins.php', LOG_DEBUG);
292 $result = $db->query($sql);
293 if ($result) {
294 $num = $db->num_rows($result);
295
296 print '<form method="post" action="'.$_SERVER ['PHP_SELF'].'?socid='.$socid.'" name="search_form">'."\n";
297 print '<input type="hidden" name="token" value="'.newToken().'">';
298 print '<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.'">';
299 if (!empty($sortfield)) {
300 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
301 }
302 if (!empty($sortorder)) {
303 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
304 }
305
306 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition, PhanPluginSuspiciousParamOrder
307 print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', 'margin');
308
309 $moreforfilter = '';
310
311 $parameters = array();
312 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
313 if (empty($reshook)) {
314 $moreforfilter .= $hookmanager->resPrint;
315 } else {
316 $moreforfilter = $hookmanager->resPrint;
317 }
318
319 if (!empty($moreforfilter)) {
320 print '<div class="liste_titre liste_titre_bydiv centpercent">';
321 print $moreforfilter;
322 print '</div>';
323 }
324
325 $selectedfields = '';
326
327 $i = 0;
328 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
329 print '<table class="noborder centpercent">';
330
331 // Fields title search
332 // --------------------------------------------------------------------
333 print '<tr class="liste_titre liste_titre_filter">';
334 // Action column
335 if ($conf->main_checkbox_left_column) {
336 print '<th class="liste_titre center maxwidthsearch">';
337 $searchpicto = $form->showFilterButtons('left');
338 print $searchpicto;
339 print '</th>';
340 }
341
342 // invoice ref
343 print '<th class="liste_titre">';
344 print '</th>';
345
346 // invoice date
347 print '<th class="liste_titre center">';
348 print '<div class="nowrapfordate">';
349 print $form->selectDate($search_invoice_date_start ?: -1, 'search_invoice_date_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
350 print '</div>';
351 print '<div class="nowrapfordate">';
352 print $form->selectDate($search_invoice_date_end ?: -1, 'search_invoice_date_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
353 print '</div>';
354 print '</th>';
355
356 // selling price
357 print '<th class="liste_titre">';
358 print '</th>';
359
360 // buying price
361 print '<th class="liste_titre">';
362 print '</th>';
363
364 // margin
365 print '<th class="liste_titre">';
366 print '</th>';
367
368 // margin rate
369 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
370 print '<th class="liste_titre">';
371 print '</th>';
372 }
373
374 // mark rate
375 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
376 print '<th class="liste_titre">';
377 print '</th>';
378 }
379
380 // status
381 print '<th class="liste_titre">';
382 print '</th>';
383
384 // Action column
385 if (!$conf->main_checkbox_left_column) {
386 print '<th class="liste_titre center maxwidthsearch">';
387 $searchpicto = $form->showFilterButtons();
388 print $searchpicto;
389 print '</th>';
390 }
391
392 print '</tr>'."\n";
393
394 print '<tr class="liste_titre">';
395 // Action column
396 if ($conf->main_checkbox_left_column) {
397 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
398 }
399 print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
400 print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder, 'center ');
401 print_liste_field_titre("SoldAmount", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right ');
402 print_liste_field_titre("PurchasedAmount", $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right ');
403 print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right ');
404 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
405 print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
406 }
407 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
408 print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
409 }
410 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
411 // Action column
412 if (!$conf->main_checkbox_left_column) {
413 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
414 }
415 print "</tr>\n";
416
417 $cumul_achat = 0;
418 $cumul_vente = 0;
419
420 if ($num > 0) {
421 $imaxinloop = ($limit ? min($num, $limit) : $num);
422 while ($i < $imaxinloop) {
423 $objp = $db->fetch_object($result);
424
425 $marginRate = ($objp->buying_price != 0) ? (100 * $objp->marge / $objp->buying_price) : '';
426 $markRate = ($objp->selling_price != 0) ? (100 * $objp->marge / $objp->selling_price) : '';
427
428 $sign = '';
429 if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
430 $sign = '-';
431 }
432
433 print '<tr class="oddeven">';
434 // Action column
435 if ($conf->main_checkbox_left_column) {
436 print '<td class="nowrap center">';
437 print '</td>';
438 }
439
440 print '<td>';
441 $invoicestatic->id = $objp->facid;
442 $invoicestatic->ref = $objp->ref;
443 $invoicestatic->type = $objp->type;
444 print $invoicestatic->getNomUrl(1);
445 print "</td>\n";
446 print "<td class=\"center\">";
447 print dol_print_date($db->jdate($objp->datef), 'day')."</td>";
448 print "<td class=\"right amount\">".price(price2num($objp->selling_price, 'MT'))."</td>\n";
449 print "<td class=\"right amount\">".price(price2num(($objp->type == 2 ? -1 : 1) * $objp->buying_price, 'MT'))."</td>\n";
450 print "<td class=\"right amount\">".$sign.price(price2num($objp->marge, 'MT'))."</td>\n";
451 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
452 print "<td class=\"right\">".(($marginRate === '') ? '<span class="opacitymedium">'.$langs->trans("NA").'</span>' : $sign.price(price2num($marginRate, 'MT'))."%")."</td>\n";
453 }
454 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
455 print "<td class=\"right\">".(($markRate === '') ? '<span class="opacitymedium">'.$langs->trans("NA").'</span>' : price(price2num($markRate, 'MT'))."%")."</td>\n";
456 }
457 print '<td class="right">'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).'</td>';
458
459 // Action column
460 if (!$conf->main_checkbox_left_column) {
461 print '<td class="nowrap center">';
462 print '</td>';
463 }
464 print "</tr>\n";
465 $i++;
466 $cumul_vente += $objp->selling_price;
467 $cumul_achat += ($objp->type == 2 ? -1 : 1) * $objp->buying_price;
468 }
469 }
470
471 // affichage totaux marges
472
473 $totalMargin = $cumul_vente - $cumul_achat;
474 if ($totalMargin < 0) {
475 $marginRate = ($cumul_achat != 0) ? -1 * (100 * $totalMargin / $cumul_achat) : '';
476 $markRate = ($cumul_vente != 0) ? -1 * (100 * $totalMargin / $cumul_vente) : '';
477 } else {
478 $marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : '';
479 $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : '';
480 }
481
482 // Total
483 print '<tr class="liste_total">';
484 $colspan = 2;
485 if ($conf->main_checkbox_left_column) {
486 print '<td></td>';
487 }
488 print '<td colspan="'.$colspan.'">'.$langs->trans('TotalMargin')."</td>";
489 print "<td class=\"right\">".price(price2num($cumul_vente, 'MT'))."</td>\n";
490 print "<td class=\"right\">".price(price2num($cumul_achat, 'MT'))."</td>\n";
491 print "<td class=\"right\">".price(price2num($totalMargin, 'MT'))."</td>\n";
492 if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
493 print "<td class=\"right\">".(($marginRate === '') ? '<span class="opacitymedium">'.$langs->trans("NA").'</span>' : price(price2num($marginRate, 'MT'))."%")."</td>\n";
494 }
495 if (getDolGlobalString('DISPLAY_MARK_RATES')) {
496 print "<td class=\"right\">".(($markRate === '') ? '<span class="opacitymedium">'.$langs->trans("NA").'</span>' : price(price2num($markRate, 'MT'))."%")."</td>\n";
497 }
498 print '<td class="right">&nbsp;</td>';
499 if (!$conf->main_checkbox_left_column) {
500 // add action column
501 print '<td></td>';
502 }
503 print "</tr>\n";
504 } else {
506 }
507 print "</table>";
508 print '</div>';
509 print '</form>';
510
511 print '<br>';
512 $db->free($result);
513} else {
514 dol_print_error(null, 'Parameter socid not defined');
515}
516
517
518print '
519 <script type="text/javascript">
520 $(document).ready(function() {
521 $("#totalMargin").html(\''. price(price2num($totalMargin, 'MT')).'\');
522 $("#marginRate").html(\''.(($marginRate === '') ? '<span class="opacitymedium">'.$langs->trans("NA").'</span>' : price(price2num($marginRate, 'MT'))."%").'\');
523 $("#markRate").html(\''.(($markRate === '') ? '<span class="opacitymedium">'.$langs->trans("NA").'</span>' : price(price2num($markRate, 'MT'))."%").'\');
524 });
525 </script>
526';
527
528// End of page
529llxFooter();
530$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 TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:624
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_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.