public function updateApiFromEvent(Google_Service_Calendar_Event $event, Member $member, $publicFlag) { $conn = $this->getConnection(); $conn->beginTransaction(); try { $schedule = $this->findOneByApiIdUnique($event->id); if ('cancelled' === $event->status) { if ($schedule) { $schedule->delete(); } $conn->commit(); return true; } if (!$schedule) { $schedule = new Schedule(); $schedule->setApiIdUnique($event->id); } elseif ($event->etag === $schedule->api_etag) { $conn->rollback(); return $schedule->id; } $schedule->setTitle($event->summary); $schedule->setBody($event->description); $schedule->setMember($member); $schedule->setPublicFlag($this->getEventPublicFlag($event, $publicFlag)); if ($event->start->dateTime) { $startDateTime = new DateTime($event->start->dateTime); $schedule->setStartDate($startDateTime->format('Y-m-d')); $schedule->setStartTime($startDateTime->format('H:i:s')); } elseif ($event->start->date) { $schedule->setStartDate($event->start->date); } if ($event->end->dateTime) { $endDateTime = new DateTime($event->end->dateTime); $schedule->setEndDate($endDateTime->format('Y-m-d')); $schedule->setEndTime($endDateTime->format('H:i:s')); } elseif ($event->end->date) { $schedule->setStartDate($event->end->date); } $schedule->setApiEtag($event->etag); $schedule->save(); ScheduleMemberTable::getInstance()->updateScheduleMember(array('schedule_id' => $schedule->id, 'member_id' => $schedule->member_id)); foreach ($event->attendees as $attendee) { $memberId = opCalendarPluginToolkit::seekEmailAndGetMemberId($attendee->email); if (!$memberId) { continue; } ScheduleMemberTable::getInstance()->updateScheduleMember(array('schedule_id' => $schedule->id, 'member_id' => $memberId)); } $conn->commit(); } catch (Exception $e) { $conn->rollback(); throw $e; } return $schedule->id; }
public function addSchedule() { $members = Member::find('all', ['order' => 'username']); $this->setViewData('members', $members); if ($_POST) { $schedule = new Schedule(); $schedule->date = strtotime($_POST['date']); $schedule->member_id = $_POST['member_id']; $schedule->save(); $this->redirect($this->url()); } }
/** * Создает новую модель Расписания. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Schedule(); if (Yii::app()->getRequest()->getPost('Schedule') !== null) { $model->setAttributes(Yii::app()->getRequest()->getPost('Schedule')); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ListnerModule.listner', 'Запись добавлена!')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id])); } } $this->render('create', ['model' => $model]); }
public function actionCreate() { $model = new Schedule(); $model2 = new ProfessorCourse(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Schedule'])) { $sql = ' select sem.end_Date from professor_course pc join courses co on pc.course_Id = co.course_Id join semesters sem on sem.semester_Id = co.semester_Id where professor_Course_Id = "' . $_POST['Schedule']['professor_Course_Id'] . '" ; '; $row1Class = Yii::app()->db->createCommand($sql)->queryRow(); $sql2 = ' select day from class_type where class_Type_Id = "' . $_POST['Schedule']['class_Type_Id'] . '" ; '; $row2Class = Yii::app()->db->createCommand($sql2)->queryRow(); $endDate = $row1Class['end_Date']; $dayNameEndDate = $row2Class['day']; $date = date('Y-m-d'); while ($date != $endDate) { $dayName = date('l', strtotime($date)); if ($dayName == $dayNameEndDate) { $model = new Schedule(); $model->date = $date; $model->attributes = $_POST['Schedule']; // other fileds if they are not getting assigned if (!$model->save()) { echo '<pre>'; print_r($model->getErrors()); echo '</pre>'; exit; } } $date = strtotime("+1 day", strtotime($date)); $date = date("Y-m-d", $date); } $this->redirect(array('index')); } $this->render('_Form2', array('model' => $model, 'model2' => $model2)); }
/** * Add new Schedule * * @return bool */ public function add($name, $desc, $start_date, $end_date, $updatedby) { $validator = Validator::make(array('name' => $name, 'desc' => $desc, 'start_date' => $start_date, 'end_date' => $end_date, 'updatedby' => $updatedby), array('name' => array('required', 'min:3'), 'desc' => array(), 'start_date' => array('required'), 'end_date' => array('required'), 'updatedby' => array('alpha_num', 'required'))); // Validation did not pass if ($validator->fails()) { throw new Exception($validator->messages()); } try { $schedule = new Schedule(); $schedule->name = $name; $schedule->desc = $desc; $schedule->start_date = $start_date; $schedule->end_date = $end_date; $schedule->updatedby = $updatedby; $schedule->save(); return true; } catch (Exception $ex) { return $ex; } }
public function createSchedule() { $rules = array('name' => 'required', 'rule' => 'required', 'period' => 'required'); $period = Input::get('period'); try { Carbon::now()->modify('+ ' . $period); } catch (Exception $e) { return Redirect::to('/schedules/new')->with('message', array('type' => 'danger', 'text' => 'Period has invalid format'))->withInput(); } $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('/schedules/new')->withErrors($validator)->withInput(); } $schedule = new Schedule(); $schedule->user_id = Auth::user()->id; $schedule->rule = Input::get('rule'); $schedule->period = $period; $schedule->name = Input::get('name'); $schedule->save(); return Redirect::to('/schedules/new')->with('message', array('type' => 'success', 'text' => 'Schedule was created!')); }
public function actionSaveInfo() { //echo 1; $number = $_POST['num']; $title = $_POST['title']; $content = $_POST['content']; $route_id = $_POST['route_id']; if ($number != '' || $title != '' || $content != '') { $v_num = explode('$$$$$$', $number); $v_title = explode('$$$$$$', $title); $v_content = explode('$$$$$$', $content); //echo 1; //echo $number; $a = ''; for ($i = 0; $i < count($v_num); $i++) { $schedule = new Schedule(); $schedule->title = $v_title[$i]; $schedule->content = $v_content[$i]; $schedule->day = $v_num[$i]; $schedule->save(); $a .= $schedule->id; if ($i != count($v_num) - 1) { $a .= ','; } } Route::model()->updateByPk($route_id, array('schedule' => $a, 'days' => count($v_num))); } else { Route::model()->updateByPk($route_id, array('schedule' => NULL, 'days' => 0)); } $this->redirect(Yii::app()->request->urlReferrer); echo 1; }
protected function afterSave() { parent::afterSave(); if ($this->isNewRecord && $this->is_test == 0) { //Формирование расписания пользователя if ($this->isNewRecord && $this->group == "on") { $group = new Group(); $group->code = $this->listner->branch->group_counter + 1; $group->name = $group->name = $group->code . ' | ' . date('Y-m-d', strtotime("+2 week")); $group->time = $this->time; $group->lvl = $this->lvl; $group->note = $this->note; $group->teacher_id = $this->teacher_id; $group->number = $this->form->number; $group->hui = $this->hui; $group->branch_id = $this->listner->branch_id; $group->subject_id = $this->subject_id; $group->parent_id = $this->id; if ($this->parent_group) { $group->parent_group = $this->parent_group; if ($group->prev->first_parent_group) { $group->first_parent_group = $group->prev->first_parent_group; } else { $group->first_parent_group = $group->prev->id; } } $group->is_active = 1; $group->save(); if ($this->form->type->id == 4) { $this->listner->branch->individual_counter += 1; } else { $this->listner->branch->group_counter += 1; } $this->listner->branch->save(); } if ($this->form->type->id == 3) { $time = explode(',', $this->time); $tCount = count($time); $j = 0; $k = 0; for ($i = 0; $i < $this->form->number; $i++) { if ($j == $tCount) { $j = 0; $k++; } $schedule = new Schedule(); //if($this->form->type->id == 3 || $this->form->type->id == 4) //$schedule->position_id = $this->id; // else{ // $schedule->position_id = $this->id; $schedule->position_id = $this->id; $schedule->number = $i + 1; $schedule->teacher_id = $this->teacher_id; $schedule->start_time = str_replace(" ", "T", date('Y-m-d H:i:s', strtotime("+" . $k . "week", strtotime($time[$j])))); if ($this->hui == "on") { $pizda = 30; } else { $pizda = 0; } $schedule->end_time = str_replace(" ", "T", date('Y-m-d H:i:s', strtotime("+" . $k . "week 1 hours " . $pizda . " minutes", strtotime($time[$j])))); $schedule->room_id = $this->findRoom($schedule->start_time, $this->listner->branch_id, 1); $schedule->save(); $j++; } if ($this->form->type->id == 3) { $this->listner->branch->individual_counter += 1; $this->listner->branch->save(); } } //Формирование прихода $inflow = new Inflow(); $inflow->subject_id = $this->subject_id; $inflow->receiver = $this->teacher->user->fullName; $inflow->form_id = $this->form_id; if ($this->is_old == "on") { $inflow->price = $this->form->old_price; } else { $inflow->price = $this->form->price; } $inflow->based = $this->code; $inflow->comment = $this->note; $inflow->date = $this->start_date; $inflow->branch_id = $this->listner->branch_id; $inflow->save(); //Изменение статуса if ($this->listner->status != 1) { $this->listner->status = 1; $this->listner->save(); } } }
/** * Updates entry revision * * @param Schedule $schedule * @param ScheduleEntry $entry * @param string $action * @param string $old * @param string $new * @return void */ public static function logRevision($schedule, $entry, $action, $old, $new) { // workaround for older events where revision history is not present if ($schedule->entry_revisions == "") { $schedule->entry_revisions = json_encode(["0" => ["entry id" => "", "job type" => "", "action" => "Keine frühere Änderungen vorhanden.", "old id" => "", "old value" => "", "new id" => "", "new value" => "", "user id" => "", "user name" => "", "from ip" => "", "timestamp" => (new DateTime())->format('d.m.Y H:i:s')]]); } // decode revision history $revisions = json_decode($schedule->entry_revisions, true); // decode old values if (!is_null($old)) { $oldId = $old->id; switch ($old->prsn_status) { case "candidate": $oldStatus = "(K)"; break; case "member": $oldStatus = "(A)"; break; case "veteran": $oldStatus = "(V)"; break; default: $oldStatus = ""; } $oldName = $old->prsn_name . $oldStatus . "(" . $old->getClub->clb_title . ")"; } else { $oldId = ""; $oldName = ""; } // decode new values if (!is_null($new)) { $newId = $new->id; switch ($new->prsn_status) { case "candidate": $newStatus = "(K)"; break; case "member": $newStatus = "(A)"; break; case "veteran": $newStatus = "(V)"; break; default: $newStatus = ""; } $newName = $new->prsn_name . $newStatus . "(" . $new->getClub->clb_title . ")"; } else { $newId = ""; $newName = ""; } // append current change array_push($revisions, ["entry id" => $entry->id, "job type" => $entry->getJobType->jbtyp_title, "action" => $action, "old id" => $oldId, "old value" => $oldName, "new id" => $newId, "new value" => $newName, "user id" => Session::get('userId') != NULL ? Session::get('userId') : "", "user name" => Session::get('userId') != NULL ? Session::get('userName') . '(' . Session::get('userClub') . ')' : "Gast", "from ip" => Request::getClientIp(), "timestamp" => (new DateTime())->format('d.m.Y H:i:s')]); // encode and save $schedule->entry_revisions = json_encode($revisions); $schedule->save(); }
public function executeSaveCopy() { $accal_tujuan = AcademicCalendarPeer::retrieveByPk($this->getRequestParameter('accal1')); $accal_asal = AcademicCalendarPeer::retrieveByPk($this->getRequestParameter('accal2')); $params = array(); foreach (explode('&', $this->getRequestParameter('ekskul_list_ser')) as $p) { $p = explode('=', $p); $params[rawurldecode($p[0])][] = rawurldecode($p[1]); } if (array_key_exists('ekskuls', $params)) { foreach ($params['ekskuls'] as $ekskul_id) { $sc = SchedulePeer::retrieveByPK($ekskul_id); $cw = new Criteria(); $cw->add(ScheduleDetailPeer::SCHEDULE_ID, $sc->getId()); $sc_details = ScheduleDetailPeer::doSelect($cw); $cd = new Criteria(); $cd->add(ScheduleTutorPeer::SCHEDULE_ID, $sc->getId()); $sc_tutors = ScheduleTutorPeer::doSelect($cd); $schedule = new Schedule(); $schedule->setGradeComponentId($sc->getGradeComponentId()); $schedule->setAcademicCalendarId($accal_tujuan->getId()); $schedule->setType(2); $schedule->setEmployeeId($sc->getEmployeeId()); $schedule->save(); foreach ($sc_details as $sc_detail) { $schedule_detail = new ScheduleDetail(); $schedule_detail->setSchedule($schedule); $schedule_detail->setLocationId($sc_detail->getLocationId()); $schedule_detail->setClassSessionId($sc_detail->getClassSessionId()); $schedule_detail->setDay($sc_detail->getDay()); $schedule_detail->save(); $cb = new Criteria(); $cb->add(StudentRaportPeer::GRADE_COMPONENT_ID, $sc->getGradeComponentId()); $cb->add(StudentRaportPeer::ACADEMIC_CALENDAR_ID, $sc->getAcademicCalendarId()); $cb->add(StudentRaportPeer::SCHEDULE_DETAIL_ID, $sc_detail->getId()); $cb->add(StudentRaportPeer::SCHEDULE_ID, $sc->getId()); $stu_raports = StudentRaportPeer::doSelect($cb); foreach ($stu_raports as $stu_raport) { $sr = new StudentRaport(); $sr->setStudentId($stu_raport->getStudentId()); $sr->setAcademicCalendarId($accal_tujuan->getId()); $sr->setGradeComponentId($sc->getGradeComponentId()); $sr->setClassGroupId($sc->getClassGroupId()); $sr->setSchedule($schedule); $sr->setScheduleDetail($schedule_detail); $sr->save(); } } foreach ($sc_tutors as $sc_tutor) { $schedule_tutor = new ScheduleTutor(); $schedule_tutor->setSchedule($schedule); $schedule_tutor->setEmployeeId($sc_tutor->getEmployeeId()); $schedule_tutor->save(); } } } return $this->redirect('extracurricular/list'); }
function schedules_save($id = '', $page = '') { $data['page_name'] = '<b>Save Schedule</b>'; $data['msg'] = ''; $this->load->helper('options'); $s = new Schedule(); $data['sched'] = $s->get_by_id($id); if (Input::get('op')) { $all_time = array('am_in_hour' => Input::get('am_in_hour'), 'am_in_min' => Input::get('am_in_min'), 'am_out_hour' => Input::get('am_out_hour'), 'am_out_min' => Input::get('am_out_min'), 'pm_in_hour' => Input::get('pm_in_hour'), 'pm_in_min' => Input::get('pm_in_min'), 'pm_out_hour' => Input::get('pm_out_hour'), 'pm_out_min' => Input::get('pm_out_min')); $s->name = Input::get('name'); $s->times = serialize($all_time); $s->save(); Session::flash('msg', 'Schedule saved!'); return Redirect::to('attendance/schedules/' . $page, 'refresh'); } $times = $s->times; $times = unserialize($times); $data['am_in_hour_selected'] = $times['am_in_hour']; $data['am_in_min_selected'] = $times['am_in_min']; $data['am_out_hour_selected'] = $times['am_out_hour']; $data['am_out_min_selected'] = $times['am_out_min']; $data['pm_in_hour_selected'] = $times['pm_in_hour']; $data['pm_in_min_selected'] = $times['pm_in_min']; $data['pm_out_hour_selected'] = $times['pm_out_hour']; $data['pm_out_min_selected'] = $times['pm_out_min']; $data['main_content'] = 'schedules_save'; return View::make('includes/template', $data); }
require "Schedule.inc.php"; require "connectToDataBase.inc.php"; if (isset($_REQUEST['save'])) { // handle ajax save request (do not show the interface) // we posted . characters, but something converts them to _ (HTTP 1.1 standard) $r = array(); foreach ($_REQUEST as $i => $v) { $r[join('.', explode('_', $i))] = $v; //convert _ back to . } $Process = array(); for ($i0 = 0; isset($r['0.' . $i0]); $i0++) { $Process[$i0] = array('id' => @$r['0.' . $i0 . '.0'], 'nr' => @$r['0.' . $i0 . '.0'], 'session' => @$r['0.' . $i0 . '.1'], 'case' => @$r['0.' . $i0 . '.2'], 'scheduled' => @$r['0.' . $i0 . '.3']); } $Schedule = new Schedule($Process); if ($Schedule->save() !== false) { die('ok:' . $_SERVER['PHP_SELF']); } else { die(''); } exit; // do not show the interface } $buttons = ""; if (isset($_REQUEST['edit'])) { $edit = true; } else { $edit = false; } $Schedule = new Schedule(); writeHead("<TITLE>Schedule - VIRO - ADL Prototype</TITLE>" . ($edit ? '<SCRIPT type="text/javascript" src="edit.js"></SCRIPT>' : '<SCRIPT type="text/javascript" src="navigate.js"></SCRIPT>') . "\n");
protected function afterSave() { if (Yii::app() instanceof CConsoleApplication) { return; } $isAdmin = Yii::app()->user->checkRole(User::ROLE_DELEGATE); //处理代表和主办 foreach (array('organizer', 'delegate') as $attribute) { $attributeId = $attribute . '_id'; $oldValues = array_values(CHtml::listData($this->{$attribute}, $attributeId, $attributeId)); $newValues = array_values((array) $this->{$attribute . 's'}); sort($oldValues); sort($newValues); if ($oldValues != $newValues) { $modelName = 'Competition' . ucfirst($attribute); foreach ($oldValues as $value) { if (!in_array($value, $newValues) && $isAdmin) { $modelName::model()->deleteAllByAttributes(array('competition_id' => $this->id, $attributeId => $value)); } } foreach ($newValues as $value) { if (!in_array($value, $oldValues)) { $model = new $modelName(); $model->competition_id = $this->id; $model->{$attribute . '_id'} = $value; $model->save(); } } } } //处理赛程 $schedules = $this->schedules; if (!empty($schedules['start_time'])) { Schedule::model()->deleteAllByAttributes(array('competition_id' => $this->id)); foreach ($schedules['start_time'] as $key => $startTime) { if (empty($startTime) || !isset($schedules['end_time'][$key]) || empty($schedules['end_time'][$key])) { continue; } $model = new Schedule(); $model->competition_id = $this->id; $model->start_time = strtotime($startTime); $model->end_time = strtotime($schedules['end_time'][$key]); $model->day = $schedules['day'][$key]; $model->stage = $schedules['stage'][$key]; $model->event = $schedules['event'][$key]; $model->group = $schedules['group'][$key]; $model->round = $schedules['round'][$key]; $model->format = $schedules['format'][$key]; $model->number = intval($schedules['number'][$key]); $model->cut_off = intval($schedules['cut_off'][$key]); $model->time_limit = intval($schedules['time_limit'][$key]); $model->save(false); } } //处理地址 $oldLocations = $this->location; foreach ($this->locations as $key => $value) { if (isset($oldLocations[$key])) { $location = $oldLocations[$key]; } else { $location = new CompetitionLocation(); $location->competition_id = $this->id; $location->location_id = $key; } $location->attributes = $value; $location->save(false); } if ($this->isOld()) { $this->old->save(false); } }
$schedule->prefinput = $_POST['prefinput']; $schedule->inetref = $_POST['inetref']; $schedule->season = intval($_POST['season']); $schedule->episode = intval($_POST['episode']); // Keep track of the parent recording for overrides if ($_POST['record'] == rectype_override) { $schedule->parentid = $schedule->recordid; } // Search schedules saved here will create a new standard schedule, // so we should wipe out the old search-type data. if ($schedule->search) { $schedule->recordid = null; } $schedule->search = 0; // Back up the program type, and save the schedule $schedule->save($type); } } // Redirect back to the page again, but without the query string, so reloads are cleaner if ($db->query_col('SELECT COUNT(*) FROM program WHERE chanid = ? and starttime = FROM_UNIXTIME(?) LIMIT 1', $program->chanid, $program->starttime) == 0) { redirect_browser(root . 'tv/detail?recordid=' . $schedule->recordid); } redirect_browser(root_url . 'tv/detail/' . $program->chanid . '/' . $program->starttime); } elseif ($_REQUEST['forget_old']) { $program->rec_forget_old(); // Redirect back to the page again, but without the query string, so reloads are cleaner redirect_browser(root_url . 'tv/detail/' . $program->chanid . '/' . $program->starttime); } elseif (isset($_GET['never_record']) || isset($_POST['never_record'])) { $program->rec_never_record(); // Redirect back to the page again, but without the query string, so reloads are cleaner redirect_browser(root_url . 'tv/detail/' . $program->chanid . '/' . $program->starttime);
public function postShift() { $path = public_path(); $allowedExts = array("xls", "xlsx", "csv"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); //$filename= $temp[0]; $filename = $temp[0] . '_' . date('YmdHis') . '_' . rand(111, 999); $destinationPath = $path . '/uploads/' . $filename . '.' . $extension; if (in_array($extension, $allowedExts) && $_FILES["file"]["size"] < 20000000) { if ($_FILES["file"]["error"] > 0) { //echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { //if (file_exists($path."/uploads/" . $_FILES["file"]["name"])) if (file_exists($path . "/uploads/" . $filename)) { //echo $_FILES["file"]["name"] . " already exists. "; } else { $uploadSuccess = move_uploaded_file($_FILES["file"]["tmp_name"], $destinationPath); Excel::load($destinationPath, function ($reader) { //$results = Excel::load('public/products2.xls')->get(); $result = $reader->all(); $reader->toArray(); //$reader->dump(); // Loop through all the sheets $reader->each(function ($sheet) { // Loop through all rows $sheet->each(function ($row) { //$date = $row->schedule_date; //$scheduleDate = date('Y-m-d', strtotime($schedule_date)); $schedule = new Schedule(); $schedule->employee_id = $row->employee_id; $schedule->year = $row->year; $schedule->month = $row->month; $schedule->day = $row->day; $schedule->day = $row->shift; $schedule->day = $row->rest_day; //$schedule->day = $row->hours_per_day; $schedule->start_time = $row->start_time; $schedule->end_time = $row->end_time; $schedule->schedule_date = date('Y-m-d', strtotime($row->schedule_date)); $schedule->save(); //Redirect::action('EmployeesController@index'); }); }); }); /*if( $uploadSuccess ) { $document_details=Response::json(Author::insert_document_details_Call($filename,$destinationPath)); return $document_details; // or do a redirect with some message that file was uploaded } else { return Response::json('error', 400); }*/ Session::flash('error', 'Uploading of employee is successful'); //return Redirect::action('EmployeesController@indexshift'); return Redirect::route('adminScheduling'); } } } else { return "Invalid file"; } }
protected function afterSave() { parent::afterSave(); if ($this->isNewRecord) { $this->position->group_id = $this->id; $this->position->code = $this->code; $this->position->update(); $time = explode(',', $this->time); $tCount = count($time); $j = 0; $k = 0; for ($i = 0; $i < $this->number; $i++) { if ($j == $tCount) { $j = 0; $k++; } $schedule = new Schedule(); $schedule->group_id = $this->id; $schedule->number = $i + 1; $schedule->teacher_id = $this->teacher_id; $schedule->start_time = str_replace(" ", "T", date('Y-m-d H:i:s', strtotime("+" . $k . "week", strtotime($time[$j])))); if ($this->hui == "on") { $pizda = 30; } else { $pizda = 0; } $schedule->end_time = str_replace(" ", "T", date('Y-m-d H:i:s', strtotime("+" . $k . "week 1 hours " . $pizda . " minutes", strtotime($time[$j])))); //die(var_dump($this->branch_id)); $schedule->room_id = $this->findRoom($schedule->start_time, $this->branch_id, count($this->positions)); if (!$schedule->save()) { die(var_dump($schedule->getErrors())); } $j++; } } }
public function update_schedule() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); $data["actions"] = Session::get('actions'); if (in_array('side_armar_horario', $data["actions"])) { $level_id = Input::get('level_id'); // si es un tutor, solo puede armar horario de su nivel $data["is_tutor"] = $data["user"]->profiles()->where('name', '=', 'Tutor')->first() ? true : false; if ($data["is_tutor"] && $data["user"]->teacher->level->id != $level_id) { Session::flash('error', 'Usted no puede modificar este horario.'); return Redirect::to('levels/' . $level_id . '/schedule')->withInput(Input::all()); } // Validate the info, create rules for the inputs $attributes = array('initial_hour' => 'Hora de inicio', 'final_hour' => 'Hora de fin', 'course_ids' => 'Cursos'); $messages = array(); $rules = array('initial_hour' => 'required', 'final_hour' => 'required', 'course_ids' => 'required'); // Run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules, $messages, $attributes); // If the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('levels/' . $level_id . '/schedule')->withErrors($validator)->withInput(Input::all()); } else { $course_ids = Input::get('course_ids'); $initial_hour = Input::get('initial_hour'); $final_hour = Input::get('final_hour'); if ($initial_hour >= $final_hour) { Session::flash('error', 'La hora de fin debe ser mayor a la hora de inicio.'); return Redirect::to('levels/' . $level_id . '/schedule')->withInput(Input::all()); } if (!Schedule::verifyHourIntersection($level_id, $initial_hour, $final_hour)) { Session::flash('error', 'Las horas se intersectan.'); return Redirect::to('levels/' . $level_id . '/schedule')->withInput(Input::all()); } if ($course_ids == ['0', '0', '0', '0', '0', '0']) { Session::flash('error', 'Debe ingresar al menos un curso.'); return Redirect::to('levels/' . $level_id . '/schedule')->withInput(Input::all()); } // Lunes if ($course_ids['0'] != '0') { $schedule = new Schedule(); $schedule->initial_hour = $initial_hour; $schedule->final_hour = $final_hour; $schedule->day = 'Lunes'; $schedule->course_id = $course_ids['0']; $schedule->save(); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó el horario con id: {{$schedule->id}}"; Helpers::registerLog(3, $log_description); } // Martes if ($course_ids['1'] != '0') { $schedule = new Schedule(); $schedule->initial_hour = $initial_hour; $schedule->final_hour = $final_hour; $schedule->day = 'Martes'; $schedule->course_id = $course_ids['1']; $schedule->save(); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó el horario con id: {{$schedule->id}}"; Helpers::registerLog(3, $log_description); } // Miercoles if ($course_ids['2'] != '0') { $schedule = new Schedule(); $schedule->initial_hour = $initial_hour; $schedule->final_hour = $final_hour; $schedule->day = 'Miercoles'; $schedule->course_id = $course_ids['2']; $schedule->save(); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó el horario con id: {{$schedule->id}}"; Helpers::registerLog(3, $log_description); } // Jueves if ($course_ids['3'] != '0') { $schedule = new Schedule(); $schedule->initial_hour = $initial_hour; $schedule->final_hour = $final_hour; $schedule->day = 'Jueves'; $schedule->course_id = $course_ids['3']; $schedule->save(); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó el horario con id: {{$schedule->id}}"; Helpers::registerLog(3, $log_description); } // Viernes if ($course_ids['4'] != '0') { $schedule = new Schedule(); $schedule->initial_hour = $initial_hour; $schedule->final_hour = $final_hour; $schedule->day = 'Viernes'; $schedule->course_id = $course_ids['4']; $schedule->save(); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó el horario con id: {{$schedule->id}}"; Helpers::registerLog(3, $log_description); } // Sabado if ($course_ids['5'] != '0') { $schedule = new Schedule(); $schedule->initial_hour = $initial_hour; $schedule->final_hour = $final_hour; $schedule->day = 'Sabado'; $schedule->course_id = $course_ids['5']; $schedule->save(); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó el horario con id: {{$schedule->id}}"; Helpers::registerLog(3, $log_description); } Session::flash('message', 'Se actualizó correctamente el horario.'); return Redirect::to('levels/' . $level_id . '/schedule'); } } else { // Llamo a la función para registrar el log de auditoria $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'"; Helpers::registerLog(10, $log_description); Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.'); return Redirect::to('/dashboard'); } } else { return View::make('error/error'); } }
$db->disable_fatal_errors(); $sh = $db->query('SELECT NULL FROM program, channel' . str_replace('?', '\\?', $schedule->subtitle) . ' WHERE ' . str_replace('?', '\\?', $schedule->description)); $db->enable_fatal_errors(); if ($db->error) { add_error("There is an error in your custom SQL query:\n\n" . preg_replace('/^.+?SQL\\s+syntax;\\s*/', '', $db->error)); } } else { $schedule->description = _or($_POST['search_phrase'], $_POST['title']); $schedule->subtitle = ''; } // Figure out the title $schedule->title = _or($_POST['title'], $schedule->description) . ' (' . t('$1 Search', $schedule->search_type) . ')'; // Only save if there are no errors if (!errors()) { // Save the schedule $schedule->save($_POST['record']); // Redirect to the new schedule header('Location: ' . root_url . 'tv/schedules/custom/' . $schedule->recordid); exit; } } } else { // Make sure we have a default rectype if (!$schedule->type) { $schedule->type = rectype_always; } // Get the searchtype string switch ($schedule->search) { case searchtype_power: $schedule->search_type = t('Power'); break;
public function post_generate() { $data = Input::json(); //edit schedule generate all on one click $found = Schedule::where('fleet_id', '=', $data->fleet_id)->where('month', '=', $data->month)->where('year', '=', $data->year)->count(); if (!($found > 0)) { $schedule = new Schedule(); $schedule->pool_id = Auth::user()->pool_id; $schedule->fleet_id = $data->fleet_id; $schedule->schedule_master_id = $data->schedule_master_id; $schedule->month = $data->month; $schedule->year = $data->year; $schedule->user_id = Auth::user()->id; $schedule->inserted_date_set = date('Y-m-d H:i:s'); $schedule->save(); $schedule_id = $schedule->id; $interval = Schedulemaster::find($data->schedule_master_id); $h = 1; $z = 0; $g = 1; for ($i = 1; $i <= date('t', mktime(1, 2, 3, $data->month, 1, $data->year)); $i++) { //new generate if ($data->day == $i) { $z = 1 + $data->sisaopscharlie; } if ($z <= $interval->charlie_interval && $z !== 0) { $driver_id = $data->charlie_id; $z++; } else { if ($i > $data->day) { if ($h <= $interval->bravo_interval) { $driver_id = $data->bravo_id; $h++; } else { if ($g <= $interval->charlie_interval) { $driver_id = $data->charlie_id; $g++; } else { $h = 2; $g = 1; $driver_id = $data->bravo_id; } } } else { $driver_id = $data->bravo_id; } } // penentuan shift operasi (kalong, reguler, non shift) belum di definisikan $schdate = new Scheduledate(); $schdate->schedule_id = $schedule_id; $schdate->date = $i; $schdate->driver_id = $driver_id; $schdate->shift_id = $data->shift; $schdate->fg_check = 0; $schdate->inserted_date_set = date('Y-m-d H:i:s'); $schdate->save(); } return $schedule_id; } $error['error'] = array('text' => 'jadwal sudah pernah di buat'); return Response::error('500', $error); //return '{"error":{"text":"jadwal sudah pernah di buat"}}'; }