Ejemplo n.º 1
0
 public function overview()
 {
     $members = Member::find('all', ['order' => 'username']);
     $this->setViewData('members', $members);
     $schedules = Schedule::find('all', ['conditions' => ['date >= UNIX_TIMESTAMP()'], 'order' => 'date']);
     $this->setViewData('schedules', $schedules);
 }
 public function get_records_html()
 {
     $records = RegisterRecord::where('user_id', Session::get('user.id'))->with('doctor')->get();
     foreach ($records as $record) {
         $doctor = $record->doctor;
         $period = $record->period()->first();
         $schedule = Schedule::find($period['schedule_id']);
         $schedule_info = array('date' => $schedule->date, 'period' => $this->possible_period[$schedule->period], 'start' => date('H:i', strtotime($period->start)), 'end' => date('H:i', strtotime($period->end)));
         $data[] = array('id' => $record->id, 'status' => $this->possible_status[$record->status], 'can_be_canceled' => $record->status == 0, 'created_at' => $record->created_at->format('Y-m-d H:i'), 'start' => $record->status ? date('Y-m-d H:i', strtotime($record->start)) : '', 'schedule' => $schedule_info, 'department' => $doctor->department->name, 'doctor' => array('id' => $doctor->id, 'name' => $doctor->name, 'title' => $doctor->title));
     }
     return View::make('user.record', array('records' => $data));
 }
 public function get_periods()
 {
     $schedule = Schedule::find(Input::get('schedule_id'));
     if (!isset($schedule)) {
         return Response::json(array('error_code' => 1, 'message' => '不存在该排班'));
     }
     $periods = $schedule->periods;
     if (!isset($periods)) {
         return Response::json(array('error_code' => 2, 'message' => '该排班无日期'));
     }
     return Response::json(array('error_code' => 0, 'periods' => $periods));
 }
Ejemplo n.º 4
0
 public function post()
 {
     if (Input::has('api_key') && Input::has('content')) {
         $api_key = Input::get('api_key');
         $content = Input::get('content');
         $settings = Settings::where('api_key', '=', $api_key)->first();
         $user_id = $settings->user_id;
         $default_networks = json_decode($settings->default_networks, true);
         $schedule = Carbon::now();
         if (Input::has('queue')) {
             $schedule_id = $settings->schedule_id;
             $interval = Schedule::find($schedule_id);
             if ($interval->rule == 'add') {
                 $schedule = $current_datetime->modify('+ ' . $interval->period);
             } else {
                 if ($interval->rule == 'random') {
                     $current_day = date('d');
                     $from_datetime = Carbon::now();
                     $to_datetime = $from_datetime->copy()->modify('+ ' . $interval->period);
                     $days_to_add = $from_datetime->diffInDays($to_datetime);
                     $day = mt_rand($current_day, $current_day + $days_to_add);
                     $hour = mt_rand(1, 23);
                     $minute = mt_rand(0, 59);
                     $second = mt_rand(0, 59);
                     //year, month and timezone is null
                     $schedule = Carbon::create(null, null, $day, $hour, $minute, $second, null);
                 }
             }
             if (empty($schedule)) {
                 $schedule = $current_datetime->addHours(1);
             }
         }
         if (!empty($default_networks)) {
             $post = new Post();
             $post->user_id = $user_id;
             $post->content = $content;
             $post->date_time = $schedule;
             $post->save();
             $post_id = $post->id;
             foreach ($default_networks as $network_id) {
                 $post_network = new PostNetwork();
                 $post_network->user_id = $user_id;
                 $post_network->post_id = $post_id;
                 $post_network->network_id = $network_id;
                 $post_network->status = 1;
                 $post_network->save();
             }
             Queue::later($schedule, 'SendPost@fire', array('post_id' => $post_id));
             $response_data = array('type' => 'success', 'text' => 'Your post was scheduled! It will be published on ' . $schedule->format('l jS \\o\\f F \\a\\t h:i A'));
             return $response_data;
         }
     }
 }
 public function select_period()
 {
     $schedule = Schedule::find(Input::get('schedule_id'));
     if (!isset($schedule)) {
         // ..
     }
     $doctor = $schedule->doctor;
     $periods = $schedule->periods;
     foreach ($periods as $period) {
         $period->start = date('H:i', strtotime($period->start));
         $period->end = date('H:i', strtotime($period->end));
     }
     return View::make('register.select_period', array('doctor' => array('name' => $doctor->name, 'photo' => $doctor->photo, 'title' => $doctor->title, 'specialty' => strip_tags($doctor->specialty), 'department' => $doctor->department->name, 'hospital' => $doctor->department->hospital->name), 'schedule' => $schedule, 'periods' => $periods->toArray()));
 }
Ejemplo n.º 6
0
 protected function schedule_notification($appt_id)
 {
     $row1 = Schedule::find($appt_id);
     if ($row1->pid != '0') {
         $row = Demographics::find($row1->pid);
         $row2 = Practiceinfo::find(Session::get('practice_id'));
         $row0 = User::find($row1->provider_id);
         $displayname = $row0->displayname;
         $to = $row->reminder_to;
         $phone = $row2->phone;
         $startdate = date("F j, Y, g:i a", $row1->start);
         if ($row1->start < time()) {
             if ($to != '') {
                 $data_message['startdate'] = date("F j, Y, g:i a", $row1->start);
                 $data_message['displayname'] = $row0->displayname;
                 $data_message['phone'] = $row2->phone;
                 $data_message['email'] = $row2->email;
                 $data_message['additional_message'] = $row2->additional_message;
                 if ($row->reminder_method == 'Cellular Phone') {
                     $this->send_mail(array('text' => 'emails.remindertext'), $data_message, 'Appointment Reminder', $to, Session::get('practice_id'));
                 } else {
                     $this->send_mail('emails.reminder', $data_message, 'Appointment Reminder', $to, Session::get('practice_id'));
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 public function get_editscheduleonmaster($scheduledate_id = false)
 {
     if (!$scheduledate_id) {
         return false;
     }
     $schd = Scheduledate::find($scheduledate_id);
     $schm = Schedule::find($schd->schedule_id);
     $stmp = mktime(0, 0, 0, $schm->month, $schd->date, $schm->year);
     $this->data['date'] = Myfungsi::fulldate($stmp);
     $this->data['schd'] = $schd;
     $this->data['schm'] = $schm;
     $this->data['month'] = date('n', $stmp);
     $this->data['year'] = date('Y', $stmp);
     $this->data['bckso'] = Kso::where('fleet_id', '=', $schm->fleet_id)->where('actived', '=', 1)->first();
     return View::make('themes.modul.' . $this->views . '.editscheduleonmaster', $this->data);
 }
Ejemplo n.º 8
0
 /**
  * Show the form for editing the specified schedule.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $schedule = Schedule::find($id);
     return View::make('schedules.edit', compact('schedule'));
 }
Ejemplo n.º 9
0
 /**
  * Add an override or dontrec record to force this show to/not record pass in
  * rectype_dontrec or rectype_override constants
  **/
 public function rec_override($rectype)
 {
     $schedule =& Schedule::find($this->recordid);
     // Unknown schedule?
     if (!$schedule) {
         add_error('Unknown schedule for this program\'s recordid:  ' . $this->recordid);
         return;
     }
     // Update the schedule with the new program info
     $schedule->chanid = $this->chanid;
     $schedule->starttime = $this->starttime;
     $schedule->endtime = $this->endtime;
     $schedule->title = $this->title;
     $schedule->subtitle = $this->subtitle;
     $schedule->description = $this->description;
     $schedule->category = $this->category;
     $schedule->station = $this->channel->callsign;
     // Note that "callsign" becomes "station"
     $schedule->seriesid = $this->seriesid;
     $schedule->programid = $this->programid;
     //        $schedule->search      = 0;
     $schedule->inactive = 0;
     // Save the schedule -- it'll know what to do about the override
     $schedule->save($rectype);
 }
Ejemplo n.º 10
0
 public function post_toolspj()
 {
     $date = Input::get('tanggal', date('Y-m-d'));
     ini_set('max_execution_time', 120);
     $timestamp = strtotime($date);
     //list armada on schedule
     $arrayschedule = array();
     $schedule = Schedule::where('month', '=', date('n', $timestamp))->where('year', '=', date('Y', $timestamp))->get(array('id', 'fleet_id'));
     foreach ($schedule as $sc) {
         $arrayschedule[] = $sc->id;
     }
     $fleets = array();
     if (is_array($arrayschedule) && !empty($arrayschedule)) {
         $fleets = Scheduledate::join('schedules', 'schedules.id', '=', 'schedule_dates.schedule_id')->join('fleets', 'fleets.id', '=', 'schedules.fleet_id')->join('ksos', 'ksos.fleet_id', '=', 'schedules.fleet_id')->where_in('schedule_dates.schedule_id', $arrayschedule)->where('schedules.pool_id', '=', Auth::user()->pool_id)->where('schedule_dates.date', '=', date('j', $timestamp))->where('schedules.month', '=', date('n', $timestamp))->where('schedule_dates.shift_id', '=', 1)->where('ksos.actived', '=', 1)->order_by('fleets.taxi_number', 'asc')->get(array('schedule_dates.id as id', 'schedule_dates.driver_id', 'schedules.fleet_id', 'fleets.taxi_number'));
     }
     if ($fleets) {
         foreach ($fleets as $f) {
             $scheduledate = Scheduledate::find($f->id);
             $scheduledate->fg_check = 1;
             $scheduledate->save();
             $schedule = Schedule::find($scheduledate->schedule_id);
             //$driverinfo = Driver::find($scheduledate->driver_id);
             //$fleetinfo = Fleet::find($schedule->fleet_id);
             $ksoinfo = Kso::where_fleet_id($schedule->fleet_id)->where_actived(1)->first();
             $dateopertion = mktime(0, 0, 0, $schedule->month, $scheduledate->date, $schedule->year);
             $checkouts = Checkout::where_fleet_id($schedule->fleet_id)->where_operasi_time(date('Y-m-d', $dateopertion))->first();
             //delete checkouts
             if ($checkouts) {
                 $checkouts->delete();
             }
             $codeops = 1;
             $status = 7;
             $keterangan = 'Print SPJ melalui Tools';
             if (!$checkouts) {
                 //insert into to checkouts step
                 $checkouts = new Checkout();
                 $checkouts->kso_id = $ksoinfo->id;
                 $checkouts->operasi_time = date('Y-m-d', $dateopertion);
                 $checkouts->fleet_id = $schedule->fleet_id;
                 $checkouts->driver_id = $scheduledate->driver_id;
                 $checkouts->checkout_step_id = $status;
                 $checkouts->shift_id = $scheduledate->shift_id;
                 $checkouts->user_id = Auth::user()->id;
                 $checkouts->pool_id = Auth::user()->pool_id;
                 $checkouts->printspj_time = date('Y-m-d H:i:s', Myfungsi::sysdate());
                 $checkouts->operasi_status_id = $codeops;
                 $checkouts->keterangan = $keterangan;
                 $checkouts->save();
                 $cinada = Checkin::where('operasi_time', '=', date('Y-m-d', $dateopertion))->where('fleet_id', '=', $schedule->fleet_id)->first();
                 if ($cinada) {
                     $cinada->delete();
                 }
                 if (!$cinada) {
                     $cin = Checkin::create(array('kso_id' => $ksoinfo->id, 'fleet_id' => $schedule->fleet_id, 'driver_id' => $scheduledate->driver_id, 'checkin_time' => date('Y-m-d H:i:s', Myfungsi::sysdate()), 'shift_id' => $scheduledate->shift_id, 'km_fleet' => 0, 'rit' => 0, 'incomekm' => 0, 'operasi_time' => date('Y-m-d', $dateopertion), 'pool_id' => Auth::user()->pool_id, 'operasi_status_id' => $codeops, 'fg_late' => '', 'checkin_step_id' => 2, 'document_check_user_id' => Auth::user()->id, 'physic_check_user_id' => '', 'bengkel_check_user_id' => '', 'finance_check_user_id' => '', 'keterangan' => $keterangan));
                     if ($cin) {
                         $docs = new Checkindocument();
                         $docs->checkin_id = $cin->id;
                         $docs->save();
                         //return Redirect::to('schedule');
                     }
                     //
                 }
             }
         }
         return Redirect::to('schedule');
     }
 }
Ejemplo n.º 11
0
        if ($_REQUEST['forget_old']) {
            $program->rec_forget_old();
        } elseif ($_REQUEST['never_record']) {
            $program->rec_never_record();
        } elseif ($_REQUEST['default']) {
            $program->rec_default();
        } elseif ($_REQUEST['dontrec']) {
            $program->rec_override(rectype_dontrec);
        } elseif ($_REQUEST['record']) {
            $program->rec_override(rectype_override);
        } elseif ($_REQUEST['activate']) {
            $program->activate();
        }
    } else {
        if ($_REQUEST['dontrec']) {
            $schedule =& Schedule::find($_GET['chanid'], $_GET['starttime'])->save(rectype_dontrec);
        } else {
            add_warning('Unknown program.');
        }
    }
    // Redirect back to the page again, but without the query string, so reloads are cleaner
    redirect_browser(root_url . 'tv/upcoming');
}
// Ignore certain shows?
if ($_POST['change_display']) {
    $_SESSION['scheduled_recordings']['disp_scheduled'] = $_POST['disp_scheduled'] ? true : false;
    $_SESSION['scheduled_recordings']['disp_duplicates'] = $_POST['disp_duplicates'] ? true : false;
    $_SESSION['scheduled_recordings']['disp_deactivated'] = $_POST['disp_deactivated'] ? true : false;
    $_SESSION['scheduled_recordings']['disp_conflicts'] = $_POST['disp_conflicts'] ? true : false;
    $_SESSION['scheduled_recordings']['disp_recgroup'] = $_POST['disp_recgroup'];
    $_SESSION['scheduled_recordings']['disp_title'] = $_POST['disp_title'];
Ejemplo n.º 12
0
 public function createPost()
 {
     $user_id = Auth::user()->id;
     $rules = array('content' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         if (Input::has('ajax')) {
             return array('type' => 'danger', 'messages' => $validator->messages());
         } else {
             return Redirect::to('/post/new')->withErrors($validator)->withInput();
         }
     }
     $content = Input::get('content');
     $post_now = Input::get('post_now');
     $schedule_type = Input::get('schedule');
     if (empty($schedule_type)) {
         $schedule_type = Setting::where('user_id', '=', $user_id)->pluck('schedule_id');
     }
     $schedule_id = Settings::where('user_id', '=', $user_id)->pluck('schedule_id');
     $current_datetime = Carbon::now();
     $schedule = Carbon::now();
     if ($post_now == '0' && $schedule_type != 'custom') {
         $schedule_id = $schedule_type;
         $interval = Schedule::find($schedule_id);
         if ($interval->rule == 'add') {
             $schedule = $current_datetime->modify('+ ' . $interval->period);
         } else {
             if ($interval->rule == 'random') {
                 $current_day = date('d');
                 $from_datetime = Carbon::now();
                 $to_datetime = $from_datetime->copy()->modify('+ ' . $interval->period);
                 $days_to_add = $from_datetime->diffInDays($to_datetime);
                 $day = mt_rand($current_day, $current_day + $days_to_add);
                 $hour = mt_rand(1, 23);
                 $minute = mt_rand(0, 59);
                 $second = mt_rand(0, 59);
                 //year, month and timezone is null
                 $schedule = Carbon::create(null, null, $day, $hour, $minute, $second, null);
             }
         }
         if (empty($schedule)) {
             $schedule = $current_datetime->addHours(1);
         }
     } else {
         $schedule = Carbon::parse(Input::get('schedule_value'));
     }
     $networks = Input::get('network');
     if (empty($networks)) {
         $networks = Setting::where('user_id', '=', $user_id)->pluck('default_networks');
         $networks = json_decode($networks, true);
     }
     $post = new Post();
     $post->user_id = $user_id;
     $post->content = $content;
     $post->date_time = $schedule->toDateTimeString();
     $post->save();
     $post_id = $post->id;
     foreach ($networks as $network_id) {
         $post_network = new PostNetwork();
         $post_network->user_id = $user_id;
         $post_network->post_id = $post_id;
         $post_network->network_id = $network_id;
         $post_network->status = 1;
         $post_network->save();
     }
     Queue::later($schedule, 'SendPost@fire', array('post_id' => $post_id));
     if (Input::has('ajax')) {
         return array('type' => 'success', 'text' => 'Your post was scheduled! It will be published on ' . $schedule->format('l jS \\o\\f F \\a\\t h:i A'));
     }
     return Redirect::to('/post/new')->with('message', array('type' => 'success', 'text' => 'Your post was scheduled! It will be published on ' . $schedule->format('l jS \\o\\f F \\a\\t h:i A')));
 }
 public function postApptView($appt_id, $pid)
 {
     $row = Schedule::find($appt_id);
     $row1 = Demographics::find($pid);
     $text = '<strong>Patient:</strong>  ' . $row1->firstname . " " . $row1->lastname . '<br><br><strong>Start Date:</strong>  ' . date('m/d/Y h:i A', $row->start) . '<br><br><strong>End Date:</strong>  ' . date('m/d/Y h:i A', $row->end) . '<br><br><strong>Visit Type:</strong> ' . $row->visit_type . '<br><br><strong>Reason:</strong> ' . $row->reason . '<br><br><strong>Status:</strong> ' . $row->status;
     echo $text;
 }
Ejemplo n.º 14
0
 public function delete_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"])) {
             $id = Input::get('schedule_id');
             $schedule = Schedule::find($id);
             $level = $schedule->course->level;
             // si es un tutor, solo puede eliminar el horario de su nivel
             $is_tutor = $data["user"]->profiles()->where('name', '=', 'Tutor')->first() ? true : false;
             if ($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');
             }
             $s_ids = $level->schedules()->where('initial_hour', '=', $schedule->initial_hour)->where('final_hour', '=', $schedule->final_hour)->get()->lists('id');
             Schedule::whereIn('id', $s_ids)->delete();
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se eliminaron los Horarios con ids: " . implode(', ', $s_ids);
             Helpers::registerLog(5, $log_description);
             Session::flash('message', 'Se eliminó correctamente la hora.');
             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');
     }
 }
Ejemplo n.º 15
0
 /**
  * Delete a task specified by parameter $id with scheduleEntries.
  * You can only delete, if you have rigths for marketing or clubleitung.
  *
  * @param int $id
  * @return RedirectResponse
  */
 public function deleteTask($id)
 {
     if (!Session::has('userId')) {
         Session::put('message', Config::get('messages_de.access-denied'));
         Session::put('msgType', 'danger');
         return Redirect::action('MonthController@showMonth', array('year' => date('Y'), 'month' => date('m')));
     }
     // at first get all data
     $schedule = Schedule::find($id);
     if (is_null($schedule)) {
         Session::put('message', Config::get('messages_de.task-doesnt-exist'));
         Session::put('msgType', 'danger');
         return Redirect::back();
     }
     // log the action
     Log::info('Delete task: User ' . Session::get('userId') . ' with rigths ' . Session::get('userGroup') . ' deletes task ' . $schedule->schdl_title . ' with id ' . $schedule->id . '.');
     $entries = $schedule->getEntries()->GetResults();
     // at least delete date in reverse order 'cause of dependencies in database
     foreach ($entries as $entry) {
         $entry->delete();
     }
     $schedule->delete();
     // show current month
     Session::put('message', Config::get('messages_de.delete-task-ok'));
     Session::put('msgType', 'success');
     return Redirect::action('ScheduleController@showTaskList');
 }
<?php

// Attempt to force some caching, will make secondary views so much faster.
header('Cache-Control: max-age-' . ($_REQUEST['starttime'] - time() + 604800));
header('Pragma: ');
header('Expires: ' . date('D, d M Y H:i:s e', $_REQUEST['starttime'] + 604800));
header('Content-Type: application/json');
echo json_encode(array('id' => 'schedule-' . $_REQUEST['recordid'], 'info' => Schedule::find($_REQUEST['recordid'])->details_list()));
Ejemplo n.º 17
0
    # Admin Delete Schedules;
    Route::get('/delete/{id}', function ($id) {
        $scObj = Schedule::find($id);
        //dd($scObj);
        $delobj = $scObj->delete();
        if ($delobj) {
            echo 1;
        } else {
            echo 0;
        }
    });
    Route::post('/add', array('uses' => 'RainTvController@postNewshedule'));
    # Admin edit Schedules
    Route::get('/edit/{id}', function ($id) {
        $user = Sentry::getUser();
        $schedules = Schedule::find($id);
        return View::make('backend.editschedules')->with('schedule', $schedules)->with('user', $user);
    });
    Route::post('/edit/{id}', array('uses' => 'RainTvController@postUpdateshedule'));
});
// Admin Panel | Videos
Route::group(array('before' => 'admin.login', 'prefix' => 'admin/videos'), function () {
    # Admin Videos
    Route::get('/', function () {
        $videos = Videos::get();
        return View::make('backend.listvideos')->with('videos', $videos);
    });
    # Admin Videos by schedules
    Route::get('/schedule', function () {
        return View::make('backend.listvideosbyschedule');
    });
Ejemplo n.º 18
0
 *
 * @package     MythWeb
 * @subpackage  TV
 *
 **/
// Scheduling a manual recording gets its own page
if ($Path[2] == 'manual' || $Path[2] == 'custom') {
    require_once 'modules/tv/schedules_' . $Path[2] . '.php';
    exit;
}
// Load the sorting routines
require_once 'includes/sorting.php';
// Parse the recording list
$the_schedules = array();
foreach (Schedule::findAll() as $key) {
    $schedule =& Schedule::find($key);
    // Ignore overrides
    #    if ($schedule->type == rectype_override)
    #        continue;
    #    if ($schedule->type == rectype_dontrec)
    #        continue;
    // Ignore manual schedules
    #    if ($schedule->category == 'Manual recording')
    #        continue;
    // Couple of modifications
    if ($schedule->type == rectype_dontrec) {
        $schedule->profile = '';
        $schedule->recgroup = '';
    }
    // Add a blank channel, to suppress warnings
    if (!$schedule->channel) {
Ejemplo n.º 19
0
</th>
    <?php 
}
?>
</tr><?php 
$row = 0;
$prev_group = '';
$cur_group = '';
foreach ($all_shows as $show) {
    flush();
    // Set the class to be used to display the recording status character
    $rec_class = implode(' ', array(recstatus_class($show), $show->recstatus));
    // Reset the command variable to a default URL
    $commands = array();
    $urlstr = $show->chanid . '/' . $show->starttime;
    if (Schedule::find($show->recordid)->search == searchtype_manual) {
        $urlstr .= '/' . $show->recordid;
    }
    // Set the recording status character, class and any applicable commands for each show
    switch ($show->recstatus) {
        case 'Recording':
            $rec_char = $show->inputname;
            $css_class = 'scheduled';
            break;
        case 'WillRecord':
            $rec_char = $show->inputname;
            $css_class = 'scheduled';
            $commands[] = 'dontrec';
            // Offer to suppress any recordings that have enough info to do so.
            if (preg_match('/\\S/', $show->title) && preg_match('/\\S/', $show->programid . $show->subtitle . $show->description)) {
                $commands[] = 'never_record';
Ejemplo n.º 20
0
 /**
  * @return mixed
  * @throws \ActiveRecord\RecordNotFound
  */
 public function getSchedules()
 {
     $options = ['conditions' => ['date >= ?', strtotime(date('Y-m-d 00:00:00'))], 'order' => 'date ASC'];
     $schedules = Schedule::find('all', $options);
     return $schedules;
 }
Ejemplo n.º 21
0
 * Schedule a custom recording by manually specifying various search options
 *
 *
 * @package     MythWeb
 * @subpackage  TV
 *
 * http://www.gossamer-threads.com/lists/mythtv/dev/102890?search_string=keyword%20search;#102890
 *
/**/
// Path-based
if ($Path[3]) {
    $_GET['recordid'] = $Path[3];
}
// Load an existing schedule?
if ($_GET['recordid']) {
    $schedule =& Schedule::find($_GET['recordid']);
    // Not a custom search schedule
    if (empty($schedule->search) || $schedule->search == searchtype_manual) {
        redirect_browser(root_url . 'tv/schedules');
    }
} else {
    $schedule = new Schedule(NULL);
}
// The user tried to update the recording settings - update the database and the variable in memory
if (isset($_POST['save'])) {
    // Which type of recording is this?  Make sure an illegal one isn't specified
    $schedule->search_type = '';
    switch ($_POST['searchtype']) {
        case searchtype_power:
            $schedule->search_type = 'Power';
            break;
Ejemplo n.º 22
0
 public function post_qzotorisasicetak()
 {
     $data = Input::json();
     $username = $data->username;
     $password = $data->password;
     $ver2 = User::where('username', '=', $username)->first();
     if ($ver2) {
         if (Hash::check($password, $ver2->password)) {
             Log::write('info', Request::ip() . ' User : '******' Event: Print SPJ otoritas', true);
             $scheduledate = Scheduledate::find($data->id);
             $schedule = Schedule::find($scheduledate->schedule_id);
             $scheduledate->fg_check = 1;
             $scheduledate->save();
             $driverinfo = Driver::find($scheduledate->driver_id);
             $fleetinfo = Fleet::find($schedule->fleet_id);
             $ksoinfo = Kso::where_fleet_id($schedule->fleet_id)->where_actived(1)->first();
             $this->data['driverinfo'] = $driverinfo;
             $this->data['fleetinfo'] = $fleetinfo;
             $this->data['pool'] = Pool::find($schedule->pool_id);
             $codeops = $data->statusops;
             $keterangan = $data->keterangan;
             if ((int) $codeops == 1) {
                 if ($driverinfo->fg_blocked == 1) {
                     $status = 5;
                     $codeops = 7;
                 } else {
                     if ($driverinfo->fg_super_blocked == 1) {
                         $status = 5;
                         $codeops = 7;
                     } else {
                         if ($fleetinfo->fg_blocked == 1) {
                             $status = 5;
                             $codeops = 7;
                         } else {
                             if ($fleetinfo->fg_bengkel == 1) {
                                 $status = 6;
                                 $codeops = 4;
                             } else {
                                 if ($fleetinfo->fg_super_blocked == 1) {
                                     $status = 5;
                                     $codeops = 7;
                                 } else {
                                     $status = 3;
                                     $codeops = $codeops;
                                 }
                             }
                         }
                     }
                 }
             } else {
                 $status = 3;
             }
             $dateopertion = mktime(0, 0, 0, $schedule->month, $scheduledate->date, $schedule->year);
             $checkouts = Checkout::where_fleet_id($schedule->fleet_id)->where_operasi_time(date('Y-m-d', $dateopertion))->first();
             if (!$checkouts) {
                 //insert into to checkouts step
                 $checkouts = new Checkout();
                 $checkouts->kso_id = $ksoinfo->id;
                 $checkouts->operasi_time = date('Y-m-d', $dateopertion);
                 $checkouts->fleet_id = $fleetinfo->id;
                 $checkouts->driver_id = $driverinfo->id;
                 $checkouts->checkout_step_id = $status;
                 $checkouts->shift_id = $scheduledate->shift_id;
                 $checkouts->user_id = Auth::user()->id;
                 $checkouts->pool_id = Auth::user()->pool_id;
                 $checkouts->printspj_time = date('Y-m-d H:i:s', Myfungsi::sysdate());
                 $checkouts->operasi_status_id = $codeops;
                 $checkouts->keterangan = $keterangan;
                 $checkouts->print_out_time = 1;
                 $checkouts->otorisasi_user_id = $ver2->id;
                 $checkouts->save();
                 if ((int) $codeops == 1) {
                     $scheduledate->fg_check = 1;
                     $scheduledate->save();
                 }
                 if ((int) $codeops !== 1) {
                     $cin = Checkin::create(array('kso_id' => $ksoinfo->id, 'fleet_id' => $fleetinfo->id, 'driver_id' => $driverinfo->id, 'checkin_time' => date('Y-m-d H:i:s', Myfungsi::sysdate()), 'shift_id' => $scheduledate->shift_id, 'km_fleet' => 0, 'rit' => 0, 'incomekm' => 0, 'operasi_time' => date('Y-m-d', $dateopertion), 'pool_id' => Auth::user()->pool_id, 'operasi_status_id' => $codeops, 'fg_late' => '', 'checkin_step_id' => 12, 'document_check_user_id' => Auth::user()->id, 'physic_check_user_id' => '', 'bengkel_check_user_id' => '', 'finance_check_user_id' => '', 'keterangan' => $keterangan));
                     if ($cin) {
                         $docs = new Checkindocument();
                         $docs->checkin_id = $cin->id;
                         $docs->save();
                     }
                     //make can't print before setoran
                     $setor = Fleet::find($fleetinfo->id);
                     $setor->fg_setor = 1;
                     $setor->save();
                 }
             } else {
                 if ((int) $codeops !== 1) {
                     $checkinstatus = Checkin::where_fleet_id($schedule->fleet_id)->where_operasi_time(date('Y-m-d', $dateopertion))->first();
                     if (!$checkinstatus) {
                         $cin = Checkin::create(array('kso_id' => $ksoinfo->id, 'fleet_id' => $fleetinfo->id, 'driver_id' => $driverinfo->id, 'checkin_time' => date('Y-m-d H:i:s', Myfungsi::sysdate()), 'shift_id' => $scheduledate->shift_id, 'km_fleet' => 0, 'rit' => 0, 'incomekm' => 0, 'operasi_time' => date('Y-m-d', $dateopertion), 'pool_id' => Auth::user()->pool_id, 'operasi_status_id' => $codeops, 'fg_late' => '', 'checkin_step_id' => 12, 'document_check_user_id' => Auth::user()->id, 'physic_check_user_id' => '', 'bengkel_check_user_id' => '', 'finance_check_user_id' => '', 'keterangan' => $keterangan));
                         if ($cin) {
                             $docs = new Checkindocument();
                             $docs->checkin_id = $cin->id;
                             $docs->save();
                         }
                     }
                 }
                 //reprint after open blocking
                 if ((int) $codeops == 1) {
                     $checkinremove = Checkin::where_fleet_id($schedule->fleet_id)->where_operasi_time(date('Y-m-d', $dateopertion))->where_in('operasi_status_id', array(2, 3, 4, 5, 6, 7))->first();
                     if ($checkinremove) {
                         $checkinremove->delete();
                         //make can print before setoran becouse update set on checkout step
                         $setor = Fleet::find($schedule->fleet_id);
                         $setor->fg_setor = 0;
                         $setor->save();
                     }
                 }
                 if ((int) $codeops == 1) {
                     $scheduledate->fg_check = 1;
                     $scheduledate->save();
                 }
                 $checkouts->kso_id = $ksoinfo->id;
                 $checkouts->operasi_time = date('Y-m-d', $dateopertion);
                 $checkouts->fleet_id = $fleetinfo->id;
                 $checkouts->driver_id = $driverinfo->id;
                 $checkouts->checkout_step_id = $status;
                 $checkouts->shift_id = $scheduledate->shift_id;
                 $checkouts->user_id = Auth::user()->id;
                 $checkouts->pool_id = Auth::user()->pool_id;
                 $checkouts->operasi_status_id = $codeops;
                 $checkouts->printspj_time = date('Y-m-d H:i:s', Myfungsi::sysdate());
                 $checkouts->keterangan = $keterangan;
                 $checkouts->print_out_time = 1;
                 $checkouts->otorisasi_user_id = $ver2->id;
                 $checkouts->save();
             }
             $content = "";
             if ($checkouts->operasi_status_id == 1) {
                 $kopsurat = 'SURAT PERINTAH JALAN';
                 $content .= "Nama dan kendaraan yang tercantum diatas";
                 $content .= "DI IZINKAN untuk mengoprasikan kendaraan";
                 $content .= "PT.DIAN TAKSI sesuai dengan tanggal yang";
                 $content .= "tercantum diatas\r\n";
                 $content .= "--------------------------------------- \r\n";
                 $content .= "a";
                 // 1 SET CENTER PAGE
                 $content .= "Tanda Tangan \r\n";
                 $content .= "a";
                 // 1 SET LEFT PAGE
                 $content .= "--------------------------------------- \r\n";
                 $content .= "  Bag. Operasi               Security \r\n";
                 $content .= "\r\n \r\n \r\n";
             } else {
                 $kopsurat = 'SURAT PENGANTAR PROSES BAP';
                 $content .= "Nama dan kendaraan yang tercantum diatas";
                 $content .= "TIDAK DI IZINKAN mengoprasikan kendaraan";
                 $content .= "PT.DIAN TAKSI sesuai dengan tanggal yang";
                 $content .= "tercantum diatas\r\n";
             }
             $headerPrint = "";
             for ($j = 1; $j < 2; $j++) {
                 $headerPrint .= "@";
                 $headerPrint .= "a";
                 // 1 SET CENTER PAGE
                 $headerPrint .= "!";
                 $headerPrint .= $kopsurat . " \r\n";
                 $headerPrint .= "!";
                 $headerPrint .= "@";
                 // 1 RESET
                 $headerPrint .= "a";
                 // 1 SET CENTER PAGE
                 $headerPrint .= "PT. DHARMA INDAH AGUNG METROPOLITAN \r\n";
                 $headerPrint .= "POOL " . Pool::find($checkouts->pool_id)->pool_name . " \r\n";
                 $headerPrint .= "======================================= \r\n";
                 $headerPrint .= "a";
                 // 1 SET LEFT PAGE
                 //content printer
                 $headerPrint .= "Nama        : " . substr($driverinfo->name, 0, 25) . " \r\n";
                 $headerPrint .= "Nip         : " . $driverinfo->nip . " \r\n";
                 $headerPrint .= "Body        : " . $fleetinfo->taxi_number . " \r\n";
                 $headerPrint .= "Tgl Operasi : " . date('d/m/Y', strtotime($checkouts->operasi_time)) . " \r\n";
                 $headerPrint .= "--------------------------------------- \r\n";
                 $headerPrint .= $content;
                 $headerPrint .= "======================================= \r\n";
                 $headerPrint .= "Tanggal Cetak " . date('d/m/Y H:i:s', MyFungsi::sysdate(date('Y-m-d H:i:s'))) . " \r\n";
                 $headerPrint .= "Lembar ke - " . $j . " \r\n";
                 $headerPrint .= "\f";
                 // 5 FF
                 $headerPrint .= "VA";
                 // 4 motong kertas
                 $headerPrint .= "@";
                 // 5 END
             }
             //create temp file
             $file = 'dataprintspj' . $checkouts->pool_id . '.txt';
             $myFile = path('public') . '/qzprint/templatedata/' . $file;
             $fh = fopen($myFile, 'w') or die("can't open file");
             $resetPrint = "";
             fwrite($fh, $resetPrint);
             $dataPrint = $headerPrint;
             fwrite($fh, $dataPrint);
             fclose($fh);
             return json_encode(array('status' => 1, 'urlfile' => $file));
         }
     }
 }