diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index fd03045b2..62756fd78 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -605,9 +605,14 @@ echo ' { projphasenhtml += "'; + echo ''; } echo ''; } diff --git a/cis/private/tools/zeitaufzeichnung_projektphasen.php b/cis/private/tools/zeitaufzeichnung_projektphasen.php index 053f38b91..05df74443 100644 --- a/cis/private/tools/zeitaufzeichnung_projektphasen.php +++ b/cis/private/tools/zeitaufzeichnung_projektphasen.php @@ -86,6 +86,7 @@ if (isset($_GET['projekt_kurzbz'])) $item['bezeichnung'] = $row->bezeichnung; $item['start'] = $datum_obj->formatDatum($row->start, 'd.m.Y'); $item['ende'] = $datum_obj->formatDatum($row->ende, 'd.m.Y'); + $item['zeitaufzeichnung_erlaubt'] = $row->zeitaufzeichnung; $result_obj[] = $item; } } diff --git a/include/projektphase.class.php b/include/projektphase.class.php index 19bd85d6d..4e3c38b7c 100644 --- a/include/projektphase.class.php +++ b/include/projektphase.class.php @@ -829,5 +829,39 @@ class projektphase extends basis_db return false; } } + + /** + * Gibt zurück, ob für eine Projektphase Zeitaufzeichnungsbuchung erlaubt ist + * @param $projektphase_id die zu überprüfende Projektphase + * @return boolean true, wenn Buchung erlaubt + */ + public function getPhasenZA($projektphase_id) + { + $qry = " + SELECT + fue.tbl_projektphase.zeitaufzeichnung + FROM + fue.tbl_projektphase + WHERE + tbl_projektphase.projektphase_id = ".$this->db_add_param($projektphase_id); + + if ($this->db_query($qry)) + { + if ($row = $this->db_fetch_object()) + { + return $row->zeitaufzeichnung; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } } ?> diff --git a/include/zeitaufzeichnung_import.class.php b/include/zeitaufzeichnung_import.class.php index e8e6a8b15..2b4913341 100644 --- a/include/zeitaufzeichnung_import.class.php +++ b/include/zeitaufzeichnung_import.class.php @@ -21,7 +21,7 @@ class zeitaufzeichnung_import { protected $project; protected $phase; protected $limitdate; - + protected $zeit; @@ -42,7 +42,7 @@ class zeitaufzeichnung_import { $this->zeit = new zeitaufzeichnung(); } - + /** * @return boolean @@ -64,7 +64,7 @@ class zeitaufzeichnung_import { public function hasInfos() { return !empty($this->infos); } - + /** * @return string */ @@ -96,15 +96,15 @@ class zeitaufzeichnung_import { $html .= '' . $msg . '
' . "\n"; } return $html; - } - + } + /** * @return string */ public function OutputToHTML() { return $this->InfosToHTML() . $this->WarningsToHTML() . $this->ErrorsToHTML(); - } - + } + /** * @param string $msg * @return void @@ -112,7 +112,7 @@ class zeitaufzeichnung_import { protected function addError($msg) { $this->errors[] = $msg; } - + /** * @param string $msg * @return void @@ -120,7 +120,7 @@ class zeitaufzeichnung_import { protected function addWarning($msg) { $this->warnings[] = $msg; } - + /** * @param string $msg * @return void @@ -134,7 +134,7 @@ class zeitaufzeichnung_import { * @param string $uid The user id * @param string $day "Y-m-d" formatted datestring * @return void - * + * * @throws Exception */ protected function checkZeitsperren($uid, $day) { @@ -150,25 +150,25 @@ class zeitaufzeichnung_import { 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) { @@ -179,11 +179,11 @@ class zeitaufzeichnung_import { .': 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) { @@ -193,13 +193,13 @@ class zeitaufzeichnung_import { .': 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) { @@ -207,13 +207,13 @@ class zeitaufzeichnung_import { 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) { @@ -222,4 +222,33 @@ class zeitaufzeichnung_import { } } + /** + * @param string $phase The Projektphase ID + * @return void + * + * @throws Exception + */ +protected function checkPhaseBebuchbar($phase) +{ + if ($this->phase->getPhasenZA($phase) == 'f') + { + throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Dieses Arbeitspaket darf nicht bebucht werden!'); + } +} + +/** +* @param string $phase The Projektphase ID +* @return void +* +* @throws Exception +*/ +protected function checkIfArbeitspaketZuWaehlen($projekt_kurzbz, $phase) +{ + $this->project->load($projekt_kurzbz); + if (!$this->project->zeitaufzeichnung && !$phase) + { + throw new Exception($this->p->t("global/fehlerBeimSpeichernDerDaten") . ': Bitte ein Arbeitspaket wählen!'); + } +} + } diff --git a/include/zeitaufzeichnung_import_csv.class.php b/include/zeitaufzeichnung_import_csv.class.php index 27a240e45..8a8e8bb2f 100644 --- a/include/zeitaufzeichnung_import_csv.class.php +++ b/include/zeitaufzeichnung_import_csv.class.php @@ -163,7 +163,8 @@ class zeitaufzeichnung_import_csv extends zeitaufzeichnung_import { $this->initData($data); $this->checkProject($data[self::PROJEKT], $data[self::PHASE]); $this->checkPhase($data[self::PHASE]); - + $this->checkPhaseBebuchbar($data[self::PHASE]); + $this->checkIfArbeitspaketZuWaehlen($data[self::PROJEKT], $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]); diff --git a/include/zeitaufzeichnung_import_post.class.php b/include/zeitaufzeichnung_import_post.class.php index a6a59376e..ded9344fb 100644 --- a/include/zeitaufzeichnung_import_post.class.php +++ b/include/zeitaufzeichnung_import_post.class.php @@ -72,6 +72,8 @@ class zeitaufzeichnung_import_post extends zeitaufzeichnung_import { $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->checkPhaseBebuchbar($this->data['projektphase_id']); + $this->checkIfArbeitspaketZuWaehlen($this->data['projekt_kurzbz'], $this->data['projektphase_id']); $this->saveZeit(); } catch (Exception $ex) { $this->addError($ex->getMessage());