public function actionAdd()
 {
     $region = $_POST['region'];
     $out = $_POST['date_out'];
     $there = $_POST['date_there'];
     $back = $_POST['date_back'];
     $courier = $_POST['courier'];
     $table = new Timetable();
     $table->add_trip($region, $courier, $out, $there, $back);
     $redirect = new Redirect();
     $redirect->redir("", '');
 }
Exemple #2
0
 public function deleteAction($id = null)
 {
     if ($this->user && preg_match('/^[0-9]{1,11}$/', $id)) {
         $id = (double) $id;
         $row = Timetable::findFirstById($id);
         if ($row) {
             $row->delete();
         }
     }
 }
Exemple #3
0
 public function indexAction()
 {
     if (!$this->session->has('uid')) {
         echo $this->view->render('account', 'login');
     } else {
         $user = $this->session->get('uid');
         $list = Timetable::find(array('conditions' => 'user=:user:'******'bind' => array('user' => $user), 'order' => 'id desc', 'limit' => 10));
         $this->view->user = $user;
         $this->view->list = $list;
     }
 }
 public function postClassTimeTable()
 {
     $class_id = Input::get('class_id');
     $period = Timetable::where('class_id', '=', $class_id)->get();
     $periods = array();
     $i = 0;
     foreach ($period as $key => $value) {
         $periods[$i] = array('id' => $period[$key]['id'], 'title' => 'Networking', 'start' => $period[$key]['start_time'], 'end' => $period[$key]['end_time'], 'className' => 'event-job', 'category' => 'Job', 'allDay' => false, 'content' => 'Out to design conference');
         $i++;
     }
     $response = array('status' => 'success', 'msg' => 'Classes fetched successfully', 'errors' => null, 'classId' => $class_id, 'result' => array('periods' => $periods));
     return Response::json($periods);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($airplane_id)
 {
     $timetable_ids = [];
     foreach (json_decode(Input::get('timetable')) as $item) {
         if (isset($item->mysql_id)) {
             $timetable = Timetable::find($item->mysql_id);
         } else {
             $timetable = new Timetable();
         }
         $timetable->airline_id = Auth::user()->id;
         $timetable->airplane_id = $airplane_id;
         $timetable->origin_airport_id = $item->origin->id;
         $timetable->destination_airport_id = $item->destination->id;
         $timetable->departure_day_of_week = $item->departure_day_of_week;
         $timetable->departure_hour = $item->departure_hour;
         $timetable->flight_duration = $item->flight_duration;
         $timetable->flight_number = $item->flight_number;
         $timetable->save();
         array_push($timetable_ids, $timetable->id);
     }
     DB::table('timetables')->where('airplane_id', $airplane_id)->where('airline_id', Auth::user()->id)->whereNotIn('id', $timetable_ids)->delete();
     DB::table('flights')->where('airplane_id', $airplane_id)->where('airline_id', Auth::user()->id)->where('accounted', '=', '0')->whereNotIn('timetable_id', $timetable_ids)->delete();
 }
function addSlot($timetableID, $slot, $game, $numberOfSlots)
{
    $thisTimetable = Timetable::find_by_timetableid($timetableID);
    $contents = unserialize($thisTimetable->contents);
    $day = substr($slot, 0, 3);
    $time = intval(substr($slot, 4, 2));
    //counter for extra slots
    //Add to the array for how ever many slots there it
    for ($x = 1; $x <= intval($numberOfSlots); $x++) {
        $contents['timetable'][$day][$time] = $game;
        //Increment counters
        $time++;
    }
    $contents = serialize($contents);
    $thisTimetable->contents = $contents;
    $thisTimetable->save();
}
    public function index()
    {
        $most_popular_routes = Timetable::select(DB::raw('*,
					COUNT(*) AS flights_per_week,
					least(origin_airport_id, destination_airport_id) as city1,
					greatest(origin_airport_id, destination_airport_id) as city2'))->with('origin', 'destination', 'airline')->groupBy(DB::raw('least(origin_airport_id, destination_airport_id)'))->groupBy(DB::raw('greatest(origin_airport_id, destination_airport_id)'))->orderBy('flights_per_week', 'DESC')->limit(20)->get();
        $most_km = Flight::select(DB::raw('airline_id, SUM(`distance`) AS overall_distance, COUNT(*) AS number_of_flights'))->with('airline')->where('accounted', '1')->groupBy('airline_id')->orderBy('overall_distance', 'DESC')->limit(20)->get();
        $longest_flights = Flight::select(DB::raw('*,
					COUNT(*) AS flights_per_week,
					least(origin_airport_id, destination_airport_id) as city1,
					greatest(origin_airport_id, destination_airport_id) as city2'))->with('origin', 'destination')->groupBy(DB::raw('least(origin_airport_id, destination_airport_id)'))->groupBy(DB::raw('greatest(origin_airport_id, destination_airport_id)'))->orderBy('distance', 'DESC')->limit(10)->get();
        $shortest_flights = Flight::select(DB::raw('*'))->with('origin', 'destination')->groupBy('origin_airport_id')->orderBy('distance', 'ASC')->limit(5)->get();
        return View::make('statistics/index', array('most_popular_routes' => $most_popular_routes, 'most_km' => $most_km, 'longest_flights' => $longest_flights, 'shortest_flights' => $shortest_flights));
        /*
        SELECT  `origin_airport_id` ,  `destination_airport_id` ,  `airline_id` , COUNT(  `origin_airport_id` )
        		FROM  `timetables`
        		GROUP BY  `origin_airport_id` ,  `destination_airport_id` ,  `airline_id`
        		ORDER BY COUNT(  `origin_airport_id` ) ASC
        */
    }
Exemple #8
0
 /**
  * 学期理论课表
  * @param string $semester    学期
  * @param string $week        周次
  * @return array
  */
 public function timetable($semester, $week = '')
 {
     $timetable = new Timetable($this->cookie);
     return $timetable->get($semester, $week);
 }
     $groupexist = false;
     $res_grp = mysql_query("SELECT  \r\n\t\t\t\t\t\t\t\tr.xRunde\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\trunde as r\r\n\t\t\t\t\t\t\tWHERE\txWettkampf = {$_POST['eventgroup']}\r\n\t\t\t\t\t\t\tAND r.Gruppe ='' ");
     if (mysql_num_rows($res_grp) > 0) {
         $row_grp = mysql_fetch_array($res_grp);
         $groupexist = true;
     }
     if ($_POST['round'] > 0 || $groupexist) {
         $tt = new Timetable();
         if ($groupexist) {
             $tt->round = $row_grp[0];
             $tt->grp = $_POST['eventgroup'];
         }
         $tt->change();
     } else {
         if (!empty($_POST['min'])) {
             $tt = new Timetable();
             $tt->add();
         }
     }
     if (!empty($GLOBALS['AA_ERROR'])) {
         AA_printErrorMsg($GLOBALS['AA_ERROR']);
     }
 } elseif ($_POST['arg'] == "change_lastdisc") {
     // first check if there are seeded rounds in current and next 'last discipline'
     list($cCat, $cCode) = split("_", $_POST['lastround']);
     // fetch round from current last discipline (cCat, cCode) and rounds from selectet last discipline
     /*$res = mysql_query("SELECT 
     			r.xRunde
     		FROM
     			runde as r
     			, wettkampf as w
     list($_POST['hr'], $_POST['min']) = AA_formatEnteredTime($_POST['time']);
     // auto configure enrolement and manipulation time
     $result = mysql_query("\r\n        SELECT\r\n            d.Typ\r\n            , d.Appellzeit\r\n            , d.Stellzeit\r\n        FROM\r\n            wettkampf as w\r\n            LEFT JOIN disziplin as d USING(xDisziplin)\r\n        WHERE w.xWettkampf = " . $_POST['item']);
     $row = mysql_fetch_row($result);
     $stdEtime = strtotime($row[1]);
     // hold standard delay for enrolement time
     $stdMtime = strtotime($row[2]);
     // and manipulation time
     $tmp = strtotime($_POST['hr'] . ":" . $_POST['min'] . ":00");
     $tmp = $tmp - $stdEtime;
     $_POST['etime'] = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60);
     $tmp = strtotime($_POST['hr'] . ":" . $_POST['min'] . ":00");
     $tmp = $tmp - $stdMtime;
     $_POST['mtime'] = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60);
     // the other times are parsed in the timetable constructor
     $tt = new Timetable();
     $tt->change();
 } elseif ($_POST['arg'] == "merge_add") {
     if (!empty($_POST['mainRound']) && !empty($_POST['round'])) {
         //mysql_query("LOCK TABLES rundenset WRITE, serie READ");
         mysql_query("LOCK TABLES rundenset WRITE, rundenset as rs READ ,serie READ, runde AS r Read, Wettkampf AS w READ, meeting READ ");
         $mr = $_POST['mainRound'];
         $r = $_POST['round'];
         $rs = $_POST['roundSet'];
         if (AA_checkReference("serie", "xRunde", $mr) != 0 || AA_checkReference("serie", "xRunde", $r) != 0) {
             $GLOBALS['AA_ERROR'] = $strErrHeatsAlreadySeeded;
         } else {
             // check group  (rounds with groups can not be merged)
             $res = mysql_query("SELECT r.Gruppe FROM runde As r WHERE r.xRunde = " . $mr . " OR r.xRunde = " . $r);
             if (mysql_errno() > 0) {
                 $GLOBALS['AA_ERROR'] = mysql_errno() . ": " . mysql_error();
Exemple #11
0
 function AA_meeting_addTime($st, $wTyp, $item, $dTyp)
 {
     // date, item, roundtype, hr, min
     include './convtables.inc.php';
     if ($wTyp > $cfgEventType[$strEventTypeSingleCombined] && $row[2] != $cfgEventType[$strEventTypeTeamSM]) {
         if ($dTyp == $cfgDisciplineType[$strDiscTypeTrack] || $dTyp == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $dTyp == $cfgDisciplineType[$strDiscTypeDistance] || $dTyp == $cfgDisciplineType[$strDiscTypeRelay]) {
             // discipline type track
             $_POST['roundtype'] = 6;
             // round type "Serie"
         } else {
             // discipline type tech
             $_POST['roundtype'] = 9;
             // round type "ohne"
         }
     }
     if (preg_match("/[\\.,;:]/", $st) == 0) {
         $_POST['hr'] = substr($st, 0, -2);
         if (strlen($st) == 3) {
             $_POST['min'] = substr($st, 1);
         } elseif (strlen($st) == 4) {
             $_POST['min'] = substr($st, 2);
         }
     } else {
         list($_POST['hr'], $_POST['min']) = preg_split("/[\\.,;:]/", $st);
     }
     // auto configure enrolement and manipulation time
     $result = mysql_query("\r\n        SELECT\r\n            d.Typ\r\n            , d.Appellzeit\r\n            , d.Stellzeit\r\n        FROM\r\n            wettkampf as w\r\n            LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d USING(xDisziplin)\r\n        WHERE w.xWettkampf = " . $item);
     $row = mysql_fetch_row($result);
     $stdEtime = strtotime($row[1]);
     // hold standard delay for enrolement time
     $stdMtime = strtotime($row[2]);
     // and manipulation time
     $tmp = strtotime($_POST['hr'] . ":" . $_POST['min'] . ":00");
     $tmp = $tmp - $stdEtime;
     $_POST['etime'] = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60);
     $tmp = strtotime($_POST['hr'] . ":" . $_POST['min'] . ":00");
     $tmp = $tmp - $stdMtime;
     $_POST['mtime'] = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60);
     if ($_POST['round'] > 0) {
         $tt = new Timetable();
         $tt->change();
     } else {
         $tt = new Timetable();
         $tt->add();
     }
 }
"/>
            <button type="button" name="close" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="submit" name="action" class="btn btn-primary" value="addTimeslot">Apply</button>
          </form>
        </div>
      </div>
    </div>
  </div>
<?php 
} else {
    ?>
  <?php 
    //Populate array for the add timetable form
    $allEvents = Event::find('all');
    //Populate array for view timetable table
    $allTimetables = Timetable::find('all', array('conditions' => array('eventid = ?', $_SESSION['event'])));
    ?>
  <h2>Timetable Management</h2>
  <form action="/includes/modules/timetableManagement/timetables.php" class="form-horizontal" method="POST">
    <div class="form-group" id="timetableNameInputDiv">
      <label for="timetableName" class="col-sm-2 control-label">Name</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" id="timetableName" name="timetableName" placeholder="Timetable name" value="<?php 
    echo $_POST['timetableName'];
    ?>
" required>
      </div>
    </div>
    <Input type="hidden" name="event" value="<?php 
    echo $_SESSION['event'];
    ?>
 /**
  * Create single timetable and link it with $bus.
  *
  * @var $type string (working_day, sunday, holiday)
  * @var $time string
  * @var $bus object
  * @return boolean
  */
 protected function create_timetable($type, $time, $bus)
 {
     $n_timetable = new Timetable(array('type' => $type, 'time' => $time));
     $n_timetable->save();
     $bus_timetable = new BusTimetablePivotal(array('bus_id' => $bus->id, 'timetable_id' => $n_timetable->id));
     $bus_timetable->timestamps = false;
     $bus_timetable->save();
 }
 public function postDeletePeriods()
 {
     $period_id = Input::get('period_id');
     $class_id = Input::get('class_id');
     $day_id = Input::get('day_id');
     $section_id = Input::get('section_id');
     $subject_id = Input::get('subject_id');
     $teacher_id = Input::get('teacher_id');
     if ($period_id) {
         $period = Timetable::find($period_id);
     } else {
         $period = Timetable::where('section_id', '=', $section_id)->where('class_id', '=', $class_id)->where('subject_id', '=', $subject_id)->where('users_id', '=', $teacher_id)->where('day_id', '=', $day_id);
     }
     if ($period->delete()) {
         $response = array('status' => 'success', 'msg' => 'Timetable Period deleted successfully', 'result' => array('period' => $period));
         return Response::json($response);
     } else {
         $response = array('status' => 'failed', 'msg' => 'Timetable Period could not be deleted successfully', 'result' => array('period' => $period));
         return Response::json($response);
     }
 }
 protected function validate()
 {
     $required = array("section" => "Section");
     global $user;
     if ($user->checkAdmin() == true) {
         if (isset($_POST)) {
             foreach ($required as $key => $value) {
                 if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
                     echo $value . ' is Required<br/>';
                     return;
                 }
             }
             global $objPDO;
             include $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/timetable_settings_class.php';
             $sett = new TimetableSettings($objPDO);
             $slots = $sett->getAllSlots();
             if (!isset($slots)) {
                 $num_slots = 0;
             } else {
                 $num_slots = count($slots);
             }
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/timetable_class.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_teacher_subject_class.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/controller/utility_class.php';
             for ($i = 0; $i < count($_POST['time_table']); $i++) {
                 $spl = array();
                 $spl = explode("-", $_POST['time_table'][$i]);
                 if (isset($spl[1])) {
                     $ttab = new Timetable($objPDO);
                     $ttab->setSectionId($_POST['section']);
                     $ttab->setSlot($spl[1]);
                     $ttab->getBySecSlot();
                     if ($spl[0] != '0') {
                         $rel = new SectionTeacherSubjectRelations($objPDO);
                         $tid = $rel->getByClassSubject($_POST['section'], $spl[0]);
                         if ($ttab->checkTeacherSlot($spl[1], $tid, $_POST['section'])) {
                             $ttab->setSubjectId($spl[0]);
                             $ttab->setTeacherId($tid);
                         } else {
                             $ttab->markForDeletion();
                             include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/subject_class.php';
                             $sub = new Subject($objPDO, $spl[0]);
                             $day = floor($spl[1] / $num_slots);
                             $slot = $spl[1] % $num_slots;
                             echo "Teacher Slot Unavailable for " . $sub->getName() . " at " . Utility::getDay($day + 1) . " " . $slots[$slot] . "<br/>";
                             return;
                             $label = false;
                         }
                     } else {
                         if ($spl[0] == '0') {
                             $ttab->markForDeletion();
                         }
                     }
                     if (!isset($label) || $label != false) {
                     }
                     $ttab->save();
                 }
             }
             echo 'Saving...';
             if (!isset($label) || $label != false) {
                 echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/timetable"/>';
             }
         }
     } else {
         header('Location:http://localhost/cloud');
     }
 }
 public function getStudentTermsByStudentId($id)
 {
     $yearsData = $this->find('all', array('fields' => array('SchoolYear.id', 'SchoolYear.name', 'SClass.id', 'SClass.name'), 'recursive' => -1, 'joins' => array(array('table' => 'classes', 'alias' => 'SClass', 'conditions' => array('SClass.id = ClassStudent.class_id')), array('table' => 'school_years', 'alias' => 'SchoolYear', 'conditions' => array('SchoolYear.id = SClass.school_year_id'))), 'conditions' => array('ClassStudent.student_id' => $id), 'order' => array('SchoolYear.name')));
     $data = array();
     if (!empty($yearsData)) {
         //Retrive each semester from timetable
         App::import('Model', 'Timetable');
         $TimetableModel = new Timetable();
         foreach ($yearsData as $key => $singleYear) {
             //pr($singleYear['SchoolYear']['name']);
             $timetablesData = $TimetableModel->getAllTimetableByClass($singleYear['SClass']['id']);
             if (!empty($timetablesData)) {
                 $data = $this->setupSchoolTermsArrayData($singleYear['SchoolYear']['name'], $timetablesData);
             }
         }
     }
     return $data;
 }