diff --git a/Stundenzettel.class.php b/Stundenzettel.class.php index ab305376d816b15705f81b0ec7cc4057b85b89e5..d86ddc402681a1cd37b16e6cdde518e29ef57a0d 100644 --- a/Stundenzettel.class.php +++ b/Stundenzettel.class.php @@ -42,27 +42,27 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin $item = new Navigation($this->_('Stundenzettel verwalten'), PluginEngine::getURL($this, array(), 'timesheet/admin_index')); $navigation->addSubNavigation('timesheets', $item); - - Navigation::addItem('contents/stundenzettelverwaltung', $navigation); + + Navigation::addItem('contents/stundenzettelverwaltung', $navigation); } - + private function setupStundenzettelNavigation() { $navigation = new Navigation($this->_('Stundenzettel')); $navigation->setURL(PluginEngine::getURL($this, array(), 'timesheet/timesheet')); - + $item = new Navigation($this->_('Stundenerfassung'), PluginEngine::getURL($this, array(), 'timesheet/timesheet')); $navigation->addSubNavigation('timetracking', $item); - + $item = new Navigation($this->_('Alle Stundenzettel verwalten'), PluginEngine::getURL($this, array(), 'timesheet')); $navigation->addSubNavigation('timesheets', $item); - + $item = new Navigation($this->_('Vertragsübersicht'), PluginEngine::getURL($this, array(), 'index')); $navigation->addSubNavigation('index', $item); - Navigation::addItem('contents/stundenzettelverwaltung', $navigation); + Navigation::addItem('contents/stundenzettelverwaltung', $navigation); } - + private function setupSupervisorNavigation() { $navigation = new Navigation($this->_('Stundenzettelverwaltung')); @@ -74,9 +74,9 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin $item = new Navigation($this->_('Stundenzettel verwalten'), PluginEngine::getURL($this, array(), 'timesheet/admin_index')); $navigation->addSubNavigation('timesheets', $item); - Navigation::addItem('contents/stundenzettelverwaltung', $navigation); + Navigation::addItem('contents/stundenzettelverwaltung', $navigation); } - + public function getCommentOptions () { return array( @@ -85,23 +85,23 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin 'Feiertag' => $this->_('Feiertag') ); } - + public function getMonths () { return array('01', '02','03','04','05','06','07','08','09','10','11','12'); } - + public function getYears () { return array( '2020', '2021','2022','2023','2024','2025','2026','2027'); } - + public function hasStumiAdminrole () { return RolePersistence::isAssignedRole($GLOBALS['user']->user_id, \Stundenzettelverwaltung\STUNDENVERWALTUNG_ROLE); } - - public function getAdminInstIds () + + public function getAdminInstIds () { $roles = RolePersistence::getAllRoles(); foreach($roles as $role) { @@ -113,22 +113,22 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin //keine leeren Einträge return array_filter($inst_ids); } - - public function isInstAdmin($inst_id) + + public function isInstAdmin($inst_id) { return in_array($inst_id, self::getAdminInstIds () ); } - + public function hasStumiContract () { return StundenzettelContract::findByUser_id($GLOBALS['user']->user_id); } - + public function isStumiSupervisor () { return StundenzettelContract::findBySupervisor($GLOBALS['user']->user_id); } - + public function vacationEntitelment($user_id, $inst_id, $year) { $contracts = StundenzettelContract::get_user_inst_contracts_in_year($user_id, $inst_id, $year); //$contract_month_in_year = 12; @@ -136,7 +136,7 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin $months_with_contract = []; //falls die bestehenden Verträge weniger als 6 Monate diesen Jahres abdecken, besteht nur monatsweise Urlaubsanspruch // andernfalls besteht voller Urlaubsanspruch - + //für jeden Monat den Urlaubsanspruch aus laufenden Verträgen dieser Einrichtung addieren for ($i = 1; $i<= 12; $i++) { foreach ($contracts as $contract){ @@ -147,7 +147,7 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin } } $total_months_with_contract = sizeof(array_unique($months_with_contract)); - + //bei mehr als 6 Monaten Vertrag im Jahr ergibt sich ein Urlaubsanspruch für vertragsfreie Monate if (12 > $total_months_with_contract && $total_months_with_contract >= 6) { for ($i = 1; $i<= 12; $i++) { @@ -165,16 +165,16 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin // $entitlement_hours += 1; // $entitlement_minutes = 0; // } - + return sprintf("%02s:%02s", $entitlement_hours, round($entitlement_minutes)) ; //round($entitlement_minutes, 3) } - - + + //TODO Berechnung nach Jahr bei mehreren Verträgen public function remainingVacation($user_id, $inst_id, $year) { //$contracts = get_user_inst_contracts_in_year($user_id, $inst_id, $year); $remaining_vacation = 0; - + foreach($contracts as $contract) { $claimed_vacation = $contract->getClaimedVacation($year); //Urlaub der mit Resturlaub aus dem Vorjahr verrechnet werden kann wird in diesem Jahr nicht abgezogen @@ -212,7 +212,7 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin return $remaining_vacation; } - + //TODO gehört in die Models public function can_access_contract_timesheets($contract_id) { @@ -223,9 +223,9 @@ class Stundenzettel extends StudipPlugin implements SystemPlugin return false; } } - + //TODO gehört in die Models - public function can_access_timesheet($timesheet_id) + public function can_access_timesheet($timesheet_id) { $timesheet = StundenzettelTimesheet::find($timesheet_id); return self::can_access_contract_timesheets($timesheet->contract_id); diff --git a/controllers/index.php b/controllers/index.php index 2a740dc3060b9f4a04724443df41f7750d108096..86b0584b4491958873e4c8736b970f2e61334627 100644 --- a/controllers/index.php +++ b/controllers/index.php @@ -6,12 +6,12 @@ class IndexController extends PluginController { { parent::before_filter($action, $args); PageLayout::setTitle($this->_("Studentische MitarbeiterInnen - Übersicht")); - + // Check permissions to be on this site if ( !($this->plugin->hasStumiAdminrole() || $this->plugin->hasStumiContract () || $this->plugin->isStumiSupervisor()) ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + if ($this->plugin->hasStumiAdminrole ()) { $this->adminrole = true; } @@ -21,7 +21,7 @@ class IndexController extends PluginController { if ($this->plugin->isStumiSupervisor ()) { $this->supervisorrole = true; } - + $this->balance_pattern = '^(-{0,1})([0-9]{1,3}):[0-5][0-9]$'; } @@ -32,20 +32,20 @@ class IndexController extends PluginController { $user = User::findCurrent(); if ($this->adminrole) { - + $this->search = Request::get('search_user')? Request::get('search_user') : ''; $search_user = new SearchWidget($this->link_for('index')); $search_user->setTitle($this->_('Nutzer suchen')); - + $search_user->addNeedle($this->_('Name'), 'search_user', true, null, null, $this->search); Sidebar::get()->addWidget($search_user); - + $actions = new ActionsWidget(); - + //get institutes for the admin-user $this->inst_ids = $this->plugin->getAdminInstIds(); $this->inst_data = array(); - + //get all stumis and contracts foreach ($this->inst_ids as $inst_id) { $institute = Institute::find($inst_id); @@ -54,10 +54,10 @@ class IndexController extends PluginController { PluginEngine::getUrl($this->plugin, [], 'index/csv_export/' . $inst_id), Icon::create('share', 'new'), ['title' => $this->_('Schreibt alle verfügbaren Vertragsdaten in eine csv Datei welche z.B. mit Excel geöffnet werden kann.')] - ); + ); } Sidebar::Get()->addWidget($actions); - + //get all stumis and contracts $user_ids = []; //use later to identify former stumis foreach ($this->inst_ids as $inst_id) { @@ -82,18 +82,18 @@ class IndexController extends PluginController { $former_stumi = User::find($old_contract->user_id); if ((!in_array($old_contract->user_id, $user_ids)) && (!$this->search || strpos(strtolower($former_stumi->username . ' ' . $former_stumi->vorname . ' ' . $former_stumi->nachname), strtolower($this->search)))) { $this->inst_data[$inst_id][0]->stumis[] = $former_stumi; - $this->inst_data[$inst_id][0]->stumi_contracts[$former_stumi->user_id] = StundenzettelContract::findBySQL('`user_id` = ? AND `inst_id` = ?', [$former_stumi->user_id, $inst_id]); - $user_ids[] = $former_stumi->user_id; + $this->inst_data[$inst_id][0]->stumi_contracts[$former_stumi->user_id] = StundenzettelContract::findBySQL('`user_id` = ? AND `inst_id` = ?', [$former_stumi->user_id, $inst_id]); + $user_ids[] = $former_stumi->user_id; } } if (sizeof($this->inst_data[$inst_id][0]->stumis) > 0){ - array_push($this->groups[$inst_id], 0); + array_push($this->groups[$inst_id], 0); } } } - + if ($this->supervisorrole) { - + //get stumis for this user $stumi_contracts = StundenzettelContract::findBySupervisor(User::findCurrent()->user_id); $this->user_ids = []; @@ -103,10 +103,10 @@ class IndexController extends PluginController { $this->stumis[] = User::find($contract->user_id); $this->stumi_contracts[$contract->user_id] = StundenzettelContract::findBySQL('`user_id` = ? AND `supervisor` = ?', [$contract->user_id, User::findCurrent()->user_id]); } - } - + } + } - + if ($this->stumirole) { $this->stumi = User::find($GLOBALS['user']->user_id); @@ -115,39 +115,39 @@ class IndexController extends PluginController { if(!in_array($inst_id, $this->inst_id)){ $this->inst_id[] = $inst_id; } - } - } + } + } } - - - + + + public function new_action($inst_id, $user_id) - { + { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + $this->inst_id = $inst_id; $this->stumi = User::find($user_id); - + $this->search = QuickSearch::get('user_id', new StandardSearch('user_id')) ->withButton(array('search_button_name' => 'search_user', 'reset_button_name' => 'reset_search')) ->render(); - + } - + public function edit_action($contract_id, $following_contract = NULL) - { + { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + $this->contract = StundenzettelContract::find($contract_id); $this->inst_id = $this->contract->inst_id; $this->stumi = $this->contract->stumi; $supervisor = User::find($this->contract->supervisor); $this->following_contract = $following_contract; - + $this->search = QuickSearch::get('user_id', new StandardSearch('user_id')) ->defaultValue($this->contract->supervisor, $supervisor->vorname . ' ' . $supervisor->nachname) ->withButton(array('search_button_name' => 'search_user', 'reset_button_name' => 'reset_search')) @@ -155,19 +155,19 @@ class IndexController extends PluginController { $this->render_action('new'); } - + public function add_contract_begin_data_action($contract_id) - { + { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + $this->contract = StundenzettelContract::find($contract_id); $this->stumi = User::find($this->contract->user_id); } - + public function save_action($inst_id, $user_id, $contract_id = NULL) - { + { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } @@ -186,113 +186,113 @@ class IndexController extends PluginController { $contract->contract_begin = strtotime(Request::get('begin')); $contract->contract_end = strtotime(Request::get('end')); $contract->contract_hours = Request::get('hours'); - $contract->supervisor = Request::get('user_id'); + $contract->supervisor = Request::get('user_id'); $contract->store(); - //TODO + //TODO $contract->reassign_mismatched_timesheets_from_existing_contracts(); - PageLayout::postMessage(MessageBox::success($message)); - + PageLayout::postMessage(MessageBox::success($message)); + $this->redirect('index/'); } - + public function delete_action($contract_id) - { + { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + $contract = StundenzettelContract::find($contract_id); - + if($contract->delete()){ - PageLayout::postMessage(MessageBox::success($this->_("Vertrag gelöscht"))); - + PageLayout::postMessage(MessageBox::success($this->_("Vertrag gelöscht"))); + } else { - PageLayout::postMessage(MessageBox::error($this->_("Vertrag konnte nicht gelöscht werden"))); + PageLayout::postMessage(MessageBox::error($this->_("Vertrag konnte nicht gelöscht werden"))); } - + $this->redirect('index/'); } - + public function save_contract_begin_data_action($contract_id) - { + { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + $contract = StundenzettelContract::find($contract_id); - + $contract->begin_digital_recording_month = Request::get('begin_month'); $contract->begin_digital_recording_year = Request::get('begin_year'); $contract->begin_vacation_claimed = StundenzettelTimesheet::stundenzettel_strtotimespan(Request::get('vacation_claimed')); $contract->begin_balance = StundenzettelTimesheet::stundenzettel_strtotimespan(Request::get('balance')); $contract->last_year_vacation_remaining = StundenzettelTimesheet::stundenzettel_strtotimespan(Request::get('begin_last_year_vacation_remainig')); - + if($contract->store()){ - PageLayout::postMessage(MessageBox::success($this->_("Vertragsdaten gespeichert"))); + PageLayout::postMessage(MessageBox::success($this->_("Vertragsdaten gespeichert"))); } else { - PageLayout::postMessage(MessageBox::error($this->_("Daten konnten nicht gespeichert werden"))); + PageLayout::postMessage(MessageBox::error($this->_("Daten konnten nicht gespeichert werden"))); } - + $this->redirect('index/'); - + } - + public function edit_institute_settings_action($inst_id) { if ( !$this->plugin->isInstAdmin($inst_id) ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } $this->groups = Statusgruppen::findByRange_ID($inst_id); - + $settings = StundenzettelInstituteSetting::find($inst_id); if ($settings) { $this->stumi_group_ids = $settings->hilfskraft_statusgruppen; $this->inst_mail = $settings->inst_mail; } - + $this->inst_id = $inst_id; - + } - + public function save_institute_settings_action($inst_id) { if ( !$this->plugin->isInstAdmin($inst_id)) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } $settings = StundenzettelInstituteSetting::find($inst_id); - + if (!$settings ){ $settings = new StundenzettelInstituteSetting($inst_id); } - + $settings->inst_mail = Request::get('email'); $settings->hilfskraft_statusgruppen = implode(',', Request::getArray('statusgruppen')); - + if($settings->store()){ - PageLayout::postMessage(MessageBox::success($this->_("Konfiguration gespeichert"))); + PageLayout::postMessage(MessageBox::success($this->_("Konfiguration gespeichert"))); } else { - PageLayout::postMessage(MessageBox::error($this->_("Daten konnten nicht gespeichert werden"))); + PageLayout::postMessage(MessageBox::error($this->_("Daten konnten nicht gespeichert werden"))); } - - $this->redirect('index/'); + + $this->redirect('index/'); } - + public function mail_action($user_id){ $user = User::find($user_id); $this->empfaengermail = $user->email; $this->empfaenger = sprintf('%s %s', $user->vorname, $user->nachname); } - + public function send_form_action($empfaenger_mail){ - + if ( !$this->adminrole && !$this->supervisorrole) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + if (Request::get('message_body')){ $mailtext = Studip\Markup::purifyHtml(Request::get('message_body')); $betreff = '[' . $this->_('Stundenzettel') . '] ' . Studip\Markup::purifyHtml(Request::get('message_subject')); @@ -304,9 +304,9 @@ class IndexController extends PluginController { ->setSenderName( User::findCurrent()->vorname . ' ' . User::findCurrent()->nachname ) ->setSubject($betreff) ->setBodyHtml($mailtext) - ->setBodyHtml(strip_tags($mailtext)) + ->setBodyHtml(strip_tags($mailtext)) ->send(); - + } if ($success){ $message = MessageBox::success($this->_('eMail wurde versendet! Eine Kopie ging in CC an Sie..')); PageLayout::postMessage($message); @@ -317,9 +317,9 @@ class IndexController extends PluginController { $this->response->add_header('X-Dialog-Close', '1'); $this->redirect('timesheet/admin_index'); } - + public function csv_export_action($inst_id){ - + //get all stumis and contracts for $inst_id $settings = StundenzettelInstituteSetting::find($inst_id); if ($settings) { @@ -348,7 +348,7 @@ class IndexController extends PluginController { } } } - + $captions = [$this->_("Nachname"), $this->_("Vorname"), $this->_("Vertragsbeginn"), @@ -361,16 +361,16 @@ class IndexController extends PluginController { $this->_("Urlaubsanspruch"), $this->_("Resturlaub zu Jahresbeginn"), $this->_("Verantwortlicher MA")]; - + $tmpname = md5(uniqid('tmp')); $export_data = $this->export_data; - + // $fp = fopen('php://temp', 'r+'); // $fp2 = fopen('php://temp', 'r+'); -// +// // foreach ($export_data as $row) { // fputcsv($fp, $row, "'", ""); -// +// // rewind($fp); // $csv = stream_get_contents($fp); // fwrite($fp2, $csv); @@ -380,14 +380,14 @@ class IndexController extends PluginController { // fclose($fp); // rewind($fp2); // file_put_contents($tmpname, $fp2); -// +// // $this->redirect( // FileManager::getDownloadURLForTemporaryFile( // $tmpname, // 'vertragsdaten-export.csv' // ) // ); -// +// // var_dump(array2csv($export_data));die(); if (array_to_csv($export_data, $GLOBALS['TMP_PATH'] . '/' . $tmpname, $captions, ";")) { $this->redirect( @@ -397,8 +397,8 @@ class IndexController extends PluginController { ) ); } - + } - - + + } diff --git a/controllers/timesheet.php b/controllers/timesheet.php index fd58918c790dc22e095cd2620b6d70d734ac2346..9e63f1b85788b3dacc29c835fd9b8f540d9ff612 100644 --- a/controllers/timesheet.php +++ b/controllers/timesheet.php @@ -6,12 +6,12 @@ class TimesheetController extends PluginController { { parent::before_filter($action, $args); PageLayout::setTitle($this->_("Stundenzettel verwalten")); - + // Check permissions to be on this site if ( !($this->plugin->hasStumiAdminrole() || $this->plugin->hasStumiContract () || $this->plugin->isStumiSupervisor()) ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung.")); } - + if ($this->plugin->hasStumiAdminrole ()) { $this->adminrole = true; } @@ -21,7 +21,7 @@ class TimesheetController extends PluginController { if ($this->plugin->isStumiSupervisor ()) { $this->supervisorrole = true; } - + $this->time_end_pattern = '^(23:00)|([01]{0,1}[6-9]|[1][0-9]|2[0-2]):[0-5][0-9]$'; $this->time_begin_pattern = '^([01]{0,1}[6-9]|[1][0-9]|2[0-2]):[0-5][0-9]$'; $this->break_pattern = '^([0-9]{1,2}):[0-5][0-9]$'; @@ -30,37 +30,37 @@ class TimesheetController extends PluginController { public function index_action($contract_id = NULL) { Navigation::activateItem('contents/stundenzettelverwaltung/timesheets'); - + if (Request::get('contract_select')){ $contract_id = Request::get('contract_select'); } - + //allgemeine Stundenzettel-Übersichtsseite für Stumis verwendet automatisch den aktuell laufenden Vertrag if (!$contract_id && $this->stumirole) { $contract_id = StundenzettelContract::getCurrentContractId($GLOBALS['user']->user_id); if (!$contract_id) { $contract_id = StundenzettelContract::getSomeContractId($GLOBALS['user']->user_id); } - } + } $this->contract = StundenzettelContract::find($contract_id); - + $this->stumi_contracts = StundenzettelContract::findByUser_id($GLOBALS['user']->user_id); foreach($this->stumi_contracts as $contract){ if(!in_array($inst_id, $this->inst_id)){ $this->inst_id[] = $inst_id; } - } - + } + if (!$this->contract){ throw new AccessDeniedException($this->_("Kein aktiver Vertrag gefunden.")); } else if (!$this->contract->can_read(User::findCurrent())){ throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung.")); } - $this->timesheets = StundenzettelTimesheet::findByContract_id($contract_id, 'ORDER by `year` ASC, `month` ASC'); + $this->timesheets = StundenzettelTimesheet::findByContract_id($contract_id, 'ORDER by `year` ASC, `month` ASC'); $this->stumi = User::find($this->contract->user_id); - + $this->records = StundenzettelRecord::findByTimesheet_Id($timesheet_id, 'ORDER BY day ASC'); - + $this->status_infos = StundenzettelContract::getStatus_array(); } @@ -77,22 +77,22 @@ class TimesheetController extends PluginController { $this->month = strftime('%m', strtotime("-1 month")); $this->year = strftime('%Y', strtotime("-1 month")); } - + $this->contracts = StundenzettelContract::getContractsByMonth($this->month, $this->year); - + foreach ($this->contracts as $contract) { $this->timesheets[$contract->id] = StundenzettelTimesheet::getContractTimesheet($contract->id, $this->month, $this->year); } - + $this->status_infos = StundenzettelContract::getStatus_array(); } - + public function select_action($contract_id, $month = '', $year = '') { if ( !($this->adminrole || $this->plugin->can_access_contract_timesheets($contract_id))) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + Navigation::activateItem('contents/stundenzettelverwaltung/timesheets'); if (Request::get('month')) { $month = Request::get('month'); @@ -110,7 +110,7 @@ class TimesheetController extends PluginController { $timesheet->store(); $this->redirect('timesheet/timesheet/' . $timesheet->id); } else { - PageLayout::postMessage(MessageBox::error(sprintf($this->_("Dieser Monat liegt außerhalb des Vertragszeitraums (%s-%s) oder außerhalb des digital zu erfassenden Zeitraums."), date('d.m.Y',$contract->contract_begin), date('d.m.Y',$contract->contract_end)))); + PageLayout::postMessage(MessageBox::error(sprintf($this->_("Dieser Monat liegt außerhalb des Vertragszeitraums (%s-%s) oder außerhalb des digital zu erfassenden Zeitraums."), date('d.m.Y',$contract->contract_begin), date('d.m.Y',$contract->contract_end)))); $this->no_timesheet = true; $this->month = $month; $this->year = $year; @@ -118,30 +118,30 @@ class TimesheetController extends PluginController { $this->render_action('timesheet'); } } else if (!$this->timesheet && $this->adminrole){ - PageLayout::postMessage(MessageBox::error($this->_("Für diesen Monat liegt kein Stundenzettel vor."))); + PageLayout::postMessage(MessageBox::error($this->_("Für diesen Monat liegt kein Stundenzettel vor."))); $this->render_action('timesheet'); } else { $this->redirect('timesheet/timesheet/' . $this->timesheet->id); } - + } - - + + public function timesheet_action($timesheet_id = NULL) { if ( ($timesheet_id) && !($this->adminrole || $this->plugin->can_access_timesheet($timesheet_id))) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + if ($this->stumirole){ Navigation::activateItem('contents/stundenzettelverwaltung/timetracking'); } else { Navigation::activateItem('contents/stundenzettelverwaltung/timesheets'); } - + $sidebar = Sidebar::Get(); //Sidebar::Get()->setTitle($this->_('Stundenzettel von ') . $GLOBALS['user']->username); - + if(!$timesheet_id && $this->stumirole){ $contract_id = StundenzettelContract::getCurrentContractId($GLOBALS['user']->user_id); //$timesheet = StundenzettelTimesheet::getContractTimesheet($contract_id, date('m'), date('Y')); @@ -152,24 +152,24 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/select/' . $contract_id . '/' . date('m') . '/' . date('Y')); } - $this->timesheet = StundenzettelTimesheet::find($timesheet_id); - $this->days_per_month = cal_days_in_month(CAL_GREGORIAN, $this->timesheet->month, $this->timesheet->year); + $this->timesheet = StundenzettelTimesheet::find($timesheet_id); + $this->days_per_month = cal_days_in_month(CAL_GREGORIAN, $this->timesheet->month, $this->timesheet->year); $this->inst_id = $this->timesheet->contract->inst_id; $this->user_id = $this->timesheet->contract->user_id; $this->records = StundenzettelRecord::findByTimesheet_Id($timesheet_id, 'ORDER BY day ASC'); - + if($this->timesheet->locked && $this->stumirole) { PageLayout::postMessage(MessageBox::info($this->_("Der Stundenzettel wurde bereits eingereicht und kann nicht mehr bearbeitet werden. Sollten Änderungen nötig sein, kontaktiere deine/n zuständigen Ansprechpartner/in."))); } else if(($this->supervisorrole || $this->adminrole) && !$this->timesheet->finished) { PageLayout::postMessage(MessageBox::info($this->_("Digitaler Stundenzettel wurde noch nicht eingereicht."))); } else if ($this->timesheet->finished && !$this->adminrole){ - PageLayout::postMessage(MessageBox::info($this->_("Bearbeitung gesperrt. Sie sind nicht berechtigt Änderungen vorzunehmen"))); - } - + PageLayout::postMessage(MessageBox::info($this->_("Bearbeitung gesperrt. Sie sind nicht berechtigt Änderungen vorzunehmen"))); + } + if($this->stumirole){ $actions = new ActionsWidget(); $actions->setTitle('Aktionen'); - + if (!$this->timesheet->finished) { $actions->addLink( $this->_('Stundenzettel einreichen'), @@ -199,19 +199,19 @@ class TimesheetController extends PluginController { } } - - + + public function save_timesheet_action($timesheet_id) { - + $timesheet = StundenzettelTimesheet::find($timesheet_id); if ( !($timesheet->can_edit(User::findCurrent())) && !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + //überflüssige Zeile? if (!$timesheet->locked || $this->adminrole) { - + $record_ids_array = Request::getArray('record_id'); $begin_array = Request::getArray('begin'); $end_array = Request::getArray('end'); @@ -234,7 +234,7 @@ class TimesheetController extends PluginController { if ($begin_array[$i]) { $record->begin = strtotime($record->getDate() . ' ' . $begin_array[$i]); if ($record->begin < strtotime($record->getDate() . ' 06:00') ){ - PageLayout::postMessage(MessageBox::error(sprintf($this->_("Arbeitszeit kann frühestens ab 6 Uhr erfasst werden: %s.%s"), $record->day, $timesheet->month ))); + PageLayout::postMessage(MessageBox::error(sprintf($this->_("Arbeitszeit kann frühestens ab 6 Uhr erfasst werden: %s.%s"), $record->day, $timesheet->month ))); $errors = true; } } else if ($record->begin){ @@ -243,7 +243,7 @@ class TimesheetController extends PluginController { if ($end_array[$i]) { $record->end = strtotime($record->getDate() . ' ' . $end_array[$i]); if ($record->end > strtotime($record->getDate() . ' 23:00') ){ - PageLayout::postMessage(MessageBox::error(sprintf($this->_("Arbeitszeit kann bis maximal 23 Uhr erfasst werden: %s.%s"), $record->day, $timesheet->month ))); + PageLayout::postMessage(MessageBox::error(sprintf($this->_("Arbeitszeit kann bis maximal 23 Uhr erfasst werden: %s.%s"), $record->day, $timesheet->month ))); $errors = true; } } else if ($record->end){ @@ -263,53 +263,53 @@ class TimesheetController extends PluginController { $record->calculate_sum(); } if ($record->sum < 0) { - PageLayout::postMessage(MessageBox::error(sprintf($this->_("Gesamtsumme der Arbeitszeit pro Tag muss positiv sein: %s.%s"), $record->day, $timesheet->month ))); - $errors = true; + PageLayout::postMessage(MessageBox::error(sprintf($this->_("Gesamtsumme der Arbeitszeit pro Tag muss positiv sein: %s.%s"), $record->day, $timesheet->month ))); + $errors = true; } else if ($record->sum > (10*3600)) { - PageLayout::postMessage(MessageBox::error(sprintf($this->_("Die tägliche Arbeitszeit darf 10 Stunden nicht überschreiten: %s.%s"), $record->day, $timesheet->month ))); - $errors = true; + PageLayout::postMessage(MessageBox::error(sprintf($this->_("Die tägliche Arbeitszeit darf 10 Stunden nicht überschreiten: %s.%s"), $record->day, $timesheet->month ))); + $errors = true; } else if ($record->sum && ($record->sum > (9*3600)) && ($record->break < 2700)){ PageLayout::postMessage(MessageBox::error(sprintf($this->_("Bei einer Arbeitszeit von mehr als neun Stunden ist eine Pause von mindestens 45 Minuten gesetzlich vorgeschrieben: %s.%s"), $record->day, $timesheet->month ))); - $errors = true; + $errors = true; } else if ($record->sum && ($record->sum > (6*3600)) && ($record->break < 1800)){ PageLayout::postMessage(MessageBox::error(sprintf($this->_("Bei einer Arbeitszeit von mehr als sechs Stunden ist eine Pause von mindestens 30 Minuten gesetzlich vorgeschrieben: %s.%s"), $record->day, $timesheet->month ))); - $errors = true; - } + $errors = true; + } if ($record->sum && !$record->entry_mktime) { PageLayout::postMessage(MessageBox::error(sprintf($this->_("fehlende Angabe -Aufgezeichnet am- für den %s.%s"), $record->day, $timesheet->month ))); - $errors = true; + $errors = true; } - + if (!$errors){ $record->store(); } - + } $timesheet = $record->timesheet; $timesheet->calculate_sum(); - PageLayout::postMessage(MessageBox::success($this->_("Änderungen gespeichert."))); + PageLayout::postMessage(MessageBox::success($this->_("Änderungen gespeichert."))); $this->redirect('timesheet/timesheet/' . $timesheet_id); - + } else { - PageLayout::postMessage(MessageBox::success($this->_("Speichern nicht möglich. Bearbeitung ist gesperrt."))); + PageLayout::postMessage(MessageBox::success($this->_("Speichern nicht möglich. Bearbeitung ist gesperrt."))); $this->redirect('timesheet/timesheet/' . $timesheet_id); } } - + public function pdf_action($timesheet_id) { - + $timesheet = StundenzettelTimesheet::find($timesheet_id); if ( !($timesheet->contract->user_id == User::findCurrent()->user_id)) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + if (!$timesheet->finished) { throw new AccessDeniedException($this->_("Stundenzettel wurde noch nicht eingereicht!")); } - + if($timesheet){ $timesheet->build_pdf(); $this->render_nothing(); @@ -318,14 +318,14 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/index'); } } - + public function send_action($timesheet_id) { $timesheet = StundenzettelTimesheet::find($timesheet_id); if ( !($timesheet->contract->user_id == User::findCurrent()->user_id)) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + if($timesheet){ $timesheet->finished = true; $timesheet->store(); @@ -337,14 +337,14 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/index'); } } - + public function unlock_action($timesheet_id) { $timesheet = StundenzettelTimesheet::find($timesheet_id); if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + //sämtliche Bestätigungsvorgänge verlieren Gültgkeit, wenn der Stundenzettel zur Veränderung durch Hilfskraft freigegeben wird if($timesheet){ $timesheet->finished = false; @@ -359,15 +359,15 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/index'); } } - + public function approve_action($timesheet_id) { $timesheet = StundenzettelTimesheet::find($timesheet_id); - + if ( !($timesheet->contract->supervisor == User::findCurrent()->user_id)) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + if($timesheet && User::findCurrent()->user_id == $timesheet->contract->supervisor){ $timesheet->approved = true; $timesheet->store(); @@ -378,17 +378,17 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/index'); } } - + public function received_action($timesheet_id) { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + $timesheet = StundenzettelTimesheet::find($timesheet_id); if($timesheet && $this->adminrole){ //toggle status - $timesheet->received = (($timesheet->getCurrentState('received', 'admin') == 'true') ? false : true); + $timesheet->received = (($timesheet->getCurrentState('received', 'admin') == 'true') ? false : true); $timesheet->store(); if ($timesheet->getCurrentState('received', 'admin') == 'true') { PageLayout::postMessage(MessageBox::success($this->_("Vorliegen in Papierform bestätigt: ") . htmlready($timesheet->contract->stumi->nachname) . '/' . strftime('%B', strtotime("2020-" . $timesheet->month . "-01") )) ); @@ -401,17 +401,17 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/index'); } } - + public function complete_action($timesheet_id) { if ( !$this->adminrole ) { throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); } - + $timesheet = StundenzettelTimesheet::find($timesheet_id); if($timesheet && $this->adminrole){ //toggle status - $timesheet->complete = (($timesheet->getCurrentState('complete', 'admin') == 'true') ? false : true); + $timesheet->complete = (($timesheet->getCurrentState('complete', 'admin') == 'true') ? false : true); $timesheet->store(); //TODO echte booleans if ($timesheet->getCurrentState('complete', 'admin') == 'true') { @@ -425,5 +425,5 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/index'); } } - + } diff --git a/cronjobs/ReminderEmail.php b/cronjobs/ReminderEmail.php index be6f357872ee150b7934ef67575c71ddf3296542..b8cf0611b11a5684527e9b2ff747dbfae37c4c60 100644 --- a/cronjobs/ReminderEmail.php +++ b/cronjobs/ReminderEmail.php @@ -32,9 +32,9 @@ class ReminderEmail extends CronJob $contracts = StundenzettelContract::getContractsByMonth($month, $year); foreach ($contracts as $contract) { - + $no_recording_required = ($contract->begin_digital_recording_year == $year) && ($month < $contract->begin_digital_recording_month); - + if (!$no_recording_required){ $timesheet = StundenzettelTimesheet::getContractTimesheet($contract->id, $month, $year); if (!$timesheet) { diff --git a/migrations/001_stumi_stundenzettel_tables.php b/migrations/001_stumi_stundenzettel_tables.php index aa89725384ae60fa1432b692d869f52dfbd6a54f..46dc4fef5bebe1a02e284bb474036e65d8ce5a17 100644 --- a/migrations/001_stumi_stundenzettel_tables.php +++ b/migrations/001_stumi_stundenzettel_tables.php @@ -11,12 +11,12 @@ class StumiStundenzettelTables extends Migration public function up() { - + $role = new Role(); $role->setRolename(\Stundenzettelverwaltung\STUNDENVERWALTUNG_ROLE); $role->setSystemtype(false); RolePersistence::saveRole($role); - + $db = DBManager::get(); //add db-table for stumis $db->exec("CREATE TABLE IF NOT EXISTS `stundenzettel_contracts` ( @@ -34,7 +34,7 @@ class StumiStundenzettelTables extends Migration `begin_vacation_claimed` int(11) NULL, PRIMARY KEY (id) ) "); - + //add db-table for timesheet $db->exec("CREATE TABLE IF NOT EXISTS `stundenzettel_timesheets` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -48,7 +48,7 @@ class StumiStundenzettelTables extends Migration `sum` int(11) NULL, PRIMARY KEY (id) ) "); - + //add db-table for record $db->exec("CREATE TABLE IF NOT EXISTS `stundenzettel_records` ( `timesheet_id` int(11) NOT NULL, @@ -73,7 +73,7 @@ class StumiStundenzettelTables extends Migration $db->exec("DROP TABLE stundenzettel_contracts"); $db->exec("DROP TABLE stundenzettel_timesheets"); $db->exec("DROP TABLE stundenzettel_records"); - + $roles = RolePersistence::getAllRoles(); foreach($roles as $role) { if($role->getRolename() == \Stundenzettelverwaltung\STUNDENVERWALTUNG_ROLE) { diff --git a/migrations/002_add_keys_to_contract_table.php b/migrations/002_add_keys_to_contract_table.php index 87b7ea499cb979036f57cfe92bd8cf2ad4159529..0fe930f3263972f3341b68cdff6fc337b41ebc11 100644 --- a/migrations/002_add_keys_to_contract_table.php +++ b/migrations/002_add_keys_to_contract_table.php @@ -8,7 +8,7 @@ class AddKeysToContractTable extends Migration } public function up() - { + { $db = DBManager::get(); $db->exec("ALTER TABLE `stundenzettel_contracts` ADD KEY `user_id` (`user_id`), @@ -19,7 +19,7 @@ class AddKeysToContractTable extends Migration public function down() { - + } } diff --git a/migrations/004_add_table_institute_settings.php b/migrations/004_add_table_institute_settings.php index 0bc8c7d45c99b20a79d5400c278b95216561d777..132fce6b78905749f2abd199166eb8bca89dfcb3 100644 --- a/migrations/004_add_table_institute_settings.php +++ b/migrations/004_add_table_institute_settings.php @@ -11,7 +11,7 @@ class AddTableInstituteSettings extends Migration public function up() { - + $db = DBManager::get(); //add db-table for stumis $db->exec("CREATE TABLE IF NOT EXISTS `stundenzettel_institute_settings` ( @@ -19,7 +19,7 @@ class AddTableInstituteSettings extends Migration `inst_mail` varchar(255) NULL, `hilfskraft_statusgruppen` varchar(255) NULL, PRIMARY KEY (inst_id) - ) "); + ) "); SimpleORMap::expireTableScheme(); } @@ -29,7 +29,7 @@ class AddTableInstituteSettings extends Migration $db = DBManager::get(); $db->exec("DROP TABLE stundenzettel_institute_settings"); - + SimpleORMap::expireTableScheme(); } } diff --git a/models/StundenzettelContract.class.php b/models/StundenzettelContract.class.php index aaf6395cc4b940820b16045e3279900045701154..06034996b273bf0b96f221cd8e68576f5f9def6b 100644 --- a/models/StundenzettelContract.class.php +++ b/models/StundenzettelContract.class.php @@ -14,12 +14,12 @@ * @property int $begin_digital_recording_month * @property int $begin_digital_recording_year * @property int $begin_balance - * @property int $begin_vacation_claimed + * @property int $begin_vacation_claimed */ class StundenzettelContract extends \SimpleORMap { - + private static $dezimal_to_minute = array( '01' => '00', '51' => '30', '02' => '01', '52' => '31', @@ -72,51 +72,51 @@ class StundenzettelContract extends \SimpleORMap '49' => '29', '99' => '59', '50' => '30' ); - + public function __construct($id = null) { parent::__construct($id); $this->registerCallback('before_store', 'before_store'); } - + protected static function configure($config = array()) { $config['db_table'] = 'stundenzettel_contracts'; - + $config['belongs_to']['stumi'] = [ 'class_name' => 'User', 'foreign_key' => 'user_id',]; - + $config['additional_fields']['default_workday_time']['get'] = function ($item) { $workday_hours = floor($item->default_workday_time_in_minutes / 60); $workday_minutes = $item->default_workday_time_in_minutes % 60; return sprintf("%02s", $workday_hours) . ':' . self::$dezimal_to_minute[$item->default_workday_minutes_dezimal]; - + }; - + $config['additional_fields']['default_workday_time_in_minutes']['get'] = function ($item) { $workday_minutes_total = round($item->contract_hours /4.348 / 5 * 60);//* 2.75; return $workday_minutes_total; - + }; - + $config['additional_fields']['default_workday_minutes_dezimal']['get'] = function ($item) { $workday_total_dezimal = round($item->contract_hours /4.348 / 5 , 2);//* 2.75; $workday_minutes_dezimal = explode('.', strval($workday_total_dezimal))[1]; - return $workday_minutes_dezimal; + return $workday_minutes_dezimal; }; - + parent::configure($config); } - + //Laufzeitüberschneidungen mit bestehenden Verträgen der Einrichtung prüfen protected function before_store() { $contracts = self::findBySQL('user_id = ? AND inst_id = ?', [$this->user_id, $this->inst_id]); foreach ($contracts as $contract){ if ($contract->id != $this->id){ - if ( (($this->contract_begin < $contract->contract_begin) && ($contract->contract_begin < $this->contract_end)) || + if ( (($this->contract_begin < $contract->contract_begin) && ($contract->contract_begin < $this->contract_end)) || (($this->contract_begin < $contract->contract_end) && ($contract->contract_end < $this->contract_end)) || (($contract->contract_begin < $this->contract_begin) && ($contract->contract_end > $this->contract_end)) ) { throw new Exception(dgettext('stundenzettel', 'Laufzeitüberschneidung mit bestehendem Vertrag')); @@ -124,13 +124,13 @@ class StundenzettelContract extends \SimpleORMap } } } - + function can_read($user){ if ($this->user_id == $user->user_id || $this->supervisor == $user->user_id || Stundenzettel::isInstAdmin($this->inst_id)) { return true; - } + } } - + static function getCurrentContractId($user_id) { $contracts = self::findByUser_id($user_id); @@ -142,13 +142,13 @@ class StundenzettelContract extends \SimpleORMap } return $contract_id; } - + static function getSomeContractId($user_id) { $contracts = self::findByUser_id($user_id); return $contracts[0]->id; } - + static function getContractsByMonth($month, $year) { $begin_lastmonth = strtotime(date("y-m",strtotime("-1 month")) . '-01'); @@ -158,22 +158,22 @@ class StundenzettelContract extends \SimpleORMap //$contracts = self::findBySQL('contract_begin < ? AND contract_end > ?', [$end_nextmonth, $begin_lastmonth]); $all_contracts = self::findBySQL('contract_begin < ? AND contract_end > ?', [$month_end, $month_begin]); $contracts = []; - + if ( $GLOBALS['perm']->have_perm('admin')){ return $all_contracts; } else { foreach ($all_contracts as $contract){ - if ($contract->user_id == User::findCurrent()->user_id || + if ($contract->user_id == User::findCurrent()->user_id || $contract->supervisor == User::findCurrent()->user_id || Stundenzettel::isInstAdmin($contract->inst_id) ){ $contracts[] = $contract; } } } - + return $contracts; } - + //TODO Institutsbezogen static function getUserContractsByMonth($user_id, $month, $year) { @@ -185,7 +185,7 @@ class StundenzettelContract extends \SimpleORMap $contract = self::findOneBySQL('user_id = ? AND contract_begin < ? AND contract_end > ?', [$user_id, $month_end, $month_begin]); return $contract; } - + static function get_user_inst_contracts_in_year($user_id, $inst_id, $year) { $year_begintime = strtotime('01.01.' . $year); @@ -195,10 +195,10 @@ class StundenzettelContract extends \SimpleORMap . ':year_begintime <= contract_end <= :year_endtime OR ' . ' (:year_begintime > contract_begin AND :year_endtime <= contract_end))', ['user_id' => $user_id, 'inst_id' => $inst_id, 'year_begintime' => $year_begintime, 'year_endtime' => $year_endtime]); - + return $contracts; } - + static function getStatus_array() { $status_array = array( @@ -234,32 +234,32 @@ class StundenzettelContract extends \SimpleORMap 'overdue_tooltip' => dgettext('stundenzettel', 'Vorgang überfällig') ), ); - + return $status_array; } - + function getContractDuration() { $begin_date = new \DateTime(); $begin_date->setTimestamp($this->contract_begin); $end_date = new \DateTime(); $end_date->setTimestamp($this->contract_end); - + $interval = date_diff($begin_date, $end_date); $month = $interval->y * 12 + $interval->m; if ($interval->d >15){ - $month++; //php date_diff tut sich hier leider schwer - //1.10.2020 bis 31.10.2020 ist ein Monat + $month++; //php date_diff tut sich hier leider schwer + //1.10.2020 bis 31.10.2020 ist ein Monat //aber 1.11.2020-30.11.2020 is 0 Monate und 29 tage } return $month; } - + function monthPartOfContract($month, $year) { - return (intval($this->contract_begin) < strtotime($year . '-' . $month . '-28')) && (strtotime($year . '-' . $month . '-01') < intval($this->contract_end)); + return (intval($this->contract_begin) < strtotime($year . '-' . $month . '-28')) && (strtotime($year . '-' . $month . '-01') < intval($this->contract_end)); } - + function monthWithVacationEntitlement($year) { $contract_month_in_year = 12; @@ -270,47 +270,47 @@ class StundenzettelContract extends \SimpleORMap } return $contract_month_in_year; } - + //unterscheidet sich von monthPartOfContract, weil der offizielle Aufzeichnungsbeginn vom Vertragsbeginn abweichen kann function monthWithinRecordingTime($month, $year) { if ($this->monthPartOfContract($month, $year)) { - if ($this->begin_digital_recording_month && $this->begin_digital_recording_year) { + if ($this->begin_digital_recording_month && $this->begin_digital_recording_year) { if (($year == $this->begin_digital_recording_year && $month < $this->begin_digital_recording_month) || $year < $this->begin_digital_recording_year ){ return false; //im Vertragszeitraum und vor konfiguriertem Aufzeichnungbeginn } else return true; //im Vertragszeitraum und nach konfiguriertem Aufzeichnungbeginn } else return true; //im Vertragszeitraum und kein späterer Aufzeichnungbeginn konfiguriert - } else return false; //außerhalb Vertragszeitraums + } else return false; //außerhalb Vertragszeitraums } - + function getVacationEntitlement($year) { - $dezimal_entitlement = $this->contract_hours * $this->monthWithVacationEntitlement($year) * 0.077; + $dezimal_entitlement = $this->contract_hours * $this->monthWithVacationEntitlement($year) * 0.077; $entitlement_hours = floor($dezimal_entitlement); $entitlement_minutes = ($dezimal_entitlement - $entitlement_hours) * 60; - + // if ($entitlement_minutes/60 >= 0.5) { // $entitlement_hours += 1; // $entitlement_minutes = 0; // } - + return sprintf("%02s:%02s", $entitlement_hours, round($entitlement_minutes)) ; //round($entitlement_minutes, 3) } - - + + function getRemainingVacation($year) { $claimed_vacation = $this->getClaimedVacation($year); //Urlaub der mit Resturlaub aus dem Vorjahr verrechnet werden kann wird in diesem Jahr nicht abgezogen - + //TODO falls manuell Daten zum Resturlaub des letzten Jahres angegeben wurden werden diese für das entsprechende Jahr genutzt, unhabhängig von sonstigen //Vertragsdaten if ($this->begin_digital_recording_year == ($year + 1)) { $remaining_vacation = $this->last_year_vacation_remaining; } else { - - + + if ($year-1 >= date('Y', $this->contract_begin) && $this->getRemainingVacation($year-1) ) { $remaining_claimed_vacation = $this->getRemainingVacation($year-1) - $this->getClaimedVacation($year, $month = 3); //falls Resturlaub nicht reicht, übrigen Urlaub vom Anspruch in diesem Jahr abziehen @@ -336,7 +336,7 @@ class StundenzettelContract extends \SimpleORMap return $remaining_vacation; } - + function getRemainingVacationAtEndOfYear($year) { if ($this->begin_digital_recording_year == ($year + 1)) { @@ -346,39 +346,39 @@ class StundenzettelContract extends \SimpleORMap } return $remaining_vacation_end_of_year; } - + //default: Urlaub aus allen monatn des Jahres //falls $month gesetzt ist: Urlaub bis einschließlich zum Moat $month (für Verrechnung von Resturlaub innrhab des erlaubten Zeitrahmens) function getClaimedVacation($year, $month = 12) { //$timesheets = StundenzettelTimesheet::findBySQL('`contract_id` = ? AND `year` = ?', [$this->id, $year]); - + //Urlaub der im Folgejahr bis einschließlich März genommen wurde einbeziehen (möglicherweise ist es übersichtlicher das separat zu bestimmen) $timesheets = StundenzettelTimesheet::findBySQL('`contract_id` = ? AND `year` = ? AND `month` <= ?', [$this->id, $year, $month]); - + //$timesheets = array_merge($timesheets_thisyear, $timesheets_nextyear); - + $claimed_vacation = 0; - + foreach ($timesheets as $timesheet) { $records = StundenzettelRecord::findBySQL('`timesheet_id` = ? AND `defined_comment` = "Urlaub"', [$timesheet->id]); foreach ($records as $record) { $claimed_vacation += $record['sum']; } - } + } //zu Aufzeichnungsbeginn in diesem Jahr bereits genutzter Urlaub - //falls Aufzeichnungsbeginn vor April diesen Jahres liegt und in diesem Zeitraum bereits Urlaub beansprucht wurde, + //falls Aufzeichnungsbeginn vor April diesen Jahres liegt und in diesem Zeitraum bereits Urlaub beansprucht wurde, //kann dieser im Zeitraum Januar-März ggf. mit Resturlaub verrechnet werden - if ($month <= 3 && $this->begin_vacation_claimed && $this->begin_digital_recording_year == $year && $this->begin_digital_recording_month <= 3) { + if ($month <= 3 && $this->begin_vacation_claimed && $this->begin_digital_recording_year == $year && $this->begin_digital_recording_month <= 3) { $claimed_vacation = $claimed_vacation + $this->begin_vacation_claimed; //falls Aufzeichnungsbeginn später im Jahr liegt kann Urlaub nur mit Gesamtjahresanspruch verrechnet werden - } else if ($month > 3 && $this->begin_vacation_claimed && $this->begin_digital_recording_year == $year) { + } else if ($month > 3 && $this->begin_vacation_claimed && $this->begin_digital_recording_year == $year) { $claimed_vacation = $claimed_vacation + $this->begin_vacation_claimed; } - + return $claimed_vacation; } - + function getWorktimeBalance() { $timesheets = StundenzettelTimesheet::findBySQL('`contract_id` = ?', [$this->id]); @@ -388,8 +388,8 @@ class StundenzettelContract extends \SimpleORMap $balance_time += $timesheet->timesheet_balance; } } - if ($this->begin_balance) { - $balance_time += $this->begin_balance; + if ($this->begin_balance) { + $balance_time += $this->begin_balance; } return $balance_time; } @@ -398,10 +398,10 @@ class StundenzettelContract extends \SimpleORMap { $month = new DateTime(); $month->setTimestamp($this->contract_begin); - + //bestehende Verträge für diesen Nutzer und diese Einrichtung $contracts = self::findBySQL('`user_id` = ? AND `inst_id` = ?', [$this->user_id, $this->inst_id]); - + //durchlaufe alle Monate seit Vertragsbeginn bis Vertragsende while ($month->getTimestamp() < $this->contract_end){ @@ -419,7 +419,7 @@ class StundenzettelContract extends \SimpleORMap $month->modify('+1 month'); } } - + // function reassign_timesheets(){ // $timesheets = StundenzettelTimesheet::findByContract_Id($this->id); // foreach ($timesheets as $timesheet){ @@ -432,7 +432,7 @@ class StundenzettelContract extends \SimpleORMap // } // } // } - + function add_timesheet($month, $year) { $timesheet = StundenzettelTimesheet::getContractTimesheet($this->id, $month, $year); diff --git a/models/StundenzettelInstituteSetting.class.php b/models/StundenzettelInstituteSetting.class.php index 837fa74e75d91888d81311a5f1b184149d03a19f..0e3ca035b471776989162a93ef9473e0fe1dd56c 100644 --- a/models/StundenzettelInstituteSetting.class.php +++ b/models/StundenzettelInstituteSetting.class.php @@ -14,26 +14,26 @@ class StundenzettelInstituteSetting extends \SimpleORMap { - + protected static function configure($config = array()) { $config['db_table'] = 'stundenzettel_institute_settings'; - + $config['belongs_to']['institute'] = [ 'class_name' => 'Institute', 'foreign_key' => 'institute_id',]; - + $config['additional_fields']['stumi_statusgroups']['get'] = function ($item) { foreach (explode(',', $item->hilfskraft_statusgruppen) as $statusgruppen_id){ $groups[] = Statusgruppen::find($statusgruppen_id); } return $groups; }; - + $config['additional_fields']['stumi_statusgroup_ids']['get'] = function ($item) { return explode(',', $item->hilfskraft_statusgruppen); }; - + parent::configure($config); } } diff --git a/models/StundenzettelRecord.class.php b/models/StundenzettelRecord.class.php index 5c4e7c2206a7765434c760ddeb3f568aee0b4c81..dc9b4e0905323200c8b65708c7169d798c4e267e 100644 --- a/models/StundenzettelRecord.class.php +++ b/models/StundenzettelRecord.class.php @@ -10,7 +10,7 @@ * @property int $end * @property int $break * @property decimal $sum - * @property enum $defined_comment + * @property enum $defined_comment * @property varchar $comment * @property int $entry_mktime @@ -23,21 +23,21 @@ class StundenzettelRecord extends \SimpleORMap protected static function configure($config = array()) { $config['db_table'] = 'stundenzettel_records'; - + $config['belongs_to']['timesheet'] = [ 'class_name' => 'StundenzettelTimesheet', 'foreign_key' => 'timesheet_id',]; - + parent::configure($config); } - + public function __construct($id = null) { parent::__construct($id); $this->registerCallback('before_store', 'before_store'); } - + //formale Vorgaben zum Ausfüllen der Stundenzettel prüfen protected function before_store() { @@ -58,7 +58,7 @@ class StundenzettelRecord extends \SimpleORMap throw new Exception(sprintf(dgettext('stundenzettel', 'Arbeitszeit kann bis maximal 23 Uhr erfasst werden'))); } } - + function calculate_sum(){ if(in_array($this->defined_comment, ['Urlaub', 'Krank', 'Feiertag']) && !$this->isWeekend() ) { $this->sum = StundenzettelTimesheet::stundenzettel_strtotimespan($this->timesheet->contract->default_workday_time); @@ -68,39 +68,39 @@ class StundenzettelRecord extends \SimpleORMap // $this->sum = ''; // } } - - function getWeekday() + + function getWeekday() { return date('w', strtotime($this->getDate())); } - - function getDate() + + function getDate() { $timesheet = StundenzettelTimesheet::find($this->timesheet_id); return sprintf("%02s", $this->day) . '.' . sprintf("%02s", $timesheet->month) . '.' . sprintf("%02s", $timesheet->year); } - + function isWeekend() { return in_array($this->getWeekday(), ['6', '0']); } - + function isHoliday() { return self::isDateHoliday($this->getDate()); } - + function isUniClosed() { return self::isUniClosedOnDate($this->getDate()); } - + static function isDateWeekend($date) { $day = date('w', strtotime($date)); return in_array($day, ['6', '0']); } - + static function isDateHoliday($date) { $holiday = holiday(strtotime($date)); @@ -108,7 +108,7 @@ class StundenzettelRecord extends \SimpleORMap return true ; } else return false; } - + static function isUniClosedOnDate($date) { static $uni_closed = array( @@ -117,10 +117,10 @@ class StundenzettelRecord extends \SimpleORMap '29.12.' => true, '30.12.' => true ); - + return array_key_exists(substr($date, 0, 6), $uni_closed); } - + static function isEditable($date) { $date_time = new DateTime($date); diff --git a/models/StundenzettelTimesheet.class.php b/models/StundenzettelTimesheet.class.php index ba29f31c79fc89e08436d4bd055baed69b955646..4eaa768e29918ff2189d42316746e2948f558a37 100644 --- a/models/StundenzettelTimesheet.class.php +++ b/models/StundenzettelTimesheet.class.php @@ -21,11 +21,11 @@ class StundenzettelTimesheet extends \SimpleORMap protected static function configure($config = array()) { $config['db_table'] = 'stundenzettel_timesheets'; - + $config['belongs_to']['contract'] = [ 'class_name' => 'StundenzettelContract', 'foreign_key' => 'contract_id',]; - + $config['additional_fields']['timesheet_balance']['get'] = function ($item) { if ($item->month_completed){ return $item->sum - ($item->contract->contract_hours * 3600); @@ -33,7 +33,7 @@ class StundenzettelTimesheet extends \SimpleORMap return ''; } }; - + $config['additional_fields']['vacation']['get'] = function ($item) { $records = StundenzettelRecord::findBySQL('`timesheet_id` = ? AND `defined_comment` = "Urlaub"', [$item->id]); foreach ($records as $record) { @@ -41,35 +41,35 @@ class StundenzettelTimesheet extends \SimpleORMap } return $vacation; }; - + //gibt an, ob der Monat, für welchen der Stundenzettel angelegt wurde bereits abgelaufen ist $config['additional_fields']['month_completed']['get'] = function ($item) { $days_per_month = cal_days_in_month(CAL_GREGORIAN, $item->month, $item->year); return strtotime($item->year . '-' . $item->month . '-' . $days_per_month) < time(); }; - + $config['additional_fields']['locked']['get'] = function ($item) { - return $item->finished; + return $item->finished; }; - + $config['additional_fields']['int_status']['get'] = function ($item) { - return $item->finished + $item->approved + $item->received + $item->complete ; + return $item->finished + $item->approved + $item->received + $item->complete ; }; - + $config['additional_fields']['overdue']['get'] = function ($item) { $offset_overdue = '01'; $due_time = strtotime("+1 month", strtotime($item->year . '-' . $item->month . '-' . $offset_overdue . ' 00:01')); - return $due_time < time();; + return $due_time < time();; }; parent::configure($config); } - + static function getContractTimesheet($contract_id, $month, $year){ $timesheet = StundenzettelTimesheet::findOneBySQL('`contract_id` = ? AND `month` = ? AND `year` = ?', [$contract_id, $month, $year]); return $timesheet; } - + function getCurrentState($status, $user_status){ if ($user_status == 'stumi'){ switch ($status){ @@ -90,7 +90,7 @@ class StundenzettelTimesheet extends \SimpleORMap else return 'false'; } } - + if ($user_status == 'supervisor'){ switch ($status){ case 'finished': @@ -111,7 +111,7 @@ class StundenzettelTimesheet extends \SimpleORMap else return 'false'; } } - + if ($user_status == 'admin'){ switch ($status){ case 'finished': @@ -136,12 +136,12 @@ class StundenzettelTimesheet extends \SimpleORMap } } } - + function build_pdf() { global $STUDIP_BASE_PATH, $TMP_PATH; $line_height = 3; - + // create new PDF document $pdf = new ExportPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'ISO-8859-1', false); $pdf->setPrintHeader(false); @@ -150,11 +150,11 @@ class StundenzettelTimesheet extends \SimpleORMap $pdf->AddPage(); $pdf->Image(PluginEngine::getPlugin('Stundenzettel')->getPluginPath(). '/assets/images/Arbeitszeitnachweis.png', 0, 0, 1200, 1550, '', '', '', false, 300); - + $records = StundenzettelRecord::findByTimesheet_Id($this->id, 'ORDER BY day ASC'); - $pdf->SetY(38); - + $pdf->SetY(38); + // Set font $pdf->SetFont('helvetica', '', 9); //$this->SetTextColor(0,127,75); @@ -172,7 +172,7 @@ class StundenzettelTimesheet extends \SimpleORMap $pdf->Write(5, StundenzettelContract::find($this->contract_id)->contract_hours); $pdf->Ln(19); $pdf->SetFont('helvetica', '', 8.7); - + //$this->Cell(0, 0, $content, 0, 1, 'L', 0, '', 0, false, 'C', 'C'); foreach ($records as $record){ //$record->calculate_sum(); @@ -190,20 +190,20 @@ class StundenzettelTimesheet extends \SimpleORMap $pdf->Write($line_height, ($record->sum && $record->defined_comment != 'Feiertag') ? date('d.m.Y', strtotime($record->entry_mktime)) : ''); $pdf->SetX(132); $pdf->Write($line_height, $record->defined_comment . ' ' . $record->comment); - + $pdf->Ln(); - + } $pdf->SetY(192); $pdf->SetX(90); $pdf->Write($line_height, self::stundenzettel_strftimespan($record->timesheet->sum)); - - $fileid = time(); + + $fileid = time(); $pdf->Output( 'Stundenzettel_' . $this->month . '-' . $this->year . '_' . User::find($this->contract->user_id)->nachname . '.pdf', 'D'); - + } - + function send_finished_mail() { $user = User::find($this->contract->user_id); @@ -224,7 +224,7 @@ class StundenzettelTimesheet extends \SimpleORMap ->send(); return $success; } - + function send_mail($betreff, $empfaenger_mail, $mailtext) { $sender = "studip@uni-osnabrueck.de"; @@ -234,54 +234,54 @@ class StundenzettelTimesheet extends \SimpleORMap ->setSenderName( 'Stud.IP' ) ->setSubject($betreff) ->setBodyHtml($mailtext) - ->setBodyHtml(strip_tags($mailtext)) + ->setBodyHtml(strip_tags($mailtext)) ->send(); return $success; } - - function is_supervisor($user) + + function is_supervisor($user) { if ($this->contract->supervisor == $user->user_id){ return true; } else return false; } - + function can_edit($user){ if (($this->contract->user_id == $user->user_id) && !$this->locked){ return true; } else return false; } - + //TODO InstAdmin identifizieren und Zugriff erlauben function can_read($user){ if ($this->contract->can_read($user)) { if ($this->contract->user_id == $user->user_id || (($this->contract->supervisor == $user->user_id) && $this->finished)) { return true; - } + } } } - + function calculate_sum(){ //if (!$this->locked){ $records = StundenzettelRecord::findByTimesheet_Id($this->id); $sum = 0; foreach ($records as $record){ - $sum += $record->sum; + $sum += $record->sum; } $this->sum = $sum; $this->store(); //} } - + //wird für vacation Berechnung noch benutzt static function subtractTimes($timea, $timeb){ $timea_pts = explode(':', $timea); $timeb_pts = explode(':', $timeb); - + $timea_minutes = intval($timea_pts[1]) + intval($timea_pts[0]) * 60; $timeb_minutes = intval($timeb_pts[1]) + intval($timeb_pts[0]) * 60; - + $minutes_total = $timea_minutes - $timeb_minutes; $hours = floor($minutes_total / 60); if (($minutes_total % 60) != 0 && $hours < 0) { @@ -290,10 +290,10 @@ class StundenzettelTimesheet extends \SimpleORMap } else { $minutes = $minutes_total % 60; } - - return (sprintf("%02s", $hours) . ':' . sprintf("%02s", abs($minutes))); + + return (sprintf("%02s", $hours) . ':' . sprintf("%02s", abs($minutes))); } - + static function stundenzettel_strtotimespan($string){ $negative = strpos($string, '-'); $pts = explode(':', $string); @@ -307,16 +307,16 @@ class StundenzettelTimesheet extends \SimpleORMap return '-' . $timespan; } } - + static function stundenzettel_strftimespan($timespan){ $hours = floor(abs($timespan) / 3600); $minutes = ($timespan % 3600) / 60; - $str = (sprintf("%02s", $hours) . ':' . sprintf("%02s", abs($minutes))); + $str = (sprintf("%02s", $hours) . ':' . sprintf("%02s", abs($minutes))); if ($timespan < 0) { return '-' . $str; } else return $str; } - + static function stundenzettel_strtotime($string){ $hours = intval(explode(':', $string)[0]); $time = strtotime($string); @@ -326,7 +326,7 @@ class StundenzettelTimesheet extends \SimpleORMap return $time; } } - + static function stundenzettel_strftime($format, $time){ $str = strftime($format, $time); if ($time < 0){ diff --git a/views/index/add_contract_begin_data.php b/views/index/add_contract_begin_data.php index 78d1a5c3847ec6939e01b117505972aba99f6083..55ab67b264ca67ca82d6771bf4cf7f1ee388d3c2 100644 --- a/views/index/add_contract_begin_data.php +++ b/views/index/add_contract_begin_data.php @@ -5,9 +5,9 @@ use Studip\Button, Studip\LinkButton; <form class='default' method="post" action="<?= $controller->link_for('index/save_contract_begin_data/' . $contract->id) ?>"> <?= CSRFProtection::tokenTag() ?> - + <h2><?= $controller->_('Name') ?>: <?= htmlready($stumi->vorname)?> <?= htmlready($stumi->nachname)?></h2> - + <label> <?= $controller->_('Beginn der digitalen Stundenerfassung ab: Monat und Jahr') ?> @@ -22,21 +22,21 @@ use Studip\Button, Studip\LinkButton; <? endforeach ?> </select> </label> - + <label> <?= $controller->_('Bereits beanspruchter Urlaub im laufenden Jahr') ?> <input type='text' pattern="<?= $balance_pattern ?>" required name="vacation_claimed" placeholder='hh:mm' value='<?= ($contract->begin_vacation_claimed) ? htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->begin_vacation_claimed)) : '00:00'?>'> </label> - + <label> <?= $controller->_('Verbleibender Resturlaub aus dem vorigen Jahr zum 01.01. diesen Jahres') ?> <input type='text' pattern="<?= $balance_pattern ?>" required name="begin_last_year_vacation_remainig" placeholder='hh:mm' value='<?= ($contract->last_year_vacation_remaining) ? htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->last_year_vacation_remaining)) : '00:00'?>'> </label> - + <label> <?= $controller->_('Stundenkonto zu Beginn der digitalen Aufzeichnung') ?> <input type='text' pattern="<?= $balance_pattern ?>" required name="balance" placeholder='(-)hh:mm' value='<?= ($contract->begin_balance) ? htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->begin_balance)) : '00:00'?>'> - </label> + </label> <footer data-dialog-button> <?= Button::create($controller->_('Übernehmen')) ?> diff --git a/views/index/edit_institute_settings.php b/views/index/edit_institute_settings.php index 96a39929f82e2a2061df414ee26ed17754353fec..24e3f32ed6348675f4be3e48e21e96d9702be6bb 100644 --- a/views/index/edit_institute_settings.php +++ b/views/index/edit_institute_settings.php @@ -4,30 +4,30 @@ use Studip\Button, Studip\LinkButton; <form class='default' method="post" action="<?= $controller->link_for('index/save_institute_settings/' . $inst_id) ?>"> <?= CSRFProtection::tokenTag() ?> - + <h2></h2> - + <label> <h2> <?= $controller->_('Hilfskraft-Statusgruppen:') ?> - <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, + <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, ['title' => $controller->_('Wählen Sie die Statusgruppe(n) der Einrichtung aus, welchen Hilfskräfte zugeordnet sind. Die zugeordneten Personen erscheinen dann automatisch in Ihrer Vertrags-Verwaltungsübersicht.') ])?> </h2> </label> - + <? foreach ($groups as $group): ?> <input type='checkbox' name='statusgruppen[]' <?= (in_array($group->id, explode(',', $stumi_group_ids) )) ? 'checked' : '' ?> value="<?= htmlready($group->id)?>"><?= htmlready($group->name) ?></input><br> <? endforeach ?> - + <label> <h2> <?= $controller->_('Mailadresse der Verwaltung') ?> - <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, + <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, ['title' => $controller->_('Emailadresse der verantwortlichen Stelle innerhalb der Einrichtung (z.B. Sekretariat). Diese wird beispielsweise als Absender von automatischen Erinnerungsmails angegeben.') ])?> </h2> - </label> + </label> <input type='text' required name="email" value='<?= htmlready($inst_mail) ?>'> - + <footer data-dialog-button> <?= Button::create($controller->_('Übernehmen')) ?> diff --git a/views/index/index.php b/views/index/index.php index bd152cdad2d10c0a034552774f349eaedb46370e..6b8d30c8298d15d700f8fb837b8c7ae43012dbf2 100644 --- a/views/index/index.php +++ b/views/index/index.php @@ -1,12 +1,12 @@ <div> - -<? if ($adminrole) : ?> + +<? if ($adminrole) : ?> <? foreach ($inst_ids as $inst_id) : ?> <? if ($adminrole) : ?> - <h2> + <h2> <a href='<?=$this->controller->link_for('index/edit_institute_settings/' . $inst_id) ?>' title='<?= $controller->_('Konfiguration bearbeiten') ?>' data-dialog='size=auto'> <?=Icon::create('edit')?> - </a> + </a> <?= htmlready(Institute::find($inst_id)->name) ?> </h2> <? else : ?> <h2><?= $controller->_('Studentische MitarbeiterInnen') ?></h2> @@ -38,12 +38,12 @@ <? foreach ($inst_data[$inst_id][$group_id]->stumis as $stumi): ?> <? if ($inst_data[$inst_id][$group_id]->stumi_contracts[$stumi->user_id]) : ?> <? foreach ($inst_data[$inst_id][$group_id]->stumi_contracts[$stumi->user_id] as $contract): ?> - <tr> + <tr> <td><a href='<?=$this->controller->link_for('timesheet/index/' . $contract->id) ?>' ><?= htmlready($stumi->nachname) ?>, <?= htmlready($stumi->vorname) ?></a> </td> <td data-sort-value="<?= $contract->contract_begin ?>"><?= date('d.m.Y', $contract->contract_begin) ?> <? if ($contract->begin_digital_recording_month && $contract->begin_digital_recording_year) : ?> - <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, + <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, ['title' => $controller->_('Beginn der elektronischen Erfassung') . ': ' . $contract->begin_digital_recording_month . '/' . $contract->begin_digital_recording_year ]);?> <? endif ?> </td> @@ -53,7 +53,7 @@ <td><?= htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->getClaimedVacation(date('Y'))))?></td> <td><?= htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->getRemainingVacation(date('Y'))))?></td> <td><?= Stundenzettel::vacationEntitelment($stumi->user_id, $inst_id, date('Y'))?> - <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, + <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, ['title' => 'Davon aus diesem Vertrag erworbener Anspruch: ' . htmlready($contract->getVacationEntitlement(date('Y'))) ]);?> </td> <td><?= htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->getRemainingVacationAtEndOfYear(date('Y')-1)))?></td> @@ -71,7 +71,7 @@ <? endforeach ?> <? elseif ($adminrole) : ?> - <tr> + <tr> <td><?= htmlready($stumi->nachname) ?>, <?= htmlready($stumi->vorname) ?> </td> <td> -- </td> @@ -95,7 +95,7 @@ </table> <? endforeach ?> <? endforeach ?> - + <? elseif ( $supervisorrole ) : ?> <h2><?= $controller->_('Vertragsdaten Hilfskräfte') ?></h2> <table id='stumi-contract-entries' class="sortable-table default"> @@ -115,12 +115,12 @@ <tbody> <? foreach ($stumis as $stumi): ?> <? foreach ($stumi_contracts[$stumi->user_id] as $contract): ?> - <tr> + <tr> <td><a href='<?=$this->controller->link_for('timesheet/index/' . $contract->id) ?>' title='<?= $controller->_('Stundenzettel einsehen') ?>'><?= htmlready($stumi->nachname) ?>, <?= htmlready($stumi->vorname) ?></a> </td> <td data-sort-value="<?= $contract->contract_begin ?>"><?= date('d.m.Y', $contract->contract_begin) ?> <? if ($contract->begin_digital_recording_month && $contract->begin_digital_recording_year) : ?> - <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, + <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, ['title' => $controller->_('Beginn der elektronischen Erfassung') . ': ' . $contract->begin_digital_recording_month . '/' . $contract->begin_digital_recording_year ]);?> <? endif ?> </td> @@ -137,7 +137,7 @@ <? endforeach ?> </tbody> </table> - + <? elseif ($stumirole) : ?> <h2> Meine Verträge </h2> @@ -160,7 +160,7 @@ <td><?= htmlready(Institute::find($contract->inst_id)->name) ?></td> <td><?= date('d.m.Y', $contract->contract_begin) ?> <? if ($contract->begin_digital_recording_month && $contract->begin_digital_recording_year) : ?> - <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, + <?= Icon::create('info-circle', Icon::ROLE_CLICKABLE, ['title' => $controller->_('Beginn der elektronischen Erfassung') . ': ' . $contract->begin_digital_recording_month . '/' . $contract->begin_digital_recording_year ]);?> <? endif ?> </td> @@ -170,12 +170,12 @@ <!-- <td><?= htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->getRemainingVacation(date('Y')))) ?>/<?= htmlready($contract->getVacationEntitlement(date('Y'))) ?></td>--> <td title='<?= User::find($contract->supervisor)->username ?>'><?= sprintf('%s %s', User::find($contract->supervisor)->vorname, User::find($contract->supervisor)->nachname) ?></td> <td> - <a data-dialog="size=1000x800;" - href="<?=$this->controller->link_for('index/mail/' . $contract->supervisor)?>" + <a data-dialog="size=1000x800;" + href="<?=$this->controller->link_for('index/mail/' . $contract->supervisor)?>" title="<?= $controller->_('eMail an verantwortliche/n MA') ?>"> <?= Icon::create('mail') ?> </a> - <a href="<?=PluginEngine::getUrl($plugin, [], 'timesheet/index/' . $contract->id )?>" + <a href="<?=PluginEngine::getUrl($plugin, [], 'timesheet/index/' . $contract->id )?>" title="<?= $controller->_('Zu den Stundenzetteln') ?>"> <?= Icon::create('files') ?> </a> @@ -185,6 +185,6 @@ </tbody> </table> -<? endif ?> - +<? endif ?> + </div> diff --git a/views/index/mail.php b/views/index/mail.php index 224bffa094eed24545aff29485cb6b788d8d7666..259fa488c905981c62cb349fcca67c4d603d6113 100644 --- a/views/index/mail.php +++ b/views/index/mail.php @@ -1,7 +1,7 @@ <form name="write_message" action="<?=$this->controller->link_for('index/send_form/' . $mail)?>" method="post" style="margin-left: auto; margin-right: auto;" > - + <h1><?= sprintf($controller->_('eMail an %s'), htmlReady($empfaenger)) ?></h1> - + <div> <label> <?= $controller->_("Betreff") ?> @@ -12,7 +12,7 @@ <label> <?= $controller->_("Nachricht") ?> </label> - <textarea style="width: 100%; height: 100px; color: black" name="message_body" class="wysiwyg"></textarea> + <textarea style="width: 100%; height: 100px; color: black" name="message_body" class="wysiwyg"></textarea> </div> <div style="text-align: center;" data-dialog-button> diff --git a/views/index/new.php b/views/index/new.php index 02360d1da54f83eb8b030a66d98fc71c8b4f8397..99f50958efe4b786d571d2c7e87038d6af163c24 100644 --- a/views/index/new.php +++ b/views/index/new.php @@ -8,15 +8,15 @@ use Studip\Button, Studip\LinkButton; <? if ($following_contract) : ?> <input type='hidden' name ='following_contract' value='true' > <? endif ?> - + <h2><?= $controller->_('Name') ?>: <?=htmlready($stumi->vorname)?> <?=htmlready($stumi->nachname)?></h2> <label> <?= $controller->_('Vertragsbeginn') ?> - - <input type='date' required class='size-l' + + <input type='date' required class='size-l' <? if ($following_contract) : ?> - min="<?= date('Y-m-d', strtotime('+1 day', $contract->contract_end)) ?>" + min="<?= date('Y-m-d', strtotime('+1 day', $contract->contract_end)) ?>" name="begin" value='<?= ($contract) ? date('Y-m-d', strtotime('+1 day', $contract->contract_end)) : ''?>' > <? else : ?> name="begin" value='<?= ($contract) ? date('Y-m-d', $contract->contract_begin) : ''?>' > @@ -31,7 +31,7 @@ use Studip\Button, Studip\LinkButton; <label> <?= $controller->_('Stundenumfang') ?> - <input type='text' required name="hours" placeholder='00:00' + <input type='text' required name="hours" placeholder='00:00' value='<?= ($contract) ? htmlready($contract->contract_hours) : ''?>'> </label> @@ -39,8 +39,8 @@ use Studip\Button, Studip\LinkButton; <?= $controller->_('Verantwortliche/r Mitarbeiter/in') ?> <?= $search ?> </label> - - + + <footer data-dialog-button> <?= Button::create($controller->_('Übernehmen')) ?> </footer> diff --git a/views/timesheet/admin_index.php b/views/timesheet/admin_index.php index edd6f7631ebe6390284f8ba6bbfa123c5f0f10b4..cba43556b229fec3f1c58219bfe141e77c1320f4 100644 --- a/views/timesheet/admin_index.php +++ b/views/timesheet/admin_index.php @@ -1,8 +1,8 @@ <div> -<? if ($adminrole || $supervisorrole) : ?> +<? if ($adminrole || $supervisorrole) : ?> <h2>Status Stundenzettel <?= strftime("%B", mktime(0, 0, 0, $month, 10)) ?> <?= $year ?> </h2> - <p><?= $controller->_('Monat/Jahr') ?>: + <p><?= $controller->_('Monat/Jahr') ?>: <form name="month_select" method="post" action="<?= $controller->link_for('timesheet/admin_index/') ?>"> <select name ='month' onchange="this.form.submit()"> <? foreach ($plugin->getMonths() as $entry_value): ?> @@ -29,13 +29,13 @@ <tbody> <? if ($contracts) : ?> <? foreach ($contracts as $contract): ?> - <tr> + <tr> <? $timesheet = $timesheets[$contract->id]; ?> <td> <a href='<?=$this->controller->link_for('timesheet/index/' . $contract->id) ?>' title='<?= $controller->_('Stundenzettel einsehen') ?>'><?= htmlready($contract->stumi->nachname) ?>, <?= htmlready($contract->stumi->vorname) ?></a> </td> <td><?= htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($contract->getWorktimeBalance())) ?></td> - <td data-sort-value= <?= htmlready($timesheet->int_status) ?> > + <td data-sort-value= <?= htmlready($timesheet->int_status) ?> > <? if ($timesheet) : ?> <?= Icon::create($status_infos['finished']['icon'], $status_infos[$timesheet->getCurrentState('finished', 'admin') . '_icon_role'], ['title' => $status_infos['finished'][$timesheet->getCurrentState('finished', 'admin') . '_tooltip']] )?> <?= Icon::create($status_infos['approved']['icon'], $status_infos[$timesheet->getCurrentState('approved', 'admin') . '_icon_role'], ['title' => $status_infos['approved'][$timesheet->getCurrentState('approved', 'admin') . '_tooltip']] )?> @@ -49,8 +49,8 @@ <? endif ?> </td> <td> - <a data-dialog="size=1000x800;" - href="<?=$this->controller->link_for('index/mail/' . $contract->user_id)?>" + <a data-dialog="size=1000x800;" + href="<?=$this->controller->link_for('index/mail/' . $contract->user_id)?>" title="<?= $controller->_('eMail an Hilfskraft') ?>"> <?= Icon::create('mail') ?> </a> @@ -60,11 +60,11 @@ <?= Icon::create('rotate-left', ['title' => $controller->_('Einreichen rückgängig machen')] )?> </a> <? endif ?> - <a href='<?=$this->controller->link_for('timesheet/received/' . $timesheet->id) ?>' + <a href='<?=$this->controller->link_for('timesheet/received/' . $timesheet->id) ?>' title='<?= ($timesheet->received) ? $controller->_("Bestätigen für Vorliegen zurückziehen") : $controller->_("Vorliegen bestätigen") ?>' > <?= Icon::create($status_infos['received']['icon']) ?> </a> - <a href='<?=$this->controller->link_for('timesheet/complete/' . $timesheet->id) ?>' + <a href='<?=$this->controller->link_for('timesheet/complete/' . $timesheet->id) ?>' title='<?= ($timesheet->complete) ? $controller->_('Vorgang wieder öffnen') : $controller->_('Vorgang abschließen') ?>' > <?= Icon::create($status_infos['complete']['icon']) ?> </a> @@ -73,7 +73,7 @@ <a href="<?= PluginEngine::getLink($plugin, [], 'timesheet/unlock/' . $timesheet->id ) ?>" data-confirm="<?= $controller->_('Einreichen Rückgängig machen? Der Stumi kann diesen Stundnezettel dann wieder bearbeiten und Sie haben erst wieder Zugriff wenn dieser erneut eingereicht wurde.') ?>"> <?= Icon::create('rotate-left', ['title' => $controller->_('Einreichen rückgängig machen')] )?> </a> - <a href='<?=$this->controller->link_for('timesheet/approve/' . $timesheet->id) ?>' + <a href='<?=$this->controller->link_for('timesheet/approve/' . $timesheet->id) ?>' title='<?= ($timesheet->approved) ? $controller->_("Bestätigung der Korrektheit zurückziehen") : $controller->_("Korrektheit der Angaben bestätigen") ?>' > <?= Icon::create($status_infos['approved']['icon']) ?> </a> @@ -85,8 +85,8 @@ <? endif ?> </tbody> </table> - -<? endif ?> - + +<? endif ?> + </div> diff --git a/views/timesheet/index.php b/views/timesheet/index.php index 6c287a75bcbb953a352e421b46b226e782a1dde9..dc179c83ddbdfa570267b4ab350a4ea76102be35 100644 --- a/views/timesheet/index.php +++ b/views/timesheet/index.php @@ -1,13 +1,13 @@ <div> -<? if (!$contract->id) : ?> +<? if (!$contract->id) : ?> <h2><?= $controller->_('Diese Ansicht fehlt noch, Für die Übersicht über Stundenzettel einer Person, einfach die Person anklicken.') ?></h2> - -<? elseif ($adminrole || $supervisorrole) : ?> + +<? elseif ($adminrole || $supervisorrole) : ?> <? $role = ($adminrole) ? 'admin' : 'supervisor' ?> - <h2> - <?= htmlready($stumi->nachname) ?>, <?= htmlready($stumi->vorname) ?> - <a data-dialog="size=1000x800;" - href="<?=$this->controller->link_for('index/mail/' . $contract->user_id)?>" + <h2> + <?= htmlready($stumi->nachname) ?>, <?= htmlready($stumi->vorname) ?> + <a data-dialog="size=1000x800;" + href="<?=$this->controller->link_for('index/mail/' . $contract->user_id)?>" title="<?= $controller->_('eMail an Hilfskraft') ?>"> <?= Icon::create('mail') ?> </a> @@ -27,7 +27,7 @@ <tbody> <? if ($timesheets) : ?> <? foreach ($timesheets as $timesheet): ?> - <tr> + <tr> <td> <a href='<?=$this->controller->link_for('timesheet/timesheet/' . $timesheet->id) ?>' title='<?= $controller->_('Stundenzettel editieren') ?>'> <?= strftime("%B", mktime(0, 0, 0, $timesheet->month, 10)) ?> @@ -36,24 +36,24 @@ </td> <td><?= ($timesheet->sum && $timesheet->finished) ? htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($timesheet->sum)) : $controller->_('(ausstehend)') ?> / <?= htmlready($timesheet->contract->contract_hours) ?></td> <td><?= ($timesheet->vacation) ? htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($timesheet->vacation)) : '0:00' ?></td> - <td> + <td> <?= Icon::create($status_infos['finished']['icon'], $status_infos[$timesheet->getCurrentState('finished', $role) . '_icon_role'], ['title' => $status_infos['finished'][$timesheet->getCurrentState('finished', $role) . '_tooltip']] )?> <?= Icon::create($status_infos['approved']['icon'], $status_infos[$timesheet->getCurrentState('approved', $role) . '_icon_role'], ['title' => $status_infos['approved'][$timesheet->getCurrentState('approved', $role) . '_tooltip']] )?> <?= Icon::create($status_infos['received']['icon'], $status_infos[$timesheet->getCurrentState('received', $role) . '_icon_role'], ['title' => $status_infos['received'][$timesheet->getCurrentState('received', $role) . '_tooltip']] )?> <?= Icon::create($status_infos['complete']['icon'], $status_infos[$timesheet->getCurrentState('complete', $role) . '_icon_role'], ['title' => $status_infos['complete'][$timesheet->getCurrentState('complete', $role) . '_tooltip']] )?> </td> - <td> + <td> <? if ($adminrole && $timesheet) : ?> <? if ($timesheet->finished) : ?> <a href="<?= PluginEngine::getLink($plugin, [], 'timesheet/unlock/' . $timesheet->id ) ?>" data-confirm="<?= $controller->_('Einreichen Rückgängig machen? Der Stumi kann diesen Stundnezettel dann wieder bearbeiten und Sie haben erst wieder Zugriff wenn dieser erneut eingereicht wurde.') ?>"> <?= Icon::create('rotate-left', ['title' => $controller->_('Einreichen rückgängig machen')] )?> </a> <? endif ?> - <a href='<?=$this->controller->link_for('timesheet/received/' . $timesheet->id) ?>' + <a href='<?=$this->controller->link_for('timesheet/received/' . $timesheet->id) ?>' title='<?= ($timesheet->received) ? $controller->_("Bestätigen für Vorliegen zurückziehen") : $controller->_("Vorliegen bestätigen") ?>' > <?= Icon::create($status_infos['received']['icon']) ?> </a> - <a href='<?=$this->controller->link_for('timesheet/complete/' . $timesheet->id) ?>' + <a href='<?=$this->controller->link_for('timesheet/complete/' . $timesheet->id) ?>' title='<?= ($timesheet->complete) ? $controller->_('Vorgang wieder öffnen') : $controller->_('Vorgang abschließen') ?>' > <?= Icon::create($status_infos['complete']['icon']) ?> </a> @@ -62,7 +62,7 @@ <a href="<?= PluginEngine::getLink($plugin, [], 'timesheet/unlock/' . $timesheet->id ) ?>" data-confirm="<?= $controller->_('Einreichen Rückgängig machen? Der Stumi kann diesen Stundnezettel dann wieder bearbeiten und Sie haben erst wieder Zugriff wenn dieser erneut eingereicht wurde.') ?>"> <?= Icon::create('rotate-left', ['title' => $controller->_('Einreichen rückgängig machen')] )?> </a> - <a href='<?=$this->controller->link_for('timesheet/approve/' . $timesheet->id) ?>' + <a href='<?=$this->controller->link_for('timesheet/approve/' . $timesheet->id) ?>' title='<?= ($timesheet->approved) ? $controller->_("Bestätigung der Korrektheit zurückziehen") : $controller->_("Korrektheit der Angaben bestätigen") ?>' > <?= Icon::create($status_infos['approved']['icon']) ?> </a> @@ -74,7 +74,7 @@ <? endif ?> </tbody> </table> - + <? elseif ($stumirole) : ?> <p> <form name="contract_select" method="post" action="<?= $controller->link_for('timesheet/index/') ?>"> @@ -101,7 +101,7 @@ <tbody> <? if ($timesheets) : ?> <? foreach ($timesheets as $timesheet): ?> - <tr> + <tr> <td> <a href='<?=$this->controller->link_for('timesheet/timesheet/' . $timesheet->id) ?>' title='<?= $controller->_('Stundenzettel editieren') ?>'> <?= strftime("%B", mktime(0, 0, 0, $timesheet->month, 10)) ?> @@ -132,8 +132,8 @@ </tbody> </table> -<? endif ?> - +<? endif ?> + </div> </body> diff --git a/views/timesheet/timesheet.php b/views/timesheet/timesheet.php index d2c28ed9bc0426499fb00451dd004ad2f59353ec..cc2dc06dc5b946d25e301fef779d9c15657db0c3 100644 --- a/views/timesheet/timesheet.php +++ b/views/timesheet/timesheet.php @@ -10,7 +10,7 @@ use Studip\Button, Studip\LinkButton; <p><?= $controller->_('Name, Vorname') ?>: <b><?= htmlready(User::find($contract->user_id)->nachname) ?>, <?= htmlready(User::find($contract->user_id)->vorname) ?></b></p> <p><?= $controller->_('Fachbereich/Organisationseinheit') ?>: <b><?= htmlready(Institute::find($contract->inst_id)->name) ?></b></p> - <p><?= $controller->_('Monat/Jahr') ?>: + <p><?= $controller->_('Monat/Jahr') ?>: <form name="month_select" method="post" action="<?= $controller->link_for('timesheet/select/' . $contract->id) ?>"> <select name ='month' onchange="this.form.submit()"> <? foreach ($plugin->getMonths() as $entry_value): ?> @@ -24,14 +24,14 @@ use Studip\Button, Studip\LinkButton; </select> </form> </p> - + <? elseif ($timesheet->can_read(User::findCurrent()) || $adminrole): ?> <h2><?= strftime("%B", mktime(0, 0, 0, $timesheet->month, 10)) . ' ' . $timesheet->year; ?> </h2> <p><?= $controller->_('Name, Vorname') ?>: <b><?= htmlready(User::find($timesheet->contract->user_id)->nachname) ?>, <?= htmlready(User::find($timesheet->contract->user_id)->vorname) ?></b></p> <p><?= $controller->_('Fachbereich/Organisationseinheit') ?>: <b><?= htmlready(Institute::find($inst_id)->name) ?></b></p> <p><?= $controller->_('Monatsarbeitszeit laut Arbeitsvertrag') ?>: <b><?= htmlready($timesheet->contract->contract_hours) ?> <?= $controller->_('Stunden') ?></b></p> - <p><?= $controller->_('Diesen Monat erfasst') ?>: <b> <?= htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($timesheet->sum)) ?><?= $controller->_('Stunden') ?></b></p> - <p><?= $controller->_('Monat/Jahr') ?>: + <p><?= $controller->_('Diesen Monat erfasst') ?>: <b><?= htmlready(StundenzettelTimesheet::stundenzettel_strftimespan($timesheet->sum)) ?> <?= $controller->_('Stunden') ?></b></p> + <p><?= $controller->_('Monat/Jahr') ?>: <form name="month_select" method="post" action="<?= $controller->link_for('timesheet/select/' . $timesheet->contract_id) ?>"> <select name ='month' onchange="this.form.submit()"> <? foreach ($plugin->getMonths() as $entry_value): ?> @@ -44,7 +44,7 @@ use Studip\Button, Studip\LinkButton; <? endforeach ?> </select> </form> - </p> + </p> <!-- langfristig Formular für admins sperren (class admin und locked-abfrage) --> <form id="timesheet_form" method="post" class='<?= $adminrole ? '' : '' ?> <?= ($timesheet->locked && !$adminrole) ? 'locked' : '' ?>' action="<?= $controller->link_for('timesheet/save_timesheet', $timesheet->id) ?>" class="default collapsable"> @@ -62,13 +62,13 @@ use Studip\Button, Studip\LinkButton; <th style='width:110px'><?= $controller->_('Bemerkung') ?></th> <th style='width:210px'><?= $controller->_('sonstige Bemerkung') ?></th> <th style='width:100px'></th> - + </tr> <? $j = 0; ?> - + <? for ($i = 1; $i <= $days_per_month; $i++) : ?> - + <!-- für diesen Tag liegt bereits ein Eintrag vor --> <? if ($records[$j]['day'] == $i ) : ?> <? $holiday = $records[$j]->isHoliday(); ?> @@ -98,9 +98,9 @@ use Studip\Button, Studip\LinkButton; </td> <td> <input type='date' - min="<?= date('Y-m-d', strtotime($date)) ?>" max="<?= date('Y-m-d', strtotime('+1 week', strtotime($date))) ?>" - <?= (!$is_editable)? 'readonly' : ''?> - class='entry_mktime <?= ($records[$j]['entry_mktime'] == '00-00-000') ? 'empty_date' :'' ?>' + min="<?= date('Y-m-d', strtotime($date)) ?>" max="<?= date('Y-m-d', strtotime('+1 week', strtotime($date))) ?>" + <?= (!$is_editable)? 'readonly' : ''?> + class='entry_mktime <?= ($records[$j]['entry_mktime'] == '00-00-000') ? 'empty_date' :'' ?>' name ='entry_mktime[<?= $i ?>]' value='<?= htmlready($records[$j]['entry_mktime']) ?>' > </td> <td> @@ -108,10 +108,10 @@ use Studip\Button, Studip\LinkButton; <select <?= ($holiday || $weekend)? 'disabled' : ''?> class='defined_comment' name ='defined_comment[<?= $i ?>]'> <option value=""> -- </option> <? foreach ($plugin->getCommentOptions() as $key => $entry_value): ?> - <option - <?= ($records[$j]['defined_comment'] == $key) ? 'selected' : ''?> - <?= ($key == 'Feiertag') ? 'disabled' : '' ?> - <?= (!$is_editable && $key == 'Krank') ? 'disabled' : '' ?> + <option + <?= ($records[$j]['defined_comment'] == $key) ? 'selected' : ''?> + <?= ($key == 'Feiertag') ? 'disabled' : '' ?> + <?= (!$is_editable && $key == 'Krank') ? 'disabled' : '' ?> value="<?=htmlready($key)?>"><?= htmlready($entry_value) ?></option> <? endforeach ?> </select> @@ -119,8 +119,8 @@ use Studip\Button, Studip\LinkButton; <select class='defined_comment' name ='defined_comment[<?= $i ?>]'> <option value=""> -- </option> <? foreach ($plugin->getCommentOptions() as $key => $entry_value): ?> - <option - <?= ($records[$j]['defined_comment'] == $key) ? 'selected' : ''?> + <option + <?= ($records[$j]['defined_comment'] == $key) ? 'selected' : ''?> <?= ($key == 'Urlaub' || $key == 'Krank') ? '' : 'disabled' ?> value="<?=htmlready($key)?>"><?= htmlready($entry_value) ?></option> <? endforeach ?> </select> @@ -136,7 +136,7 @@ use Studip\Button, Studip\LinkButton; </td> </tr> <? $j++; ?> - + <!-- für diesen Tag liegt noch kein Eintrag vor --> <? else: ?> <? $date = $i . '.' . $timesheet->month . '.' . $timesheet->year; ?> @@ -167,22 +167,22 @@ use Studip\Button, Studip\LinkButton; <td> <!-- data-datepicker='{">":<?= $date ?>}' --> <input type='date' - min="<?= date('Y-m-d', strtotime($date)) ?>" max="<?= date('Y-m-d', strtotime('+1 week', strtotime($date))) ?>" - <?= (!$is_editable)? 'readonly' : ''?> - class ='entry_mktime empty_date' + min="<?= date('Y-m-d', strtotime($date)) ?>" max="<?= date('Y-m-d', strtotime('+1 week', strtotime($date))) ?>" + <?= (!$is_editable)? 'readonly' : ''?> + class ='entry_mktime empty_date' name ='entry_mktime[<?= $i ?>]' value='<?= ($holiday) ? date('Y-m-d', strtotime($date)) : '' ?>' > </td> <td> - + <!-- für Feiertage und Wochenenden ggf. Bearbeitung sperren und passenden Wert setzen --> <? if (!$uni_closed || $holiday || $weekend) : ?> <select <?= ($holiday || $weekend)? 'disabled' : ''?> class='defined_comment' name ='defined_comment[<?= $i ?>]'> <option <?= ($holiday) ? '' : 'selected' ?> value=""> -- </option> <? foreach ($plugin->getCommentOptions() as $key => $entry_value): ?> - <option - <?= ($holiday && ($key == 'Feiertag')) ? 'selected' : ''?> - <?= ($key == 'Feiertag') ? 'disabled' : '' ?> - <?= (!$is_editable && $key == 'Krank') ? 'disabled' : '' ?> + <option + <?= ($holiday && ($key == 'Feiertag')) ? 'selected' : ''?> + <?= ($key == 'Feiertag') ? 'disabled' : '' ?> + <?= (!$is_editable && $key == 'Krank') ? 'disabled' : '' ?> value="<?= htmlready($key)?>"><?= htmlready($entry_value) ?> </option> <? endforeach ?> @@ -192,7 +192,7 @@ use Studip\Button, Studip\LinkButton; <select class='defined_comment' name ='defined_comment[<?= $i ?>]'> <option selected value=""> -- </option> <? foreach ($plugin->getCommentOptions() as $key => $entry_value): ?> - <option + <option <?= ($key == 'Urlaub') ? '' : 'disabled' ?> value="<?= htmlready($key) ?>"><?= htmlready($entry_value) ?></option> <? endforeach ?> </select> @@ -231,17 +231,17 @@ use Studip\Button, Studip\LinkButton; ]) ?> <? endif ?> </footer> - <? endif ?> + <? endif ?> </form> - + <? if ($timesheet->is_supervisor(User::findCurrent()) && $timesheet->finished) : ?> <?= LinkButton::create($controller->_('Korrektheit bestätigen'), $controller->link_for('timesheet/approve/' . $timesheet->id) ) ?> <? elseif ($adminrole && $timesheet->finished) : ?> <?= LinkButton::create($controller->_('Eingang bestätigen'), $controller->link_for('timesheet/received/' . $timesheet->id) ) ?> -<? endif ?> +<? endif ?> -<? endif ?> +<? endif ?> <style> @@ -258,30 +258,30 @@ use Studip\Button, Studip\LinkButton; background-color: #f4d33a; } input[class*="empty_date"]::-webkit-datetime-edit { - color: transparent; + color: transparent; } :invalid { box-shadow: none; /* FF */ outline: 0; /* IE */ border-color: red; } - + </style> <script> - + var form = document.getElementById('timesheet_form'); form.addEventListener('invalid', function(e) { document.getElementById('form_error').style.removeProperty("display"); - //alert('Speichern wegen fehlerhafter Werte nicht möglich. Bitte überprüfe deine Eingaben.'); + //alert('Speichern wegen fehlerhafter Werte nicht möglich. Bitte überprüfe deine Eingaben.'); }, true); - + form.addEventListener('valid', function(e) { document.getElementById('form_error').style.display = 'none'; - //alert('Speichern wegen fehlerhafter Werte nicht möglich. Bitte überprüfe deine Eingaben.'); + //alert('Speichern wegen fehlerhafter Werte nicht möglich. Bitte überprüfe deine Eingaben.'); }, true); - - + + $(function() { inputs = document.getElementsByClassName('Krank'); for (index = 0; index < inputs.length; ++index) { @@ -301,7 +301,7 @@ use Studip\Button, Studip\LinkButton; var rec_index = name.substring(5, 10); disable_timetracking(rec_index); } - + var form = document.getElementById('timesheet_form'); if (form.classList.contains('admin') || form.classList.contains('locked') ){ var inputs = form.querySelectorAll("input, select"); @@ -312,12 +312,12 @@ use Studip\Button, Studip\LinkButton; submit_button.style.display = 'none'; } }); - + function validateFormSaved() { alert("Ungespeicherte Änderungen!"); return false; } - + function clearLine(event, row_index) { event.preventDefault(); document.getElementsByName('begin' + row_index)[0].value = ''; @@ -334,12 +334,12 @@ use Studip\Button, Studip\LinkButton; document.getElementsByName('defined_comment' + row_index)[0].value = ''; document.getElementsByName('entry_mktime' + row_index)[0].value = ''; } - + function calculate_sum(begin, end, brk){ - + if (begin && end){ if (!brk || brk == '0') { - brk = '00:00'; + brk = '00:00'; } var begin_array = begin.split(':'); var end_array = end.split(':'); @@ -375,9 +375,9 @@ use Studip\Button, Studip\LinkButton; hours_total = +end_hours - +begin_hours; return (("0" + hours_total).slice (-2) + ':' + ("0" + minutes_total).slice (-2)); } else return ''; - + } - + function autofill_row(row_index){ var begin = document.getElementsByName('begin' + row_index)[0].value; var end = document.getElementsByName('end' + row_index)[0].value; @@ -393,12 +393,12 @@ use Studip\Button, Studip\LinkButton; document.getElementsByName('sum' + row_index)[0].value = res; } } - + function set_mktime(row_index){ var today = new Date().toISOString().slice(0, 10); document.getElementsByName('entry_mktime' + row_index)[0].value = today; } - + function getDateofRow(row_index){ var month = <?= htmlready($timesheet->month) ?>; var year = <?= htmlready($timesheet->year) ?>; @@ -406,13 +406,13 @@ use Studip\Button, Studip\LinkButton; var row_date = new Date(year + '-' + month + '-' + day); return row_date; } - + function set_time_inputs_in_row_required(row_index){ document.getElementsByName('begin' + row_index)[0].setAttribute("required", ""); document.getElementsByName('end' + row_index)[0].setAttribute("required", ""); document.getElementsByName('entry_mktime' + row_index)[0].setAttribute("required", ""); } - + function disable_timetracking(row_index){ document.getElementsByName('begin' + row_index)[0].value = ''; document.getElementsByName('begin' + row_index)[0].style.display = 'none'; @@ -423,18 +423,18 @@ use Studip\Button, Studip\LinkButton; document.getElementsByName('break' + row_index)[0].value = ''; document.getElementsByName('break' + row_index)[0].style.display = 'none'; } - + function enable_timetracking(row_index){ document.getElementsByName('begin' + row_index)[0].style.removeProperty("display"); document.getElementsByName('end' + row_index)[0].style.removeProperty("display"); document.getElementsByName('break' + row_index)[0].style.removeProperty("display"); } - + function autocalc_sum(row_index){ var default_workday_time = '<?= htmlready($timesheet->contract->default_workday_time) ?>'; document.getElementsByName('sum' + row_index)[0].value = default_workday_time; } - + $('.begin').change(function() { var name = this.getAttribute("name"); var rec_index = name.substring(5, 9); @@ -442,7 +442,7 @@ use Studip\Button, Studip\LinkButton; set_mktime(rec_index); set_time_inputs_in_row_required(rec_index); }); - + $('.end').change(function() { var name = this.getAttribute("name"); var rec_index = name.substring(3, 7); @@ -450,7 +450,7 @@ use Studip\Button, Studip\LinkButton; set_mktime(rec_index); set_time_inputs_in_row_required(rec_index); }); - + $('.break').change(function() { var name = this.getAttribute("name"); var rec_index = name.substring(5, 9); @@ -458,7 +458,7 @@ use Studip\Button, Studip\LinkButton; set_mktime(rec_index); set_time_inputs_in_row_required(rec_index); }); - + //handling of Urlaub and Krank $('.defined_comment').change(function() { var name = this.getAttribute("name"); @@ -485,7 +485,7 @@ use Studip\Button, Studip\LinkButton; }); </script> - + <!-- remove --> <script> @@ -498,6 +498,6 @@ use Studip\Button, Studip\LinkButton; // return false; // } } - + </script>