Пример #1
0
 function trainings($employee_id = '')
 {
     $data['page_name'] = '<b>Personal Data Sheet</b>';
     $data['section_name'] = '<b>Personal Information</b>';
     $data['focus_field'] = 'tra_name';
     $data['msg'] = '';
     $e = new Employee_m();
     $data['employee'] = $e->get_by_id($employee_id);
     if (Input::get('op')) {
         // TRAINING PROGRAMS=========================
         $tra_name = Input::get('tra_name');
         $tra_date_from = Input::get('tra_date_from');
         $tra_date_to = Input::get('tra_date_to');
         $tra_hours = Input::get('tra_hours');
         $tra_conduct = Input::get('tra_conduct');
         $tra_location = Input::get('tra_location');
         $t = new Training();
         $t->get_by_employee_id($employee_id);
         $t->delete_all();
         $i = 0;
         foreach ($tra_name as $tra) {
             if ($tra != "") {
                 $t = new Training();
                 $t->employee_id = $employee_id;
                 $t->name = $tra_name[$i];
                 $t->date_from = $tra_date_from[$i];
                 $t->date_to = $tra_date_to[$i];
                 $t->number_hours = $tra_hours[$i];
                 $t->conducted_by = $tra_conduct[$i];
                 $t->location = $tra_location[$i];
                 $t->save();
             }
             $i++;
         }
         $data['msg'] = 'Trainings has been saved!';
     }
     // Training=========================================================
     $t = new Training();
     //STR_TO_DATE(date_from, '%M %Y') DESC
     $t->order_by('date_from', 'DESC');
     //$t->order_by('STR_TO_DATE(date_from, "%Y-%m-%d")', 'DESC');
     //$t->order_by("YEAR(date_from)", 'DESC');
     //var_dump($t);
     $data['trains'] = $t->get_by_employee_id($employee_id);
     $data['tra_location_options'] = array('local' => 'Local', 'regional' => 'Regional', 'national' => 'National', 'international' => 'International');
     if ($employee_id == '') {
         $data['trains'] = array();
     }
     $data['selected'] = $e->office_id;
     // Use for office listbox
     $data['options'] = $this->options->office_options();
     $data['employee_id'] = $employee_id;
     $data['main_content'] = 'trainings';
     return View::make('includes/template', $data);
 }
Пример #2
0
 function employees($employee_id = '')
 {
     $data['page_name'] = '<b>Employee\'s Training Record</b>';
     $data['focus_field'] = 'tra_name';
     $data['msg'] = '';
     $employee_id = Input::get('employee_id');
     $e = new Employee_m();
     $data['employee'] = $e->get_by_id(Input::get('employee_id'));
     $data['pics'] = file_exists('pics/' . $e->pics) ? $e->pics : 'not_available.jpg';
     $image_properties = array('src' => base_url() . 'pics/' . $data['pics'], 'width' => '140', 'height' => '140');
     $data['pics'] = $image_properties;
     $em = new Employee_movement_m();
     $em->get_by_id($e->employee_movement_id);
     $data['employment_movement'] = $em->employee_movement;
     if (Input::get('op')) {
         // TRAINING PROGRAMS=========================
         $tra_name = Input::get('tra_name');
         $tra_date_from = Input::get('tra_date_from');
         $tra_date_to = Input::get('tra_date_to');
         $tra_hours = Input::get('tra_hours');
         $tra_conduct = Input::get('tra_conduct');
         $tra_location = Input::get('tra_location');
         $t = new Training();
         $t->get_by_employee_id($employee_id);
         $t->delete_all();
         $i = 0;
         foreach ($tra_name as $tra) {
             if ($tra != "") {
                 $t = new Training();
                 $t->employee_id = $employee_id;
                 $t->name = $tra_name[$i];
                 $t->date_from = $tra_date_from[$i];
                 $t->date_to = $tra_date_to[$i];
                 $t->number_hours = $tra_hours[$i];
                 $t->conducted_by = $tra_conduct[$i];
                 $t->location = $tra_location[$i];
                 $t->save();
             }
             $i++;
         }
         $data['msg'] = 'Trainings has been saved!';
     }
     // Recommended trainings
     if (Input::get('op2')) {
         $recommends = Input::get('recommend_id');
         $reco_year = Input::get('reco_year');
         $course_id = Input::get('course_id');
         $relevant = Input::get('relevant');
         $reco_remarks = Input::get('reco_remarks');
         $i = 0;
         foreach ($recommends as $r_id) {
             if ($reco_year[$i] != '') {
                 $t = new Training_recomended_m();
                 $t->where('course_id', $course_id[$i]);
                 $t->where('reco_year', $reco_year[$i]);
                 $t->where('employee_id', $employee_id);
                 $t->get();
                 $t->employee_id = $employee_id;
                 $t->reco_year = $reco_year[$i];
                 $t->course_id = $course_id[$i];
                 $t->relevant = $relevant[$i];
                 $t->reco_remarks = $reco_remarks[$i];
                 $t->save();
             }
             $i++;
         }
         // Remove checked
         if (Input::get('remove')) {
             foreach (Input::get('remove') as $recommended_id) {
                 $t = new Training_recomended_m();
                 $t->get_by_id($recommended_id);
                 $t->delete();
             }
         }
     }
     // Actual duties
     if (Input::get('op3')) {
         $duties_ids = Input::get('duties_id');
         $duty_from = Input::get('duty_from');
         $duty_to = Input::get('duty_to');
         $duty_desc = Input::get('duty_desc');
         $i = 0;
         foreach ($duties_ids as $r_id) {
             if ($duty_from[$i] != '') {
                 $ed = new Employee_duty_m();
                 $ed->get_by_id($r_id);
                 $ed->employee_id = $employee_id;
                 $ed->duty_from = $duty_from[$i];
                 $ed->duty_to = $duty_to[$i];
                 $ed->duty_desc = $duty_desc[$i];
                 $ed->save();
             }
             $i++;
         }
     }
     // Training===========================================================
     $t = new Training();
     $t->order_by('date_from', 'DESC');
     $data['trains'] = $t->get_by_employee_id($employee_id);
     $data['tra_location_options'] = array('local' => 'Local', 'regional' => 'Regional', 'national' => 'National', 'international' => 'International');
     if ($employee_id == '') {
         $data['trains'] = array();
     }
     // Recommended Trainings
     $t = new Training_recomended_m();
     $t->order_by('reco_year');
     $data['recommends'] = $t->get_by_employee_id($employee_id);
     // Actual Duties
     $ed = new Employee_duty_m();
     $ed->order_by('duty_from');
     $data['duties'] = $ed->get_by_employee_id($employee_id);
     $data['selected'] = $e->office_id;
     //Use for office listbox
     $data['options'] = $this->options->office_options();
     // Courses
     $t = new Training_course();
     $data['courses'] = $t->courses();
     $data['employee_id'] = $employee_id;
     $data['main_content'] = 'employees';
     return View::make('includes/template', $data);
 }