diff --git a/htdocs/compta/hrm.php b/htdocs/compta/hrm.php index 4df30c023fc..f253193b1a9 100644 --- a/htdocs/compta/hrm.php +++ b/htdocs/compta/hrm.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Laurent Destailleur + * Copyright (C) 2013-2015 Laurent Destailleur * Copyright (C) 2012-2014 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * @@ -109,15 +109,22 @@ if (! empty($conf->holiday->enabled)) { $user_id = $user->id; - $nbaquis=$holiday->getCPforUser($user_id); - $nbdeduced=$holiday->getConfCP('nbHolidayDeducted'); - $nb_holiday = $nbaquis / $nbdeduced; - print ''; print ''; print ""; print ''; print ''; print '
'.$langs->trans("Holidays").'
'; - print $langs->trans('SoldeCPUser',round($nb_holiday,2)).($nbdeduced != 1 ? ' ('.$nbaquis.' / '.$nbdeduced.')' : ''); + + $out=''; + $typeleaves=$holiday->getTypes(1,1); + foreach($typeleaves as $key => $val) + { + $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); + $nb_holiday += $nb_type; + $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; + } + print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'
'; + print $out; + print '

'; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ba1250ab131..f20acde69b7 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -866,14 +866,26 @@ class FormFile if (image_format_supported($file['name']) > 0) { $permtoedit=0; - if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoedit=1; - if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoedit=1; + $newmodulepart=$modulepart; + if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service') + { + if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoedit=1; + if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoedit=1; + $newmodulepart='produit|service'; + } + /* TODO Not yet working + if ($modulepart == 'holiday') + { + if ($user->rights->holiday->write_all) $permtoedit=1; + } + */ + if (empty($conf->global->MAIN_UPLOAD_DOC)) $permtoedit=0; if ($permtoedit) { // Link to resize - print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'   '; + print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'   '; } } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0f4f826e27d..4e1644f27b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3761,7 +3761,7 @@ function get_exdir($num,$level,$alpha,$withoutslash,$object,$modulepart) // TODO if object is null, load it from id and modulepart. - if (! empty($level) && in_array($modulepart, array('cheque','user','category','shipment', 'member','don','donation','supplier_invoice','invoice_supplier'))) + if (! empty($level) && in_array($modulepart, array('cheque','user','category','holiday','shipment', 'member','don','donation','supplier_invoice','invoice_supplier'))) { // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num); @@ -4313,17 +4313,16 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) /** * Set event message in dol_events session object. Will be output by calling dol_htmloutput_events. * Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function. + * Note: Prefer to use setEventMessages instead. * * @param mixed $mesgs Message string or array * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') * @return void * @see dol_htmloutput_events - * @deprecated Use setEventMessages instead */ function setEventMessage($mesgs, $style='mesgs') { - dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); - + //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function if (! is_array($mesgs)) // If mesgs is a string { if ($mesgs) $_SESSION['dol_events'][$style][] = $mesgs; diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index bb42f2e0760..42551601524 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -34,11 +34,16 @@ function holiday_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/holiday/card.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/holiday/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id; + $head[$h][1] = $langs->trans('Document'); + $head[$h][2] = 'documents'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 66768696320..a8d9a901b9b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1217,16 +1217,17 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu */ if ($mainmenu == 'hrm') { - // Holiday module + // Leave/Holiday/Vacation module if (! empty($conf->holiday->enabled)) { $langs->load("holiday"); - $newmenu->add("/holiday/index.php?&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->write, '', $mainmenu, 'hrm'); + $newmenu->add("/holiday/index.php?&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm'); $newmenu->add("/holiday/card.php?&action=request", $langs->trans("MenuAddCP"), 1,$user->rights->holiday->write); + $newmenu->add("/holiday/index.php?&leftmenu=hrm", $langs->trans("List"), 1,$user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->define_holiday); - $newmenu->add("/holiday/view_log.php?&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->view_log); - $newmenu->add("/holiday/month_report.php?&action=request", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->month_report); + $newmenu->add("/holiday/view_log.php?&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); + $newmenu->add("/holiday/month_report.php?&action=request", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->define_holiday); } // Trips and expenses diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index e45b40a3f57..91dde16ed08 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -134,16 +134,16 @@ class modHoliday extends DolibarrModules $r=0; $this->rights[$r][0] = 20001; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label + $this->rights[$r][1] = 'Read your own holidays'; // Permission label $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20002; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify hollidays for everybody'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; @@ -155,23 +155,23 @@ class modHoliday extends DolibarrModules $r++; $this->rights[$r][0] = 20004; // Permission id (must not be already used) - $this->rights[$r][1] = 'Setup holidays of users'; // Permission label + $this->rights[$r][1] = 'Read hollidays for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20005; // Permission id (must not be already used) - $this->rights[$r][1] = 'See logs for holidays requests'; // Permission label + $this->rights[$r][1] = 'Create/modify hollidays for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'view_log'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20006; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read holidays monthly report'; // Permission label + $this->rights[$r][1] = 'Setup holidays of users (setup and update balance)'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'month_report'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 9a3f69ac6c1..217f431b96e 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -37,7 +37,6 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $langs->load("products"); $langs->load("other"); @@ -52,12 +51,19 @@ $cancel=GETPOST("cancel"); // Security check if (empty($modulepart)) accessforbidden('Bad value for modulepart'); $accessallowed=0; -if ($modulepart=='produit|service') +if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') { $result=restrictedArea($user,'produit|service',$id,'product&product'); if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); $accessallowed=1; } +elseif ($modulepart == 'holiday') +{ + $result=restrictedArea($user,'holiday',$id,'holiday'); + if ($modulepart=='holiday' && (! $user->rights->holiday->read)) accessforbidden(); + $accessallowed=1; +} + // Security: // Limit access if permissions are wrong @@ -66,15 +72,32 @@ if (! $accessallowed) accessforbidden(); } -$object = new Product($db); -if ($id > 0) +// Define dir according to modulepart +if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') { - $result = $object->fetch($id); - if ($result <= 0) dol_print_error($db,'Failed to load object'); - $dir=$conf->product->multidir_output[$object->entity]; // By default - if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; - if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $object = new Product($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db,'Failed to load object'); + $dir=$conf->product->multidir_output[$object->entity]; // By default + if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; + if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; + } } +elseif ($modulepart == 'holiday') +{ + require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; + $object = new Holiday($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db,'Failed to load object'); + $dir=$conf->holiday->dir_output; // By default + } +} + /* * Actions diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php index 6b1bb5923bc..274a4ba27dd 100644 --- a/htdocs/holiday/admin/holiday.php +++ b/htdocs/holiday/admin/holiday.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2015 Laurent Destailleur * Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2012 Regis Houssin * diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 1a430ab84cf..befdc7ae094 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1088,6 +1088,7 @@ else print ''; print ''; } + print ''; print ''."\n"; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6e447d8cb95..a98b50bf48b 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -85,18 +85,30 @@ class Holiday extends CommonObject /** - * updateSold. Update sold and check table of users for holidays is complete. If not complete. + * Update balance of vacations and check table of users for holidays is complete. If not complete. * - * @return int Return 1 + * @return int <0 if KO, >0 if OK */ - function updateSold() + function updateBalance() { - // Mets à jour les congés payés en début de mois - $this->updateSoldeCP(); + $this->db->begin(); + + // Update sold of vocations + $result = $this->updateSoldeCP(); // Vérifie le nombre d'utilisateur et mets à jour si besoin - $this->verifNbUsers($this->countActiveUsersWithoutCP(),$this->getConfCP('nbUser')); - return 1; + if ($result > 0) $result = $this->verifNbUsers($this->countActiveUsersWithoutCP(), $this->getConfCP('nbUser')); + + if ($result >= 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } } /** @@ -901,8 +913,9 @@ class Holiday extends CommonObject // Si mise à jour pour tout le monde en début de mois $now=dol_now(); - // Mois actuel $month = date('m',$now); + + // Get month of last update $lastUpdate = $this->getConfCP('lastUpdate'); $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; //print 'month: '.$month.' '.$lastUpdate.' '.$monthLastUpdate;exit; @@ -1127,12 +1140,11 @@ class Holiday extends CommonObject } /** - * Liste la liste des utilisateurs du module congés - * uniquement pour vérifier si il existe de nouveau utilisateur + * Get list of Users or list of vacation balance. * - * @param boolean $liste si vrai retourne une liste, si faux retourne un array - * @param boolean $type si vrai retourne pour Dolibarr, si faux retourne pour CP - * @return string retourne un tableau de tout les utilisateurs actifs + * @param boolean $liste If true return a string list. If false, return an array + * @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list. + * @return array|string Return an array */ function fetchUsers($liste=true,$type=true) { @@ -1182,9 +1194,10 @@ class Holiday extends CommonObject } else - { // Si utilisateur du module Congés Payés - $sql = "SELECT u.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as u"; + { + // Si utilisateur du module Congés Payés + $sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holidays, u.lastname, u.firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu"; dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); $resql=$this->db->query($sql); @@ -1224,7 +1237,7 @@ class Holiday extends CommonObject else { // Si faux donc user Congés Payés - // Si c'est pour les utilisateurs de Dolibarr + // List for Dolibarr users if ($type) { $sql = "SELECT u.rowid, u.lastname, u.firstname"; @@ -1248,7 +1261,10 @@ class Holiday extends CommonObject $tab_result[$i]['rowid'] = $obj->rowid; $tab_result[$i]['name'] = $obj->lastname; + $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; + $tab_result[$i]['type'] = $obj->type; + $tab_result[$i]['nb_holidays'] = $obj->nb_holidays; $i++; } @@ -1261,13 +1277,11 @@ class Holiday extends CommonObject $this->error="Error ".$this->db->lasterror(); return -1; } - - // Si c'est pour les utilisateurs du module Congés Payés } else { - - $sql = "SELECT DISTINCT cpu.fk_user, u.lastname, u.firstname"; + // List of vacation balance users + $sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holidays, u.lastname, u.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE cpu.fk_user = u.rowid"; @@ -1283,13 +1297,16 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // Boucles du listage des utilisateurs - while($i < $num) { - + while($i < $num) + { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->fk_user; $tab_result[$i]['name'] = $obj->lastname; + $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; + $tab_result[$i]['type'] = $obj->type; + $tab_result[$i]['nb_holidays'] = $obj->nb_holidays; $i++; } @@ -1344,9 +1361,9 @@ class Holiday extends CommonObject * * @param int $userDolibarrWithoutCP Number of active users in Dolibarr without holidays * @param int $userCP Number of active users into table of holidays - * @return void + * @return int <0 if KO, >0 if OK */ - function verifNbUsers($userDolibarrWithoutCP,$userCP) + function verifNbUsers($userDolibarrWithoutCP, $userCP) { if (empty($userCP)) $userCP=0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); @@ -1437,6 +1454,7 @@ class Holiday extends CommonObject } } + return 1; } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 4aae0ab7f7d..d2cde8de5a0 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -39,6 +39,8 @@ $action=GETPOST('action'); $holiday = new Holiday($db); +$langs->load('users'); + /* * Actions @@ -100,7 +102,7 @@ if ($action == 'update' && isset($_POST['update_cp'])) } } - if (! $error) setEventMessage($langs->trans('UpdateConfCPOK')); + if (! $error) setEventMessages($langs->trans('UpdateConfCPOK'), '', 'mesgs'); } elseif($action == 'add_event') { @@ -120,7 +122,7 @@ elseif($action == 'add_event') if ($error) { - setEventMessage($langs->trans('ErrorAddEventToUserCP'), 'errors'); + setEventMessages($langs->trans('ErrorAddEventToUserCP'), '', 'errors'); } else { @@ -133,7 +135,7 @@ elseif($action == 'add_event') $holiday->updateSoldeCP($userCP,$new_holiday); - setEventMessage($langs->trans('AddEventToUserOkCP')); + setEventMessages($langs->trans('AddEventToUserOkCP'), '', 'mesgs'); } } @@ -145,13 +147,20 @@ elseif($action == 'add_event') $form = new Form($db); $userstatic=new User($db); -$langs->load('users'); - llxHeader(array(),$langs->trans('CPTitreMenu')); print_fiche_titre($langs->trans('MenuConfCP'), '', 'title_hrm.png'); -$holiday->updateSold(); // Create users into table holiday if they don't exists. TODO Remove if we use field into table user. +print '
'.$langs->trans('LastUpdateCP').': '."\n"; +if ($cp->getConfCP('lastUpdate')) print ''.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')),'dayhour','tzuser').''; +else print $langs->trans('None'); +print "

\n"; + +$result = $holiday->updateBalance(); // Create users into table holiday if they don't exists. TODO Remove this whif we use field into table user. +if ($result < 0) +{ + setEventMessages($holiday->error, $holiday->errors, 'errors'); +} $listUsers = $holiday->fetchUsers(false,true); diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php new file mode 100644 index 00000000000..63d07cebddf --- /dev/null +++ b/htdocs/holiday/document.php @@ -0,0 +1,236 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador + * + * 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 . + */ + +/** + * \file htdocs/holiday/document.php + * \ingroup fichinter + * \brief Page des documents joints sur les contrats + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +$langs->load("other"); +$langs->load("holidays"); +$langs->load("companies"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'holiday', $id, 'holiday'); + + +// Get parameters +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + + +$object = new Holiday($db); +$object->fetch($id, $ref); + +$upload_dir = $conf->holiday->dir_output.'/'.get_exdir($object->id, 0, 0, 0, $object, 'holiday').dol_sanitizeFileName($object->ref); +$modulepart='holiday'; + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; + + +/* + * View + */ + +$form = new Form($db); + +$listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); + +llxHeader("","",$langs->trans("InterventionCard")); + + +if ($object->id) +{ + $valideur = new User($db); + $valideur->fetch($object->fk_validator); + + $userRequest = new User($db); + $userRequest->fetch($object->fk_user); + + $head=holiday_prepare_head($object); + + dol_fiche_head($head, 'documents',$langs->trans("CPTitreMenu"),0,'holiday'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + $linkback=''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + + // Type + print ''; + print ''; + print ''; + print ''; + + $starthalfday=($object->halfday == -1 || $object->halfday == 2)?'afternoon':'morning'; + $endhalfday=($object->halfday == 1 || $object->halfday == 2)?'morning':'afternoon'; + + if(!$edit) + { + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + print ''; + } + + if (!$edit) + { + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + print ''; + } + print ''; + print ''; + print ''; + print ''; + + // Status + print ''; + print ''; + print ''; + print ''; + if ($object->statut == 5) + { + print ''; + print ''; + print ''; + print ''; + } + + // Description + if (!$edit) + { + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + print ''; + } + + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref'); + print '
'.$langs->trans("User").''; + print $userRequest->getNomUrl(1); + print '
'.$langs->trans("Type").''; + $typeleaves=$object->getTypes(1,1); + print $typeleaves[$object->fk_type]['label']; + print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'.dol_print_date($object->date_debut,'day'); + print '     '; + print $langs->trans($listhalfday[$starthalfday]); + print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + $form->select_date($object->date_debut,'date_debut_'); + print '     '; + print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):$starthalfday)); + print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'.dol_print_date($object->date_fin,'day'); + print '     '; + print $langs->trans($listhalfday[$endhalfday]); + print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + $form->select_date($object->date_fin,'date_fin_'); + print '     '; + print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):$endhalfday)); + print '
'.$langs->trans('NbUseDaysCP').''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'
'.$langs->trans('StatutCP').''.$object->getLibStatut(2).'
'.$langs->trans('DetailRefusCP').''.$object->detail_refuse.'
'.$langs->trans('DescCP').''.nl2br($object->description).'
'.$langs->trans('DescCP').'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + dol_fiche_end(); + + $modulepart = 'holiday'; + $permission = $user->rights->holiday->write; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + print $langs->trans("ErrorUnknown"); +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index cd8e0daaced..8e2e04019ce 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin +/* Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin * * 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 @@ -96,7 +96,7 @@ $holidaystatic=new Holiday($db); $fuser = new User($db); // Update sold -$holiday->updateSold(); +$result = $holiday->updateBalance(); $max_year = 5; $min_year = 10; @@ -187,7 +187,7 @@ if ($id > 0) $user_id = $fuser->id; } // Récupération des congés payés de l'utilisateur ou de tous les users -if (!$user->rights->holiday->write_all || $id > 0) +if (empty($user->rights->holiday->write_all) || $id > 0) { $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); // Load array $holiday->holiday } @@ -292,13 +292,18 @@ $formother->select_year($year_create,'year_create',1, $min_year, 0); print ''; // UTILISATEUR -if($user->rights->holiday->write_all) +if ($user->rights->holiday->write_all) { print ''; print $form->select_dolusers($search_employe,"search_employe",1,"",0,'','',0,32); print ''; -} else { - print ' '; +} +else +{ + //print ' '; + print ''; + print $form->select_dolusers($user->id,"search_employe",1,"",1,'','',0,32); + print ''; } // VALIDEUR diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 2d0df2b692d..caf04e90bd1 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2015 Laurent Destailleur * Copyright (C) 2011 François Legastelois * * This program is free software; you can redistribute it and/or modify @@ -34,7 +34,7 @@ if ($user->societe_id > 0) accessforbidden(); // Si l'utilisateur n'a pas le droit de lire cette page -if(!$user->rights->holiday->month_report) accessforbidden(); +if(!$user->rights->holiday->read_all) accessforbidden(); @@ -73,18 +73,24 @@ $num = $db->num_rows($result); print_fiche_titre($langs->trans('MenuReportMonth'), '', 'title_hrm.png'); -print '
'; +// Get month of last update +$lastUpdate = $cp->getConfCP('lastUpdate', 0); +$monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; +$yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3]; +print $langs->trans("MonthOfLastMonthlyUpdate").': '.$yearLastUpdate.'-'.$monthLastUpdate.'

'."\n"; + print '
'."\n"; +dol_fiche_head(); + print $langs->trans('Month').': '; print $htmlother->select_month($month, 'month_start').' '; print $htmlother->select_year($year,'year_start',1,10,3); print ''; -print '
'; - +print '
'; print '
'; $var=true; @@ -137,7 +143,11 @@ if($num == '0') { } } print ''; -print '
'; + +dol_fiche_end(); + +print ''; + // Fin de page llxFooter(); diff --git a/htdocs/holiday/tomergewithdefine_holiday.php b/htdocs/holiday/tomergewithdefine_holiday.php deleted file mode 100644 index 707783712a5..00000000000 --- a/htdocs/holiday/tomergewithdefine_holiday.php +++ /dev/null @@ -1,124 +0,0 @@ - - * Copyright (C) 2011 Dimitri Mouillard - * - * 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 . - */ - -/** - * \file define_congespayes.php - * \ingroup congespayes - * \brief File that defines the balance of paid leave of users. - * \version $Id: define_congespayes.php,v 1.00 2011/09/15 11:00:00 dmouillard Exp $ - * \author dmouillard@teclib.com - * \remarks File that defines the balance of paid leave of users. - */ - -require('../main.inc.php'); -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; - -// 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->define_holiday) accessforbidden(); - - -/* - * View - */ - -llxHeader(array(),$langs->trans('CPTitreMenu')); - - -print_fiche_titre($langs->trans('MenuConfCP')); - -$congespayes = new Holiday($db); -$listUsers = $congespayes->fetchUsers(false, true); - -// Si il y a une action de mise à jour -if (isset($_POST['action']) && $_POST['action'] == 'update') { - - $fk_type = $_POST['fk_type']; - - foreach ($_POST['nb_conges'] as $user_id => $compteur) { - if (!empty($compteur)) { - $userValue = str_replace(',', '.', $compteur); - $userValue = number_format($userValue, 2, '.', ''); - } else { - $userValue = '0.00'; - } - $congespayes->updateSoldeCP($user_id,$userValue,$fk_type); - } - - print '
'; - print $langs->trans('UpdateConfCPOK'); - print '
'; - -} - -$var = true; -$i = 0; - -foreach($congespayes->getTypes() as $type) -{ - if($type['affect']==1) - { - print '
'; - - print '

'.$type['label'].'

'; - - print '
' . "\n"; - print ''; - print ''; - - print ''; - print ""; - print ''; - print ''; - print ''; - - foreach ($listUsers as $users) { - $var = !$var; - print ''; - print ''; - print '' . "\n"; - print ''; - - $i++; - } - - echo ""; - print ''; - echo ""; - - print '
' . $langs->trans('Employee') . '' . $langs->trans('Counter') . '
' . $users['name'] . ' ' . $users['firstname'] . ''; - print ''; - print ' jours
'; - print '
'; - - print '
'; - } -} - -// Fin de page -$db->close(); -llxFooter(); diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 6ccd9f38665..766478ed9de 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if ($user->societe_id > 0) accessforbidden(); // Si l'utilisateur n'a pas le droit de lire cette page -if(!$user->rights->holiday->view_log) accessforbidden(); +if(!$user->rights->holiday->read_all) accessforbidden(); $year=GETPOST('year'); if (empty($year)) @@ -41,22 +41,27 @@ if (empty($year)) $year=$tmpdate['year']; } +$langs->load('users'); + /* * View */ -$langs->load('users'); +$cp = new Holiday($db); llxHeader(array(),$langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')'); - -$cp = new Holiday($db); // Recent changes are more important than old changes $log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year,1,1))."' AND '".$db->idate(dol_get_last_day($year,12,1))."'"); // Load $cp->logs print load_fiche_titre($langs->trans('LogCP'), '', 'title_hrm.png'); +print '
'.$langs->trans('LastUpdateCP').': '."\n"; +if ($cp->getConfCP('lastUpdate')) print ''.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')),'dayhour','tzuser').''; +else print $langs->trans('None'); +print "

\n"; + print ''; print ''; print ''; @@ -107,6 +112,6 @@ print ''."\n"; print '
'."\n"; -// Fin de page -$db->close(); llxFooter(); + +$db->close(); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 6f14791f6b4..7b5f299d758 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -364,7 +364,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) { migrate_event_assignement($db,$langs,$conf); } - + // Scripts for lat version $afterversionarray=explode('.','3.7.9'); $beforeversionarray=explode('.','3.8.9'); @@ -381,6 +381,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) 'MAIN_MODULE_ECM', 'MAIN_MODULE_FACTURE', 'MAIN_MODULE_FOURNISSEUR', + 'MAIN_MODULE_HOLIDAY', 'MAIN_MODULE_OPENSURVEY', 'MAIN_MODULE_PAYBOX', 'MAIN_MODULE_PRODUIT', @@ -3824,7 +3825,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array()) if ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Service"); - + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; if ($res) { $mod=new modService($db); @@ -3835,7 +3836,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array()) if ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Commande"); - + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; if ($res) { $mod=new modCommande($db); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index f9d9f047411..bb337c6c67e 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -3,7 +3,7 @@ HRM=HRM Holidays=Leaves CPTitreMenu=Leaves MenuReportMonth=Monthly statement -MenuAddCP=Make a leave request +MenuAddCP=New leave request NotActiveModCP=You must enable the module Leaves to view this page. NotConfigModCP=You must configure the module Leaves to view this page. To do this, click here . NoCPforUser=You don't have any available day. @@ -93,6 +93,7 @@ ValueOptionCP=Value GroupToValidateCP=Group with the ability to approve leave requests ConfirmConfigCP=Validate the configuration LastUpdateCP=Last automatic update of leaves allocation +MonthOfLastMonthlyUpdate=Month of last automatic update of leaves allocation UpdateConfCPOK=Updated successfully. ErrorUpdateConfCP=An error occurred during the update, please try again. AddCPforUsers=Please add the balance of leaves allocation of users by clicking here. @@ -140,12 +141,11 @@ HolidaysRefused=Request denied HolidaysRefusedBody=Your leave request for %s to %s has been denied for the following reason : HolidaysCanceled=Canceled leaved request HolidaysCanceledBody=Your leave request for %s to %s has been canceled. -Permission20000=Read you own leave requests -Permission20001=Create/modify your leave requests -Permission20002=Create/modify leave requests for everybody +Permission20001=Read you own leave requests +Permission20002=Create/modify your leave requests Permission20003=Delete leave requests -Permission20004=Setup users available vacation days -Permission20005=Review log of modified leave requests -Permission20006=Read leaves monthly report +Permission20004=Read leave requests for everybody +Permission20005=Create/modify leave requests for everybody +Permission20006=Admin leave requests (setup and update balance) NewByMonth=Added per month GoIntoDictionaryHolidayTypes=Go into Home - Setup - Dictionaries - Type of leaves to setup the different types of leaves. \ No newline at end of file diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index 30595470a20..3456312aa55 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -139,10 +139,3 @@ HolidaysRefused=Accès refusé HolidaysRefusedBody=Votre demande de congés payés %s à %s vient d'être refusée pour le motif suivant : HolidaysCanceled=Abandonner la demande de congés HolidaysCanceledBody=Votre demande de congés du %s au %s a été annulée. -Permission20000=Lire ses propres demandes de congés -Permission20001=Créer/modifier une demande de congés -Permission20002=Créer/modifier les congés pour tout le monde -Permission20003=Supprimer la demande de Congés -Permission20004=Configuration des jours disponibles -Permission20005=Voir l'historique des demandes de congés -Permission20006=Accéder au rapport mensuel des congés diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 35d1b1080fb..cb174e5847e 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -87,10 +87,10 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { //Delete line if product propal merge is linked to a file - if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { + if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) + { if ($action == 'confirm_deletefile' && $confirm == 'yes') { - print 'toto'; //extract file name $urlfile = GETPOST('urlfile', 'alpha'); $filename = basename($urlfile); @@ -109,7 +109,8 @@ if (empty($reshook)) } -if ($action=='filemerge') { +if ($action=='filemerge') +{ $is_refresh = GETPOST('refresh'); if (empty($is_refresh)) {