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