diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index bac9c99a013..d13f43a6ed5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -70,7 +70,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,10,23,12,13,0,14,0,7,17,24,0,22,20,18,21,0,15,0,25,0,26); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,0,25,0,26); // Name of SQL tables of dictionaries $tabname=array(); @@ -101,6 +101,7 @@ $tabname[24]= MAIN_DB_PREFIX."c_type_resource"; $tabname[25]= MAIN_DB_PREFIX."c_email_templates"; $tabname[26]= MAIN_DB_PREFIX."c_units"; $tabname[27]= MAIN_DB_PREFIX."c_stcomm"; +$tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; // Dictionary labels $tablib=array(); @@ -131,22 +132,23 @@ $tablib[24]= "DictionaryResourceType"; $tablib[25]= "DictionaryEMailTemplates"; $tablib[26]= "DictionaryUnits"; $tablib[27]= "DictionaryProspectStatus"; +$tablib[28]= "DictionaryHolidayTypes"; // Requests to extract data $tabsql=array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; -$tabsql[4] = "SELECT rowid as rowid, code, label, active, favorite FROM ".MAIN_DB_PREFIX."c_country"; +$tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite FROM ".MAIN_DB_PREFIX."c_country AS c"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid"; -$tabsql[9] = "SELECT code_iso as code, label, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies"; +$tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; $tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; -$tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c'; -$tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active, accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement AS c"; +$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c'; +$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement AS c"; $tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; $tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; $tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; @@ -161,6 +163,7 @@ $tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX $tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content, active FROM ".MAIN_DB_PREFIX."c_email_templates"; $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; +$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.delay, h.newByMonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -191,6 +194,7 @@ $tabsqlsort[24]="code ASC,label ASC"; $tabsqlsort[25]="label ASC"; $tabsqlsort[26]="code ASC"; $tabsqlsort[27]="code ASC"; +$tabsqlsort[28]="country ASC, code ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); @@ -221,6 +225,7 @@ $tabfield[24]= "code,label"; $tabfield[25]= "label,type_template,private,position,topic,content"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; +$tabfield[28]= "code,label,delay,newByMonth,country_id,country"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); @@ -251,6 +256,7 @@ $tabfieldvalue[24]= "code,label"; $tabfieldvalue[25]= "label,type_template,private,position,topic,content"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; +$tabfieldvalue[28]= "code,label,delay,newByMonth,country"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); @@ -281,6 +287,7 @@ $tabfieldinsert[24]= "code,label"; $tabfieldinsert[25]= "label,type_template,private,position,topic,content"; $tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27]= "code,libelle"; +$tabfieldinsert[28]= "code,label,delay,newByMonth,fk_country"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on @@ -313,6 +320,7 @@ $tabrowid[24]= ""; $tabrowid[25]= ""; $tabrowid[26]= ""; $tabrowid[27]= "id"; +$tabrowid[28]= ""; // Condition to show dictionary in setup page $tabcond=array(); @@ -343,6 +351,7 @@ $tabcond[24]= ! empty($conf->resource->enabled); $tabcond[25]= true; // && ! empty($conf->global->MAIN_EMAIL_EDIT_TEMPLATE_FROM_DIC); $tabcond[26]= ! empty($conf->product->enabled); $tabcond[27]= ! empty($conf->societe->enabled); +$tabcond[28]= ! empty($conf->holiday->enabled); // List of help for fields $tabhelp=array(); @@ -373,6 +382,7 @@ $tabhelp[24] = array(); $tabhelp[25] = array(); $tabhelp[26] = array(); $tabhelp[27] = array(); +$tabhelp[28] = array(); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); @@ -403,6 +413,7 @@ $tabfieldcheck[24] = array(); $tabfieldcheck[25] = array(); $tabfieldcheck[26] = array(); $tabfieldcheck[27] = array(); +$tabfieldcheck[28] = array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); @@ -475,7 +486,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=1; foreach ($listfield as $f => $value) { - if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType'))) continue; // For some pages, country is not mandatory + if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes'))) continue; // For some pages, country is not mandatory if ($value == 'country' && in_array($tablib[$id],array('DictionaryCanton','DictionaryCompanyType'))) continue; // For some pages, country is not mandatory if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; @@ -524,7 +535,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) { - if (in_array($tablib[$id],array('DictionaryCompanyType'))) + if (in_array($tablib[$id],array('DictionaryCompanyType','DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries { $_POST["country"]=''; } diff --git a/htdocs/compta/hrm.php b/htdocs/compta/hrm.php index 59389f41d51..4df30c023fc 100644 --- a/htdocs/compta/hrm.php +++ b/htdocs/compta/hrm.php @@ -67,7 +67,7 @@ $childids[]=$user->id; llxHeader(array(),$langs->trans('HRMArea')); -print_fiche_titre($langs->trans("HRMArea")); +print_fiche_titre($langs->trans("HRMArea"),'', 'title_hrm.png'); print '
'; diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php index 1986ae1cdf7..6b1bb5923bc 100644 --- a/htdocs/holiday/admin/holiday.php +++ b/htdocs/holiday/admin/holiday.php @@ -52,7 +52,7 @@ if (empty($conf->holiday->enabled)) print $langs->trans('NotActiveModCP'); llxheader('',$langs->trans('TitleAdminCP')); $linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans('ConfCP'), $linkback); +print_fiche_titre($langs->trans('ConfCP'), $linkback, 'title_hrm.png'); $cp = new Holiday($db); @@ -132,7 +132,7 @@ if ($action == "add") } // Option du nombre de jours à déduire pour 1 jour de congés - $nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],2); + $nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],5); if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) { @@ -165,7 +165,7 @@ elseif ($action == 'create_event') $error = 0; $optName = trim($optName); - $optValue = price2num($optValue,2); + $optValue = price2num($optValue,5); if (! $optName) { @@ -218,7 +218,7 @@ elseif($action == 'event' && isset($_POST['update_event'])) if (!empty($eventValue)) { - $eventValue = price2num($eventValue,2); + $eventValue = price2num($eventValue,5); } else { $error++; } @@ -254,10 +254,11 @@ elseif($action && isset($_POST['delete_event'])) } } -print '
'; +/*print '
'; print_fiche_titre($langs->trans('TitleOptionMainCP'),'',''); + dol_fiche_head(array(),'',''); print '
'."\n"; @@ -272,13 +273,6 @@ print ''; $var=true; -/*$var=!$var; -print ''."\n"; -print ''.$langs->trans('GroupToValidateCP').''."\n"; -print ''.$cp->selectUserGroup('userGroup').''."\n"; -print ''."\n"; -*/ - $var=!$var; print ''."\n"; print ''.$langs->trans('DelayForSubmitCP').''."\n"; @@ -316,19 +310,22 @@ print '
'."\n\n"; dol_fiche_end(); - +*/ /*$var=!$var; print $langs->trans('nbUserCP').': '."\n"; print $cp->getConfCP('nbUser')."
\n"; */ -$var=!$var; -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 '
'.$langs->trans("GoIntoDictionaryHolidayTypes").'

'; +$var=!$var; +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_fiche_titre($langs->trans('TitleOptionEventCP'),'',''); @@ -406,7 +403,7 @@ print ''; print ''; dol_fiche_end(); - +*/ // Fin de page llxFooter(); diff --git a/htdocs/holiday/admin/tomergewithholiday.php b/htdocs/holiday/admin/tomergewithholiday.php deleted file mode 100644 index e4630f35bce..00000000000 --- a/htdocs/holiday/admin/tomergewithholiday.php +++ /dev/null @@ -1,225 +0,0 @@ - - * Copyright (C) 2011 Dimitri Mouillard - * 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 - * 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 . - */ - -/** - * Page module configuration paid holiday. - * - * \file holiday.php - * \ingroup holiday - * \brief Page module configuration paid holiday. - */ - -require '../../main.inc.php'; -require DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; -require_once DOL_DOCUMENT_ROOT. '/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT. '/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT. '/user/class/usergroup.class.php'; - -// Si pas administrateur -if (! $user->admin) accessforbidden(); - - -/* - * View - */ - -// Vérification si module activé -if (empty($conf->holiday->enabled)) print $langs->trans('NotActiveModCP'); - -llxheader('',$langs->trans('TitleAdminCP')); - -print_fiche_titre($langs->trans('MenuCPTypes')); - -echo '
'; - -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; - -$types = $db->query( - "SELECT * - FROM llx_congespayes_types - WHERE deleteAt IS NULL - ORDER BY label" -); - -while($type = $db->fetch_array($types)) -{ - echo' - - - - - - - - - - - - - '; -} - -echo ' - - - - - - -
' . $langs->trans('TypeLabel') . '' . $langs->trans('TypeDescription') . '' . $langs->trans('TypeAffect') . '' . $langs->trans('TypeDelay') . '' . $langs->trans('nbCongesDeductedCPMini') . '' . $langs->trans('nbCongesEveryMonthCPMini') . '
'.$type['label'].''.($type['description']?$type['description']:'N/A').' - '.($type['affect']?$langs->trans('TypeAffectYes'):$langs->trans('TypeAffectNo')).' - '.$type['delay'].''.$type['nbCongesDeducted'].''.$type['nbCongesEveryMonth'].' - - -
- -
- -'; - -echo '
'; - -llxFooter(); - -$db->close(); diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 4e405cf920a..308bbac2661 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2012-2013 Laurent Destailleur + * Copyright (C) 2012-2015 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014 Ferran Marcet @@ -381,7 +381,7 @@ if ($action == 'confirm_send') // Si Validation de la demande -if($action == 'confirm_valid') +if ($action == 'confirm_valid') { $cp = new Holiday($db); $cp->fetch($id); @@ -673,7 +673,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create else { // Formulaire de demande de congés payés - print_fiche_titre($langs->trans('MenuAddCP')); + print_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png'); // Si il y a une erreur if (GETPOST('error')) { @@ -747,8 +747,26 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print '
'."\n"; print ''."\n"; print ''."\n"; - print '
'; - print ''.$langs->trans('DelayToRequestCP',$cp->getConfCP('delayForRequest')).'

'; + + dol_fiche_head(); + + $out=''; + $typeleaves=$cp->getTypes(1,1); + foreach($typeleaves as $key => $val) + { + $nb_type = $cp->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; + + dol_fiche_end(); + + + dol_fiche_head(); + + //print ''.$langs->trans('DelayToRequestCP',$cp->getConfCP('delayForRequest')).'

'; print ''; print ''; @@ -761,8 +779,6 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; } else print $form->select_users(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0); - $nb_holiday = $cp->getCPforUser($user->id) / $cp->getConfCP('nbHolidayDeducted'); - print '   '.$langs->trans('SoldeCPUser', round($nb_holiday,2)).''; print ''; print ''; print ''; @@ -818,17 +834,17 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print '
'; - print '
'; - print '
'; - print ''."\n"; + + dol_fiche_end(); print '
'; print ''; print '    '; print ''; print '
'; - } + print ''."\n"; + } } else { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 066c5080f45..6743ce102a7 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -373,6 +373,7 @@ class Holiday extends CommonObject $sql.= " cp.rowid,"; $sql.= " cp.fk_user,"; + $sql.= " cp.fk_type,"; $sql.= " cp.date_create,"; $sql.= " cp.description,"; $sql.= " cp.date_debut,"; @@ -430,6 +431,7 @@ class Holiday extends CommonObject $tab_result[$i]['rowid'] = $obj->rowid; $tab_result[$i]['ref'] = $obj->rowid; $tab_result[$i]['fk_user'] = $obj->fk_user; + $tab_result[$i]['fk_type'] = $obj->fk_type; $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); $tab_result[$i]['description'] = $obj->description; $tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut); @@ -846,13 +848,15 @@ class Holiday extends CommonObject * Retourne la valeur d'un paramètre de configuration * * @param string $name name du paramètre de configuration + * @param int $fk_type Filter on type * @return string retourne la valeur du paramètre */ - function getConfCP($name) + function getConfCP($name, $fk_type=0) { $sql = "SELECT value"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; $sql.= " WHERE name = '".$name."'"; + if ($fk_type > 0) $sql.=" AND fk_type = ".$fk_type; dol_syslog(get_class($this).'::getConfCP name='.$name.'', LOG_DEBUG); $result = $this->db->query($sql); @@ -877,13 +881,16 @@ class Holiday extends CommonObject * * @param int $userID Id of user * @param int $nbHoliday Nb of days + * @param int $fk_type Type of vacation * @return int 0=Nothing done, 1=OK, -1=KO */ - function updateSoldeCP($userID='',$nbHoliday='') + function updateSoldeCP($userID='',$nbHoliday='', $fk_type='') { global $user, $langs; - if (empty($userID) && empty($nbHoliday)) + $error = 0; + + if (empty($userID) && empty($nbHoliday) && empty($fk_type)) { // Si mise à jour pour tout le monde en début de mois $now=dol_now(); @@ -897,60 +904,112 @@ class Holiday extends CommonObject // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp if ($month != $monthLastUpdate) { + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; $sql.= " WHERE name = 'lastUpdate'"; - dol_syslog(get_class($this).'::updateSoldeCP', LOG_DEBUG); $result = $this->db->query($sql); - // On ajoute x jours à chaque utilisateurs - $nb_holiday = $this->getConfCP('nbHolidayEveryMonth'); - if (empty($nb_holiday)) $nb_holiday=0; + $typeleaves=$cp->getTypes(1,1); + foreach($typeleaves as $key => $val) + { + // On ajoute x jours à chaque utilisateurs + $nb_holiday = $val['newByMonth']; + if (empty($nb_holiday)) $nb_holiday=0; - $users = $this->fetchUsers(false,false); - $nbUser = count($users); + $users = $this->fetchUsers(false,false); + $nbUser = count($users); - $i = 0; + $i = 0; + while ($i < $nbUser) + { + $now_holiday = $this->getCPforUser($users[$i]['rowid'], $val['rowid']); + $new_solde = $now_holiday + $this->getConfCP('nbHolidayEveryMonth'); - while ($i < $nbUser) - { - $now_holiday = $this->getCPforUser($users[$i]['rowid']); - $new_solde = $now_holiday + $this->getConfCP('nbHolidayEveryMonth'); + // On ajoute la modification dans le LOG + $this->addLogCP($user->id, $users[$i]['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $new_solde, $val['rowid']); - // On ajoute la modification dans le LOG - $this->addLogCP($user->id,$users[$i]['rowid'], $langs->trans('HolidaysMonthlyUpdate'),$new_solde); + $i++; + } - $i++; - } + $sql2 = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; + $sql2.= " nb_holiday = nb_holiday + ".$nb_holiday; + $sql2.= " WHERE fk_type = ".$val['rowid']; - $sql2 = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql2.= " nb_holiday = nb_holiday + ".$nb_holiday; + $result= $this->db->query($sql2); - dol_syslog(get_class($this).'::updateSoldeCP', LOG_DEBUG); - $result= $this->db->query($sql2); + if (! $result) break; + } - if ($result) return 1; - else return -1; + if ($result) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } } return 0; } else - { + { // Mise à jour pour un utilisateur - $nbHoliday = price2num($nbHoliday,2); + $nbHoliday = price2num($nbHoliday,5); - // Mise à jour pour un utilisateur - $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql.= " nb_holiday = ".$nbHoliday; - $sql.= " WHERE fk_user = '".$userID."'"; + $sql = "SELECT nb_holiday FROM ".MAIN_DB_PREFIX."holiday_users"; + $sql.= " WHERE fk_user = '".$userID."' AND fk_type = ".$fk_type; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); - dol_syslog(get_class($this).'::updateSoldeCP', LOG_DEBUG); - $result = $this->db->query($sql); + if ($num > 0) + { + // Update for user + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; + $sql.= " nb_holiday = ".$nbHoliday; + $sql.= " WHERE fk_user = '".$userID."' AND fk_type = ".$fk_type; + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[]=$this->db->lasterror(); + } + } + else + { + // Insert for user + $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users(nb_holiday, fk_user, fk_type) VALUES ("; + $sql.= $nbHoliday; + $sql.= ", '".$userID."', ".$fk_type.")"; + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[]=$this->db->lasterror(); + } + } + } + else + { + $this->errors[]=$this->db->lasterror(); + $error++; + } - if ($result) return 1; - else return -1; + if (! $error) + { + return 1; + } + else + { + return -1; + } } } @@ -1036,24 +1095,29 @@ class Holiday extends CommonObject * Retourne le solde de congés payés pour un utilisateur * * @param int $user_id ID de l'utilisateur + * @param int $fk_type Filter on type * @return float Retourne le solde de congés payés de l'utilisateur */ - function getCPforUser($user_id) { - + function getCPforUser($user_id, $fk_type=0) + { $sql = "SELECT nb_holiday"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; $sql.= " WHERE fk_user = '".$user_id."'"; + if ($fk_type > 0) $sql.=" AND fk_type = ".$fk_type; dol_syslog(get_class($this).'::getCPforUser', LOG_DEBUG); $result = $this->db->query($sql); - if($result) { + if($result) + { $obj = $this->db->fetch_object($result); //return number_format($obj->nb_holiday,2); - return $obj->nb_holiday; - } else { - return '0'; + if ($obj) return $obj->nb_holiday; + else return null; + } + else + { + return null; } - } /** @@ -1067,9 +1131,10 @@ class Holiday extends CommonObject function fetchUsers($liste=true,$type=true) { // Si vrai donc pour user Dolibarr - if($liste) { - - if($type) { + if ($liste) + { + if($type) + { // Si utilisateur de Dolibarr $sql = "SELECT u.rowid"; @@ -1109,7 +1174,9 @@ class Holiday extends CommonObject return -1; } - } else { // Si utilisateur du module Congés Payés + } + else + { // Si utilisateur du module Congés Payés $sql = "SELECT u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as u"; @@ -1147,11 +1214,13 @@ class Holiday extends CommonObject } } - } else { // Si faux donc user Congés Payés + } + else + { // Si faux donc user Congés Payés // Si c'est pour les utilisateurs de Dolibarr - if($type) { - + if ($type) + { $sql = "SELECT u.rowid, u.lastname, u.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE statut > 0"; @@ -1188,9 +1257,11 @@ class Holiday extends CommonObject } // Si c'est pour les utilisateurs du module Congés Payés - } else { + } + else + { - $sql = "SELECT cpu.fk_user, u.lastname, u.firstname"; + $sql = "SELECT DISTINCT cpu.fk_user, 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"; @@ -1269,8 +1340,8 @@ class Holiday extends CommonObject * @param int $userCP Number of active users into table of holidays * @return void */ - function verifNbUsers($userDolibarrWithoutCP,$userCP) { - + function verifNbUsers($userDolibarrWithoutCP,$userCP) + { if (empty($userCP)) $userCP=0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); @@ -1316,7 +1387,9 @@ class Holiday extends CommonObject return -1; } - } else { + } + else + { $this->db->begin(); // Si il y a moins d'utilisateur Dolibarr que dans le module CP @@ -1599,51 +1672,53 @@ class Holiday extends CommonObject * * @param int $fk_user_action Id user creation * @param int $fk_user_update Id user update - * @param int $type Type + * @param string $label Label * @param int $new_solde New value - * @return number|string + * @param int $fk_type Type of vacation + * @return int Id of record added, 0 if nothing done, < 0 if KO */ - function addLogCP($fk_user_action,$fk_user_update,$type,$new_solde) { - + function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) + { global $conf, $langs; $error=0; - $prev_solde = $this->getCPforUser($fk_user_update); - $new_solde = number_format($new_solde,2,'.',''); + $prev_solde = price2num($this->getCPforUser($fk_user_update, $fk_type), 5); + $new_solde = price2num($new_solde, 5); + //print "$prev_solde == $new_solde"; - // Insert request + if ($prev_solde == $new_solde) return 0; + + $this->db->begin(); + + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_logs ("; - $sql.= "date_action,"; $sql.= "fk_user_action,"; $sql.= "fk_user_update,"; $sql.= "type_action,"; $sql.= "prev_solde,"; - $sql.= "new_solde"; - + $sql.= "new_solde,"; + $sql.= "fk_type"; $sql.= ") VALUES ("; - - $sql.= " NOW(), "; + $sql.= " '".$this->db->idate(dol_now())."',"; $sql.= " '".$fk_user_action."',"; $sql.= " '".$fk_user_update."',"; - $sql.= " '".$this->db->escape($type)."',"; + $sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$prev_solde."',"; - $sql.= " '".$new_solde."'"; + $sql.= " '".$new_solde."',"; + $sql.= " ".$fk_type; $sql.= ")"; - $this->db->begin(); - - dol_syslog(get_class($this)."::addLogCP", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { + $resql=$this->db->query($sql); + if (! $resql) + { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $error) { $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs"); - } // Commit or rollback @@ -1682,8 +1757,8 @@ class Holiday extends CommonObject $sql.= " cpl.fk_user_update,"; $sql.= " cpl.type_action,"; $sql.= " cpl.prev_solde,"; - $sql.= " cpl.new_solde"; - + $sql.= " cpl.new_solde,"; + $sql.= " cpl.fk_type"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; $sql.= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria @@ -1724,6 +1799,7 @@ class Holiday extends CommonObject $tab_result[$i]['type_action'] = $obj->type_action; $tab_result[$i]['prev_solde'] = $obj->prev_solde; $tab_result[$i]['new_solde'] = $obj->new_solde; + $tab_result[$i]['fk_type'] = $obj->fk_type; $i++; } @@ -1743,21 +1819,35 @@ class Holiday extends CommonObject /** * Return array with list of types * - * @return boolean Return array with list of types + * @param int $active Status of type + * @param int $affect Filter on affect + * @return array Return array with list of types */ - function getTypes() + function getTypes($active=-1, $affect=-1) { - $result = $this->db->query("SELECT rowid, type, affect FROM " . MAIN_DB_PREFIX . "holiday_types"); - $num = $this->db->num_rows($result); - if ($num) - { - while ($obj = $this->db->fetch_object($result)) - { - $types[] = array('rowid'=> $obj->rowid, 'type'=> $obj->type, 'affect'=>$obj->affect); - } + global $mysoc; - return $types; + $sql = "SELECT rowid, code, label, affect, delay, newByMonth"; + $sql.= " FROM " . MAIN_DB_PREFIX . "c_holiday_types"; + $sql.= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; + if ($active >= 0) $sql.=" AND active = ".((int) $active); + if ($affect >= 0) $sql.=" AND affect = ".((int) $affect); + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num) + { + while ($obj = $this->db->fetch_object($result)) + { + $types[] = array('rowid'=> $obj->rowid, 'code'=> $obj->code, 'label'=>$obj->label, 'affect'=>$obj->affect, 'delay'=>$obj->delay, 'newByMonth'=>$obj->newByMonth); + } + + return $types; + } } + else dol_print_error($this->db); return array(); } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index fa3f745de81..4aae0ab7f7d 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2015 Laurent Destailleur * Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2013 Marcos García * @@ -37,62 +37,77 @@ if(!$user->rights->holiday->define_holiday) accessforbidden(); $action=GETPOST('action'); - -/* - * View - */ - -$form = new Form($db); -$userstatic=new User($db); $holiday = new Holiday($db); -llxHeader(array(),$langs->trans('CPTitreMenu')); - -print_fiche_titre($langs->trans('MenuConfCP')); - -$holiday->updateSold(); // Create users into table holiday if they don't exists. TODO Remove if we use field into table user. - -$listUsers = $holiday->fetchUsers(false,false); +/* + * Actions + */ // 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]; - $userValue = $_POST['nb_holiday']; - $userValue = $userValue[$userID]; + foreach($typeleaves as $key => $val) + { + $userValue = $_POST['nb_holiday_'.$val['rowid']]; + $userValue = $userValue[$userID]; - if(!empty($userValue)) { - $userValue = price2num($userValue,2); - } else { - $userValue = 0; + 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 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].')' : ''); - - // We add the modification to the log - $holiday->addLogCP($user->id,$userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment,$userValue); - - // Update of the days of the employee - $holiday->updateSoldeCP($userID,$userValue); - - // If it first update of sold, 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); - - setEventMessage($langs->trans('UpdateConfCPOK')); + if (! $error) setEventMessage($langs->trans('UpdateConfCPOK')); } elseif($action == 'add_event') { $error = 0; + $typeleaves=$holiday->getTypes(1,1); + if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) { $event = $_POST['list_event']; } else { $error++; @@ -122,13 +137,29 @@ elseif($action == 'add_event') } } + +/* + * View + */ + +$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. + +$listUsers = $holiday->fetchUsers(false,true); + $var=true; $i = 0; $cp_events = $holiday->fetchEventsCP(); - -if($cp_events == 1) +if ($cp_events == 1) { print '
'."\n"; print ''; @@ -144,19 +175,26 @@ if($cp_events == 1) print '
'; } + +$typeleaves=$holiday->getTypes(1,1); + print '
'."\n"; print ''; + print ''; print ""; print ''; -print ''; +foreach($typeleaves as $key => $val) +{ + print ''; +} print ''; print ''; print ''; + foreach($listUsers as $users) { - $var=!$var; print ''; @@ -166,9 +204,15 @@ foreach($listUsers as $users) $userstatic->firstname=$users['firstname']; print $userstatic->getNomUrl(1); print ''; - print ''."\n"; + foreach($typeleaves as $key => $val) + { + $nbtoshow=''; + if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5); + print ''."\n"; + } print ''; print ''."\n"; print ''; @@ -177,6 +221,7 @@ foreach($listUsers as $users) } print '
'.$langs->trans('Employee').''.$langs->trans('Available').''.$val['label'].''.$langs->trans('Note').'
'; - print ''; - print ' '.$langs->trans('days').''; + print ''; + //print ' '.$langs->trans('days'); + print '
'; + print '
'; llxFooter(); diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index 5b9e7d4c0ba..cd8e0daaced 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -189,24 +189,23 @@ if ($id > 0) // Récupération des congés payés de l'utilisateur ou de tous les users if (!$user->rights->holiday->write_all || $id > 0) { - $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); + $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); // Load array $holiday->holiday } else { - $holiday_payes = $holiday->fetchAll($order,$filter); + $holiday_payes = $holiday->fetchAll($order,$filter); // Load array $holiday->holiday } // Si erreur SQL if ($holiday_payes == '-1') { - print_fiche_titre($langs->trans('CPTitreMenu')); + print_fiche_titre($langs->trans('CPTitreMenu'), '', 'title_hrm.png'); dol_print_error($db, $langs->trans('Error').' '.$holiday->error); exit(); } -/************************************* - * Affichage du tableau des congés payés -*************************************/ + +// Show table of vacations $var=true; $num = count($holiday->holiday); $form = new Form($db); @@ -242,19 +241,26 @@ if ($id > 0) } else { - print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num); + print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num, 0, 'title_hrm.png'); dol_fiche_head(''); } -$nbaquis=$holiday->getCPforUser($user_id); -$nbdeduced=$holiday->getConfCP('nbHolidayDeducted'); -$nb_holiday = $nbaquis / $nbdeduced; -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; dol_fiche_end(); + if ($id > 0) print '
'; @@ -265,11 +271,12 @@ print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cp.rowid","", print_liste_field_titre($langs->trans("DateCreateCP"),$_SERVER["PHP_SELF"],"cp.date_create","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Employe"),$_SERVER["PHP_SELF"],"cp.fk_user","",'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ValidatorCP"),$_SERVER["PHP_SELF"],"cp.fk_validator","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],'','','','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateDebCP"),$_SERVER["PHP_SELF"],"cp.date_debut","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateFinCP"),$_SERVER["PHP_SELF"],"cp.date_fin","",'','align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cp.statut","",'','align="center"',$sortfield,$sortorder); -print ''; +print_liste_field_titre(''); print "\n"; // FILTRES @@ -285,9 +292,10 @@ $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 ''; - $form->select_users($search_employe,"search_employe",1,"",0,''); + print $form->select_dolusers($search_employe,"search_employe",1,"",0,'','',0,32); print ''; } else { print ' '; @@ -303,7 +311,7 @@ if($user->rights->holiday->write_all) $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; - $form->select_users($search_valideur,"search_valideur",1,"",0,$valideurarray,''); + print $form->select_dolusers($search_valideur,"search_valideur",1,"",0,$valideurarray,'', 0, 32); print ''; } else @@ -311,6 +319,13 @@ else print ' '; } +// Type +print ''; +print ''; + +// DUREE +print ' '; + // DATE DEBUT print ''; print ''; @@ -323,9 +338,6 @@ print 'select_year($year_end,'year_end',1, $min_year, $max_year); print ''; -// DUREE -print ' '; - // STATUT print ''; $holiday->selectStatutCP($search_statut); @@ -371,11 +383,13 @@ if (! empty($holiday->holiday)) print ''.dol_print_date($date,'day').''; print ''.$userstatic->getNomUrl('1').''; print ''.$approbatorstatic->getNomUrl('1').''; - print ''.dol_print_date($infos_CP['date_debut'],'day').''; - print ''.dol_print_date($infos_CP['date_fin'],'day').''; + print ''.$infos_CP['fk_type'].''; print ''; $nbopenedday=num_open_day($infos_CP['date_debut_gmt'], $infos_CP['date_fin_gmt'], 0, 1, $infos_CP['halfday']); print $nbopenedday.' '.$langs->trans('DurationDays'); + print ''; + print ''.dol_print_date($infos_CP['date_debut'],'day').''; + print ''.dol_print_date($infos_CP['date_fin'],'day').''; print ''.$holidaystatic->LibStatut($infos_CP['statut'],5).''; print ''."\n"; diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 05046f5ad60..2d0df2b692d 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -71,7 +71,7 @@ $sql.= " ORDER BY u.lastname,cp.date_debut"; $result = $db->query($sql); $num = $db->num_rows($result); -print_fiche_titre($langs->trans('MenuReportMonth')); +print_fiche_titre($langs->trans('MenuReportMonth'), '', 'title_hrm.png'); print '
'; diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index bb9b2c430be..6ccd9f38665 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2015 Laurent Destailleur * Copyright (C) 2011 Dimitri Mouillard * * This program is free software; you can redistribute it and/or modify @@ -55,7 +55,7 @@ $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_fiche_titre($langs->trans('LogCP'),''.img_previous().' '.$langs->trans("Year").':'.$year.' '.img_next().''); +print load_fiche_titre($langs->trans('LogCP'), '', 'title_hrm.png'); print ''; print ''; @@ -66,6 +66,7 @@ print ''; print ''; print ''; print ''; +print ''; print ''; print ''; @@ -88,8 +89,9 @@ foreach($cp->logs as $logs_CP) print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''."\n"; } diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 79ab44a5aef..f9853ab773c 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -676,6 +676,8 @@ ALTER TABLE llx_c_stcomm ADD COLUMN picto varchar(128); INSERT INTO llx_c_action_trigger (code, label, description, elementtype, rang) VALUES ('BILL_SUPPLIER_UNVALIDATE','Supplier invoice unvalidated','Executed when a supplier invoice status is set back to draft','invoice_supplier',15); +ALTER TABLE llx_holiday_users DROP PRIMARY KEY; + DROP TABLE llx_holiday_types; CREATE TABLE llx_c_holiday_types ( @@ -685,6 +687,23 @@ CREATE TABLE llx_c_holiday_types ( affect integer NOT NULL, delay integer NOT NULL, newByMonth double(8,5) DEFAULT 0 NOT NULL, - fk_country integer DEFAULT NULL + fk_country integer DEFAULT NULL, + active integer DEFAULT 1 ) ENGINE=innodb; +ALTER TABLE llx_c_holiday_types ADD UNIQUE INDEX uk_c_holiday_types(code); + +insert into llx_c_holiday_types(code, label, affect, delay, newByMonth, fk_country) values ('LEAVE_PAID', 'Paid vacation', 1, 7, 0, NULL); +insert into llx_c_holiday_types(code, label, affect, delay, newByMonth, fk_country) values ('LEAVE_SICK', 'Sick leave', 0, 0, 0, NULL); +insert into llx_c_holiday_types(code, label, affect, delay, newByMonth, fk_country) values ('LEAVE_OTHER','Other leave', 0, 0, 0, NULL); +-- Leaves specific to France +insert into llx_c_holiday_types(code, label, affect, delay, newByMonth, fk_country) values ('LEAVE_RTT', 'RTT' , 1, 7, 0.83, 1); + +ALTER TABLE llx_holiday ADD COLUMN fk_type integer NOT NULL DEFAULT 1; +ALTER TABLE llx_holiday_users ADD COLUMN fk_type integer NOT NULL DEFAULT 1; +ALTER TABLE llx_holiday_logs ADD COLUMN fk_type integer NOT NULL DEFAULT 1; + +UPDATE llx_holiday_users SET fk_type = 1 WHERE fk_type IS NULL; +UPDATE llx_holiday_logs SET fk_type = 1 WHERE fk_type IS NULL; + + diff --git a/htdocs/install/mysql/tables/llx_c_holiday_types.key.sql b/htdocs/install/mysql/tables/llx_c_holiday_types.key.sql new file mode 100644 index 00000000000..854742695a8 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_holiday_types.key.sql @@ -0,0 +1,19 @@ +-- =================================================================== +-- Copyright (C) 2012 Laurent Destailleur +-- +-- 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 . +-- +-- =================================================================== + +ALTER TABLE llx_c_holiday_types ADD UNIQUE INDEX uk_c_holiday_types(code); diff --git a/htdocs/install/mysql/tables/llx_c_holiday_types.sql b/htdocs/install/mysql/tables/llx_c_holiday_types.sql index dac1a10fdad..6bd375b6d1f 100755 --- a/htdocs/install/mysql/tables/llx_c_holiday_types.sql +++ b/htdocs/install/mysql/tables/llx_c_holiday_types.sql @@ -23,5 +23,6 @@ CREATE TABLE llx_c_holiday_types ( affect integer NOT NULL, -- a request will change sold or not delay integer NOT NULL, -- Minimum delay to be allowed to make request newByMonth double(8,5) DEFAULT 0 NOT NULL, -- Amount of new days for each user each month - fk_country integer DEFAULT NULL -- This type is dedicated to a country + fk_country integer DEFAULT NULL, -- This type is dedicated to a country + active integer DEFAULT 1 ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_holiday.sql b/htdocs/install/mysql/tables/llx_holiday.sql index fa9e7a070dc..3f61b893bd4 100644 --- a/htdocs/install/mysql/tables/llx_holiday.sql +++ b/htdocs/install/mysql/tables/llx_holiday.sql @@ -21,6 +21,7 @@ CREATE TABLE llx_holiday rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_user integer NOT NULL, fk_user_create integer, +fk_type integer NOT NULL, date_create DATETIME NOT NULL, description VARCHAR( 255 ) NOT NULL, date_debut DATE NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_holiday_logs.sql b/htdocs/install/mysql/tables/llx_holiday_logs.sql index cfacafc9746..7c84ebeaa20 100644 --- a/htdocs/install/mysql/tables/llx_holiday_logs.sql +++ b/htdocs/install/mysql/tables/llx_holiday_logs.sql @@ -22,6 +22,7 @@ rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, date_action DATETIME NOT NULL, fk_user_action integer NOT NULL, fk_user_update integer NOT NULL, +fk_type integer NOT NULL, type_action VARCHAR( 255 ) NOT NULL, prev_solde VARCHAR( 255 ) NOT NULL, new_solde VARCHAR( 255 ) NOT NULL diff --git a/htdocs/install/mysql/tables/llx_holiday_users.sql b/htdocs/install/mysql/tables/llx_holiday_users.sql index 1ba6cb016c5..5aa1c3fc061 100644 --- a/htdocs/install/mysql/tables/llx_holiday_users.sql +++ b/htdocs/install/mysql/tables/llx_holiday_users.sql @@ -1,5 +1,5 @@ -- =================================================================== --- Copyright (C) 2012 Laurent Destailleur +-- Copyright (C) 2012-2015 Laurent Destailleur -- -- 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 @@ -18,7 +18,8 @@ CREATE TABLE llx_holiday_users ( -fk_user integer NOT NULL PRIMARY KEY, -nb_holiday real NOT NULL DEFAULT '0' + fk_user integer NOT NULL, + fk_type integer NOT NULL, + nb_holiday real NOT NULL DEFAULT '0' ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4547093cc06..cdc8c639a20 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -820,6 +820,7 @@ DictionaryAccountancysystem=Models for chart of accounts DictionaryEMailTemplates=Emails templates DictionaryUnits=Units DictionaryProspectStatus=Prospection status +DictionaryHolidayTypes=Type of leaves SetupSaved=Setup saved BackToModuleList=Back to modules list BackToDictionaryList=Back to dictionaries list diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index f5b87fefb08..b693c594f87 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -71,7 +71,7 @@ MotifCP=Reason UserCP=User ErrorAddEventToUserCP=An error occurred while adding the exceptional leave. AddEventToUserOkCP=The addition of the exceptional leave has been completed. -MenuLogCP=View logs of leave requests +MenuLogCP=View change logs LogCP=Log of updates of available vacation days ActionByCP=Performed by UserUpdateCP=For the user @@ -146,3 +146,5 @@ Permission20003=Delete leave requests Permission20004=Setup users available vacation days Permission20005=Review log of modified leave requests Permission20006=Read leaves monthly report +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/theme/eldy/img/menus_black/globe.png b/htdocs/theme/eldy/img/menus_black/globe.png index 04bd3fc25ce..bb32b38a0f4 100644 Binary files a/htdocs/theme/eldy/img/menus_black/globe.png and b/htdocs/theme/eldy/img/menus_black/globe.png differ diff --git a/htdocs/theme/eldy/img/menus_black/holiday.png b/htdocs/theme/eldy/img/menus_black/holiday.png new file mode 100644 index 00000000000..de788526bc1 Binary files /dev/null and b/htdocs/theme/eldy/img/menus_black/holiday.png differ diff --git a/htdocs/theme/eldy/img/title_hrm.png b/htdocs/theme/eldy/img/title_hrm.png new file mode 100644 index 00000000000..de788526bc1 Binary files /dev/null and b/htdocs/theme/eldy/img/title_hrm.png differ
'.$langs->trans('Date').''.$langs->trans('ActionByCP').''.$langs->trans('UserUpdateCP').''.$langs->trans('Description').''.$langs->trans('Type').''.$langs->trans('PrevSoldeCP').''.$langs->trans('NewSoldeCP').''.$user_action->getNomUrl(1).''.$user_update->getNomUrl(1).''.$logs_CP['type_action'].''.price2num($logs_CP['prev_solde'],8).' '.$langs->trans('days').''.price2num($logs_CP['new_solde'],8).' '.$langs->trans('days').''.$logs_CP['fk_type'].''.price2num($logs_CP['prev_solde'],5).' '.$langs->trans('days').''.price2num($logs_CP['new_solde'],5).' '.$langs->trans('days').'