function loan($employee_id = '') { $data['page_name'] = '<b>Loan Schedule</b>'; //Use for office listbox $data['options'] = $this->options->office_options(); $data['selected'] = Session::get('office_id'); $data['employee_id'] = $employee_id; $data['msg'] = ''; $p = new Deduction_loan(); //echo $this->db->last_query(); $this->load->library('pagination'); $config['base_url'] = base_url() . 'payroll/deduction/loan/'; $config['total_rows'] = $p->get()->count(); $config['per_page'] = '15'; $this->pagination->initialize($config); // How many related records we want to limit ourselves to $limit = $config['per_page']; // Set the offset for our paging $offset = $this->uri->segment(3); // Get all positions //$p = new Position(); //$p->order_by('desc'); //$data['deductions'] = $p->get($limit, $offset); $data['deductions'] = array(); if ($employee_id) { $p->where('employee_id', $employee_id); $data['deductions'] = $p->get($limit, $offset); } if (Input::get('op')) { $data['employee_id'] = Input::get('employee_id'); $data['selected'] = Input::get('office_id'); $p->where('employee_id', Input::get('employee_id')); $data['deductions'] = $p->get($limit, $offset); } $data['main_content'] = 'deduction/loan/loan'; return View::make('includes/template', $data); }
// Lets count info per agency $d = new Deduction_information(); $d->order_by('report_order'); $infos = $d->get_by_deduction_agency_id($agency->id); ?> <?php foreach ($infos as $info) { ?> <?php // To do: we are going to check for active deductions per employee $dl = new Deduction_loan(); $dl->where('employee_id', $employee->id); $dl->where('deduction_information_id', $info->id); $dl->get(); $deduct = 0; if ($dl->exists()) { $deduct = $dl->monthly_due; // Deduct from salary $net_pay_monthly = $net_pay_monthly - $dl->monthly_due; } // If tax if ($info->code == 'Tax Withheld') { $tt = new Tax_table(); $tt->where('start_range <', $monthly_salary); $tt->order_by('start_range', 'DESC'); $tt->get(1); // The tax fix amount // If fix amount is not equal to zero meaning the // salary is more than 10,000.00
function loan_deductions() { $CI =& get_instance(); $date = $CI->input->post('year') . '-' . $CI->input->post('month') . '-15'; $d = new Deduction_loan(); $d->where('employee_id', $this->employee_id); $d->where('deduction_information_id', $this->deduction_id); $d->where('date_to >=', $date); $d->where('status', 'active'); $d->get(); $this->loan_id = $d->id; // The deduction loan id $this->share = 'employee_share'; $this->add_deductions($this->share, $d->monthly_pay); // add up deductions return $d->monthly_pay; }