From c8856182a6fa51a8c34e728e522ea0a735b968fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jun 2017 15:34:18 +0200 Subject: [PATCH] Fix look and feel v6 --- htdocs/core/lib/files.lib.php | 6 + htdocs/core/lib/functions.lib.php | 13 +- htdocs/holiday/card.php | 34 ++-- htdocs/holiday/class/holiday.class.php | 24 ++- htdocs/holiday/define_holiday.php | 247 ++++++++++++++++--------- 5 files changed, 204 insertions(+), 120 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 60b970fffce..21fb1be7c0d 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1891,6 +1891,12 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file; } + // Wrapping pour les apercu supplier invoice + elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) + { + if ($fuser->rights->expensereport->{$lire}) $accessallowed=1; + $original_file=$conf->expensereport->dir_output.'/'.$original_file; + } // Wrapping pour les images des stats propales elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bc18f0984de..54f02c5feea 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1155,14 +1155,15 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (class_exists("Imagick")) { - if ($object->element == 'propal') $modulepart='propal'; - if ($object->element == 'commande') $modulepart='commande'; - if ($object->element == 'facture') $modulepart='facture'; - if ($object->element == 'fichinter') $modulepart='ficheinter'; - if ($object->element == 'contrat') $modulepart='contract'; + if ($object->element == 'propal') $modulepart='propal'; + if ($object->element == 'commande') $modulepart='commande'; + if ($object->element == 'facture') $modulepart='facture'; + if ($object->element == 'fichinter') $modulepart='ficheinter'; + if ($object->element == 'contrat') $modulepart='contract'; if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal'; if ($object->element == 'order_supplier') $modulepart='supplier_order'; if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice'; + if ($object->element == 'expensereport') $modulepart='expensereport'; } if ($object->element == 'product') @@ -1192,7 +1193,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { $phototoshow=''; // Check if a preview file is available - if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice')) && class_exists("Imagick")) + if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) { $objectref = dol_sanitizeFileName($object->ref); $dir_output = $conf->$modulepart->dir_output . "/"; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 6e31f1868c7..531f42fd47f 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -576,27 +576,27 @@ if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') { $object = new Holiday($db); $object->fetch($id); - + $oldstatus = $object->statut; $object->statut = 1; - + $result = $object->update($user); if ($result < 0) { $error = $langs->trans('ErrorBackToDraft'); } - + if (! $error) { $db->commit(); - + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $db->rollback(); - } + } } // Si Validation de la demande @@ -1029,7 +1029,7 @@ else { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1); } - + $head=holiday_prepare_head($object); @@ -1041,17 +1041,17 @@ else print ''."\n"; } - dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday'); + dol_fiche_head($head, 'card', $langs->trans("CPTitreMenu"), -1, 'holiday'); $linkback=''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref'); - - + + print '
'; print '
'; print '
'; - + print ''; print ''; @@ -1153,9 +1153,9 @@ else print ''; print '
'; print '
'; - + print '
'; - + // Info workflow print '
'."\n"; print ''; @@ -1212,12 +1212,12 @@ else print ''; print ''; print ''; - + print '
'; - + dol_fiche_end(); - + if ($action == 'edit' && $object->statut == 1) { print '
'; @@ -1273,7 +1273,7 @@ else { print ''.$langs->trans("SetToDraft").''; } - + print '
'; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 15a565b04f9..9973223ba0f 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1195,12 +1195,15 @@ class Holiday extends CommonObject * * @param boolean $stringlist If true return a string list of id. If false, return an array * @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list. + * @param string $filters Filters * @return array|string|int Return an array */ - function fetchUsers($stringlist=true,$type=true) + function fetchUsers($stringlist=true, $type=true, $filters='') { global $conf; + dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); + // Si vrai donc pour user Dolibarr if ($stringlist) { @@ -1219,11 +1222,12 @@ class Holiday extends CommonObject $sql.= " OR u.admin = 1"; } else + { $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; - + } $sql.= " AND u.statut > 0"; + if ($filters) $sql.=$filters; - dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); $resql=$this->db->query($sql); // Si pas d'erreur SQL @@ -1261,9 +1265,10 @@ class Holiday extends CommonObject { // We want only list of user id $sql = "SELECT DISTINCT cpu.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE cpu.fk_user = u.user"; + if ($filters) $sql.=$filters; - dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); $resql=$this->db->query($sql); // Si pas d'erreur SQL @@ -1318,8 +1323,8 @@ class Holiday extends CommonObject $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; $sql.= " AND u.statut > 0"; + if ($filters) $sql.=$filters; - dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); $resql=$this->db->query($sql); // Si pas d'erreur SQL @@ -1358,14 +1363,13 @@ class Holiday extends CommonObject } } else - { + { // List of vacation balance users $sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu,"; - $sql.= " ".MAIN_DB_PREFIX."user as u"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE cpu.fk_user = u.rowid"; + if ($filters) $sql.=$filters; - dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); $resql=$this->db->query($sql); // Si pas d'erreur SQL diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index e1b8b21a7bd..88f3438dcaf 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -30,81 +30,135 @@ require('../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +$langs->load('users'); +$langs->load('hrm'); + +$action=GETPOST('action','aZ09'); + +$search_name=GETPOST('search_name', 'alpha'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$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(); // If the user does not have perm to read the page if(!$user->rights->holiday->read) accessforbidden(); -$action=GETPOST('action','aZ09'); + +// Initialize technical object to manage context to save list fields +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'defineholidaylist'; + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('defineholidaylist')); +$extrafields = new ExtraFields($db); $holiday = new Holiday($db); -$langs->load('users'); -$langs->load('hrm'); - /* * Actions */ -// Si il y a une action de mise à jour -if ($action == 'update' && isset($_POST['update_cp'])) +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)) { - $error = 0; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - $typeleaves=$holiday->getTypes(1,1); - - $userID = array_keys($_POST['update_cp']); - $userID = $userID[0]; - - foreach($typeleaves as $key => $val) + // 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 { - $userValue = $_POST['nb_holiday_'.$val['rowid']]; - $userValue = $userValue[$userID]; - - if (!empty($userValue)) - { - $userValue = price2num($userValue,5); - } else { - $userValue = ''; - } - - //If the user set a comment, we add it to the log comment - $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : ''); - - //print 'eee'.$val['rowid'].'-'.$userValue; - if ($userValue != '') - { - // We add the modification to the log (must be before update of sold because we read current value of sold) - $result=$holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']); - if ($result < 0) - { - setEventMessages($holiday->error, $holiday->errors, 'errors'); - $error++; - } - - // Update of the days of the employee - $result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']); - if ($result < 0) - { - setEventMessages($holiday->error, $holiday->errors, 'errors'); - $error++; - } - - // If it first update of balance, we set date to avoid to have sold incremented by new month - /* - $now=dol_now(); - $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; - $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. - dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG); - $result = $db->query($sql); - */ - } + $search_name=''; + $toselect=''; + $search_array_options=array(); } - if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs'); + // 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'; + */ + + // Si il y a une action de mise à jour + if ($action == 'update' && isset($_POST['update_cp'])) + { + $error = 0; + + $typeleaves=$holiday->getTypes(1,1); + + $userID = array_keys($_POST['update_cp']); + $userID = $userID[0]; + + foreach($typeleaves as $key => $val) + { + $userValue = $_POST['nb_holiday_'.$val['rowid']]; + $userValue = $userValue[$userID]; + + if (!empty($userValue)) + { + $userValue = price2num($userValue,5); + } else { + $userValue = ''; + } + + //If the user set a comment, we add it to the log comment + $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : ''); + + //print 'eee'.$val['rowid'].'-'.$userValue; + if ($userValue != '') + { + // We add the modification to the log (must be before update of sold because we read current value of sold) + $result=$holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']); + if ($result < 0) + { + setEventMessages($holiday->error, $holiday->errors, 'errors'); + $error++; + } + + // Update of the days of the employee + $result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']); + if ($result < 0) + { + setEventMessages($holiday->error, $holiday->errors, 'errors'); + $error++; + } + + // If it first update of balance, we set date to avoid to have sold incremented by new month + /* + $now=dol_now(); + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; + $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; + $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. + dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG); + $result = $db->query($sql); + */ + } + } + + if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs'); + } } @@ -117,6 +171,17 @@ $userstatic=new User($db); llxHeader('', $langs->trans('CPTitreMenu')); + +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + print load_fiche_titre($langs->trans('MenuConfCP'), '', 'title_hrm.png'); print '
'.$langs->trans('LastUpdateCP').': '."\n"; @@ -137,10 +202,12 @@ if ($result < 0) setEventMessages($holiday->error, $holiday->errors, 'errors'); } -$listUsers = $holiday->fetchUsers(false,true); +$filters=natural_search(array('u.firstname','u.lastname'), $search_name); + +$listUsers = $holiday->fetchUsers(false,true,$filters); if (is_numeric($listUsers) && $listUsers < 0) { - setEventMessages($holiday->error, $holiday->errors, 'errors'); + setEventMessages($holiday->error, $holiday->errors, 'errors'); } $var=true; @@ -159,22 +226,44 @@ else { $canedit=0; if (! empty($user->rights->holiday->define_holiday)) $canedit=1; - + // Get array of ids of all childs $userchilds=array(); if (empty($user->rights->holiday->read_all)) { $userchilds=$user->getAllChildIds(); } - - print ''."\n"; + print ''; $moreforfilter=''; - + print '
'; print '
'."\n"; - + + print ''; + print ''; + if (count($typeleaves)) + { + foreach($typeleaves as $key => $val) + { + print ''; + } + } + else + { + print ''; + } + print ''; + + // Action column + print ''; + + print ''; + print ''; print_liste_field_titre($langs->trans('Employee'), $_SERVER["PHP_SELF"]); if (count($typeleaves)) @@ -193,35 +282,18 @@ else print ''; print_liste_field_titre(''); print ''; - print ''; - print ''; - if (count($typeleaves)) - { - foreach($typeleaves as $key => $val) - { - print ''; - } - } - else - { - print ''; - } - print ''; - print ''; - print ''; - + + foreach($listUsers as $users) { - - // If user has not permission to edit/read all, we must see only subordinates - if (empty($user->rights->holiday->read_all)) + if (empty($user->rights->holiday->read_all)) { if (($users['rowid'] != $user->id) && (! in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it. } - + print ''; - + // User print ''; } - + // Note print '
'; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'; $userstatic->id=$users['rowid']; @@ -252,7 +324,7 @@ else { print ''; if ($canedit) print ''; @@ -270,9 +342,10 @@ else print '
'; print '
'; - print ''; } +print ''; + llxFooter(); $db->close();