Lock entry per user if has submitted timesheets

This commit is contained in:
Gerald Raab
2018-08-09 15:48:21 +02:00
parent a86111a803
commit 88cfc3265e
2 changed files with 50 additions and 1 deletions
+7 -1
View File
@@ -102,11 +102,16 @@ else
$activities_str = "'".implode("','", $activities)."'";
// definiert bis zu welchem Datum die Eintragung nicht mehr möglich ist
if (defined('CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS') && CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS != '')
$zasperre = new zeitaufzeichnung();
if ($sperrdat = $zasperre->getEintragungGesperrtBisForUser($user))
$gesperrt_bis = $sperrdat;
else if (defined('CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS') && CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS != '')
$gesperrt_bis = CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS;
else
$gesperrt_bis = '2015-08-31';
//var_dump($gesperrt_bis);
$sperrdatum = date('c', strtotime($gesperrt_bis));
// Uses urlencode to avoid XSS issues
@@ -1506,4 +1511,5 @@ function getZeitaufzeichnung($user, $von, $bis)
$za->getListeUserFromTo($user, $von, $bis);
return $za;
}
?>
+43
View File
@@ -742,5 +742,48 @@ or not exists
return $lehre_arr;
}
/**
* Holt das Datum bis zu dem die Eintragung für einen bestimmten User gesperrt ist
* @param string $user
* @return string $tag Y-m-d or false
*/
public function getEintragungGesperrtBisForUser($user)
{
//check if addon casetime is installed
$qrytable = "
SELECT EXISTS(
SELECT *
FROM information_schema.tables
WHERE
table_schema = 'addon' AND
table_name = 'tbl_casetime_timesheet'
);
";
$res = $this->db_query($qrytable);
if ($this->db_fetch_row($res)[0])
{
//check if sent timesheets for the UID exist
$where = "uid=".$this->db_add_param($user);
$qry = "select max(datum) from addon.tbl_casetime_timesheet where ".$where." and abgeschicktamum is not null";
if($result = $this->db_query($qry))
{
$datum = $this->db_fetch_object($result);
return $datum->max;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
?>