Support type of leave.
This commit is contained in:
parent
7d1d1caf30
commit
5975536fcf
@ -51,7 +51,6 @@ $now=dol_now();
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Si création de la demande
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
@ -66,12 +65,15 @@ if ($action == 'create')
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
|
$date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
|
||||||
$date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
|
$date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
|
||||||
$date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
|
$date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
|
||||||
$date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
|
$date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
|
||||||
$starthalfday=GETPOST('starthalfday');
|
$starthalfday=GETPOST('starthalfday');
|
||||||
$endhalfday=GETPOST('endhalfday');
|
$endhalfday=GETPOST('endhalfday');
|
||||||
|
$type=GETPOST('type');
|
||||||
$halfday=0;
|
$halfday=0;
|
||||||
if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2;
|
if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2;
|
||||||
else if ($starthalfday == 'afternoon') $halfday=-1;
|
else if ($starthalfday == 'afternoon') $halfday=-1;
|
||||||
@ -131,17 +133,22 @@ if ($action == 'create')
|
|||||||
$cp->date_fin = $date_fin;
|
$cp->date_fin = $date_fin;
|
||||||
$cp->fk_validator = $valideur;
|
$cp->fk_validator = $valideur;
|
||||||
$cp->halfday = $halfday;
|
$cp->halfday = $halfday;
|
||||||
|
$cp->fk_type = $type;
|
||||||
|
|
||||||
$verif = $cp->create($userid);
|
$verif = $cp->create($user);
|
||||||
|
|
||||||
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
||||||
if ($verif > 0)
|
if ($verif > 0)
|
||||||
{
|
{
|
||||||
|
$db->commit();
|
||||||
|
|
||||||
header('Location: card.php?id='.$verif);
|
header('Location: card.php?id='.$verif);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$db->rollback();
|
||||||
|
|
||||||
// Sinon on affiche le formulaire de demande avec le message d'erreur SQL
|
// Sinon on affiche le formulaire de demande avec le message d'erreur SQL
|
||||||
header('Location: card.php?action=request&error=SQL_Create&msg='.$cp->error);
|
header('Location: card.php?action=request&error=SQL_Create&msg='.$cp->error);
|
||||||
exit;
|
exit;
|
||||||
@ -242,9 +249,7 @@ if ($action == 'update')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si suppression de la demande
|
// Si suppression de la demande
|
||||||
if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes')
|
if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->holiday->delete)
|
||||||
{
|
|
||||||
if($user->rights->holiday->delete)
|
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -280,7 +285,6 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes')
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Si envoi de la demande
|
// Si envoi de la demande
|
||||||
if ($action == 'confirm_send')
|
if ($action == 'confirm_send')
|
||||||
@ -770,6 +774,8 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
|||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tbody>';
|
print '<tbody>';
|
||||||
|
|
||||||
|
// User
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="fieldrequired">'.$langs->trans("User").'</td>';
|
print '<td class="fieldrequired">'.$langs->trans("User").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
@ -781,6 +787,24 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
|||||||
else print $form->select_users(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0);
|
else print $form->select_users(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Type
|
||||||
|
print '<tr>';
|
||||||
|
print '<td class="fieldrequired">'.$langs->trans("Type").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
$typeleaves=$cp->getTypes(1,1);
|
||||||
|
$arraytypeleaves=array();
|
||||||
|
foreach($typeleaves as $key => $val)
|
||||||
|
{
|
||||||
|
$labeltoshow = $val['label'];
|
||||||
|
$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
|
||||||
|
$arraytypeleaves[$val['rowid']]=$labeltoshow;
|
||||||
|
}
|
||||||
|
print $form->selectarray('type', $arraytypeleaves, (GETPOST('type')?GETPOST('type'):''), 1);
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// Date start
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="fieldrequired">'.$langs->trans("DateDebCP").' ('.$langs->trans("FirstDayOfHoliday").')</td>';
|
print '<td class="fieldrequired">'.$langs->trans("DateDebCP").' ('.$langs->trans("FirstDayOfHoliday").')</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
@ -795,6 +819,8 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
|||||||
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning'));
|
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning'));
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Date end
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="fieldrequired">'.$langs->trans("DateFinCP").' ('.$langs->trans("LastDayOfHoliday").')</td>';
|
print '<td class="fieldrequired">'.$langs->trans("DateFinCP").' ('.$langs->trans("LastDayOfHoliday").')</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
@ -952,9 +978,9 @@ else
|
|||||||
if ($action == 'edit' && $cp->statut == 1)
|
if ($action == 'edit' && $cp->statut == 1)
|
||||||
{
|
{
|
||||||
$edit = true;
|
$edit = true;
|
||||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$_GET['id'].'">'."\n";
|
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$id.'">'."\n";
|
||||||
print '<input type="hidden" name="action" value="update"/>'."\n";
|
print '<input type="hidden" name="action" value="update"/>'."\n";
|
||||||
print '<input type="hidden" name="holiday_id" value="'.$_GET['id'].'" />'."\n";
|
print '<input type="hidden" name="holiday_id" value="'.$id.'" />'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
@ -974,6 +1000,15 @@ else
|
|||||||
print $userRequest->getNomUrl(1);
|
print $userRequest->getNomUrl(1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Type
|
||||||
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans("Type").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
$typeleaves=$cp->getTypes(1,1);
|
||||||
|
print $typeleaves[$cp->fk_type]['label'];
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
$starthalfday=($cp->halfday == -1 || $cp->halfday == 2)?'afternoon':'morning';
|
$starthalfday=($cp->halfday == -1 || $cp->halfday == 2)?'afternoon':'morning';
|
||||||
$endhalfday=($cp->halfday == 1 || $cp->halfday == 2)?'morning':'afternoon';
|
$endhalfday=($cp->halfday == 1 || $cp->halfday == 2)?'morning':'afternoon';
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,7 @@ class Holiday extends CommonObject
|
|||||||
var $date_cancel='';
|
var $date_cancel='';
|
||||||
var $fk_user_cancel;
|
var $fk_user_cancel;
|
||||||
var $detail_refuse='';
|
var $detail_refuse='';
|
||||||
|
var $fk_type;
|
||||||
|
|
||||||
var $holiday = array();
|
var $holiday = array();
|
||||||
var $events = array();
|
var $events = array();
|
||||||
@ -71,6 +72,7 @@ class Holiday extends CommonObject
|
|||||||
var $optValue = '';
|
var $optValue = '';
|
||||||
var $optRowid = '';
|
var $optRowid = '';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -124,10 +126,10 @@ class Holiday extends CommonObject
|
|||||||
$sql.= "date_fin,";
|
$sql.= "date_fin,";
|
||||||
$sql.= "halfday,";
|
$sql.= "halfday,";
|
||||||
$sql.= "statut,";
|
$sql.= "statut,";
|
||||||
$sql.= "fk_validator";
|
$sql.= "fk_validator,";
|
||||||
|
$sql.= "fk_type,";
|
||||||
|
$sql.= "fk_user_create";
|
||||||
$sql.= ") VALUES (";
|
$sql.= ") VALUES (";
|
||||||
|
|
||||||
// User
|
|
||||||
$sql.= "'".$this->fk_user."',";
|
$sql.= "'".$this->fk_user."',";
|
||||||
$sql.= " '".$this->db->idate($now)."',";
|
$sql.= " '".$this->db->idate($now)."',";
|
||||||
$sql.= " '".$this->db->escape($this->description)."',";
|
$sql.= " '".$this->db->escape($this->description)."',";
|
||||||
@ -135,8 +137,9 @@ class Holiday extends CommonObject
|
|||||||
$sql.= " '".$this->db->idate($this->date_fin)."',";
|
$sql.= " '".$this->db->idate($this->date_fin)."',";
|
||||||
$sql.= " ".$this->halfday.",";
|
$sql.= " ".$this->halfday.",";
|
||||||
$sql.= " '1',";
|
$sql.= " '1',";
|
||||||
$sql.= " '".$this->fk_validator."'";
|
$sql.= " '".$this->fk_validator."',";
|
||||||
|
$sql.= " '".$this->fk_type."',";
|
||||||
|
$sql.= " ".$user->id;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -150,7 +153,6 @@ class Holiday extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
|
$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
@ -200,7 +202,9 @@ class Holiday extends CommonObject
|
|||||||
$sql.= " cp.fk_user_cancel,";
|
$sql.= " cp.fk_user_cancel,";
|
||||||
$sql.= " cp.detail_refuse,";
|
$sql.= " cp.detail_refuse,";
|
||||||
$sql.= " cp.note_private,";
|
$sql.= " cp.note_private,";
|
||||||
$sql.= " cp.note_public";
|
$sql.= " cp.note_public,";
|
||||||
|
$sql.= " cp.fk_user_create,";
|
||||||
|
$sql.= " cp.fk_type";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp";
|
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp";
|
||||||
$sql.= " WHERE cp.rowid = ".$id;
|
$sql.= " WHERE cp.rowid = ".$id;
|
||||||
|
|
||||||
@ -234,6 +238,8 @@ class Holiday extends CommonObject
|
|||||||
$this->detail_refuse = $obj->detail_refuse;
|
$this->detail_refuse = $obj->detail_refuse;
|
||||||
$this->note_private = $obj->note_private;
|
$this->note_private = $obj->note_private;
|
||||||
$this->note_public = $obj->note_public;
|
$this->note_public = $obj->note_public;
|
||||||
|
$this->fk_user_create = $obj->fk_user_create;
|
||||||
|
$this->fk_type = $obj->fk_type;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
@ -1841,7 +1847,7 @@ class Holiday extends CommonObject
|
|||||||
{
|
{
|
||||||
while ($obj = $this->db->fetch_object($result))
|
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);
|
$types[$obj->rowid] = array('rowid'=> $obj->rowid, 'code'=> $obj->code, 'label'=>$obj->label, 'affect'=>$obj->affect, 'delay'=>$obj->delay, 'newByMonth'=>$obj->newByMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
|
|||||||
@ -127,6 +127,7 @@ ErrorMailNotSend=An error occurred while sending email:
|
|||||||
NoCPforMonth=No leave this month.
|
NoCPforMonth=No leave this month.
|
||||||
nbJours=Number days
|
nbJours=Number days
|
||||||
TitleAdminCP=Configuration of Leaves
|
TitleAdminCP=Configuration of Leaves
|
||||||
|
NoticePeriod=Notice period
|
||||||
#Messages
|
#Messages
|
||||||
Hello=Hello
|
Hello=Hello
|
||||||
HolidaysToValidate=Validate leave requests
|
HolidaysToValidate=Validate leave requests
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user