function index() { $sess_now = sessNow() - 1; $sess_now = sessNow(); //TABLE COMPONENT_VALUE; $master = getAll('payroll_master', array('session_id' => 'where/' . date('year') - 1)); foreach ($master->result() as $m) { $masterz = array('employee_id' => $m->employee_id, 'session_id' => $m->session_id); $m_num_rows = getAll('payroll_master', array('session_id' => 'where/' . $sess_now, 'employee_id' => 'where/' . $m->employee_id))->num_rows(); if ($m_num_rows > 0) { $this->db->where('session_id', $sess_now)->where('employee_id', $m->employee_id)->update('payroll_master', $masterz); $m_id = getValue('id', 'payroll_master', array('session_id' => 'where/' . $sess_now, 'employee_id' => 'where/' . $m->employee_id)); } else { $this->db->insert('payroll_master', $masterz); $m_id = $this->db->insert_id(); } $m_comp = getAll('payroll_master_component', array('payroll_master_id' => 'where/' . $m->id)); foreach ($m_comp->result() as $m_c) { $m_compz = array('payroll_master_id' => $m_id, 'payroll_component_id' => $m_c->payroll_component_id, 'value' => $m_c->value); $m_comp_num_rows = getAll('payroll_master_component', array('payroll_master_id' => 'where/' . $m_id))->num_rows(); if ($m_comp_num_rows > 0) { $this->db->where('payroll_master_id', $m_id)->update('payroll_master_component', $m_compz); } else { $this->db->insert('payroll_master_component', $m_compz); } } } echo json_encode(array("result" => TRUE)); }
public function generate_new_session() { $sess_now = sessNow(); $sess_now = 2016; //TABLE COMPONENT_VALUE; $comp = getAll('payroll_component_value', array('session_id' => 'where/' . date('year') - 1)); foreach ($comp->result() as $c) { $component = array('session_id' => $sess_now, 'payroll_component_id' => $c->payroll_component_id, 'formula' => $c->formula, 'is_condition' => $c->is_condition, 'min' => $c->min, 'max' => $c->max); $c_num_rows = getAll('payroll_component_value', array('session_id' => 'where/' . $sess_now, 'payroll_component_id' => 'where/' . $c->payroll_component_id))->num_rows(); if ($c_num_rows > 0) { $this->db->where('session_id', $sess_now)->where('payroll_component_id', $c->payroll_component_id)->update('payroll_component_value', $component); } else { $this->db->insert('payroll_component_value', $component); } } $master = getAll('payroll_master', array('session_id' => 'where/' . date('year') - 1)); foreach ($master->result() as $m) { $masterz = array('employee_id' => $m->employee_id, 'session_id' => $m->session_id); $m_num_rows = getAll('payroll_master', array('session_id' => 'where/' . $sess_now, 'employee_id' => 'where/' . $m->employee_id))->num_rows(); if ($m_num_rows > 0) { $this->db->where('session_id', $sess_now)->where('employee_id', $m->employee_id)->update('payroll_master', $masterz); $m_id = getValue('id', 'payroll_master', array('session_id' => 'where/' . $sess_now, 'employee_id' => 'where/' . $m->employee_id)); } else { $this->db->insert('payroll_master', $masterz); $m_id = $this->db->insert_id(); } $m_comp = getAll('payroll_master_component', array('payroll_master_id' => 'where/' . $m->id)); foreach ($m_comp->result() as $m_c) { $m_compz = array('payroll_master_id' => $m_id, 'payroll_component_id' => $m_c->payroll_component_id, 'value' => $m_c->value); $m_comp_num_rows = getAll('payroll_master_component', array('payroll_master_id' => 'where/' . $m_id))->num_rows(); if ($m_comp_num_rows > 0) { $this->db->where('payroll_master_id', $m_id)->update('payroll_master_component', $m_compz); } else { $this->db->insert('payroll_master_component', $m_compz); } } } echo json_encode(array("result" => TRUE)); }
<!--Tab COLA--> <div class="tab-pane fade" id="tab-cola"> <div class="container-fluid container-fullw bg-white"> <div class="row"> <div class="col-md-12"> <div class="cola"> <div class="row"> <div class="col-md-2"> <label class="label-form">Select Session</label> </div> <div class="col-md-3"> <select class="select2" id="session_select_cola" style="width:100%"> <option>-- Select Session --</option> <?php foreach ($session->result() as $s) { $selected = $s->id == sessNow() ? "selected='selected'" : ''; ?> <option value="<?php echo $s->id; ?> " <?php echo $selected; ?> ><?php echo $s->description; ?> </option> <?php } ?> </select>
} ?> </select> <span class="help-block"></span> </div> </div> </div> <div class="col-md-7"> <div class="col-md-12"> <label class="control-label col-md-3">Session</label> <div class="col-md-9"> <select name="session_id" class="form-control"> <?php if ($session_id->num_rows() > 0) { foreach ($session_id->result() as $sess) { $selected = $sess->id == sessNow() ? 'selected="selected"' : ''; ?> <option value="<?php echo $sess->id; ?> " <?php echo $selected; ?> ><?php echo $sess->id; ?> </option> <?php } } ?>