33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
45 $langs->loadLangs(array(
'companies',
'bills',
'compta',
'admin',
'other'));
47 $action =
GETPOST(
'action',
'alpha');
48 $massaction =
GETPOST(
'massaction',
'alpha');
49 $show_files =
GETPOST(
'show_files',
'int');
50 $confirm =
GETPOST(
'confirm',
'alpha');
51 $cancel =
GETPOST(
'cancel',
'alpha');
52 $toselect =
GETPOST(
'toselect',
'array');
53 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicetemplatelist';
54 $optioncss =
GETPOST(
'optioncss',
'aZ');
57 $socid =
GETPOST(
'socid',
'int');
60 $lineid =
GETPOST(
'lineid',
'int');
63 $socid = $user->socid;
65 $objecttype =
'facture_rec';
66 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_nb_gen_done =
GETPOST(
'search_nb_gen_done',
'aplha');
97 $search_status =
GETPOST(
'search_status',
'int');
99 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
100 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
101 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
103 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
107 $offset = $limit * $page;
108 $pageprev = $page - 1;
109 $pagenext = $page + 1;
115 if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
116 $ret = $object->fetch($id, $ref);
123 $hookmanager->initHooks(array(
'invoicereclist'));
126 $extrafields->fetch_name_optionals_label($object->table_element);
128 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
135 $sortfield =
'f.titre';
138 $arrayfields = array(
139 'f.titre'=>array(
'label'=>
"Ref",
'checked'=>1),
140 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
141 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1),
142 'f.total_tva'=>array(
'label'=>
"AmountVAT",
'checked'=>-1),
143 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>1),
144 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>0),
145 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentTerm",
'checked'=>0),
146 'recurring'=>array(
'label'=>
"RecurringInvoice",
'checked'=>1),
147 'f.frequency'=>array(
'label'=>
"Frequency",
'checked'=>1),
148 'f.unit_frequency'=>array(
'label'=>
"FrequencyUnit",
'checked'=>1),
149 'f.nb_gen_done'=>array(
'label'=>
"NbOfGenerationDoneShort",
'checked'=>1),
150 'f.date_last_gen'=>array(
'label'=>
"DateLastGenerationShort",
'checked'=>1),
151 'f.date_when'=>array(
'label'=>
"NextDateToExecutionShort",
'checked'=>1),
152 'f.fk_user_author'=>array(
'label'=>
"UserCreation",
'checked'=>0,
'position'=>500),
153 'f.fk_user_modif'=>array(
'label'=>
"UserModification",
'checked'=>0,
'position'=>505),
154 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>520),
155 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>525),
156 'status'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
159 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
165 $tmpthirdparty =
new Societe($db);
166 $res = $tmpthirdparty->fetch($socid);
168 $search_societe = $tmpthirdparty->name;
173 $tmpthirdparty =
new Societe($db);
174 $res = $tmpthirdparty->fetch($socid);
176 $search_societe = $tmpthirdparty->name;
180 $objecttype =
'facture_rec';
182 $permissionnote = $user->hasRight(
'facture',
'creer');
183 $permissiondellink = $user->hasRight(
'facture',
'creer');
184 $permissiontoedit = $user->hasRight(
'facture',
'creer');
187 $result =
restrictedArea($user,
'facture', $object->id, $objecttype);
194 if (
GETPOST(
'cancel',
'alpha')) {
198 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
202 $parameters = array(
'socid' => $socid);
203 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
208 if (empty($reshook)) {
214 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
217 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
219 $search_societe =
'';
220 $search_montant_ht =
'';
221 $search_montant_vat =
'';
222 $search_montant_ttc =
'';
223 $search_payment_mode =
'';
224 $search_payment_term =
'';
225 $search_date_startday =
'';
226 $search_date_startmonth =
'';
227 $search_date_startyear =
'';
228 $search_date_endday =
'';
229 $search_date_endmonth =
'';
230 $search_date_endyear =
'';
231 $search_date_start =
'';
232 $search_date_end =
'';
233 $search_date_when_startday =
'';
234 $search_date_when_startmonth =
'';
235 $search_date_when_startyear =
'';
236 $search_date_when_endday =
'';
237 $search_date_when_endmonth =
'';
238 $search_date_when_endyear =
'';
239 $search_date_when_start =
'';
240 $search_date_when_end =
'';
241 $search_recurring =
'';
242 $search_frequency =
'';
243 $search_unit_frequency =
'';
244 $search_nb_gen_done =
'';
247 $search_array_options = array();
249 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
250 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
273 $companystatic =
new Societe($db);
275 $tmpuser =
new User($db);
280 $title = $langs->trans(
"RepeatableInvoices");
285 $today =
dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
290 $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,";
291 $sql .=
" f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
292 $sql .=
" f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
293 $sql .=
" f.fk_cond_reglement, f.fk_mode_reglement";
295 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
296 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
297 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
301 $parameters = array();
302 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
303 $sql .= $hookmanager->resPrint;
304 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
308 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_rec as f";
309 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
310 if (empty($user->rights->societe->client->voir) && !$socid) {
311 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
314 $parameters = array();
315 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
316 $sql .= $hookmanager->resPrint;
318 $sql .=
" WHERE f.fk_soc = s.rowid";
319 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
320 if (empty($user->rights->societe->client->voir) && !$socid) {
321 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
327 $sql .=
' AND s.rowid = '.(int) $socid;
329 if ($search_societe) {
332 if ($search_montant_ht !=
'') {
335 if ($search_montant_vat !=
'') {
338 if ($search_montant_ttc !=
'') {
341 if (!empty($search_payment_mode) && $search_payment_mode !=
'-1') {
344 if (!empty($search_payment_term) && $search_payment_term !=
'-1') {
347 if ($search_recurring ==
'1') {
348 $sql .=
' AND f.frequency > 0';
350 if ($search_recurring ==
'0') {
351 $sql .=
' AND (f.frequency IS NULL or f.frequency = 0)';
353 if ($search_frequency !=
'') {
356 if ($search_unit_frequency !=
'') {
357 $sql .=
' AND f.frequency > 0';
360 if ($search_nb_gen_done !=
'') {
363 if ($search_status !=
'' && $search_status >= -1) {
364 if ($search_status == 0) {
365 $sql .=
' AND frequency = 0 AND suspended = 0';
367 if ($search_status == 1) {
368 $sql .=
' AND frequency != 0 AND suspended = 0';
370 if ($search_status == -1) {
371 $sql .=
' AND suspended = 1';
374 if ($search_date_start) {
375 $sql .=
" AND f.date_last_gen >= '".$db->idate($search_date_start).
"'";
377 if ($search_date_end) {
378 $sql .=
" AND f.date_last_gen <= '".$db->idate($search_date_end).
"'";
380 if ($search_date_when_start) {
381 $sql .=
" AND f.date_when >= '".$db->idate($search_date_when_start).
"'";
383 if ($search_date_when_end) {
384 $sql .=
" AND f.date_when <= '".$db->idate($search_date_when_end).
"'";
388 $nbtotalofrecords =
'';
391 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
392 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
393 $resql = $db->query($sqlforcount);
395 $objforcount = $db->fetch_object($resql);
396 $nbtotalofrecords = $objforcount->nbtotalofrecords;
401 if (($page * $limit) > $nbtotalofrecords) {
408 $tmpsortfield = $sortfield;
409 if ($tmpsortfield ==
'recurring') {
410 $tmpsortfield =
'f.frequency';
414 $sql .= $db->order($tmpsortfield, $sortorder);
416 $sql .= $db->plimit($limit + 1, $offset);
419 $resql = $db->query(
$sql);
425 $num = $db->num_rows($resql);
433 $arrayofselected = is_array($toselect) ? $toselect : array();
437 $param .=
'&mode='.urlencode($mode);
439 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
440 $param .=
'&contextpage='.urlencode($contextpage);
442 if ($limit > 0 && $limit != $conf->liste_limit) {
443 $param .=
'&limit='.((int) $limit);
446 $param .=
'&socid='.urlencode($socid);
448 if ($search_date_startday) {
449 $param .=
'&search_date_startday='.urlencode($search_date_startday);
451 if ($search_date_startmonth) {
452 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
454 if ($search_date_startyear) {
455 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
457 if ($search_date_endday) {
458 $param .=
'&search_date_endday='.urlencode($search_date_endday);
460 if ($search_date_endmonth) {
461 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
463 if ($search_date_endyear) {
464 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
466 if ($search_date_when_startday) {
467 $param .=
'&search_date_when_startday='.urlencode($search_date_when_startday);
469 if ($search_date_when_startmonth) {
470 $param .=
'&search_date_when_startmonth='.urlencode($search_date_when_startmonth);
472 if ($search_date_when_startyear) {
473 $param .=
'&search_date_when_startyear='.urlencode($search_date_when_startyear);
475 if ($search_date_when_endday) {
476 $param .=
'&search_date_when_endday='.urlencode($search_date_when_endday);
478 if ($search_date_when_endmonth) {
479 $param .=
'&search_date_when_endmonth='.urlencode($search_date_when_endmonth);
481 if ($search_date_when_endyear) {
482 $param .=
'&search_date_when_endyear='.urlencode($search_date_when_endyear);
485 $param .=
'&search_ref='.urlencode($search_ref);
487 if ($search_societe) {
488 $param .=
'&search_societe='.urlencode($search_societe);
490 if ($search_montant_ht !=
'') {
491 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
493 if ($search_montant_vat !=
'') {
494 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
496 if ($search_montant_ttc !=
'') {
497 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
499 if ($search_payment_mode !=
'') {
500 $param .=
'&search_payment_mode='.urlencode($search_payment_mode);
502 if ($search_payment_term !=
'') {
503 $param .=
'&search_payment_term='.urlencode($search_payment_term);
505 if ($search_recurring !=
'' && $search_recurring !=
'-1') {
506 $param .=
'&search_recurring='.urlencode($search_recurring);
508 if ($search_frequency > 0) {
509 $param .=
'&search_frequency='.urlencode($search_frequency);
511 if ($search_unit_frequency !=
'') {
512 $param .=
'&search_unit_frequency='.urlencode($search_unit_frequency);
514 if ($search_nb_gen_done !=
'') {
515 $param .=
'&search_nb_gen_done='.urlencode($search_nb_gen_done);
517 if ($search_status !=
'') {
518 $param .=
'&search_status='.urlencode($search_status);
520 if ($optioncss !=
'') {
521 $param .=
'&optioncss='.urlencode($optioncss);
524 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
526 $parameters = array();
527 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
528 $param .= $hookmanager->resPrint;
531 $arrayofmassactions = array(
538 $massactionbutton =
$form->selectMassAction(
'', $massaction ==
'presend' ? array() : array(
'presend'=>$langs->trans(
"SendByMail"),
'builddoc'=>$langs->trans(
"PDFMerge")));
540 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
541 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
544 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
545 if ($optioncss !=
'') {
546 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
548 print
'<input type="hidden" name="token" value="'.newToken().
'">';
549 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
550 print
'<input type="hidden" name="action" value="list">';
551 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
552 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
553 print
'<input type="hidden" name="page" value="'.$page.
'">';
554 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
555 print
'<input type="hidden" name="page_y" value="">';
556 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
559 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0,
'',
'', $limit, 0, 0, 1);
561 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv(
"ChangeIntoRepeatableInvoice")).
'</span><br><br>';
567 $parameters = array();
568 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
569 if (empty($reshook)) {
570 $moreforfilter .= $hookmanager->resPrint;
572 $moreforfilter = $hookmanager->resPrint;
575 if (!empty($moreforfilter)) {
576 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
577 print $moreforfilter;
581 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
582 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
583 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
585 print
'<div class="div-table-responsive">';
586 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
591 print
'<tr class="liste_titre_filter">';
594 print
'<td class="liste_titre maxwidthsearch center">';
595 $searchpicto =
$form->showFilterButtons(
'left');
600 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
601 print
'<td class="liste_titre left">';
602 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
606 if (!empty($arrayfields[
's.nom'][
'checked'])) {
607 print
'<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
609 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
611 print
'<td class="liste_titre right">';
612 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
615 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
617 print
'<td class="liste_titre right">';
618 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
621 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
623 print
'<td class="liste_titre right">';
624 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
627 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
629 print
'<td class="liste_titre">';
630 print
$form->getSelectConditionsPaiements($search_payment_term,
'search_payment_term', -1, 1, 1,
'maxwidth100');
633 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
635 print
'<td class="liste_titre">';
636 print
$form->select_types_paiements($search_payment_mode,
'search_payment_mode',
'', 0, 1, 1, 0, 1,
'maxwidth100', 1);
639 if (!empty($arrayfields[
'recurring'][
'checked'])) {
641 print
'<td class="liste_titre center">';
642 print
$form->selectyesno(
'search_recurring', $search_recurring, 1,
false, 1);
645 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
647 print
'<td class="liste_titre center">';
648 print
'<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).
'">';
651 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
653 print
'<td class="liste_titre center">';
654 print
'<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).
'">';
657 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
659 print
'<td class="liste_titre" align="center">';
660 print
'<input class="flat" type="text" size="1" name="search_nb_gen_done" value="'.dol_escape_htmltag($search_nb_gen_done).
'">';
664 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
665 print
'<td class="liste_titre center">';
666 print
'<div class="nowrap">';
667 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
669 print
'<div class="nowrap">';
670 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
675 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
676 print
'<td class="liste_titre center">';
677 print
'<div class="nowrap">';
678 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'));
680 print
'<div class="nowrap">';
681 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'));
686 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
689 $parameters = array(
'arrayfields'=>$arrayfields);
690 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
691 print $hookmanager->resPrint;
693 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
694 print
'<td class="liste_titre">';
698 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
699 print
'<td class="liste_titre">';
703 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
704 print
'<td class="liste_titre">';
708 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
709 print
'<td class="liste_titre">';
713 if (!empty($arrayfields[
'status'][
'checked'])) {
714 print
'<td class="liste_titre center minwidth75imp parentonrightofpage">';
716 0=>$langs->trans(
"Draft"),
717 1=>$langs->trans(
"Active"),
718 -1=>$langs->trans(
"Disabled"),
720 print
$form->selectarray(
'search_status', $liststatus, $search_status, -2, 0, 0,
'', 0, 0, 0,
'',
'width100 onrightofpage');
725 print
'<td class="liste_titre maxwidthsearch center">';
726 $searchpicto =
$form->showFilterButtons();
732 $totalarray = array();
733 $totalarray[
'nbfield'] = 0;
737 print
'<tr class="liste_titre">';
739 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
740 $totalarray[
'nbfield']++;
742 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
743 print_liste_field_titre($arrayfields[
'f.titre'][
'label'], $_SERVER[
'PHP_SELF'],
"f.titre",
"", $param,
"", $sortfield, $sortorder);
744 $totalarray[
'nbfield']++;
746 if (!empty($arrayfields[
's.nom'][
'checked'])) {
747 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
748 $totalarray[
'nbfield']++;
750 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
751 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
752 $totalarray[
'nbfield']++;
754 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
755 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
756 $totalarray[
'nbfield']++;
758 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
759 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
760 $totalarray[
'nbfield']++;
762 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
763 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
764 $totalarray[
'nbfield']++;
766 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
767 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
768 $totalarray[
'nbfield']++;
770 if (!empty($arrayfields[
'recurring'][
'checked'])) {
771 print_liste_field_titre($arrayfields[
'recurring'][
'label'], $_SERVER[
'PHP_SELF'],
"recurring",
"", $param,
'', $sortfield, $sortorder,
'center ');
772 $totalarray[
'nbfield']++;
774 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
775 print_liste_field_titre($arrayfields[
'f.frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
776 $totalarray[
'nbfield']++;
778 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
779 print_liste_field_titre($arrayfields[
'f.unit_frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.unit_frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
780 $totalarray[
'nbfield']++;
782 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
783 print_liste_field_titre($arrayfields[
'f.nb_gen_done'][
'label'], $_SERVER[
'PHP_SELF'],
"f.nb_gen_done",
"", $param,
'', $sortfield, $sortorder,
'center ');
784 $totalarray[
'nbfield']++;
786 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
787 print_liste_field_titre($arrayfields[
'f.date_last_gen'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_last_gen",
"", $param,
'', $sortfield, $sortorder,
'center ');
788 $totalarray[
'nbfield']++;
790 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
791 print_liste_field_titre($arrayfields[
'f.date_when'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_when",
"", $param,
'', $sortfield, $sortorder,
'center ');
792 $totalarray[
'nbfield']++;
794 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
795 print_liste_field_titre($arrayfields[
'f.fk_user_author'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_author",
"", $param,
'', $sortfield, $sortorder,
'center ');
796 $totalarray[
'nbfield']++;
798 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
799 print_liste_field_titre($arrayfields[
'f.fk_user_modif'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_modif",
"", $param,
'', $sortfield, $sortorder,
'center ');
800 $totalarray[
'nbfield']++;
802 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
803 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
'PHP_SELF'],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
804 $totalarray[
'nbfield']++;
806 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
807 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
808 $totalarray[
'nbfield']++;
811 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
812 if (!empty($arrayfields[
'status'][
'checked'])) {
813 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
'PHP_SELF'],
"f.suspended,f.frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
814 $totalarray[
'nbfield']++;
818 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
819 $totalarray[
'nbfield']++;
824 $savnbfield = $totalarray[
'nbfield'];
825 $totalarray = array();
826 $totalarray[
'nbfield'] = 0;
827 $totalarray[
'val'][
'f.total_ht'] = 0;
828 $totalarray[
'val'][
'f.total_tva'] = 0;
829 $totalarray[
'val'][
'f.total_ttc'] = 0;
830 $imaxinloop = ($limit ? min($num, $limit) : $num);
831 while ($i < $imaxinloop) {
832 $objp = $db->fetch_object($resql);
837 $companystatic->id = $objp->socid;
838 $companystatic->name = $objp->name;
840 $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
841 $invoicerectmp->frequency = $objp->frequency;
842 $invoicerectmp->suspended = $objp->suspended;
843 $invoicerectmp->unit_frequency = $objp->unit_frequency;
844 $invoicerectmp->nb_gen_max = $objp->nb_gen_max;
845 $invoicerectmp->nb_gen_done = $objp->nb_gen_done;
846 $invoicerectmp->ref = $objp->title;
847 $invoicerectmp->total_ht = $objp->total_ht;
848 $invoicerectmp->total_tva = $objp->total_tva;
849 $invoicerectmp->total_ttc = $objp->total_ttc;
853 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
856 print
'<td class="nowrap center">';
857 if ($user->hasRight(
'facture',
'creer') && empty($invoicerectmp->suspended)) {
858 if ($invoicerectmp->isMaxNbGenReached()) {
859 print $langs->trans(
"MaxNumberOfGenerationReached");
860 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
861 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&socid='.$objp->socid.
'&fac_rec='.$objp->facid.
'">';
862 print
img_picto($langs->trans(
"CreateBill"),
'add',
'class="paddingrightonly"');
863 print $langs->trans(
"CreateBill").
'</a>';
865 print
$form->textwithpicto(
'', $langs->trans(
"DateIsNotEnough"));
870 $totalarray[
'nbfield']++;
873 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
874 print
'<td class="nowrap tdoverflowmax200">';
875 print $invoicerectmp->getNomUrl(1);
878 $totalarray[
'nbfield']++;
881 if (!empty($arrayfields[
's.nom'][
'checked'])) {
882 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
884 $totalarray[
'nbfield']++;
887 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
888 print
'<td class="nowrap right amount">'.price($objp->total_ht).
'</td>'.
"\n";
890 $totalarray[
'nbfield']++;
893 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
895 $totalarray[
'val'][
'f.total_ht'] += $objp->total_ht;
897 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
898 print
'<td class="nowrap right amount">'.price($objp->total_tva).
'</td>'.
"\n";
900 $totalarray[
'nbfield']++;
903 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
905 $totalarray[
'val'][
'f.total_tva'] += $objp->total_tva;
907 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
908 print
'<td class="nowrap right amount">'.price($objp->total_ttc).
'</td>'.
"\n";
910 $totalarray[
'nbfield']++;
913 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
915 $totalarray[
'val'][
'f.total_ttc'] += $objp->total_ttc;
918 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
919 print
'<td class="tdoverflowmax150">';
920 $form->form_conditions_reglement(
'', $objp->fk_cond_reglement,
'none');
923 $totalarray[
'nbfield']++;
927 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
928 print
'<td class="tdoverflowmax150">';
929 $form->form_modes_reglement(
'', $objp->fk_mode_reglement,
'none');
932 $totalarray[
'nbfield']++;
936 if (!empty($arrayfields[
'recurring'][
'checked'])) {
937 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>';
939 $totalarray[
'nbfield']++;
942 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
943 print
'<td class="center">'.($objp->frequency > 0 ? $objp->frequency :
'').
'</td>';
945 $totalarray[
'nbfield']++;
948 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
949 print
'<td class="center">'.($objp->frequency > 0 ? $objp->unit_frequency :
'').
'</td>';
951 $totalarray[
'nbfield']++;
954 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
955 print
'<td class="center">';
956 print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ?
' / '.$objp->nb_gen_max :
'') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
959 $totalarray[
'nbfield']++;
963 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
964 print
'<td class="center">';
965 print ($objp->frequency > 0 ?
dol_print_date($db->jdate($objp->date_last_gen),
'day') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
968 $totalarray[
'nbfield']++;
972 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
973 print
'<td class="center">';
974 print
'<div class="nowraponall">';
975 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>');
976 if (!$invoicerectmp->isMaxNbGenReached()) {
977 if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
981 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
986 $totalarray[
'nbfield']++;
989 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
990 print
'<td class="center tdoverflowmax150">';
991 if ($objp->fk_user_author > 0) {
992 $tmpuser->fetch($objp->fk_user_author);
993 print $tmpuser->getNomUrl(1);
997 $totalarray[
'nbfield']++;
1000 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
1001 print
'<td class="center tdoverflowmax150">';
1002 if ($objp->fk_user_author > 0) {
1003 $tmpuser->fetch($objp->fk_user_author);
1004 print $tmpuser->getNomUrl(1);
1008 $totalarray[
'nbfield']++;
1011 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1012 print
'<td class="center nowraponall">';
1016 $totalarray[
'nbfield']++;
1019 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1020 print
'<td class="center nowraponall">';
1024 $totalarray[
'nbfield']++;
1030 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1032 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1033 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1034 print $hookmanager->resPrint;
1036 if (!empty($arrayfields[
'status'][
'checked'])) {
1037 print
'<td class="center">';
1038 print $invoicerectmp->getLibStatut(5, 0);
1041 $totalarray[
'nbfield']++;
1046 print
'<td class="nowrap center tdoverflowmax125">';
1047 if ($user->hasRight(
'facture',
'creer') && empty($invoicerectmp->suspended)) {
1048 if ($invoicerectmp->isMaxNbGenReached()) {
1049 print $langs->trans(
"MaxNumberOfGenerationReached");
1050 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
1051 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&socid='.$objp->socid.
'&fac_rec='.$objp->facid.
'">';
1052 print
img_picto($langs->trans(
"CreateBill"),
'add',
'class="paddingrightonly"');
1053 print $langs->trans(
"CreateBill").
'</a>';
1055 print
$form->textwithpicto(
'', $langs->trans(
"DateIsNotEnough"));
1060 $totalarray[
'nbfield']++;
1070 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1075 foreach ($arrayfields as $key => $val) {
1076 if (!empty($val[
'checked'])) {
1080 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1086 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
1087 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1088 print $hookmanager->resPrint;
1090 print
'</table>'.
"\n";
1091 print
'</div>'.
"\n";
1093 print
'</form>'.
"\n";
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoice templates.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
img_info($titlealt='default')
Show info logo.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.