function plantilla($office_id = '', $year = '2009') { $data = array(); $this->Employee->fields = array('id', 'employee_id', 'office_id', 'lname', 'fname', 'mname'); if ($office_id != '') { $p = new Plantilla_item(); $data['rows'] = $p->get_by_office_id($office_id); } // $data['year'] = $year; foreach ($data['rows'] as $row) { $c = new Plantilla(); $c->where('employee_id', $row->id); $c->where('year', $year); $c->get(); if ($c->exists()) { //echo 'cool'; } else { $c->employee_id = $row->id; $c->year = $year; //$c->type = 'balance'; //$c->save(); //echo 'not cool'; } } return View::make('ajax/plantilla', $data); }
function index($year = '2009') { $data['page_name'] = '<b>Plantilla of Personnel</b>'; $data['msg'] = ''; $data['error_msg'] = ''; // Use for office listbox $data['options'] = $this->options->office_options(); $data['selected'] = Input::get('office_id') ? Input::get('office_id') : Session::get('office_id'); $data['year_options'] = $this->options->year_options(date('Y') - 5, date('Y') + 3); //2010 - 2020 $data['year_selected'] = Input::get('year') ? Input::get('year') : date('Y'); $office_id = $data['selected']; $this->Employee->fields = array('id', 'employee_id', 'office_id', 'lname', 'fname', 'mname'); if ($office_id != '') { $p = new Plantilla_item(); $data['rows'] = $p->get_by_office_id($office_id); } // $data['year'] = $year; foreach ($data['rows'] as $row) { $c = new Plantilla_m(); $c->where('employee_id', $row->id); $c->where('year', $year); $c->get(); if ($c->exists()) { //echo 'cool'; } else { $c->employee_id = $row->id; $c->year = $year; //$c->type = 'balance'; //$c->save(); //echo 'not cool'; } } if (Input::get('op')) { } $data['main_content'] = 'plantilla/index'; return View::make('includes/template', $data); }