dolibarr 21.0.3
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-2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
7 * Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com>
8 * Copyright (C) 2024 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';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
36require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37
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
263
264// Show report header
265if ($modecompta == "CREANCES-DETTES") {
266 $name = $langs->trans("Turnover").', '.$langs->trans("ByProductsAndServices");
267 $calcmode = $langs->trans("CalcModeDebt");
268 //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
269
270 $description = $langs->trans("RulesCADue");
271 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
272 $description .= $langs->trans("DepositsAreNotIncluded");
273 } else {
274 $description .= $langs->trans("DepositsAreIncluded");
275 }
276 $builddate = dol_now();
277} elseif ($modecompta == "RECETTES-DEPENSES") {
278 $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices");
279 $calcmode = $langs->trans("CalcModePayment");
280 //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
281
282 $description = $langs->trans("RulesCAIn");
283 $description .= $langs->trans("DepositsAreIncluded");
284
285 $builddate = dol_now();
286} // elseif ($modecompta == "BOOKKEEPING") {
287// } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
288// }
289
290$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
291$period .= ' - ';
292$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
293if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) {
294 $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>';
295} else {
296 $periodlink = '';
297}
298
299report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
300
301if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
302 print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, '1');
303}
304
305
306$name = array();
307
308// SQL request
309$catotal = 0;
310$catotal_ht = 0;
311$qtytotal = 0;
312
313if ($modecompta == 'CREANCES-DETTES') {
314 $sql = "SELECT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,";
315 $sql .= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,";
316 $sql .= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty";
317
318 $parameters = array();
319 $hookmanager->executeHooks('printFieldListSelect', $parameters);
320 $sql .= $hookmanager->resPrint;
321
322 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
323 $sql .= ",".MAIN_DB_PREFIX."facturedet as l";
324 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
325 if ($typent_id > 0) {
326 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)";
327 }
328 $parameters = array();
329 $hookmanager->executeHooks('printFieldListFrom', $parameters);
330 $sql .= $hookmanager->resPrint;
331
332 $sql .= " WHERE l.fk_facture = f.rowid";
333 $sql .= " AND 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 = -1;
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 = -1;
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($sortfield, $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 if ($result) {
440 $num = $db->num_rows($result);
441 $i = 0;
442 while ($i < $num) {
443 $obj = $db->fetch_object($result);
444
445 $amount_ht[$obj->rowid] = $obj->amount;
446 $amount[$obj->rowid] = $obj->amount_ttc;
447 $qty[$obj->rowid] = $obj->qty;
448 $name[$obj->rowid] = $obj->ref.'&nbsp;-&nbsp;'.$obj->label;
449 $type[$obj->rowid] = $obj->product_type;
450 $catotal_ht += $obj->amount;
451 $catotal += $obj->amount_ttc;
452 $qtytotal += $obj->qty;
453 $i++;
454 }
455 } else {
456 dol_print_error($db);
457 }
458
459 // Show Array
460 $i = 0;
461 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
462 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
463 // Extra parameters management
464 foreach ($headerparams as $key => $value) {
465 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
466 }
467
468 $moreforfilter = '';
469
470 print '<div class="div-table-responsive">';
471 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
472
473 // Category filter
474 print '<tr class="liste_titre">';
475 print '<td>';
476 print img_picto('', 'category', 'class="pictofixedwidth"');
477 print $formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
478 print ' ';
479 print '<input type="checkbox" class="marginleft" id="subcat" name="subcat" value="yes"';
480 if ($subcat) {
481 print ' checked';
482 }
483 print '>';
484 print '<label for="subcat" class="marginrightonly">'.$langs->trans("SubCats").'?</label>';
485 // type filter (produit/service)
486 $form->select_type_of_lines($selected_type, 'search_type', $langs->trans("Type"), 1, 1);
487
488 // Third party filter
489 print '<br>';
490 print img_picto('', 'category', 'class="pictofixedwidth"');
491 print $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_catsoc, 'search_categ_soc', 0, $langs->trans("CustomersProspectsCategoriesShort"));
492
493 // Type of third party filter
494 print '&nbsp; &nbsp;';
495 $formcompany = new FormCompany($db);
496 // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on ascending label.
497 $sortparam = getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC');
498 print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, $langs->trans("ThirdPartyType"), 0, 0, '', 0, 0, 0, $sortparam, '', 1);
499
500 print '<br>';
501 print img_picto('', 'company', 'class="pictofixedwidth"');
502 print $form->select_company($selected_soc, 'search_soc', '', $langs->trans("ThirdParty"));
503 print '</td>';
504
505 print '<td colspan="5" class="right">';
506 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")).'">';
507 print '</td>';
508
509 print '</tr>';
510
511 // Array header
512 print "<tr class=\"liste_titre\">";
514 $langs->trans("Product"),
515 $_SERVER["PHP_SELF"],
516 "ref",
517 "",
518 $paramslink,
519 "",
520 $sortfield,
521 $sortorder
522 );
524 $langs->trans('Quantity'),
525 $_SERVER["PHP_SELF"],
526 "qty",
527 "",
528 $paramslink,
529 'class="right"',
530 $sortfield,
531 $sortorder
532 );
534 $langs->trans("Percentage"),
535 $_SERVER["PHP_SELF"],
536 "qty",
537 "",
538 $paramslink,
539 'class="right"',
540 $sortfield,
541 $sortorder
542 );
544 $langs->trans('AmountHT'),
545 $_SERVER["PHP_SELF"],
546 "amount",
547 "",
548 $paramslink,
549 'class="right"',
550 $sortfield,
551 $sortorder
552 );
554 $langs->trans("AmountTTC"),
555 $_SERVER["PHP_SELF"],
556 "amount_ttc",
557 "",
558 $paramslink,
559 'class="right"',
560 $sortfield,
561 $sortorder
562 );
564 $langs->trans("Percentage"),
565 $_SERVER["PHP_SELF"],
566 "amount_ttc",
567 "",
568 $paramslink,
569 'class="right"',
570 $sortfield,
571 $sortorder
572 );
573 print "</tr>\n";
574
575 if (count($name)) {
576 foreach ($name as $key => $value) {
577 print '<tr class="oddeven">';
578
579 // Product
580 print "<td>";
581 $fullname = $name[$key];
582 if ($key > 0) {
583 $linkname = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$key.'">'.img_object($langs->trans("ShowProduct"), $type[$key] == 0 ? 'product' : 'service').' '.$fullname.'</a>';
584 } else {
585 $linkname = $langs->trans("PaymentsNotLinkedToProduct");
586 }
587 print $linkname;
588 print "</td>\n";
589
590 // Quantity
591 print '<td class="right">';
592 print price($qty[$key], 1, $langs, 0, 0);
593 print '</td>';
594
595 // Percent;
596 print '<td class="right">'.($qtytotal > 0 ? round(100 * $qty[$key] / $qtytotal, 2).'%' : '&nbsp;').'</td>';
597
598 // Amount w/o VAT
599 print '<td class="right">';
600 /*if ($key > 0) {
601 print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
602 } else {
603 print '<a href="#">';
604 }*/
605 print price($amount_ht[$key]);
606 //print '</a>';
607 print '</td>';
608
609 // Amount with VAT
610 print '<td class="right">';
611 /*if ($key > 0) {
612 print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
613 } else {
614 print '<a href="#">';
615 }*/
616 print price($amount[$key]);
617 //print '</a>';
618 print '</td>';
619
620 // Percent;
621 print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
622
623 // TODO: statistics?
624
625 print "</tr>\n";
626 $i++;
627 }
628
629 // Total
630 print '<tr class="liste_total">';
631 print '<td>'.$langs->trans("Total").'</td>';
632 print '<td class="right">'.$qtytotal.'</td>';
633 print '<td class="right">100%</td>';
634 print '<td class="right">'.price($catotal_ht).'</td>';
635 print '<td class="right">'.price($catotal).'</td>';
636 print '<td class="right">100%</td>';
637 print '</tr>';
638
639 $db->free($result);
640 } else {
641 print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
642 }
643 print "</table>";
644 print '</div>';
645
646 print '</form>';
647} else {
648 // $modecompta != 'CREANCES-DETTES'
649 // "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
650 // 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 ?
651 // Because there is no way to know this, this report is not relevant.
652 print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant").'<br>';
653}
654
655// End of page
656llxFooter();
657$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
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:71
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 permettant la generation de composants html autre 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:600
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:619
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...
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)
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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_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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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.