From d8e3cd2a5f37b819afb4c1a648bfcaecfa1f0d35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2023 13:50:15 +0200 Subject: [PATCH] Fix look and feel supplier recuring invoices --- .../compta/facture/invoicetemplate_list.php | 23 +- htdocs/fourn/facture/list-rec.php | 1249 ++++++++++------- 2 files changed, 718 insertions(+), 554 deletions(-) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 5554b2d7310..f2573a42307 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -169,14 +169,6 @@ if ($socid > 0) { } } -if ($socid > 0) { - $tmpthirdparty = new Societe($db); - $res = $tmpthirdparty->fetch($socid); - if ($res > 0) { - $search_societe = $tmpthirdparty->name; - } -} - $objecttype = 'facture_rec'; $permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php @@ -254,8 +246,8 @@ if (empty($reshook)) { // Mass actions /*$objectclass='MyObject'; $objectlabel='MyObject'; - $permissiontoread = $user->rights->mymodule->read; - $permissiontodelete = $user->rights->mymodule->delete; + $permissiontoread = $user->hasRight("mymodule", "read"); + $permissiontodelete = $user->hasRight("mymodule", "delete"); $uploaddir = $conf->mymodule->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ } @@ -317,7 +309,7 @@ $sql .= $hookmanager->resPrint; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; -if (empty($user->rights->societe->client->voir) && !$socid) { +if (!$user->hasRight("societe", "client", "voir") && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($search_ref) { @@ -538,7 +530,7 @@ $arrayofmassactions = array( $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'."\n"; @@ -735,6 +727,7 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +// Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; @@ -853,7 +846,7 @@ while ($i < $imaxinloop) { print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; if ($user->hasRight('facture', 'creer') && empty($invoicerectmp->suspended)) { if ($invoicerectmp->isMaxNbGenReached()) { print $langs->trans("MaxNumberOfGenerationReached"); @@ -940,7 +933,9 @@ while ($i < $imaxinloop) { } } if (!empty($arrayfields['f.frequency']['checked'])) { - print ''.($objp->frequency > 0 ? $objp->frequency : '').''; + print ''; + print ($objp->frequency > 0 ? $objp->frequency : ''); + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php index a6a7da35a2d..2b8d3c17db9 100644 --- a/htdocs/fourn/facture/list-rec.php +++ b/htdocs/fourn/facture/list-rec.php @@ -24,7 +24,7 @@ */ /** - * \file htdocs/compta/facture/invoicetemplate_list.php + * \file htdocs/fourn/facture/list-rec.php * \ingroup facture * \brief Page to show list of template/recurring invoices */ @@ -50,12 +50,12 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search -$optioncss = GETPOST('optioncss', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierinvoicestemplatelist'; // To manage different context of search +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $socid = GETPOST('socid', 'int'); -// Security check $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); $lineid = GETPOST('lineid', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -93,26 +93,25 @@ $search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $sear $search_recurring = GETPOST('search_recurring', 'int'); $search_frequency = GETPOST('search_frequency', 'alpha'); $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); +$search_nb_gen_done = GETPOST('search_nb_gen_done', 'aplha'); $search_status = GETPOST('search_status', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'alpha'); -$sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); -if (empty($page) || $page == -1) { +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; -if (!$sortorder) { - $sortorder = 'DESC'; -} -if (!$sortfield) { - $sortfield = 'f.titre'; -} $pageprev = $page - 1; $pagenext = $page + 1; +// Initialize technical objects $object = new FactureFournisseurRec($db); +$extrafields = new ExtraFields($db); + if (($id > 0 || $ref) && $action != 'create' && $action != 'add') { $ret = $object->fetch($id, $ref); if (!$ret) { @@ -122,17 +121,19 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('supplierinvoicereclist')); -$extrafields = new ExtraFields($db); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php - +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortorder) { + $sortorder = 'DESC'; +} +if (!$sortfield) { + $sortfield = 'f.titre'; +} $arrayfields = array( 'f.titre'=>array('label'=>'Ref', 'checked'=>1), 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1), @@ -151,7 +152,7 @@ $arrayfields = array( 'f.fk_user_modif'=>array('label'=>'UserModification', 'checked'=>0, 'position'=>505), 'f.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>520), 'f.tms'=>array('label'=>'DateModificationShort', 'checked'=>0, 'position'=>525), - 'suspended '=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), + 'status'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -168,6 +169,10 @@ if ($socid > 0) { } $objecttype = 'facture_fourn_rec'; +$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php + $result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype); @@ -190,15 +195,15 @@ if ($reshook < 0) { } if (empty($reshook)) { - if (GETPOST('cancel', 'alpha')) { + /*if (GETPOST('cancel', 'alpha')) { $action = ''; - } + }*/ // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Do we click on purge search criteria ? - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_ref = ''; $search_societe = ''; $search_montant_ht = ''; @@ -225,9 +230,15 @@ if (empty($reshook)) { $search_recurring = ''; $search_frequency = ''; $search_unit_frequency = ''; + $search_nb_gen_done = ''; $search_status = ''; + $toselect = array(); $search_array_options = array(); } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } // Mass actions /*$objectclass='MyObject'; @@ -243,9 +254,6 @@ if (empty($reshook)) { * View */ -$help_url = ''; -llxHeader('', $langs->trans("RepeatableSupplierInvoices"), $help_url); - $form = new Form($db); $formother = new FormOther($db); if (isModEnabled('project')) { @@ -256,13 +264,18 @@ $supplierinvoicerectmp = new FactureFournisseurRec($db); $tmpuser = new User($db); $now = dol_now(); + +$help_url = ''; +$title = $langs->trans("RepeatableSupplierInvoices"); +$morejs = array(); +$morecss = array(); + $tmparray = dol_getdate($now); $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day -/* - * List mode - */ +// Build and execute select +// -------------------------------------------------------------------- $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,"; $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; @@ -280,15 +293,22 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn_rec as f'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_rec_extrafields as ef ON ef.fk_object = f.rowid'; if (!$user->hasRight("societe", "client", "voir") && !$socid) { $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; } -$sql .= ' WHERE f.fk_soc = s.rowid'; +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + +$sql .= " WHERE f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '. (int) $user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($search_ref) { $sql .= natural_search('f.titre', $search_ref); @@ -324,7 +344,11 @@ if ($search_frequency != '') { $sql .= natural_search('f.frequency', $search_frequency, 1); } if ($search_unit_frequency != '') { - $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); + $sql .= ' AND f.frequency > 0'; + $sql .= natural_search('f.unit_frequency', $search_unit_frequency); +} +if ($search_nb_gen_done != '') { + $sql .= natural_search("f.nb_gen_done", $search_nb_gen_done, 1); } if ($search_status != '' && $search_status >= -1) { if ($search_status == 0) { @@ -350,582 +374,727 @@ if ($search_date_when_end) { $sql .= " AND f.date_when <= '".$db->idate($search_date_when_end)."'"; } -$tmpsortfield = $sortfield; -if ($tmpsortfield == 'recurring') { - $tmpsortfield = 'f.frequency'; -} -$sql .= $db->order($tmpsortfield, $sortorder); - +// Count total nb of records $nbtotalofrecords = ''; if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +$tmpsortfield = $sortfield; +if ($tmpsortfield == 'recurring') { + $tmpsortfield = 'f.frequency'; +} + +// Complete request and execute it with limit +$sql .= $db->order($tmpsortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); +if (!$resql) { + dol_print_error($db); + exit; +} - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($socid > 0) { - $param .= '&socid='.urlencode($socid); - } - if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); - } - if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); - } - if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); - } - if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); - } - if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); - } - if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); - } - if ($search_date_when_startday) { - $param .= '&search_date_when_startday='.urlencode($search_date_when_startday); - } - if ($search_date_when_startmonth) { - $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth); - } - if ($search_date_when_startyear) { - $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear); - } - if ($search_date_when_endday) { - $param .= '&search_date_when_endday='.urlencode($search_date_when_endday); - } - if ($search_date_when_endmonth) { - $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth); - } - if ($search_date_when_endyear) { - $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_societe) { - $param .= '&search_societe='.urlencode($search_societe); - } - if ($search_montant_ht != '') { - $param .= '&search_montant_ht='.urlencode($search_montant_ht); - } - if ($search_montant_vat != '') { - $param .= '&search_montant_vat='.urlencode($search_montant_vat); - } - if ($search_montant_ttc != '') { - $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); - } - if ($search_payment_mode != '') { - $param .= '&search_payment_mode='.urlencode($search_payment_mode); - } - if ($search_payment_term != '') { - $param .= '&search_payment_term='.urlencode($search_payment_term); - } - if ($search_recurring != '' && $search_recurring != '-1') { - $param .= '&search_recurring='.urlencode($search_recurring); - } - if ($search_frequency > 0) { - $param .= '&search_frequency='.urlencode($search_frequency); - } - if ($search_unit_frequency != '') { - $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); - } - if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +$num = $db->num_rows($resql); - $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); +// Output page +// -------------------------------------------------------------------- - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); - print ''; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +$arrayofselected = is_array($toselect) ? $toselect : array(); - $title = $langs->trans("RepeatableSupplierInvoices"); +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); +} +if ($socid > 0) { + $param .= '&socid='.urlencode($socid); +} +if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); +} +if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); +} +if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); +} +if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); +} +if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); +} +if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); +} +if ($search_date_when_startday) { + $param .= '&search_date_when_startday='.urlencode($search_date_when_startday); +} +if ($search_date_when_startmonth) { + $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth); +} +if ($search_date_when_startyear) { + $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear); +} +if ($search_date_when_endday) { + $param .= '&search_date_when_endday='.urlencode($search_date_when_endday); +} +if ($search_date_when_endmonth) { + $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth); +} +if ($search_date_when_endyear) { + $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear); +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_societe) { + $param .= '&search_societe='.urlencode($search_societe); +} +if ($search_montant_ht != '') { + $param .= '&search_montant_ht='.urlencode($search_montant_ht); +} +if ($search_montant_vat != '') { + $param .= '&search_montant_vat='.urlencode($search_montant_vat); +} +if ($search_montant_ttc != '') { + $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); +} +if ($search_payment_mode != '') { + $param .= '&search_payment_mode='.urlencode($search_payment_mode); +} +if ($search_payment_term != '') { + $param .= '&search_payment_term='.urlencode($search_payment_term); +} +if ($search_recurring != '' && $search_recurring != '-1') { + $param .= '&search_recurring='.urlencode($search_recurring); +} +if ($search_frequency > 0) { + $param .= '&search_frequency='.urlencode($search_frequency); +} +if ($search_unit_frequency != '') { + $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); +} +if ($search_nb_gen_done != '') { + $param .= '&search_nb_gen_done='.urlencode($search_nb_gen_done); +} +if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; - print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), + //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +); - print ''.$langs->trans("ToCreateAPredefinedSupplierInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; +$massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - $i = 0; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields +//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - $moreforfilter = ''; +print ''."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; - print '
'; - print ''."\n"; - // Filters lines - print ''; - // Ref - if (!empty($arrayfields['f.titre']['checked'])) { - print ''; - } - // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - } - if (!empty($arrayfields['f.total_ht']['checked'])) { - // Amount net - print ''; - } - if (!empty($arrayfields['f.total_tva']['checked'])) { - // Amount Vat - print ''; - } - if (!empty($arrayfields['f.total_ttc']['checked'])) { - // Amount - print ''; - } - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - // Payment term - print '"; - } - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - // Payment mode - print ''; - } - if (!empty($arrayfields['recurring']['checked'])) { - // Recurring or not - print ''; - } - if (!empty($arrayfields['f.frequency']['checked'])) { - // Recurring or not - print ''; - } - if (!empty($arrayfields['f.unit_frequency']['checked'])) { - // Frequency unit - print ''; - } - if (!empty($arrayfields['f.nb_gen_done']['checked'])) { - // Nb generation - print ''; - } - // Date invoice - if (!empty($arrayfields['f.date_last_gen']['checked'])) { - print ''; - } - // Date next generation - if (!empty($arrayfields['f.date_when']['checked'])) { - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; +print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // User creation - if (!empty($arrayfields['f.fk_user_author']['checked'])) { - print ''; - } - // User modification - if (!empty($arrayfields['f.fk_user_modif']['checked'])) { - print ''; - } - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - } - // Action column - print ''; +} + +$db->free($resql); + + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); - print "'; - print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1); - print ''; - print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print '
'; - 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')); - print '
'; - print '
'; - 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')); - print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; +print ''.$langs->trans("ToCreateAPredefinedSupplierInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; + +$i = 0; + +$moreforfilter = ''; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} +// Ref +if (!empty($arrayfields['f.titre']['checked'])) { + print ''; +} +// Thirdparty +if (!empty($arrayfields['s.nom']['checked'])) { + print ''; +} +if (!empty($arrayfields['f.total_ht']['checked'])) { + // Amount net + print ''; +} +if (!empty($arrayfields['f.total_tva']['checked'])) { + // Amount Vat + print ''; +} +if (!empty($arrayfields['f.total_ttc']['checked'])) { + // Amount + print ''; +} +if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + // Payment term + print '"; +} +if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + // Payment mode + print ''; +} +if (!empty($arrayfields['recurring']['checked'])) { + // Recurring or not + print ''; +} +if (!empty($arrayfields['f.frequency']['checked'])) { + // Recurring or not + print ''; +} +if (!empty($arrayfields['f.unit_frequency']['checked'])) { + // Frequency unit + print ''; +} +if (!empty($arrayfields['f.nb_gen_done']['checked'])) { + // Nb generation + print ''; +} +// Date invoice +if (!empty($arrayfields['f.date_last_gen']['checked'])) { + print ''; +} +// Date next generation +if (!empty($arrayfields['f.date_when']['checked'])) { + print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// User creation +if (!empty($arrayfields['f.fk_user_author']['checked'])) { + print ''; +} +// User modification +if (!empty($arrayfields['f.fk_user_modif']['checked'])) { + print ''; +} +// Date creation +if (!empty($arrayfields['f.datec']['checked'])) { + print ''; +} +// Date modification +if (!empty($arrayfields['f.tms']['checked'])) { + print ''; +} +// Status +if (!empty($arrayfields['status']['checked'])) { + print ''; +} +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; - print "\n"; +} +print ''."\n"; + +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.titre']['checked'])) { + print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.total_tva']['checked'])) { + print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['recurring']['checked'])) { + print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.frequency']['checked'])) { + print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.unit_frequency']['checked'])) { + print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.nb_gen_done']['checked'])) { + print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.date_last_gen']['checked'])) { + print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.date_when']['checked'])) { + print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_user_author']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.fk_user_modif']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.datec']['checked'])) { + print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['f.tms']['checked'])) { + print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +if (!empty($arrayfields['status']['checked'])) { + print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} +print ''."\n"; + +$i = 0; +$savnbfield = $totalarray['nbfield']; +$totalarray = array(); +$totalarray['nbfield'] = 0; +$totalarray['val']['f.total_ht'] = 0; +$totalarray['val']['f.total_tva'] = 0; +$totalarray['val']['f.total_ttc'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); + +while ($i < $imaxinloop) { + $objp = $db->fetch_object($resql); + if (empty($objp)) { + break; + } + + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + + $supplierinvoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid; + $supplierinvoicerectmp->frequency = $objp->frequency; + $supplierinvoicerectmp->suspended = $objp->suspended; + $supplierinvoicerectmp->unit_frequency = $objp->unit_frequency; + $supplierinvoicerectmp->nb_gen_max = $objp->nb_gen_max; + $supplierinvoicerectmp->nb_gen_done = $objp->nb_gen_done; + $supplierinvoicerectmp->ref = $objp->title; + $supplierinvoicerectmp->total_ht = $objp->total_ht; + $supplierinvoicerectmp->total_tva = $objp->total_tva; + $supplierinvoicerectmp->total_ttc = $objp->total_ttc; + + // Show here line of result + $j = 0; + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } - print ''; if (!empty($arrayfields['f.titre']['checked'])) { - print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.total_ht']['checked'])) { - print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, 'class="right"', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } + $totalarray['val']['f.total_ht'] += $objp->total_ht; } if (!empty($arrayfields['f.total_tva']['checked'])) { - print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, 'class="right"', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; + } + $totalarray['val']['f.total_tva'] += $objp->total_tva; } if (!empty($arrayfields['f.total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } + $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } + // Payment term if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } } + // Payment mode if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } } + // Is it a recurring invoice if (!empty($arrayfields['recurring']['checked'])) { - print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.frequency']['checked'])) { - print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.unit_frequency']['checked'])) { - print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.nb_gen_done']['checked'])) { - print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + // Date last generation if (!empty($arrayfields['f.date_last_gen']['checked'])) { - print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + // Date next generation if (!empty($arrayfields['f.date_when']['checked'])) { - print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.fk_user_author']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.fk_user_modif']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.datec']['checked'])) { - print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['f.tms']['checked'])) { - print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + + $obj = $objp; // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Status if (!empty($arrayfields['status']['checked'])) { - print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch '); - print "\n"; - - if ($num > 0) { - $i = 0; - $totalarray = array(); - $totalarray['nbfield'] = 0; - $totalarray['val']['f.total_ht'] = 0; - $totalarray['val']['f.total_tva'] = 0; - $totalarray['val']['f.total_ttc'] = 0; - while ($i < min($num, $limit)) { - $objp = $db->fetch_object($resql); - if (empty($objp)) { - break; - } - - $companystatic->id = $objp->socid; - $companystatic->name = $objp->name; - - $supplierinvoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid; - $supplierinvoicerectmp->frequency = $objp->frequency; - $supplierinvoicerectmp->suspended = $objp->suspended; - $supplierinvoicerectmp->unit_frequency = $objp->unit_frequency; - $supplierinvoicerectmp->nb_gen_max = $objp->nb_gen_max; - $supplierinvoicerectmp->nb_gen_done = $objp->nb_gen_done; - $supplierinvoicerectmp->ref = $objp->title; - $supplierinvoicerectmp->total_ht = $objp->total_ht; - $supplierinvoicerectmp->total_tva = $objp->total_tva; - $supplierinvoicerectmp->total_ttc = $objp->total_ttc; - - print ''; - - if (!empty($arrayfields['f.titre']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.total_ht']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; - } - $totalarray['val']['f.total_ht'] += $objp->total_ht; - } - if (!empty($arrayfields['f.total_tva']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; - } - $totalarray['val']['f.total_tva'] += $objp->total_tva; - } - if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; - } - $totalarray['val']['f.total_ttc'] += $objp->total_ttc; - } - // Payment term - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Is it a recurring invoice - if (!empty($arrayfields['recurring']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.frequency']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.unit_frequency']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.nb_gen_done']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date last generation - if (!empty($arrayfields['f.date_last_gen']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date next generation - if (!empty($arrayfields['f.date_when']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.fk_user_author']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.fk_user_modif']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $obj = $objp; - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Status - if (!empty($arrayfields['status']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - print '"; - - print "\n"; - - $i++; - } - } else { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; + print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); } } - print ''; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + print ''."\n"; - - print "
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); + print "'; + print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1); + print ''; + print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print '
'; + 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')); + print '
'; + print '
'; + 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')); + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + $liststatus = array( + 0=>$langs->trans("Draft"), + 1=>$langs->trans("Active"), + -1=>$langs->trans("Disabled"), + ); + print $form->selectarray('search_status', $liststatus, $search_status, -2, 0, 0, '', 0, 0, 0, '', 'width100 onrightofpage'); + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; + if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) { + if ($supplierinvoicerectmp->isMaxNbGenReached()) { + print $langs->trans("MaxNumberOfGenerationReached"); + } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { + print ''; + print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"'); + print $langs->trans("CreateBill").''; + } else { + print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); + } + } + print "
'; + print $supplierinvoicerectmp->getNomUrl(1); + print "'.$companystatic->getNomUrl(1, 'supplier').''.price($objp->total_ht).''.price($objp->total_tva).''.price($objp->total_ttc).''; + $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); + print ''; + $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); + print ''.($objp->frequency ? img_picto($langs->trans("Frequency").': '.$objp->frequency.' '.$objp->unit_frequency, 'recurring', 'class="opacitymedium"').' ' : '').yn($objp->frequency ? 1 : 0).''; + print ($objp->frequency > 0 ? $objp->frequency : ''); + print ''; + if ($objp->frequency > 1) { + $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")); + } else { + $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")); + } + print ($objp->frequency > 0 ? $dur[$objp->unit_frequency] : ''); + print ''; + print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : ''.$langs->trans('NA').''); + print ''; + print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); + print ''; + print '
'; + print ($objp->frequency ? ($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '').dol_print_date($db->jdate($objp->date_when), 'day').($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '') : ''.$langs->trans('NA').''); + if (!$supplierinvoicerectmp->isMaxNbGenReached()) { + if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) { + print img_warning($langs->trans("Late")); + } + } else { + print img_info($langs->trans("MaxNumberOfGenerationReached")); + } + print '
'; + print '
'; + if ($objp->fk_user_author > 0) { + $tmpuser->fetch($objp->fk_user_author); + print $tmpuser->getNomUrl(1); + } + print ''; + if ($objp->fk_user_author > 0) { + $tmpuser->fetch($objp->fk_user_author); + print $tmpuser->getNomUrl(1); + } + print ''; + print dol_print_date($db->jdate($objp->datec), 'dayhour'); + print ''; + print dol_print_date($db->jdate($objp->tms), 'dayhour'); + print ''; + print $supplierinvoicerectmp->getLibStatut(5, 0); + print '
'; - print $supplierinvoicerectmp->getNomUrl(1); - print ""; - print "'.$companystatic->getNomUrl(1, 'supplier').''.price($objp->total_ht).''.price($objp->total_tva).''.price($objp->total_ttc).''; - $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); - print ''; - $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); - print ''.($objp->frequency ? img_picto($langs->trans("Frequency").': '.$objp->frequency.' '.$objp->unit_frequency, 'recurring', 'class="opacitymedium"').' ' : '').yn($objp->frequency ? 1 : 0).''; - print ($objp->frequency > 0 ? $objp->frequency : ''); - print ''; - if ($objp->frequency > 1) { - $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")); - } else { - $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")); - } - print ($objp->frequency > 0 ? $dur[$objp->unit_frequency] : ''); - print ''; - print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : ''.$langs->trans('NA').''); - print ''; - print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); - print ''; - print '
'; - print ($objp->frequency ? ($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '').dol_print_date($db->jdate($objp->date_when), 'day').($supplierinvoicerectmp->isMaxNbGenReached() ? '' : '') : ''.$langs->trans('NA').''); - if (!$supplierinvoicerectmp->isMaxNbGenReached()) { - if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) { - print img_warning($langs->trans("Late")); - } - } else { - print img_info($langs->trans("MaxNumberOfGenerationReached")); - } - print '
'; - print '
'; - if ($objp->fk_user_author > 0) { - $tmpuser->fetch($objp->fk_user_author); - print $tmpuser->getNomUrl(1); - } - print ''; - if ($objp->fk_user_author > 0) { - $tmpuser->fetch($objp->fk_user_author); - print $tmpuser->getNomUrl(1); - } - print ''; - print dol_print_date($db->jdate($objp->datec), 'dayhour'); - print ''; - print dol_print_date($db->jdate($objp->tms), 'dayhour'); - print ''; - print $supplierinvoicerectmp->getLibStatut(3, 0); - print ''; - if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) { - if ($supplierinvoicerectmp->isMaxNbGenReached()) { - print $langs->trans("MaxNumberOfGenerationReached"); - } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { - print ''; - print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"'); - print $langs->trans("CreateBill").''; - } else { - print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); - } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) { + if ($supplierinvoicerectmp->isMaxNbGenReached()) { + print $langs->trans("MaxNumberOfGenerationReached"); + } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { + print ''; + print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"'); + print $langs->trans("CreateBill").''; } else { - print " "; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "
'.$langs->trans("NoRecordFound").'
"; - print "
"; - print ""; - - $db->free($resql); -} else { - dol_print_error($db); + $i++; } + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print ''."\n"; + + // End of page llxFooter(); $db->close();