function update_component() { $comp = GetAllSelect('payroll_component', 'id')->result(); foreach ($comp as $c) { $data = array('session_id' => $this->new_session, 'payroll_component_id' => $c->id); $filter = array('session_id' => 'where/' . $this->new_session, 'payroll_component_id' => 'where/' . $c->id); $num_rows = GetAllSelect('payroll_component_session', 'id', $filter)->num_rows(); if ($num_rows > 0) { $this->db->where('session_id', $this->new_session)->where('payroll_component_id', $c->id)->update('payroll_component_session', $data); } else { $this->db->insert('payroll_component_session', $data); } $filter2 = array('session_id' => 'where/' . $this->old_session, 'payroll_component_id' => 'where/' . $c->id); $comp_sess_before = getValue('id', 'payroll_component_session', $filter2); print_ag($comp_sess_before); $comp_value = getAll('payroll_component_value', array('payroll_component_session_id' => 'where/' . $comp_sess_before))->row(); print_ag($comp_value); $comp_sess_new = getValue('id', 'payroll_component_session', $filter); $num_rows_new = GetAllSelect('payroll_component_value', 'id', array('payroll_component_session_id' => 'where/' . $comp_sess_new))->num_rows(); if (!empty($comp_value)) { $data2 = array('payroll_component_session_id' => $comp_sess_new, 'from' => $comp_value->from, 'to' => $comp_value->to, 'formula' => $comp_value->formula, 'is_condition' => $comp_value->is_condition, 'min' => $comp_value->min, 'max' => $comp_value->max, 'created_by' => sessId(), 'created_on' => dateNow()); if ($num_rows_new > 0) { $this->db->where('payroll_component_session_id', $comp_sess_new)->update('payroll_component_value', $data2); } else { $this->db->insert('payroll_component_value', $data2); } } print_ag($this->db->last_query()); } }
function insert_kontak_stok_log() { $q = getAll('stok_log')->result(); foreach ($q as $k) { $kontak = ($k->type = 'in') ? getValue("kontak_id", "purchase_order", array('id' => 'where/' . $k->ref)) : getValue("kontak_id", "sales_order", array('id' => 'where/' . $k->ref)); $this->db->where('id', $k->id)->update('stok_log', array('kontak' => $kontak)); print_ag($this->db->last_query()); } }