dolibarr  7.0.0-beta
invoicetemplate_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6  * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
8  * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
9  * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
10  * Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
32 require '../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 if (! empty($conf->projet->enabled)) {
37  require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
38  //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
39 }
40 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
41 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
42 require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
43 require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
44 
45 $langs->load('bills');
46 $langs->load('compta');
47 $langs->load('admin');
48 $langs->load('other');
49 
50 $action = GETPOST('action','alpha');
51 $massaction = GETPOST('massaction','alpha');
52 $show_files = GETPOST('show_files','int');
53 $confirm = GETPOST('confirm','alpha');
54 $cancel = GETPOST('cancel', 'alpha');
55 $toselect = GETPOST('toselect', 'array');
56 $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search
57 
58 // Security check
59 $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int'));
60 $lineid=GETPOST('lineid','int');
61 $ref=GETPOST('ref','alpha');
62 if ($user->societe_id) $socid=$user->societe_id;
63 $objecttype = 'facture_rec';
64 if ($action == "create" || $action == "add") $objecttype = '';
65 $result = restrictedArea($user, 'facture', $id, $objecttype);
66 $projectid = GETPOST('projectid','int');
67 
68 $search_ref=GETPOST('search_ref');
69 $search_societe=GETPOST('search_societe');
70 $search_montant_ht=GETPOST('search_montant_ht');
71 $search_montant_vat=GETPOST('search_montant_vat');
72 $search_montant_ttc=GETPOST('search_montant_ttc');
73 $search_payment_mode=GETPOST('search_payment_mode');
74 $search_payment_term=GETPOST('search_payment_term');
75 $day=GETPOST('day');
76 $year=GETPOST('year');
77 $month=GETPOST('month');
78 $day_date_when=GETPOST('day_date_when');
79 $year_date_when=GETPOST('year_date_when');
80 $month_date_when=GETPOST('month_date_when');
81 $search_recurring=GETPOST('search_recurring','int');
82 $search_frequency=GETPOST('search_frequency','alpha');
83 $search_unit_frequency=GETPOST('search_unit_frequency','alpha');
84 $search_status=GETPOST('search_status','int');
85 
86 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
87 $sortfield = GETPOST("sortfield",'alpha');
88 $sortorder = GETPOST("sortorder",'alpha');
89 $page = GETPOST("page",'int');
90 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
91 $offset = $limit * $page;
92 if (! $sortorder) $sortorder='DESC';
93 if (! $sortfield) $sortfield='f.titre';
94 $pageprev = $page - 1;
95 $pagenext = $page + 1;
96 
97 $object = new FactureRec($db);
98 if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
99 {
100  $ret = $object->fetch($id, $ref);
101  if (!$ret)
102  {
103  setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
104  }
105 }
106 
107 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
108 $hookmanager->initHooks(array('invoicereccard','globalcard'));
109 $extrafields = new ExtraFields($db);
110 
111 // fetch optionals attributes and labels
112 $extralabels = $extrafields->fetch_name_optionals_label('facture_rec');
113 $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
114 
115 $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
116 $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
117 $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
118 
119 $arrayfields=array(
120  'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
121  's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
122  'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
123  'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
124  'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
125  'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0),
126  'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0),
127  'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
128  'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1),
129  'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1),
130  'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDoneShort"), 'checked'=>1),
131  'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGenerationShort"), 'checked'=>1),
132  'f.date_when'=>array('label'=>$langs->trans("NextDateToExecutionShort"), 'checked'=>1),
133  'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
134  'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
135  'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
136 );
137 // Extra fields
138 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
139 {
140  foreach($extrafields->attribute_label as $key => $val)
141  {
142  if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
143  }
144 }
145 
146 
147 /*
148  * Actions
149  */
150 
151 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
152 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
153 
154 $parameters = array('socid' => $socid);
155 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
156 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
157 
158 if (empty($reshook))
159 {
160  if (GETPOST('cancel','alpha')) $action='';
161 
162  // Selection of new fields
163  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
164 
165  // Do we click on purge search criteria ?
166  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
167  {
168  $search_ref='';
169  $search_societe='';
170  $search_montant_ht='';
171  $search_montant_vat='';
172  $search_montant_ttc='';
173  $search_payment_mode='';
174  $search_payment_term='';
175  $day='';
176  $year='';
177  $month='';
178  $day_date_when='';
179  $year_date_when='';
180  $month_date_when='';
181  $search_recurring='';
182  $search_frequency='';
183  $search_unit_frequency='';
184  $search_status='';
185  $search_array_options=array();
186  }
187 
188  // Mass actions
189  /*$objectclass='MyObject';
190  $objectlabel='MyObject';
191  $permtoread = $user->rights->mymodule->read;
192  $permtodelete = $user->rights->mymodule->delete;
193  $uploaddir = $conf->mymodule->dir_output;
194  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
195 
196 }
197 
198 
199 /*
200  * View
201  */
202 
203 llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec');
204 
205 $form = new Form($db);
206 $formother = new FormOther($db);
207 if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
208 $companystatic = new Societe($db);
209 $invoicerectmp = new FactureRec($db);
210 
211 $now = dol_now();
212 $tmparray=dol_getdate($now);
213 $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day
214 
215 
216 /*
217  * List mode
218  */
219 $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
220 $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
221 $sql.= " f.datec, f.tms,";
222 $sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
223 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
224 if (! $user->rights->societe->client->voir && ! $socid) {
225  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
226 }
227 $sql.= " WHERE f.fk_soc = s.rowid";
228 $sql.= ' AND f.entity IN ('.getEntity('facture').')';
229 if (! $user->rights->societe->client->voir && ! $socid) {
230  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
231 }
232 if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
233 if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
234 if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1);
235 if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1);
236 if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
237 if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
238 if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
239 if ($search_recurring == '1') $sql .= ' AND f.frequency > 0';
240 if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
241 if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1);
242 if ($search_unit_frequency != '') $sql .= natural_search('f.unit_frequency', $search_unit_frequency);
243 if ($search_status != '' && $search_status >= -1)
244 {
245  if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0';
246  if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0';
247  if ($search_status == -1) $sql.= ' AND suspended = 1';
248 }
249 if ($month > 0)
250 {
251  if ($year > 0 && empty($day))
252  $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
253  else if ($year > 0 && ! empty($day))
254  $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
255  else
256  $sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'";
257 }
258 else if ($year > 0)
259 {
260  $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
261 }
262 if ($month_date_when > 0)
263 {
264  if ($year_date_when > 0 && empty($day_date_when))
265  $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'";
266  else if ($year_date_when > 0 && ! empty($day_date_when))
267  $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'";
268  else
269  $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'";
270 }
271 else if ($year_date_when > 0)
272 {
273  $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
274 }
275 
276 $nbtotalofrecords = '';
277 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
278 {
279  $result = $db->query($sql);
280  $nbtotalofrecords = $db->num_rows($result);
281 }
282 
283 $sql.= $db->order($sortfield, $sortorder);
284 $sql.= $db->plimit($limit+1,$offset);
285 
286 $resql = $db->query($sql);
287 if ($resql)
288 {
289  $num = $db->num_rows($resql);
290 
291  $param='';
292  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
293  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
294  if ($socid) $param.='&socid='.urlencode($socid);
295  if ($day) $param.='&day='.urlencode($day);
296  if ($month) $param.='&month='.urlencode($month);
297  if ($year) $param.='&year=' .urlencode($year);
298  if ($day_date_when) $param.='&day_date_when='.urlencode($day_date_when);
299  if ($month_date_when) $param.='&month_date_when='.urlencode($month_date_when);
300  if ($year_date_when) $param.='&year_date_when=' .urlencode($year_date_when);
301  if ($search_ref) $param.='&search_ref=' .urlencode($search_ref);
302  if ($search_societe) $param.='&search_societe=' .urlencode($search_societe);
303  if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht);
304  if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat);
305  if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
306  if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode);
307  if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type);
308  if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring);
309  if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency);
310  if ($search_unit_frequency > 0) $param.='&search_unit_frequency='.urlencode($search_unit_frequency);
311  if ($search_status != '') $param.='&search_status='.urlencode($search_status);
312  if ($option) $param.="&option=".urlencode($option);
313  if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
314  // Add $param from extra fields
315  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
316 
317  $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
318 
319  $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
320  $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
321  //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
322 
323  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
324  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
325  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
326  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
327  print '<input type="hidden" name="action" value="list">';
328  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
329  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
330  print '<input type="hidden" name="page" value="'.$page.'">';
331  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
332  print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
333 
334  print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
335 
336  print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>';
337 
338  $i = 0;
339 
340  print '<div class="div-table-responsive">';
341  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
342 
343  // Filters lines
344  print '<tr class="liste_titre_filter">';
345  // Ref
346  if (! empty($arrayfields['f.titre']['checked']))
347  {
348  print '<td class="liste_titre" align="left">';
349  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
350  print '</td>';
351  }
352  // Thirpdarty
353  if (! empty($arrayfields['s.nom']['checked']))
354  {
355  print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
356  }
357  if (! empty($arrayfields['f.total']['checked']))
358  {
359  // Amount net
360  print '<td class="liste_titre" align="right">';
361  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
362  print '</td>';
363  }
364  if (! empty($arrayfields['f.tva']['checked']))
365  {
366  // Amount Vat
367  print '<td class="liste_titre" align="right">';
368  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
369  print '</td>';
370  }
371  if (! empty($arrayfields['f.total_ttc']['checked']))
372  {
373  // Amount
374  print '<td class="liste_titre" align="right">';
375  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
376  print '</td>';
377  }
378  if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
379  {
380  // Payment term
381  print '<td class="liste_titre" align="right">';
382  print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
383  print "</td>";
384  }
385  if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
386  {
387  // Payment mode
388  print '<td class="liste_titre" align="right">';
389  print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100');
390  print '</td>';
391  }
392  if (! empty($arrayfields['recurring']['checked']))
393  {
394  // Recurring or not
395  print '<td class="liste_titre" align="center">';
396  print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
397  print '</td>';
398  }
399  if (! empty($arrayfields['f.frequency']['checked']))
400  {
401  // Recurring or not
402  print '<td class="liste_titre" align="center">';
403  print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
404  print '</td>';
405  }
406  if (! empty($arrayfields['f.unit_frequency']['checked']))
407  {
408  // Frequency unit
409  print '<td class="liste_titre" align="center">';
410  print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
411  print '</td>';
412  }
413  if (! empty($arrayfields['f.nb_gen_done']['checked']))
414  {
415  // Nb generation
416  print '<td class="liste_titre" align="center">';
417  print '</td>';
418  }
419  // Date invoice
420  if (! empty($arrayfields['f.date_last_gen']['checked']))
421  {
422  print '<td class="liste_titre" align="center">';
423  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
424  print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
425  $formother->select_year($year?$year:-1,'year',1, 20, 5);
426  print '</td>';
427  }
428  // Date due
429  if (! empty($arrayfields['f.date_when']['checked']))
430  {
431  print '<td class="liste_titre" align="center">';
432  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_date_when" value="'.$day_date_when.'">';
433  print '<input class="flat" type="text" size="1" maxlength="2" name="month_date_when" value="'.$month_date_when.'">';
434  $formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5);
435  print '</td>';
436  }
437  // Extra fields
438  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
439 
440  // Fields from hook
441  $parameters=array('arrayfields'=>$arrayfields);
442  $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
443  print $hookmanager->resPrint;
444  // Date creation
445  if (! empty($arrayfields['f.datec']['checked']))
446  {
447  print '<td class="liste_titre">';
448  print '</td>';
449  }
450  // Date modification
451  if (! empty($arrayfields['f.tms']['checked']))
452  {
453  print '<td class="liste_titre">';
454  print '</td>';
455  }
456  // Status
457  if (! empty($arrayfields['status']['checked']))
458  {
459  print '<td class="liste_titre" align="center">';
460  $liststatus=array(
461  0=>$langs->trans("Draft"),
462  1=>$langs->trans("Active"),
463  -1=>$langs->trans("Disabled"),
464  );
465  print $form->selectarray('search_status', $liststatus, $search_status, -2);
466  print '</td>';
467  }
468  // Action column
469  print '<td class="liste_titre" align="middle">';
470  $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
471  print $searchpicto;
472  print '</td>';
473  print "</tr>\n";
474 
475 
476  print '<tr class="liste_titre">';
477  if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder);
478  if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder);
479  if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder);
480  if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
481  if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
482  if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder);
483  if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder);
484  if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder);
485  if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder);
486  if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder);
487  if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
488  if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
489  if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
490  if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
491  if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
492  if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder);
493  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n";
494  print "</tr>\n";
495 
496  if ($num > 0)
497  {
498  $i=0;
499  $totalarray=array();
500  while ($i < min($num,$limit))
501  {
502  $objp = $db->fetch_object($resql);
503  if (empty($objp)) break;
504 
505  $companystatic->id=$objp->socid;
506  $companystatic->name=$objp->name;
507 
508  $invoicerectmp->id=$objp->id?$objp->id:$objp->facid;
509  $invoicerectmp->frequency=$objp->frequency;
510  $invoicerectmp->suspended=$objp->suspended;
511  $invoicerectmp->unit_frequency=$objp->unit_frequency;
512  $invoicerectmp->nb_gen_max=$objp->nb_gen_max;
513  $invoicerectmp->nb_gen_done=$objp->nb_gen_done;
514  $invoicerectmp->ref=$objp->titre;
515 
516  print '<tr class="oddeven">';
517 
518  if (! empty($arrayfields['f.titre']['checked']))
519  {
520  print '<td>';
521  print $invoicerectmp->getNomUrl(1);
522  print "</a>";
523  print "</td>\n";
524  if (! $i) $totalarray['nbfield']++;
525  }
526  if (! empty($arrayfields['s.nom']['checked']))
527  {
528  print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>';
529  if (! $i) $totalarray['nbfield']++;
530  }
531  if (! empty($arrayfields['f.total']['checked']))
532  {
533  print '<td align="right">'.price($objp->total).'</td>'."\n";
534  if (! $i) $totalarray['nbfield']++;
535  if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total';
536  $totalarray['val']['f.total'] += $objp->total;
537  }
538  if (! empty($arrayfields['f.tva']['checked']))
539  {
540  print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
541  if (! $i) $totalarray['nbfield']++;
542  if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva';
543  $totalarray['val']['f.tva'] += $objp->total_vat;
544  }
545  if (! empty($arrayfields['f.total_ttc']['checked']))
546  {
547  print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
548  if (! $i) $totalarray['nbfield']++;
549  if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
550  $totalarray['val']['f.total_ttc'] += $objp->total_ttc;
551  }
552  // Payment term
553  if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
554  {
555  print '<td align="right">';
556  print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
557  print '</td>'."\n";
558  if (! $i) $totalarray['nbfield']++;
559  }
560  // Payment mode
561  if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
562  {
563  print '<td align="right">';
564  print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
565  print '</td>'."\n";
566  if (! $i) $totalarray['nbfield']++;
567  }
568  if (! empty($arrayfields['recurring']['checked']))
569  {
570  print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
571  if (! $i) $totalarray['nbfield']++;
572  }
573  if (! empty($arrayfields['f.frequency']['checked']))
574  {
575  print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
576  if (! $i) $totalarray['nbfield']++;
577  }
578  if (! empty($arrayfields['f.unit_frequency']['checked']))
579  {
580  print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
581  if (! $i) $totalarray['nbfield']++;
582  }
583  if (! empty($arrayfields['f.nb_gen_done']['checked']))
584  {
585  print '<td align="center">';
586  print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
587  print '</td>';
588  if (! $i) $totalarray['nbfield']++;
589  }
590  if (! empty($arrayfields['f.date_last_gen']['checked']))
591  {
592  print '<td align="center">';
593  print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
594  print '</td>';
595  if (! $i) $totalarray['nbfield']++;
596  }
597  if (! empty($arrayfields['f.date_when']['checked']))
598  {
599  print '<td align="center">';
600  print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
601  print '</td>';
602  if (! $i) $totalarray['nbfield']++;
603  }
604  if (! empty($arrayfields['f.datec']['checked']))
605  {
606  print '<td align="center">';
607  print dol_print_date($db->jdate($objp->datec),'dayhour');
608  print '</td>';
609  if (! $i) $totalarray['nbfield']++;
610  }
611  if (! empty($arrayfields['f.tms']['checked']))
612  {
613  print '<td align="center">';
614  print dol_print_date($db->jdate($objp->tms),'dayhour');
615  print '</td>';
616  if (! $i) $totalarray['nbfield']++;
617  }
618  if (! empty($arrayfields['status']['checked']))
619  {
620  print '<td align="center">';
621  print $invoicerectmp->getLibStatut(3,0);
622  print '</td>';
623  if (! $i) $totalarray['nbfield']++;
624  }
625  // Action column
626  print '<td align="center">';
627  if ($user->rights->facture->creer && empty($invoicerectmp->suspended))
628  {
629  if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
630  {
631  print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
632  print $langs->trans("CreateBill").'</a>';
633  }
634  else
635  {
636  print $langs->trans("DateIsNotEnough");
637  }
638  }
639  else
640  {
641  print "&nbsp;";
642  }
643  if (! $i) $totalarray['nbfield']++;
644  print "</td>";
645 
646  print "</tr>\n";
647 
648  $i++;
649  }
650  }
651  else
652  {
653  $colspan=1;
654  foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
655  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
656  }
657 
658  //var_dump($totalarray);
659  // Show total line
660  if (isset($totalarray['pos']))
661  {
662  print '<tr class="liste_total">';
663  $i=0;
664  while ($i < $totalarray['nbfield'])
665  {
666  $i++;
667  if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
668  else
669  {
670  if ($i == 1)
671  {
672  if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
673  else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
674  }
675  else print '<td></td>';
676  }
677  }
678  print '</tr>';
679  }
680 
681  print "</table>";
682  print "</div>";
683  print "</form>";
684 
685  $db->free($resql);
686 }
687 else
688 {
689  dol_print_error($db);
690 }
691 
692 llxFooter();
693 
694 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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...
Class to manage invoice templates.
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...
if(empty($reshook)) $form
View.
Definition: perms.php:103
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 standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage building of HTML components.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:46
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.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
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.
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.