function save($id = '') { $data['page_name'] = '<b>Save Office</b>'; $data['msg'] = ''; $office = new Office_m(); $data['office'] = $office->get_by_office_id($id); if (Input::get('op')) { $this->form_validation->set_rules('office_name', 'Office Name', 'required'); //var_dump($office->exists()); if (!$office->exists()) { $this->form_validation->set_rules('office_name', 'Office Name', 'required|callback_office_check'); } if ($this->form_validation->run($this) == TRUE) { $office->office_code = Input::get('office_code'); $office->office_name = Input::get('office_name'); $office->office_address = Input::get('office_address'); $office->salary_grade_type = Input::get('salary_grade_type'); $office->office_head = Input::get('office_head'); $office->employee_id = Input::get('employee_id'); $office->position = Input::get('position'); $office->office_location = Input::get('office_location'); $office->save(); Session::flash('msg', 'Office has been saved!'); return Redirect::to('offices', 'refresh'); } } $data['main_content'] = 'save'; return View::make('includes/template', $data); }
function dtr() { $data['page_name'] = '<b>View/Print DTR</b>'; $data['msg'] = ''; $data['focus_field'] = 'employee_id'; $data['pop_up'] = 0; // Use for office listbox $data['options'] = $this->options->office_options(); $data['selected'] = Session::get('office_id'); // Type of employment $data['permanent_options'] = $this->options->type_employment($all = TRUE); $data['permanent_selected'] = ''; // Months $data['month_options'] = $this->options->month_options(); $data['month_selected'] = date('m'); // Period from $data['days_options'] = $this->options->days_options(); // Period to $data['days_options'] = $this->options->days_options(); $data['days_selected'] = date('d'); $data['year_options'] = $this->options->year_options(2009, 2020); //2010 - 2020 $data['year_selected'] = date('Y'); $show_employee_number_dtr = Setting::getField('show_employee_number_dtr'); //If ($op == 1) ================== START ========================== if (Input::get('op') == 1) { $data['month_selected'] = Input::get('month'); $data['days_selected'] = Input::get('period_to'); $data['year_selected'] = Input::get('year'); // Get the data that need to process $this->employee_array[] = Input::get('employee_id'); $this->employee_array[] = Input::get('hidden_employee_id'); // Dont compute dates $this->dont_compute_dates = Setting::getField('dont_compute'); $this->month = Input::get('month'); $this->year = Input::get('year'); $this->period_from = Input::get('period_from'); $this->period_to = Input::get('period_to'); //$start_date = '1'; // If the $this->period_from is not 1 if ($this->period_from != '1') { $this->start_date = Input::get('period_from'); // Start of viewing DTR $this->period_from = '1'; // We will still use the first day } // If the Multiple employee checkbox is checked if (Input::get('multi_employee')) { // Array of employee from checkboxes $employees = Input::get('employee'); if (is_array($employees)) { $this->employee_array = $employees; } } // If the request is from view attendance page===>>>> $this->from_view_attendance(); // Remove empty array $this->employee_array = array_filter($this->employee_array); // Foreach($employee_array as $employee_id) ========= START ============= foreach ($this->employee_array as $employee_id) { $this->employee_id = $employee_id; $between_from = $this->year . '-' . $this->month . '-' . $this->period_from; $between_to = $this->year . '-' . $this->month . '-' . $this->period_to; // Dates to be delete after insert to table $array_of_deleted_dates = $this->Dtr->get_blank_dates($this->employee_id, $this->period_from, $this->period_to, $this->year, $this->month); // Get employee info $this->Employee->fields = array('fname', 'mname', 'lname', 'extension', 'shift_type', 'friday_exempted', 'office_id', 'detailed_office_id', 'assistant_dept_head'); //Fields $name = $this->Employee->get_employee_info($this->employee_id); $this->friday_exempted = $name['friday_exempted']; //echo $this->friday_exempted; //exit; // Check what type of user is logged // If leave manager $this->load->library('session'); if (Session::get('user_type') == 5) { // If the office is not equal to office id of user logged if (Session::get('office_id') != $name['office_id']) { echo '<font color="red">You are not allowed to view this records!</font>'; exit; } } $whole_name = $name['fname'] . ' ' . $name['mname'] . ' ' . $name['lname']; if ($name['extension'] != '') { $whole_name = $name['fname'] . ' ' . $name['mname'] . ' ' . $name['lname'] . ', ' . $name['extension']; } // If the LGU wants to see the last name in DTR first if (Setting::getField('last_name_first_dtr') == 'yes') { $whole_name = $name['lname'] . ', ' . $name['fname'] . ' ' . $name['mname']; if ($name['extension'] != '') { //$whole_name = $name['fname'].' '.$name['mname'].' '.$name['lname'].', '.$name['extension']; $whole_name = $name['lname'] . ', ' . $name['fname'] . ' ' . $name['extension'] . ' ' . $name['mname']; } } $this->shift_type = $name['shift_type']; $this->load->library('fpdf'); //define('FPDF_FONTPATH', $this->config->item('fonts_path')); $this->load->library('fpdi'); // initiate FPDI $this->pdf = new FPDI(); // add a page $this->pdf->AddPage(); // set the sourcefile $this->pdf->setSourceFile('dtr/template/dtr.pdf'); // select the first page $tplIdx = $this->pdf->importPage(1); // use the page we imported $this->pdf->useTemplate($tplIdx); // set font, font style, font size. $this->pdf->SetFont('Times', 'B', 11); #################################### #THIS IS FOR THE NAME OF EMPLOYEE # #################################### if ($show_employee_number_dtr == 'yes') { $this->pdf->SetXY(80, 10); $this->pdf->Write(0, $this->employee_id); $this->pdf->SetX(175); $this->pdf->Write(0, $this->employee_id); } // set initial placement $this->pdf->SetXY(30, 22.5); // line break $this->pdf->Ln(5); // go to 25 X (indent) $this->pdf->SetX(40); // write $this->pdf->Write(0, ucwords(strtolower(utf8_decode($whole_name)))); // go to 25 X (indent) $this->pdf->SetX(130); // write $this->pdf->Write(0, ucwords(strtolower(utf8_decode($whole_name)))); ######################################## #THIS IS FOR THE NAME OF EMPLOYEE (END)# ######################################## #################################### #THIS IS FOR THE MONTH # #################################### $month2 = $this->Helps->get_month_name($this->month); // line break $this->pdf->Ln(11); // go to 25 X (indent) $this->pdf->SetX(43); // write $this->pdf->Write(0, ucwords(strtolower($month2 . ' ' . $this->start_date . '-' . $this->period_to . ', ' . $this->year))); // go to 25 X (indent) $this->pdf->SetX(137); // write $this->pdf->Write(0, ucwords(strtolower($month2 . ' ' . $this->start_date . '-' . $this->period_to . ', ' . $this->year))); #################################### #THIS IS FOR THE MONTH (END) # #################################### $this->pdf->Ln(28.5); $this->pdf->SetFont('Times', '', 9); // This will start the writing process to pdf // DTR query result $this->Dtr->fields = array('am_login', 'am_logout', 'pm_login', 'pm_logout', 'ot_login', 'ot_logout', 'leave_type_id', 'log_date', 'manual_log_id'); $dtr_result = $this->Dtr->employee_dtr($between_from, $between_to, $this->employee_id); //foreach ($dtr_result as $row) ========= START ==================================== foreach ($dtr_result as $row) { $this->set_dtr($row); // // Split the logged_date // As of PHP 5.3.0 the regex extension is deprecated, // calling this function will issue an E_DEPRECATED notice. list($log_year, $log_month, $log_day) = explode('-', $this->log_date); // Check if the day is Sat or Sun $this->sat_or_sun = $this->Helps->is_sat_sun($log_month, $log_day, $log_year); // Check if the day is holiday $this->is_holiday = $this->Holiday->is_holiday($this->log_date); $allow_forty_hours = Setting::getField('allow_forty_hours'); // If the $this->period_from is not 1 something like // June 16-30 2012 if ($this->start_date != '1') { if ($log_day < $this->start_date) { $this->am_login = ''; $this->am_logout = ''; $this->pm_login = ''; $this->pm_logout = ''; $this->ot_login = ''; $this->ot_logout = ''; $this->sat_or_sun = ''; $this->is_holiday = FALSE; } } // If regular hours (8-5) // We can also use shift_type 3 here because it has // 4 logs //if( $this->shift_type == 1 ) if ($this->shift_type == 1 || $this->shift_type == 3) { $this->regular_hours(); $this->allow_40hrs == FALSE; } // If shifting if ($this->shift_type == 2) { if ($allow_forty_hours == 1) { // Allow 40 hrs per week $this->allow_40hrs = TRUE; } $this->shifting_same_day(); } // If 24 hrs //if ($this->shift_type == 3) if ($this->shift_type == 4) { if ($allow_forty_hours == 1) { // Allow 40 hrs per week $this->allow_40hrs = TRUE; } $this->shifting_same_day(); // added 7.27.2011 5:47pm } //echo $this->log_date.' -- '.$this->Helps->hours_late.'<br>'; //===========RESET Late and undertime $this->Helps->hours_late = 0; $this->Helps->count_late = 0; $this->Helps->hours_undertime = 0; $this->Helps->count_undertime = 0; $this->Helps->am_login = 0; $this->Helps->pm_login = 0; $this->Helps->am_logout = 0; $this->Helps->pm_logout = 0; $this->Helps->pm_late_hours = 0; $this->Helps->pm_undertime_hours = 0; // Set the line number from where in the pdf position will be place $line_numbers = array(4, 6, 8, 11, 14, 17, 19, 21, 24, 28); $line_number_view = in_array($this->line_number, $line_numbers) ? 4 : 3.5; $this->pdf->Ln($line_number_view); // Check for saturdays and sundays // If the date has log on it if ($this->am_login != "" or $this->am_logout != "" or $this->pm_login != "" or $this->pm_logout != "" or $this->ot_login != "" or $this->ot_logout != "") { //Do nothing // If the date is holiday if ($this->is_holiday == TRUE) { // Lets check if the holiday is half day if ($this->Holiday->half_day == TRUE) { if ($this->Holiday->am_pm == 'am') { $this->am_login = strtoupper($this->Holiday->holiday_name($this->log_date)); } else { $this->pm_login = strtoupper($this->Holiday->holiday_name($this->log_date)); } } } } else { // Do if not Leave //if ( $this->leave_type_id != 0 ) //{ if ($this->sat_or_sun == 'Saturday') { $this->am_login = '******'; } if ($this->sat_or_sun == 'Sunday') { $this->am_login = '******'; } // If the date is holiday if ($this->is_holiday == TRUE) { $this->am_login = strtoupper($this->Holiday->holiday_name($this->log_date)); if ($this->Holiday->am_pm == 'pm') { //$this->am_login = ''; } } //} } // Lets check if the logs has atleast one OB in entries $has_ob = FALSE; $has_ob = $this->Helps->has_ob($this->am_login, $this->am_logout, $this->pm_login, $this->pm_logout); $ob_location = ''; if ($has_ob == TRUE) { $ob_location = $this->Manual_log->get_notes($this->manual_log_id); } // Check if Official Business (Change Official Business to OB) $this->am_login = $this->Helps->is_ob($this->am_login); $this->am_logout = $this->Helps->is_ob($this->am_logout); $this->pm_login = $this->Helps->is_ob($this->pm_login); $this->pm_logout = $this->Helps->is_ob($this->pm_logout); // If whole day ob if ($this->am_login == 'OB' && $this->am_logout == 'OB' && $this->pm_login == 'OB' && $this->pm_logout == 'OB') { $ob_location = ''; $notes = $this->Manual_log->get_notes($this->manual_log_id); if (trim($notes) == '') { $this->am_login = '******'; $this->am_logout = 'OB'; $this->pm_login = '******'; $this->pm_logout = 'OB'; } else { $this->am_login = '******'; $this->am_logout = ''; $this->pm_login = $notes; $this->pm_logout = ''; } } // Check if Travel Order (Change Travel Order to To) $this->am_login = $this->Helps->is_to($this->am_login); $this->am_logout = $this->Helps->is_to($this->am_logout); $this->pm_login = $this->Helps->is_to($this->pm_login); $this->pm_logout = $this->Helps->is_to($this->pm_logout); // If whole day to if ($this->am_login == 'TO' && $this->am_logout == 'TO' && $this->pm_login == 'TO' && $this->pm_logout == 'TO') { $notes = $this->Manual_log->get_notes($this->manual_log_id); if (trim($notes) == '') { $this->am_login = '******'; $this->am_logout = 'TO'; $this->pm_login = '******'; $this->pm_logout = 'TO'; } else { $this->am_login = '******'; $this->am_logout = ''; $this->pm_login = trim($notes); $this->pm_logout = ''; } } // Check if the log is leave if ($this->leave_type_id != 0 && $this->am_login == 'Leave' && $this->am_logout == 'Leave' && $this->pm_login == 'Leave' && $this->pm_logout == 'Leave') { $this->am_login = strtoupper($this->Leave_type->get_leave_name($this->leave_type_id)); $this->am_logout = ''; $this->pm_login = ''; $this->pm_logout = ''; } $am_is_leave = FALSE; // If half day leave (morning) if ($this->leave_type_id != 0 && $this->am_login == 'Leave' && $this->am_logout == 'Leave') { $this->am_login = strtoupper($this->Leave_type->get_leave_code($this->leave_type_id)); $this->am_logout = ''; $am_is_leave = TRUE; } $pm_is_leave = FALSE; // If half day leave (afternoon) if ($this->leave_type_id != 0 && $this->pm_login == 'Leave' && $this->pm_logout == 'Leave') { $this->pm_login = strtoupper($this->Leave_type->get_leave_code($this->leave_type_id)); $this->pm_logout = ''; $pm_is_leave = TRUE; } // Execute only if regular hours (8-5) // and special sched (added 08-08-2011) if ($this->shift_type == 1 || $this->shift_type == 3) { // We need to check if the settings enabled for this halfday tardy // Check if there is no log on am or pm // For the compliant to CSC MC 17 series of 2010 // put VL if absent on AM and VL if absent on PM // AM Absent if ($this->am_login == '' && $this->am_logout == '' && $this->pm_login != '' && $this->pm_logout != '') { //$this->am_login = '******'; //$this->am_login = '******'; // Update 2.8.2013 // Put Tardy only if not saturday or sunday if ($this->sat_or_sun != 'Saturday' and $this->sat_or_sun != 'Sunday' and $this->is_holiday == FALSE) { $this->am_login = '******'; $this->am_logout = ''; // Change font color $this->Helps->font_color_am_login = 200; } } // PM Absent if ($this->am_login != '' && $this->am_logout != '' && $this->pm_login == '' && $this->pm_logout == '') { //$this->pm_login = '******'; $this->pm_login = '******'; $this->pm_logout = ''; // Check if saturday or sunday and shift_id == 1 // if true we dont need to put undertime to DTR if ($this->shift_type == 1 && ($this->sat_or_sun == 'Saturday' || $this->sat_or_sun == 'Sunday')) { $this->pm_login = ''; } // Change font color $this->Helps->font_color_pm_login = 200; // add this lines 12.14.2012 8.37am /* if ( $this->Holiday->is_holiday($this->log_date) and $this->Holiday->half_day == TRUE and $this->Holiday->am_pm == 'pm' ) { $this->pm_logout = ''; } */ // end add 12.14.2012 8.37am } else { if ($this->am_login != '' && $this->am_logout != '' && $this->pm_login != '' && $this->pm_logout == '') { $this->pm_logout = 'Undertime'; // add this lines 12.14.2012 8.37am if ($this->Holiday->is_holiday($this->log_date) and $this->Holiday->half_day == TRUE and $this->Holiday->am_pm == 'pm') { $this->pm_logout = ''; } // end add 12.14.2012 8.37am // Check if saturday or sunday and shift_id == 1 // if true we dont need to put undertime to DTR if ($this->shift_type == 1 && ($this->sat_or_sun == 'Saturday' || $this->sat_or_sun == 'Sunday')) { $this->pm_logout = ''; } // If pm is leave if ($pm_is_leave == TRUE) { $this->pm_logout = ''; } // Change font color $this->Helps->font_color_pm_logout = 200; } else { if ($this->am_login != '' && $this->am_logout != '' && $this->pm_login == '' && $this->pm_logout != '') { //$this->pm_logout= 'Undertime'; $this->pm_login = '******'; // If pm is leave if ($pm_is_leave == TRUE) { //$this->pm_logout = ''; } // Change font color $this->Helps->font_color_pm_login = 200; } else { if ($this->am_login != '' && $this->am_logout == '' && $this->pm_login != '' && $this->pm_logout != '' && $this->leave_type_id == 0) { $this->am_logout = 'Tardy'; // If pm is leave if ($pm_is_leave == TRUE) { //$this->pm_logout = ''; } //$this->leave_type_id // Change font color $this->Helps->font_color_am_logout = 200; } else { if ($this->am_login == '' && $this->am_logout == 'OB' && $this->pm_login == 'OB' && $this->pm_logout == 'OB' && $this->leave_type_id == 0) { $this->am_login = '******'; // If pm is leave if ($pm_is_leave == TRUE) { //$this->pm_logout = ''; } // Change font color $this->Helps->font_color_am_login = 200; } } } } } } //if ($this->log_date == '2013-03-30') //{ //var_dump( $this->pm_login);exit; //} //convert the time to 12 hour //am login A $this->pdf->SetX(24); $this->pdf->SetTextColor($this->Helps->font_color_am_login, 0, 0); $this->pdf->SetFont('Times', $this->Helps->am_font_bold, 9); $this->pdf->Write(0, $this->am_login); //am login B $this->pdf->SetX(118); $this->pdf->Write(0, $this->am_login); $this->Helps->font_color_am_login = 0; $this->Helps->am_font_bold = ''; //am logout A $this->pdf->SetX(36); $this->pdf->SetTextColor($this->Helps->font_color_am_logout, 0, 0); $this->pdf->SetFont('Times', $this->Helps->am_out_bold, 9); $this->pdf->Write(0, $this->am_logout); //am logout B $this->pdf->SetX(130); $this->pdf->Write(0, $this->am_logout); $this->Helps->font_color_am_logout = 0; $this->Helps->am_out_bold = ''; //pm login A $this->pdf->SetX(50); $this->pdf->SetTextColor($this->Helps->font_color_pm_login, 0, 0); $this->pdf->SetFont('Times', $this->Helps->pm_font_bold, 9); // Change format(only if notes is blank) if (isset($notes) && $notes != '') { $this->pm_login = $notes; } else { // If pm login is not leave and pm login is not half day absent(vacation leave) // If( ($this->leave_type_id == 0 && $this->pm_login != 'Vacation Leave') ) orig if ($this->leave_type_id == 0 && $this->pm_login != 'Undertime' && $this->pm_login != 'UT') { $this->pm_login = $this->Helps->change_format($this->pm_login, 1, $format = ''); // add this lines 12.14.2012 8.37am if ($this->Holiday->is_holiday($this->log_date) and $this->Holiday->half_day == TRUE and $this->Holiday->am_pm == 'pm') { $this->pm_login = $this->Holiday->holiday_name($this->log_date); } // end add 12.14.2012 8.37am } // If leave in the pm and pm_login is not equal to leave code(VL, SPL) if ($this->leave_type_id != 0 && $this->pm_login != strtoupper($this->Leave_type->get_leave_code($this->leave_type_id))) { $this->pm_login = $this->Helps->change_format($this->pm_login, 1, $format = ''); } } //echo //if ($this->log_date == '2012-03-30') //{ //var_dump( $this->pm_login);exit; //} // Reset the notes to blank $notes = ''; $this->pdf->Write(0, $this->pm_login); //pm login B $this->pdf->SetX(144); $this->pdf->Write(0, $this->pm_login); $this->Helps->font_color_pm_login = 0; $this->Helps->pm_font_bold = ''; //pm logout A $this->pdf->SetX(62); $this->pdf->SetTextColor($this->Helps->font_color_pm_logout, 0, 0); $this->pdf->SetFont('Times', $this->Helps->pm_out_bold, 9); // Change format if the entry is not leave and not Undertime or (leave in the morning) if ($this->leave_type_id == 0 && $this->pm_logout != 'Undertime' or $am_is_leave == TRUE) { $this->pm_logout = $this->Helps->change_format($this->pm_logout, 1, $format = ''); } $this->pdf->Write(0, $this->pm_logout); //pm logout B $this->pdf->SetX(157); $this->pdf->Write(0, $this->pm_logout); $this->Helps->font_color_pm_logout = 0; $this->Helps->pm_out_bold = ''; //ot login A $this->pdf->SetX(74); $this->pdf->SetTextColor(0, 0, 0); if ($has_ob == TRUE and trim($ob_location) != '') { $this->ot_login = $ob_location; } else { $this->ot_login = $this->Helps->change_format($this->ot_login, 1, $format = ''); } $this->pdf->Write(0, $this->ot_login); //ot login B $this->pdf->SetX(169); $this->pdf->SetTextColor(0, 0, 0); $this->pdf->Write(0, $this->ot_login); //ot logout A $this->pdf->SetX(88); $this->pdf->SetTextColor(0, 0, 0); $this->ot_logout = $this->Helps->change_format($this->ot_logout, 1, $format = ''); $this->pdf->Write(0, $this->ot_logout); //ot logout B $this->pdf->SetX(182); $this->pdf->SetTextColor(0, 0, 0); $this->pdf->Write(0, $this->ot_logout); $this->line_number++; $this->Holiday->half_day = FALSE; // reset //echo $this->log_date.' '.$this->late_final.'<br>'; //exit; } //foreach ($dtr_result as $row) ========= END ==================================== //exit; // If allow the 40 hrs per week (offsettings)===================================== if ($this->allow_40hrs == TRUE) { // If the work for 1st week is 40 hours or more or 5 days or more if ($this->Helps->compute_time($this->week1_hours) >= '5 days') { // Subtract the week 1 total late and undertime count $this->late_count -= $this->week1_late_count; $this->undertime_count -= $this->week1_undertime_count; // Subtract the week 1 total late and undertime hours $this->late_final -= $this->week1_late_final; $this->undertime_final -= $this->week1_undertime_final; } // If the work for 2nd week is 40 hours or more or 5 days or more if ($this->Helps->compute_time($this->week2_hours) >= '5 days') { // Subtract the week 2 total late and undertime count $this->late_count -= $this->week2_late_count; $this->undertime_count -= $this->week2_undertime_count; // Subtract the week 2 total late and undertime hours $this->late_final -= $this->week2_late_final; $this->undertime_final -= $this->week2_undertime_final; } // If the work for 3rd week is 40 hours or more or 5 days or more if ($this->Helps->compute_time($this->week3_hours) >= '5 days') { // Subtract the week 3 total late and undertime count $this->late_count -= $this->week3_late_count; $this->undertime_count -= $this->week3_undertime_count; // Subtract the week 3 total late and undertime hours $this->late_final -= $this->week3_late_final; $this->undertime_final -= $this->week3_undertime_final; } // If the work for 4th week is 40 hours or more or 5 days or more if ($this->Helps->compute_time($this->week4_hours) >= '5 days') { // Subtract the week 4 total late and undertime count $this->late_count -= $this->week4_late_count; $this->undertime_count -= $this->week4_undertime_count; // Subtract the week 4 total late and undertime hours $this->late_final -= $this->week4_late_final; $this->undertime_final -= $this->week4_undertime_final; } } // ================================================================= // set initial placement $this->pdf->SetXY(30, 34); //$this->pdf->Ln(160.5); $this->pdf->Ln(153); //total A $this->pdf->SetX(50); //$this->pdf->Write(0, ucwords(($this->Helps->compute_time($this->number_of_hours_work)))); //total B $this->pdf->SetX(145); //$this->pdf->Write(0, ucwords(($this->Helps->compute_time($this->number_of_hours_work)))); // LGU CODE $lgu_code = Setting::getField('lgu_code'); if ($lgu_code == 'marinduque_province') { // Total tardiness $this->total_tardiness = $this->late_final + $this->undertime_final; //$this->late_count += $this->undertime_count; $this->undertime_final = $this->Helps->compute_time($this->undertime_final + $this->late_final); $this->late_final = ''; } else { // Total tardiness $this->total_tardiness = $this->late_final + $this->undertime_final; // Compute the late in words $this->late_final = $this->Helps->compute_time($this->late_final); // Compute undertime $this->undertime_final = $this->Helps->compute_time($this->undertime_final); } // Total $this->pdf->Ln(48); $this->pdf->SetX(17); $this->pdf->Write(0, 'Tardiness:'); $this->pdf->SetX(40); $this->pdf->Write(0, '(' . $this->late_count . 'x)' . $this->late_final); $this->pdf->SetX(110); $this->pdf->Write(0, 'Tardiness:'); $this->pdf->SetX(133); $this->pdf->Write(0, '(' . $this->late_count . 'x)' . $this->late_final); $this->pdf->Ln(6); $this->pdf->SetX(17); $this->pdf->Write(0, 'Under time:'); $this->pdf->SetX(40); if ($lgu_code == 'marinduque_province') { $this->pdf->Write(0, $this->undertime_final); } else { $this->pdf->Write(0, '(' . $this->undertime_count . 'x) ' . $this->undertime_final); } $this->pdf->SetX(110); $this->pdf->Write(0, 'Under time:'); $this->pdf->SetX(133); if ($lgu_code == 'marinduque_province') { $this->pdf->Write(0, $this->undertime_final); } else { $this->pdf->Write(0, '(' . $this->undertime_count . 'x) ' . $this->undertime_final); } //overtime $this->pdf->Ln(6); $this->number_of_hours_work = $this->Helps->compute_time($this->number_of_hours_work); $this->pdf->SetX(17); //$this->pdf->Write(0, ucwords(('Number of Tardiness:'))); $this->pdf->SetX(50); //$this->pdf->Write(0, ucwords(($late_count + $undertime_count))); $this->pdf->SetX(110); //$this->pdf->Write(0, ucwords(('Number of Tardiness:'))); $this->pdf->SetX(143); //$this->pdf->Write(0, ucwords(($late_count + $undertime_count))); //overtime $this->overtime = $this->Helps->compute_time($this->overtime); $print_overtime_in_dtr = Setting::getField('print_overtime_in_dtr'); if ($print_overtime_in_dtr == 1) { $this->pdf->SetX(17); $this->pdf->Write(0, ucwords('Over time:')); $this->pdf->Write(0, ucwords($this->overtime)); $this->pdf->SetX(110); $this->pdf->Write(0, ucwords('Over time:')); $this->pdf->Write(0, ucwords($this->overtime)); } // If allow the 40 hrs per week if ($this->allow_40hrs == TRUE) { $this->pdf->Ln(6); $this->pdf->SetX(17); $this->pdf->Write(0, 'The system allow the 40 hrs a week'); $this->pdf->SetX(110); $this->pdf->Write(0, 'The system allow the 40 hrs a week'); // We require hours only here. $this->Helps->hours_only = TRUE; $this->pdf->Ln(4); $this->pdf->SetX(17); $this->pdf->Write(0, '1st week: ' . $this->Helps->compute_time($this->week1_hours)); $this->pdf->SetX(110); $this->pdf->Write(0, '1st week: ' . $this->Helps->compute_time($this->week1_hours)); $this->pdf->Ln(4); $this->pdf->SetX(17); $this->pdf->Write(0, '2nd week: ' . $this->Helps->compute_time($this->week2_hours)); $this->pdf->SetX(110); $this->pdf->Write(0, '2nd week: ' . $this->Helps->compute_time($this->week2_hours)); $this->pdf->Ln(4); $this->pdf->SetX(17); $this->pdf->Write(0, '3rd week: ' . $this->Helps->compute_time($this->week3_hours)); $this->pdf->SetX(110); $this->pdf->Write(0, '3rd week: ' . $this->Helps->compute_time($this->week3_hours)); $this->pdf->Ln(4); $this->pdf->SetX(17); $this->pdf->Write(0, '4th week: ' . $this->Helps->compute_time($this->week4_hours)); $this->pdf->SetX(110); $this->pdf->Write(0, '4th week: ' . $this->Helps->compute_time($this->week4_hours)); } // Add office head and designation $print_office_head_in_dtr = Setting::getField('print_office_head_in_dtr'); if ($print_office_head_in_dtr == 1) { $office = $this->Office->get_office_info($name['office_id']); // If detailed if ($name['detailed_office_id'] != 0) { $detailed_office = $this->Office->get_office_info($name['detailed_office_id']); $office['office_head'] = $detailed_office['office_head']; $office['position'] = $detailed_office['position']; } // If Employee is Department Head $o = new Office_m(); $o->get_by_employee_id($this->employee_id); if ($o->exists()) { if ($lgu_code == 'marinduque_province') { $office['office_head'] = 'CARMENCITA O. REYES'; $office['position'] = 'Governor'; } else { $office['office_head'] = 'ATTORNEY AGUSTIN M. ROCAMORA'; $office['position'] = 'City Administrator'; } } // Check if assistant if ($lgu_code == '') { if ($name['assistant_dept_head'] == 1) { $office['office_head'] = 'ATTORNEY AGUSTIN M. ROCAMORA'; $office['position'] = 'City Administrator'; } } // We need to work out for this as exception if ($this->employee_id === '61') { $office['office_head'] = 'ANTONIO L. UY, JR. M.D.'; $office['position'] = 'Vice Governor'; } // We need to work out for this as exception (Puerto) if ($this->employee_id == '013001') { $office['office_head'] = 'LUCILO BAYRON'; $office['position'] = 'Vice Mayor'; } // For Quirino Province if ($this->employee_id == '122265') { $office['office_head'] = 'PELIGIO H. OBLIGACION, JR.'; $office['position'] = 'Supervising Administrative Officer'; } $this->pdf->SetXY(17, 217); $this->pdf->Cell(73, 4, strtoupper($office['office_head']), '0', 0, 'C', FALSE); $this->pdf->SetX(110); $this->pdf->Cell(73, 4, strtoupper($office['office_head']), '0', 0, 'C', FALSE); $this->pdf->Ln(4); $this->pdf->SetX(17); $this->pdf->Cell(73, 4, $office['position'], '0', 0, 'C', FALSE); $this->pdf->SetX(110); $this->pdf->Cell(73, 4, $office['position'], '0', 0, 'C', FALSE); } // Process the adding of undertime to leave card $this->leave_card_undertime(); // Reset $this->late_count = 0; $this->late_final = 0; $this->undertime_count = 0; $this->undertime_final = 0; $this->line_number = 1; $this->overtime = 0; $this->number_of_hours_work = 0; header('Cache-Control: maxage=3600'); //Adjust maxage appropriately header('Pragma: public'); // If the parameter is D = download F = save as file $this->pdf->Output('dtr/archives/' . $name['office_id'] . "_{$employee_id}.pdf", 'F'); // All name of dtr file. put in an array $multiple_dtr[] = 'dtr/archives/' . $name['office_id'] . "_{$employee_id}.pdf"; foreach ($array_of_deleted_dates as $dates) { $this->Dtr->delete_dtr($this->employee_id, $dates); } } //foreach($employee_array as $employee_id) ========= START ==================================== if (file_exists('dtr/archives/' . $name['office_id'] . ".pdf")) { unlink('dtr/archives/' . $name['office_id'] . ".pdf"); } /* // Concatenate the pdf files $this->pdf = new FPDI(); $this->pdf->setFiles($multiple_dtr); $this->pdf->concat(); $this->pdf->Output('dtr/archives/'.$name['office_id'].".pdf", 'F'); */ // Changed on 1.28.2012 // Since I updated the fpdf and fpdi libraries, // I did this for safe update of libraries // Orig is on top of this comments $this->load->library('concat_pdf'); $this->concat_pdf->setFiles($multiple_dtr); $this->concat_pdf->concat(); $this->concat_pdf->Output('dtr/archives/' . $name['office_id'] . ".pdf", 'F'); // Delete all files foreach ($this->array_pdf as $filename) { if (file_exists($filename)) { unlink($filename); } } $data['pop_up'] = 1; $data['office_id'] = $name['office_id']; $_POST['office_id'] = $name['office_id']; // added 2011-02-14 Session::put('from_view_attendance_office_id', $name['office_id']); // added 2013-11-22 // Delete all tardiness with zero seconds $this->Tardiness->delete_zero_seconds(); } //if ($op == 1) ================== END ========================== //To do: execute if page is not from view attendance if ($this->input->get('from_view_attendance') != TRUE) { $data['main_content'] = 'dtr'; return View::make('includes/template', $data); } }
function cto_apps($id = '') { $c = CompensatoryTimeoff::find($id); $name = $this->Employee->get_employee_info($c->employee_id); $office_name = $this->Office->get_office_name($name['office_id']); $this->load->library('fpdf'); define('FPDF_FONTPATH', $this->config->item('fonts_path')); $this->load->library('fpdi'); $pdf = new FPDI('P', 'mm', 'Legal'); // add a page $pdf->AddPage(); // set the sourcefile $pdf->setSourceFile('dtr/template/app_for_offset.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('Arial', 'B', 12); // set initial placement $pdf->SetXY(158, 10.5); $pdf->Write(0, 'Tracking no: ' . $id); $pdf->Ln(9); $pdf->SetX(158); $pdf->Ln(20); // go to 25 X (indent) $pdf->SetX(12); $this->Office->fields = array('office_code'); $office = $this->Office->get_office_info($name['office_id']); // write office $pdf->SetFont('Arial', 'B', 10); $pdf->Write(0, $office['office_name']); $pdf->SetFont('Arial', 'B', 12); //lname $pdf->SetX(99); $pdf->Write(0, $name['lname']); //fname $pdf->SetX(145); $pdf->Write(0, $name['fname']); //mname $pdf->SetX(187); $pdf->Write(0, $name['mname'][0] . '.'); $pdf->Ln(10); //date of file $pdf->SetX(20); $pdf->Write(0, $c->date_file); //position $pdf->SetFont('Arial', 'B', 10); $pdf->SetX(63); $pdf->Write(0, $name['position']); $pdf->SetFont('Arial', 'B', 12); // We need to check what salary grade the office use if ($office['salary_grade_type'] == 'hospital') { $this->Salary_grade->salary_grade_type = 'hospital'; } //monthly salary $pdf->SetX(140); $pdf->Write(0, 'P ' . number_format($this->Salary_grade->get_monthly_salary($name['salary_grade'], $name['step']), 2)); $days = 'day'; if ($c->days > 1) { $days = 'days'; } $pdf->Ln(13); $pdf->SetX(30); $pdf->Write(0, $c->days . ' ' . $days); $pdf->SetX(140); //$pdf->Write(0, 'daily rate here'); $pdf->Ln(13); $pdf->SetX(50); $pdf->Write(0, $this->Helps->get_month_name($c->month) . ' ' . $c->dates . ', ' . $c->year); $cto_balances_as_of = date("F d, Y", strtotime($c->date_file . "-1 day")); $pdf->SetXY(30, 106); $pdf->Write(0, $cto_balances_as_of); // Compute balances // (balance + earn) - spent $cto = CompensatoryTimeoff::getBalance($c->employee_id); //$balance = $cto->days; $balance = $cto; $cto = CompensatoryTimeoff::getEarnedSpent($c->employee_id); //$earn = $cto->days; $earn = $cto; $cto = CompensatoryTimeoff::getEarnedSpent($c->employee_id, 'spent'); //$spent = $cto->days; $spent = $cto; $total_balance = $balance + $earn - $spent; $pdf->SetXY(35, 116); $pdf->Write(0, $total_balance); $pdf->SetX(87); $pdf->Write(0, ''); // hours here // Get office head $office = $this->Office->get_office_info($name['office_id']); // If detailed if ($name['detailed_office_id'] != 0) { $detailed_office = $this->Office->get_office_info($name['detailed_office_id']); $office['office_head'] = $detailed_office['office_head']; $office['position'] = $detailed_office['position']; } // If Employee is Department head $o = new Office_m(); $o->get_by_employee_id($c->employee_id); if ($o->exists()) { $office['office_head'] = 'CARMENCITA O. REYES'; $office['position'] = 'Governor'; } // We need to work out for this as exception if ($c->employee_id == '61') { $office['office_head'] = 'ANTONIO L. UY, JR. M.D.'; $office['position'] = 'Vice Governor'; } $pdf->Ln(6); $pdf->SetX(120); $pdf->Cell(73, 4, strtoupper($office['office_head']), '0', 0, 'C', FALSE); $pdf->Ln(5); $pdf->SetFont('Arial', '', 10); $pdf->SetX(120); $pdf->Cell(73, 4, $office['position'], '0', 0, 'C', FALSE); $pdf->SetFont('Arial', 'B', 12); // Statement of CTO signatory $statement_certified = Setting::getField('cto_certification'); $statement_certified_position = Setting::getField('cto_certification_position'); $pdf->Ln(5); $pdf->SetX(22); $pdf->Cell(73, 4, strtoupper($statement_certified), '0', 0, 'C', FALSE); $pdf->Ln(5); $pdf->SetFont('Arial', '', 10); $pdf->SetX(22); $pdf->Cell(73, 4, $statement_certified_position, '0', 0, 'C', FALSE); $pdf->SetFont('Arial', 'B', 12); // ====================Second Form ============= $pdf->Ln(44); $pdf->SetX(12); // write office $pdf->SetFont('Arial', 'B', 10); $pdf->Write(0, $office['office_name']); $pdf->SetFont('Arial', 'B', 12); //lname $pdf->SetX(99); $pdf->Write(0, $name['lname']); //fname $pdf->SetX(145); $pdf->Write(0, $name['fname']); //mname $pdf->SetX(187); $pdf->Write(0, $name['mname'][0] . '.'); $pdf->Ln(10); //date of file $pdf->SetX(20); $pdf->Write(0, $c->date_file); //position $pdf->SetFont('Arial', 'B', 10); $pdf->SetX(63); $pdf->Write(0, $name['position']); $pdf->SetFont('Arial', 'B', 12); //monthly salary $pdf->SetX(140); $pdf->Write(0, 'P ' . number_format($this->Salary_grade->get_monthly_salary($name['salary_grade'], $name['step']), 2)); $pdf->Ln(13); $pdf->SetX(30); $pdf->Write(0, $c->days . ' ' . $days); $pdf->SetX(140); //$pdf->Write(0, 'daily rate here'); $pdf->Ln(13); $pdf->SetX(50); $pdf->Write(0, $this->Helps->get_month_name($c->month) . ' ' . $c->dates . ', ' . $c->year); $cto_balances_as_of = date("F d, Y", strtotime($c->date_file . "-1 day")); $pdf->Ln(30); $pdf->SetX(30); //$pdf->Write(0, $cto_balances_as_of); $pdf->Ln(10); $pdf->SetX(35); //$pdf->Write(0, $total_balance); $pdf->Ln(6); $pdf->SetX(120); $pdf->Cell(73, 4, strtoupper($office['office_head']), '0', 0, 'C', FALSE); $pdf->Ln(5); $pdf->SetFont('Arial', '', 10); $pdf->SetX(120); $pdf->Cell(73, 4, $office['position'], '0', 0, 'C', FALSE); $pdf->SetFont('Arial', 'B', 12); $pdf->Ln(5); $pdf->SetX(22); $pdf->Cell(73, 4, strtoupper($statement_certified), '0', 0, 'C', FALSE); $pdf->Ln(5); $pdf->SetFont('Arial', '', 10); $pdf->SetX(22); $pdf->Cell(73, 4, $statement_certified_position, '0', 0, 'C', FALSE); $pdf->SetFont('Arial', 'B', 12); header('Cache-Control: maxage=3600'); //Adjust maxage appropriately header('Pragma: public'); $pdf->Output('dtr/reports/cto-apps-' . intval($c->employee_id) . '.pdf', 'I'); //return Redirect::to('dtr/reports/leave-apps-'.$rows['employee_id'].'.pdf', 'refresh'); }