dolibarr  13.0.2
casoc.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
6  * Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.fr>
7  * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array('companies', 'categories', 'bills', 'compta'));
40 
41 // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
42 $modecompta = $conf->global->ACCOUNTING_MODE;
43 if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta");
44 
45 $sortorder = isset($_GET["sortorder"]) ? $_GET["sortorder"] : $_POST["sortorder"];
46 $sortfield = isset($_GET["sortfield"]) ? $_GET["sortfield"] : $_POST["sortfield"];
47 if (!$sortorder) $sortorder = "asc";
48 if (!$sortfield) $sortfield = "nom";
49 
50 $socid = GETPOST('socid', 'int');
51 
52 // Category
53 $selected_cat = (int) GETPOST('search_categ', 'int');
54 $subcat = false;
55 if (GETPOST('subcat', 'alpha') === 'yes') {
56  $subcat = true;
57 }
58 
59 // Security check
60 if ($user->socid > 0) $socid = $user->socid;
61 if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat');
62 if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
63 
64 // Hook
65 $hookmanager->initHooks(array('casoclist'));
66 
67 // Date range
68 $year = GETPOST("year", 'int');
69 $month = GETPOST("month", 'int');
70 $search_societe = GETPOST("search_societe", 'alpha');
71 $search_zip = GETPOST("search_zip", 'alpha');
72 $search_town = GETPOST("search_town", 'alpha');
73 $search_country = GETPOST("search_country", 'alpha');
74 $date_startyear = GETPOST("date_startyear", 'alpha');
75 $date_startmonth = GETPOST("date_startmonth", 'alpha');
76 $date_startday = GETPOST("date_startday", 'alpha');
77 $date_endyear = GETPOST("date_endyear", 'alpha');
78 $date_endmonth = GETPOST("date_endmonth", 'alpha');
79 $date_endday = GETPOST("date_endday", 'alpha');
80 if (empty($year))
81 {
82  $year_current = strftime("%Y", dol_now());
83  $month_current = strftime("%m", dol_now());
84  $year_start = $year_current;
85 } else {
86  $year_current = $year;
87  $month_current = strftime("%m", dol_now());
88  $year_start = $year;
89 }
90 $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
91 $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
92 // Quarter
93 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
94 {
95  $q = GETPOST("q", "int") ?GETPOST("q", "int") : 0;
96  if (empty($q))
97  {
98  // We define date_start and date_end
99  $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
100  $year_end = $year_start;
101  $month_end = $month_start;
102  if (!GETPOST("month")) // If month not forced
103  {
104  if (!GETPOST('year') && $month_start > $month_current)
105  {
106  $year_start--;
107  $year_end--;
108  }
109  $month_end = $month_start - 1;
110  if ($month_end < 1) $month_end = 12;
111  else $year_end++;
112  }
113  $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false);
114  }
115  if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
116  if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
117  if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
118  if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
119 } else {
120  // TODO We define q
121 }
122 
123 // $date_start and $date_end are defined. We force $year_start and $nbofyear
124 $tmps = dol_getdate($date_start);
125 $year_start = $tmps['year'];
126 $tmpe = dol_getdate($date_end);
127 $year_end = $tmpe['year'];
128 $nbofyear = ($year_end - $year_start) + 1;
129 
130 $commonparams = array();
131 $commonparams['modecompta'] = $modecompta;
132 $commonparams['sortorder'] = $sortorder;
133 $commonparams['sortfield'] = $sortfield;
134 
135 $headerparams = array();
136 $headerparams['date_startyear'] = $date_startyear;
137 $headerparams['date_startmonth'] = $date_startmonth;
138 $headerparams['date_startday'] = $date_startday;
139 $headerparams['date_endyear'] = $date_endyear;
140 $headerparams['date_endmonth'] = $date_endmonth;
141 $headerparams['date_endday'] = $date_endday;
142 $headerparams['q'] = $q;
143 
144 $tableparams = array();
145 $tableparams['search_categ'] = $selected_cat;
146 $tableparams['search_societe'] = $search_societe;
147 $tableparams['search_zip'] = $search_zip;
148 $tableparams['search_town'] = $search_town;
149 $tableparams['search_country'] = $search_country;
150 $tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
151 
152 // Adding common parameters
153 $allparams = array_merge($commonparams, $headerparams, $tableparams);
154 $headerparams = array_merge($commonparams, $headerparams);
155 $tableparams = array_merge($commonparams, $tableparams);
156 
157 foreach ($allparams as $key => $value) {
158  $paramslink .= '&'.$key.'='.$value;
159 }
160 
161 
162 /*
163  * View
164  */
165 
166 llxHeader();
167 
168 $form = new Form($db);
169 $thirdparty_static = new Societe($db);
170 $formother = new FormOther($db);
171 
172 // TODO Report from bookkeeping not yet available, so we switch on report on business events
173 if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES";
174 if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES";
175 
176 // Show report header
177 if ($modecompta == "CREANCES-DETTES")
178 {
179  $name = $langs->trans("Turnover").', '.$langs->trans("ByThirdParties");
180  $calcmode = $langs->trans("CalcModeDebt");
181  //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
182  $description = $langs->trans("RulesCADue");
183  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded");
184  else $description .= $langs->trans("DepositsAreIncluded");
185  $builddate = dol_now();
186  //$exportlink=$langs->trans("NotYetAvailable");
187 } elseif ($modecompta == "RECETTES-DEPENSES")
188 {
189  $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByThirdParties");
190  $calcmode = $langs->trans("CalcModeEngagement");
191  //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
192  $description = $langs->trans("RulesCAIn");
193  $description .= $langs->trans("DepositsAreIncluded");
194  $builddate = dol_now();
195  //$exportlink=$langs->trans("NotYetAvailable");
196 } elseif ($modecompta == "BOOKKEEPING")
197 {
198 } elseif ($modecompta == "BOOKKEEPINGCOLLECTED")
199 {
200 }
201 $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
202 if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $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>';
203 else $periodlink = '';
204 
205 report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
206 
207 if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
208 {
209  print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
210 }
211 
212 
213 $name = array();
214 
215 // Show Array
216 $catotal = 0;
217 if ($modecompta == 'CREANCES-DETTES') {
218  $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
219  $sql .= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
220  $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
221  if ($selected_cat === -2) // Without any category
222  {
223  $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
224  } elseif ($selected_cat) // Into a specific category
225  {
226  $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
227  }
228  $sql .= " WHERE f.fk_statut in (1,2)";
229  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
230  $sql .= " AND f.type IN (0,1,2,5)";
231  } else {
232  $sql .= " AND f.type IN (0,1,2,3,5)";
233  }
234  $sql .= " AND f.fk_soc = s.rowid";
235  if ($date_start && $date_end) {
236  $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
237  }
238  if ($selected_cat === -2) // Without any category
239  {
240  $sql .= " AND cs.fk_soc is null";
241  } elseif ($selected_cat) { // Into a specific category
242  $sql .= " AND (c.rowid = ".$db->escape($selected_cat);
243  if ($subcat) $sql .= " OR c.fk_parent = ".$db->escape($selected_cat);
244  $sql .= ")";
245  $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
246  }
247 } else {
248  /*
249  * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
250  * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
251  */
252  $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
253  $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
254  $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
255  $sql .= ", ".MAIN_DB_PREFIX."paiement as p";
256  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
257  if ($selected_cat === -2) // Without any category
258  {
259  $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
260  } elseif ($selected_cat) // Into a specific category
261  {
262  $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
263  }
264  $sql .= " WHERE p.rowid = pf.fk_paiement";
265  $sql .= " AND pf.fk_facture = f.rowid";
266  $sql .= " AND f.fk_soc = s.rowid";
267  if ($date_start && $date_end) {
268  $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
269  }
270  if ($selected_cat === -2) // Without any category
271  {
272  $sql .= " AND cs.fk_soc is null";
273  } elseif ($selected_cat) { // Into a specific category
274  $sql .= " AND (c.rowid = ".$selected_cat;
275  if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat;
276  $sql .= ")";
277  $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
278  }
279 }
280 if (!empty($search_societe)) $sql .= natural_search('s.nom', $search_societe);
281 if (!empty($search_zip)) $sql .= natural_search('s.zip', $search_zip);
282 if (!empty($search_town)) $sql .= natural_search('s.town', $search_town);
283 if ($search_country > 0) $sql .= ' AND s.fk_pays = '.$search_country.'';
284 $sql .= " AND f.entity IN (".getEntity('invoice').")";
285 if ($socid) $sql .= " AND f.fk_soc = ".$socid;
286 $sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
287 $sql .= " ORDER BY s.rowid";
288 //echo $sql;
289 
290 $amount = array();
291 
292 dol_syslog("casoc", LOG_DEBUG);
293 $result = $db->query($sql);
294 if ($result) {
295  $num = $db->num_rows($result);
296  $i = 0;
297  while ($i < $num) {
298  $obj = $db->fetch_object($result);
299  $amount_ht[$obj->socid] = $obj->amount;
300  $amount[$obj->socid] = $obj->amount_ttc;
301  $name[$obj->socid] = $obj->name.' '.$obj->firstname;
302  $address_zip[$obj->socid] = $obj->zip;
303  $address_town[$obj->socid] = $obj->town;
304  $address_pays[$obj->socid] = getCountry($obj->fk_pays);
305  $catotal_ht += $obj->amount;
306  $catotal += $obj->amount_ttc;
307  $i++;
308  }
309 } else {
310  dol_print_error($db);
311 }
312 
313 // On ajoute les paiements anciennes version, non lies par paiement_facture
314 if ($modecompta != 'CREANCES-DETTES') {
315  $sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc";
316  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
317  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
318  $sql .= ", ".MAIN_DB_PREFIX."paiement as p";
319  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
320  $sql .= " WHERE pf.rowid IS NULL";
321  $sql .= " AND p.fk_bank = b.rowid";
322  $sql .= " AND b.fk_account = ba.rowid";
323  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
324  if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
325  $sql .= " GROUP BY socid, name";
326  $sql .= " ORDER BY name";
327 
328  $result = $db->query($sql);
329  if ($result) {
330  $num = $db->num_rows($result);
331  $i = 0;
332  while ($i < $num) {
333  $obj = $db->fetch_object($result);
334  $amount[$obj->rowid] += $obj->amount_ttc;
335  $name[$obj->rowid] = $obj->name;
336  $address_zip[$obj->rowid] = $obj->zip;
337  $address_town[$obj->rowid] = $obj->town;
338  $address_pays[$obj->rowid] = getCountry($obj->fk_pays);
339  $catotal += $obj->amount_ttc;
340  $i++;
341  }
342  } else {
343  dol_print_error($db);
344  }
345 }
346 
347 
348 // Show array
349 $i = 0;
350 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
351 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
352 // Extra parameters management
353 foreach ($headerparams as $key => $value)
354 {
355  print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
356 }
357 
358 $moreforfilter = '';
359 
360 print '<div class="div-table-responsive">';
361 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
362 
363 // Category filter
364 print '<tr class="liste_titre">';
365 print '<td>';
366 print $langs->trans("Category").': '.$formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_cat, 'search_categ', true);
367 print ' ';
368 print $langs->trans("SubCats").'? ';
369 print '<input type="checkbox" name="subcat" value="yes"';
370 if ($subcat) {
371  print ' checked';
372 }
373 print'></td>';
374 print '<td colspan="7" class="right">';
375 print '<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")).'">';
376 print '</td>';
377 print '</tr>';
378 
379 print '<tr class="liste_titre">';
380 print '<td class="liste_titre left">';
381 print '<input class="flat" size="6" type="text" name="search_societe" value="'.$search_societe.'">';
382 print '</td>';
383 print '<td class="liste_titre left">';
384 print '<input class="flat" size="6" type="text" name="search_zip" value="'.$search_zip.'">';
385 print '</td>';
386 print '<td class="liste_titre left">';
387 print '<input class="flat" size="6" type="text" name="search_town" value="'.$search_town.'">';
388 print '</td>';
389 print '<td class="liste_titre left">';
390 print $form->select_country($search_country, 'search_country');
391 //print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
392 print '</td>';
393 print '<td class="liste_titre">&nbsp;</td>';
394 print '<td class="liste_titre">&nbsp;</td>';
395 print '<td class="liste_titre">&nbsp;</td>';
396 print '<td class="liste_titre">&nbsp;</td>';
397 print '</tr>';
398 
399 // Array titles
400 print "<tr class='liste_titre'>";
402  $langs->trans("Company"),
403  $_SERVER["PHP_SELF"],
404  "nom",
405  "",
406  $paramslink,
407  "",
408  $sortfield, $sortorder
409  );
411  $langs->trans("Zip"),
412  $_SERVER["PHP_SELF"],
413  "zip",
414  "",
415  $paramslink,
416  "",
417  $sortfield, $sortorder
418  );
420  $langs->trans("Town"),
421  $_SERVER["PHP_SELF"],
422  "town",
423  "",
424  $paramslink,
425  "",
426  $sortfield, $sortorder
427  );
429  $langs->trans("Country"),
430  $_SERVER["PHP_SELF"],
431  "country",
432  "",
433  $paramslink,
434  "",
435  $sortfield, $sortorder
436  );
437 if ($modecompta == 'CREANCES-DETTES') {
439  $langs->trans('AmountHT'),
440  $_SERVER["PHP_SELF"],
441  "amount_ht",
442  "",
443  $paramslink,
444  'class="right"',
445  $sortfield,
446  $sortorder
447  );
448 } else {
450 }
452  $langs->trans("AmountTTC"),
453  $_SERVER["PHP_SELF"],
454  "amount_ttc",
455  "",
456  $paramslink,
457  'class="right"',
458  $sortfield,
459  $sortorder
460 );
462  $langs->trans("Percentage"),
463  $_SERVER["PHP_SELF"],
464  "amount_ttc",
465  "",
466  $paramslink,
467  'class="right"',
468  $sortfield,
469  $sortorder
470 );
472  $langs->trans("OtherStatistics"),
473  $_SERVER["PHP_SELF"],
474  "",
475  "",
476  "",
477  'align="center" width="20%"'
478 );
479 print "</tr>\n";
480 
481 
482 if (count($amount)) {
483  $arrayforsort = $name;
484  // Defining array arrayforsort
485  if ($sortfield == 'nom' && $sortorder == 'asc') {
486  asort($name);
487  $arrayforsort = $name;
488  }
489  if ($sortfield == 'nom' && $sortorder == 'desc') {
490  arsort($name);
491  $arrayforsort = $name;
492  }
493  if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
494  asort($amount_ht);
495  $arrayforsort = $amount_ht;
496  }
497  if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
498  arsort($amount_ht);
499  $arrayforsort = $amount_ht;
500  }
501  if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
502  asort($amount);
503  $arrayforsort = $amount;
504  }
505  if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
506  arsort($amount);
507  $arrayforsort = $amount;
508  }
509  if ($sortfield == 'zip' && $sortorder == 'asc') {
510  asort($address_zip);
511  $arrayforsort = $address_zip;
512  }
513  if ($sortfield == 'zip' && $sortorder == 'desc') {
514  arsort($address_zip);
515  $arrayforsort = $address_zip;
516  }
517  if ($sortfield == 'town' && $sortorder == 'asc') {
518  asort($address_town);
519  $arrayforsort = $address_town;
520  }
521  if ($sortfield == 'town' && $sortorder == 'desc') {
522  arsort($address_town);
523  $arrayforsort = $address_town;
524  }
525  if ($sortfield == 'country' && $sortorder == 'asc') {
526  asort($address_pays);
527  $arrayforsort = $address_town;
528  }
529  if ($sortfield == 'country' && $sortorder == 'desc') {
530  arsort($address_pays);
531  $arrayforsort = $address_town;
532  }
533 
534  foreach ($arrayforsort as $key=>$value) {
535  print '<tr class="oddeven">';
536 
537  // Third party
538  $fullname = $name[$key];
539  if ($key > 0) {
540  $thirdparty_static->id = $key;
541  $thirdparty_static->name = $fullname;
542  $thirdparty_static->client = 1;
543  $linkname = $thirdparty_static->getNomUrl(1, 'customer');
544  } else {
545  $linkname = $langs->trans("PaymentsNotLinkedToInvoice");
546  }
547  print "<td>".$linkname."</td>\n";
548 
549  print '<td>';
550  print $address_zip[$key];
551  print '</td>';
552 
553  print '<td>';
554  print $address_town[$key];
555  print '</td>';
556 
557  print '<td>';
558  print $address_pays[$key];
559  print '</td>';
560 
561  // Amount w/o VAT
562  print '<td class="right">';
563  if ($modecompta != 'CREANCES-DETTES') {
564  if ($key > 0) {
565  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
566  } else {
567  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid=-1">';
568  }
569  } else {
570  if ($key > 0) {
571  print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
572  } else {
573  print '<a href="#">';
574  }
575  print price($amount_ht[$key]);
576  }
577  print '</td>';
578 
579  // Amount with VAT
580  print '<td class="right">';
581  if ($modecompta != 'CREANCES-DETTES') {
582  if ($key > 0) {
583  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
584  } else {
585  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?orphelins=1">';
586  }
587  } else {
588  if ($key > 0) {
589  print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
590  } else {
591  print '<a href="#">';
592  }
593  }
594  print price($amount[$key]);
595  print '</a>';
596  print '</td>';
597 
598  // Percent;
599  print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
600 
601  // Other stats
602  print '<td class="center">';
603  if (!empty($conf->propal->enabled) && $key > 0) {
604  print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"), "stats").'</a>&nbsp;';
605  }
606  if (!empty($conf->commande->enabled) && $key > 0) {
607  print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("OrderStats"), "stats").'</a>&nbsp;';
608  }
609  if (!empty($conf->facture->enabled) && $key > 0) {
610  print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"), "stats").'</a>&nbsp;';
611  }
612  print '</td>';
613  print "</tr>\n";
614  $i++;
615  }
616 
617  // Total
618  print '<tr class="liste_total">';
619  print '<td>'.$langs->trans("Total").'</td>';
620  print '<td>&nbsp;</td>';
621  print '<td>&nbsp;</td>';
622  print '<td>&nbsp;</td>';
623  if ($modecompta != 'CREANCES-DETTES') {
624  print '<td></td>';
625  } else {
626  print '<td class="right">'.price($catotal_ht).'</td>';
627  }
628  print '<td class="right">'.price($catotal).'</td>';
629  print '<td>&nbsp;</td>';
630  print '<td>&nbsp;</td>';
631  print '</tr>';
632 
633  $db->free($result);
634 }
635 
636 print "</table>";
637 print "</div>";
638 
639 print '</form>';
640 
641 // End of page
642 llxFooter();
643 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink= '', $moreparam=array(), $calcmode= '', $varlink= '')
Show header of a report.
Definition: report.lib.php:41
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:481
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Classe permettant la generation de composants html autre Only common components are here...
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
img_next($titlealt= 'default', $moreatt= '')
Show next logo.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:498
print
Draft customers invoices.
Definition: index.php:89
img_previous($titlealt= 'default', $moreatt= '')
Show previous logo.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:114
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...