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