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 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
44 $langs->loadLangs(array(
'bills',
'compta',
'admin',
'other'));
46 $action =
GETPOST(
'action',
'alpha');
47 $massaction =
GETPOST(
'massaction',
'alpha');
48 $show_files =
GETPOST(
'show_files',
'int');
49 $confirm =
GETPOST(
'confirm',
'alpha');
50 $cancel =
GETPOST(
'cancel',
'alpha');
51 $toselect =
GETPOST(
'toselect',
'array');
52 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicetemplatelist';
53 $optioncss =
GETPOST(
'optioncss',
'alpha');
55 $socid =
GETPOST(
'socid',
'int');
59 $lineid =
GETPOST(
'lineid',
'int');
62 $socid = $user->socid;
64 $objecttype =
'facture_rec';
65 if ($action ==
"create" || $action ==
"add") {
70 $search_ref =
GETPOST(
'search_ref');
71 $search_societe =
GETPOST(
'search_societe');
72 $search_montant_ht =
GETPOST(
'search_montant_ht');
73 $search_montant_vat =
GETPOST(
'search_montant_vat');
74 $search_montant_ttc =
GETPOST(
'search_montant_ttc');
75 $search_payment_mode =
GETPOST(
'search_payment_mode');
76 $search_payment_term =
GETPOST(
'search_payment_term');
77 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
78 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
79 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
80 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
81 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
82 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
83 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
84 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
85 $search_date_when_startday =
GETPOST(
'search_date_when_startday',
'int');
86 $search_date_when_startmonth =
GETPOST(
'search_date_when_startmonth',
'int');
87 $search_date_when_startyear =
GETPOST(
'search_date_when_startyear',
'int');
88 $search_date_when_endday =
GETPOST(
'search_date_when_endday',
'int');
89 $search_date_when_endmonth =
GETPOST(
'search_date_when_endmonth',
'int');
90 $search_date_when_endyear =
GETPOST(
'search_date_when_endyear',
'int');
91 $search_date_when_start =
dol_mktime(0, 0, 0, $search_date_when_startmonth, $search_date_when_startday, $search_date_when_startyear);
92 $search_date_when_end =
dol_mktime(23, 59, 59, $search_date_when_endmonth, $search_date_when_endday, $search_date_when_endyear);
93 $search_recurring =
GETPOST(
'search_recurring',
'int');
94 $search_frequency =
GETPOST(
'search_frequency',
'alpha');
95 $search_unit_frequency =
GETPOST(
'search_unit_frequency',
'alpha');
96 $search_status =
GETPOST(
'search_status',
'int');
98 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
99 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
100 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
102 if (empty($page) || $page == -1) {
105 $offset = $limit * $page;
110 $sortfield =
'f.titre';
112 $pageprev = $page - 1;
113 $pagenext = $page + 1;
116 if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
117 $ret = $object->fetch($id, $ref);
124 $hookmanager->initHooks(array(
'invoicereclist'));
128 $extrafields->fetch_name_optionals_label($object->table_element);
130 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
132 $permissionnote = $user->rights->facture->creer;
133 $permissiondellink = $user->rights->facture->creer;
134 $permissiontoedit = $user->rights->facture->creer;
136 $arrayfields = array(
137 'f.titre'=>array(
'label'=>
"Ref",
'checked'=>1),
138 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
139 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1),
140 'f.total_tva'=>array(
'label'=>
"AmountVAT",
'checked'=>1),
141 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>1),
142 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>0),
143 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentTerm",
'checked'=>0),
144 'recurring'=>array(
'label'=>
"RecurringInvoice",
'checked'=>1),
145 'f.frequency'=>array(
'label'=>
"Frequency",
'checked'=>1),
146 'f.unit_frequency'=>array(
'label'=>
"FrequencyUnit",
'checked'=>1),
147 'f.nb_gen_done'=>array(
'label'=>
"NbOfGenerationDoneShort",
'checked'=>1),
148 'f.date_last_gen'=>array(
'label'=>
"DateLastGenerationShort",
'checked'=>1),
149 'f.date_when'=>array(
'label'=>
"NextDateToExecutionShort",
'checked'=>1),
150 'f.fk_user_author'=>array(
'label'=>
"UserCreation",
'checked'=>0,
'position'=>500),
151 'f.fk_user_modif'=>array(
'label'=>
"UserModification",
'checked'=>0,
'position'=>505),
152 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>520),
153 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>525),
154 'status'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
157 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
163 $tmpthirdparty =
new Societe($db);
164 $res = $tmpthirdparty->fetch($socid);
166 $search_societe = $tmpthirdparty->name;
172 $tmpthirdparty =
new Societe($db);
173 $res = $tmpthirdparty->fetch($socid);
175 $search_societe = $tmpthirdparty->name;
179 $objecttype =
'facture_rec';
181 $result =
restrictedArea($user,
'facture', $object->id, $objecttype);
188 if (
GETPOST(
'cancel',
'alpha')) {
192 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
196 $parameters = array(
'socid' => $socid);
197 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
202 if (empty($reshook)) {
203 if (
GETPOST(
'cancel',
'alpha')) {
208 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
211 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
213 $search_societe =
'';
214 $search_montant_ht =
'';
215 $search_montant_vat =
'';
216 $search_montant_ttc =
'';
217 $search_payment_mode =
'';
218 $search_payment_term =
'';
219 $search_date_startday =
'';
220 $search_date_startmonth =
'';
221 $search_date_startyear =
'';
222 $search_date_endday =
'';
223 $search_date_endmonth =
'';
224 $search_date_endyear =
'';
225 $search_date_start =
'';
226 $search_date_end =
'';
227 $search_date_when_startday =
'';
228 $search_date_when_startmonth =
'';
229 $search_date_when_startyear =
'';
230 $search_date_when_endday =
'';
231 $search_date_when_endmonth =
'';
232 $search_date_when_endyear =
'';
233 $search_date_when_start =
'';
234 $search_date_when_end =
'';
235 $search_recurring =
'';
236 $search_frequency =
'';
237 $search_unit_frequency =
'';
239 $search_array_options = array();
256 llxHeader(
'', $langs->trans(
"RepeatableInvoices"),
'ch-facture.html#s-fac-facture-rec');
263 $companystatic =
new Societe($db);
265 $tmpuser =
new User($db);
269 $today =
dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
276 $sql =
"SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total_ht, f.total_tva, f.total_ttc, f.frequency, f.unit_frequency,";
277 $sql .=
" f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
278 $sql .=
" f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
279 $sql .=
" f.fk_cond_reglement, f.fk_mode_reglement";
281 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
282 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
283 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
287 $parameters = array();
288 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
289 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
290 $sql = preg_replace(
'/,\s*$/',
'', $sql);
292 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_rec as f";
293 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
294 if (empty($user->rights->societe->client->voir) && !$socid) {
295 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
297 $sql .=
" WHERE f.fk_soc = s.rowid";
298 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
299 if (empty($user->rights->societe->client->voir) && !$socid) {
300 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
306 $sql .=
' AND s.rowid = '.(int) $socid;
308 if ($search_societe) {
311 if ($search_montant_ht !=
'') {
314 if ($search_montant_vat !=
'') {
317 if ($search_montant_ttc !=
'') {
320 if (!empty($search_payment_mode) && $search_payment_mode !=
'-1') {
321 $sql .=
natural_search(
'f.fk_mode_reglement', $search_payment_mode, 1);
323 if (!empty($search_payment_term) && $search_payment_term !=
'-1') {
324 $sql .=
natural_search(
'f.fk_cond_reglement', $search_payment_term, 1);
326 if ($search_recurring ==
'1') {
327 $sql .=
' AND f.frequency > 0';
329 if ($search_recurring ==
'0') {
330 $sql .=
' AND (f.frequency IS NULL or f.frequency = 0)';
332 if ($search_frequency !=
'') {
335 if ($search_unit_frequency !=
'') {
336 $sql .=
' AND f.frequency > 0'.natural_search(
'f.unit_frequency', $search_unit_frequency);
338 if ($search_status !=
'' && $search_status >= -1) {
339 if ($search_status == 0) {
340 $sql .=
' AND frequency = 0 AND suspended = 0';
342 if ($search_status == 1) {
343 $sql .=
' AND frequency != 0 AND suspended = 0';
345 if ($search_status == -1) {
346 $sql .=
' AND suspended = 1';
349 if ($search_date_start) {
350 $sql .=
" AND f.date_last_gen >= '".$db->idate($search_date_start).
"'";
352 if ($search_date_end) {
353 $sql .=
" AND f.date_last_gen <= '".$db->idate($search_date_end).
"'";
355 if ($search_date_when_start) {
356 $sql .=
" AND f.date_when >= '".$db->idate($search_date_when_start).
"'";
358 if ($search_date_when_end) {
359 $sql .=
" AND f.date_when <= '".$db->idate($search_date_when_end).
"'";
362 $tmpsortfield = $sortfield;
363 if ($tmpsortfield ==
'recurring') {
364 $tmpsortfield =
'f.frequency';
366 $sql .= $db->order($tmpsortfield, $sortorder);
368 $nbtotalofrecords =
'';
369 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
370 $result = $db->query($sql);
371 $nbtotalofrecords = $db->num_rows($result);
372 if (($page * $limit) > $nbtotalofrecords) {
378 $sql .= $db->plimit($limit + 1, $offset);
380 $resql = $db->query($sql);
382 $num = $db->num_rows(
$resql);
385 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
386 $param .=
'&contextpage='.urlencode($contextpage);
388 if ($limit > 0 && $limit != $conf->liste_limit) {
389 $param .=
'&limit='.urlencode($limit);
392 $param .=
'&socid='.urlencode($socid);
394 if ($search_date_startday) {
395 $param .=
'&search_date_startday='.urlencode($search_date_startday);
397 if ($search_date_startmonth) {
398 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
400 if ($search_date_startyear) {
401 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
403 if ($search_date_endday) {
404 $param .=
'&search_date_endday='.urlencode($search_date_endday);
406 if ($search_date_endmonth) {
407 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
409 if ($search_date_endyear) {
410 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
412 if ($search_date_when_startday) {
413 $param .=
'&search_date_when_startday='.urlencode($search_date_when_startday);
415 if ($search_date_when_startmonth) {
416 $param .=
'&search_date_when_startmonth='.urlencode($search_date_when_startmonth);
418 if ($search_date_when_startyear) {
419 $param .=
'&search_date_when_startyear='.urlencode($search_date_when_startyear);
421 if ($search_date_when_endday) {
422 $param .=
'&search_date_when_endday='.urlencode($search_date_when_endday);
424 if ($search_date_when_endmonth) {
425 $param .=
'&search_date_when_endmonth='.urlencode($search_date_when_endmonth);
427 if ($search_date_when_endyear) {
428 $param .=
'&search_date_when_endyear='.urlencode($search_date_when_endyear);
431 $param .=
'&search_ref='.urlencode($search_ref);
433 if ($search_societe) {
434 $param .=
'&search_societe='.urlencode($search_societe);
436 if ($search_montant_ht !=
'') {
437 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
439 if ($search_montant_vat !=
'') {
440 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
442 if ($search_montant_ttc !=
'') {
443 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
445 if ($search_payment_mode !=
'') {
446 $param .=
'&search_payment_mode='.urlencode($search_payment_mode);
448 if ($search_payment_term !=
'') {
449 $param .=
'&search_payment_term='.urlencode($search_payment_term);
451 if ($search_recurring !=
'' && $search_recurring !=
'-1') {
452 $param .=
'&search_recurring='.urlencode($search_recurring);
454 if ($search_frequency > 0) {
455 $param .=
'&search_frequency='.urlencode($search_frequency);
457 if ($search_unit_frequency !=
'') {
458 $param .=
'&search_unit_frequency='.urlencode($search_unit_frequency);
460 if ($search_status !=
'') {
461 $param .=
'&search_status='.urlencode($search_status);
463 if ($optioncss !=
'') {
464 $param .=
'&optioncss='.urlencode($optioncss);
467 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
469 $massactionbutton =
$form->selectMassAction(
'', $massaction ==
'presend' ? array() : array(
'presend'=>$langs->trans(
"SendByMail"),
'builddoc'=>$langs->trans(
"PDFMerge")));
471 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
472 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
475 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
476 if ($optioncss !=
'') {
477 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
479 print
'<input type="hidden" name="token" value="'.newToken().
'">';
480 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
481 print
'<input type="hidden" name="action" value="list">';
482 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
483 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
484 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
485 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
487 $title = $langs->trans(
"RepeatableInvoices");
489 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'bill', 0,
'',
'', $limit, 0, 0, 1);
491 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv(
"ChangeIntoRepeatableInvoice")).
'</span><br><br>';
497 print
'<div class="div-table-responsive">';
498 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
501 print
'<tr class="liste_titre_filter">';
503 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
504 print
'<td class="liste_titre left">';
505 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
509 if (!empty($arrayfields[
's.nom'][
'checked'])) {
510 print
'<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
512 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
514 print
'<td class="liste_titre right">';
515 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
518 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
520 print
'<td class="liste_titre right">';
521 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
524 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
526 print
'<td class="liste_titre right">';
527 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
530 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
532 print
'<td class="liste_titre right">';
533 $form->select_conditions_paiements($search_payment_term,
'search_payment_term', -1, 1, 1,
'maxwidth100');
536 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
538 print
'<td class="liste_titre right">';
539 $form->select_types_paiements($search_payment_mode,
'search_payment_mode',
'', 0, 1, 1, 0, 1,
'maxwidth100');
542 if (!empty($arrayfields[
'recurring'][
'checked'])) {
544 print
'<td class="liste_titre center">';
545 print
$form->selectyesno(
'search_recurring', $search_recurring, 1,
false, 1);
548 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
550 print
'<td class="liste_titre center">';
551 print
'<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).
'">';
554 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
556 print
'<td class="liste_titre center">';
557 print
'<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).
'">';
560 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
562 print
'<td class="liste_titre" align="center">';
566 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
567 print
'<td class="liste_titre center">';
568 print
'<div class="nowrap">';
569 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
571 print
'<div class="nowrap">';
572 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
577 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
578 print
'<td class="liste_titre center">';
579 print
'<div class="nowrap">';
580 print
$form->selectDate($search_date_when_start ? $search_date_when_start : -1,
'search_date_when_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
582 print
'<div class="nowrap">';
583 print
$form->selectDate($search_date_when_end ? $search_date_when_end : -1,
'search_date_when_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
588 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
591 $parameters = array(
'arrayfields'=>$arrayfields);
592 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
593 print $hookmanager->resPrint;
595 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
596 print
'<td class="liste_titre">';
600 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
601 print
'<td class="liste_titre">';
605 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
606 print
'<td class="liste_titre">';
610 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
611 print
'<td class="liste_titre">';
615 if (!empty($arrayfields[
'status'][
'checked'])) {
616 print
'<td class="liste_titre center">';
618 0=>$langs->trans(
"Draft"),
619 1=>$langs->trans(
"Active"),
620 -1=>$langs->trans(
"Disabled"),
622 print
$form->selectarray(
'search_status', $liststatus, $search_status, -2, 0, 0,
'', 0, 0, 0,
'',
'width100');
626 print
'<td class="liste_titre" align="middle">';
627 $searchpicto =
$form->showFilterButtons();
632 print
'<tr class="liste_titre">';
633 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
634 print_liste_field_titre($arrayfields[
'f.titre'][
'label'], $_SERVER[
'PHP_SELF'],
"f.titre",
"", $param,
"", $sortfield, $sortorder);
636 if (!empty($arrayfields[
's.nom'][
'checked'])) {
637 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
639 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
640 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ht",
"", $param,
'class="right"', $sortfield, $sortorder);
642 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
643 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_tva",
"", $param,
'class="right"', $sortfield, $sortorder);
645 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
646 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ttc",
"", $param,
'class="right"', $sortfield, $sortorder);
648 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
649 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
651 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
652 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
654 if (!empty($arrayfields[
'recurring'][
'checked'])) {
655 print_liste_field_titre($arrayfields[
'recurring'][
'label'], $_SERVER[
'PHP_SELF'],
"recurring",
"", $param,
'class="center"', $sortfield, $sortorder);
657 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
658 print_liste_field_titre($arrayfields[
'f.frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.frequency",
"", $param,
'align="center"', $sortfield, $sortorder);
660 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
661 print_liste_field_titre($arrayfields[
'f.unit_frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.unit_frequency",
"", $param,
'align="center"', $sortfield, $sortorder);
663 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
664 print_liste_field_titre($arrayfields[
'f.nb_gen_done'][
'label'], $_SERVER[
'PHP_SELF'],
"f.nb_gen_done",
"", $param,
'align="center"', $sortfield, $sortorder);
666 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
667 print_liste_field_titre($arrayfields[
'f.date_last_gen'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_last_gen",
"", $param,
'align="center"', $sortfield, $sortorder);
669 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
670 print_liste_field_titre($arrayfields[
'f.date_when'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_when",
"", $param,
'align="center"', $sortfield, $sortorder);
672 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
673 print_liste_field_titre($arrayfields[
'f.fk_user_author'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_author",
"", $param,
'align="center"', $sortfield, $sortorder);
675 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
676 print_liste_field_titre($arrayfields[
'f.fk_user_modif'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_modif",
"", $param,
'align="center"', $sortfield, $sortorder);
678 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
679 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
'PHP_SELF'],
"f.datec",
"", $param,
'align="center"', $sortfield, $sortorder);
681 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
682 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"f.tms",
"", $param,
'align="center"', $sortfield, $sortorder);
685 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
686 if (!empty($arrayfields[
'status'][
'checked'])) {
687 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
'PHP_SELF'],
"f.suspended,f.frequency",
"", $param,
'align="center"', $sortfield, $sortorder);
689 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'center maxwidthsearch ');
694 $totalarray = array();
695 $totalarray[
'nbfield'] = 0;
696 $totalarray[
'val'][
'f.total_ht'] = 0;
697 $totalarray[
'val'][
'f.total_tva'] = 0;
698 $totalarray[
'val'][
'f.total_ttc'] = 0;
699 while ($i < min($num, $limit)) {
700 $objp = $db->fetch_object(
$resql);
705 $companystatic->id = $objp->socid;
706 $companystatic->name = $objp->name;
708 $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
709 $invoicerectmp->frequency = $objp->frequency;
710 $invoicerectmp->suspended = $objp->suspended;
711 $invoicerectmp->unit_frequency = $objp->unit_frequency;
712 $invoicerectmp->nb_gen_max = $objp->nb_gen_max;
713 $invoicerectmp->nb_gen_done = $objp->nb_gen_done;
714 $invoicerectmp->ref = $objp->title;
715 $invoicerectmp->total_ht = $objp->total_ht;
716 $invoicerectmp->total_tva = $objp->total_tva;
717 $invoicerectmp->total_ttc = $objp->total_ttc;
719 print
'<tr class="oddeven">';
721 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
722 print
'<td class="nowrap tdoverflowmax200">';
723 print $invoicerectmp->getNomUrl(1);
726 $totalarray[
'nbfield']++;
729 if (!empty($arrayfields[
's.nom'][
'checked'])) {
730 print
'<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
732 $totalarray[
'nbfield']++;
735 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
736 print
'<td class="nowrap right amount">'.price($objp->total_ht).
'</td>'.
"\n";
738 $totalarray[
'nbfield']++;
741 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
743 $totalarray[
'val'][
'f.total_ht'] += $objp->total_ht;
745 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
746 print
'<td class="nowrap right amount">'.price($objp->total_tva).
'</td>'.
"\n";
748 $totalarray[
'nbfield']++;
751 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
753 $totalarray[
'val'][
'f.total_tva'] += $objp->total_tva;
755 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
756 print
'<td class="nowrap right amount">'.price($objp->total_ttc).
'</td>'.
"\n";
758 $totalarray[
'nbfield']++;
761 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
763 $totalarray[
'val'][
'f.total_ttc'] += $objp->total_ttc;
766 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
767 print
'<td class="tdoverflowmax150">';
768 $form->form_conditions_reglement(
'', $objp->fk_cond_reglement,
'none');
771 $totalarray[
'nbfield']++;
775 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
776 print
'<td class="tdoverflowmax150">';
777 $form->form_modes_reglement(
'', $objp->fk_mode_reglement,
'none');
780 $totalarray[
'nbfield']++;
784 if (!empty($arrayfields[
'recurring'][
'checked'])) {
785 print
'<td class="center">'.($objp->frequency ?
img_picto($langs->trans(
"Frequency").
': '.$objp->frequency.
' '.$objp->unit_frequency,
'recurring',
'class="opacitymedium"').
' ' :
'').
yn($objp->frequency ? 1 : 0).
'</td>';
787 $totalarray[
'nbfield']++;
790 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
791 print
'<td class="center">'.($objp->frequency > 0 ? $objp->frequency :
'').
'</td>';
793 $totalarray[
'nbfield']++;
796 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
797 print
'<td class="center">'.($objp->frequency > 0 ? $objp->unit_frequency :
'').
'</td>';
799 $totalarray[
'nbfield']++;
802 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
803 print
'<td class="center">';
804 print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ?
' / '.$objp->nb_gen_max :
'') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
807 $totalarray[
'nbfield']++;
811 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
812 print
'<td class="center">';
813 print ($objp->frequency > 0 ?
dol_print_date($db->jdate($objp->date_last_gen),
'day') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
816 $totalarray[
'nbfield']++;
820 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
821 print
'<td class="center">';
822 print
'<div class="nowraponall">';
823 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>');
824 if (!$invoicerectmp->isMaxNbGenReached()) {
825 if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
829 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
834 $totalarray[
'nbfield']++;
837 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
838 print
'<td class="center tdoverflowmax150">';
839 if ($objp->fk_user_author > 0) {
840 $tmpuser->fetch($objp->fk_user_author);
841 print $tmpuser->getNomUrl(1);
845 $totalarray[
'nbfield']++;
848 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
849 print
'<td class="center tdoverflowmax150">';
850 if ($objp->fk_user_author > 0) {
851 $tmpuser->fetch($objp->fk_user_author);
852 print $tmpuser->getNomUrl(1);
856 $totalarray[
'nbfield']++;
859 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
860 print
'<td class="center nowraponall">';
864 $totalarray[
'nbfield']++;
867 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
868 print
'<td class="center nowraponall">';
872 $totalarray[
'nbfield']++;
878 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
880 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$objp,
'i'=>$i,
'totalarray'=>&$totalarray);
881 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
882 print $hookmanager->resPrint;
884 if (!empty($arrayfields[
'status'][
'checked'])) {
885 print
'<td class="center">';
886 print $invoicerectmp->getLibStatut(3, 0);
889 $totalarray[
'nbfield']++;
893 print
'<td class="center tdoverflowmax125">';
894 if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) {
895 if ($invoicerectmp->isMaxNbGenReached()) {
896 print $langs->trans(
"MaxNumberOfGenerationReached");
897 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
898 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&socid='.$objp->socid.
'&fac_rec='.$objp->facid.
'">';
899 print
img_picto($langs->trans(
"CreateBill"),
'add',
'class="paddingrightonly"');
900 print $langs->trans(
"CreateBill").
'</a>';
902 print
$form->textwithpicto(
'', $langs->trans(
"DateIsNotEnough"));
908 $totalarray[
'nbfield']++;
918 foreach ($arrayfields as $key => $val) {
919 if (!empty($val[
'checked'])) {
923 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
927 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';