dolibarr 21.0.3
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 * 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';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37
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
240// Show report header
241if ($modecompta == "CREANCES-DETTES") {
242 $name = $langs->trans("PurchaseTurnover").', '.$langs->trans("ByThirdParties");
243 $calcmode = $langs->trans("CalcModeDebt");
244 //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
245 $description = $langs->trans("RulesPurchaseTurnoverDue");
246 $builddate = dol_now();
247} elseif ($modecompta == "RECETTES-DEPENSES") {
248 $name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByThirdParties");
249 $calcmode = $langs->trans("CalcModePayment");
250 //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
251 $description = $langs->trans("RulesPurchaseTurnoverIn");
252
253 $builddate = dol_now();
254} elseif ($modecompta == "BOOKKEEPING") {
255 // TODO
256} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
257 // TODO
258}
259
260$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
261$period .= ' - ';
262$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
263if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) {
264 $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>';
265} else {
266 $periodlink = '';
267}
268
269$exportlink = '';
270
271report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
272
273if (isModEnabled('accounting')) {
274 if ($modecompta != 'BOOKKEEPING') {
275 print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, '1');
276 } else {
277 // Test if there is at least one line in bookkeeping
278 $pcgverid = getDolGlobalInt('CHARTOFACCOUNTS');
279 $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
280 if (empty($pcgvercode)) {
281 $pcgvercode = $pcgverid;
282 }
283
284 $sql = "SELECT b.rowid ";
285 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
286 $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
287 $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
288 $sql .= " AND b.numero_compte = aa.account_number";
289 $sql .= " AND aa.entity = ".$conf->entity;
290 $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
291 $sql .= $db->plimit(1);
292
293 $resql = $db->query($sql);
294 $nb = $db->num_rows($resql);
295 if ($nb == 0) {
296 $langs->load("errors");
297 print info_admin($langs->trans("WarningNoDataTransferedInAccountancyYet"), 0, 0, '1');
298 }
299 }
300}
301
302// Show Array
303$catotal = 0;
304$catotal_ht = 0;
305$name = array();
306$amount = array();
307$amount_ht = array();
308$address_zip = array();
309$address_town = array();
310$address_pays = array();
311
312if ($modecompta == 'CREANCES-DETTES') {
313 $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
314 $sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
315 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
316 if ($selected_cat === -2) { // Without any category
317 $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
318 } elseif ($selected_cat) { // Into a specific category
319 $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
320 }
321 $sql .= " WHERE f.fk_statut in (1,2)";
322 $sql .= " AND f.type IN (0,2)";
323 $sql .= " AND f.fk_soc = s.rowid";
324 if ($date_start && $date_end) {
325 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
326 }
327 if ($selected_cat === -2) { // Without any category
328 $sql .= " AND cs.fk_soc is null";
329 } elseif ($selected_cat) { // Into a specific category
330 $sql .= " AND (c.rowid = ".((int) $selected_cat);
331 if ($subcat) {
332 $sql .= " OR c.fk_parent = ".((int) $selected_cat);
333 }
334 $sql .= ")";
335 $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
336 }
337} elseif ($modecompta == "RECETTES-DEPENSES") {
338 $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
339 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
340 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
341 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn as p";
342 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
343 if ($selected_cat === -2) { // Without any category
344 $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
345 } elseif ($selected_cat) { // Into a specific category
346 $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
347 }
348 $sql .= " WHERE p.rowid = pf.fk_paiementfourn";
349 $sql .= " AND pf.fk_facturefourn = f.rowid";
350 $sql .= " AND f.fk_soc = s.rowid";
351 if ($date_start && $date_end) {
352 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
353 }
354 if ($selected_cat === -2) { // Without any category
355 $sql .= " AND cs.fk_soc is null";
356 } elseif ($selected_cat) { // Into a specific category
357 $sql .= " AND (c.rowid = ".((int) $selected_cat);
358 if ($subcat) {
359 $sql .= " OR c.fk_parent = ".((int) $selected_cat);
360 }
361 $sql .= ")";
362 $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
363 }
364}
365if (!empty($search_societe)) {
366 $sql .= natural_search('s.nom', $search_societe);
367}
368if (!empty($search_zip)) {
369 $sql .= natural_search('s.zip', $search_zip);
370}
371if (!empty($search_town)) {
372 $sql .= natural_search('s.town', $search_town);
373}
374if ($search_country > 0) {
375 $sql .= ' AND s.fk_pays = '.((int) $search_country);
376}
377$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
378if ($socid) {
379 $sql .= " AND f.fk_soc = ".((int) $socid);
380}
381$sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
382$sql .= " ORDER BY s.rowid";
383//echo $sql;
384
385$catotal_ht = 0;
386$catotal = 0;
387
388dol_syslog("supplier_turnover_by_thirdparty", LOG_DEBUG);
389$resql = $db->query($sql);
390if ($resql) {
391 $num = $db->num_rows($resql);
392 $i = 0;
393 while ($i < $num) {
394 $obj = $db->fetch_object($resql);
395
396 $amount_ht[$obj->socid] = (empty($obj->amount) ? 0 : $obj->amount);
397 $amount[$obj->socid] = $obj->amount_ttc;
398 $name[$obj->socid] = $obj->name;
399
400 $address_zip[$obj->socid] = $obj->zip;
401 $address_town[$obj->socid] = $obj->town;
402 $address_pays[$obj->socid] = getCountry($obj->fk_pays);
403
404 $catotal_ht += (empty($obj->amount) ? 0 : $obj->amount);
405 $catotal += $obj->amount_ttc;
406
407 $i++;
408 }
409} else {
410 dol_print_error($db);
411}
412
413// Show array
414$i = 0;
415print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
416print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
417// Extra parameters management
418foreach ($headerparams as $key => $value) {
419 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
420}
421
422$moreforfilter = '';
423
424print '<div class="div-table-responsive">';
425print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
426
427// Category filter
428print '<tr class="liste_titre">';
429print '<td>';
430print img_picto('', 'category', 'class="paddingrightonly"');
431print $formother->select_categories(Categorie::TYPE_SUPPLIER, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
432print ' ';
433print '<label for="subcat" class="marginleftonly">'.$langs->trans("SubCats").'?</label> ';
434print '<input type="checkbox" id="subcat" name="subcat" value="yes"';
435if ($subcat) {
436 print ' checked';
437}
438print'></td>';
439print '<td colspan="7" class="right">';
440print '<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")).'">';
441print '</td>';
442print '</tr>';
443
444print '<tr class="liste_titre">';
445print '<td class="liste_titre left">';
446print '<input class="flat" size="6" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
447print '</td>';
448print '<td class="liste_titre left">';
449print '<input class="flat" size="6" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
450print '</td>';
451print '<td class="liste_titre left">';
452print '<input class="flat" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
453print '</td>';
454print '<td class="liste_titre left">';
455print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150');
456//print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
457print '</td>';
458print '<td class="liste_titre">&nbsp;</td>';
459print '<td class="liste_titre">&nbsp;</td>';
460print '<td class="liste_titre">&nbsp;</td>';
461print '<td class="liste_titre">&nbsp;</td>';
462print '</tr>';
463
464// Array titles
465print "<tr class='liste_titre'>";
467 $langs->trans("Company"),
468 $_SERVER["PHP_SELF"],
469 "nom",
470 "",
471 $paramslink,
472 "",
473 $sortfield,
474 $sortorder
475);
477 $langs->trans("Zip"),
478 $_SERVER["PHP_SELF"],
479 "zip",
480 "",
481 $paramslink,
482 "",
483 $sortfield,
484 $sortorder
485);
487 $langs->trans("Town"),
488 $_SERVER["PHP_SELF"],
489 "town",
490 "",
491 $paramslink,
492 "",
493 $sortfield,
494 $sortorder
495);
497 $langs->trans("Country"),
498 $_SERVER["PHP_SELF"],
499 "country",
500 "",
501 $paramslink,
502 "",
503 $sortfield,
504 $sortorder
505);
506if ($modecompta == 'CREANCES-DETTES') {
508 $langs->trans('AmountHT'),
509 $_SERVER["PHP_SELF"],
510 "amount_ht",
511 "",
512 $paramslink,
513 'class="right"',
514 $sortfield,
515 $sortorder
516 );
517} else {
519}
521 $langs->trans("AmountTTC"),
522 $_SERVER["PHP_SELF"],
523 "amount_ttc",
524 "",
525 $paramslink,
526 'class="right"',
527 $sortfield,
528 $sortorder
529);
531 $langs->trans("Percentage"),
532 $_SERVER["PHP_SELF"],
533 "amount_ttc",
534 "",
535 $paramslink,
536 'class="right"',
537 $sortfield,
538 $sortorder
539);
541 $langs->trans("OtherStatistics"),
542 $_SERVER["PHP_SELF"],
543 "",
544 "",
545 "",
546 'align="center" width="20%"'
547);
548print "</tr>\n";
549
550
551if (count($amount)) {
552 $arrayforsort = $name;
553 // Defining array arrayforsort
554 if ($sortfield == 'nom' && $sortorder == 'asc') {
555 asort($name);
556 $arrayforsort = $name;
557 }
558 if ($sortfield == 'nom' && $sortorder == 'desc') {
559 arsort($name);
560 $arrayforsort = $name;
561 }
562 if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
563 asort($amount_ht);
564 $arrayforsort = $amount_ht;
565 }
566 if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
567 arsort($amount_ht);
568 $arrayforsort = $amount_ht;
569 }
570 if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
571 asort($amount);
572 $arrayforsort = $amount;
573 }
574 if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
575 arsort($amount);
576 $arrayforsort = $amount;
577 }
578 if ($sortfield == 'zip' && $sortorder == 'asc') {
579 asort($address_zip);
580 $arrayforsort = $address_zip;
581 }
582 if ($sortfield == 'zip' && $sortorder == 'desc') {
583 arsort($address_zip);
584 $arrayforsort = $address_zip;
585 }
586 if ($sortfield == 'town' && $sortorder == 'asc') {
587 asort($address_town);
588 $arrayforsort = $address_town;
589 }
590 if ($sortfield == 'town' && $sortorder == 'desc') {
591 arsort($address_town);
592 $arrayforsort = $address_town;
593 }
594 if ($sortfield == 'country' && $sortorder == 'asc') {
595 asort($address_pays);
596 $arrayforsort = $address_town;
597 }
598 if ($sortfield == 'country' && $sortorder == 'desc') {
599 arsort($address_pays);
600 $arrayforsort = $address_town;
601 }
602
603 foreach ($arrayforsort as $key => $value) {
604 print '<tr class="oddeven">';
605
606 // Third party
607 $fullname = $name[$key];
608 if ($key > 0) {
609 $thirdparty_static->id = $key;
610 $thirdparty_static->name = $fullname;
611 $thirdparty_static->client = 1;
612 $linkname = $thirdparty_static->getNomUrl(1, 'supplier');
613 } else {
614 $linkname = $langs->trans("PaymentsNotLinkedToInvoice");
615 }
616 print "<td>".$linkname."</td>\n";
617
618 print '<td>';
619 print $address_zip[$key];
620 print '</td>';
621
622 print '<td>';
623 print $address_town[$key];
624 print '</td>';
625
626 print '<td>';
627 print $address_pays[$key];
628 print '</td>';
629
630 // Amount w/o VAT
631 print '<td class="right">';
632 if ($modecompta != 'CREANCES-DETTES') {
633 if ($key > 0) {
634 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
635 } else {
636 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid=-1">';
637 }
638 } else {
639 if ($key > 0) {
640 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
641 } else {
642 print '<a href="#">';
643 }
644 print price($amount_ht[$key]);
645 }
646 print '</td>';
647
648 // Amount with VAT
649 print '<td class="right">';
650 if ($modecompta != 'CREANCES-DETTES') {
651 if ($key > 0) {
652 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
653 } else {
654 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?orphelins=1">';
655 }
656 } else {
657 if ($key > 0) {
658 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
659 } else {
660 print '<a href="#">';
661 }
662 }
663 print price($amount[$key]);
664 print '</a>';
665 print '</td>';
666
667 // Percent;
668 print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
669
670 // Other stats
671 print '<td class="center">';
672 if (isModEnabled('supplier_proposal') && $key > 0) {
673 print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"), "stats").'</a>&nbsp;';
674 }
675 if (isModEnabled("supplier_order") && $key > 0) {
676 print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("OrderStats"), "stats").'</a>&nbsp;';
677 }
678 if (isModEnabled("supplier_invoice") && $key > 0) {
679 print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"), "stats").'</a>&nbsp;';
680 }
681 print '</td>';
682 print "</tr>\n";
683 $i++;
684 }
685
686 // Total
687 print '<tr class="liste_total">';
688 print '<td>'.$langs->trans("Total").'</td>';
689 print '<td></td>';
690 print '<td></td>';
691 print '<td></td>';
692 if ($modecompta != 'CREANCES-DETTES') {
693 print '<td></td>';
694 } else {
695 print '<td class="right">'.price($catotal_ht).'</td>';
696 }
697 print '<td class="right">'.price($catotal).'</td>';
698 print '<td></td>';
699 print '<td></td>';
700 print '</tr>';
701
702 $db->free($result);
703} else {
704 print '<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
705}
706
707print "</table>";
708print "</div>";
709
710print '</form>';
711
712// End of page
713llxFooter();
714$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
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:71
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:600
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:619
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.
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)
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_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.