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