diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 1026ea12442..5347eebd392 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -245,6 +245,7 @@ if ($action == 'update') {
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_CHECKBOX_LEFT_COLUMN", GETPOST("MAIN_CHECKBOX_LEFT_COLUMN", 'int'), 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", GETPOST("MAIN_DISABLE_JAVASCRIPT", 'aZ09'), 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", GETPOST("MAIN_BUTTON_HIDE_UNAUTHORIZED", 'aZ09'), 'chaine', 0, '', $conf->entity);
@@ -408,6 +409,12 @@ if ($mode == 'other') {
print '
| '.$langs->trans("showInputBorder").' | ';
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 0471b97c038..f0d6001d892 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -51,7 +51,8 @@ $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');
+$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');
@@ -66,7 +67,6 @@ $objecttype = 'facture_rec';
if ($action == "create" || $action == "add") {
$objecttype = '';
}
-$result = restrictedArea($user, 'facture', $id, $objecttype);
$search_ref = GETPOST('search_ref');
$search_societe = GETPOST('search_societe');
@@ -101,20 +101,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) {
+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 FactureRec($db);
+$extrafields = new ExtraFields($db);
+
if (($id > 0 || $ref) && $action != 'create' && $action != 'add') {
$ret = $object->fetch($id, $ref);
if (!$ret) {
@@ -124,16 +122,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('invoicereclist'));
-$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->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
-$permissiontoedit = $user->rights->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),
@@ -169,7 +170,6 @@ if ($socid > 0) {
}
}
-
if ($socid > 0) {
$tmpthirdparty = new Societe($db);
$res = $tmpthirdparty->fetch($socid);
@@ -180,6 +180,10 @@ if ($socid > 0) {
$objecttype = 'facture_rec';
+$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
+$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
+
$result = restrictedArea($user, 'facture', $object->id, $objecttype);
@@ -202,15 +206,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 = '';
@@ -239,8 +243,13 @@ if (empty($reshook)) {
$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';
@@ -256,8 +265,6 @@ if (empty($reshook)) {
* View
*/
-llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-facture-rec');
-
$form = new Form($db);
$formother = new FormOther($db);
if (isModEnabled('project')) {
@@ -268,13 +275,17 @@ $invoicerectmp = new FactureRec($db);
$tmpuser = new User($db);
$now = dol_now();
+
+$help_url = '';
+$title = $langs->trans("RepeatableInvoices");
+$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,";
@@ -292,11 +303,18 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $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_rec as f";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
+// 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 (empty($user->rights->societe->client->voir) && !$socid) {
@@ -366,587 +384,696 @@ 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 (empty($conf->global->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='.urlencode($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';
+$num = $db->num_rows($resql);
- $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.=$form->showCheckAddButtons('checkforselect', 1);
+// Output page
+// --------------------------------------------------------------------
- print ''."\n";
+
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 1255586b2dc..5ef76f9ef88 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -9784,7 +9784,7 @@ class Form
/**
* Return HTML to show the search and clear seach button
*
- * @param string $pos position colon on liste value left or right
+ * @param string $pos Position of colon on the list. Value 'left' or 'right'
* @return string
*/
public function showFilterButtons($pos = '')
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 3c5991128d7..d9e12731022 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -2372,3 +2372,4 @@ WarningModuleHasChangedLastVersionCheckParameter=Warning: the module %s has set
WarningModuleHasChangedSecurityCsrfParameter=Warning: the module %s has disabled the CSRF security of your instance. This action is suspect and your installation may no more be secured. Please contact the author of the module for explanation.
EMailsInGoingDesc=Incoming emails are managed by the module %s. You must enable and configure it if you need to support ingoing emails.
MAIN_IMAP_USE_PHPIMAP=Use the PHP-IMAP library for IMAP instead of native PHP IMAP. This also allows the use of an OAuth2 connection for IMAP (module OAuth must also be activated).
+MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default)
\ No newline at end of file
|