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; } }
/** * 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(); }
"/> <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']; ?>
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); } }