Backups Created:
/home/japatmex/public_html/wp-content/edit-wolf.php
Savvy
W
olf -
MANAGER
Edit File: Coupon.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Coupon extends MY_Controller { public function __construct(){ parent::__construct(); $this->load->model('Ecomm_model'); $this->load->helper('ecomm_helper'); } public function index($page = 1) { $this->data['page_title'] = 'Coupons'; $this->data['current_page'] = 'Coupons'; $row=$this->Ecomm_model->coupon_list(); $config = array(); $config["base_url"] = base_url($this->config->item('apanel_name').'/ecomm/coupon'); $config["total_rows"] = count($row); $config["per_page"] = 12; $config['num_links'] = 4; $config['use_page_numbers'] = TRUE; $config['reuse_query_string'] = TRUE; $config['enable_query_strings'] = TRUE; $config['page_query_string'] = FALSE; $config['full_tag_open'] = '<ul class="pagination">'; $config['full_tag_close'] = '</ul>'; $config['first_link'] = '<i class="fa fa-angle-double-left"></i>'; $config['first_tag_open'] = '<li>'; $config['first_tag_close'] = '</li>'; $config['last_link'] = '<i class="fa fa-angle-double-right"></i>'; $config['last_tag_open'] = '<li>'; $config['last_tag_close'] = '</li>'; $config['next_link'] = ''; $config['next_tag_open'] = '<span class="nextlink">'; $config['next_tag_close'] = '</span>'; $config['prev_link'] = ''; $config['prev_tag_open'] = '<span class="prevlink">'; $config['prev_tag_close'] = '</span>'; $config['cur_tag_open'] = '<li class="active"><a href="#">'; $config['cur_tag_close'] = '<span class="sr-only">(current)</span></a></li>'; $config['num_tag_open'] = '<li style="margin:3px">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $page=($page-1) * $config["per_page"]; if($this->input->post('search_value')!=''){ $keyword=addslashes(trim($this->input->post('search_value'))); $this->data['coupon_list'] = $this->Ecomm_model->coupon_list('id', 'DESC', '', '', $keyword); } else{ $this->data["links"] = $this->pagination->create_links(); $this->data['coupon_list'] = $this->Ecomm_model->coupon_list('id', 'DESC', $config["per_page"], $page); } $this->data['view'] = 'admin/ecomm/coupon'; $this->load->view('admin/layouts/default1', $this->data); } public function add() { $THEME = $rowSettings->Theme; if($this->input->method() == 'post') { $this->form_validation->set_rules('coupon_code', 'Enter Coupon Code', 'trim|required'); if($this->form_validation->run() == FALSE) { $messge = array('message' => $this->lang->line('input_required'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/coupon/add').get_query_string()); } else { $config['upload_path'] = FCPATH . 'uplds'.$THEME.'/ecomm/images/coupons/'; $config['allowed_types'] = 'jpg|png|jpeg|gif'; $image = date('dmYhis').'_'.rand(0,99999).".".pathinfo($_FILES['file_name']['name'], PATHINFO_EXTENSION); $config['file_name'] = $image; $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/coupon/add').get_query_string()); } else { $upload_data = $this->upload->data(); } $this->load->helper("date"); $data = array( 'coupon_desc' => $this->input->post('coupon_desc'), 'coupon_code' => $this->input->post('coupon_code'), 'coupon_image' => $image, 'coupon_per' => $this->input->post('coupon_per'), 'coupon_amt' => $this->input->post('coupon_amt'), 'max_amt_status' => $this->input->post('max_amt_status'), 'coupon_max_amt' => $this->input->post('coupon_max_amt'), 'cart_status' => $this->input->post('cart_status'), 'coupon_cart_min' => $this->input->post('coupon_cart_min'), 'coupon_limit_use' => $this->input->post('coupon_limit_use'), 'created_at' => strtotime(date('d-m-Y h:i:s A')) ); $data = $this->security->xss_clean($data); if($this->Ecomm_model->insert($data, 'tbl_gf_ecomm_coupon')){ $messge = array('message' => $this->lang->line('add_msg'),'class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); } else{ $messge = array('message' => $this->lang->line('add_error'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); } redirect(base_url($this->config->item('apanel_name').'/ecomm/coupon/add').get_query_string()); } } $this->data['page_title'] = 'Coupons'; $this->data['current_page'] = 'Add Coupon'; $this->data['view'] = 'admin/ecomm/add_coupon'; $this->load->view('admin/layouts/default1', $this->data); } public function edit($id) { $THEME = $rowSettings->Theme; if($this->input->method() == 'post') { $data = $this->Ecomm_model->single_coupon($id); if($_FILES['file_name']['error']!=4){ unlink(FCPATH . 'uplds'.$THEME.'/ecomm/images/coupons/'.$data[0]->banner_image); // unlink(FCPATH . 'uplds'.$THEME.'/ecomm/images/coupons/thumbs'.$data[0]->coupon_image); $config['upload_path'] = FCPATH . 'uplds'.$THEME.'/ecomm/images/coupons/'; $config['allowed_types'] = 'jpg|png|jpeg|gif'; $image = date('dmYhis').'_'.rand(0,99999).".".pathinfo($_FILES['file_name']['name'], PATHINFO_EXTENSION); $config['file_name'] = $image; $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/coupon/edit/'.$id).get_query_string()); } } else{ $image=$data[0]->coupon_image; } $this->load->helper("date"); $data = array( 'coupon_desc' => $this->input->post('coupon_desc'), 'coupon_code' => $this->input->post('coupon_code'), 'coupon_image' => $image, 'coupon_per' => $this->input->post('coupon_per'), 'coupon_amt' => $this->input->post('coupon_amt'), 'max_amt_status' => $this->input->post('max_amt_status'), 'coupon_max_amt' => $this->input->post('coupon_max_amt'), 'cart_status' => $this->input->post('cart_status'), 'coupon_cart_min' => $this->input->post('coupon_cart_min'), 'coupon_limit_use' => $this->input->post('coupon_limit_use') ); $data = $this->security->xss_clean($data); if($this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_coupon')){ $messge = array('message' => $this->lang->line('update_msg'),'class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); } else{ $messge = array('message' => $this->lang->line('update_error'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); } redirect(base_url($this->config->item('apanel_name').'/ecomm/coupon/edit/'.$id).get_query_string()); } $this->data['page_title'] = 'Coupons'; $this->data['coupon'] = $this->Ecomm_model->single_coupon($id); $this->data['current_page'] = 'Edit Coupon'; $this->data['view'] = 'admin/ecomm/edit_coupon'; $this->load->view('admin/layouts/default1', $this->data); } public function delete($id) { echo $this->Ecomm_model->deleteCoupon($id); } public function active($id) { $data = array( 'status' => 1 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_coupon'); echo 'Enable successfully...'; } public function deactive($id) { $data = array( 'status' => 0 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_coupon'); echo 'Disable successfully...'; } }