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