dolibarr  20.0.0-beta
supplier_turnover_by_thirdparty.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2020 Maxime Kohlhaas <maxime@atm-consulting.fr>
3  * Copyright (C) 2023 Ferran Marcet <fmarcet@2byte.es>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 // Load Dolibarr environment
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array('companies', 'categories', 'bills', 'compta'));
37 
38 // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
39 $modecompta = getDolGlobalString('ACCOUNTING_MODE');
40 if (GETPOST("modecompta")) {
41  $modecompta = GETPOST("modecompta");
42 }
43 
44 // Sort Order
45 $sortorder = GETPOST("sortorder", 'aZ09comma');
46 $sortfield = GETPOST("sortfield", 'aZ09comma');
47 if (!$sortorder) {
48  $sortorder = "asc";
49 }
50 if (!$sortfield) {
51  $sortfield = "nom";
52 }
53 
54 
55 $socid = GETPOSTINT('socid');
56 
57 // Category
58 $selected_cat = GETPOSTINT('search_categ');
59 $subcat = false;
60 if (GETPOST('subcat', 'alpha') === 'yes') {
61  $subcat = true;
62 }
63 
64 // Hook
65 $hookmanager->initHooks(array('supplierturnoverbythirdpartylist'));
66 
67 
68 // Search Parameters
69 $search_societe = GETPOST("search_societe", 'alpha');
70 $search_zip = GETPOST("search_zip", 'alpha');
71 $search_town = GETPOST("search_town", 'alpha');
72 $search_country = GETPOST("search_country", 'aZ09');
73 
74 
75 // Date range
76 $year = GETPOSTINT("year");
77 $month = GETPOSTINT("month");
78 $date_startyear = GETPOST("date_startyear", 'alpha');
79 $date_startmonth = GETPOST("date_startmonth", 'alpha');
80 $date_startday = GETPOST("date_startday", 'alpha');
81 $date_endyear = GETPOST("date_endyear", 'alpha');
82 $date_endmonth = GETPOST("date_endmonth", 'alpha');
83 $date_endday = GETPOST("date_endday", 'alpha');
84 if (empty($year)) {
85  $year_current = dol_print_date(dol_now(), '%Y');
86  $month_current = dol_print_date(dol_now(), '%m');
87  $year_start = $year_current;
88 } else {
89  $year_current = $year;
90  $month_current = dol_print_date(dol_now(), '%m');
91  $year_start = $year;
92 }
93 $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
94 $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
95 // Quarter
96 if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
97  $q = GETPOSTINT("q") ? GETPOSTINT("q") : 0;
98  if (empty($q)) {
99  // We define date_start and date_end
100  $month_start = GETPOST("month") ? GETPOST("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
101  $year_end = $year_start;
102  $month_end = $month_start;
103  if (!GETPOST("month")) { // If month not forced
104  if (!GETPOST('year') && $month_start > $month_current) {
105  $year_start--;
106  $year_end--;
107  }
108  $month_end = $month_start - 1;
109  if ($month_end < 1) {
110  $month_end = 12;
111  } else {
112  $year_end++;
113  }
114  }
115  $date_start = dol_get_first_day($year_start, $month_start, false);
116  $date_end = dol_get_last_day($year_end, $month_end, false);
117  }
118  if ($q == 1) {
119  $date_start = dol_get_first_day($year_start, 1, false);
120  $date_end = dol_get_last_day($year_start, 3, false);
121  }
122  if ($q == 2) {
123  $date_start = dol_get_first_day($year_start, 4, false);
124  $date_end = dol_get_last_day($year_start, 6, false);
125  }
126  if ($q == 3) {
127  $date_start = dol_get_first_day($year_start, 7, false);
128  $date_end = dol_get_last_day($year_start, 9, false);
129  }
130  if ($q == 4) {
131  $date_start = dol_get_first_day($year_start, 10, false);
132  $date_end = dol_get_last_day($year_start, 12, false);
133  }
134 } else {
135  // TODO We define q
136 }
137 
138 // $date_start and $date_end are defined. We force $year_start and $nbofyear
139 $tmps = dol_getdate($date_start);
140 $year_start = $tmps['year'];
141 $tmpe = dol_getdate($date_end);
142 $year_end = $tmpe['year'];
143 $nbofyear = ($year_end - $year_start) + 1;
144 
145 $commonparams = array();
146 $commonparams['modecompta'] = $modecompta;
147 $commonparams['sortorder'] = $sortorder;
148 $commonparams['sortfield'] = $sortfield;
149 
150 $headerparams = array();
151 $headerparams['date_startyear'] = $date_startyear;
152 $headerparams['date_startmonth'] = $date_startmonth;
153 $headerparams['date_startday'] = $date_startday;
154 $headerparams['date_endyear'] = $date_endyear;
155 $headerparams['date_endmonth'] = $date_endmonth;
156 $headerparams['date_endday'] = $date_endday;
157 
158 $tableparams = array();
159 $tableparams['search_categ'] = $selected_cat;
160 $tableparams['search_societe'] = $search_societe;
161 $tableparams['search_zip'] = $search_zip;
162 $tableparams['search_town'] = $search_town;
163 $tableparams['search_country'] = $search_country;
164 $tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
165 
166 // Adding common parameters
167 $allparams = array_merge($commonparams, $headerparams, $tableparams);
168 $headerparams = array_merge($commonparams, $headerparams);
169 $tableparams = array_merge($commonparams, $tableparams);
170 
171 $paramslink = '';
172 foreach ($allparams as $key => $value) {
173  $paramslink .= '&'.$key.'='.$value;
174 }
175 
176 // Security check
177 if ($user->socid > 0) {
178  $socid = $user->socid;
179 }
180 if (isModEnabled('comptabilite')) {
181  $result = restrictedArea($user, 'compta', '', '', 'resultat');
182 }
183 if (isModEnabled('accounting')) {
184  $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
185 }
186 
187 
188 /*
189  * View
190  */
191 
192 llxHeader();
193 
194 $form = new Form($db);
195 $thirdparty_static = new Societe($db);
196 $formother = new FormOther($db);
197 
198 // TODO Report from bookkeeping not yet available, so we switch on report on business events
199 if ($modecompta == "BOOKKEEPING") {
200  $modecompta = "CREANCES-DETTES";
201 }
202 if ($modecompta == "BOOKKEEPINGCOLLECTED") {
203  $modecompta = "RECETTES-DEPENSES";
204 }
205 
206 // Show report header
207 if ($modecompta == "CREANCES-DETTES") {
208  $name = $langs->trans("PurchaseTurnover").', '.$langs->trans("ByThirdParties");
209  $calcmode = $langs->trans("CalcModeDebt");
210  //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
211  $description = $langs->trans("RulesPurchaseTurnoverDue");
212  //$exportlink=$langs->trans("NotYetAvailable");
213 } elseif ($modecompta == "RECETTES-DEPENSES") {
214  $name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByThirdParties");
215  $calcmode = $langs->trans("CalcModePayment");
216  //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
217  $description = $langs->trans("RulesPurchaseTurnoverIn");
218  //$exportlink=$langs->trans("NotYetAvailable");
219 } elseif ($modecompta == "BOOKKEEPING") {
220  // TODO
221 } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
222  // TODO
223 }
224 $builddate = dol_now();
225 $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
226 $period .= ' - ';
227 $period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
228 if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) {
229  $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>';
230 } else {
231  $periodlink = '';
232 }
233 
234 $exportlink = '';
235 
236 report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
237 
238 if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
239  print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
240 }
241 
242 // Show Array
243 $catotal = 0;
244 $catotal_ht = 0;
245 $name = array();
246 $amount = array();
247 $amount_ht = array();
248 $address_zip = array();
249 $address_town = array();
250 $address_pays = array();
251 if ($modecompta == 'CREANCES-DETTES') {
252  $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
253  $sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
254  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
255  if ($selected_cat === -2) { // Without any category
256  $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
257  } elseif ($selected_cat) { // Into a specific category
258  $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
259  }
260  $sql .= " WHERE f.fk_statut in (1,2)";
261  $sql .= " AND f.type IN (0,2)";
262  $sql .= " AND f.fk_soc = s.rowid";
263  if ($date_start && $date_end) {
264  $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
265  }
266  if ($selected_cat === -2) { // Without any category
267  $sql .= " AND cs.fk_soc is null";
268  } elseif ($selected_cat) { // Into a specific category
269  $sql .= " AND (c.rowid = ".((int) $selected_cat);
270  if ($subcat) {
271  $sql .= " OR c.fk_parent = ".((int) $selected_cat);
272  }
273  $sql .= ")";
274  $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
275  }
276 } elseif ($modecompta == "RECETTES-DEPENSES") {
277  $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
278  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
279  $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
280  $sql .= ", ".MAIN_DB_PREFIX."paiementfourn as p";
281  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
282  if ($selected_cat === -2) { // Without any category
283  $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
284  } elseif ($selected_cat) { // Into a specific category
285  $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
286  }
287  $sql .= " WHERE p.rowid = pf.fk_paiementfourn";
288  $sql .= " AND pf.fk_facturefourn = f.rowid";
289  $sql .= " AND f.fk_soc = s.rowid";
290  if ($date_start && $date_end) {
291  $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
292  }
293  if ($selected_cat === -2) { // Without any category
294  $sql .= " AND cs.fk_soc is null";
295  } elseif ($selected_cat) { // Into a specific category
296  $sql .= " AND (c.rowid = ".((int) $selected_cat);
297  if ($subcat) {
298  $sql .= " OR c.fk_parent = ".((int) $selected_cat);
299  }
300  $sql .= ")";
301  $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
302  }
303 }
304 if (!empty($search_societe)) {
305  $sql .= natural_search('s.nom', $search_societe);
306 }
307 if (!empty($search_zip)) {
308  $sql .= natural_search('s.zip', $search_zip);
309 }
310 if (!empty($search_town)) {
311  $sql .= natural_search('s.town', $search_town);
312 }
313 if ($search_country > 0) {
314  $sql .= ' AND s.fk_pays = '.((int) $search_country);
315 }
316 $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
317 if ($socid) {
318  $sql .= " AND f.fk_soc = ".((int) $socid);
319 }
320 $sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
321 $sql .= " ORDER BY s.rowid";
322 //echo $sql;
323 
324 $catotal_ht = 0;
325 $catotal = 0;
326 
327 dol_syslog("supplier_turnover_by_thirdparty", LOG_DEBUG);
328 $resql = $db->query($sql);
329 if ($resql) {
330  $num = $db->num_rows($resql);
331  $i = 0;
332  while ($i < $num) {
333  $obj = $db->fetch_object($resql);
334 
335  $amount_ht[$obj->socid] = (empty($obj->amount) ? 0 : $obj->amount);
336  $amount[$obj->socid] = $obj->amount_ttc;
337  $name[$obj->socid] = $obj->name;
338 
339  $address_zip[$obj->socid] = $obj->zip;
340  $address_town[$obj->socid] = $obj->town;
341  $address_pays[$obj->socid] = getCountry($obj->fk_pays);
342 
343  $catotal_ht += (empty($obj->amount) ? 0 : $obj->amount);
344  $catotal += $obj->amount_ttc;
345 
346  $i++;
347  }
348 } else {
349  dol_print_error($db);
350 }
351 
352 // Show array
353 $i = 0;
354 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
355 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
356 // Extra parameters management
357 foreach ($headerparams as $key => $value) {
358  print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
359 }
360 
361 $moreforfilter = '';
362 
363 print '<div class="div-table-responsive">';
364 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
365 
366 // Category filter
367 print '<tr class="liste_titre">';
368 print '<td>';
369 print img_picto('', 'category', 'class="paddingrightonly"');
370 print $formother->select_categories(Categorie::TYPE_SUPPLIER, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
371 print ' ';
372 print $langs->trans("SubCats").'? ';
373 print '<input type="checkbox" name="subcat" value="yes"';
374 if ($subcat) {
375  print ' checked';
376 }
377 print'></td>';
378 print '<td colspan="7" class="right">';
379 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")).'">';
380 print '</td>';
381 print '</tr>';
382 
383 print '<tr class="liste_titre">';
384 print '<td class="liste_titre left">';
385 print '<input class="flat" size="6" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
386 print '</td>';
387 print '<td class="liste_titre left">';
388 print '<input class="flat" size="6" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
389 print '</td>';
390 print '<td class="liste_titre left">';
391 print '<input class="flat" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
392 print '</td>';
393 print '<td class="liste_titre left">';
394 print $form->select_country($search_country, 'search_country');
395 //print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
396 print '</td>';
397 print '<td class="liste_titre">&nbsp;</td>';
398 print '<td class="liste_titre">&nbsp;</td>';
399 print '<td class="liste_titre">&nbsp;</td>';
400 print '<td class="liste_titre">&nbsp;</td>';
401 print '</tr>';
402 
403 // Array titles
404 print "<tr class='liste_titre'>";
406  $langs->trans("Company"),
407  $_SERVER["PHP_SELF"],
408  "nom",
409  "",
410  $paramslink,
411  "",
412  $sortfield,
413  $sortorder
414 );
416  $langs->trans("Zip"),
417  $_SERVER["PHP_SELF"],
418  "zip",
419  "",
420  $paramslink,
421  "",
422  $sortfield,
423  $sortorder
424 );
426  $langs->trans("Town"),
427  $_SERVER["PHP_SELF"],
428  "town",
429  "",
430  $paramslink,
431  "",
432  $sortfield,
433  $sortorder
434 );
436  $langs->trans("Country"),
437  $_SERVER["PHP_SELF"],
438  "country",
439  "",
440  $paramslink,
441  "",
442  $sortfield,
443  $sortorder
444 );
445 if ($modecompta == 'CREANCES-DETTES') {
447  $langs->trans('AmountHT'),
448  $_SERVER["PHP_SELF"],
449  "amount_ht",
450  "",
451  $paramslink,
452  'class="right"',
453  $sortfield,
454  $sortorder
455  );
456 } else {
458 }
460  $langs->trans("AmountTTC"),
461  $_SERVER["PHP_SELF"],
462  "amount_ttc",
463  "",
464  $paramslink,
465  'class="right"',
466  $sortfield,
467  $sortorder
468 );
470  $langs->trans("Percentage"),
471  $_SERVER["PHP_SELF"],
472  "amount_ttc",
473  "",
474  $paramslink,
475  'class="right"',
476  $sortfield,
477  $sortorder
478 );
480  $langs->trans("OtherStatistics"),
481  $_SERVER["PHP_SELF"],
482  "",
483  "",
484  "",
485  'align="center" width="20%"'
486 );
487 print "</tr>\n";
488 
489 
490 if (count($amount)) {
491  $arrayforsort = $name;
492  // Defining array arrayforsort
493  if ($sortfield == 'nom' && $sortorder == 'asc') {
494  asort($name);
495  $arrayforsort = $name;
496  }
497  if ($sortfield == 'nom' && $sortorder == 'desc') {
498  arsort($name);
499  $arrayforsort = $name;
500  }
501  if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
502  asort($amount_ht);
503  $arrayforsort = $amount_ht;
504  }
505  if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
506  arsort($amount_ht);
507  $arrayforsort = $amount_ht;
508  }
509  if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
510  asort($amount);
511  $arrayforsort = $amount;
512  }
513  if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
514  arsort($amount);
515  $arrayforsort = $amount;
516  }
517  if ($sortfield == 'zip' && $sortorder == 'asc') {
518  asort($address_zip);
519  $arrayforsort = $address_zip;
520  }
521  if ($sortfield == 'zip' && $sortorder == 'desc') {
522  arsort($address_zip);
523  $arrayforsort = $address_zip;
524  }
525  if ($sortfield == 'town' && $sortorder == 'asc') {
526  asort($address_town);
527  $arrayforsort = $address_town;
528  }
529  if ($sortfield == 'town' && $sortorder == 'desc') {
530  arsort($address_town);
531  $arrayforsort = $address_town;
532  }
533  if ($sortfield == 'country' && $sortorder == 'asc') {
534  asort($address_pays);
535  $arrayforsort = $address_town;
536  }
537  if ($sortfield == 'country' && $sortorder == 'desc') {
538  arsort($address_pays);
539  $arrayforsort = $address_town;
540  }
541 
542  foreach ($arrayforsort as $key => $value) {
543  print '<tr class="oddeven">';
544 
545  // Third party
546  $fullname = $name[$key];
547  if ($key > 0) {
548  $thirdparty_static->id = $key;
549  $thirdparty_static->name = $fullname;
550  $thirdparty_static->client = 1;
551  $linkname = $thirdparty_static->getNomUrl(1, 'supplier');
552  } else {
553  $linkname = $langs->trans("PaymentsNotLinkedToInvoice");
554  }
555  print "<td>".$linkname."</td>\n";
556 
557  print '<td>';
558  print $address_zip[$key];
559  print '</td>';
560 
561  print '<td>';
562  print $address_town[$key];
563  print '</td>';
564 
565  print '<td>';
566  print $address_pays[$key];
567  print '</td>';
568 
569  // Amount w/o VAT
570  print '<td class="right">';
571  if ($modecompta != 'CREANCES-DETTES') {
572  if ($key > 0) {
573  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
574  } else {
575  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid=-1">';
576  }
577  } else {
578  if ($key > 0) {
579  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
580  } else {
581  print '<a href="#">';
582  }
583  print price($amount_ht[$key]);
584  }
585  print '</td>';
586 
587  // Amount with VAT
588  print '<td class="right">';
589  if ($modecompta != 'CREANCES-DETTES') {
590  if ($key > 0) {
591  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
592  } else {
593  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?orphelins=1">';
594  }
595  } else {
596  if ($key > 0) {
597  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
598  } else {
599  print '<a href="#">';
600  }
601  }
602  print price($amount[$key]);
603  print '</a>';
604  print '</td>';
605 
606  // Percent;
607  print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
608 
609  // Other stats
610  print '<td class="center">';
611  if (isModEnabled('supplier_proposal') && $key > 0) {
612  print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"), "stats").'</a>&nbsp;';
613  }
614  if (isModEnabled("supplier_order") && $key > 0) {
615  print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("OrderStats"), "stats").'</a>&nbsp;';
616  }
617  if (isModEnabled("supplier_invoice") && $key > 0) {
618  print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"), "stats").'</a>&nbsp;';
619  }
620  print '</td>';
621  print "</tr>\n";
622  $i++;
623  }
624 
625  // Total
626  print '<tr class="liste_total">';
627  print '<td>'.$langs->trans("Total").'</td>';
628  print '<td>&nbsp;</td>';
629  print '<td>&nbsp;</td>';
630  print '<td>&nbsp;</td>';
631  if ($modecompta != 'CREANCES-DETTES') {
632  print '<td></td>';
633  } else {
634  print '<td class="right">'.price($catotal_ht).'</td>';
635  }
636  print '<td class="right">'.price($catotal).'</td>';
637  print '<td>&nbsp;</td>';
638  print '<td>&nbsp;</td>';
639  print '</tr>';
640 
641  $db->free($result);
642 }
643 
644 print "</table>";
645 print "</div>";
646 
647 print '</form>';
648 
649 // End of page
650 llxFooter();
651 $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:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
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.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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:745
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:595
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:124
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:614
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)
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.