/**
  * Updates schedule entries of a specific schedule.
  *
  * If a password is needed, check it's correct and throw an error to the session if it's not,
  * update all entries in bulk otherwise.
  *
  * @param int $id
  *
  * @return RedirectResponse
  */
 private function onUpdate($id)
 {
     $schedule = Schedule::findOrFail($id);
     $entries = ScheduleEntry::where('schdl_id', '=', $id)->get();
     // Check if that schedule needs a password
     if ($schedule->schdl_password !== '') {
         //get password for specific id here, similar to enty->id
         if (!Hash::check(Input::get('password'), $schedule->schdl_password)) {
             Session::put('message', Config::get('messages_de.schedule-pw-needed'));
             Session::put('msgType', 'danger');
             return Redirect::back();
         }
     }
     foreach ($entries as $entry) {
         // Remember old value for logging
         $oldPerson = $entry->getPerson;
         // Entry was empty
         if (!isset($entry->prsn_id)) {
             // Entry is not empty now
             if (!Input::get('userName' . $entry->id) == '') {
                 // Add new entry data
                 $this->onAdd($entry);
                 // log revision
                 ScheduleController::logRevision($entry->getSchedule, $entry, "Dienst eingetragen", $oldPerson, $entry->getPerson()->first());
                 // new value
             }
             // Otherwise no change found - do nothing
         } else {
             // Same person there?
             if ($entry->getPerson->prsn_name == Input::get('userName' . $entry->id) and Person::where('id', '=', $entry->prsn_id)->first()->prsn_ldap_id == Input::get('ldapId' . $entry->id)) {
                 // Was comment updated?
                 if ($entry->entry_user_comment != Input::get('comment' . $entry->id)) {
                     $entry->entry_user_comment = Input::get('comment' . $entry->id);
                 }
                 // Otherwise no change found - do nothing
             } else {
                 // Was entry deleted?
                 if (Input::get('userName' . $entry->id) == '') {
                     $this->onDelete($entry);
                     // log revision
                     ScheduleController::logRevision($entry->getSchedule, $entry, "Dienst ausgetragen", $oldPerson, $entry->getPerson()->first());
                     // new value
                 } else {
                     // delete old data
                     $this->onDelete($entry);
                     // add new data
                     $this->onAdd($entry);
                     // log revision
                     ScheduleController::logRevision($entry->getSchedule, $entry, "Dienst geƤndert", $oldPerson, $entry->getPerson()->first());
                     // new value
                 }
             }
         }
     }
 }
 /**
  * Edit or create a schedule with its entered information.
  * If $scheduleId is null create a new schedule, otherwise the schedule specified by $scheduleId will be edit. 
  *
  * @param int $scheduleId
  * @return Schedule newSchedule
  */
 private function editSchedule($scheduleId)
 {
     $schedule = ScheduleController::editSchedule($scheduleId);
     $schedule->schdl_title = Input::get('title');
     $schedule->schdl_time_preparation_start = null;
     return $schedule;
 }
 /**
  * Edit or create a schedule with its entered information.
  * If $scheduleId is null create a new schedule, otherwise the schedule specified by $scheduleId will be edit. 
  *
  * @param int $scheduleId
  * @return Schedule newSchedule
  */
 private function editSchedule($scheduleId)
 {
     $schedule = ScheduleController::editSchedule($scheduleId);
     $schedule->schdl_due_date = null;
     return $schedule;
 }
Example #4
0
            header('Route Not Found', true, 404);
        }
        break;
    case 'POST':
        ScheduleController::create($_POST);
        break;
    case 'GET':
        if (isset($request) && !empty($request) && $request[0] !== '') {
            if ($request[0] == 'check') {
                $field = $request[1];
                $value = $request[2];
                ScheduleController::check($field, $value);
            } else {
                $id = $request[0];
                ScheduleController::detail($id);
            }
        } else {
            ScheduleController::read();
        }
        break;
    case 'DELETE':
        if (isset($request) && !empty($request) && $request[0] !== '') {
            $id = $request[0];
            ScheduleController::delete($id);
        }
        break;
    default:
        print json_encode('ENTRANCE EXAM API v.0.1 developed by: Philip Cesar B. Garay');
        break;
}
exit;
Example #5
0
<?php

require_once 'db_connect.php';
// Aktualizacja danych
require 'ScheduleManager.php';
require 'ScheduleController.php';
/*
$backend = new ScheduleManager();
$backend->updateAllData();
*/
$schedule_controller = new ScheduleController();
$schedule_controller->getTeacherList();
$schedule_controller->getClassList();
$schedule_controller->getClassroomList();
if (isset($_GET['type']) && isset($_GET['id'])) {
    $type = $_GET['type'];
    $id = $_GET['id'];
    if ($type == 'class') {
        $schedule_controller->getClassSchedule($id);
    } elseif ($type == 'classroom') {
        $schedule_controller->getClassroomSchedule($id);
    } elseif ($type == 'teacher') {
        $schedule_controller->getTeacherSchedule($id);
    }
}