dolibarr 24.0.0-beta
cabyprodserv.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.fr>
3 * Copyright (C) 2013-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
5 * Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
7 * Copyright (C) 2024-2026 Charlene Benke <charlene@patas-monkey.com>
8 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
29// Load Dolibarr environment
30require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
44require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array("products", "categories", "errors", 'accountancy'));
48
49// Security pack (data & check)
50$socid = GETPOSTINT('socid');
51
52if ($user->socid > 0) {
53 $socid = $user->socid;
54}
55
56// Hook
57$hookmanager->initHooks(array('cabyprodservlist'));
58
59if (isModEnabled('comptabilite')) {
60 $result = restrictedArea($user, 'compta', '', '', 'resultat');
61}
62if (isModEnabled('accounting')) {
63 $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
64}
65
66// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
67$modecompta = getDolGlobalString('ACCOUNTING_MODE');
68if (GETPOST("modecompta")) {
69 $modecompta = GETPOST("modecompta");
70}
71
72$sortorder = GETPOST("sortorder", 'aZ09comma');
73$sortfield = GETPOST("sortfield", 'aZ09comma');
74if (!$sortorder) {
75 $sortorder = "asc";
76}
77if (!$sortfield) {
78 $sortfield = "ref";
79}
80
81// Category
82$selected_cat = GETPOST('search_categ', 'intcomma');
83$selected_catsoc = GETPOST('search_categ_soc', 'intcomma');
84$selected_soc = GETPOST('search_soc', 'intcomma');
85$typent_id = GETPOST('typent_id', 'int');
86$subcat = false;
87if (GETPOST('subcat', 'alpha') === 'yes') {
88 $subcat = true;
89}
90$categorie = new Categorie($db);
91
92// product/service
93$selected_type = GETPOST('search_type', 'intcomma');
94if ($selected_type == '') {
95 $selected_type = -1;
96}
97
98// Date range
99$year = GETPOSTINT("year");
100$month = GETPOSTINT("month");
101$date_startyear = GETPOST("date_startyear");
102$date_startmonth = GETPOST("date_startmonth");
103$date_startday = GETPOST("date_startday");
104$date_endyear = GETPOST("date_endyear");
105$date_endmonth = GETPOST("date_endmonth");
106$date_endday = GETPOST("date_endday");
107if (empty($year)) {
108 $year_current = dol_print_date(dol_now(), '%Y');
109 $month_current = dol_print_date(dol_now(), '%m');
110 $year_start = $year_current;
111} else {
112 $year_current = $year;
113 $month_current = dol_print_date(dol_now(), '%m');
114 $year_start = $year;
115}
116$date_start = dol_mktime(0, 0, 0, GETPOSTINT("date_startmonth"), GETPOSTINT("date_startday"), GETPOSTINT("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere
117$date_end = dol_mktime(23, 59, 59, GETPOSTINT("date_endmonth"), GETPOSTINT("date_endday"), GETPOSTINT("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere
118// Quarter
119if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
120 $q = GETPOSTINT("q");
121 if (empty($q)) {
122 // We define date_start and date_end
123 $month_start = GETPOST("month") ? GETPOST("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
124 $year_end = $year_start;
125 $month_end = $month_start;
126 if (!GETPOST("month")) { // If month not forced
127 if (!GETPOST('year') && $month_start > $month_current) {
128 $year_start--;
129 $year_end--;
130 }
131 $month_end = $month_start - 1;
132 if ($month_end < 1) {
133 $month_end = 12;
134 } else {
135 $year_end++;
136 }
137 }
138 $date_start = dol_get_first_day($year_start, $month_start, false);
139 $date_end = dol_get_last_day($year_end, $month_end, false);
140 } else {
141 if ($q == 1) {
142 $date_start = dol_get_first_day($year_start, 1, false);
143 $date_end = dol_get_last_day($year_start, 3, false);
144 }
145 if ($q == 2) {
146 $date_start = dol_get_first_day($year_start, 4, false);
147 $date_end = dol_get_last_day($year_start, 6, false);
148 }
149 if ($q == 3) {
150 $date_start = dol_get_first_day($year_start, 7, false);
151 $date_end = dol_get_last_day($year_start, 9, false);
152 }
153 if ($q == 4) {
154 $date_start = dol_get_first_day($year_start, 10, false);
155 $date_end = dol_get_last_day($year_start, 12, false);
156 }
157 }
158} else {
159 // TODO We define q
160}
161
162// $date_start and $date_end are defined. We force $year_start and $nbofyear
163$tmps = dol_getdate($date_start);
164$year_start = $tmps['year'];
165$tmpe = dol_getdate($date_end);
166$year_end = $tmpe['year'];
167$nbofyear = ($year_end - $year_start) + 1;
168
169$commonparams = array();
170if (!empty($modecompta)) {
171 $commonparams['modecompta'] = $modecompta;
172}
173if (!empty($sortorder)) {
174 $commonparams['sortorder'] = $sortorder;
175}
176if (!empty($sortfield)) {
177 $commonparams['sortfield'] = $sortfield;
178}
179
180$headerparams = array();
181if (!empty($date_startyear)) {
182 $headerparams['date_startyear'] = $date_startyear;
183}
184if (!empty($date_startmonth)) {
185 $headerparams['date_startmonth'] = $date_startmonth;
186}
187if (!empty($date_startday)) {
188 $headerparams['date_startday'] = $date_startday;
189}
190if (!empty($date_endyear)) {
191 $headerparams['date_endyear'] = $date_endyear;
192}
193if (!empty($date_endmonth)) {
194 $headerparams['date_endmonth'] = $date_endmonth;
195}
196if (!empty($date_endday)) {
197 $headerparams['date_endday'] = $date_endday;
198}
199if (!empty($year)) {
200 $headerparams['year'] = $year;
201}
202if (!empty($month)) {
203 $headerparams['month'] = $month;
204}
205if (!empty($q)) {
206 $headerparams['q'] = $q;
207}
208
209$tableparams = array();
210if (!empty($selected_cat)) {
211 $tableparams['search_categ'] = $selected_cat;
212}
213if (!empty($selected_catsoc)) {
214 $tableparams['search_categ_soc'] = $selected_catsoc;
215}
216if (!empty($selected_soc)) {
217 $tableparams['search_soc'] = $selected_soc;
218}
219if ($selected_type > 0) {
220 $tableparams['search_type'] = $selected_type;
221}
222if (!empty($typent_id)) {
223 $tableparams['typent_id'] = $typent_id;
224}
225$tableparams['subcat'] = $subcat ? 'yes' : '';
226
227// Adding common parameters
228$allparams = array_merge($commonparams, $headerparams, $tableparams);
229$headerparams = array_merge($commonparams, $headerparams);
230$tableparams = array_merge($commonparams, $tableparams);
231
232$paramslink = "";
233foreach ($allparams as $key => $value) {
234 $paramslink .= '&'.urlencode($key).'='.urlencode($value);
235}
236
237
238/*
239 * View
240 */
241
242llxHeader();
243
244$form = new Form($db);
245$formother = new FormOther($db);
246
247// TODO Report from bookkeeping not yet available, so we switch on report on business events
248if ($modecompta == "BOOKKEEPING") {
249 $modecompta = "CREANCES-DETTES";
250}
251if ($modecompta == "BOOKKEEPINGCOLLECTED") {
252 $modecompta = "RECETTES-DEPENSES";
253}
254
255$exportlink = "";
256$namelink = "";
257$builddate = 0;
258$calcmode = '';
259$name = '';
260$period = '';
261$periodlink = '';
262$description = '';
263
264
265// Show report header
266if ($modecompta == "CREANCES-DETTES") {
267 $name = $langs->trans("Turnover").', '.$langs->trans("ByProductsAndServices");
268 $calcmode = $langs->trans("CalcModeDebt");
269 //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
270
271 $description = $langs->trans("RulesCADue");
272 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
273 $description .= $langs->trans("DepositsAreNotIncluded");
274 } else {
275 $description .= $langs->trans("DepositsAreIncluded");
276 }
277 $builddate = dol_now();
278} elseif ($modecompta == "RECETTES-DEPENSES") {
279 $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices");
280 $calcmode = $langs->trans("CalcModePayment");
281 //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
282
283 $description = $langs->trans("RulesCAIn");
284 $description .= $langs->trans("DepositsAreIncluded");
285
286 $builddate = dol_now();
287} // elseif ($modecompta == "BOOKKEEPING") {
288// } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
289// }
290
291$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
292$period .= ' - ';
293$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
294if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) {
295 $periodlink = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start - 1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start + 1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
296} else {
297 $periodlink = '';
298}
299
300report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
301
302if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
303 print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, '1');
304}
305
306
307$name = array();
308
309// SQL request
310$catotal = 0;
311$catotal_ht = 0;
312$qtytotal = 0;
313
314if ($modecompta == 'CREANCES-DETTES') {
315 $sql = "SELECT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,";
316 $sql .= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,";
317 $sql .= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty";
318
319 $parameters = array();
320 $hookmanager->executeHooks('printFieldListSelect', $parameters);
321 $sql .= $hookmanager->resPrint;
322
323 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
324 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture";
325 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
326 if ($typent_id > 0) {
327 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)";
328 }
329 $parameters = array();
330 $hookmanager->executeHooks('printFieldListFrom', $parameters);
331 $sql .= $hookmanager->resPrint;
332
333 $sql .= " WHERE f.fk_statut in (1,2)";
334 $sql .= " AND l.product_type in (0,1)";
335 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
336 $sql .= " AND f.type IN (0,1,2,5)";
337 } else {
338 $sql .= " AND f.type IN (0,1,2,3,5)";
339 }
340 if ($date_start && $date_end) {
341 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
342 }
343 if ($selected_type >= 0) {
344 $sql .= " AND l.product_type = ".((int) $selected_type);
345 }
346
347 // Search for tag/category ($searchCategoryProductList is an array of ID)
348 $searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
349 $searchCategoryProductList = array($selected_cat);
350 if ($subcat) {
351 $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1);
352 $searchCategoryProductList = array();
353 foreach ($TListOfCats as $key => $cat) {
354 $searchCategoryProductList[] = $cat['id'];
355 }
356 }
357 if (!empty($searchCategoryProductList)) {
358 $searchCategoryProductSqlList = array();
359 $listofcategoryid = '';
360 foreach ($searchCategoryProductList as $searchCategoryProduct) {
361 if (intval($searchCategoryProduct) == -2) {
362 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE l.fk_product = ck.fk_product)";
363 } elseif (intval($searchCategoryProduct) > 0) {
364 if ($searchCategoryProductOperator == 0) {
365 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE l.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
366 } else {
367 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
368 }
369 }
370 }
371 if ($listofcategoryid) {
372 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE l.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
373 }
374 if ($searchCategoryProductOperator == 1) {
375 if (!empty($searchCategoryProductSqlList)) {
376 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
377 }
378 } else {
379 if (!empty($searchCategoryProductSqlList)) {
380 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
381 }
382 }
383 }
384
385 // Search for tag/category ($searchCategorySocieteList is an array of ID)
386 $searchCategorySocieteOperator = GETPOSTINT('search_category_societe_operator');
387 $searchCategorySocieteList = array($selected_catsoc);
388 if (!empty($searchCategorySocieteList)) {
389 $searchCategorySocieteSqlList = array();
390 $listofcategoryid = '';
391 foreach ($searchCategorySocieteList as $searchCategorySociete) {
392 if (intval($searchCategorySociete) == -2) {
393 $searchCategorySocieteSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE f.fk_soc = cs.fk_soc)";
394 } elseif (intval($searchCategorySociete) > 0) {
395 if ($searchCategorySocieteOperator == 0) {
396 $searchCategorySocieteSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE f.fk_soc = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategorySociete).")";
397 } else {
398 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySociete);
399 }
400 }
401 }
402 if ($listofcategoryid) {
403 $searchCategorySocieteSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE f.fk_soc = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
404 }
405 if ($searchCategorySocieteOperator == 1) {
406 if (!empty($searchCategorySocieteSqlList)) {
407 $sql .= " AND (".implode(' OR ', $searchCategorySocieteSqlList).")";
408 }
409 } else {
410 if (!empty($searchCategorySocieteSqlList)) {
411 $sql .= " AND (".implode(' AND ', $searchCategorySocieteSqlList).")";
412 }
413 }
414 }
415
416 if ($selected_soc > 0) {
417 $sql .= " AND f.fk_soc = ".((int) $selected_soc);
418 }
419
420 if ($typent_id > 0) {
421 $sql .= " AND soc.fk_typent = ".((int) $typent_id);
422 }
423
424 $sql .= " AND f.entity IN (".getEntity('invoice').")";
425
426 $parameters = array();
427 $hookmanager->executeHooks('printFieldListWhere', $parameters);
428 $sql .= $hookmanager->resPrint;
429
430 $sql .= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type";
431 $sql .= $db->order((string) $sortfield, (string) $sortorder);
432
433 dol_syslog("cabyprodserv", LOG_DEBUG);
434 $result = $db->query($sql);
435
436 $amount_ht = array();
437 $amount = array();
438 $qty = array();
439 $type = [];
440 if ($result) {
441 $num = $db->num_rows($result);
442 $i = 0;
443 while ($i < $num) {
444 $obj = $db->fetch_object($result);
445
446 $amount_ht[$obj->rowid] = $obj->amount;
447 $amount[$obj->rowid] = $obj->amount_ttc;
448 $qty[$obj->rowid] = $obj->qty;
449 $name[$obj->rowid] = $obj->ref.'&nbsp;-&nbsp;'.$obj->label;
450 $type[$obj->rowid] = $obj->product_type;
451 $catotal_ht += $obj->amount;
452 $catotal += $obj->amount_ttc;
453 $qtytotal += $obj->qty;
454 $i++;
455 }
456 } else {
458 }
459
460 // Show Array
461 $i = 0;
462 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
463 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
464 // Extra parameters management
465 foreach ($headerparams as $key => $value) {
466 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
467 }
468
469 $moreforfilter = '';
470
471 print '<div class="div-table-responsive">';
472 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
473
474 // Category filter
475 print '<tr class="liste_titre">';
476 print '<td>';
477 print img_picto('', 'category', 'class="pictofixedwidth"');
478 print $formother->select_categories(Categorie::TYPE_PRODUCT, (int) $selected_cat, 'search_categ', 0, $langs->trans("Category"));
479 print ' ';
480 print '<input type="checkbox" class="marginleft" id="subcat" name="subcat" value="yes"';
481 if ($subcat) {
482 print ' checked';
483 }
484 print '>';
485 print '<label for="subcat" class="marginrightonly">'.$langs->trans("SubCats").'?</label>';
486 // type filter (produit/service)
487 $form->select_type_of_lines($selected_type, 'search_type', $langs->trans("Type"), 1, 1);
488
489 // Third party filter
490 print '<br>';
491 print img_picto('', 'category', 'class="pictofixedwidth"');
492 print $formother->select_categories(Categorie::TYPE_CUSTOMER, (int) $selected_catsoc, 'search_categ_soc', 0, $langs->trans("CustomersProspectsCategoriesShort"));
493
494 // Type of third party filter
495 print '&nbsp; &nbsp;';
496 $formcompany = new FormCompany($db);
497 // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on ascending label.
498 $sortparam = getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC');
499 print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, $langs->trans("ThirdPartyType"), 0, 0, '', 0, 0, 0, $sortparam, '', 1);
500
501 print '<br>';
502 print img_picto('', 'company', 'class="pictofixedwidth"');
503 print $form->select_company($selected_soc, 'search_soc', '', $langs->trans("ThirdParty"));
504 print '</td>';
505
506 print '<td colspan="5" class="right">';
507 print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
508 print '</td>';
509
510 print '</tr>';
511
512 // Array header
513 print "<tr class=\"liste_titre\">";
515 $langs->trans("Product"),
516 $_SERVER["PHP_SELF"],
517 "ref",
518 "",
519 $paramslink,
520 "",
521 $sortfield,
522 $sortorder
523 );
525 $langs->trans('Quantity'),
526 $_SERVER["PHP_SELF"],
527 "qty",
528 "",
529 $paramslink,
530 'class="right"',
531 $sortfield,
532 $sortorder
533 );
535 $langs->trans("Percentage"),
536 $_SERVER["PHP_SELF"],
537 "qty",
538 "",
539 $paramslink,
540 'class="right"',
541 $sortfield,
542 $sortorder
543 );
545 $langs->trans('AmountHT'),
546 $_SERVER["PHP_SELF"],
547 "amount",
548 "",
549 $paramslink,
550 'class="right"',
551 $sortfield,
552 $sortorder
553 );
555 $langs->trans("AmountTTC"),
556 $_SERVER["PHP_SELF"],
557 "amount_ttc",
558 "",
559 $paramslink,
560 'class="right"',
561 $sortfield,
562 $sortorder
563 );
565 $langs->trans("Percentage"),
566 $_SERVER["PHP_SELF"],
567 "amount_ttc",
568 "",
569 $paramslink,
570 'class="right"',
571 $sortfield,
572 $sortorder
573 );
574 print "</tr>\n";
575
576 if (count($name)) {
577 foreach ($name as $key => $value) {
578 print '<tr class="oddeven">';
579
580 // Product
581 print "<td>";
582 $fullname = $name[$key];
583 if ($key > 0) {
584 $linkname = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$key.'">'.img_object($langs->trans("ShowProduct"), $type[$key] == 0 ? 'product' : 'service').' '.$fullname.'</a>';
585 } else {
586 $linkname = $langs->trans("PaymentsNotLinkedToProduct");
587 }
588 print $linkname;
589 print "</td>\n";
590
591 // Quantity
592 print '<td class="right">';
593 print price($qty[$key], 1, $langs, 0, 0);
594 print '</td>';
595
596 // Percent;
597 print '<td class="right">'.($qtytotal > 0 ? round(100 * $qty[$key] / $qtytotal, 2).'%' : '&nbsp;').'</td>';
598
599 // Amount w/o VAT
600 print '<td class="right">';
601 /*if ($key > 0) {
602 print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
603 } else {
604 print '<a href="#">';
605 }*/
606 print price($amount_ht[$key]);
607 //print '</a>';
608 print '</td>';
609
610 // Amount with VAT
611 print '<td class="right">';
612 /*if ($key > 0) {
613 print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
614 } else {
615 print '<a href="#">';
616 }*/
617 print price($amount[$key]);
618 //print '</a>';
619 print '</td>';
620
621 // Percent;
622 print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
623
624 // TODO: statistics?
625
626 print "</tr>\n";
627 $i++;
628 }
629
630 // Total
631 print '<tr class="liste_total">';
632 print '<td>'.$langs->trans("Total").'</td>';
633 print '<td class="right">'.$qtytotal.'</td>';
634 print '<td class="right">100%</td>';
635 print '<td class="right">'.price($catotal_ht).'</td>';
636 print '<td class="right">'.price($catotal).'</td>';
637 print '<td class="right">100%</td>';
638 print '</tr>';
639
640 $db->free($result);
641 } else {
642 print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
643 }
644 print "</table>";
645 print '</div>';
646
647 print '</form>';
648} else {
649 // $modecompta != 'CREANCES-DETTES'
650 // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an
651 // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ?
652 // Because there is no way to know this, this report is not relevant.
653 print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant").'<br>';
654}
655
656// End of page
657llxFooter();
658$db->close();
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 categories.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:604
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:126
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:623
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
$date_start
Variables from include:
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
img_next($titlealt='default', $moreatt='')
Show next logo.
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_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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...
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
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.