From a6d8f943df769e3ae000ea16ac593884b2109459 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2015 02:12:37 +0100 Subject: [PATCH 1/4] Fix several bugs into leave requets module --- htdocs/core/class/html.form.class.php | 5 ++- htdocs/core/menus/init_menu_auguria.sql | 10 +++-- htdocs/holiday/card.php | 58 ++++++++++++++----------- htdocs/holiday/list.php | 2 +- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index da22c014e50..549959bd561 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1259,10 +1259,11 @@ class Form * @param string $show_every 0=default list, 1=add also a value "Everybody" at beginning of list * @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. * @param string $morecss More css + * @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='') + function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0) { global $conf,$user,$langs; @@ -1322,7 +1323,7 @@ class Form if (! empty($user->societe_id)) $sql.= " AND u.fk_soc = ".$user->societe_id; if (is_array($exclude) && $excludeUsers) $sql.= " AND u.rowid NOT IN ('".$excludeUsers."')"; if (is_array($include) && $includeUsers) $sql.= " AND u.rowid IN ('".$includeUsers."')"; - if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND u.statut <> 0"; + if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql.= " AND u.statut <> 0"; if (! empty($morefilter)) $sql.=" ".$morefilter; $sql.= " ORDER BY u.lastname ASC"; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 8444a855650..71d393955e7 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -300,11 +300,13 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5200__+MAX_llx_menu__, 'members', 'cat', 13__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=3', 'MembersCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5201__+MAX_llx_menu__, 'members', '', 5200__+MAX_llx_menu__, '/categories/card.php?action=create&type=3', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- HRM - Holiday -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?&action=request', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?&action=request', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?&action=request', 'MenuLogCP', 1, 'holiday', '$user->rights->holiday->view_log', '', 0, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/month_report.php?&action=request', 'MenuReportMonth', 1, 'holiday', '$user->rights->holiday->month_report', '', 0, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'List', 1, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?select_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?&action=request', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5005__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?&action=request', 'MenuLogCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5006__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/month_report.php?&action=request', 'MenuReportMonth', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 4, __ENTITY__); -- HRM - Expense reports insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled', __HANDLER__, 'left', 2100__+MAX_llx_menu__, 'accountancy', 'tripsandexpenses', 15__+MAX_llx_menu__, '/compta/deplacement/index.php?leftmenu=tripsandexpenses', 'TripsAndExpenses', 0, 'trips', '$user->rights->deplacement->lire', '', 0, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled', __HANDLER__, 'left', 2101__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses', 'New', 1, 'trips', '$user->rights->deplacement->creer', '', 0, 1, __ENTITY__); diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index ebda47dd196..ca0b1d04d7a 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -124,22 +124,31 @@ if ($action == 'create') // If no validator designated if ($valideur < 1) { - header('Location: card.php?action=request&error=Valideur'); - exit; + setEventMessage($langs->transnoentitiesnoconv('InvalidValidatorCP'), 'errors'); + $error++; } - $cp->fk_user = $userid; - $cp->description = $description; - $cp->date_debut = $date_debut; - $cp->date_fin = $date_fin; - $cp->fk_validator = $valideur; - $cp->halfday = $halfday; - $cp->fk_type = $type; - - $verif = $cp->create($user); + if ($type < 1) + { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Type")), 'errors'); + $error++; + } + if (! $error) + { + $cp->fk_user = $userid; + $cp->description = $description; + $cp->date_debut = $date_debut; + $cp->date_fin = $date_fin; + $cp->fk_validator = $valideur; + $cp->halfday = $halfday; + $cp->fk_type = $type; + + $verif = $cp->create($user); + } + // If no SQL error we redirect to the request card - if ($verif > 0) + if (! $error && $verif > 0) { $db->commit(); @@ -149,10 +158,6 @@ if ($action == 'create') else { $db->rollback(); - - // Otherwise we display the request form with the SQL error message - header('Location: card.php?action=request&error=SQL_Create&msg='.$cp->error); - exit; } } } @@ -802,6 +807,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create $arraytypeleaves[$val['rowid']]=$labeltoshow; } print $form->selectarray('type', $arraytypeleaves, (GETPOST('type')?GETPOST('type'):''), 1); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; print ''; @@ -810,10 +816,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''.$langs->trans("DateDebCP").' ('.$langs->trans("FirstDayOfHoliday").')'; print ''; // Si la demande ne vient pas de l'agenda - if(!isset($_GET['datep'])) { + if (! GETPOST('date_debut_')) { $form->select_date(-1,'date_debut_'); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('datepmonth'), GETPOST('datepday'), GETPOST('datepyear')); + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); $form->select_date($tmpdate,'date_debut_'); } print '     '; @@ -826,10 +832,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''.$langs->trans("DateFinCP").' ('.$langs->trans("LastDayOfHoliday").')'; print ''; // Si la demande ne vient pas de l'agenda - if(!isset($_GET['datep'])) { + if (! GETPOST('date_fin_')) { $form->select_date(-1,'date_fin_'); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('datefmonth'), GETPOST('datefday'), GETPOST('datefyear')); + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); $form->select_date($tmpdate,'date_fin_'); } print '     '; @@ -846,7 +852,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create $valideurarray = array(); foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; print ''; - print $form->select_dolusers($user->fk_user, "valideur", 1, "", 0, $valideurarray); // By default, hierarchical parent + print $form->select_dolusers((GETPOST('valideur')>0?GETPOST('valideur'):$user->fk_user), "valideur", 1, "", 0, $valideurarray, 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent print ''; print ''; @@ -973,7 +979,6 @@ else $head=holiday_prepare_head($cp); - dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday'); if ($action == 'edit' && $cp->statut == 1) { @@ -983,6 +988,8 @@ else print ''."\n"; } + dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday'); + print ''; print ''; @@ -1157,19 +1164,20 @@ else print ''; print '
'; + dol_fiche_end(); + if ($action == 'edit' && $cp->statut == 1) { - print '
'; + print '
'; if ($canedit && $cp->statut == 1) { - print ''; + print ''; } print '
'; print ''; } - dol_fiche_end(); if (! $edit) { diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 4e10fbf925c..b329cffda35 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -406,7 +406,7 @@ if (! empty($holiday->holiday)) if($holiday_payes == '2') { print ''; - print ''.$langs->trans('None').''; + print ''.$langs->trans('None').''; print ''; } From 1b9039af36f318fec9d39ccba8884d3bcad71006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 26 Nov 2015 20:30:11 +0100 Subject: [PATCH 2/4] Update list.php --- htdocs/resource/list.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 29ae4a42803..9a19809d5d7 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -22,15 +22,10 @@ */ -// Change this following line to use the correct relative path (../, ../../, etc) -$res=0; -$res=@include("../main.inc.php"); // For root directory -if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory -if (! $res) die("Include of main fails"); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php'; -require 'class/resource.class.php'; - -// Load traductions files requiredby by page +// Load translations files requiredby by page $langs->load("resource"); $langs->load("companies"); $langs->load("other"); @@ -52,7 +47,7 @@ $object = new Resource($db); $hookmanager->initHooks(array('resource_list')); -if (empty($sortorder)) $sortorder="DESC"; +if (empty($sortorder)) $sortorder="ASC"; if (empty($sortfield)) $sortfield="t.rowid"; if (empty($arch)) $arch = 0; @@ -89,8 +84,6 @@ llxHeader('',$pagetitle,''); $form=new Form($db); -print_fiche_titre($pagetitle,'','title_generic'); - // Confirmation suppression resource line if ($action == 'delete_resource') { @@ -102,6 +95,8 @@ $ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset); if($ret == -1) { dol_print_error($db,$object->error); exit; +} else { + print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $ret+1, $object->num_all,'title_generic.png'); } if(!$ret) { print '
'.$langs->trans('NoResourceInDatabase').'
'; From e6033369a8501e5fbe2473c6f068792641743996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 26 Nov 2015 20:33:07 +0100 Subject: [PATCH 3/4] Update resource.class.php --- htdocs/resource/class/resource.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php index 3c3f0ee6e49..e42b8983c7a 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/resource.class.php @@ -22,7 +22,6 @@ */ -// Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"; @@ -403,7 +402,13 @@ class Resource extends CommonObject } $sql.= " GROUP BY t.rowid"; $sql.= $this->db->order($sortfield,$sortorder); - if ($limit) $sql.= $this->db->plimit($limit+1,$offset); + $this->num_all = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $this->db->query($sql); + $this->num_all = $this->db->num_rows($result); + } + if ($limit) $sql.= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); $resql=$this->db->query($sql); From cbcb79b1eb513ed65dbcaf0fed2347252035f290 Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 27 Nov 2015 16:58:28 +0100 Subject: [PATCH 4/4] FIX jquery select of project generate js error on change event --- htdocs/core/class/html.formprojet.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index b44a30dcd05..2b7f76dedf9 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -148,7 +148,7 @@ class FormProjets if (! empty($conf->use_javascript_ajax)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); + $comboenhancement = ajax_combobox($htmlname, array(), 0, $forcefocus); $out.=$comboenhancement; $nodatarole=($comboenhancement?' data-role="none"':''); $minmax='minwidth100 maxwidth300';