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