35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47$langs->loadLangs(array(
'bills',
'compta',
'admin',
'other',
'suppliers'));
49$action =
GETPOST(
'action',
'alpha');
50$massaction =
GETPOST(
'massaction',
'alpha');
52$confirm =
GETPOST(
'confirm',
'alpha');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$toselect =
GETPOST(
'toselect',
'array');
55$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierinvoicestemplatelist';
56$optioncss =
GETPOST(
'optioncss',
'aZ');
65 $socid = $user->socid;
67$objecttype =
'facture_fourn_rec';
68if ($action ==
"create" || $action ==
"add") {
72$search_ref =
GETPOST(
'search_ref');
73$search_societe =
GETPOST(
'search_societe');
74$search_montant_ht =
GETPOST(
'search_montant_ht');
75$search_montant_vat =
GETPOST(
'search_montant_vat');
76$search_montant_ttc =
GETPOST(
'search_montant_ttc');
77$search_payment_mode =
GETPOST(
'search_payment_mode');
78$search_payment_term =
GETPOST(
'search_payment_term');
79$search_date_startday =
GETPOSTINT(
'search_date_startday');
80$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
81$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
82$search_date_endday =
GETPOSTINT(
'search_date_endday');
83$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
84$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
85$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
86$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
87$search_date_when_startday =
GETPOSTINT(
'search_date_when_startday');
88$search_date_when_startmonth =
GETPOSTINT(
'search_date_when_startmonth');
89$search_date_when_startyear =
GETPOSTINT(
'search_date_when_startyear');
90$search_date_when_endday =
GETPOSTINT(
'search_date_when_endday');
91$search_date_when_endmonth =
GETPOSTINT(
'search_date_when_endmonth');
92$search_date_when_endyear =
GETPOSTINT(
'search_date_when_endyear');
93$search_date_when_start =
dol_mktime(0, 0, 0, $search_date_when_startmonth, $search_date_when_startday, $search_date_when_startyear);
94$search_date_when_end =
dol_mktime(23, 59, 59, $search_date_when_endmonth, $search_date_when_endday, $search_date_when_endyear);
95$search_recurring =
GETPOST(
'search_recurring',
'intcomma');
96$search_frequency =
GETPOST(
'search_frequency',
'alpha');
97$search_unit_frequency =
GETPOST(
'search_unit_frequency',
'alpha');
98$search_nb_gen_done =
GETPOST(
'search_nb_gen_done',
'alpha');
99$search_status =
GETPOST(
'search_status',
'intcomma');
102$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
103$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
105if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
109$offset = $limit * $page;
110$pageprev = $page - 1;
111$pagenext = $page + 1;
117if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
118 $ret =
$object->fetch($id, $ref);
125$hookmanager->initHooks(array(
'supplierinvoicereclist'));
128$extrafields->fetch_name_optionals_label(
$object->table_element);
130$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
137 $sortfield =
'f.titre';
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),
160include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
164'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
167 $tmpthirdparty =
new Societe($db);
168 $res = $tmpthirdparty->fetch($socid);
170 $search_societe = $tmpthirdparty->name;
174$objecttype =
'facture_fourn_rec';
176$permissionnote = $user->hasRight(
'facture',
'creer');
177$permissiondellink = $user->hasRight(
'facture',
'creer');
178$permissiontoedit = $user->hasRight(
'facture',
'creer');
188if (
GETPOST(
'cancel',
'alpha')) {
192if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
196$parameters = array(
'socid' => $socid);
197$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
202if (empty($reshook)) {
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 =
'';
238 $search_nb_gen_done =
'';
241 $search_array_options = array();
243 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
244 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
262$form =
new Form($db);
264if (isModEnabled(
'project')) {
267$companystatic =
new Societe($db);
269$tmpuser =
new User($db);
274$title = $langs->trans(
"RepeatableSupplierInvoices");
279$today =
dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
285$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,";
286$sql .=
" f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
287$sql .=
" f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
288$sql .=
" f.fk_cond_reglement, f.fk_mode_reglement";
290if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
291 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
292 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
296$parameters = array();
297$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
298$sql .= $hookmanager->resPrint;
299$sql = preg_replace(
'/,\s*$/',
'', $sql);
303$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'facture_fourn_rec as f';
304$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_rec_extrafields as ef ON ef.fk_object = f.rowid';
305if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
306 $sql .=
', '.MAIN_DB_PREFIX.
'societe_commerciaux as sc';
309$parameters = array();
310$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
311$sql .= $hookmanager->resPrint;
313$sql .=
" WHERE f.fk_soc = s.rowid";
314$sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
315if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
316 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
322 $sql .=
' AND s.rowid = '.(int) $socid;
324if ($search_societe) {
327if ($search_montant_ht !=
'') {
330if ($search_montant_vat !=
'') {
333if ($search_montant_ttc !=
'') {
336if (!empty($search_payment_mode) && $search_payment_mode !=
'-1') {
337 $sql .=
natural_search(
'f.fk_mode_reglement', $search_payment_mode, 1);
339if (!empty($search_payment_term) && $search_payment_term !=
'-1') {
340 $sql .=
natural_search(
'f.fk_cond_reglement', $search_payment_term, 1);
342if ($search_recurring ==
'1') {
343 $sql .=
' AND f.frequency > 0';
345if ($search_recurring ==
'0') {
346 $sql .=
' AND (f.frequency IS NULL or f.frequency = 0)';
348if ($search_frequency !=
'') {
351if ($search_unit_frequency !=
'') {
352 $sql .=
' AND f.frequency > 0';
353 $sql .=
natural_search(
'f.unit_frequency', $search_unit_frequency);
355if ($search_nb_gen_done !=
'') {
358if ($search_status !=
'' && $search_status >= -1) {
359 if ($search_status == 0) {
360 $sql .=
' AND frequency = 0 AND suspended = 0';
362 if ($search_status == 1) {
363 $sql .=
' AND frequency != 0 AND suspended = 0';
365 if ($search_status == -1) {
366 $sql .=
' AND suspended = 1';
369if ($search_date_start) {
370 $sql .=
" AND f.date_last_gen >= '".$db->idate($search_date_start).
"'";
372if ($search_date_end) {
373 $sql .=
" AND f.date_last_gen <= '".$db->idate($search_date_end).
"'";
375if ($search_date_when_start) {
376 $sql .=
" AND f.date_when >= '".$db->idate($search_date_when_start).
"'";
378if ($search_date_when_end) {
379 $sql .=
" AND f.date_when <= '".$db->idate($search_date_when_end).
"'";
382include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
385$nbtotalofrecords =
'';
388 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
389 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
390 $resql = $db->query($sqlforcount);
392 $objforcount = $db->fetch_object($resql);
393 $nbtotalofrecords = $objforcount->nbtotalofrecords;
398 if (($page * $limit) > $nbtotalofrecords) {
405$tmpsortfield = $sortfield;
406if ($tmpsortfield ==
'recurring') {
407 $tmpsortfield =
'f.frequency';
411$sql .= $db->order($tmpsortfield, $sortorder);
413 $sql .= $db->plimit($limit + 1, $offset);
416$resql = $db->query($sql);
422$num = $db->num_rows($resql);
427llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-fourn-facture page-list-rec');
429$arrayofselected = is_array($toselect) ? $toselect : array();
433 $param .=
'&mode='.urlencode($mode);
435if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
436 $param .=
'&contextpage='.urlencode($contextpage);
438if ($limit > 0 && $limit != $conf->liste_limit) {
439 $param .=
'&limit='.((int) $limit);
442 $param .=
'&socid='.urlencode((
string) ($socid));
444if ($search_date_startday) {
445 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
447if ($search_date_startmonth) {
448 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
450if ($search_date_startyear) {
451 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
453if ($search_date_endday) {
454 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
456if ($search_date_endmonth) {
457 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
459if ($search_date_endyear) {
460 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
462if ($search_date_when_startday) {
463 $param .=
'&search_date_when_startday='.urlencode((
string) ($search_date_when_startday));
465if ($search_date_when_startmonth) {
466 $param .=
'&search_date_when_startmonth='.urlencode((
string) ($search_date_when_startmonth));
468if ($search_date_when_startyear) {
469 $param .=
'&search_date_when_startyear='.urlencode((
string) ($search_date_when_startyear));
471if ($search_date_when_endday) {
472 $param .=
'&search_date_when_endday='.urlencode((
string) ($search_date_when_endday));
474if ($search_date_when_endmonth) {
475 $param .=
'&search_date_when_endmonth='.urlencode((
string) ($search_date_when_endmonth));
477if ($search_date_when_endyear) {
478 $param .=
'&search_date_when_endyear='.urlencode((
string) ($search_date_when_endyear));
481 $param .=
'&search_ref='.urlencode($search_ref);
483if ($search_societe) {
484 $param .=
'&search_societe='.urlencode($search_societe);
486if ($search_montant_ht !=
'') {
487 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
489if ($search_montant_vat !=
'') {
490 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
492if ($search_montant_ttc !=
'') {
493 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
495if ($search_payment_mode !=
'') {
496 $param .=
'&search_payment_mode='.urlencode($search_payment_mode);
498if ($search_payment_term !=
'') {
499 $param .=
'&search_payment_term='.urlencode($search_payment_term);
501if ($search_recurring !=
'' && $search_recurring !=
'-1') {
502 $param .=
'&search_recurring='.urlencode($search_recurring);
504if ($search_frequency > 0) {
505 $param .=
'&search_frequency='.urlencode($search_frequency);
507if ($search_unit_frequency !=
'') {
508 $param .=
'&search_unit_frequency='.urlencode($search_unit_frequency);
510if ($search_nb_gen_done !=
'') {
511 $param .=
'&search_nb_gen_done='.urlencode($search_nb_gen_done);
513if ($search_status !=
'') {
514 $param .=
'&search_status='.urlencode($search_status);
516if ($optioncss !=
'') {
517 $param .=
'&optioncss='.urlencode($optioncss);
520include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
522$parameters = array(
'param' => &$param);
523$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
524$param .= $hookmanager->resPrint;
527$arrayofmassactions = array(
534$massactionbutton = $form->selectMassAction(
'', $massaction ==
'presend' ? array() : array(
'presend' => $langs->trans(
"SendByMail"),
'builddoc' => $langs->trans(
"PDFMerge")));
536$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
537$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
538$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
541print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
542if ($optioncss !=
'') {
543 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
545print
'<input type="hidden" name="token" value="'.newToken().
'">';
546print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
547print
'<input type="hidden" name="action" value="list">';
548print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
549print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
550print
'<input type="hidden" name="page" value="'.$page.
'">';
551print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
552print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
553print
'<input type="hidden" name="page_y" value="">';
554print
'<input type="hidden" name="mode" value="'.$mode.
'">';
557print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0,
'',
'', $limit, 0, 0, 1);
559print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateAPredefinedSupplierInvoice", $langs->transnoentitiesnoconv(
"ChangeIntoRepeatableInvoice")).
'</span><br><br>';
565$parameters = array();
566$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
567if (empty($reshook)) {
568 $moreforfilter .= $hookmanager->resPrint;
570 $moreforfilter = $hookmanager->resPrint;
573if (!empty($moreforfilter)) {
574 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
575 print $moreforfilter;
579$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
580$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
581$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
583print
'<div class="div-table-responsive">';
584print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
588print
'<tr class="liste_titre_filter">';
591 print
'<td class="liste_titre maxwidthsearch center">';
592 $searchpicto = $form->showFilterButtons(
'left');
597if (!empty($arrayfields[
'f.titre'][
'checked'])) {
598 print
'<td class="liste_titre left">';
599 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
603if (!empty($arrayfields[
's.nom'][
'checked'])) {
604 print
'<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
606if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
608 print
'<td class="liste_titre right">';
609 print
'<input class="flat width50" type="text" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
612if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
614 print
'<td class="liste_titre right">';
615 print
'<input class="flat width50" type="text" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
618if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
620 print
'<td class="liste_titre right">';
621 print
'<input class="flat width50" type="text" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
624if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
626 print
'<td class="liste_titre">';
627 print $form->getSelectConditionsPaiements($search_payment_term,
'search_payment_term', -1, 1, 1,
'maxwidth100');
630if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
632 print
'<td class="liste_titre">';
633 print $form->select_types_paiements($search_payment_mode,
'search_payment_mode',
'', 0, 1, 1, 0, 1,
'maxwidth100', 1);
636if (!empty($arrayfields[
'recurring'][
'checked'])) {
638 print
'<td class="liste_titre center">';
639 print $form->selectyesno(
'search_recurring', $search_recurring, 1,
false, 1);
642if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
644 print
'<td class="liste_titre center">';
645 print
'<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).
'">';
648if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
650 print
'<td class="liste_titre center">';
651 print
'<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).
'">';
654if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
656 print
'<td class="liste_titre" align="center">';
657 print
'<input class="flat" type="text" size="1" name="search_nb_gen_done" value="'.dol_escape_htmltag($search_nb_gen_done).
'">';
661if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
662 print
'<td class="liste_titre center">';
663 print
'<div class="nowrapfordate">';
664 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
666 print
'<div class="nowrapfordate">';
667 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
672if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
673 print
'<td class="liste_titre center">';
674 print
'<div class="nowrapfordate">';
675 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'));
677 print
'<div class="nowrapfordate">';
678 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'));
683include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
686$parameters = array(
'arrayfields' => $arrayfields);
687$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
688print $hookmanager->resPrint;
690if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
691 print
'<td class="liste_titre">';
695if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
696 print
'<td class="liste_titre">';
700if (!empty($arrayfields[
'f.datec'][
'checked'])) {
701 print
'<td class="liste_titre">';
705if (!empty($arrayfields[
'f.tms'][
'checked'])) {
706 print
'<td class="liste_titre">';
710if (!empty($arrayfields[
'status'][
'checked'])) {
711 print
'<td class="liste_titre center minwidth75imp parentonrightofpage">';
713 0 => $langs->trans(
"Draft"),
714 1 => $langs->trans(
"Active"),
715 -1 => $langs->trans(
"Disabled"),
718 print $form->selectarray(
'search_status', $liststatus, $search_status, -2, 0, 0,
'', 0, 0, 0,
'',
'width100 onrightofpage');
723 print
'<td class="liste_titre maxwidthsearch center">';
724 $searchpicto = $form->showFilterButtons();
730$totalarray = array();
731$totalarray[
'nbfield'] = 0;
735print
'<tr class="liste_titre">';
738 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
739 $totalarray[
'nbfield']++;
741if (!empty($arrayfields[
'f.titre'][
'checked'])) {
742 print_liste_field_titre($arrayfields[
'f.titre'][
'label'], $_SERVER[
'PHP_SELF'],
"f.titre",
"", $param,
"", $sortfield, $sortorder);
743 $totalarray[
'nbfield']++;
745if (!empty($arrayfields[
's.nom'][
'checked'])) {
746 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
747 $totalarray[
'nbfield']++;
749if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
750 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
751 $totalarray[
'nbfield']++;
753if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
754 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
755 $totalarray[
'nbfield']++;
757if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
758 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
"f.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
759 $totalarray[
'nbfield']++;
761if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
762 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
763 $totalarray[
'nbfield']++;
765if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
766 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
767 $totalarray[
'nbfield']++;
769if (!empty($arrayfields[
'recurring'][
'checked'])) {
770 print_liste_field_titre($arrayfields[
'recurring'][
'label'], $_SERVER[
'PHP_SELF'],
"recurring",
"", $param,
'', $sortfield, $sortorder,
'center ');
771 $totalarray[
'nbfield']++;
773if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
774 print_liste_field_titre($arrayfields[
'f.frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
775 $totalarray[
'nbfield']++;
777if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
778 print_liste_field_titre($arrayfields[
'f.unit_frequency'][
'label'], $_SERVER[
'PHP_SELF'],
"f.unit_frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
779 $totalarray[
'nbfield']++;
781if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
782 print_liste_field_titre($arrayfields[
'f.nb_gen_done'][
'label'], $_SERVER[
'PHP_SELF'],
"f.nb_gen_done",
"", $param,
'', $sortfield, $sortorder,
'center ');
783 $totalarray[
'nbfield']++;
785if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
786 print_liste_field_titre($arrayfields[
'f.date_last_gen'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_last_gen",
"", $param,
'', $sortfield, $sortorder,
'center ');
787 $totalarray[
'nbfield']++;
789if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
790 print_liste_field_titre($arrayfields[
'f.date_when'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_when",
"", $param,
'', $sortfield, $sortorder,
'center ');
791 $totalarray[
'nbfield']++;
793if (!empty($arrayfields[
'f.fk_user_author'][
'checked'])) {
794 print_liste_field_titre($arrayfields[
'f.fk_user_author'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_author",
"", $param,
'', $sortfield, $sortorder,
'center ');
795 $totalarray[
'nbfield']++;
797if (!empty($arrayfields[
'f.fk_user_modif'][
'checked'])) {
798 print_liste_field_titre($arrayfields[
'f.fk_user_modif'][
'label'], $_SERVER[
'PHP_SELF'],
"f.fk_user_modif",
"", $param,
'', $sortfield, $sortorder,
'center ');
799 $totalarray[
'nbfield']++;
801if (!empty($arrayfields[
'f.datec'][
'checked'])) {
802 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
'PHP_SELF'],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
803 $totalarray[
'nbfield']++;
805if (!empty($arrayfields[
'f.tms'][
'checked'])) {
806 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
807 $totalarray[
'nbfield']++;
810include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
811if (!empty($arrayfields[
'status'][
'checked'])) {
812 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
'PHP_SELF'],
"f.suspended,f.frequency",
"", $param,
'', $sortfield, $sortorder,
'center ');
813 $totalarray[
'nbfield']++;
817 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
818 $totalarray[
'nbfield']++;
823$savnbfield = $totalarray[
'nbfield'];
824$totalarray = array();
825$totalarray[
'nbfield'] = 0;
826$totalarray[
'val'][
'f.total_ht'] = 0;
827$totalarray[
'val'][
'f.total_tva'] = 0;
828$totalarray[
'val'][
'f.total_ttc'] = 0;
829$imaxinloop = ($limit ? min($num, $limit) : $num);
831while ($i < $imaxinloop) {
832 $objp = $db->fetch_object($resql);
837 $companystatic->id = $objp->socid;
838 $companystatic->name = $objp->name;
840 $supplierinvoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
841 $supplierinvoicerectmp->frequency = $objp->frequency;
842 $supplierinvoicerectmp->suspended = $objp->suspended;
843 $supplierinvoicerectmp->unit_frequency = $objp->unit_frequency;
844 $supplierinvoicerectmp->nb_gen_max = $objp->nb_gen_max;
845 $supplierinvoicerectmp->nb_gen_done = $objp->nb_gen_done;
846 $supplierinvoicerectmp->ref = $objp->title;
847 $supplierinvoicerectmp->total_ht = $objp->total_ht;
848 $supplierinvoicerectmp->total_tva = $objp->total_tva;
849 $supplierinvoicerectmp->total_ttc = $objp->total_ttc;
853 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
856 print
'<td class="center tdoverflowmax125">';
857 if ($user->hasRight(
'facture',
'creer') && empty($supplierinvoicerectmp->suspended)) {
858 if ($supplierinvoicerectmp->isMaxNbGenReached()) {
859 print $langs->trans(
"MaxNumberOfGenerationReached");
860 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
861 print
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$objp->socid.
'&fac_rec='.$objp->facid.
'">';
862 print
img_picto($langs->trans(
"CreateBill"),
'add',
'class="paddingrightonly"');
866 print $form->textwithpicto(
'', $langs->trans(
"DateIsNotEnough"));
871 $totalarray[
'nbfield']++;
875 if (!empty($arrayfields[
'f.titre'][
'checked'])) {
876 print
'<td class="nowrap tdoverflowmax200">';
877 print $supplierinvoicerectmp->getNomUrl(1);
880 $totalarray[
'nbfield']++;
883 if (!empty($arrayfields[
's.nom'][
'checked'])) {
884 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'supplier').
'</td>';
886 $totalarray[
'nbfield']++;
889 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
890 print
'<td class="nowrap right amount">'.price($objp->total_ht).
'</td>'.
"\n";
892 $totalarray[
'nbfield']++;
895 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
897 $totalarray[
'val'][
'f.total_ht'] += $objp->total_ht;
899 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
900 print
'<td class="nowrap right amount">'.price($objp->total_tva).
'</td>'.
"\n";
902 $totalarray[
'nbfield']++;
905 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
907 $totalarray[
'val'][
'f.total_tva'] += $objp->total_tva;
909 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
910 print
'<td class="nowrap right amount">'.price($objp->total_ttc).
'</td>'.
"\n";
912 $totalarray[
'nbfield']++;
915 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
917 $totalarray[
'val'][
'f.total_ttc'] += $objp->total_ttc;
920 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
921 print
'<td class="tdoverflowmax150">';
922 $form->form_conditions_reglement(
'', $objp->fk_cond_reglement,
'none');
925 $totalarray[
'nbfield']++;
929 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
930 print
'<td class="tdoverflowmax150">';
931 $form->form_modes_reglement(
'', $objp->fk_mode_reglement,
'none');
934 $totalarray[
'nbfield']++;
938 if (!empty($arrayfields[
'recurring'][
'checked'])) {
939 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>';
941 $totalarray[
'nbfield']++;
944 if (!empty($arrayfields[
'f.frequency'][
'checked'])) {
945 print
'<td class="center">';
946 print($objp->frequency > 0 ? $objp->frequency :
'');
949 $totalarray[
'nbfield']++;
952 if (!empty($arrayfields[
'f.unit_frequency'][
'checked'])) {
953 print
'<td class="center">';
954 if ($objp->frequency > 1) {
955 $dur = array(
"i" => $langs->trans(
"Minutes"),
"h" => $langs->trans(
"Hours"),
"d" => $langs->trans(
"Days"),
"w" => $langs->trans(
"Weeks"),
"m" => $langs->trans(
"Months"),
"y" => $langs->trans(
"Years"));
957 $dur = array(
"i" => $langs->trans(
"Minute"),
"h" => $langs->trans(
"Hour"),
"d" => $langs->trans(
"Day"),
"w" => $langs->trans(
"Week"),
"m" => $langs->trans(
"Month"),
"y" => $langs->trans(
"Year"));
959 print($objp->frequency > 0 ? $dur[$objp->unit_frequency] :
'');
962 $totalarray[
'nbfield']++;
965 if (!empty($arrayfields[
'f.nb_gen_done'][
'checked'])) {
966 print
'<td class="center">';
967 print($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ?
' / '.$objp->nb_gen_max :
'') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
970 $totalarray[
'nbfield']++;
974 if (!empty($arrayfields[
'f.date_last_gen'][
'checked'])) {
975 print
'<td class="center">';
976 print($objp->frequency > 0 ?
dol_print_date($db->jdate($objp->date_last_gen),
'day') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
979 $totalarray[
'nbfield']++;
983 if (!empty($arrayfields[
'f.date_when'][
'checked'])) {
984 print
'<td class="center">';
985 print
'<div class="nowraponall">';
986 print($objp->frequency ? ($supplierinvoicerectmp->isMaxNbGenReached() ?
'<strike>' :
'').
dol_print_date($db->jdate($objp->date_when),
'day').($supplierinvoicerectmp->isMaxNbGenReached() ?
'</strike>' :
'') :
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>');
987 if (!$supplierinvoicerectmp->isMaxNbGenReached()) {
988 if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
992 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
997 $totalarray[
'nbfield']++;
1000 if (!empty($arrayfields[
'f.fk_user_author'][
'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.fk_user_modif'][
'checked'])) {
1012 print
'<td class="center tdoverflowmax150">';
1013 if ($objp->fk_user_author > 0) {
1014 $tmpuser->fetch($objp->fk_user_author);
1015 print $tmpuser->getNomUrl(1);
1019 $totalarray[
'nbfield']++;
1022 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1023 print
'<td class="center nowraponall">';
1027 $totalarray[
'nbfield']++;
1030 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1031 print
'<td class="center nowraponall">';
1035 $totalarray[
'nbfield']++;
1041 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1043 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1044 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1045 print $hookmanager->resPrint;
1047 if (!empty($arrayfields[
'status'][
'checked'])) {
1048 print
'<td class="center">';
1049 print $supplierinvoicerectmp->getLibStatut(5, 0);
1052 $totalarray[
'nbfield']++;
1057 print
'<td class="nowrap center tdoverflowmax125">';
1058 if ($user->hasRight(
'facture',
'creer') && empty($supplierinvoicerectmp->suspended)) {
1059 if ($supplierinvoicerectmp->isMaxNbGenReached()) {
1060 print $langs->trans(
"MaxNumberOfGenerationReached");
1061 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
1062 print
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$objp->socid.
'&fac_rec='.$objp->facid.
'">';
1063 print
img_picto($langs->trans(
"CreateBill"),
'add',
'class="paddingrightonly"');
1067 print $form->textwithpicto(
'', $langs->trans(
"DateIsNotEnough"));
1072 $totalarray[
'nbfield']++;
1083include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1088 foreach ($arrayfields as $key => $val) {
1089 if (!empty($val[
'checked'])) {
1093 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1099$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1100$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1101print $hookmanager->resPrint;
1103print
'</table>'.
"\n";
1106print
'</form>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoice templates.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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.
print_barre_liste($title, $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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.