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