diff --git a/htdocs/compta/hrm.php b/htdocs/compta/hrm.php
index 4122f850723..d4639947529 100644
--- a/htdocs/compta/hrm.php
+++ b/htdocs/compta/hrm.php
@@ -140,7 +140,82 @@ $max=10;
$langs->load("boxes");
-// Last trips
+
+
+// Last expense report (new module)
+if (! empty($conf->holiday->enabled) && $user->rights->holiday->read)
+{
+ $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
+ $sql.= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
+ $sql.= " WHERE u.rowid = x.fk_user";
+ $sql.= " AND x.entity = ".$conf->entity;
+ if (empty($user->rights->holiday->read_all)) $sql.=' AND x.fk_user IN ('.join(',',$childids).')';
+ //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+ //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
+ $sql.= $db->order("x.tms","DESC");
+ $sql.= $db->plimit($max, 0);
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $var=false;
+ $num = $db->num_rows($result);
+
+ $holidaystatic=new Holiday($db);
+ $userstatic=new User($db);
+
+ $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));
+ $typeleaves=$holidaystatic->getTypes(1,-1);
+
+ $i = 0;
+
+ print '
';
+ print '';
+ print '| '.$langs->trans("BoxTitleLastLeaveRequests",min($max,$num)).' | ';
+ print ''.$langs->trans("from").' | ';
+ print ''.$langs->trans("to").' | ';
+ print ''.$langs->trans("DateModificationShort").' | ';
+ print ' | ';
+ print '
';
+ if ($num)
+ {
+ while ($i < $num && $i < $max)
+ {
+ $obj = $db->fetch_object($result);
+ $holidaystatic->id=$obj->rowid;
+ $holidaystatic->ref=$obj->ref;
+ $userstatic->id=$obj->uid;
+ $userstatic->lastname=$obj->lastname;
+ $userstatic->firstname=$obj->firstname;
+ print '';
+ print '| '.$holidaystatic->getNomUrl(1).' | ';
+ print ''.$userstatic->getNomUrl(1).' | ';
+ print ''.$typeleaves[$obj->fk_type]['label'].' | ';
+
+ $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning';
+ $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon';
+
+ print ''.dol_print_date($obj->date_start,'day').' '.$langs->trans($listhalfday[$endhalfday]);
+ print ' | '.dol_print_date($obj->date_end,'day').' '.$langs->trans($listhalfday[$endhalfday]);
+ print ' | '.dol_print_date($db->jdate($obj->dm),'day').' | ';
+ print ''.$holidaystatic->LibStatut($obj->status,3).' | ';
+ print '
';
+ $var=!$var;
+ $i++;
+ }
+
+ }
+ else
+ {
+ print '| '.$langs->trans("None").' |
';
+ }
+ print '
';
+ }
+ else dol_print_error($db);
+}
+
+
+// Last expense report (old module)
if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
{
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut";
@@ -204,6 +279,7 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
else dol_print_error($db);
}
+// Last expense report (new module)
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
{
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index 80d06fdb446..608c2af1b24 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -84,7 +84,7 @@ if ($action == 'create')
$description = trim(GETPOST('description'));
$userID = GETPOST('userID');
- // If no start date
+ // If no type
if ($type <= 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
@@ -136,12 +136,6 @@ if ($action == 'create')
$result = 0;
- if ($type < 1)
- {
- setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Type")), null, 'errors');
- $error++;
- }
-
if (! $error)
{
$cp->fk_user = $userid;
@@ -769,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']);
@@ -806,7 +800,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
print '';
print '| '.$langs->trans("Type").' | ';
print '';
- $typeleaves=$cp->getTypes(1,1);
+ $typeleaves=$cp->getTypes(1,-1);
$arraytypeleaves=array();
foreach($typeleaves as $key => $val)
{
@@ -1019,7 +1013,7 @@ else
print ' |
';
print '| '.$langs->trans("Type").' | ';
print '';
- $typeleaves=$cp->getTypes(1,1);
+ $typeleaves=$cp->getTypes(1,-1);
print $typeleaves[$cp->fk_type]['label'];
print ' | ';
print '
';
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index 6bb253319e0..21c36574ea9 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -732,6 +732,16 @@ class Holiday extends CommonObject
if ($statut == 4) return img_picto($langs->trans('CancelCP'),'statut5').' '.$langs->trans('CancelCP');
if ($statut == 5) return img_picto($langs->trans('RefuseCP'),'statut5').' '.$langs->trans('RefuseCP');
}
+ if ($mode == 3)
+ {
+ $pictoapproved='statut6';
+ if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4';
+ if ($statut == 1) return img_picto($langs->trans('DraftCP'),'statut0');
+ if ($statut == 2) return img_picto($langs->trans('ToReviewCP'),'statut1');
+ if ($statut == 3) return img_picto($langs->trans('ApprovedCP'),$pictoapproved);
+ if ($statut == 4) return img_picto($langs->trans('CancelCP'),'statut5');
+ if ($statut == 5) return img_picto($langs->trans('RefuseCP'),'statut5');
+ }
if ($mode == 5)
{
$pictoapproved='statut6';
@@ -1795,7 +1805,7 @@ class Holiday extends CommonObject
* Return array with list of types
*
* @param int $active Status of type
- * @param int $affect Filter on affect
+ * @param int $affect Filter on affect (a request will change sold or not)
* @return array Return array with list of types
*/
function getTypes($active=-1, $affect=-1)
diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php
index 1c82288973e..87b442c4531 100644
--- a/htdocs/holiday/list.php
+++ b/htdocs/holiday/list.php
@@ -102,6 +102,9 @@ $holiday = new Holiday($db);
$holidaystatic=new Holiday($db);
$fuser = new User($db);
+$childids = $user->getAllChildIds();
+$childids[]=$user->id;
+
// Update sold
$result = $holiday->updateBalance();
@@ -184,6 +187,7 @@ if (!empty($sall))
$filter.= natural_search(array_keys($fieldstosearchall), $sall);
}
+if (empty($user->rights->holiday->read_all)) $filter.=' AND cp.fk_user IN ('.join(',',$childids).')';
/*************************************
* Fin des filtres de recherche
diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
index 5e53d259376..80759ffe9d8 100755
--- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
+++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
@@ -573,3 +573,5 @@ insert into llx_c_chargesociales (id, libelle, deductible, active, code, fk_pays
ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN doc_ref varchar(255) NOT NULL;
+ALTER TABLE llx_holiday ADD COLUMN tms timestamp;
+ALTER TABLE llx_holiday ADD COLUMN entity integer DEFAULT 1 NOT NULL;
diff --git a/htdocs/install/mysql/tables/llx_holiday.sql b/htdocs/install/mysql/tables/llx_holiday.sql
index 3f61b893bd4..0af8b35b041 100644
--- a/htdocs/install/mysql/tables/llx_holiday.sql
+++ b/htdocs/install/mysql/tables/llx_holiday.sql
@@ -19,6 +19,7 @@
CREATE TABLE llx_holiday
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
+entity integer DEFAULT 1 NOT NULL, -- Multi company id
fk_user integer NOT NULL,
fk_user_create integer,
fk_type integer NOT NULL,
@@ -26,7 +27,7 @@ date_create DATETIME NOT NULL,
description VARCHAR( 255 ) NOT NULL,
date_debut DATE NOT NULL,
date_fin DATE NOT NULL,
-halfday integer DEFAULT 0,
+halfday integer DEFAULT 0, -- 0=start morning and end afternoon, -1=start afternoon end afternoon, 1=start morning and end morning, 2=start afternoon and end morning
statut integer NOT NULL DEFAULT '1',
fk_validator integer NOT NULL,
date_valid DATETIME DEFAULT NULL,
@@ -37,6 +38,7 @@ date_cancel DATETIME DEFAULT NULL,
fk_user_cancel integer DEFAULT NULL,
detail_refuse varchar( 250 ) DEFAULT NULL,
note_private text,
-note_public text
+note_public text,
+tms timestamp
)
ENGINE=innodb;
diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang
index 725336d8790..4b8c9507b92 100644
--- a/htdocs/langs/en_US/holiday.lang
+++ b/htdocs/langs/en_US/holiday.lang
@@ -82,6 +82,7 @@ UserName=Name
Employee=Employee
FirstDayOfHoliday=First day of vacation
LastDayOfHoliday=Last day of vacation
+BoxTitleLastLeaveRequests=Last %s modified leave requests
HolidaysMonthlyUpdate=Monthly update
ManualUpdate=Manual update
HolidaysCancelation=Leave request cancelation