mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
Merge branch 'feature-17517/AdaptierungenZeiterfassungenSprint177'
This commit is contained in:
@@ -45,7 +45,7 @@ $uid = get_uid();
|
||||
|
||||
$PHP_SELF = $_SERVER['PHP_SELF'];
|
||||
|
||||
$typen_arr = array("Urlaub", "PflegeU", "ZA", "Krank", "DienstF", "DienstV");
|
||||
$typen_arr = array("Urlaub", "PflegeU", "ZA", "Krank", "DienstF", "DienstV", "CovidSB", "CovidKS");
|
||||
|
||||
if(isset($_GET['type']))
|
||||
$type=$_GET['type'];
|
||||
@@ -69,8 +69,8 @@ $datum_obj = new datum();
|
||||
$ma= new mitarbeiter();
|
||||
|
||||
// definiert bis zu welchem Datum die Eintragung nicht mehr möglich ist
|
||||
$zasperre = new zeitaufzeichnung();
|
||||
if ($sperrdat = $zasperre->getEintragungGesperrtBisForUser($uid))
|
||||
$zaufzeichnung = new zeitaufzeichnung();
|
||||
if ($sperrdat = $zaufzeichnung->getEintragungGesperrtBisForUser($uid))
|
||||
$gesperrt_bis = $sperrdat;
|
||||
else if (defined('CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS') && CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS != '')
|
||||
$gesperrt_bis = CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS;
|
||||
@@ -138,7 +138,15 @@ $( document ).ready(function()
|
||||
rows: 4,
|
||||
});
|
||||
|
||||
$("#vondatum").change(
|
||||
function()
|
||||
{
|
||||
$(".error").text("");
|
||||
}
|
||||
)
|
||||
|
||||
});
|
||||
|
||||
// set holidays function which is configured in beforeShowDay
|
||||
function setHoliDays(date) {
|
||||
for (i = 0; i < holiDays.length; i++) {
|
||||
@@ -302,7 +310,9 @@ function showHideStudeDropDown()
|
||||
|| dd.options[dd.selectedIndex].value == 'Urlaub'
|
||||
|| dd.options[dd.selectedIndex].value == 'Krank'
|
||||
|| dd.options[dd.selectedIndex].value == 'DienstF'
|
||||
|| dd.options[dd.selectedIndex].value == 'DienstV')
|
||||
|| dd.options[dd.selectedIndex].value == 'DienstV'
|
||||
|| dd.options[dd.selectedIndex].value == 'CovidSB'
|
||||
|| dd.options[dd.selectedIndex].value == 'CovidKS')
|
||||
{
|
||||
document.getElementById('vonStd').style.visibility = 'hidden';
|
||||
document.getElementById('bisStd').style.visibility = 'hidden';
|
||||
@@ -350,6 +360,40 @@ if(isset($_GET['type']) && ($_GET['type']=='edit_sperre' || $_GET['type']=='new_
|
||||
$error_msg .= $p->t('zeitsperre/bisDatumUngueltig').' ';
|
||||
}
|
||||
|
||||
//Prüfen auf vorhandene Zeitaufzeichnung
|
||||
if (isset($_POST['bisdatum']) && isset($_POST['vondatum'])
|
||||
&& $zaufzeichnung->existsZeitaufzeichnung($uid, $_POST['vondatum'], $_POST['bisdatum'])
|
||||
// Nur Zeitaufzeichnungsrelevante Typen sollen das speichern blockieren
|
||||
&& in_array($_POST['zeitsperretyp_kurzbz'], zeitsperre::getBlockierendeZeitsperren()))
|
||||
{
|
||||
$error = true;
|
||||
$error_msg .= $p->t('zeitsperre/zeitaufzeichnungVorhanden');
|
||||
}
|
||||
|
||||
//Prüfen auf vorhandene Zeitsperre
|
||||
if (isset($_POST['bisdatum']) && isset($_POST['vondatum'])
|
||||
&& in_array($_POST['zeitsperretyp_kurzbz'], zeitsperre::getBlockierendeZeitsperren()))
|
||||
{
|
||||
$von = $_POST['vondatum'];
|
||||
$von2 = new DateTime($von);
|
||||
$von2 = $von2->format('Y-m-d');
|
||||
$zeitsperre = new zeitsperre();
|
||||
|
||||
if ($zeitsperre->getSperreByDate($uid, $von2, null, zeitsperre::NUR_BLOCKIERENDE_ZEITSPERREN))
|
||||
{
|
||||
foreach ($zeitsperre->result as $z)
|
||||
{
|
||||
// Beim editieren nicht mit dem eigenen Eintrag kollidieren
|
||||
if($_GET['type'] == 'edit_sperre' && $z->zeitsperre_id == $_GET['id'])
|
||||
continue;
|
||||
|
||||
$typ = $z->zeitsperretyp_kurzbz;
|
||||
$error = true;
|
||||
$error_msg .= $p->t('zeitsperre/zeitsperreEingetragen', [$von, $typ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//von - bis-datum pruefen von darf nicht groesser als bis sein
|
||||
// 09.02.2009 simane
|
||||
$vondatum=0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,11 @@ $sprache_index = $sprache_obj->index;
|
||||
|
||||
$uid = get_uid();
|
||||
|
||||
$mitarbeiter = new mitarbeiter();
|
||||
$mitarbeiter->getUntergebene($uid, true);
|
||||
$untergebenen_arr = array();
|
||||
$untergebenen_arr = $mitarbeiter->untergebene;
|
||||
|
||||
//Wenn User Administrator ist und UID uebergeben wurde, dann die Zeitaufzeichnung
|
||||
//des uebergebenen Users anzeigen
|
||||
if (isset($_GET['uid']))
|
||||
@@ -55,7 +60,7 @@ if (isset($_GET['uid']))
|
||||
$rechte = new benutzerberechtigung();
|
||||
$rechte->getBerechtigungen($uid);
|
||||
|
||||
if ($rechte->isBerechtigt('admin'))
|
||||
if ($rechte->isBerechtigt('admin') || (in_array($_GET['uid'], $untergebenen_arr)))
|
||||
{
|
||||
$uid = $_GET['uid'];
|
||||
}
|
||||
@@ -74,9 +79,9 @@ $year = $_GET['projexpjahr'];
|
||||
|
||||
$monthtext = $monatsname[$sprache_index][$month - 1];
|
||||
$username = $benutzer->vorname." ".$benutzer->nachname;
|
||||
$mitarbeiter = new mitarbeiter();
|
||||
$mitarbeiter->load($uid);
|
||||
$persnr = $mitarbeiter->personalnummer;
|
||||
|
||||
$daysinmonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
||||
|
||||
$date = new datum();
|
||||
|
||||
@@ -27,12 +27,18 @@ require_once('../../../include/projektphase.class.php');
|
||||
require_once('../../../include/datum.class.php');
|
||||
require_once('../../../include/benutzerberechtigung.class.php');
|
||||
require_once('../../../include/phrasen.class.php');
|
||||
require_once('../../../include/mitarbeiter.class.php');
|
||||
|
||||
if (!$db = new basis_db())
|
||||
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
|
||||
|
||||
$user = get_uid();
|
||||
|
||||
$mitarbeiter = new mitarbeiter();
|
||||
$mitarbeiter->getUntergebene($user, true);
|
||||
$untergebenen_arr = array();
|
||||
$untergebenen_arr = $mitarbeiter->untergebene;
|
||||
|
||||
//Wenn User Administrator ist und UID uebergeben wurde, dann die Phasen
|
||||
//des uebergebenen Users anzeigen
|
||||
if (isset($_GET['uid']) && $user != $_GET['uid'])
|
||||
@@ -40,7 +46,7 @@ if (isset($_GET['uid']) && $user != $_GET['uid'])
|
||||
$rechte = new benutzerberechtigung();
|
||||
$rechte->getBerechtigungen($user);
|
||||
|
||||
if ($rechte->isBerechtigt('admin'))
|
||||
if ($rechte->isBerechtigt('admin') || (in_array($_GET['uid'], $untergebenen_arr)))
|
||||
{
|
||||
$user = $_GET['uid'];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Manuela Thamer <manuela.thamer@technikum-wien.at>
|
||||
*/
|
||||
/**
|
||||
* Checks, if there is a zeitsperre for a certain date. It should not be possible
|
||||
* to add a zeitaufzeichnung with a holiday (or else) entry on the same day.
|
||||
*/
|
||||
|
||||
|
||||
require_once('../../../config/cis.config.inc.php');
|
||||
require_once('../../../include/globals.inc.php');
|
||||
require_once('../../../include/phrasen.class.php');
|
||||
require_once('../../../include/benutzerberechtigung.class.php');
|
||||
require_once('../../../include/zeitsperre.class.php');
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
$sprache = getSprache();
|
||||
$p = new phrasen($sprache);
|
||||
|
||||
if ( isset($_GET['day']) )
|
||||
{
|
||||
$auth = new authentication();
|
||||
$uid = $auth->getUser();
|
||||
$day = $_GET['day'];
|
||||
|
||||
$zs = new zeitsperre();
|
||||
$sperreVorhanden = false;
|
||||
$typ = '';
|
||||
$zs->getSperreByDate($uid, $day, null, zeitsperre::NUR_BLOCKIERENDE_ZEITSPERREN);
|
||||
$result_obj = array();
|
||||
$now = new DateTime($day);
|
||||
$now = $now->format('d.m.Y');
|
||||
|
||||
foreach ($zs->result as $z)
|
||||
{
|
||||
if ($z->zeitsperretyp_kurzbz)
|
||||
{
|
||||
$item['typ'] = $z->zeitsperretyp_kurzbz;
|
||||
$item['day'] = $now;
|
||||
$item['sperreVorhanden'] = true;
|
||||
$result_obj[] = $item;
|
||||
}
|
||||
}
|
||||
echo json_encode($result_obj);
|
||||
} else {
|
||||
http_response_code(500);
|
||||
echo json_encode(array(
|
||||
array(
|
||||
"error" => 'missing parameter day'
|
||||
)
|
||||
));
|
||||
}
|
||||
@@ -1468,22 +1468,25 @@ class mitarbeiter extends benutzer
|
||||
$hasUDF = false;
|
||||
$udf = new UDF();
|
||||
|
||||
$qry = "SELECT DISTINCT ON(mitarbeiter_uid) *,
|
||||
tbl_benutzer.aktiv as aktiv,
|
||||
tbl_mitarbeiter.insertamum,
|
||||
tbl_mitarbeiter.insertvon,
|
||||
tbl_mitarbeiter.updateamum,
|
||||
tbl_mitarbeiter.updatevon";
|
||||
$qry = "SELECT
|
||||
*,
|
||||
tbl_benutzer.aktiv as aktiv,
|
||||
tbl_mitarbeiter.insertamum,
|
||||
tbl_mitarbeiter.insertvon,
|
||||
tbl_mitarbeiter.updateamum,
|
||||
tbl_mitarbeiter.updatevon";
|
||||
|
||||
if ($hasUDF = $udf->personHasUDF())
|
||||
{
|
||||
$qry .= ", public.tbl_person.udf_values AS p_udf_values";
|
||||
}
|
||||
|
||||
$qry .= " FROM ((public.tbl_mitarbeiter JOIN public.tbl_benutzer ON(mitarbeiter_uid=uid))
|
||||
JOIN public.tbl_person USING(person_id))
|
||||
LEFT JOIN public.tbl_benutzerfunktion USING(uid)
|
||||
WHERE uid in(".$this->db_implode4SQL($uid_arr).")";;
|
||||
$qry .= " FROM
|
||||
public.tbl_mitarbeiter
|
||||
JOIN public.tbl_benutzer ON(mitarbeiter_uid=uid)
|
||||
JOIN public.tbl_person USING(person_id)
|
||||
WHERE uid in(".$this->db_implode4SQL($uid_arr).")";
|
||||
$qry .= " ORDER BY nachname, vorname";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
|
||||
@@ -812,20 +812,141 @@ or not exists
|
||||
|
||||
$qry = "select max(datum) from addon.tbl_casetime_timesheet where ".$where." and abgeschicktamum is not null";
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
if ($result = $this->db_query($qry))
|
||||
{
|
||||
$datum = $this->db_fetch_object($result);
|
||||
return $datum->max;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob es für einen bestimmten User für einen bestimmten Tag eine Zeitaufzeichnung gibt
|
||||
* @param string $user Uid des zu prüfenden Users.
|
||||
* @param date $vonDay Startdatum des zu prüfenden Zeitraumes im Format d.m.Y.
|
||||
* @param date $bisDay Enddatum des zu prüfenden Zeitraumes im Format d.m.Y.
|
||||
* @return boolean true, wenn vorhanden, sonst false
|
||||
*/
|
||||
public function existsZeitaufzeichnung($user, $vonDay, $bisDay)
|
||||
{
|
||||
$datum = date($vonDay);
|
||||
$year = substr($datum, 6, 4);
|
||||
$month = substr($datum, 3, 2);
|
||||
$day = substr($datum, 0, 2);
|
||||
|
||||
$datumbisDay = date($bisDay);
|
||||
$yearbisDay = substr($datumbisDay, 6, 4);
|
||||
$monthbisDay = substr($datumbisDay, 3, 2);
|
||||
$daybisDay = substr($datumbisDay, 0, 2);
|
||||
|
||||
$bisDay = date("Y-m-d", (mktime(0, 0, 0, $monthbisDay, $daybisDay + 1, $yearbisDay)));
|
||||
$datum = date("Y-m-d", (mktime(0, 0, 0, $month, $day, $year)));
|
||||
|
||||
$qry = "
|
||||
SELECT *
|
||||
FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE uid = ". $this->db_add_param($user). "
|
||||
AND start >= ". $this->db_add_param($datum). "
|
||||
AND ende < ". $this->db_add_param($bisDay). ";
|
||||
";
|
||||
|
||||
if ($this->db_query($qry))
|
||||
{
|
||||
$num_rows = $this->db_num_rows();
|
||||
if ($num_rows >= 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Check, if there is a blocking PausenError
|
||||
*
|
||||
* @param string $uid User uid.
|
||||
* @param string $datumday Day to be check in the format "Y-m-d".
|
||||
* @return boolean True if there is a Pausen error.
|
||||
*/
|
||||
public function checkPausenErrors($uid, $datumday)
|
||||
{
|
||||
$tagesbeginn = '';
|
||||
$tagesende = '';
|
||||
$pausesumme = '00:00';
|
||||
$tagessaldo = '';
|
||||
$elsumme = '00:00';
|
||||
$pflichtpause = false;
|
||||
$blockingError = false;
|
||||
$datum = new datum();
|
||||
|
||||
$this->getListeUserFromTo($uid, $datumday, $datumday, null);
|
||||
|
||||
foreach ($this->result as $row)
|
||||
{
|
||||
$datumtag = $datum->formatDatum($row->datum, 'Y-m-d');
|
||||
|
||||
if (($tagesbeginn == '' || $datum->mktime_fromtimestamp($datum->formatDatum($tagesbeginn, $format = 'Y-m-d H:i:s')) > $datum->mktime_fromtimestamp($datum->formatDatum($row->start, $format = 'Y-m-d H:i:s'))) && $row->aktivitaet_kurzbz != 'LehreExtern' && $row->aktivitaet_kurzbz != 'Ersatzruhe')
|
||||
$tagesbeginn = $datum->formatDatum($row->start, 'H:i');
|
||||
|
||||
if (($tagesende == '' || $datum->mktime_fromtimestamp($datum->formatDatum($tagesende, $format = 'Y-m-d H:i:s')) < $datum->mktime_fromtimestamp($datum->formatDatum($row->ende, $format = 'Y-m-d H:i:s'))) && $row->aktivitaet_kurzbz != 'LehreExtern' && $row->aktivitaet_kurzbz != 'Ersatzruhe')
|
||||
$tagesende = $datum->formatDatum($row->ende, 'H:i');
|
||||
|
||||
if ($row->aktivitaet_kurzbz == "Pause")
|
||||
$pausesumme = $row->diff;
|
||||
}
|
||||
|
||||
$tagessaldo = $datum->mktime_fromtimestamp($datum->formatDatum($tagesende, $format = 'Y-m-d H:i:s')) - $datum->mktime_fromtimestamp($datum->formatDatum($tagesbeginn, $format = 'Y-m-d H:i:s')) - 3600;
|
||||
|
||||
list($h1, $m1) = explode(':', $pausesumme);
|
||||
$pausesumme = $h1 * 3600 + $m1 * 60;
|
||||
|
||||
list($h2, $m2) = explode(':', $elsumme);
|
||||
$elsumme = $h2 * 3600 + $m2 * 60;
|
||||
|
||||
|
||||
if ($datum->formatDatum($datumday, 'Y-m-d') >= '2019-11-06')
|
||||
{
|
||||
$pausesumme = $pausesumme;
|
||||
}
|
||||
elseif ($tagessaldo > 18000 && $tagessaldo < 19800 && $pflichtpause == false && $elsumme == 0)
|
||||
{
|
||||
$pausesumme = $tagessaldo - 18000;
|
||||
}
|
||||
elseif ($tagessaldo > 18000 && $pflichtpause == false && $elsumme == 0)
|
||||
{
|
||||
$pausesumme = $pausesumme + 1800;
|
||||
}
|
||||
|
||||
if ($elsumme > 0)
|
||||
{
|
||||
$pausesumme = $pausesumme + $elsumme;
|
||||
$pflichtpause = true;
|
||||
}
|
||||
|
||||
$tagessaldo = $tagessaldo - $pausesumme;
|
||||
|
||||
//check if blocking error
|
||||
if (($tagessaldo > 19800 && $pausesumme < 1800) || ($tagessaldo > 18000 && $tagessaldo < 19800 && $pausesumme < $tagessaldo - 18000))
|
||||
{
|
||||
$blockingError = true;
|
||||
}
|
||||
|
||||
return $blockingError;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
require_once('../../../include/datum.class.php');
|
||||
require_once('../../../include/projekt.class.php');
|
||||
require_once('../../../include/projektphase.class.php');
|
||||
require_once('../../../include/zeitaufzeichnung.class.php');
|
||||
|
||||
/**
|
||||
* Description of zeitaufzeichnung_import
|
||||
*
|
||||
* @author chris
|
||||
*/
|
||||
class zeitaufzeichnung_import {
|
||||
|
||||
protected $errors;
|
||||
protected $warnings;
|
||||
protected $infos;
|
||||
|
||||
protected $p;
|
||||
protected $datum;
|
||||
|
||||
protected $project;
|
||||
protected $phase;
|
||||
protected $limitdate;
|
||||
|
||||
protected $zeit;
|
||||
|
||||
|
||||
/**
|
||||
* @param phrasen $p The Translator object
|
||||
*/
|
||||
public function __construct($p) {
|
||||
$this->errors = [];
|
||||
$this->warnings = [];
|
||||
$this->infos = [];
|
||||
|
||||
$this->p = $p;
|
||||
$this->datum = new datum();
|
||||
|
||||
$this->project = new projekt();
|
||||
$this->phase = new projektphase();
|
||||
$this->limitdate = date('c', strtotime("+5 weeks"));
|
||||
|
||||
$this->zeit = new zeitaufzeichnung();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasErrors() {
|
||||
return !empty($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasWarnings() {
|
||||
return !empty($this->warnings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasInfos() {
|
||||
return !empty($this->infos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ErrorsToHTML() {
|
||||
$html = '';
|
||||
foreach ($this->errors as $msg) {
|
||||
$html .= '<span style="color:red;"><b>' . $msg . '</b></span><br>' . "\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function WarningsToHTML() {
|
||||
$html = '';
|
||||
foreach ($this->warnings as $msg) {
|
||||
$html .= '<span style="color:orange;"><b>' . $msg . '</b></span><br>' . "\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function InfosToHTML() {
|
||||
$html = '';
|
||||
foreach ($this->infos as $msg) {
|
||||
$html .= '<span style="color:green;"><b>' . $msg . '</b></span><br>' . "\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function OutputToHTML() {
|
||||
return $this->InfosToHTML() . $this->WarningsToHTML() . $this->ErrorsToHTML();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
protected function addError($msg) {
|
||||
$this->errors[] = $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
protected function addWarning($msg) {
|
||||
$this->warnings[] = $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
protected function addInfo($msg) {
|
||||
$this->infos[] = $msg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $uid The user id
|
||||
* @param string $day "Y-m-d" formatted datestring
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkZeitsperren($uid, $day) {
|
||||
$zs = new zeitsperre();
|
||||
|
||||
if (!$zs->getSperreByDate($uid, $day, null, zeitsperre::NUR_BLOCKIERENDE_ZEITSPERREN)) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ": Fehler beim Überprüfen der Zeitsperren");
|
||||
}
|
||||
|
||||
if (count($zs->result) !== 0) {
|
||||
$zsdate = new DateTime($day);
|
||||
$zsdate = $zsdate->format('d.m.Y');
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ": " . $this->p->t("zeitaufzeichnung/zeitsperreVorhanden", [$zsdate, $zs->result[0]->zeitsperretyp_kurzbz]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date datetimestring
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkLimitdatum($date) {
|
||||
if ($this->datum->formatDatum($date, 'Y-m-d H:i:s') > $this->limitdate) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Eingabe nicht möglich da (' . $date . ') zu weit in der Zukunft liegt.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start datestring
|
||||
* @param string $end datestring
|
||||
* @param string $aktivitaet_kurzbz
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkDienstreise($start, $end, $aktivitaet_kurzbz) {
|
||||
$startDate = $this->datum->formatDatum($start, 'Y-m-d');
|
||||
$endDate = $this->datum->formatDatum($end, 'Y-m-d');
|
||||
if ($startDate != $endDate && $aktivitaet_kurzbz != "DienstreiseMT") {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten")
|
||||
.': Eingabe nicht möglich, da keine Zeitaufzeichnung über mehrere Tage erlaubt ist (ausgenommen Dienstreisen).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $end timestring
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkTagesgenau($end) {
|
||||
$endTime = $this->datum->formatDatum($end, 'H:i:s');
|
||||
if ($endTime == '00:00:00') {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten")
|
||||
.': Bitte Arbeitszeiten gemäß Arbeitsaufzeichnung Leitfaden tagesgenau abgrenzen: Nur Eingaben von 00:00 bis 23:59 erlaubt!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $projekt_kurzbz
|
||||
* @param string $start datestring
|
||||
* @param string $end datestring
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkProjectInterval($projekt_kurzbz, $start, $end) {
|
||||
if (!$this->project->checkProjectInCorrectTime($projekt_kurzbz, $start, $end)) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Eingabe nicht möglich, da angegebenes Anfangs und Enddatum nicht in den Projektzeitrahmen fällt: (' . $start . ') (' . $end . ')');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $phase The Projektphase ID
|
||||
* @param string $start datestring
|
||||
* @param string $end datestring
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkPhaseInterval($phase, $start, $end) {
|
||||
if (!$this->phase->checkProjectphaseInCorrectTime($phase, $start, $end)) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Eingabe nicht möglich, da angegebenes Anfangs und Enddatum nicht in den Projektphasenzeitrahmen fällt: (' . $start . ') (' . $end . ')');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,435 @@
|
||||
<?php
|
||||
require_once('zeitaufzeichnung_import.class.php');
|
||||
require_once('../../../include/organisationseinheit.class.php');
|
||||
|
||||
/**
|
||||
* Description of zeitaufzeichnung_csv_import
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class zeitaufzeichnung_import_csv extends zeitaufzeichnung_import {
|
||||
|
||||
const USER = 0;
|
||||
const AKTIVITAET = 1;
|
||||
const STARTDT = 2;
|
||||
const ENDEDT = 3;
|
||||
const BESCHREIBUNG = 4;
|
||||
const OE = 5;
|
||||
const PROJEKT = 6;
|
||||
const PHASE = 7;
|
||||
const SERVICE = 8;
|
||||
const HOMEOFFICE = 9;
|
||||
const ANZAHL_PFLICHTFELDER = 4;
|
||||
|
||||
protected $tmpname;
|
||||
protected $fh;
|
||||
|
||||
protected $anzahl;
|
||||
protected $importtage_array;
|
||||
protected $ende_vorher;
|
||||
|
||||
protected $user;
|
||||
|
||||
protected $project_kurzbz_array;
|
||||
protected $projectphasen_kurzbz_array;
|
||||
|
||||
protected $sperrdatum;
|
||||
|
||||
protected $current_line;
|
||||
|
||||
protected $homeoffice;
|
||||
|
||||
|
||||
/**
|
||||
* @param phrasen $p The Translator object
|
||||
* @param string $user The user ID
|
||||
* @param string $sperrdatum "c" formatted datetimestring
|
||||
* @param string $filename
|
||||
*/
|
||||
public function __construct(phrasen $p, $user, $sperrdatum, $filename) {
|
||||
parent::__construct($p);
|
||||
|
||||
$this->user = $user;
|
||||
$this->tmpname = $filename;
|
||||
$this->sperrdatum = $sperrdatum;
|
||||
|
||||
$this->project_kurzbz_array = [];
|
||||
$projects = $this->project->getProjekteListForMitarbeiter($user);
|
||||
foreach ($projects as $pp)
|
||||
$this->project_kurzbz_array[] = (string) $pp->projekt_kurzbz;
|
||||
|
||||
$this->projectphasen_kurzbz_array = [];
|
||||
$projektphasen = $this->phase->getProjectphaseForMitarbeiter($user);
|
||||
foreach ($projektphasen as $pp)
|
||||
$this->projectphasen_kurzbz_array[] = (string) $pp->projektphase_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $msg
|
||||
* @param boolean $prepend_current_line
|
||||
* @return void
|
||||
*/
|
||||
protected function addError($msg, $prepend_current_line = false) {
|
||||
if( $prepend_current_line ) {
|
||||
$msg = 'Zeile ' . $this->current_line . ' - ' . $msg;
|
||||
}
|
||||
$this->errors[] = $msg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function import() {
|
||||
try {
|
||||
$this->checkMimeType();
|
||||
$this->openFileForReading();
|
||||
$this->checkEncoding();
|
||||
$this->iterateRows();
|
||||
$this->checkAndCleanup();
|
||||
} catch (Exception $ex) {
|
||||
$this->addError($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkMimeType() {
|
||||
$mimeType = mime_content_type($this->tmpname);
|
||||
if ($mimeType !== 'text/plain' ) {
|
||||
throw new Exception('Datei ist nicht im CSV Format.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function openFileForReading() {
|
||||
if (false === ($this->fh = fopen($this->tmpname, 'r')) )
|
||||
{
|
||||
throw new Exception('CSV - Datei konnte nicht zum lesen geöffnet werden.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkEncoding() {
|
||||
$filecontent = file_get_contents($this->tmpname);
|
||||
if (!mb_detect_encoding($filecontent, 'UTF-8', true) ) {
|
||||
throw new Exception('Datei konnte nicht importiert werden. Encoding ist nicht UTF-8!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function iterateRows() {
|
||||
set_time_limit(0);
|
||||
|
||||
$this->anzahl = 0;
|
||||
$this->importtage_array = array();
|
||||
$this->ende_vorher = date('Y-m-d H:i:s');
|
||||
|
||||
$data = null;
|
||||
$this->current_line = 0;
|
||||
while (($data = fgetcsv($this->fh, 1000, ';', '"')) !== FALSE) {
|
||||
if ((false !== strpos($data[self::USER], '#'))
|
||||
|| count($data) < self::ANZAHL_PFLICHTFELDER) {
|
||||
// ignore lines starting with #
|
||||
continue;
|
||||
}
|
||||
$this->current_line++;
|
||||
$this->processData($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function processData($data) {
|
||||
try {
|
||||
$this->checkUser($data[self::USER]);
|
||||
$this->initData($data);
|
||||
$this->checkProject($data[self::PROJEKT], $data[self::PHASE]);
|
||||
$this->checkPhase($data[self::PHASE]);
|
||||
|
||||
$this->checkZeitsperren($this->user, $this->datum->formatDatum($data[self::STARTDT], 'Y-m-d'));
|
||||
$this->checkSperrdatum($data[self::STARTDT]);
|
||||
$this->checkLimitdatum($data[self::STARTDT]);
|
||||
$this->checkDienstreise($data[self::STARTDT], $data[self::ENDEDT], $data[self::AKTIVITAET]);
|
||||
$this->checkTagesgenau($data[self::ENDEDT]);
|
||||
if(empty($data[self::PHASE]))
|
||||
$this->checkProjectInterval($data[self::PROJEKT], $data[self::STARTDT], $data[self::ENDEDT]);
|
||||
$this->checkPhaseInterval($data[self::PHASE], $data[self::STARTDT], $data[self::ENDEDT]);
|
||||
$this->checkVals($data[self::OE],$data[self::PROJEKT],$data[self::PHASE],$data[self::SERVICE]);
|
||||
$this->mapLehreIntern($data);
|
||||
$this->prepareZeitaufzeichnung($data);
|
||||
$this->checkImporttage($data[self::STARTDT]);
|
||||
$this->saveZeit($data[self::STARTDT], $data[self::ENDEDT]);
|
||||
} catch (Exception $ex) {
|
||||
$this->addError($ex->getMessage(), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user The User ID
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkUser($user) {
|
||||
if ($user !== $this->user || (strpos($user, '#') !== false))
|
||||
{
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten").': Falsche UID nicht importiert (' . $user . ')');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $project The Project ID or empty string
|
||||
* @param string $phase The Phase ID or empty string
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkProject($project, $phase) {
|
||||
if(!empty($project) && !in_array($project, $this->project_kurzbz_array) && empty($phase))
|
||||
{
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten").': Eingabe nicht möglich, da Sie folgendem Projekt entweder nicht zugewiesen sind oder das Projekt schon abgeschlossen wurde: (' . $project . ')');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $phase The Phase ID or empty string
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkPhase($phase) {
|
||||
if(!empty($phase) && !in_array($phase, $this->projectphasen_kurzbz_array))
|
||||
{
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten").': Eingabe nicht möglich, da Sie folgender Projektphase entweder nicht zugewiesen sind oder die Projektphase schon abgeschlossen wurde: (' . $phase . ')');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function initData(&$data) {
|
||||
foreach ([self::OE, self::PROJEKT, self::PHASE, self::SERVICE] as $key)
|
||||
if (!isset($data[$key]))
|
||||
$data[$key] = NULL;
|
||||
|
||||
if (!isset($data[self::HOMEOFFICE]))
|
||||
$data[$key] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start datetimestring
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkSperrdatum($start) {
|
||||
if ($this->datum->formatDatum($start, 'Y-m-d H:i:s') < $this->sperrdatum) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Eingabe nicht möglich da vor dem Sperrdatum (' . $start . ')');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $oe_val
|
||||
* @param string $project_val
|
||||
* @param string $phase_val
|
||||
* @param string $service_val
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkVals($oe_val, $project_val, $phase_val, $service_val) {
|
||||
$failedvals = $this->_checkVals($oe_val, $project_val, $phase_val, $service_val);
|
||||
if( count($failedvals) > 0 )
|
||||
{
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten").': Fehlerhafte Werte ('.implode(', ', $failedvals).')');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $oe_val
|
||||
* @param string $project_val
|
||||
* @param string $phase_val
|
||||
* @param string $service_val
|
||||
* @return array
|
||||
*/
|
||||
protected function _checkVals ($oe_val, $project_val, $phase_val, $service_val) {
|
||||
$error = [];
|
||||
if ($service_val && ( filter_var($service_val, FILTER_VALIDATE_INT) === false )) {
|
||||
$error[] = 'service';
|
||||
}
|
||||
if ($phase_val && ( filter_var($phase_val, FILTER_VALIDATE_INT) === false )) {
|
||||
$error[] = 'phase';
|
||||
}
|
||||
if ($oe_val) {
|
||||
$oecheck = new organisationseinheit($oe_val);
|
||||
if ($oecheck->errormsg) {
|
||||
$error[] = 'OE';
|
||||
}
|
||||
}
|
||||
if ($project_val) {
|
||||
$procheck = new projekt($project_val);
|
||||
if ($procheck->errormsg) {
|
||||
$error[] = 'projekt';
|
||||
}
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function mapLehreIntern(&$data) {
|
||||
if ($data[self::AKTIVITAET] == 'LehreIntern') {
|
||||
$data[self::AKTIVITAET] = 'Lehre';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareZeitaufzeichnung($data) {
|
||||
$this->zeit->new = true;
|
||||
$this->zeit->beschreibung = NULL;
|
||||
$this->zeit->oe_kurzbz_1 = NULL;
|
||||
$this->zeit->projekt_kurzbz = NULL;
|
||||
$this->zeit->projektphase_id = NULL;
|
||||
$this->zeit->service_id = NULL;
|
||||
|
||||
$this->zeit->insertamum = date('Y-m-d H:i:s');
|
||||
$this->zeit->updateamum = date('Y-m-d H:i:s');
|
||||
$this->zeit->updatevon = $this->user;
|
||||
$this->zeit->insertvon = $this->user;
|
||||
$this->zeit->uid = $data[self::USER];
|
||||
$this->zeit->aktivitaet_kurzbz = $data[self::AKTIVITAET];
|
||||
$this->zeit->start = $this->datum->formatDatum($data[self::STARTDT], 'Y-m-d H:i:s');
|
||||
$this->zeit->ende = $this->datum->formatDatum($data[self::ENDEDT], 'Y-m-d H:i:s');
|
||||
if (isset($data[self::BESCHREIBUNG])) {
|
||||
$this->zeit->beschreibung = $data[self::BESCHREIBUNG];
|
||||
}
|
||||
if (isset($data[self::OE])) {
|
||||
$this->zeit->oe_kurzbz_1 = $data[self::OE];
|
||||
}
|
||||
if (isset($data[self::PROJEKT])) {
|
||||
$this->zeit->projekt_kurzbz = $data[self::PROJEKT];
|
||||
}
|
||||
if (isset($data[self::PHASE])) {
|
||||
$this->zeit->projektphase_id = $data[self::PHASE];
|
||||
}
|
||||
if (isset($data[self::SERVICE])) {
|
||||
$this->zeit->service_id = $data[self::SERVICE];
|
||||
}
|
||||
$this->zeit->homeoffice = false;
|
||||
if (isset($data[self::HOMEOFFICE])) {
|
||||
$this->zeit->homeoffice = (strtolower($data[self::HOMEOFFICE]) == 'true');
|
||||
if (strtolower($data[self::HOMEOFFICE]) == 'true') {
|
||||
// check, ob homeoffice gemäß Bisverwendung
|
||||
$vonCSV = $this->datum->formatDatum($data[self::STARTDT], 'Y-m-d');
|
||||
$verwendung = new bisverwendung();
|
||||
$verwendung->getVerwendungDatum($data[self::USER], $vonCSV);
|
||||
|
||||
foreach ($verwendung->result as $v) {
|
||||
if ($v->homeoffice) {
|
||||
$this->zeit->homeoffice = true;
|
||||
} else {
|
||||
$this->addWarning($this->p->t("zeitaufzeichnung/homeofficeNichtErlaubt", [$vonCSV]));
|
||||
$this->zeit->homeoffice = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start datestring
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkImporttage($start) {
|
||||
$tag = $this->datum->formatDatum($start, 'Y-m-d');
|
||||
|
||||
if (!in_array($tag, $this->importtage_array)) {
|
||||
$this->importtage_array[] = $tag;
|
||||
$this->zeit->deleteEntriesForUser($this->user, $tag);
|
||||
} else if ($this->ende_vorher < $this->zeit->start) {
|
||||
$this->savePause();
|
||||
}
|
||||
|
||||
$this->ende_vorher = $this->zeit->ende;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function savePause() {
|
||||
$pause = new zeitaufzeichnung();
|
||||
$pause->new = true;
|
||||
$pause->insertamum = date('Y-m-d H:i:s');
|
||||
$pause->updateamum = date('Y-m-d H:i:s');
|
||||
$pause->updatevon = $this->user;
|
||||
$pause->insertvon = $this->user;
|
||||
$pause->uid = $this->user;
|
||||
$pause->aktivitaet_kurzbz = 'Pause';
|
||||
$pause->start = $this->ende_vorher;
|
||||
$pause->ende = $this->zeit->start;
|
||||
$pause->beschreibung = '';
|
||||
$pause->homeoffice = $this->zeit->homeoffice;
|
||||
if(!$pause->save())
|
||||
{
|
||||
$this->addError($this->p->t("global/fehlerBeimSpeichernDerDaten").': '.$pause->errormsg, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start datetimestring
|
||||
* @param string $end datetimestring
|
||||
* @return void
|
||||
*/
|
||||
protected function saveZeit($start, $end) {
|
||||
if ($start != $end) {
|
||||
if (!$this->zeit->save()) {
|
||||
$this->addError($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': ' . $this->zeit->errormsg . '(' . $this->zeit->start . ')', true);
|
||||
} else {
|
||||
$this->anzahl++;
|
||||
}
|
||||
} else {
|
||||
$this->anzahl++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function checkAndCleanup() {
|
||||
if ($this->anzahl > 0) {
|
||||
$this->addInfo($this->p->t("global/datenWurdenGespeichert") . ' (' . $this->anzahl . ')');
|
||||
foreach ($this->importtage_array as $ptag) {
|
||||
$this->zeit->cleanPausenForUser($this->user, $ptag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
require_once('zeitaufzeichnung_import.class.php');
|
||||
|
||||
/**
|
||||
* Description of zeitaufzeichnung_import_post
|
||||
*
|
||||
* @author chris
|
||||
*/
|
||||
class zeitaufzeichnung_import_post extends zeitaufzeichnung_import {
|
||||
|
||||
protected $datum;
|
||||
|
||||
protected $user;
|
||||
protected $edit;
|
||||
protected $data;
|
||||
|
||||
|
||||
/**
|
||||
* @param phrasen $p The Translator object
|
||||
* @param string $user The user ID
|
||||
* @param boolean $edit Edit or create a new one
|
||||
* @param array $data The array keys are:
|
||||
* - aktivitaet_kurzbz string
|
||||
* - beschreibung string
|
||||
* - bis datum
|
||||
* - bis_pause datum
|
||||
* - homeoffice boolean
|
||||
* - kunde_uid string ID
|
||||
* - oe_kurzbz_1 string
|
||||
* - oe_kurzbz_2 string
|
||||
* - projekt_kurzbz string
|
||||
* - projektphase_id string ID
|
||||
* - service_id string ID
|
||||
* - von datum
|
||||
* - von_pause datum
|
||||
* - zeitaufzeichnung_id string ID
|
||||
* @param string $filename
|
||||
*/
|
||||
public function __construct(phrasen $p, $user, $edit, $data) {
|
||||
parent::__construct($p);
|
||||
|
||||
$this->user = $user;
|
||||
$this->edit = $edit;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ErrorsToHTML() {
|
||||
$html = '';
|
||||
foreach ($this->errors as $msg) {
|
||||
$html .= '<span id="triggerPhasenReset" style="color:red;"><b>' . $msg . '</b></span><br>' . "\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function import() {
|
||||
try {
|
||||
$this->checkNew($this->data['zeitaufzeichnung_id']);
|
||||
$this->prepareZeitaufzeichnung($this->data['aktivitaet_kurzbz'], $this->data['von'], $this->data['bis'], $this->data['beschreibung'], $this->data['oe_kurzbz_1'], $this->data['oe_kurzbz_2'], $this->data['projekt_kurzbz'], $this->data['projektphase_id'], $this->data['homeoffice'], $this->data['service_id'], $this->data['kunde_uid']);
|
||||
$this->checkZeitsperren($this->user, $this->datum->formatDatum($this->data['von'], 'Y-m-d'));
|
||||
$this->checkProjectInterval($this->data['projekt_kurzbz'], $this->data['von'], $this->data['bis']);
|
||||
$this->checkLimitdatum($this->data['von']);
|
||||
$this->checkLimitdatum($this->data['bis']);
|
||||
$this->checkPhaseInterval($this->data['projektphase_id'], $this->data['von'], $this->data['bis']);
|
||||
$this->checkDienstreise($this->data['von'], $this->data['bis'], $this->data['aktivitaet_kurzbz']);
|
||||
$this->checkTagesgenau($this->data['bis']);
|
||||
$this->processPause($this->data['von_pause'], $this->data['bis_pause']);
|
||||
$this->saveZeit();
|
||||
} catch (Exception $ex) {
|
||||
$this->addError($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $zeitaufzeichnung_id
|
||||
* @return void
|
||||
*/
|
||||
protected function checkNew($zeitaufzeichnung_id) {
|
||||
if($this->edit) {
|
||||
if(!$this->zeit->load($zeitaufzeichnung_id))
|
||||
die($this->p->t("global/fehlerBeimLadenDesDatensatzes"));
|
||||
|
||||
$this->zeit->new = false;
|
||||
} else {
|
||||
$this->zeit->new = true;
|
||||
$this->zeit->insertamum = date('Y-m-d H:i:s');
|
||||
$this->zeit->insertvon = $this->user;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $aktivitaet_kurzbz
|
||||
* @param string $von datetime
|
||||
* @param string $bis datetime
|
||||
* @param string $beschreibung
|
||||
* @param string $oe_kurzbz_1
|
||||
* @param string $oe_kurzbz_2
|
||||
* @param string $projekt_kurzbz
|
||||
* @param string $projektphase_id
|
||||
* @param boolean $homeoffice
|
||||
* @param string $service_id
|
||||
* @param string $kunde_uid
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareZeitaufzeichnung($aktivitaet_kurzbz, $von, $bis, $beschreibung, $oe_kurzbz_1, $oe_kurzbz_2, $projekt_kurzbz, $projektphase_id, $homeoffice, $service_id, $kunde_uid) {
|
||||
$this->zeit->uid = $this->user;
|
||||
$this->zeit->aktivitaet_kurzbz = $aktivitaet_kurzbz;
|
||||
$this->zeit->start = $this->datum->formatDatum($von, 'Y-m-d H:i:s');
|
||||
$this->zeit->ende = $this->datum->formatDatum($bis, 'Y-m-d H:i:s');
|
||||
$this->zeit->beschreibung = $beschreibung;
|
||||
$this->zeit->oe_kurzbz_1 = $oe_kurzbz_1;
|
||||
$this->zeit->oe_kurzbz_2 = $oe_kurzbz_2;
|
||||
$this->zeit->updateamum = date('Y-m-d H:i:s');
|
||||
$this->zeit->updatevon = $this->user;
|
||||
$this->zeit->projekt_kurzbz = $projekt_kurzbz;
|
||||
$this->zeit->projektphase_id = $projektphase_id;
|
||||
$this->zeit->homeoffice = $homeoffice;
|
||||
$this->zeit->service_id = $service_id;
|
||||
$this->zeit->kunde_uid = $kunde_uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start datetime
|
||||
* @param string $end datetime
|
||||
* @return void
|
||||
*/
|
||||
protected function processPause($start, $end) {
|
||||
if (isset($_POST['genPause'])) {
|
||||
$p_start = $this->datum->formatDatum($start, 'Y-m-d H:i:s');
|
||||
$p_end = $this->datum->formatDatum($end, 'Y-m-d H:i:s');
|
||||
$this->checkPauseInArbeitszeit($p_start, $p_end);
|
||||
$this->checkPauseValid($p_start, $p_end);
|
||||
$this->savePause($start, $end);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start "Y-m-d H:i:s" formatted datetime
|
||||
* @param string $end "Y-m-d H:i:s" formatted datetime
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkPauseInArbeitszeit($start, $end) {
|
||||
if ($this->zeit->start > $start || $this->zeit->ende < $end) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Pause außerhalb der Arbeitszeit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start "Y-m-d H:i:s" formatted datetime
|
||||
* @param string $end "Y-m-d H:i:s" formatted datetime
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkPauseValid($start, $end) {
|
||||
if ($start > $end) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Fehlerhafte Pausenzeiten');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start datetime
|
||||
* @param string $end datetime
|
||||
* @return void
|
||||
*/
|
||||
protected function savePause($start, $end) {
|
||||
//Eintrag Arbeit bis zur Pause
|
||||
$ende = $this->zeit->ende;
|
||||
$this->zeit->ende = $this->datum->formatDatum($start, 'Y-m-d H:i:s');
|
||||
if (!$this->zeit->save()) {
|
||||
$this->addError($p->t("global/fehlerBeimSpeichernDerDaten") . ': ' . $this->zeit->errormsg);
|
||||
}
|
||||
//Eintrag für die Pause
|
||||
$pause = new zeitaufzeichnung();
|
||||
$pause->new = true;
|
||||
$pause->insertamum = date('Y-m-d H:i:s');
|
||||
$pause->updateamum = date('Y-m-d H:i:s');
|
||||
$pause->updatevon = $this->user;
|
||||
$pause->insertvon = $this->user;
|
||||
$pause->uid = $this->user;
|
||||
$pause->aktivitaet_kurzbz = 'Pause';
|
||||
$pause->homeoffice = $this->zeit->homeoffice;
|
||||
$pause->start = $this->datum->formatDatum($start, 'Y-m-d H:i:s');
|
||||
$pause->ende = $this->datum->formatDatum($end, 'Y-m-d H:i:s');
|
||||
$pause->beschreibung = '';
|
||||
if (!$pause->save()) {
|
||||
$this->addError($p->t("global/fehlerBeimSpeichernDerDaten") . ': ' . $pause->errormsg);
|
||||
}
|
||||
// Eintrag Arbeit ab der Pause
|
||||
if ($this->zeit->new == false) {
|
||||
$this->zeit->new = true;
|
||||
$this->zeit->insertamum = date('Y-m-d H:i:s');
|
||||
$this->zeit->insertvon = $this->user;
|
||||
}
|
||||
|
||||
$this->zeit->start = $this->datum->formatDatum($end, 'Y-m-d H:i:s');
|
||||
$this->zeit->ende = $ende;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function saveZeit() {
|
||||
if (!$this->zeit->save()) {
|
||||
throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': ' . $this->zeit->errormsg);
|
||||
} else if (!$this->hasErrors()) {
|
||||
$this->addInfo($this->p->t("global/datenWurdenGespeichert"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,9 @@ require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class zeitsperre extends basis_db
|
||||
{
|
||||
const NUR_BLOCKIERENDE_ZEITSPERREN = true;
|
||||
const BLOCKIERENDE_ZEITSPERREN = "'Krank','Urlaub','ZA','DienstV','PflegeU','DienstF','CovidSB','CovidKS'";
|
||||
|
||||
public $new; // boolean
|
||||
public $result = array(); // news Objekt
|
||||
|
||||
@@ -57,6 +60,11 @@ class zeitsperre extends basis_db
|
||||
$this->load($zeitsperre_id);
|
||||
}
|
||||
|
||||
public static function getBlockierendeZeitsperren()
|
||||
{
|
||||
return explode("','",trim(self::BLOCKIERENDE_ZEITSPERREN, '\''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Zeitsperren eines Benutzers wo ende>=now() ist
|
||||
* @param $uid
|
||||
@@ -368,11 +376,13 @@ class zeitsperre extends basis_db
|
||||
*
|
||||
* @param $user
|
||||
* @param $datum
|
||||
* @param $stunde
|
||||
* @param $stunde optional, wird nur abgefragt, wenn != null
|
||||
* @param $nurblockierend boolean default false
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getSperreByDate($user, $datum, $stunde)
|
||||
public function getSperreByDate($user, $datum, $stunde=null, $nurblockierend=false)
|
||||
{
|
||||
$this->result = array();
|
||||
$qry = "
|
||||
SELECT
|
||||
*
|
||||
@@ -380,16 +390,23 @@ class zeitsperre extends basis_db
|
||||
campus.tbl_zeitsperre
|
||||
WHERE
|
||||
vondatum<=".$this->db_add_param($datum)."
|
||||
AND bisdatum>=".$this->db_add_param($datum)." AND
|
||||
((vondatum=".$this->db_add_param($datum)." AND vonstunde<=".$this->db_add_param($stunde).") OR vonstunde is null OR vondatum<>".$this->db_add_param($datum).") AND
|
||||
((bisdatum=".$this->db_add_param($datum)." AND bisstunde>=".$this->db_add_param($stunde).") OR bisstunde is null OR bisdatum<>".$this->db_add_param($datum).") AND
|
||||
mitarbeiter_uid=".$this->db_add_param($user);
|
||||
AND bisdatum>=".$this->db_add_param($datum);
|
||||
|
||||
if( $nurblockierend ) {
|
||||
$qry .= " AND zeitsperretyp_kurzbz in (" . self::BLOCKIERENDE_ZEITSPERREN . ")";
|
||||
}
|
||||
|
||||
if(!is_null($stunde))
|
||||
$qry.=" AND
|
||||
((vondatum=".$this->db_add_param($datum)." AND vonstunde<=".$this->db_add_param($stunde).") OR vonstunde is null OR vondatum<>".$this->db_add_param($datum).") AND
|
||||
((bisdatum=".$this->db_add_param($datum)." AND bisstunde>=".$this->db_add_param($stunde).") OR bisstunde is null OR bisdatum<>".$this->db_add_param($datum).")";
|
||||
|
||||
$qry .= "AND mitarbeiter_uid=".$this->db_add_param($user);
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object($result))
|
||||
{
|
||||
|
||||
$obj = new zeitsperre();
|
||||
|
||||
$obj->zeitsperre_id = $row->zeitsperre_id;
|
||||
@@ -482,7 +499,7 @@ class zeitsperre extends basis_db
|
||||
|
||||
$qry = "select datum::date, freigabevon, zeitsperretyp_kurzbz
|
||||
from (SELECT generate_series(vondatum::timestamp, bisdatum::timestamp, '1 day') as datum, freigabevon, mitarbeiter_uid, zeitsperretyp_kurzbz FROM campus.tbl_zeitsperre where vonstunde is null and bisstunde is null) a
|
||||
where a.mitarbeiter_uid = ".$this->db_add_param($uid)." and datum>(now() - interval '".$anz_tage." Days') and zeitsperretyp_kurzbz in ('Krank','Urlaub', 'ZA', 'DienstV','PflegeU', 'DienstF','CovidSB','CovidKS')";
|
||||
where a.mitarbeiter_uid = ".$this->db_add_param($uid)." and datum>(now() - interval '".$anz_tage." Days') and zeitsperretyp_kurzbz in (" . self::BLOCKIERENDE_ZEITSPERREN . ")";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -65,3 +65,5 @@ $this->phrasen['zeitaufzeichnung/pauseEinfuegen']='Pause automatisch einfügen';
|
||||
$this->phrasen['zeitaufzeichnung/zeitraumZuKurz']='Zeitraum zu kurz für automatische Pause';
|
||||
$this->phrasen['zeitaufzeichnung/supportAnfragen']='<p><hr>Supportanfragen unter<br><a href="mailto:zeiterfassung@technikum-wien.at">zeiterfassung@technikum-wien.at</a></p>';
|
||||
$this->phrasen['zeitaufzeichnung/homeofficeNichtErlaubt']='Homeoffice für den Tag %s nicht erlaubt';
|
||||
$this->phrasen['zeitaufzeichnung/zeitsperreVorhanden']='Achtung: Für den Tag %s existiert eine ganztägige Zeitsperre vom Typ %s!';
|
||||
$this->phrasen['zeitaufzeichnung/zeitsperreVorhanden1']='Für diesen Tag ist bereits eine ganztägige Zeitsperre eingetragen!';
|
||||
|
||||
@@ -44,4 +44,7 @@ $this->phrasen['zeitsperre/legendeDurchwahl']='(123)...Durchwahl';
|
||||
$this->phrasen['zeitsperre/vertretungNichtKorrekt']='Die angegebene Vertretung kann nicht gefunden werden. Bitte prüfen Sie die Vertretung und versuchen Sie es erneut.';
|
||||
$this->phrasen['zeitsperre/vorSperrdatum']='Datum liegt vor dem Sperrdatum der Zeitliste';
|
||||
$this->phrasen['zeitsperre/abwesend']='Abwesend';
|
||||
$this->phrasen['zeitsperre/zeitaufzeichnungVorhanden']='Es existiert mindestens eine Zeitaufzeichnung im angegebenen Zeitraum.';
|
||||
$this->phrasen['zeitsperre/zeitsperreEingetragen']='Für den <strong>%s</strong> existiert bereits eine Zeitsperre vom Typ <strong>%s</strong>.
|
||||
Bitte löschen Sie diese bevor Sie eine neue für diesen Tag eintragen!';
|
||||
?>
|
||||
|
||||
@@ -65,3 +65,4 @@ $this->phrasen['zeitaufzeichnung/pauseEinfuegen']='insert break automatically';
|
||||
$this->phrasen['zeitaufzeichnung/zeitraumZuKurz']='Timeslot too short for automatic break.';
|
||||
$this->phrasen['zeitaufzeichnung/supportAnfragen']='<p><hr>Contact for support<br><a href="mailto:zeiterfassung@technikum-wien.at">zeiterfassung@technikum-wien.at</a></p>';
|
||||
$this->phrasen['zeitaufzeichnung/homeofficeNichtErlaubt']='Homeoffice for day %s not allowed';
|
||||
$this->phrasen['zeitaufzeichnung/zeitsperreVorhanden']='<p>Please note: There is a timeout for the day %s: %s!</p>';
|
||||
|
||||
@@ -44,4 +44,7 @@ $this->phrasen['zeitsperre/legendeDurchwahl']='(123)...Extension';
|
||||
$this->phrasen['zeitsperre/vertretungNichtKorrekt']='The selected substitute is invalid. Please check the substitute an try again.';
|
||||
$this->phrasen['zeitsperre/vorSperrdatum']='Date is before last open timesheet date';
|
||||
$this->phrasen['zeitsperre/abwesend']='absent';
|
||||
$this->phrasen['zeitsperre/zeitaufzeichnungVorhanden']='It exists at least one time record in the specified period.';
|
||||
$this->phrasen['zeitsperre/zeitsperreEingetragen']='There already exists an unavailability on the <strong>%s</strong> of the type <strong>%s</strong>.
|
||||
Please delete the existing before creating a new one for this date!';
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user