dolibarr 21.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-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
299$builddate = 0;
300$calcmode = '';
301$name = '';
302$period = '';
303$periodlink = '';
304
305report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
306
307if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
308 print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, '1');
309}
310
311
312$name = array();
313
314// SQL request
315$catotal = 0;
316$catotal_ht = 0;
317$qtytotal = 0;
318
319if ($modecompta == 'CREANCES-DETTES') {
320 $sql = "SELECT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,";
321 $sql .= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,";
322 $sql .= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty";
323
324 $parameters = array();
325 $hookmanager->executeHooks('printFieldListSelect', $parameters);
326 $sql .= $hookmanager->resPrint;
327
328 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
329 $sql .= ",".MAIN_DB_PREFIX."facturedet as l";
330 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
331 if ($typent_id > 0) {
332 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)";
333 }
334 $parameters = array();
335 $hookmanager->executeHooks('printFieldListFrom', $parameters);
336 $sql .= $hookmanager->resPrint;
337
338 $sql .= " WHERE l.fk_facture = f.rowid";
339 $sql .= " AND f.fk_statut in (1,2)";
340 $sql .= " AND l.product_type in (0,1)";
341 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
342 $sql .= " AND f.type IN (0,1,2,5)";
343 } else {
344 $sql .= " AND f.type IN (0,1,2,3,5)";
345 }
346 if ($date_start && $date_end) {
347 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
348 }
349 if ($selected_type >= 0) {
350 $sql .= " AND l.product_type = ".((int) $selected_type);
351 }
352
353 // Search for tag/category ($searchCategoryProductList is an array of ID)
354 $searchCategoryProductOperator = -1;
355 $searchCategoryProductList = array($selected_cat);
356 if ($subcat) {
357 $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1);
358 $searchCategoryProductList = array();
359 foreach ($TListOfCats as $key => $cat) {
360 $searchCategoryProductList[] = $cat['id'];
361 }
362 }
363 if (!empty($searchCategoryProductList)) {
364 $searchCategoryProductSqlList = array();
365 $listofcategoryid = '';
366 foreach ($searchCategoryProductList as $searchCategoryProduct) {
367 if (intval($searchCategoryProduct) == -2) {
368 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE l.fk_product = ck.fk_product)";
369 } elseif (intval($searchCategoryProduct) > 0) {
370 if ($searchCategoryProductOperator == 0) {
371 $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).")";
372 } else {
373 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
374 }
375 }
376 }
377 if ($listofcategoryid) {
378 $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)."))";
379 }
380 if ($searchCategoryProductOperator == 1) {
381 if (!empty($searchCategoryProductSqlList)) {
382 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
383 }
384 } else {
385 if (!empty($searchCategoryProductSqlList)) {
386 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
387 }
388 }
389 }
390
391 // Search for tag/category ($searchCategorySocieteList is an array of ID)
392 $searchCategorySocieteOperator = -1;
393 $searchCategorySocieteList = array($selected_catsoc);
394 if (!empty($searchCategorySocieteList)) {
395 $searchCategorySocieteSqlList = array();
396 $listofcategoryid = '';
397 foreach ($searchCategorySocieteList as $searchCategorySociete) {
398 if (intval($searchCategorySociete) == -2) {
399 $searchCategorySocieteSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE f.fk_soc = cs.fk_soc)";
400 } elseif (intval($searchCategorySociete) > 0) {
401 if ($searchCategorySocieteOperator == 0) {
402 $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).")";
403 } else {
404 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySociete);
405 }
406 }
407 }
408 if ($listofcategoryid) {
409 $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)."))";
410 }
411 if ($searchCategorySocieteOperator == 1) {
412 if (!empty($searchCategorySocieteSqlList)) {
413 $sql .= " AND (".implode(' OR ', $searchCategorySocieteSqlList).")";
414 }
415 } else {
416 if (!empty($searchCategorySocieteSqlList)) {
417 $sql .= " AND (".implode(' AND ', $searchCategorySocieteSqlList).")";
418 }
419 }
420 }
421
422 if ($selected_soc > 0) {
423 $sql .= " AND f.fk_soc = ".((int) $selected_soc);
424 }
425
426 if ($typent_id > 0) {
427 $sql .= " AND soc.fk_typent = ".((int) $typent_id);
428 }
429
430 $sql .= " AND f.entity IN (".getEntity('invoice').")";
431
432 $parameters = array();
433 $hookmanager->executeHooks('printFieldListWhere', $parameters);
434 $sql .= $hookmanager->resPrint;
435
436 $sql .= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type";
437 $sql .= $db->order($sortfield, $sortorder);
438
439 dol_syslog("cabyprodserv", LOG_DEBUG);
440 $result = $db->query($sql);
441
442 $amount_ht = array();
443 $amount = array();
444 $qty = array();
445 if ($result) {
446 $num = $db->num_rows($result);
447 $i = 0;
448 while ($i < $num) {
449 $obj = $db->fetch_object($result);
450
451 $amount_ht[$obj->rowid] = $obj->amount;
452 $amount[$obj->rowid] = $obj->amount_ttc;
453 $qty[$obj->rowid] = $obj->qty;
454 $name[$obj->rowid] = $obj->ref.'&nbsp;-&nbsp;'.$obj->label;
455 $type[$obj->rowid] = $obj->product_type;
456 $catotal_ht += $obj->amount;
457 $catotal += $obj->amount_ttc;
458 $qtytotal += $obj->qty;
459 $i++;
460 }
461 } else {
462 dol_print_error($db);
463 }
464
465 // Show Array
466 $i = 0;
467 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
468 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
469 // Extra parameters management
470 foreach ($headerparams as $key => $value) {
471 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
472 }
473
474 $moreforfilter = '';
475
476 print '<div class="div-table-responsive">';
477 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
478
479 // Category filter
480 print '<tr class="liste_titre">';
481 print '<td>';
482 print img_picto('', 'category', 'class="pictofixedwidth"');
483 print $formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
484 print ' ';
485 print '<input type="checkbox" class="marginleft" id="subcat" name="subcat" value="yes"';
486 if ($subcat) {
487 print ' checked';
488 }
489 print '>';
490 print '<label for="subcat" class="marginrightonly">'.$langs->trans("SubCats").'?</label>';
491 // type filter (produit/service)
492 $form->select_type_of_lines($selected_type, 'search_type', $langs->trans("Type"), 1, 1);
493
494 // Third party filter
495 print '<br>';
496 print img_picto('', 'category', 'class="pictofixedwidth"');
497 print $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_catsoc, 'search_categ_soc', 0, $langs->trans("CustomersProspectsCategoriesShort"));
498
499 // Type of third party filter
500 print '&nbsp; &nbsp;';
501 $formcompany = new FormCompany($db);
502 // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on ascending label.
503 $sortparam = getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC');
504 print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, $langs->trans("ThirdPartyType"), 0, 0, '', 0, 0, 0, $sortparam, '', 1);
505
506 print '<br>';
507 print img_picto('', 'company', 'class="pictofixedwidth"');
508 print $form->select_company($selected_soc, 'search_soc', '', $langs->trans("ThirdParty"));
509 print '</td>';
510
511 print '<td colspan="5" class="right">';
512 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")).'">';
513 print '</td>';
514
515 print '</tr>';
516
517 // Array header
518 print "<tr class=\"liste_titre\">";
520 $langs->trans("Product"),
521 $_SERVER["PHP_SELF"],
522 "ref",
523 "",
524 $paramslink,
525 "",
526 $sortfield,
527 $sortorder
528 );
530 $langs->trans('Quantity'),
531 $_SERVER["PHP_SELF"],
532 "qty",
533 "",
534 $paramslink,
535 'class="right"',
536 $sortfield,
537 $sortorder
538 );
540 $langs->trans("Percentage"),
541 $_SERVER["PHP_SELF"],
542 "qty",
543 "",
544 $paramslink,
545 'class="right"',
546 $sortfield,
547 $sortorder
548 );
550 $langs->trans('AmountHT'),
551 $_SERVER["PHP_SELF"],
552 "amount",
553 "",
554 $paramslink,
555 'class="right"',
556 $sortfield,
557 $sortorder
558 );
560 $langs->trans("AmountTTC"),
561 $_SERVER["PHP_SELF"],
562 "amount_ttc",
563 "",
564 $paramslink,
565 'class="right"',
566 $sortfield,
567 $sortorder
568 );
570 $langs->trans("Percentage"),
571 $_SERVER["PHP_SELF"],
572 "amount_ttc",
573 "",
574 $paramslink,
575 'class="right"',
576 $sortfield,
577 $sortorder
578 );
579 print "</tr>\n";
580
581 if (count($name)) {
582 foreach ($name as $key => $value) {
583 print '<tr class="oddeven">';
584
585 // Product
586 print "<td>";
587 $fullname = $name[$key];
588 if ($key > 0) {
589 $linkname = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$key.'">'.img_object($langs->trans("ShowProduct"), $type[$key] == 0 ? 'product' : 'service').' '.$fullname.'</a>';
590 } else {
591 $linkname = $langs->trans("PaymentsNotLinkedToProduct");
592 }
593 print $linkname;
594 print "</td>\n";
595
596 // Quantity
597 print '<td class="right">';
598 print price($qty[$key], 1, $langs, 0, 0);
599 print '</td>';
600
601 // Percent;
602 print '<td class="right">'.($qtytotal > 0 ? round(100 * $qty[$key] / $qtytotal, 2).'%' : '&nbsp;').'</td>';
603
604 // Amount w/o VAT
605 print '<td class="right">';
606 /*if ($key > 0) {
607 print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
608 } else {
609 print '<a href="#">';
610 }*/
611 print price($amount_ht[$key]);
612 //print '</a>';
613 print '</td>';
614
615 // Amount with VAT
616 print '<td class="right">';
617 /*if ($key > 0) {
618 print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
619 } else {
620 print '<a href="#">';
621 }*/
622 print price($amount[$key]);
623 //print '</a>';
624 print '</td>';
625
626 // Percent;
627 print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
628
629 // TODO: statistics?
630
631 print "</tr>\n";
632 $i++;
633 }
634
635 // Total
636 print '<tr class="liste_total">';
637 print '<td>'.$langs->trans("Total").'</td>';
638 print '<td class="right">'.$qtytotal.'</td>';
639 print '<td class="right">100%</td>';
640 print '<td class="right">'.price($catotal_ht).'</td>';
641 print '<td class="right">'.price($catotal).'</td>';
642 print '<td class="right">100%</td>';
643 print '</tr>';
644
645 $db->free($result);
646 } else {
647 print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
648 }
649 print "</table>";
650 print '</div>';
651
652 print '</form>';
653} else {
654 // $modecompta != 'CREANCES-DETTES'
655 // "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
656 // 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 ?
657 // Because there is no way to know this, this report is not relevant.
658 print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant").'<br>';
659}
660
661// End of page
662llxFooter();
663$db->close();
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
llxFooter()
Footer empty.
Definition document.php:107
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_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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.
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.