Пример #1
0
  <tr class="type-one-header">
    <th width="5%" bgcolor="#D6D6D6">ID</th>
    <th width="24%" bgcolor="#D6D6D6"><strong>Description</strong></th>
    <th width="24%" bgcolor="#D6D6D6">Date</th>
    <th width="22%" bgcolor="#D6D6D6">Schedule</th>
    <th width="15%" bgcolor="#D6D6D6">Employees</th>
    <th width="10%" bgcolor="#D6D6D6">Actions</th>
    </tr>
    <?php 
$s = new Schedule();
?>
  <?php 
foreach ($rows as $row) {
    ?>
  	<?php 
    $s->get_by_id($row->schedule_id);
    ?>
  <?php 
    $bg = $this->Helps->set_line_colors();
    ?>
			
  <tr bgcolor="<?php 
    echo $bg;
    ?>
" onmouseover="this.bgColor = '<?php 
    echo $this->config->item('mouseover_linecolor');
    ?>
';" 
    onmouseout ="this.bgColor = '<?php 
    echo $bg;
    ?>
Пример #2
0
 function employee_schedule_save($id = '', $page = '')
 {
     $data['page_name'] = '<b>Save Employee Schedule</b>';
     $data['msg'] = '';
     $data['selected'] = Session::get('office_id');
     if ($id != '') {
         $sd = new Schedule_detail();
         $sd->get_by_id($id);
         $data['selected'] = $sd->office_id;
     }
     // Use for office listbox
     $data['options'] = $this->options->office_options(TRUE);
     $this->load->helper('options');
     $sd = new Schedule_detail();
     $data['sched'] = $sd->get_by_id($id);
     $dates = unserialize($sd->dates);
     if ($dates == '') {
         $dates = array('year' => date('Y'), 'period_from' => 1, 'period_to' => date('d'), 'month' => date('m'));
     }
     $db_employees = unserialize($sd->employees);
     if (!Input::get('op')) {
         // if the database has value on it add the value from database to session
         if (is_array($db_employees)) {
             if (!is_array(Session::get('employees'))) {
                 Session::put('employees', array());
             }
             $employees = array_merge(Session::get('employees'), $db_employees);
             Session::put('employees', $employees);
         }
     }
     if (Input::get('op')) {
         $employees = Session::get('employees');
         $month_year = Input::get('year') . '-' . Input::get('month');
         $between_from = $month_year . '-' . Input::get('period_from');
         $between_to = $month_year . '-' . Input::get('period_to');
         $dates = array('year' => Input::get('year'), 'period_from' => Input::get('period_from'), 'period_to' => Input::get('period_to'), 'month' => Input::get('month'));
         $days = $this->Helps->get_days_in_between($between_from, $between_to);
         if (!Input::get('op')) {
             if (is_array($db_employees)) {
                 $employees = array_merge($employees, $db_employees);
             }
         }
         $employees = array_unique($employees);
         $sd->name = Input::get('name');
         $sd->employees = serialize($employees);
         $sd->dates = serialize($dates);
         $sd->schedule_id = Input::get('schedule_id');
         $sd->office_id = Input::get('office_id');
         $sd->save();
         Session::flash('msg', 'Schedule saved!');
         // Get the schedule
         $s = new Schedule();
         $s->get_by_id(Input::get('schedule_id'));
         $times = unserialize($s->times);
         // Check if 2 logs or 4 logs
         if ($times['am_in_hour'] != '' && $times['am_out_hour'] != '' && $times['pm_in_hour'] != '' && $times['pm_out_hour'] != '') {
             $sched_data['hour_from'] = '';
             $sched_data['hour_to'] = '';
             $sched_data['am_in'] = $times['am_in_hour'] . ':' . $times['am_in_min'];
             $sched_data['am_out'] = $times['am_out_hour'] . ':' . $times['am_out_min'];
             $sched_data['pm_in'] = $times['pm_in_hour'] . ':' . $times['pm_in_min'];
             $sched_data['pm_out'] = $times['pm_out_hour'] . ':' . $times['pm_out_min'];
             $shift_id = 3;
             $shift_type = 3;
         } else {
             //echo '2 times';
             // IN
             if ($times['am_in_hour'] != '') {
                 $sched_data['hour_from'] = $times['am_in_hour'] . ':' . $times['am_in_min'];
             } else {
                 if ($times['pm_in_hour'] != '') {
                     $sched_data['hour_from'] = $times['pm_in_hour'] . ':' . $times['pm_in_min'];
                 }
             }
             // OUT
             if ($times['am_out_hour'] != '') {
                 $sched_data['hour_to'] = $times['am_out_hour'] . ':' . $times['am_out_min'];
             } else {
                 if ($times['pm_out_hour'] != '') {
                     $sched_data['hour_to'] = $times['pm_out_hour'] . ':' . $times['pm_out_min'];
                 }
             }
             $sched_data['am_in'] = '';
             $sched_data['am_out'] = '';
             $sched_data['pm_in'] = '';
             $sched_data['pm_out'] = '';
             $shift_id = 2;
             $shift_type = 2;
             // Check if 24 hrs
             if ($sched_data['hour_from'] == $sched_data['hour_to']) {
                 $shift_id = 4;
                 $shift_type = 4;
             }
         }
         foreach ($days as $day) {
             //echo $day."<br>";
             $sched_data['date'] = $day;
             $oe = new Employee_m();
             foreach ($employees as $employee) {
                 // Change the shift ID
                 $oe->get_by_employee_id($employee);
                 $oe->shift_id = $shift_id;
                 $oe->shift_type = $shift_type;
                 $oe->save();
                 // Check if there is schedule for this date
                 $sched_data['employee_id'] = $employee;
                 $is_schedule_exists = $this->Schedule_employees->is_schedule_exists($employee, $day);
                 // Update
                 if ($is_schedule_exists == TRUE) {
                     $this->Schedule_employees->update($sched_data, $day, $employee);
                 } else {
                     $this->Schedule_employees->insert($sched_data);
                 }
             }
         }
         //Unset the session
         //$employees = array();
         //Session::put($employees);
         Session::forget('employees');
         //return Redirect::to('settings_manage/schedules/'.$page, 'refresh');
         Session::flash('msg', 'Schedule saved!');
         $data['msg'] = 'Employee Schedule has been saved!';
     }
     // Months
     $data['month_options'] = $this->options->month_options();
     $data['month_selected'] = $dates['month'];
     //print_r($dates);
     // Period from
     $data['days_options'] = $this->options->days_options();
     $data['period_from_selected'] = $dates['period_from'];
     // Period to
     $data['days_options'] = $this->options->days_options();
     $data['period_to_selected'] = $dates['period_to'];
     $data['year_options'] = $this->options->year_options(2009, 2020);
     //2010 - 2020
     $data['year_selected'] = $dates['year'];
     $data['main_content'] = 'employee_schedule_save';
     return View::make('includes/template', $data);
 }