dolibarr 21.0.0-alpha
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
26require '../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/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');
40if (GETPOST("modecompta")) {
41 $modecompta = GETPOST("modecompta");
42}
43
44// Sort Order
45$sortorder = GETPOST("sortorder", 'aZ09comma');
46$sortfield = GETPOST("sortfield", 'aZ09comma');
47if (!$sortorder) {
48 $sortorder = "asc";
49}
50if (!$sortfield) {
51 $sortfield = "nom";
52}
53
54
55$socid = GETPOSTINT('socid');
56
57// Category
58$selected_cat = GETPOSTINT('search_categ');
59$subcat = false;
60if (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$date_startyear = GETPOST("date_startyear", 'alpha');
75$date_startmonth = GETPOST("date_startmonth", 'alpha');
76$date_startday = GETPOST("date_startday", 'alpha');
77$date_endyear = GETPOST("date_endyear", 'alpha');
78$date_endmonth = GETPOST("date_endmonth", 'alpha');
79$date_endday = GETPOST("date_endday", 'alpha');
80
81$nbofyear = 1;
82
83// Date range
84$year = GETPOSTINT("year");
85$month = GETPOSTINT("month");
86if (empty($year)) {
87 $year_current = (int) dol_print_date(dol_now(), "%Y");
88 $month_current = (int) dol_print_date(dol_now(), "%m");
89 $year_start = $year_current - ($nbofyear - 1);
90} else {
91 $year_current = $year;
92 $month_current = (int) dol_print_date(dol_now(), "%m");
93 $year_start = $year - $nbofyear + (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
94}
95$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); // We use timezone of server so report is same from everywhere
96$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear, 'tzserver'); // We use timezone of server so report is same from everywhere
97
98// We define date_start and date_end
99if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
100 $q = GETPOSTINT("q");
101 if (empty($q)) {
102 // We define date_start and date_end
103 $year_end = $year_start + $nbofyear - (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
104 $month_start = GETPOSTISSET("month") ? GETPOSTINT("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
105 if (!GETPOST("month")) { // If month not forced
106 if (!$year && $month_start > $month_current) {
107 $year_start--;
108 $year_end--;
109 }
110 $month_end = $month_start - 1;
111 if ($month_end < 1) {
112 $month_end = 12;
113 }
114 } else {
115 $month_end = $month_start;
116 }
117 $date_start = dol_get_first_day($year_start, $month_start, false);
118 $date_end = dol_get_last_day($year_end, $month_end, false);
119 }
120 if ($q == 1) {
121 $date_start = dol_get_first_day($year_start, 1, false);
122 $date_end = dol_get_last_day($year_start, 3, false);
123 }
124 if ($q == 2) {
125 $date_start = dol_get_first_day($year_start, 4, false);
126 $date_end = dol_get_last_day($year_start, 6, false);
127 }
128 if ($q == 3) {
129 $date_start = dol_get_first_day($year_start, 7, false);
130 $date_end = dol_get_last_day($year_start, 9, false);
131 }
132 if ($q == 4) {
133 $date_start = dol_get_first_day($year_start, 10, false);
134 $date_end = dol_get_last_day($year_start, 12, false);
135 }
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 = '';
172foreach ($allparams as $key => $value) {
173 $paramslink .= '&'.$key.'='.$value;
174}
175
176// Security check
177if ($user->socid > 0) {
178 $socid = $user->socid;
179}
180if (isModEnabled('comptabilite')) {
181 $result = restrictedArea($user, 'compta', '', '', 'resultat');
182}
183if (isModEnabled('accounting')) {
184 $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
185}
186
187
188/*
189 * View
190 */
191
192llxHeader();
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
199if ($modecompta == "BOOKKEEPING") {
200 $modecompta = "CREANCES-DETTES";
201}
202if ($modecompta == "BOOKKEEPINGCOLLECTED") {
203 $modecompta = "RECETTES-DEPENSES";
204}
205
206// Show report header
207if ($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 $builddate = dol_now();
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
219 $builddate = dol_now();
220} elseif ($modecompta == "BOOKKEEPING") {
221 // TODO
222} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
223 // TODO
224}
225
226$builddate = dol_now();
227$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
228$period .= ' - ';
229$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
230if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) {
231 $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>';
232} else {
233 $periodlink = '';
234}
235
236$exportlink = '';
237
238report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
239
240if (isModEnabled('accounting')) {
241 if ($modecompta != 'BOOKKEEPING') {
242 print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
243 } else {
244 // Test if there is at least one line in bookkeeping
245 $pcgverid = getDolGlobalInt('CHARTOFACCOUNTS');
246 $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
247 if (empty($pcgvercode)) {
248 $pcgvercode = $pcgverid;
249 }
250
251 $sql = "SELECT b.rowid ";
252 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
253 $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
254 $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
255 $sql .= " AND b.numero_compte = aa.account_number";
256 $sql .= " AND aa.entity = ".$conf->entity;
257 $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
258 $sql .= $db->plimit(1);
259
260 $resql = $db->query($sql);
261 $nb = $db->num_rows($resql);
262 if ($nb == 0) {
263 $langs->load("errors");
264 print info_admin($langs->trans("WarningNoDataTransferedInAccountancyYet"), 0, 0, 1);
265 }
266 }
267}
268
269// Show Array
270$catotal = 0;
271$catotal_ht = 0;
272$name = array();
273$amount = array();
274$amount_ht = array();
275$address_zip = array();
276$address_town = array();
277$address_pays = array();
278
279if ($modecompta == 'CREANCES-DETTES') {
280 $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
281 $sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
282 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
283 if ($selected_cat === -2) { // Without any category
284 $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
285 } elseif ($selected_cat) { // Into a specific category
286 $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
287 }
288 $sql .= " WHERE f.fk_statut in (1,2)";
289 $sql .= " AND f.type IN (0,2)";
290 $sql .= " AND f.fk_soc = s.rowid";
291 if ($date_start && $date_end) {
292 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
293 }
294 if ($selected_cat === -2) { // Without any category
295 $sql .= " AND cs.fk_soc is null";
296 } elseif ($selected_cat) { // Into a specific category
297 $sql .= " AND (c.rowid = ".((int) $selected_cat);
298 if ($subcat) {
299 $sql .= " OR c.fk_parent = ".((int) $selected_cat);
300 }
301 $sql .= ")";
302 $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
303 }
304} elseif ($modecompta == "RECETTES-DEPENSES") {
305 $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
306 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
307 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
308 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn as p";
309 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
310 if ($selected_cat === -2) { // Without any category
311 $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
312 } elseif ($selected_cat) { // Into a specific category
313 $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
314 }
315 $sql .= " WHERE p.rowid = pf.fk_paiementfourn";
316 $sql .= " AND pf.fk_facturefourn = f.rowid";
317 $sql .= " AND f.fk_soc = s.rowid";
318 if ($date_start && $date_end) {
319 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
320 }
321 if ($selected_cat === -2) { // Without any category
322 $sql .= " AND cs.fk_soc is null";
323 } elseif ($selected_cat) { // Into a specific category
324 $sql .= " AND (c.rowid = ".((int) $selected_cat);
325 if ($subcat) {
326 $sql .= " OR c.fk_parent = ".((int) $selected_cat);
327 }
328 $sql .= ")";
329 $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
330 }
331}
332if (!empty($search_societe)) {
333 $sql .= natural_search('s.nom', $search_societe);
334}
335if (!empty($search_zip)) {
336 $sql .= natural_search('s.zip', $search_zip);
337}
338if (!empty($search_town)) {
339 $sql .= natural_search('s.town', $search_town);
340}
341if ($search_country > 0) {
342 $sql .= ' AND s.fk_pays = '.((int) $search_country);
343}
344$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
345if ($socid) {
346 $sql .= " AND f.fk_soc = ".((int) $socid);
347}
348$sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
349$sql .= " ORDER BY s.rowid";
350//echo $sql;
351
352$catotal_ht = 0;
353$catotal = 0;
354
355dol_syslog("supplier_turnover_by_thirdparty", LOG_DEBUG);
356$resql = $db->query($sql);
357if ($resql) {
358 $num = $db->num_rows($resql);
359 $i = 0;
360 while ($i < $num) {
361 $obj = $db->fetch_object($resql);
362
363 $amount_ht[$obj->socid] = (empty($obj->amount) ? 0 : $obj->amount);
364 $amount[$obj->socid] = $obj->amount_ttc;
365 $name[$obj->socid] = $obj->name;
366
367 $address_zip[$obj->socid] = $obj->zip;
368 $address_town[$obj->socid] = $obj->town;
369 $address_pays[$obj->socid] = getCountry($obj->fk_pays);
370
371 $catotal_ht += (empty($obj->amount) ? 0 : $obj->amount);
372 $catotal += $obj->amount_ttc;
373
374 $i++;
375 }
376} else {
377 dol_print_error($db);
378}
379
380// Show array
381$i = 0;
382print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
383print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
384// Extra parameters management
385foreach ($headerparams as $key => $value) {
386 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
387}
388
389$moreforfilter = '';
390
391print '<div class="div-table-responsive">';
392print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
393
394// Category filter
395print '<tr class="liste_titre">';
396print '<td>';
397print img_picto('', 'category', 'class="paddingrightonly"');
398print $formother->select_categories(Categorie::TYPE_SUPPLIER, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
399print ' ';
400print '<label for="subcat" class="marginleftonly">'.$langs->trans("SubCats").'?</label> ';
401print '<input type="checkbox" id="subcat" name="subcat" value="yes"';
402if ($subcat) {
403 print ' checked';
404}
405print'></td>';
406print '<td colspan="7" class="right">';
407print '<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")).'">';
408print '</td>';
409print '</tr>';
410
411print '<tr class="liste_titre">';
412print '<td class="liste_titre left">';
413print '<input class="flat" size="6" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
414print '</td>';
415print '<td class="liste_titre left">';
416print '<input class="flat" size="6" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
417print '</td>';
418print '<td class="liste_titre left">';
419print '<input class="flat" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
420print '</td>';
421print '<td class="liste_titre left">';
422print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150');
423//print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
424print '</td>';
425print '<td class="liste_titre">&nbsp;</td>';
426print '<td class="liste_titre">&nbsp;</td>';
427print '<td class="liste_titre">&nbsp;</td>';
428print '<td class="liste_titre">&nbsp;</td>';
429print '</tr>';
430
431// Array titles
432print "<tr class='liste_titre'>";
434 $langs->trans("Company"),
435 $_SERVER["PHP_SELF"],
436 "nom",
437 "",
438 $paramslink,
439 "",
440 $sortfield,
441 $sortorder
442);
444 $langs->trans("Zip"),
445 $_SERVER["PHP_SELF"],
446 "zip",
447 "",
448 $paramslink,
449 "",
450 $sortfield,
451 $sortorder
452);
454 $langs->trans("Town"),
455 $_SERVER["PHP_SELF"],
456 "town",
457 "",
458 $paramslink,
459 "",
460 $sortfield,
461 $sortorder
462);
464 $langs->trans("Country"),
465 $_SERVER["PHP_SELF"],
466 "country",
467 "",
468 $paramslink,
469 "",
470 $sortfield,
471 $sortorder
472);
473if ($modecompta == 'CREANCES-DETTES') {
475 $langs->trans('AmountHT'),
476 $_SERVER["PHP_SELF"],
477 "amount_ht",
478 "",
479 $paramslink,
480 'class="right"',
481 $sortfield,
482 $sortorder
483 );
484} else {
486}
488 $langs->trans("AmountTTC"),
489 $_SERVER["PHP_SELF"],
490 "amount_ttc",
491 "",
492 $paramslink,
493 'class="right"',
494 $sortfield,
495 $sortorder
496);
498 $langs->trans("Percentage"),
499 $_SERVER["PHP_SELF"],
500 "amount_ttc",
501 "",
502 $paramslink,
503 'class="right"',
504 $sortfield,
505 $sortorder
506);
508 $langs->trans("OtherStatistics"),
509 $_SERVER["PHP_SELF"],
510 "",
511 "",
512 "",
513 'align="center" width="20%"'
514);
515print "</tr>\n";
516
517
518if (count($amount)) {
519 $arrayforsort = $name;
520 // Defining array arrayforsort
521 if ($sortfield == 'nom' && $sortorder == 'asc') {
522 asort($name);
523 $arrayforsort = $name;
524 }
525 if ($sortfield == 'nom' && $sortorder == 'desc') {
526 arsort($name);
527 $arrayforsort = $name;
528 }
529 if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
530 asort($amount_ht);
531 $arrayforsort = $amount_ht;
532 }
533 if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
534 arsort($amount_ht);
535 $arrayforsort = $amount_ht;
536 }
537 if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
538 asort($amount);
539 $arrayforsort = $amount;
540 }
541 if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
542 arsort($amount);
543 $arrayforsort = $amount;
544 }
545 if ($sortfield == 'zip' && $sortorder == 'asc') {
546 asort($address_zip);
547 $arrayforsort = $address_zip;
548 }
549 if ($sortfield == 'zip' && $sortorder == 'desc') {
550 arsort($address_zip);
551 $arrayforsort = $address_zip;
552 }
553 if ($sortfield == 'town' && $sortorder == 'asc') {
554 asort($address_town);
555 $arrayforsort = $address_town;
556 }
557 if ($sortfield == 'town' && $sortorder == 'desc') {
558 arsort($address_town);
559 $arrayforsort = $address_town;
560 }
561 if ($sortfield == 'country' && $sortorder == 'asc') {
562 asort($address_pays);
563 $arrayforsort = $address_town;
564 }
565 if ($sortfield == 'country' && $sortorder == 'desc') {
566 arsort($address_pays);
567 $arrayforsort = $address_town;
568 }
569
570 foreach ($arrayforsort as $key => $value) {
571 print '<tr class="oddeven">';
572
573 // Third party
574 $fullname = $name[$key];
575 if ($key > 0) {
576 $thirdparty_static->id = $key;
577 $thirdparty_static->name = $fullname;
578 $thirdparty_static->client = 1;
579 $linkname = $thirdparty_static->getNomUrl(1, 'supplier');
580 } else {
581 $linkname = $langs->trans("PaymentsNotLinkedToInvoice");
582 }
583 print "<td>".$linkname."</td>\n";
584
585 print '<td>';
586 print $address_zip[$key];
587 print '</td>';
588
589 print '<td>';
590 print $address_town[$key];
591 print '</td>';
592
593 print '<td>';
594 print $address_pays[$key];
595 print '</td>';
596
597 // Amount w/o VAT
598 print '<td class="right">';
599 if ($modecompta != 'CREANCES-DETTES') {
600 if ($key > 0) {
601 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
602 } else {
603 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid=-1">';
604 }
605 } else {
606 if ($key > 0) {
607 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
608 } else {
609 print '<a href="#">';
610 }
611 print price($amount_ht[$key]);
612 }
613 print '</td>';
614
615 // Amount with VAT
616 print '<td class="right">';
617 if ($modecompta != 'CREANCES-DETTES') {
618 if ($key > 0) {
619 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
620 } else {
621 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?orphelins=1">';
622 }
623 } else {
624 if ($key > 0) {
625 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
626 } else {
627 print '<a href="#">';
628 }
629 }
630 print price($amount[$key]);
631 print '</a>';
632 print '</td>';
633
634 // Percent;
635 print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
636
637 // Other stats
638 print '<td class="center">';
639 if (isModEnabled('supplier_proposal') && $key > 0) {
640 print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"), "stats").'</a>&nbsp;';
641 }
642 if (isModEnabled("supplier_order") && $key > 0) {
643 print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("OrderStats"), "stats").'</a>&nbsp;';
644 }
645 if (isModEnabled("supplier_invoice") && $key > 0) {
646 print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"), "stats").'</a>&nbsp;';
647 }
648 print '</td>';
649 print "</tr>\n";
650 $i++;
651 }
652
653 // Total
654 print '<tr class="liste_total">';
655 print '<td>'.$langs->trans("Total").'</td>';
656 print '<td></td>';
657 print '<td></td>';
658 print '<td></td>';
659 if ($modecompta != 'CREANCES-DETTES') {
660 print '<td></td>';
661 } else {
662 print '<td class="right">'.price($catotal_ht).'</td>';
663 }
664 print '<td class="right">'.price($catotal).'</td>';
665 print '<td></td>';
666 print '<td></td>';
667 print '</tr>';
668
669 $db->free($result);
670} else {
671 print '<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
672}
673
674print "</table>";
675print "</div>";
676
677print '</form>';
678
679// End of page
680llxFooter();
681$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
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.
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: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:613
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.