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