function up()
 {
     // Do only if Province of Laguna
     $lgu_code = Setting::getField('lgu_code');
     if ($lgu_code == 'laguna_province') {
         $o = new Office_m();
         $offices = $o->get();
         foreach ($offices as $office) {
             // Select all employees by office
             $e = new Employee_m();
             $employees = $e->get_by_office_id($office->office_id);
             $office_id = sprintf("%03d", $office->office_id);
             // Add leading zeros
             $i = 1;
             foreach ($employees as $employee) {
                 // Lets update the employee id
                 $employee_id = sprintf("%03d", $i);
                 // Add leading zeros
                 $update_employee = new Employee_m();
                 $update_employee->get_by_id($employee->id);
                 $update_employee->employee_id = $office_id . $employee_id;
                 $update_employee->save();
                 $i++;
             }
         }
     }
 }
 function up()
 {
     $lgu_code = Setting::getField('lgu_code');
     if ($lgu_code == '') {
         if ($this->db->table_exists('pds_profile')) {
             $this->db->order_by('id');
             $q = $this->db->get('pds_profile');
             if ($q->num_rows() > 0) {
                 foreach ($q->result_array() as $row) {
                     $p = new Employee_m();
                     $p->get_by_id($row['employee_id']);
                     $p->item_number = $row['item_number'];
                     $p->last_promotion = $row['last_promotion'];
                     $p->level = $row['level'];
                     $p->eligibility = $row['eligibility'];
                     $p->graduated = $row['graduated'];
                     $p->course = $row['course'];
                     $p->units = $row['units'];
                     $p->post_grad = $row['post_grad'];
                     $p->save();
                 }
             }
         }
     }
 }
 function up()
 {
     if ($this->db->table_exists('pds_personal_info')) {
         $q = $this->db->get('pds_personal_info');
         if ($q->num_rows() > 0) {
             foreach ($q->result_array() as $row) {
                 $e = new Employee_m();
                 $e->get_by_id($row['employee_id']);
                 $e->birth_date = $row['birth_date'];
                 $e->sex = $row['sex'];
                 $e->save();
             }
         }
     }
 }
Esempio n. 4
0
 function edit_place($mode = '')
 {
     if ($mode == 'tax_exempt') {
         $e = new Employee_m();
         $e->where('id', Input::get('rowid'));
         $e->get();
         if (Input::get('colid') == 'tax_status') {
             $e->tax_status = Input::get('new');
         }
         if (Input::get('colid') == 'dependents') {
             $e->dependents = Input::get('new');
         }
         $e->save();
         exit;
     }
 }
Esempio n. 5
0
 /**
  * Enter description here...
  *
  * @param unknown_type $employee_id
  * @param unknown_type $office_id
  * @param unknown_type $page
  */
 function edit_employee($employee_id = '', $office_id = '', $page = '')
 {
     $data['page_name'] = '<b>Edit Employee</b>';
     $data['msg'] = '';
     $this->Employee->fields = array('shift_id', 'friday_exempted', 'office_id', 'detailed_office_id', 'permanent', 'first_day_of_service', 'position', 'assistant_dept_head', 'employee_id', 'division_id', 'salary_grade', 'step', 'pics', 'id', 'salut', 'lname', 'fname', 'mname', 'extension', 'orig_id', 'emergency_contact', 'emergency_contact_no');
     $employee_info = $this->Employee->get_employee_info($employee_id);
     if ($employee_id == '') {
         $employee_info = $this->Employee->get_employee_info(Input::get('orig_id'));
     }
     $shift_id_from_select = $employee_info['shift_id'];
     //Use for office listbox
     $data['options'] = $this->options->office_options();
     $data['selected'] = $employee_info['office_id'];
     $data['division_id'] = $employee_info['division_id'];
     //for detailed office
     $data['detailed_options'] = $this->options->office_options($add_select = TRUE);
     $data['detailed_selected'] = $employee_info['detailed_office_id'];
     //dropdown for type of employment
     $data['permanent_options'] = $this->options->type_employment();
     $data['permanent_options_selected'] = $employee_info['permanent'];
     $data['first_day_of_service'] = $employee_info['first_day_of_service'];
     $data['position'] = $employee_info['position'];
     $data['assistant_dept_head'] = $employee_info['assistant_dept_head'];
     $data['employee_id'] = $employee_info['employee_id'];
     $data['friday_exempted'] = $employee_info['friday_exempted'];
     //Salary grade options
     $data['sg_options'] = $this->options->salary_grade();
     //step increment
     $data['step_options'] = $this->options->step();
     $data['sg_selected'] = $employee_info['salary_grade'];
     $data['step_selected'] = $employee_info['step'];
     $data['page'] = $this->uri->segment(5);
     $data['office_return'] = $this->uri->segment(4);
     $data['image_file_name'] = $employee_info['pics'];
     //Shift List
     $data['shifts_options'] = $this->options->shift();
     $data['shift2'] = $employee_info['shift_id'];
     if ($employee_info['pics'] == '' || !file_exists('pics/' . $employee_info['pics'])) {
         $data['image_file_name'] = 'not_available.jpg';
     }
     $data['id'] = $employee_info['id'];
     $data['salutation'] = $employee_info['salut'];
     $data['lname'] = $employee_info['lname'];
     $data['fname'] = $employee_info['fname'];
     $data['mname'] = $employee_info['mname'];
     $data['extension'] = $employee_info['extension'];
     //The original employee id
     $data['orig_id'] = $employee_info['id'];
     $data['emergency_contact'] = $employee_info['emergency_contact'];
     $data['emergency_contact_no'] = $employee_info['emergency_contact_no'];
     if (Input::get('op')) {
         $orig_id = Input::get('orig_id');
         $id = Input::get('id');
         if ($employee_id != Input::get('employee_id')) {
             $this->form_validation->set_rules('employee_id', 'Employee ID', 'required|callback_employee_id_check');
         }
         $this->form_validation->set_rules('salutation', 'Salutation', 'required');
         $this->form_validation->set_rules('lname', 'Last Name', 'required');
         $this->form_validation->set_rules('fname', 'First Name', 'required');
         $this->form_validation->set_rules('position', 'Position', 'required');
         $this->form_validation->set_rules('extension', 'First Name', '');
         $this->form_validation->set_rules('permanent', 'Type of employment', 'required');
         if ($this->form_validation->run($this) == FALSE) {
             $data['selected'] = Input::get('office_id');
             $data['detailed_selected'] = Input::get('detailed_office_id');
             $data['employee_id'] = Input::get('employee_id');
             $data['page'] = Input::get('page');
             $data['office_return'] = Input::get('office_return');
         } else {
             if (Input::get('employee_id') != $employee_info['employee_id']) {
                 $em = new Employee_m();
                 $em->get_by_id($orig_id);
                 $em->orig_id = $employee_info['employee_id'];
                 $em->save();
                 # code...
             }
             //echo $orig_id;
             //echo Input::get('employee_id');
             //var_dump($employee_info['employee_id']);
             //var_dump($employee_info['orig_id']);
             //exit;
             $info = array('employee_id' => Input::get('employee_id'), 'lname' => Input::get('lname'), 'fname' => Input::get('fname'), 'mname' => Input::get('mname'), 'extension' => Input::get('extension'), 'office_id' => Input::get('office_id'), 'division_id' => Input::get('division_id'), 'section_id' => Input::get('section_id'), 'detailed_office_id' => Input::get('detailed_office_id'), 'salut' => Input::get('salutation'), 'permanent' => Input::get('permanent'), 'first_day_of_service' => Input::get('first_day_of_service'), 'salary_grade' => Input::get('sg'), 'step' => Input::get('step'), 'position' => Input::get('position'), 'assistant_dept_head' => Input::get('assistant_dept_head'), 'shift_id' => Input::get('shift2'), 'shift_type' => Input::get('shift2'), 'friday_exempted' => Input::get('friday_exempted'), 'updated' => 1, 'emergency_contact' => Input::get('emergency_contact'), 'emergency_contact_no' => Input::get('emergency_contact_no'));
             //$data['emergency_contact'] = $employee_info['emergency_contact'];
             //File name of the photo
             $file_register = Session::get('file_register');
             if ($file_register) {
                 $info['pics'] = $file_register;
                 $info['finger_pics'] = '/../' . current_work_dir() . '/pics/' . Session::get('file_register');
             }
             $this->Employee->update_employee($info, $id);
             $this->Logs->insert_logs('employees', 'EDIT EMPLOYEE', 'Edit employee (' . $id . ')', $id);
             $page = Input::get('page');
             $office_return = Input::get('office_return');
             // Use for messaging
             Session::flash('msg', 'Employee updated!');
             return Redirect::to('employees/index/' . $page . '/' . $office_return, 'refresh');
         }
     }
     $data['main_content'] = 'edit_employee';
     return View::make('includes/template', $data);
 }
Esempio n. 6
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);
 }
Esempio n. 7
0
 function money_value($date_retired = '', $leave_balance = 0, $employee_id = '1')
 {
     $data = array();
     $data['msg'] = '';
     $e = new Employee_m();
     $e->get_by_employee_id($employee_id);
     // View the form
     if (!Input::get('op')) {
         $data['date_retired'] = $e->date_retired;
         return View::make('date_retired', $data);
         return;
     }
     $date_retired = Input::get('date_retired');
     if ($date_retired == '') {
         $date_retired = NULL;
     }
     $e->date_retired = $date_retired;
     $e->save();
     $this->date_retired = $date_retired;
     $this->load->library('fpdf');
     define('FPDF_FONTPATH', $this->config->item('fonts_path'));
     $this->load->library('fpdi');
     // initiate FPDI
     $pdf = new FPDI('P', 'mm', 'Letter');
     // add a page
     $pdf->AddPage();
     // set the sourcefile
     $pdf->setSourceFile('dtr/template/leave/computation_money_value.pdf');
     // select the first page
     $tplIdx = $pdf->importPage(1);
     // use the page we imported
     $pdf->useTemplate($tplIdx);
     // set font, font style, font size.
     $pdf->SetFont('Times', 'B', 12);
     $pdf->SetTextColor(89, 89, 89);
     // set initial placement
     $pdf->SetXY(83, 30);
     $personal = new Personal_m();
     $personal->where('employee_id', $e->id);
     $personal->get(1);
     $this->load->helper('date');
     $date_birth = convert_long_date($personal->birth_date);
     $first_day_of_service = convert_long_date($e->first_day_of_service);
     $date_retired = convert_long_date($date_retired);
     $salary = $this->Salary_grade->get_monthly_salary($e->salary_grade, $e->step);
     $pdf->Cell(50, 8, $e->fname . ' ' . $e->mname . ' ' . $e->lname, '', 0, 'C', FALSE);
     $pdf->SetFont('Times', '', 12);
     $pdf->Ln(6);
     $pdf->SetX(83);
     $pdf->Cell(50, 8, "January 1, 2012 May 10, 2012", '', 0, 'C', FALSE);
     $pdf->Ln(20.5);
     $pdf->SetX(114);
     $pdf->Write(0, $date_birth);
     $pdf->Ln(6);
     $pdf->SetX(114);
     $pdf->Write(0, $first_day_of_service);
     $pdf->Ln(11);
     $pdf->SetX(114);
     $pdf->Write(0, $date_retired);
     $pdf->Ln(6);
     $pdf->SetX(114);
     $pdf->Write(0, number_format($salary, 2));
     $pdf->Ln(5.5);
     $pdf->SetX(114);
     $pdf->Write(0, number_format($leave_balance, 3));
     $total_money = $salary * $leave_balance * 0.0478087;
     $pdf->Ln(18);
     $pdf->SetX(27);
     $pdf->Cell(50, 8, number_format($salary, 2), '', 0, 'R', FALSE);
     $pdf->SetX(58);
     $pdf->Cell(50, 8, number_format($leave_balance, 3), '', 0, 'R', FALSE);
     $pdf->SetX(167);
     $pdf->Cell(15, 8, number_format($total_money, 2), '', 0, 'L', FALSE);
     $pdf->Ln(44);
     $pdf->SetX(50);
     $pdf->Cell(50, 8, Setting::getField('money_value_signatory_prepared'), '', 0, 'C', FALSE);
     $pdf->SetX(136);
     $pdf->Cell(50, 8, Setting::getField('money_value_signatory_certified'), '', 0, 'C', FALSE);
     $pdf->Ln(6);
     $pdf->SetX(50);
     $pdf->Cell(50, 8, Setting::getField('money_value_signatory_prepared_position'), '', 0, 'C', FALSE);
     $pdf->SetX(136);
     $pdf->Cell(50, 8, Setting::getField('money_value_signatory_certified_position'), '', 0, 'C', FALSE);
     header('Cache-Control: maxage=3600');
     //Adjust maxage appropriately
     header('Pragma: public');
     $pdf->Output('dtr/reports/money_value' . $employee_id . '.pdf', 'F');
     $this->pages['P'] = 'dtr/reports/money_value' . $employee_id . '.pdf';
     // index 'P' for portrait
     $this->schedule_retirement_pay($this->date_retired, $employee_id);
     // Lets concat
     $this->load->library('concat_pdf');
     $this->concat_pdf->setFiles($this->pages);
     $this->concat_pdf->concat();
     $this->concat_pdf->Output("dtr/template/pds/archives/" . $employee_id . ".pdf", 'I');
 }