diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index 155bb564137..e8a059b84f8 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -162,7 +162,7 @@ if (empty($reshook)) {
$halfday = 1;
}
- $valideur = GETPOST('valideur', 'int');
+ $approverid = GETPOST('valideur', 'int');
$description = trim(GETPOST('description', 'restricthtml'));
// Check that leave is for a user inside the hierarchy or advanced permission for all is set
@@ -229,7 +229,7 @@ if (empty($reshook)) {
}
// If no validator designated
- if ($valideur < 1) {
+ if ($approverid < 1) {
setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors');
$error++;
}
@@ -239,7 +239,7 @@ if (empty($reshook)) {
if (!$error) {
$object->fk_user = $fuserid;
$object->description = $description;
- $object->fk_validator = $valideur;
+ $object->fk_validator = $approverid;
$object->fk_type = $type;
$object->date_debut = $date_debut;
$object->date_fin = $date_fin;
@@ -315,7 +315,7 @@ if (empty($reshook)) {
if ($object->statut == Holiday::STATUS_DRAFT) {
// If this is the requestor or has read/write rights
if ($cancreate) {
- $valideur = GETPOST('valideur', 'int');
+ $approverid = GETPOST('valideur', 'int');
$description = trim(GETPOST('description', 'restricthtml'));
// If no start date
@@ -337,7 +337,7 @@ if (empty($reshook)) {
}
// If no validator designated
- if ($valideur < 1) {
+ if ($approverid < 1) {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=Valideur');
exit;
}
@@ -352,7 +352,7 @@ if (empty($reshook)) {
$object->description = $description;
$object->date_debut = $date_debut;
$object->date_fin = $date_fin;
- $object->fk_validator = $valideur;
+ $object->fk_validator = $approverid;
$object->halfday = $halfday;
// Update
@@ -1100,8 +1100,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
if (($id > 0) || $ref) {
$result = $object->fetch($id, $ref);
- $valideur = new User($db);
- $valideur->fetch($object->fk_validator);
+ $approverexpected = new User($db);
+ $approverexpected->fetch($object->fk_validator);
$userRequest = new User($db);
$userRequest->fetch($object->fk_user);
@@ -1314,7 +1314,14 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
print $langs->trans('ReviewedByCP');
}
print '';
- print '
'.$valideur->getNomUrl(-1);
+ print ' | ';
+ if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) {
+ $approverdone = new User($db);
+ $approverdone->fetch($object->fk_user_valid);
+ print $approverdone->getNomUrl(-1);
+ } else {
+ print $approverexpected->getNomUrl(-1);
+ }
$include_users = $object->fetch_users_approver_holiday();
if (is_array($include_users) && in_array($user->id, $include_users) && $object->statut == Holiday::STATUS_VALIDATED) {
print 'id.'&action=editvalidator">'.img_edit($langs->trans("Edit")).'';
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index aab00e8f0b7..003ac79ede8 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -85,31 +85,42 @@ class Holiday extends CommonObject
public $statut = ''; // 1=draft, 2=validated, 3=approved
/**
- * @var int ID
+ * @var int ID of user that must approve. TODO: there is no date for validation (date_valid is used for approval), add one.
*/
public $fk_validator;
+ /**
+ * @var int Date of approval. TODO: Add a field for approval date and use date_valid instead for validation.
+ */
public $date_valid = '';
/**
- * @var int ID
+ * @var int ID of user that has approved (empty if not approved)
*/
public $fk_user_valid;
+
+ /**
+ * @var int Date for refuse
+ */
public $date_refuse = '';
/**
- * @var int ID
+ * @var int ID for refuse
*/
public $fk_user_refuse;
+ /**
+ * @var int Date for cancelation
+ */
public $date_cancel = '';
/**
- * @var int ID
+ * @var int ID for cancelation
*/
public $fk_user_cancel;
+
public $detail_refuse = '';
/**
@@ -2106,7 +2117,7 @@ class Holiday extends CommonObject
{
global $conf;
- $sql = "SELECT f.rowid,";
+ $sql = "SELECT f.rowid, f.statut as status,";
$sql .= " f.date_create as datec,";
$sql .= " f.tms as date_modification,";
$sql .= " f.date_valid as datev,";
@@ -2114,8 +2125,8 @@ class Holiday extends CommonObject
$sql .= " f.date_refuse as dater,";
$sql .= " f.fk_user_create as fk_user_creation,";
$sql .= " f.fk_user_modif as fk_user_modification,";
- $sql .= " f.fk_user_valid,";
- $sql .= " f.fk_validator as fk_user_approve,";
+ $sql .= " f.fk_user_valid as fk_user_approve_done,";
+ $sql .= " f.fk_validator as fk_user_approve_expected,";
$sql .= " f.fk_user_refuse as fk_user_refuse";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as f";
$sql .= " WHERE f.rowid = ".((int) $id);
@@ -2152,10 +2163,19 @@ class Holiday extends CommonObject
$muser->fetch($obj->fk_user_modification);
$this->user_modification = $muser;
}
- if ($obj->fk_user_approve) {
- $auser = new User($this->db);
- $auser->fetch($obj->fk_user_approve);
- $this->user_approve = $auser;
+
+ if ($obj->status == Holiday::STATUS_APPROVED || $obj->status == Holiday::STATUS_CANCELED) {
+ if ($obj->fk_user_approve_done) {
+ $auser = new User($this->db);
+ $auser->fetch($obj->fk_user_approve_done);
+ $this->user_approve = $auser;
+ }
+ } else {
+ if ($obj->fk_user_approve_expected) {
+ $auser = new User($this->db);
+ $auser->fetch($obj->fk_user_approve_expected);
+ $this->user_approve = $auser;
+ }
}
}
$this->db->free($resql);
|