2
0
forked from Wavyzz/dolibarr

FIX It was not possible to define if leave type need to be followed by a

counter or not. Added also a message to ask user to finish setup if no
leave with counter was setup.
This commit is contained in:
Laurent Destailleur
2016-01-09 01:18:53 +01:00
parent e79750dc89
commit 0d8788e552
6 changed files with 82 additions and 52 deletions

View File

@@ -41,6 +41,7 @@ $langs->load("errors");
$langs->load("admin");
$langs->load("companies");
$langs->load("resource");
$langs->load("holiday");
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha');
@@ -168,7 +169,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";
$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, 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";
$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
// Criteria to sort dictionaries
@@ -232,7 +233,7 @@ $tabfield[24]= "code,label";
$tabfield[25]= "label,type_template,position,topic,content";
$tabfield[26]= "code,label,short_label";
$tabfield[27]= "code,libelle";
$tabfield[28]= "code,label,delay,newByMonth,country_id,country";
$tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country";
$tabfield[29]= "code,label,percent,position";
// Nom des champs d'edition pour modification d'un enregistrement
@@ -264,7 +265,7 @@ $tabfieldvalue[24]= "code,label";
$tabfieldvalue[25]= "label,type_template,position,topic,content";
$tabfieldvalue[26]= "code,label,short_label";
$tabfieldvalue[27]= "code,libelle";
$tabfieldvalue[28]= "code,label,delay,newByMonth,country";
$tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country";
$tabfieldvalue[29]= "code,label,percent,position";
// Nom des champs dans la table pour insertion d'un enregistrement
@@ -296,7 +297,7 @@ $tabfieldinsert[24]= "code,label";
$tabfieldinsert[25]= "label,type_template,position,topic,content";
$tabfieldinsert[26]= "code,label,short_label";
$tabfieldinsert[27]= "code,libelle";
$tabfieldinsert[28]= "code,label,delay,newByMonth,fk_country";
$tabfieldinsert[28]= "code,label,affect,delay,newByMonth,fk_country";
$tabfieldinsert[29]= "code,label,percent,position";
// Nom du rowid si le champ n'est pas de type autoincrement
@@ -394,7 +395,7 @@ $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[25] = array('type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[28] = array('delay'=>$langs->trans("MinimumNoticePeriod"), 'newByMonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newByMonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
// List of check for fields (NOT USED YET)

View File

@@ -763,7 +763,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
dol_fiche_head();
$out='';
$typeleaves=$cp->getTypes(1,-1);
$typeleaves=$cp->getTypes(1,1);
foreach($typeleaves as $key => $val)
{
$nb_type = $cp->getCPforUser($user->id, $val['rowid']);

View File

@@ -1804,8 +1804,8 @@ class Holiday extends CommonObject
/**
* Return array with list of types
*
* @param int $active Status of type
* @param int $affect Filter on affect (a request will change sold or not)
* @param int $active Status of type. -1 = Both
* @param int $affect Filter on affect (a request will change sold or not). -1 = Both
* @return array Return array with list of types
*/
function getTypes($active=-1, $affect=-1)

View File

@@ -132,7 +132,8 @@ elseif($action == 'add_event')
$new_holiday = $nb_holiday + $add_holiday;
// add event to existing types of vacation
foreach ($typeleaves as $key => $leave) {
foreach ($typeleaves as $key => $leave)
{
$vacationTypeID = $leave['rowid'];
// On ajoute la modification dans le LOG
@@ -193,52 +194,77 @@ if ($cp_events == 1)
$typeleaves=$holiday->getTypes(1,1);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<input type="hidden" name="action" value="update" />';
print '<table class="noborder" width="100%;">';
print "<tr class=\"liste_titre\">";
print '<td width="55%">'.$langs->trans('Employee').'</td>';
foreach($typeleaves as $key => $val)
if (count($typeleaves) == 0)
{
print '<td width="20%" style="text-align:center">'.$val['label'].'</td>';
//print '<div class="info">';
print $langs->trans("NoLeaveWithCounterDefined")."<br>\n";
print $langs->trans("GoIntoDictionaryHolidayTypes");
//print '</div>';
}
print '<td width="20%" style="text-align:center">'.$langs->trans('Note').'</td>';
print '<td></td>';
print '</tr>';
foreach($listUsers as $users)
else
{
$var=!$var;
print '<tr '.$bc[$var].' style="height: 20px;">';
print '<td>';
$userstatic->id=$users['rowid'];
$userstatic->lastname=$users['name'];
$userstatic->firstname=$users['firstname'];
print $userstatic->getNomUrl(1);
print '</td>';
foreach($typeleaves as $key => $val)
{
$nbtoshow='';
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
print '<td style="text-align:center">';
print '<input type="text" value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
//print ' '.$langs->trans('days');
print '</td>'."\n";
}
print '<td style="text-align:center"><input type="text" value="" name="note_holiday['.$users['rowid'].']" size="30"/></td>';
print '<td><input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Update")).'" class="button"/></td>'."\n";
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<input type="hidden" name="action" value="update" />';
print '<table class="noborder" width="100%;">';
print "<tr class=\"liste_titre\">";
print '<td width="55%">'.$langs->trans('Employee').'</td>';
if (count($typeleaves))
{
foreach($typeleaves as $key => $val)
{
print '<td width="20%" style="text-align:center">'.$val['label'].'</td>';
}
}
else
{
print '<td>'.$langs->trans("NoLeaveWithCounterDefined").'</td>';
}
print '<td width="20%" style="text-align:center">'.$langs->trans('Note').'</td>';
print '<td></td>';
print '</tr>';
$i++;
foreach($listUsers as $users)
{
$var=!$var;
print '<tr '.$bc[$var].' style="height: 20px;">';
print '<td>';
$userstatic->id=$users['rowid'];
$userstatic->lastname=$users['name'];
$userstatic->firstname=$users['firstname'];
print $userstatic->getNomUrl(1);
print '</td>';
if (count($typeleaves))
{
foreach($typeleaves as $key => $val)
{
$nbtoshow='';
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
print '<td style="text-align:center">';
print '<input type="text" value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
//print ' '.$langs->trans('days');
print '</td>'."\n";
}
}
else
{
print '<td></td>';
}
print '<td style="text-align:center"><input type="text" value="" name="note_holiday['.$users['rowid'].']" size="30"/></td>';
print '<td><input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Update")).'" class="button"/></td>'."\n";
print '</tr>';
$i++;
}
print '</table>';
print '</form>';
}
print '</table>';
print '</form>';
llxFooter();
$db->close();

View File

@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -101,10 +101,10 @@ foreach($cp->logs as $logs_CP)
}
if($log_holiday == '2')
if ($log_holiday == '2')
{
print '<tr>';
print '<td colspan="7" class="pair" style="text-align: center; padding: 5px;">'.$langs->trans('NoResults').'</td>';
print '<td colspan="8" '.$bc[false].'>'.$langs->trans('None').'</td>';
print '</tr>';
}

View File

@@ -140,4 +140,7 @@ HolidaysRefusedBody=Your leave request for %s to %s has been denied for the foll
HolidaysCanceled=Canceled leaved request
HolidaysCanceledBody=Your leave request for %s to %s has been canceled.
NewByMonth=Added per month
Affect=Followed by a counter
FollowedByACounter=1: This type of leave need to be followed by a counter. Counter is incremented manually or automatically and when a leave request is validated, counter is decremented.<br>0: Not followed by a counter.
NoLeaveWithCounterDefined=There is no leave types defined that need to be followed by a counter
GoIntoDictionaryHolidayTypes=Go into <strong>Home - Setup - Dictionaries - Type of leaves</strong> to setup the different types of leaves.