public function index() { $this->session->set_userdata(array('log_MODULE' => 'Category', 'log_MID' => '')); $segERR = ''; $catERR = ''; $segment_id = ''; $category_name = ''; $userId = $this->session->userdata('userId'); $show_modal = 0; if ($_POST) { $show_modal = 1; $this->custom_log->write_log('custom_log', 'FOrm submit ' . print_r($_POST, true)); $catID = $this->input->post('catID'); $segment_id = $this->input->post('segment_id'); $category_name = $this->input->post('category_name'); $rules = category_rules(); $this->form_validation->set_rules($rules); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run()) { if ($catID) { if ($this->segment_cat_m->update_category($catID, $segment_id, $category_name)) { $this->session->set_flashdata('success', $this->lang->line('success_update_category')); $this->custom_log->write_log('custom_log', 'message is ' . $this->lang->line('success_update_category')); } else { $this->session->set_flashdata('error', $this->lang->line('error_update_category')); $this->custom_log->write_log('custom_log', 'message is ' . $this->lang->line('error_update_category')); } redirect(base_url() . 'admin/category'); } else { $categoryId = $this->segment_cat_m->add_category($segment_id, $category_name); $this->custom_log->write_log('custom_log', 'categor id is ' . $categoryId); if ($categoryId) { $this->session->set_flashdata('success', $this->lang->line('success_add_category')); $this->custom_log->write_log('custom_log', 'message is ' . $this->lang->line('success_add_category')); } else { $this->session->set_flashdata('error', $this->lang->line('error_add_category')); $this->custom_log->write_log('custom_log', 'message is ' . $this->lang->line('error_add_category')); } redirect(base_url() . 'admin/category'); } } else { $segERR = form_error('segment_id'); $catERR = form_error('category_name'); } } $modified_by = ''; $modified_time = ''; $last_modified = $this->segment_cat_m->last_modified_category(); if (!empty($last_modified)) { $modified_by = $last_modified->first_name . ' ' . $last_modified->last_name; $modified_time = $last_modified->last_modified_time; } $this->data['modified_by'] = $modified_by; $this->data['modified_time'] = $modified_time; $this->data['total'] = $this->segment_cat_m->total_category_where(); $this->data['show_modal'] = $show_modal; $this->data['sendData'] = 'segERR=' . $segERR . '&catERR=' . $catERR . '&segment_id=' . $segment_id . '&category_name=' . $category_name; $this->adminCustomView('category/category_list', $this->data); }
public function addEditmarketingCategory($parentCatId, $catId) { $return = array(); $return['categoryName'] = ''; $return['pageSubmit'] = 1; if ($_POST) { $return['pageSubmit'] = 0; $return['categoryName'] = $this->CI->input->post('category_name'); $catID = $this->CI->input->post('catID'); $rules = category_rules(); $this->CI->form_validation->set_rules($rules); $this->CI->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->CI->form_validation->run()) { $addArr = array('categoryCode' => $return['categoryName'], 'categoryDescription' => $return['categoryName'], 'parentCategoryId' => $parentCatId, 'isMarketing' => 1); if ($catID) { $this->CI->segment_cat_m->update_category($catID, $addArr); $this->CI->session->set_flashdata('success', $this->CI->lang->line('success_update_segment')); $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('success_update_segment')); } else { $inserID = $this->CI->segment_cat_m->add_category($addArr); $this->CI->custom_log->write_log('custom_log', 'inserted segment id is ' . $inserID); if ($inserID) { $this->CI->session->set_flashdata('success', $this->CI->lang->line('success_add_segment')); $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('success_add_segment')); } else { $this->CI->session->set_flashdata('error', $this->CI->lang->line('error_add_segment')); $this->CI->custom_log->write_log('custom_log', 'inserted segment id is ' . $this->CI->lang->line('error_add_segment')); } } redirect(base_url() . $this->CI->session->userdata('userType') . '/marketing_category_management/view_list/' . id_encrypt($parentCatId)); } } if ($return['pageSubmit']) { $details = $this->CI->segment_cat_m->category_details($catId); if (!empty($details)) { $return['categoryName'] = $details->categoryCode; } } return $return; }