diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index f52641dc63a6e17aebe0533e304bdcb5e7e547cf..3595d871c728fed6d2bb2d6af1cb85818a655843 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -992,7 +992,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index c88b3d552c1cfa848fdf5124e8b25b0c8470573d..8cab07c978022770e684a88c8a58fdba0fcdf6c7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1403,7 +1403,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index bddf1292214d6c06119ce30d7ffa5014092f3ceb..286836b010322c2ee3d47c747b22470cc5d312b3 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -1264,7 +1264,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totaldebfield'] == $i) print '<td align="right">'.price(-1 * $totalarray['totaldeb']).'</td>'; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index b808fa8f596a099244cba18198f15e80a04ed1f8..f98f9b9cb49d5622d677b24d12837bf4c28bcb19 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -606,7 +606,7 @@ if (isset($totalarray['totalbalancefield']) && $lastcurrencycode != 'various') / $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalbalancefield'] == $i) print '<td align="right">'.price($totalarray['totalbalance'], 0, $langs, 0, 0, -1, $lastcurrencycode).'</td>'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 8946dc84bd4d8e2b768405bfaa090d8a7589b57f..5b01c4459606df836d07abbe5693d8e480eaf124 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -517,7 +517,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit,$offset); +$sql.= $db->plimit($limit+1,$offset); //print $sql; $resql = $db->query($sql); @@ -1270,7 +1270,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 706c75fab0743525c198402234abdde85635540d..e76a6edc49ab859e4abcff7091f08983825f1bb4 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -273,7 +273,7 @@ if ($resql) if (isset($totalarray['totalttcfield'])) { print '<tr class="liste_total">'; - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; print '<td></td>'; print '<td></td>'; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index e9712816b34242b3afa7a9b249277dfc4c9ce405..204115d811242407ac7bb6c0adba4296a2e3db73 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -694,7 +694,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 3b6f1be10ffb2da755b03b879c352b739334b741..b5a6bcb0e94b1522a4ede35305e0cf06a4818b2b 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -592,7 +592,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>'; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 6ff901521c62b429943ec9bf0268206450611821..2924a40001a263be5c3f3ad2c31ee5f2d3b5293f 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1167,7 +1167,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; diff --git a/htdocs/modulebuilder/skeletons/skeleton_card.php b/htdocs/modulebuilder/skeletons/skeleton_card.php index 42fce48e2cbc3a5a4deded58e829ba0a256ac2bf..84cbcbb216070477f9072de181f2ed559fe70c03 100644 --- a/htdocs/modulebuilder/skeletons/skeleton_card.php +++ b/htdocs/modulebuilder/skeletons/skeleton_card.php @@ -84,11 +84,11 @@ $hookmanager->initHooks(array('skeleton')); -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ +/* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + */ $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -210,11 +210,11 @@ if (empty($reshook)) -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ +/* + * VIEW + * + * Put here all code to build page + */ $form=new Form($db); diff --git a/htdocs/modulebuilder/skeletons/skeleton_list.php b/htdocs/modulebuilder/skeletons/skeleton_list.php index c7b728617eadf111da62c52228cf904c77dcb209..51158664889dc7a7eadc9d639773ae2f2e837562 100644 --- a/htdocs/modulebuilder/skeletons/skeleton_list.php +++ b/htdocs/modulebuilder/skeletons/skeleton_list.php @@ -137,11 +137,11 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ +/* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } @@ -177,11 +177,11 @@ if (empty($reshook)) -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ +/* + * VIEW + * + * Put here all code to build page + */ $now=dol_now(); @@ -244,7 +244,6 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.=$db->order($sortfield,$sortorder); -//$sql.= $db->plimit($conf->liste_limit+1, $offset); // Count total nb of records $nbtotalofrecords = ''; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php new file mode 100644 index 0000000000000000000000000000000000000000..c249f165242950432c2975456b3a3706ac776e30 --- /dev/null +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -0,0 +1,175 @@ +<?php +/* <one line to give the program's name and a brief idea of what it does.> + * Copyright (C) <year> <name of author> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file myobject_list.php + * \ingroup mymodule + * \brief Page with list of myobject. + * + * List of myobject + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + +// Change the following lines to use the correct relative path (../, ../../, etc) + +// Load Dolibarr environment +if (false === (@include '../../main.inc.php')) { // From htdocs directory + require '../../../main.inc.php'; // From "custom" directory +} + +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +dol_include_once('/mymodule/class/myclass.class.php'); + +// Load translation files required by the page +$langs->load("mymodule@mymodule"); + +// Get parameters +$action = GETPOST('action','alpha'); +$massaction = GETPOST('massaction','alpha'); +$show_files = GETPOST('show_files','int'); +$confirm = GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + +$id = GETPOST('id','int'); +$backtopage = GETPOST('backtopage'); +// TODO Add here list of search params +$myparam = GETPOST('myparam','alpha'); + +// Load variable for pagination +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield="t.rowid"; // Set here default search field +if (! $sortorder) $sortorder="ASC"; + +// Protection if external user +if ($user->societe_id > 0) +{ + //accessforbidden(); +} +//$result = restrictedArea($user, 'mymodule', $id); + +// Initialize technical object to manage context to save list fields +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'mymodulelist'; + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('mymodulelist')); +$extrafields = new ExtraFields($db); + +// Load object if id or ref is provided as parameter +$object = new MyClass($db); +if (($id > 0 || ! empty($ref)) && $action != 'add') { + $result = $object->fetch($id, $ref); + if ($result < 0) dol_print_error($db); +} + + +/* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + */ + +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + { + $search_field1=''; + $search_field2=''; + $search_date_creation=''; + $search_date_update=''; + $toselect=''; + $search_array_options=array(); + } + + // Mass actions + $objectclass='Skeleton'; + $objectlabel='Skeleton'; + $permtoread = $user->rights->skeleton->read; + $permtodelete = $user->rights->skeleton->delete; + $uploaddir = $conf->skeleton->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + +/* + * VIEW + * + * Put here all code to build page + */ + +llxHeader('', $langs->trans('MyPageName'), ''); + +$form = new Form($db); + +// Put here content of your page +// Example 1: Adding jquery code +print '<script type="text/javascript" language="javascript"> +jQuery(document).ready(function() { + function init_myfunc() + { + jQuery("#myid").removeAttr(\'disabled\'); + jQuery("#myid").attr(\'disabled\',\'disabled\'); + } + init_myfunc(); + jQuery("#mybutton").click(function() { + init_myfunc(); + }); +}); +</script>'; + + + +// TODO + + + + +// Example 2: Adding links to objects +// The class must extend CommonObject for this method to be available +$somethingshown = $form->showLinkedObjectBlock($myobject); + +// End of page +llxFooter(); diff --git a/htdocs/modulebuilder/template/mypage.php b/htdocs/modulebuilder/template/mypage.php deleted file mode 100644 index 368fd86c0a44226dde0e3574e0743607ab89b68d..0000000000000000000000000000000000000000 --- a/htdocs/modulebuilder/template/mypage.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/* <one line to give the program's name and a brief idea of what it does.> - * Copyright (C) <year> <name of author> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * \file mypage.php - * \ingroup mymodule - * \brief Example PHP page. - * - * Put detailed description here. - */ - -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -// Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -// Do not check style html tag into posted data -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); -// Do not check anti POST attack test -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -// If there is no need to load and show top and left menu -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -// If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -// If this page is public (can be called outside logged session) -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); -// Change the following lines to use the correct relative path -// (../, ../../, etc) - -// Load Dolibarr environment -if (false === (@include '../../main.inc.php')) { // From htdocs directory - require '../../../main.inc.php'; // From "custom" directory -} - -global $db, $langs, $user; - -dol_include_once('/mymodule/class/myclass.class.php'); - -// Load translation files required by the page -$langs->load("mymodule@mymodule"); - -// Get parameters -$id = GETPOST('id', 'int'); -$action = GETPOST('action', 'alpha'); -$myparam = GETPOST('myparam', 'alpha'); - -// Access control -if ($user->socid > 0) { - // External user - accessforbidden(); -} - -// Default action -if (empty($action) && empty($id) && empty($ref)) { - $action='create'; -} - -// Load object if id or ref is provided as parameter -$object = new MyClass($db); -if (($id > 0 || ! empty($ref)) && $action != 'add') { - $result = $object->fetch($id, $ref); - if ($result < 0) { - dol_print_error($db); - } -} - -/* - * ACTIONS - * - * Put here all code to do according to value of "action" parameter - */ - -if ($action == 'add') { - $myobject = new MyClass($db); - $myobject->prop1 = $_POST["field1"]; - $myobject->prop2 = $_POST["field2"]; - $result = $myobject->create($user); - if ($result > 0) { - // Creation OK - } { - // Creation KO - $mesg = $myobject->error; - } -} - -/* - * VIEW - * - * Put here all code to build page - */ - -llxHeader('', $langs->trans('MyPageName'), ''); - -$form = new Form($db); - -// Put here content of your page -// Example 1: Adding jquery code -echo '<script type=application/javascript" language="javascript"> - jQuery(document).ready(function() { - function init_myfunc() - { - jQuery("#myid") - .removeAttr(\'disabled\') - .attr(\'disabled\',\'disabled\'); - } - init_myfunc(); - jQuery("#mybutton").click(function() { - init_needroot(); - }); - }); -</script>'; - -// Example 2: Adding links to objects -// The class must extend CommonObject for this method to be available -$somethingshown = $form->showLinkedObjectBlock($myobject); - -// End of page -llxFooter(); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index b3c4737b1a52edccdea2f2bfadc4525882f27769..d8879d1fa28dcf283cc7f84010e4fdee2f60ef8b 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -569,7 +569,7 @@ if ($resql) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index e5cab88609a009ab8a33b58568ae25b1726f3027..a7285e1f410fd2b4870217b6fc7de2a82faa3a90 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -883,7 +883,7 @@ if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield'] $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totaloppfield'] == $i) print '<td align="right">'.price($totalarray['totalopp']).'</td>'; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 9450a2620ed4111c3f0a97c774479b9d9ccb972b..8579d436d71f26172eaf267a95eb46d630e18c66 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -858,7 +858,7 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totalplannedworkloadfield'] == $i) print '<td align="center">'.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).'</td>'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index b090680b6bcb72d6e19691911ded9a791c73f2b9..eed7bae2734f315c0063a74ed27ff6fd63c097a1 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -996,7 +996,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $i++; if ($i == 1) { - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; } elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'],'allhourmin').'</td>';