function cancel_cto($id = '', $employee_id = '') { CompensatoryTimeoff::find($id)->delete(); $this->Dtr->cancel_cto($id, $employee_id); Session::flash('msg', 'Compensatory Timeoff has been cancelled!'); return Redirect::to('manual_manage/cto/' . $employee_id, 'refresh'); }
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'); }
function file_cto($process = '', $id = '') { $employee_id = Input::get('employee_id'); $month = Input::get('month'); $year = Input::get('year'); $allow_sat_sun = Input::get('allow_sat_sun'); $process = Input::get('process'); $multiple = Input::get('multiple'); // If not approved_leave replace dash with underscore if ($employee_id != 'approved_leave') { //$employee_id = str_replace('_','-',$employee_id); } $params = array('employee_id' => $employee_id, 'multiple' => $multiple, 'month' => $month, 'year' => $year, 'process' => $process, 'allow_sat_sun' => $allow_sat_sun); $this->load->library('cto', $params); if (Input::get('id') != '') { $cto_apps = CompensatoryTimeoff::find(Input::get('id')); $params = array('employee_id' => $cto_apps->employee_id, 'multiple' => $cto_apps->dates, 'month' => $cto_apps->month, 'year' => $cto_apps->year, 'process' => 2, 'allow_sat_sun' => 1); $process = 2; // Initilize and reset $this->cto->initialize($params); // Set the leave to approved CompensatoryTimeoff::setApproved(Input::get('id')); //exit; } if (!is_numeric($this->cto->employee_id)) { // Check if the employee id exists $is_employee_id_exists = $this->Employee->is_employee_id_exists($employee_id); if ($is_employee_id_exists == FALSE) { // If the process is approved dont exit if ($process == 2) { } else { //echo $this->view_name($this->cto->employee_id); exit; } } } $dates = explode(",", $this->cto->multiple); $name = $this->Employee->get_employee_info($this->cto->employee_id); //echo $name; if ($process != 2) { // Output name if exists $this->cto->is_employee($name); } $invalid = ''; $this->cto->dates = $dates; $this->cto->process_dates(); $this->cto->dates = array_unique($this->cto->date_process); echo $this->cto->count_leave . ' day(s) Compensatory Timeoff'; //print_r($this->cto->dates); //exit; $office_id = $this->Employee->get_single_field('office_id', $this->cto->employee_id); // View only if not online apps if ($process != 2) { // 6.15.2011 5.33pm =============== //if ( $this->cto->leave_type_id == 21) //{ $total_leave = $this->Leave_card->get_total_leave_credits($employee_id); $vbalance = $total_leave['vacation']; $sbalance = $total_leave['sick']; $total_leave_balance = $vbalance + $sbalance; //$this->cto->count_leave = $total_leave_balance; //} // ================================ //echo $this->cto->count_leave.'<br><br>'; } // If date is sat sun or holiday if ($this->cto->count_leave == 0) { echo '<input name="sat_sun" type="hidden" id="sat_sun" value="1" />'; } else { echo '<input name="sat_sun" type="hidden" id="sat_sun" value="0" />'; } if ($process || $process == 2) { if (Session::get('user_type') == 5) { $c = new CompensatoryTimeoff(); $c->employee_id = $this->cto->employee_id; $c->office_id = $office_id; $c->month = $this->cto->month; $c->year = $this->cto->year; $c->days = $this->cto->count_leave; $c->dates = $this->cto->multiple; $c->date_file = date('Y-m-d'); $c->type = 'spent'; $c->status = 'inactive'; $c->save(); ?> <script> $('#messages').hide('slow'); $('#messages').addClass("clean-green"); $('#messages').html('CTO application was set for approval.<br>You may print your CTO application now. ' + '<a href="#" onClick="print_preview(<?php echo intval($c->id); ?> )">Print Preview</a>'); $('#messages').slideDown('slow'); $('#multiple').val(""); $('#allow_sat_sun').attr("checked", false); </script> <?php exit; } $c = new CompensatoryTimeoff(); $c->employee_id = $this->cto->employee_id; $c->office_id = $office_id; $c->month = $this->cto->month; $c->year = $this->cto->year; $c->days = $this->cto->count_leave; $c->dates = $this->cto->multiple; $c->type = 'spent'; $c->status = 'active'; $c->save(); //echo Input::get('id').'25333334455'; //exit; foreach ($this->cto->dates as $date) { // If half day if (strlen($date) > 10) { //get am or pm $am_pm = strtolower(substr($date, -2)); $day = explode(" ", $date); $day = $day[0]; if ($am_pm == 'am') { $field = 'am_login'; $field2 = 'am_logout'; } if ($am_pm == 'pm') { $field = 'pm_login'; $field2 = 'pm_logout'; } //Select if log_date exist in dtr $is_log_date_exists = $this->Dtr->is_log_date_exists($this->cto->employee_id, $day); //update if ($is_log_date_exists == TRUE) { $info = array($field => 'offset', $field2 => 'offset'); $this->Dtr->edit_dtr($info, $this->cto->employee_id, $day); } else { $info = array($field => 'offset', $field2 => 'offset', "log_date" => $day, "employee_id" => $this->cto->employee_id, "office_id" => $office_id, 'compensatory_timeoff_id' => Input::get('id')); $this->Dtr->insert_dtr($info); //use for use logs $this->Logs->insert_logs('attendance', 'Compensatory Timeoff EVENT', '', $this->cto->employee_id); } } else { //Select if log_date exist in dtr $is_log_date_exists = $this->Dtr->is_log_date_exists($this->cto->employee_id, $date); //delete the data if the date and employee id exists if ($is_log_date_exists == TRUE) { //delete the data $this->Dtr->delete_dtr($this->cto->employee_id, $date); } $info = array("employee_id" => $this->cto->employee_id, "log_date" => $date, 'compensatory_timeoff_id' => Input::get('id'), "am_login" => 'offset', "am_logout" => 'offset', "pm_login" => 'offset', "pm_logout" => 'offset', "office_id" => $office_id); $this->Dtr->insert_dtr($info); } } if ($process == 2) { echo '<b> has been approved!</b>'; ?> <script> //$('#messages').addClass("clean-green"); //$('.clean-green').show(); </script> <?php } ?> <script> $('#multiple').val(""); $('#leave_card').load("<?php echo base_url() . 'ajax/show_cto/'; ?> " + $('#employee_id').val()); $('.clean-green').show(); $('#allow_sat_sun').attr("checked", false); //$('#messages').hide(); </script> <?php } }
public static function setApproved($id = '') { $c = CompensatoryTimeoff::find($id); $c->status = 'active'; $c->save(); }