dolibarr  9.0.0
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 <http://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->societe_id > 0) $socid = $user->societe_id;
61 if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
62 if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');
63 
64 // Date range
65 $year=GETPOST("year",'int');
66 $month=GETPOST("month",'int');
67 $search_societe = GETPOST("search_societe",'alpha');
68 $search_zip = GETPOST("search_zip",'alpha');
69 $search_town = GETPOST("search_town",'alpha');
70 $search_country = GETPOST("search_country",'alpha');
71 $date_startyear = GETPOST("date_startyear",'alpha');
72 $date_startmonth = GETPOST("date_startmonth",'alpha');
73 $date_startday = GETPOST("date_startday",'alpha');
74 $date_endyear = GETPOST("date_endyear",'alpha');
75 $date_endmonth = GETPOST("date_endmonth",'alpha');
76 $date_endday = GETPOST("date_endday",'alpha');
77 if (empty($year))
78 {
79  $year_current = strftime("%Y",dol_now());
80  $month_current = strftime("%m",dol_now());
81  $year_start = $year_current;
82 } else {
83  $year_current = $year;
84  $month_current = strftime("%m",dol_now());
85  $year_start = $year;
86 }
87 $date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear"));
88 $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear"));
89 // Quarter
90 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
91 {
92  $q=GETPOST("q","int")?GETPOST("q","int"):0;
93  if (empty($q))
94  {
95  // We define date_start and date_end
96  $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
97  $year_end=$year_start;
98  $month_end=$month_start;
99  if (! GETPOST("month")) // If month not forced
100  {
101  if (! GETPOST('year') && $month_start > $month_current)
102  {
103  $year_start--;
104  $year_end--;
105  }
106  $month_end=$month_start-1;
107  if ($month_end < 1) $month_end=12;
108  else $year_end++;
109  }
110  $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
111  }
112  if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
113  if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
114  if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); }
115  if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
116 }
117 else
118 {
119  // TODO We define q
120 }
121 
122 // $date_start and $date_end are defined. We force $year_start and $nbofyear
123 $tmps=dol_getdate($date_start);
124 $year_start = $tmps['year'];
125 $tmpe=dol_getdate($date_end);
126 $year_end = $tmpe['year'];
127 $nbofyear = ($year_end - $year_start) + 1;
128 
129 $commonparams=array();
130 $commonparams['modecompta']=$modecompta;
131 $commonparams['sortorder'] = $sortorder;
132 $commonparams['sortfield'] = $sortfield;
133 
134 $headerparams = array();
135 $headerparams['date_startyear'] = $date_startyear;
136 $headerparams['date_startmonth'] = $date_startmonth;
137 $headerparams['date_startday'] = $date_startday;
138 $headerparams['date_endyear'] = $date_endyear;
139 $headerparams['date_endmonth'] = $date_endmonth;
140 $headerparams['date_endday'] = $date_endday;
141 $headerparams['q'] = $q;
142 
143 $tableparams = array();
144 $tableparams['search_categ'] = $selected_cat;
145 $tableparams['search_societe'] = $search_societe;
146 $tableparams['search_zip'] = $search_zip;
147 $tableparams['search_town'] = $search_town;
148 $tableparams['search_country'] = $search_country;
149 $tableparams['subcat'] = ($subcat === true)?'yes':'';
150 
151 // Adding common parameters
152 $allparams = array_merge($commonparams, $headerparams, $tableparams);
153 $headerparams = array_merge($commonparams, $headerparams);
154 $tableparams = array_merge($commonparams, $tableparams);
155 
156 foreach($allparams as $key => $value) {
157  $paramslink .= '&' . $key . '=' . $value;
158 }
159 
160 
161 /*
162  * View
163  */
164 
165 llxHeader();
166 
167 $form=new Form($db);
168 $thirdparty_static=new Societe($db);
169 $formother = new FormOther($db);
170 
171 // TODO Report from bookkeeping not yet available, so we switch on report on business events
172 if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES";
173 if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES";
174 
175 // Show report header
176 if ($modecompta=="CREANCES-DETTES")
177 {
178  $name=$langs->trans("Turnover").', '.$langs->trans("ByThirdParties");
179  $calcmode=$langs->trans("CalcModeDebt");
180  //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
181  $description=$langs->trans("RulesCADue");
182  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
183  else $description.= $langs->trans("DepositsAreIncluded");
184  $builddate=dol_now();
185  //$exportlink=$langs->trans("NotYetAvailable");
186 }
187 else if ($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 }
197 else if ($modecompta=="BOOKKEEPING")
198 {
199 
200 
201 }
202 else if ($modecompta=="BOOKKEEPINGCOLLECTED")
203 {
204 
205 
206 }
207 $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
208 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>';
209 else $periodlink = '';
210 
211 report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams,$calcmode);
212 
213 if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
214 {
215  print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
216 }
217 
218 
219 $name=array();
220 
221 // Show Array
222 $catotal=0;
223 if ($modecompta == 'CREANCES-DETTES') {
224  $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
225  $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
226  $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
227  if ($selected_cat === -2) // Without any category
228  {
229  $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
230  }
231  else if ($selected_cat) // Into a specific category
232  {
233  $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
234  }
235  $sql.= " WHERE f.fk_statut in (1,2)";
236  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
237  $sql.= " AND f.type IN (0,1,2,5)";
238  } else {
239  $sql.= " AND f.type IN (0,1,2,3,5)";
240  }
241  $sql.= " AND f.fk_soc = s.rowid";
242  if ($date_start && $date_end) {
243  $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
244  }
245  if ($selected_cat === -2) // Without any category
246  {
247  $sql.=" AND cs.fk_soc is null";
248  }
249  else if ($selected_cat) { // Into a specific category
250  $sql.= " AND (c.rowid = ".$db->escape($selected_cat);
251  if ($subcat) $sql.=" OR c.fk_parent = " . $db->escape($selected_cat);
252  $sql.= ")";
253  $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
254  }
255 } else {
256  /*
257  * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
258  * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
259  */
260  $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
261  $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
262  $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
263  $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
264  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
265  if ($selected_cat === -2) // Without any category
266  {
267  $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
268  }
269  else if ($selected_cat) // Into a specific category
270  {
271  $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
272  }
273  $sql.= " WHERE p.rowid = pf.fk_paiement";
274  $sql.= " AND pf.fk_facture = f.rowid";
275  $sql.= " AND f.fk_soc = s.rowid";
276  if ($date_start && $date_end) {
277  $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
278  }
279  if ($selected_cat === -2) // Without any category
280  {
281  $sql.=" AND cs.fk_soc is null";
282  }
283  else if ($selected_cat) { // Into a specific category
284  $sql.= " AND (c.rowid = ".$selected_cat;
285  if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat;
286  $sql.= ")";
287  $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
288  }
289 }
290 if (!empty($search_societe)) $sql.= natural_search('s.nom', $search_societe);
291 if (!empty($search_zip)) $sql.= natural_search('s.zip', $search_zip);
292 if (!empty($search_town)) $sql.= natural_search('s.town', $search_town);
293 if ($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.'';
294 $sql.= " AND f.entity = ".$conf->entity;
295 if ($socid) $sql.= " AND f.fk_soc = ".$socid;
296 $sql.= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
297 $sql.= " ORDER BY s.rowid";
298 //echo $sql;
299 
300 dol_syslog("casoc", LOG_DEBUG);
301 $result = $db->query($sql);
302 if ($result) {
303  $num = $db->num_rows($result);
304  $i=0;
305  while ($i < $num) {
306  $obj = $db->fetch_object($result);
307  $amount_ht[$obj->socid] = $obj->amount;
308  $amount[$obj->socid] = $obj->amount_ttc;
309  $name[$obj->socid] = $obj->name.' '.$obj->firstname;
310  $address_zip[$obj->socid] = $obj->zip;
311  $address_town[$obj->socid] = $obj->town;
312  $address_pays[$obj->socid] = getCountry($obj->fk_pays);
313  $catotal_ht+=$obj->amount;
314  $catotal+=$obj->amount_ttc;
315  $i++;
316  }
317 } else {
318  dol_print_error($db);
319 }
320 
321 // On ajoute les paiements anciennes version, non lies par paiement_facture
322 if ($modecompta != 'CREANCES-DETTES') {
323  $sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc";
324  $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
325  $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
326  $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
327  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
328  $sql.= " WHERE pf.rowid IS NULL";
329  $sql.= " AND p.fk_bank = b.rowid";
330  $sql.= " AND b.fk_account = ba.rowid";
331  $sql.= " AND ba.entity IN (".getEntity('bank_account').")";
332  if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
333  $sql.= " GROUP BY socid, name";
334  $sql.= " ORDER BY name";
335 
336  $result = $db->query($sql);
337  if ($result) {
338  $num = $db->num_rows($result);
339  $i=0;
340  while ($i < $num) {
341  $obj = $db->fetch_object($result);
342  $amount[$obj->rowid] += $obj->amount_ttc;
343  $name[$obj->rowid] = $obj->name;
344  $address_zip[$obj->rowid] = $obj->zip;
345  $address_town[$obj->rowid] = $obj->town;
346  $address_pays[$obj->rowid] = getCountry($obj->fk_pays);
347  $catotal+=$obj->amount_ttc;
348  $i++;
349  }
350  } else {
351  dol_print_error($db);
352  }
353 }
354 
355 
356 // Show array
357 $i = 0;
358 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
359 // Extra parameters management
360 foreach($headerparams as $key => $value)
361 {
362  print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
363 }
364 
365 $moreforfilter='';
366 
367 print '<div class="div-table-responsive">';
368 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
369 
370 // Category filter
371 print '<tr class="liste_titre">';
372 print '<td>';
373 print $langs->trans("Category") . ': ' . $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_cat, 'search_categ', true);
374 print ' ';
375 print $langs->trans("SubCats") . '? ';
376 print '<input type="checkbox" name="subcat" value="yes"';
377 if ($subcat) {
378  print ' checked';
379 }
380 print'></td>';
381 print '<td colspan="7" align="right">';
382 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")).'">';
383 print '</td>';
384 print '</tr>';
385 
386 print '<tr class="liste_titre">';
387 print '<td class="liste_titre" align="left">';
388 print '<input class="flat" size="6" type="text" name="search_societe" value="'.$search_societe.'">';
389 print '</td>';
390 print '<td class="liste_titre" align="left">';
391 print '<input class="flat" size="6" type="text" name="search_zip" value="'.$search_zip.'">';
392 print '</td>';
393 print '<td class="liste_titre" align="left">';
394 print '<input class="flat" size="6" type="text" name="search_town" value="'.$search_town.'">';
395 print '</td>';
396 print '<td class="liste_titre" align="left">';
397 print $form->select_country($search_country, 'search_country');
398 //print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
399 print '</td>';
400 print '<td class="liste_titre">&nbsp;</td>';
401 print '<td class="liste_titre">&nbsp;</td>';
402 print '<td class="liste_titre">&nbsp;</td>';
403 print '<td class="liste_titre">&nbsp;</td>';
404 print '</tr>';
405 
406 // Array titles
407 print "<tr class='liste_titre'>";
409  $langs->trans("Company"),
410  $_SERVER["PHP_SELF"],
411  "nom",
412  "",
413  $paramslink,
414  "",
415  $sortfield,$sortorder
416  );
418  $langs->trans("Zip"),
419  $_SERVER["PHP_SELF"],
420  "zip",
421  "",
422  $paramslink,
423  "",
424  $sortfield,$sortorder
425  );
427  $langs->trans("Town"),
428  $_SERVER["PHP_SELF"],
429  "town",
430  "",
431  $paramslink,
432  "",
433  $sortfield,$sortorder
434  );
436  $langs->trans("Country"),
437  $_SERVER["PHP_SELF"],
438  "country",
439  "",
440  $paramslink,
441  "",
442  $sortfield,$sortorder
443  );
444 if ($modecompta == 'CREANCES-DETTES') {
446  $langs->trans('AmountHT'),
447  $_SERVER["PHP_SELF"],
448  "amount_ht",
449  "",
450  $paramslink,
451  'align="right"',
452  $sortfield,
453  $sortorder
454  );
455  } else {
457 }
459  $langs->trans("AmountTTC"),
460  $_SERVER["PHP_SELF"],
461  "amount_ttc",
462  "",
463  $paramslink,
464  'align="right"',
465  $sortfield,
466  $sortorder
467  );
469  $langs->trans("Percentage"),
470  $_SERVER["PHP_SELF"],
471  "amount_ttc",
472  "",
473  $paramslink,
474  'align="right"',
475  $sortfield,
476  $sortorder
477  );
479  $langs->trans("OtherStatistics"),
480  $_SERVER["PHP_SELF"],
481  "",
482  "",
483  "",
484  'align="center" width="20%"'
485  );
486 print "</tr>\n";
487 
488 
489 if (count($amount)) {
490  $arrayforsort=$name;
491  // Defining array arrayforsort
492  if ($sortfield == 'nom' && $sortorder == 'asc') {
493  asort($name);
494  $arrayforsort=$name;
495  }
496  if ($sortfield == 'nom' && $sortorder == 'desc') {
497  arsort($name);
498  $arrayforsort=$name;
499  }
500  if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
501  asort($amount_ht);
502  $arrayforsort=$amount_ht;
503  }
504  if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
505  arsort($amount_ht);
506  $arrayforsort=$amount_ht;
507  }
508  if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
509  asort($amount);
510  $arrayforsort=$amount;
511  }
512  if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
513  arsort($amount);
514  $arrayforsort=$amount;
515  }
516  if ($sortfield == 'zip' && $sortorder == 'asc') {
517  asort($address_zip);
518  $arrayforsort=$address_zip;
519  }
520  if ($sortfield == 'zip' && $sortorder == 'desc') {
521  arsort($address_zip);
522  $arrayforsort=$address_zip;
523  }
524  if ($sortfield == 'town' && $sortorder == 'asc') {
525  asort($address_town);
526  $arrayforsort=$address_town;
527  }
528  if ($sortfield == 'town' && $sortorder == 'desc') {
529  arsort($address_town);
530  $arrayforsort=$address_town;
531  }
532  if ($sortfield == 'country' && $sortorder == 'asc') {
533  asort($address_pays);
534  $arrayforsort=$address_town;
535  }
536  if ($sortfield == 'country' && $sortorder == 'desc') {
537  arsort($address_pays);
538  $arrayforsort=$address_town;
539  }
540 
541  foreach($arrayforsort as $key=>$value) {
542 
543  print '<tr class="oddeven">';
544 
545  // Third party
546  $fullname=$name[$key];
547  if ($key > 0) {
548  $thirdparty_static->id=$key;
549  $thirdparty_static->name=$fullname;
550  $thirdparty_static->client=1;
551  $linkname=$thirdparty_static->getNomUrl(1,'customer');
552  } else {
553  $linkname=$langs->trans("PaymentsNotLinkedToInvoice");
554  }
555  print "<td>".$linkname."</td>\n";
556 
557  print '<td>';
558  print $address_zip[$key];
559  print '</td>';
560 
561  print '<td>';
562  print $address_town[$key];
563  print '</td>';
564 
565  print '<td>';
566  print $address_pays[$key];
567  print '</td>';
568 
569  // Amount w/o VAT
570  print '<td align="right">';
571  if ($modecompta != 'CREANCES-DETTES') {
572  if ($key > 0) {
573  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
574  } else {
575  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid=-1">';
576  }
577  } else {
578  if ($key > 0) {
579  print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
580  } else {
581  print '<a href="#">';
582  }
583  print price($amount_ht[$key]);
584  }
585  print '</td>';
586 
587  // Amount with VAT
588  print '<td align="right">';
589  if ($modecompta != 'CREANCES-DETTES') {
590  if ($key > 0) {
591  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?socid='.$key.'">';
592  } else {
593  print '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?orphelins=1">';
594  }
595  } else {
596  if ($key > 0) {
597  print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
598  } else {
599  print '<a href="#">';
600  }
601  }
602  print price($amount[$key]);
603  print '</a>';
604  print '</td>';
605 
606  // Percent;
607  print '<td align="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
608 
609  // Other stats
610  print '<td align="center">';
611  if (! empty($conf->propal->enabled) && $key>0) {
612  print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"),"stats").'</a>&nbsp;';
613  }
614  if (! empty($conf->commande->enabled) && $key>0) {
615  print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("OrderStats"),"stats").'</a>&nbsp;';
616  }
617  if (! empty($conf->facture->enabled) && $key>0) {
618  print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"),"stats").'</a>&nbsp;';
619  }
620  print '</td>';
621  print "</tr>\n";
622  $i++;
623  }
624 
625  // Total
626  print '<tr class="liste_total">';
627  print '<td>'.$langs->trans("Total").'</td>';
628  print '<td>&nbsp;</td>';
629  print '<td>&nbsp;</td>';
630  print '<td>&nbsp;</td>';
631  if ($modecompta != 'CREANCES-DETTES') {
632  print '<td colspan="1"></td>';
633  } else {
634  print '<td align="right">'.price($catotal_ht).'</td>';
635  }
636  print '<td align="right">'.price($catotal).'</td>';
637  print '<td>&nbsp;</td>';
638  print '<td>&nbsp;</td>';
639  print '</tr>';
640 
641  $db->free($result);
642 }
643 
644 print "</table>";
645 print "</div>";
646 
647 print '</form>';
648 
649 // End of page
650 llxFooter();
651 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
img_next($titlealt='default', $moreatt='')
Show next logo.
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)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='')
Show information for admin users or standard users.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:44
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...
dol_now($mode='gmt')
Return date for now.
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_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
Definition: report.lib.php:41
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:116
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)