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); }
<th width="35%" bgcolor="#D6D6D6"><strong>Name of Incumbent</strong></th> <th width="12%" bgcolor="#D6D6D6">Year</th> <th width="7%" bgcolor="#D6D6D6">SG</th> <th width="11%" bgcolor="#D6D6D6">Amount</th> </tr> <?php $i = 0; ?> <?php $p = new Plantilla_m(); ?> <?php foreach ($rows as $row) { ?> <?php $p->where('year', $year); $p->where('plantilla_item_id', $row->id); $p->get(); $e = new Employee_m(); $e->get_by_id($p->employee_id); // last param of dg_editCell is the size of the textbox $onclick0 = "onClick=\"dg_editCell(offices,'" . $p->id . "','item_no','offices.0.{$i}', 'plantilla')\""; $onclick1 = "onClick=\"dg_editCell(offices,'" . $p->id . "','position','offices.1.{$i}', 'plantilla', '40')\""; $onclick2 = "onClick=\"dg_editCell(offices,'" . $p->id . "','year','offices.2.{$i}', 'plantilla', '8')\""; $onclick3 = "onClick=\"dg_editCell(offices,'" . $p->id . "','sg','offices.3.{$i}', 'plantilla', '5')\""; $onclick4 = "onClick=\"dg_editCell(offices,'" . $p->id . "','amount','offices.4.{$i}', 'plantilla', '10')\""; ?> <?php $bg = $this->Helps->set_line_colors(); ?> <tr bgcolor="<?php