ok
Direktori : /home2/selectio/www/gangabuvana/admin/cms/application/controllers/admin/ |
Current File : //home2/selectio/www/gangabuvana/admin/cms/application/controllers/admin/Pricing_table.php |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Pricing_table extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('admin/Model_common'); $this->load->model('admin/Model_pricing_table'); } public function index() { $data['setting'] = $this->Model_common->get_setting_data(); $data['pricing_table'] = $this->Model_pricing_table->show(); $this->load->view('admin/view_header',$data); $this->load->view('admin/view_pricing_table',$data); $this->load->view('admin/view_footer'); } public function add() { $data['setting'] = $this->Model_common->get_setting_data(); $data['all_lang'] = $this->Model_common->all_lang(); $error = ''; $success = ''; if(isset($_POST['form1'])) { if(PROJECT_MODE == 0) { $this->session->set_flashdata('error',PROJECT_NOTIFICATION); redirect($_SERVER['HTTP_REFERER']); } $valid = 1; // $this->form_validation->set_rules('icon', 'Icon', 'trim|required'); $this->form_validation->set_rules('title', 'Title', 'trim|required'); $this->form_validation->set_rules('price', 'Price', 'trim|required'); $this->form_validation->set_rules('subtitle', 'Subtitle', 'trim|required'); $this->form_validation->set_rules('text', 'Text', 'trim|required'); // $this->form_validation->set_rules('button_text', 'Button Text', 'trim|required'); // $this->form_validation->set_rules('button_url', 'Button URL', 'trim|required'); if($this->form_validation->run() == FALSE) { $valid = 0; $error .= validation_errors(); } $path = $_FILES['photo']['name']; $path_tmp = $_FILES['photo']['tmp_name']; if($path!='') { $ext = pathinfo( $path, PATHINFO_EXTENSION ); $file_name = basename( $path, '.' .date("h-i-s"). $ext ); $ext_check = $this->Model_common->extension_check_photo($ext); if($ext_check == FALSE) { $valid = 0; $error .= 'You must have to upload jpg, jpeg, gif or png file for featured photo<br>'; } } else { $valid = 0; $error .= 'You must have to select a photo for featured photo<br>'; } if($valid == 1) { $final_name = 'service-'.date("h-i-s").'.'.$ext; move_uploaded_file( $path_tmp, './public/uploads/'.$final_name ); $form_data = array( // 'icon' => $_POST['icon'], 'title' => $_POST['title'], 'price' => $_POST['price'], 'subtitle' => $_POST['subtitle'], 'text' => $_POST['text'], 'photo' => $final_name, // 'button_text' => $_POST['button_text'], // 'button_url' => $_POST['button_url'], 'lang_id' => 5 ); $this->Model_pricing_table->add($form_data); $success = 'Price table item is added successfully!'; $this->session->set_flashdata('success',$success); redirect(base_url().'admin/pricing_table'); } else { $this->session->set_flashdata('error',$error); redirect(base_url().'admin/pricing_table/add'); } } else { $this->load->view('admin/view_header',$data); $this->load->view('admin/view_pricing_table_add',$data); $this->load->view('admin/view_footer'); } } public function edit($id) { // If there is no pricing table in this id, then redirect $tot = $this->Model_pricing_table->pricing_table_check($id); if(!$tot) { redirect(base_url().'admin/pricing_table'); exit; } $data['setting'] = $this->Model_common->get_setting_data(); $data['all_lang'] = $this->Model_common->all_lang(); $error = ''; $success = ''; if(isset($_POST['form1'])) { if(PROJECT_MODE == 0) { $this->session->set_flashdata('error',PROJECT_NOTIFICATION); redirect($_SERVER['HTTP_REFERER']); } $valid = 1; // $this->form_validation->set_rules('icon', 'Icon', 'trim|required'); $this->form_validation->set_rules('title', 'Title', 'trim|required'); $this->form_validation->set_rules('price', 'Price', 'trim|required'); $this->form_validation->set_rules('subtitle', 'Subtitle', 'trim|required'); $this->form_validation->set_rules('text', 'Text', 'trim|required'); // $this->form_validation->set_rules('button_text', 'Button Text', 'trim|required'); // $this->form_validation->set_rules('button_url', 'Button URL', 'trim|required'); if($this->form_validation->run() == FALSE) { $valid = 0; $error .= validation_errors(); } $path = $_FILES['photo']['name']; $path_tmp = $_FILES['photo']['tmp_name']; if($path!='') { $ext = pathinfo( $path, PATHINFO_EXTENSION ); $file_name = basename( $path,'.' .date("h-i-s"). $ext ); $ext_check = $this->Model_common->extension_check_photo($ext); if($ext_check == FALSE) { $valid = 0; $error .= 'You must have to upload jpg, jpeg, gif or png file for featured photo<br>'; } } if($valid == 1) { $data['pricing_table'] = $this->Model_pricing_table->getData($id); if($path == '') { $form_data = array( 'icon' => $_POST['icon'], 'title' => $_POST['title'], 'price' => $_POST['price'], 'subtitle' => $_POST['subtitle'], 'text' => $_POST['text'], 'button_text' => $_POST['button_text'], 'button_url' => $_POST['button_url'], 'lang_id' => 5 ); $this->Model_pricing_table->update($id,$form_data); } else{ unlink('./public/uploads/'.$data['pricing_table']['photo']); $final_name = 'service-'.date("h-i-s").'.'.$ext; move_uploaded_file( $path_tmp, './public/uploads/'.$final_name ); $form_data = array( 'icon' => $_POST['icon'], 'title' => $_POST['title'], 'price' => $_POST['price'], 'subtitle' => $_POST['subtitle'], 'text' => $_POST['text'], 'photo' => $final_name, 'button_text' => $_POST['button_text'], 'button_url' => $_POST['button_url'], 'lang_id' => 5 ); $this->Model_pricing_table->update($id,$form_data); } $success = 'Pricing table is updated successfully'; $this->session->set_flashdata('success',$success); redirect(base_url().'admin/pricing_table'); } else { $this->session->set_flashdata('error',$error); redirect(base_url().'admin/pricing_table/edit/'.$id); } } else { $data['pricing_table'] = $this->Model_pricing_table->getData($id); $this->load->view('admin/view_header',$data); $this->load->view('admin/view_pricing_table_edit',$data); $this->load->view('admin/view_footer'); } } public function delete($id) { // If there is no pricing table in this id, then redirect $tot = $this->Model_pricing_table->pricing_table_check($id); if(!$tot) { redirect(base_url().'admin/pricing_table'); exit; } if(PROJECT_MODE == 0) { $this->session->set_flashdata('error',PROJECT_NOTIFICATION); redirect($_SERVER['HTTP_REFERER']); } $this->Model_pricing_table->delete($id); $success = 'Pricing table is deleted successfully'; $this->session->set_flashdata('success',$success); redirect(base_url().'admin/pricing_table'); } }