%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class News extends CI_Controller { function __construct() { parent::__construct(); if((!isset($_SESSION['is_logged']))||($_SESSION['is_logged']==false)) { $_SESSION['redirect'] = base_url()."admin/News/view_news"; redirect(base_url().'admin/login'); } $this->load->model('news_model', 'news'); } public function index() { //echo "Workin="; $this->view_news(); } public function add_news() { extract($_POST); $data = array(); $data['data_string'] = ''; echo '<script>console.log("add News")</script>'; $post=$this->input->post(); if($post){ echo '<script>console.log("post")</script>'; $this->form_validation->set_rules('newsTitle', 'News Title', 'required'); $this->form_validation->set_rules('newsslug', 'newsslug', 'required'); $this->form_validation->set_rules('news_detail', 'news detail', 'required'); $this->form_validation->set_rules('newsDate', 'newsDate', 'required'); if ($this->form_validation->run() == FALSE) { echo '<script>console.log("Error in validating doctor")</script>'; //console.log("Error in validating doctor"); $this->load->view('admin/AddNews'); } else { $insert_data = array( 'newsid' => $post['newsid'], 'news_title' => $post['newsTitle'], 'news_description' => $post['news_detail'], 'news_slug' => $post['newsslug'], 'news_date' => $post['newsDate'], 'status' => '1' ); $insert_data['image']= $this->uploadImage(); $success = ''; $success = $this->news->insert_news($insert_data); echo '<script>console.log("'.$success.'")</script>'; if($success){ redirect(base_url()."admin/News/view_news"); } } } $this->load->view('admin/AddNews',$data); } public function update_news($id){ extract($_POST); $data = array(); $data['data_string'] = ''; $post=$this->input->post(); $records = $this->news->get_news($id); if($id) { $data = array( 'newsid' => $records[0]['newsid'], 'news_title' => $records[0]['news_title'], 'image' => $records[0]['image'], 'news_description' => $records[0]['news_description'], 'news_slug' => $records[0]['news_slug'], 'newsDate' => $records[0]['news_date'], 'status' => $records[0]['status'] ); $this->load->view('admin/update_news',$data); } } public function updatenews($ids){ extract($_POST); $post=$this->input->post(); if($post){ $this->form_validation->set_rules('newsTitle', 'News Title', 'required'); $this->form_validation->set_rules('newsslug', 'newsslug', 'required'); $this->form_validation->set_rules('news_detail', 'news detail', 'required'); $this->form_validation->set_rules('newsDate', 'newsDate', 'required'); if($this->form_validation->run() == FALSE) { echo '<script>console.log("Error in validating doctor")</script>'; //console.log("Error in validating doctor"); $this->load->view('admin/update_news'); } else { $insert_data = array( 'newsid' => $post['newsid'], 'news_title' => $post['newsTitle'], 'news_description' => $post['news_detail'], 'news_slug' => $post['newsslug'], 'news_date' => $post['newsDate'], 'status' => '1' ); $insert_data['image']= $this->uploadImage(); if($_POST['old_image']!='' && $insert_data['image']==''){ $insert_data['image'] = $_POST['old_image']; } unset($_POST['old_image']); $success = ''; $success = $this->news->editnews($insert_data,$newsid); echo '<script>console.log("'.$success.'")</script>'; if($success){ redirect(base_url()."admin/News/view_news"); } } } //$this->load->view('admin/AddNews',$data); } public function remove_news($id) { $data = array(); if($this->news->delete_news($id)){ $data['msg'] = 'News Section deleted succesfully'; $this->load->view('admin/view_news',$data); } else{ $data['msg'] = 'News could not be deleted'; } $data['records'] = $this->news->get_news($id); if(!$data){ show_404(); } $this->load->view('admin/view_news',$data); } public function view_news($id=0) { $data = array(); $data['records'] = $this->news->get_news($id); if(!$data){ show_404(); } $this->load->view('admin/view_news',$data); } public function uploadImage() { $config['upload_path'] = './uploads/news/'; $config['allowed_types'] = "*"; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image')) { log_message('error', 'Image Upload Error: ' . $this->upload->display_errors()); } $img = $this->upload->data(); // if(!empty($img['file_name'])) { // resizeImage($img['file_name'],'300','300','attachments/awards_images'); // } return $img['file_name']; } }