dolibarr  18.0.6
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 = $conf->global->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 = GETPOST('socid', 'int');
56 
57 // Category
58 $selected_cat = (int) GETPOST('search_categ', 'int');
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", 'alpha');
73 
74 
75 // Date range
76 $year = GETPOST("year", 'int');
77 $month = GETPOST("month", 'int');
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 = GETPOST("q", "int") ?GETPOST("q", "int") : 0;
98  if (empty($q)) {
99  // We define date_start and date_end
100  $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->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("CalcModeEngagement");
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 if ($modecompta == 'CREANCES-DETTES') {
249  $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
250  $sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
251  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
252  if ($selected_cat === -2) { // Without any category
253  $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
254  } elseif ($selected_cat) { // Into a specific category
255  $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
256  }
257  $sql .= " WHERE f.fk_statut in (1,2)";
258  $sql .= " AND f.type IN (0,2)";
259  $sql .= " AND f.fk_soc = s.rowid";
260  if ($date_start && $date_end) {
261  $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
262  }
263  if ($selected_cat === -2) { // Without any category
264  $sql .= " AND cs.fk_soc is null";
265  } elseif ($selected_cat) { // Into a specific category
266  $sql .= " AND (c.rowid = ".((int) $selected_cat);
267  if ($subcat) {
268  $sql .= " OR c.fk_parent = ".((int) $selected_cat);
269  }
270  $sql .= ")";
271  $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
272  }
273 } elseif ($modecompta == "RECETTES-DEPENSES") {
274  $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
275  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
276  $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
277  $sql .= ", ".MAIN_DB_PREFIX."paiementfourn as p";
278  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
279  if ($selected_cat === -2) { // Without any category
280  $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
281  } elseif ($selected_cat) { // Into a specific category
282  $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
283  }
284  $sql .= " WHERE p.rowid = pf.fk_paiementfourn";
285  $sql .= " AND pf.fk_facturefourn = f.rowid";
286  $sql .= " AND f.fk_soc = s.rowid";
287  if ($date_start && $date_end) {
288  $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
289  }
290  if ($selected_cat === -2) { // Without any category
291  $sql .= " AND cs.fk_soc is null";
292  } elseif ($selected_cat) { // Into a specific category
293  $sql .= " AND (c.rowid = ".((int) $selected_cat);
294  if ($subcat) {
295  $sql .= " OR c.fk_parent = ".((int) $selected_cat);
296  }
297  $sql .= ")";
298  $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
299  }
300 }
301 if (!empty($search_societe)) {
302  $sql .= natural_search('s.nom', $search_societe);
303 }
304 if (!empty($search_zip)) {
305  $sql .= natural_search('s.zip', $search_zip);
306 }
307 if (!empty($search_town)) {
308  $sql .= natural_search('s.town', $search_town);
309 }
310 if ($search_country > 0) {
311  $sql .= ' AND s.fk_pays = '.((int) $search_country);
312 }
313 $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
314 if ($socid) {
315  $sql .= " AND f.fk_soc = ".((int) $socid);
316 }
317 $sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
318 $sql .= " ORDER BY s.rowid";
319 //echo $sql;
320 
321 $catotal_ht = 0;
322 $catotal = 0;
323 
324 dol_syslog("supplier_turnover_by_thirdparty", LOG_DEBUG);
325 $resql = $db->query($sql);
326 if ($resql) {
327  $num = $db->num_rows($resql);
328  $i = 0;
329  while ($i < $num) {
330  $obj = $db->fetch_object($resql);
331 
332  $amount_ht[$obj->socid] = (empty($obj->amount) ? 0 : $obj->amount);
333  $amount[$obj->socid] = $obj->amount_ttc;
334  $name[$obj->socid] = $obj->name;
335 
336  $address_zip[$obj->socid] = $obj->zip;
337  $address_town[$obj->socid] = $obj->town;
338  $address_pays[$obj->socid] = getCountry($obj->fk_pays);
339 
340  $catotal_ht += (empty($obj->amount) ? 0 : $obj->amount);
341  $catotal += $obj->amount_ttc;
342 
343  $i++;
344  }
345 } else {
346  dol_print_error($db);
347 }
348 
349 // Show array
350 $i = 0;
351 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
352 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
353 // Extra parameters management
354 foreach ($headerparams as $key => $value) {
355  print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
356 }
357 
358 $moreforfilter = '';
359 
360 print '<div class="div-table-responsive">';
361 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
362 
363 // Category filter
364 print '<tr class="liste_titre">';
365 print '<td>';
366 print img_picto('', 'category', 'class="paddingrightonly"');
367 print $formother->select_categories(Categorie::TYPE_SUPPLIER, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
368 print ' ';
369 print $langs->trans("SubCats").'? ';
370 print '<input type="checkbox" name="subcat" value="yes"';
371 if ($subcat) {
372  print ' checked';
373 }
374 print'></td>';
375 print '<td colspan="7" class="right">';
376 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")).'">';
377 print '</td>';
378 print '</tr>';
379 
380 print '<tr class="liste_titre">';
381 print '<td class="liste_titre left">';
382 print '<input class="flat" size="6" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
383 print '</td>';
384 print '<td class="liste_titre left">';
385 print '<input class="flat" size="6" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
386 print '</td>';
387 print '<td class="liste_titre left">';
388 print '<input class="flat" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
389 print '</td>';
390 print '<td class="liste_titre left">';
391 print $form->select_country($search_country, 'search_country');
392 //print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
393 print '</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 '<td class="liste_titre">&nbsp;</td>';
398 print '</tr>';
399 
400 // Array titles
401 print "<tr class='liste_titre'>";
403  $langs->trans("Company"),
404  $_SERVER["PHP_SELF"],
405  "nom",
406  "",
407  $paramslink,
408  "",
409  $sortfield,
410  $sortorder
411 );
413  $langs->trans("Zip"),
414  $_SERVER["PHP_SELF"],
415  "zip",
416  "",
417  $paramslink,
418  "",
419  $sortfield,
420  $sortorder
421 );
423  $langs->trans("Town"),
424  $_SERVER["PHP_SELF"],
425  "town",
426  "",
427  $paramslink,
428  "",
429  $sortfield,
430  $sortorder
431 );
433  $langs->trans("Country"),
434  $_SERVER["PHP_SELF"],
435  "country",
436  "",
437  $paramslink,
438  "",
439  $sortfield,
440  $sortorder
441 );
442 if ($modecompta == 'CREANCES-DETTES') {
444  $langs->trans('AmountHT'),
445  $_SERVER["PHP_SELF"],
446  "amount_ht",
447  "",
448  $paramslink,
449  'class="right"',
450  $sortfield,
451  $sortorder
452  );
453 } else {
455 }
457  $langs->trans("AmountTTC"),
458  $_SERVER["PHP_SELF"],
459  "amount_ttc",
460  "",
461  $paramslink,
462  'class="right"',
463  $sortfield,
464  $sortorder
465 );
467  $langs->trans("Percentage"),
468  $_SERVER["PHP_SELF"],
469  "amount_ttc",
470  "",
471  $paramslink,
472  'class="right"',
473  $sortfield,
474  $sortorder
475 );
477  $langs->trans("OtherStatistics"),
478  $_SERVER["PHP_SELF"],
479  "",
480  "",
481  "",
482  'align="center" width="20%"'
483 );
484 print "</tr>\n";
485 
486 
487 if (count($amount)) {
488  $arrayforsort = $name;
489  // Defining array arrayforsort
490  if ($sortfield == 'nom' && $sortorder == 'asc') {
491  asort($name);
492  $arrayforsort = $name;
493  }
494  if ($sortfield == 'nom' && $sortorder == 'desc') {
495  arsort($name);
496  $arrayforsort = $name;
497  }
498  if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
499  asort($amount_ht);
500  $arrayforsort = $amount_ht;
501  }
502  if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
503  arsort($amount_ht);
504  $arrayforsort = $amount_ht;
505  }
506  if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
507  asort($amount);
508  $arrayforsort = $amount;
509  }
510  if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
511  arsort($amount);
512  $arrayforsort = $amount;
513  }
514  if ($sortfield == 'zip' && $sortorder == 'asc') {
515  asort($address_zip);
516  $arrayforsort = $address_zip;
517  }
518  if ($sortfield == 'zip' && $sortorder == 'desc') {
519  arsort($address_zip);
520  $arrayforsort = $address_zip;
521  }
522  if ($sortfield == 'town' && $sortorder == 'asc') {
523  asort($address_town);
524  $arrayforsort = $address_town;
525  }
526  if ($sortfield == 'town' && $sortorder == 'desc') {
527  arsort($address_town);
528  $arrayforsort = $address_town;
529  }
530  if ($sortfield == 'country' && $sortorder == 'asc') {
531  asort($address_pays);
532  $arrayforsort = $address_town;
533  }
534  if ($sortfield == 'country' && $sortorder == 'desc') {
535  arsort($address_pays);
536  $arrayforsort = $address_town;
537  }
538 
539  foreach ($arrayforsort as $key => $value) {
540  print '<tr class="oddeven">';
541 
542  // Third party
543  $fullname = $name[$key];
544  if ($key > 0) {
545  $thirdparty_static->id = $key;
546  $thirdparty_static->name = $fullname;
547  $thirdparty_static->client = 1;
548  $linkname = $thirdparty_static->getNomUrl(1, 'supplier');
549  } else {
550  $linkname = $langs->trans("PaymentsNotLinkedToInvoice");
551  }
552  print "<td>".$linkname."</td>\n";
553 
554  print '<td>';
555  print $address_zip[$key];
556  print '</td>';
557 
558  print '<td>';
559  print $address_town[$key];
560  print '</td>';
561 
562  print '<td>';
563  print $address_pays[$key];
564  print '</td>';
565 
566  // Amount w/o VAT
567  print '<td class="right">';
568  if ($modecompta != 'CREANCES-DETTES') {
569  if ($key > 0) {
570  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
571  } else {
572  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid=-1">';
573  }
574  } else {
575  if ($key > 0) {
576  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
577  } else {
578  print '<a href="#">';
579  }
580  print price($amount_ht[$key]);
581  }
582  print '</td>';
583 
584  // Amount with VAT
585  print '<td class="right">';
586  if ($modecompta != 'CREANCES-DETTES') {
587  if ($key > 0) {
588  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
589  } else {
590  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?orphelins=1">';
591  }
592  } else {
593  if ($key > 0) {
594  print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
595  } else {
596  print '<a href="#">';
597  }
598  }
599  print price($amount[$key]);
600  print '</a>';
601  print '</td>';
602 
603  // Percent;
604  print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
605 
606  // Other stats
607  print '<td class="center">';
608  if (isModEnabled('supplier_proposal') && $key > 0) {
609  print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"), "stats").'</a>&nbsp;';
610  }
611  if (isModEnabled("supplier_order") && $key > 0) {
612  print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("OrderStats"), "stats").'</a>&nbsp;';
613  }
614  if (isModEnabled("supplier_invoice") && $key > 0) {
615  print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"), "stats").'</a>&nbsp;';
616  }
617  print '</td>';
618  print "</tr>\n";
619  $i++;
620  }
621 
622  // Total
623  print '<tr class="liste_total">';
624  print '<td>'.$langs->trans("Total").'</td>';
625  print '<td>&nbsp;</td>';
626  print '<td>&nbsp;</td>';
627  print '<td>&nbsp;</td>';
628  if ($modecompta != 'CREANCES-DETTES') {
629  print '<td></td>';
630  } else {
631  print '<td class="right">'.price($catotal_ht).'</td>';
632  }
633  print '<td class="right">'.price($catotal).'</td>';
634  print '<td>&nbsp;</td>';
635  print '<td>&nbsp;</td>';
636  print '</tr>';
637 
638  $db->free($result);
639 }
640 
641 print "</table>";
642 print "</div>";
643 
644 print '</form>';
645 
646 // End of page
647 llxFooter();
648 $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 generation of HTML components Only common components must be here.
Classe 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=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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
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:577
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:122
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:596
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...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 for admin users or standard users.
img_next($titlealt='default', $moreatt='')
Show next logo.
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.