diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 10589c9d0b4..1a71889ec1f 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1286,7 +1286,7 @@ class Holiday extends CommonObject /** * Get list of Users or list of vacation balance. * - * @param boolean $stringlist If true return a string list of id. If false, return an array + * @param boolean $stringlist If true return a string list of id. If false, return an array with detail. * @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 @@ -1297,7 +1297,6 @@ class Holiday extends CommonObject dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); - // Si vrai donc pour user Dolibarr if ($stringlist) { if ($type) @@ -1356,7 +1355,7 @@ class Holiday extends CommonObject } else { - // We want only list of user id + // We want only list of vacation balance for user ids $sql = "SELECT DISTINCT cpu.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE cpu.fk_user = u.user"; @@ -1397,12 +1396,12 @@ class Holiday extends CommonObject } else - { // Si faux donc user Congés Payés + { // Si faux donc return array // List for Dolibarr users if ($type) { - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut"; + $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) @@ -1440,6 +1439,7 @@ class Holiday extends CommonObject $tab_result[$i]['status'] = $obj->statut; $tab_result[$i]['employee'] = $obj->employee; $tab_result[$i]['photo'] = $obj->photo; + $tab_result[$i]['fk_user'] = $obj->fk_user; //$tab_result[$i]['type'] = $obj->type; //$tab_result[$i]['nb_holiday'] = $obj->nb_holiday; @@ -1458,7 +1458,7 @@ 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 = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $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; @@ -1478,9 +1478,15 @@ class Holiday extends CommonObject $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->fk_user; - $tab_result[$i]['name'] = $obj->lastname; + $tab_result[$i]['name'] = $obj->lastname; // deprecated $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; + $tab_result[$i]['gender'] = $obj->gender; + $tab_result[$i]['status'] = $obj->statut; + $tab_result[$i]['employee'] = $obj->employee; + $tab_result[$i]['photo'] = $obj->photo; + $tab_result[$i]['fk_user'] = $obj->fk_user; + $tab_result[$i]['type'] = $obj->type; $tab_result[$i]['nb_holiday'] = $obj->nb_holiday; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index de8a7147267..58816d82ff8 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -36,6 +36,7 @@ $langs->load('hrm'); $action=GETPOST('action','aZ09'); $search_name=GETPOST('search_name', 'alpha'); +$search_supervisor=GETPOST('search_supervisor', 'int'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; @@ -87,6 +88,7 @@ if (empty($reshook)) 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_name=''; + $search_supervisor=''; $toselect=''; $search_array_options=array(); } @@ -202,9 +204,11 @@ if ($result < 0) setEventMessages($holiday->error, $holiday->errors, 'errors'); } -$filters=natural_search(array('u.firstname','u.lastname'), $search_name); +$filters=''; +$filters.=natural_search(array('u.firstname','u.lastname'), $search_name); +if ($search_supervisor > 0) $filters.=natural_search(array('u.fk_user'), $search_supervisor, 2); -$listUsers = $holiday->fetchUsers(false,true,$filters); +$listUsers = $holiday->fetchUsers(false, true, $filters); if (is_numeric($listUsers) && $listUsers < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); @@ -242,7 +246,16 @@ else print '
| '; + + // Supervisor + print ' | '; + print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, null, null, 0, 0, 0, '', 0, '', 'maxwidth200'); + print ' | '; + + // Type of leave request if (count($typeleaves)) { foreach($typeleaves as $key => $val) @@ -266,23 +279,23 @@ else print '||||
| '.$val['label'].' | '; + print_liste_field_titre($val['label'], $_SERVER["PHP_SELF"], '', '', '', 'align="center"'); } } else { - print ''.$langs->trans("NoLeaveWithCounterDefined").' | '; + print_liste_field_titre($langs->trans("NoLeaveWithCounterDefined"), $_SERVER["PHP_SELF"], '', '', '', ''); } - print ''; - if ($canedit) print $langs->trans('Note'); - print ' | '; + print_liste_field_titre($langs->trans('Note'), $_SERVER["PHP_SELF"]); print_liste_field_titre(''); print '|||
|---|---|---|---|---|---|
| '; $userstatic->id=$users['rowid']; $userstatic->lastname=$users['lastname']; $userstatic->firstname=$users['firstname']; @@ -303,9 +312,22 @@ else $userstatic->photo=$users['photo']; $userstatic->statut=$users['status']; $userstatic->employee=$users['employee']; + $userstatic->fk_user=$users['fk_user']; + + if ($userstatic->fk_user > 0) $usersupervisor->fetch($userstatic->fk_user); + + print ' | |||||
| '; print $userstatic->getNomUrl(-1); print ' | '; + // Supervisor + print ''; + if ($userstatic->fk_user > 0) print $usersupervisor->getNomUrl(-1); + print ' | '; + // Amount for each type if (count($typeleaves)) { @@ -313,6 +335,8 @@ else { $nbtoshow=''; if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5); + + //var_dump($users['rowid'].' - '.$val['rowid']); print ''; if ($canedit) print ''; else print $nbtoshow; @@ -326,7 +350,7 @@ else } // Note - print ' | '; + print ' | '; if ($canedit) print ''; print ' | '; print '';
diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
index f3f0f143ec8..d2845969bb0 100644
--- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
+++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
@@ -41,6 +41,10 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
-- For 7.0
+-- VMYSQL4.1 ALTER TABLE llx_holiday_users DROP PRIMARY KEY;
+
+ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type, nb_holiday);
+
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_tx double(6,3) DEFAULT 0;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0';
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_tx double(6,3) DEFAULT 0;
diff --git a/htdocs/install/mysql/tables/llx_holiday_users.key.sql b/htdocs/install/mysql/tables/llx_holiday_users.key.sql
new file mode 100644
index 00000000000..e03dd6ebfcb
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_holiday_users.key.sql
@@ -0,0 +1,19 @@
+-- ===================================================================
+-- Copyright (C) 2017 Laurent Destailleur |