34 require
'../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
46 $langs->loadLangs(array(
'companies',
'bills',
'compta',
'admin',
'other'));
48 $action =
GETPOST(
'action',
'alpha');
49 $massaction =
GETPOST(
'massaction',
'alpha');
50 $show_files =
GETPOST(
'show_files',
'int');
51 $confirm =
GETPOST(
'confirm',
'alpha');
52 $cancel =
GETPOST(
'cancel',
'alpha');
53 $toselect =
GETPOST(
'toselect',
'array');
54 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicetemplatelist';
55 $optioncss =
GETPOST(
'optioncss',
'aZ');
58 $socid =
GETPOST(
'socid',
'int');
61 $lineid =
GETPOST(
'lineid',
'int');
64 $socid = $user->socid;
66 $objecttype =
'facture_rec';
67 if ($action ==
"create" || $action ==
"add") {
71 $search_ref =
GETPOST(
'search_ref');
72 $search_societe =
GETPOST(
'search_societe');
73 $search_montant_ht =
GETPOST(
'search_montant_ht');
74 $search_montant_vat =
GETPOST(
'search_montant_vat');
75 $search_montant_ttc =
GETPOST(
'search_montant_ttc');
76 $search_payment_mode =
GETPOST(
'search_payment_mode');
77 $search_payment_term =
GETPOST(
'search_payment_term');
78 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
79 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
80 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
81 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
82 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
83 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
84 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
85 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
86 $search_date_when_startday =
GETPOST(
'search_date_when_startday',
'int');
87 $search_date_when_startmonth =
GETPOST(
'search_date_when_startmonth',
'int');
88 $search_date_when_startyear =
GETPOST(
'search_date_when_startyear',
'int');
89 $search_date_when_endday =
GETPOST(
'search_date_when_endday',
'int');
90 $search_date_when_endmonth =
GETPOST(
'search_date_when_endmonth',
'int');
91 $search_date_when_endyear =
GETPOST(
'search_date_when_endyear',
'int');
92 $search_date_when_start =
dol_mktime(0, 0, 0, $search_date_when_startmonth, $search_date_when_startday, $search_date_when_startyear);
93 $search_date_when_end =
dol_mktime(23, 59, 59, $search_date_when_endmonth, $search_date_when_endday, $search_date_when_endyear);
94 $search_recurring =
GETPOST(
'search_recurring',
'int');
95 $search_frequency =
GETPOST(
'search_frequency',
'alpha');
96 $search_unit_frequency =
GETPOST(
'search_unit_frequency',
'alpha');
97 $search_nb_gen_done =
GETPOST(
'search_nb_gen_done',
'aplha');
98 $search_status =
GETPOST(
'search_status',
'int');
100 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
101 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
102 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
104 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
108 $offset = $limit * $page;
109 $pageprev = $page - 1;
110 $pagenext = $page + 1;
116 if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
117 $ret = $object->fetch($id, $ref);
124 $hookmanager->initHooks(array(
'invoicereclist'));
127 $extrafields->fetch_name_optionals_label($object->table_element);
129 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
136 $sortfield =
'f.titre';
139 $arrayfields = array(
140 'f.titre'=>array(
'label'=>
"Ref",
'checked'=>1),
141 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
142 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1),
143 'f.total_tva'=>array(
'label'=>
"AmountVAT",
'checked'=>-1),
144 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>1),
145 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>0),
146 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentTerm",
'checked'=>0),
147 'recurring'=>array(
'label'=>
"RecurringInvoice",
'checked'=>1),
148 'f.frequency'=>array(
'label'=>
"Frequency",
'checked'=>1),
149 'f.unit_frequency'=>array(
'label'=>
"FrequencyUnit",
'checked'=>1),
150 'f.nb_gen_done'=>array(
'label'=>
"NbOfGenerationDoneShort",
'checked'=>1),
151 'f.date_last_gen'=>array(
'label'=>
"DateLastGenerationShort",
'checked'=>1),
152 'f.date_when'=>array(
'label'=>
"NextDateToExecutionShort",
'checked'=>1),
153 'f.fk_user_author'=>array(
'label'=>
"UserCreation",
'checked'=>0,
'position'=>500),
154 'f.fk_user_modif'=>array(
'label'=>
"UserModification",
'checked'=>0,
'position'=>505),
155 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>520),
156 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>525),
157 'status'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
160 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
166 $tmpthirdparty =
new Societe($db);
167 $res = $tmpthirdparty->fetch($socid);
169 $search_societe = $tmpthirdparty->name;
174 $tmpthirdparty =
new Societe($db);
175 $res = $tmpthirdparty->fetch($socid);
177 $search_societe = $tmpthirdparty->name;
181 $objecttype =
'facture_rec';
183 $permissionnote = $user->hasRight(
'facture',
'creer');
184 $permissiondellink = $user->hasRight(
'facture',
'creer');
185 $permissiontoedit = $user->hasRight(
'facture',
'creer');
188 $result =
restrictedArea($user,
'facture', $object->id, $objecttype);
195 if (
GETPOST(
'cancel',
'alpha')) {
199 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
203 $parameters = array(
'socid' => $socid);
204 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
209 if (empty($reshook)) {
215 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
218 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
220 $search_societe =
'';
221 $search_montant_ht =
'';
222 $search_montant_vat =
'';
223 $search_montant_ttc =
'';
224 $search_payment_mode =
'';
225 $search_payment_term =
'';
226 $search_date_startday =
'';
227 $search_date_startmonth =
'';
228 $search_date_startyear =
'';
229 $search_date_endday =
'';
230 $search_date_endmonth =
'';
231 $search_date_endyear =
'';
232 $search_date_start =
'';
233 $search_date_end =
'';
234 $search_date_when_startday =
'';
235 $search_date_when_startmonth =
'';
236 $search_date_when_startyear =
'';
237 $search_date_when_endday =
'';
238 $search_date_when_endmonth =
'';
239 $search_date_when_endyear =
'';
240 $search_date_when_start =
'';
241 $search_date_when_end =
'';
242 $search_recurring =
'';
243 $search_frequency =
'';
244 $search_unit_frequency =
'';
245 $search_nb_gen_done =
'';
248 $search_array_options = array();
250 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
251 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
274 $companystatic =
new Societe($db);
276 $tmpuser =
new User($db);
281 $title = $langs->trans(
"RepeatableInvoices");
286 $today =
dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
291 $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,";
292 $sql .=
" f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
293 $sql .=
" f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
294 $sql .=
" f.fk_cond_reglement, f.fk_mode_reglement";
296 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
297 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
298 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
302 $parameters = array();
303 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
304 $sql .= $hookmanager->resPrint;
305 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
309 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_rec as f";
310 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
311 if (empty($user->rights->societe->client->voir) && !$socid) {
312 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
315 $parameters = array();
316 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
317 $sql .= $hookmanager->resPrint;
319 $sql .=
" WHERE f.fk_soc = s.rowid";
320 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
321 if (empty($user->rights->societe->client->voir) && !$socid) {
322 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
328 $sql .=
' AND s.rowid = '.(int) $socid;
330 if ($search_societe) {
333 if ($search_montant_ht !=
'') {
336 if ($search_montant_vat !=
'') {
339 if ($search_montant_ttc !=
'') {
342 if (!empty($search_payment_mode) && $search_payment_mode !=
'-1') {
345 if (!empty($search_payment_term) && $search_payment_term !=
'-1') {
348 if ($search_recurring ==
'1') {
349 $sql .=
' AND f.frequency > 0';
351 if ($search_recurring ==
'0') {
352 $sql .=
' AND (f.frequency IS NULL or f.frequency = 0)';
354 if ($search_frequency !=
'') {
357 if ($search_unit_frequency !=
'') {
358 $sql .=
' AND f.frequency > 0';
361 if ($search_nb_gen_done !=
'') {
364 if ($search_status !=
'' && $search_status >= -1) {
365 if ($search_status == 0) {
366 $sql .=
' AND frequency = 0 AND suspended = 0';
368 if ($search_status == 1) {
369 $sql .=
' AND frequency != 0 AND suspended = 0';
371 if ($search_status == -1) {
372 $sql .=
' AND suspended = 1';
375 if ($search_date_start) {
376 $sql .=
" AND f.date_last_gen >= '".$db->idate($search_date_start).
"'";
378 if ($search_date_end) {
379 $sql .=
" AND f.date_last_gen <= '".$db->idate($search_date_end).
"'";
381 if ($search_date_when_start) {
382 $sql .=
" AND f.date_when >= '".$db->idate($search_date_when_start).
"'";
384 if ($search_date_when_end) {
385 $sql .=
" AND f.date_when <= '".$db->idate($search_date_when_end).
"'";
388 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
391 $nbtotalofrecords =
'';
394 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
395 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
396 $resql = $db->query($sqlforcount);
398 $objforcount = $db->fetch_object($resql);
399 $nbtotalofrecords = $objforcount->nbtotalofrecords;
404 if (($page * $limit) > $nbtotalofrecords) {
411 $tmpsortfield = $sortfield;
412 if ($tmpsortfield ==
'recurring') {
413 $tmpsortfield =
'f.frequency';
417 $sql .= $db->order($tmpsortfield, $sortorder);
419 $sql .= $db->plimit($limit + 1, $offset);
422 $resql = $db->query(
$sql);
428 $num = $db->num_rows($resql);
436 $arrayofselected = is_array($toselect) ? $toselect : array();
440 $param .=
'&mode='.urlencode($mode);
442 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
443 $param .=
'&contextpage='.urlencode($contextpage);
445 if ($limit > 0 && $limit != $conf->liste_limit) {
446 $param .=
'&limit='.((int) $limit);
449 $param .=
'&socid='.urlencode($socid);
451 if ($search_date_startday) {
452 $param .=
'&search_date_startday='.urlencode($search_date_startday);
454 if ($search_date_startmonth) {
455 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
457 if ($search_date_startyear) {
458 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
460 if ($search_date_endday) {
461 $param .=
'&search_date_endday='.urlencode($search_date_endday);
463 if ($search_date_endmonth) {
464 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
466 if ($search_date_endyear) {
467 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
469 if ($search_date_when_startday) {
470 $param .=
'&search_date_when_startday='.urlencode($search_date_when_startday);
472 if ($search_date_when_startmonth) {
473 $param .=
'&search_date_when_startmonth='.urlencode($search_date_when_startmonth);
475 if ($search_date_when_startyear) {
476 $param .=
'&search_date_when_startyear='.urlencode($search_date_when_startyear);
478 if ($search_date_when_endday) {
479 $param .=
'&search_date_when_endday='.urlencode($search_date_when_endday);
481 if ($search_date_when_endmonth) {
482 $param .=
'&search_date_when_endmonth='.urlencode($search_date_when_endmonth);
484 if ($search_date_when_endyear) {
485 $param .=
'&search_date_when_endyear='.urlencode($search_date_when_endyear);
488 $param .=
'&search_ref='.urlencode($search_ref);
490 if ($search_societe) {
491 $param .=
'&search_societe='.urlencode($search_societe);
493 if ($search_montant_ht !=
'') {
494 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
496 if ($search_montant_vat !=
'') {
497 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
499 if ($search_montant_ttc !=
'') {
500 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
502 if ($search_payment_mode !=
'') {
503 $param .=
'&search_payment_mode='.urlencode($search_payment_mode);
505 if ($search_payment_term !=
'') {
506 $param .=
'&search_payment_term='.urlencode($search_payment_term);
508 if ($search_recurring !=
'' && $search_recurring !=
'-1') {
509 $param .=
'&search_recurring='.urlencode($search_recurring);
511 if ($search_frequency > 0) {
512 $param .=
'&search_frequency='.urlencode($search_frequency);
514 if ($search_unit_frequency !=
'') {
515 $param .=
'&search_unit_frequency='.urlencode($search_unit_frequency);
517 if ($search_nb_gen_done !=
'') {
518 $param .=
'&search_nb_gen_done='.urlencode($search_nb_gen_done);
520 if ($search_status !=
'') {
521 $param .=
'&search_status='.urlencode($search_status);
523 if ($optioncss !=
'') {
524 $param .=
'&optioncss='.urlencode($optioncss);
527 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
529 $parameters = array();
530 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
531 $param .= $hookmanager->resPrint;
534 $arrayofmassactions = array(
541 $massactionbutton =
$form->selectMassAction(
'', $massaction ==
'presend' ? array() : array(
'presend'=>$langs->trans(
"SendByMail"),
'builddoc'=>$langs->trans(
"PDFMerge")));
543 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
544 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
547 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
548 if ($optioncss !=
'') {
549 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
551 print
'<input type="hidden" name="token" value="'.newToken().
'">';
552 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
553 print
'<input type="hidden" name="action" value="list">';
554 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
555 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
556 print
'<input type="hidden" name="page" value="'.$page.
'">';
557 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
558 print
'<input type="hidden" name="page_y" value="">';
559 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
562 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0,
'',
'', $limit, 0, 0, 1);
564 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv(
"ChangeIntoRepeatableInvoice")).
'</span><br><br>';
570 $parameters = array();
571 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
572 if (empty($reshook)) {
573 $moreforfilter .= $hookmanager->resPrint;
575 $moreforfilter = $hookmanager->resPrint;
578 if (!empty($moreforfilter)) {
579 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
580 print $moreforfilter;
584 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
585 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
586 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
588 print
'<div class="div-table-responsive">';
589 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
594 print
'<tr class="liste_titre_filter">';
597 print
'<td class="liste_titre maxwidthsearch center">';
598 $searchpicto =
$form->showFilterButtons(
'left');
603 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
604 print
'<td class="liste_titre left">';
605 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
609 if (!empty($arrayfields[
's.nom'][
'checked'])) {
610 print
'<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
612 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
614 print
'<td class="liste_titre right">';
615 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
618 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
620 print
'<td class="liste_titre right">';
621 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
624 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
626 print
'<td class="liste_titre right">';
627 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
630 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
632 print
'<td class="liste_titre">';
633 print
$form->getSelectConditionsPaiements($search_payment_term,
'search_payment_term', -1, 1, 1,
'maxwidth100');
636 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
638 print
'<td class="liste_titre">';
639 print
$form->select_types_paiements($search_payment_mode,
'search_payment_mode',
'', 0, 1, 1, 0, 1,
'maxwidth100', 1);
642 if (!empty($arrayfields[
'recurring'][
'checked'])) {
644 print
'<td class="liste_titre center">';
645 print
$form->selectyesno(
'search_recurring', $search_recurring, 1,
false, 1);
648 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
650 print
'<td class="liste_titre center">';
651 print
'<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).
'">';
654 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
656 print
'<td class="liste_titre center">';
657 print
'<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).
'">';
660 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
662 print
'<td class="liste_titre" align="center">';
663 print
'<input class="flat" type="text" size="1" name="search_nb_gen_done" value="'.dol_escape_htmltag($search_nb_gen_done).
'">';
667 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
668 print
'<td class="liste_titre center">';
669 print
'<div class="nowrap">';
670 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
672 print
'<div class="nowrap">';
673 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
678 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
679 print
'<td class="liste_titre center">';
680 print
'<div class="nowrap">';
681 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'));
683 print
'<div class="nowrap">';
684 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'));
689 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
692 $parameters = array(
'arrayfields'=>$arrayfields);
693 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
694 print $hookmanager->resPrint;
696 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
697 print
'<td class="liste_titre">';
701 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
702 print
'<td class="liste_titre">';
706 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
707 print
'<td class="liste_titre">';
711 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
712 print
'<td class="liste_titre">';
716 if (!empty($arrayfields[
'status'][
'checked'])) {
717 print
'<td class="liste_titre center minwidth75imp parentonrightofpage">';
719 0=>$langs->trans(
"Draft"),
720 1=>$langs->trans(
"Active"),
721 -1=>$langs->trans(
"Disabled"),
723 print
$form->selectarray(
'search_status', $liststatus, $search_status, -2, 0, 0,
'', 0, 0, 0,
'',
'width100 onrightofpage');
728 print
'<td class="liste_titre maxwidthsearch center">';
729 $searchpicto =
$form->showFilterButtons();
735 $totalarray = array();
736 $totalarray[
'nbfield'] = 0;
740 print
'<tr class="liste_titre">';
742 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
743 $totalarray[
'nbfield']++;
745 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
746 print_liste_field_titre($arrayfields[
'f.titre'][
'label'], $_SERVER[
'PHP_SELF'],
"f.titre",
"", $param,
"", $sortfield, $sortorder);
747 $totalarray[
'nbfield']++;
749 if (!empty($arrayfields[
's.nom'][
'checked'])) {
750 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
751 $totalarray[
'nbfield']++;
753 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
754 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
755 $totalarray[
'nbfield']++;
757 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
758 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
759 $totalarray[
'nbfield']++;
761 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
762 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
763 $totalarray[
'nbfield']++;
765 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
766 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
767 $totalarray[
'nbfield']++;
769 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
770 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
771 $totalarray[
'nbfield']++;
773 if (!empty($arrayfields[
'recurring'][
'checked'])) {
774 print_liste_field_titre($arrayfields[
'recurring'][
'label'], $_SERVER[
'PHP_SELF'],
"recurring",
"", $param,
'', $sortfield, $sortorder,
'center ');
775 $totalarray[
'nbfield']++;
777 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
778 print_liste_field_titre($arrayfields[
'f.frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
779 $totalarray[
'nbfield']++;
781 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
782 print_liste_field_titre($arrayfields[
'f.unit_frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.unit_frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
783 $totalarray[
'nbfield']++;
785 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
786 print_liste_field_titre($arrayfields[
'f.nb_gen_done'][
'label'], $_SERVER[
'PHP_SELF'],
"f.nb_gen_done",
"", $param,
'', $sortfield, $sortorder,
'center ');
787 $totalarray[
'nbfield']++;
789 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
790 print_liste_field_titre($arrayfields[
'f.date_last_gen'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_last_gen",
"", $param,
'', $sortfield, $sortorder,
'center ');
791 $totalarray[
'nbfield']++;
793 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
794 print_liste_field_titre($arrayfields[
'f.date_when'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_when",
"", $param,
'', $sortfield, $sortorder,
'center ');
795 $totalarray[
'nbfield']++;
797 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
798 print_liste_field_titre($arrayfields[
'f.fk_user_author'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_author",
"", $param,
'', $sortfield, $sortorder,
'center ');
799 $totalarray[
'nbfield']++;
801 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
802 print_liste_field_titre($arrayfields[
'f.fk_user_modif'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_modif",
"", $param,
'', $sortfield, $sortorder,
'center ');
803 $totalarray[
'nbfield']++;
805 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
806 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
'PHP_SELF'],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
807 $totalarray[
'nbfield']++;
809 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
810 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
811 $totalarray[
'nbfield']++;
814 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
815 if (!empty($arrayfields[
'status'][
'checked'])) {
816 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
'PHP_SELF'],
"f.suspended,f.frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
817 $totalarray[
'nbfield']++;
821 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
822 $totalarray[
'nbfield']++;
827 $savnbfield = $totalarray[
'nbfield'];
828 $totalarray = array();
829 $totalarray[
'nbfield'] = 0;
830 $totalarray[
'val'][
'f.total_ht'] = 0;
831 $totalarray[
'val'][
'f.total_tva'] = 0;
832 $totalarray[
'val'][
'f.total_ttc'] = 0;
833 $imaxinloop = ($limit ? min($num, $limit) : $num);
834 while ($i < $imaxinloop) {
835 $objp = $db->fetch_object($resql);
840 $companystatic->id = $objp->socid;
841 $companystatic->name = $objp->name;
843 $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
844 $invoicerectmp->frequency = $objp->frequency;
845 $invoicerectmp->suspended = $objp->suspended;
846 $invoicerectmp->unit_frequency = $objp->unit_frequency;
847 $invoicerectmp->nb_gen_max = $objp->nb_gen_max;
848 $invoicerectmp->nb_gen_done = $objp->nb_gen_done;
849 $invoicerectmp->ref = $objp->title;
850 $invoicerectmp->total_ht = $objp->total_ht;
851 $invoicerectmp->total_tva = $objp->total_tva;
852 $invoicerectmp->total_ttc = $objp->total_ttc;
856 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
859 print
'<td class="nowrap center">';
860 if ($user->hasRight(
'facture',
'creer') && empty($invoicerectmp->suspended)) {
861 if ($invoicerectmp->isMaxNbGenReached()) {
862 print $langs->trans(
"MaxNumberOfGenerationReached");
863 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
864 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&socid='.$objp->socid.
'&fac_rec='.$objp->facid.
'">';
865 print
img_picto($langs->trans(
"CreateBill"),
'add',
'class="paddingrightonly"');
866 print $langs->trans(
"CreateBill").
'</a>';
868 print
$form->textwithpicto(
'', $langs->trans(
"DateIsNotEnough"));
873 $totalarray[
'nbfield']++;
876 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
877 print
'<td class="nowrap tdoverflowmax200">';
878 print $invoicerectmp->getNomUrl(1);
881 $totalarray[
'nbfield']++;
884 if (!empty($arrayfields[
's.nom'][
'checked'])) {
885 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer').
'</td>';
887 $totalarray[
'nbfield']++;
890 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
891 print
'<td class="nowrap right amount">'.price($objp->total_ht).
'</td>'.
"\n";
893 $totalarray[
'nbfield']++;
896 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
898 $totalarray[
'val'][
'f.total_ht'] += $objp->total_ht;
900 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
901 print
'<td class="nowrap right amount">'.price($objp->total_tva).
'</td>'.
"\n";
903 $totalarray[
'nbfield']++;
906 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
908 $totalarray[
'val'][
'f.total_tva'] += $objp->total_tva;
910 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
911 print
'<td class="nowrap right amount">'.price($objp->total_ttc).
'</td>'.
"\n";
913 $totalarray[
'nbfield']++;
916 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
918 $totalarray[
'val'][
'f.total_ttc'] += $objp->total_ttc;
921 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
922 print
'<td class="tdoverflowmax150">';
923 $form->form_conditions_reglement(
'', $objp->fk_cond_reglement,
'none');
926 $totalarray[
'nbfield']++;
930 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
931 print
'<td class="tdoverflowmax150">';
932 $form->form_modes_reglement(
'', $objp->fk_mode_reglement,
'none');
935 $totalarray[
'nbfield']++;
939 if (!empty($arrayfields[
'recurring'][
'checked'])) {
940 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>';
942 $totalarray[
'nbfield']++;
945 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
946 print
'<td class="center">'.($objp->frequency > 0 ? $objp->frequency :
'').
'</td>';
948 $totalarray[
'nbfield']++;
951 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
952 print
'<td class="center">'.($objp->frequency > 0 ? $objp->unit_frequency :
'').
'</td>';
954 $totalarray[
'nbfield']++;
957 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
958 print
'<td class="center">';
959 print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ?
' / '.$objp->nb_gen_max :
'') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
962 $totalarray[
'nbfield']++;
966 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
967 print
'<td class="center">';
968 print ($objp->frequency > 0 ?
dol_print_date($db->jdate($objp->date_last_gen),
'day') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
971 $totalarray[
'nbfield']++;
975 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
976 print
'<td class="center">';
977 print
'<div class="nowraponall">';
978 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>');
979 if (!$invoicerectmp->isMaxNbGenReached()) {
980 if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
984 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
989 $totalarray[
'nbfield']++;
992 if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
993 print
'<td class="center tdoverflowmax150">';
994 if ($objp->fk_user_author > 0) {
995 $tmpuser->fetch($objp->fk_user_author);
996 print $tmpuser->getNomUrl(1);
1000 $totalarray[
'nbfield']++;
1003 if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
1004 print
'<td class="center tdoverflowmax150">';
1005 if ($objp->fk_user_author > 0) {
1006 $tmpuser->fetch($objp->fk_user_author);
1007 print $tmpuser->getNomUrl(1);
1011 $totalarray[
'nbfield']++;
1014 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1015 print
'<td class="center nowraponall">';
1019 $totalarray[
'nbfield']++;
1022 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1023 print
'<td class="center nowraponall">';
1027 $totalarray[
'nbfield']++;
1033 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1035 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1036 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1037 print $hookmanager->resPrint;
1039 if (!empty($arrayfields[
'status'][
'checked'])) {
1040 print
'<td class="center">';
1041 print $invoicerectmp->getLibStatut(5, 0);
1044 $totalarray[
'nbfield']++;
1049 print
'<td class="nowrap center tdoverflowmax125">';
1050 if ($user->hasRight(
'facture',
'creer') && empty($invoicerectmp->suspended)) {
1051 if ($invoicerectmp->isMaxNbGenReached()) {
1052 print $langs->trans(
"MaxNumberOfGenerationReached");
1053 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
1054 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&socid='.$objp->socid.
'&fac_rec='.$objp->facid.
'">';
1055 print
img_picto($langs->trans(
"CreateBill"),
'add',
'class="paddingrightonly"');
1056 print $langs->trans(
"CreateBill").
'</a>';
1058 print
$form->textwithpicto(
'', $langs->trans(
"DateIsNotEnough"));
1063 $totalarray[
'nbfield']++;
1073 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1078 foreach ($arrayfields as $key => $val) {
1079 if (!empty($val[
'checked'])) {
1083 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1089 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
1090 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1091 print $hookmanager->resPrint;
1093 print
'</table>'.
"\n";
1094 print
'</div>'.
"\n";
1096 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.