<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Reviews extends CI_Controller {

	
	public function __construct()
        {
                parent::__construct();
                $this->load->library('session');
                $this->load->model('admin/Add_order_model');
                if(!isset($_SESSION['admin'])){redirect('admin/Login');}
        }

	

	public function index()
	{
		$data['view_all'] = $this->Add_order_model->get_all_review();
		$this->load->view('admin/header');
		$this->load->view('admin/review-table', $data);
		$this->load->view('admin/footer');
	}

	public function old()
	{
		$data['view_all'] = $this->Add_order_model->get_all_oldx();
		$this->load->view('admin/header');
		$this->load->view('admin/old_review-table', $data);
		$this->load->view('admin/footer');
	}

	

	

	public function mark($id){
		$data = $this->Add_order_model->markx($id);
		if($data == 1){
			$this->session->set_flashdata("success"," Review is Publish Successfully");
				redirect('admin/Reviews');
		}else{
			$this->session->set_flashdata("error"," Something is Wrong");
			redirect('admin/Reviews');
		}
	}
    public function edit($id) {
            $data['update_rows'] = $this->Add_order_model->by_id($id);
//            $this->output->enable_profiler(TRUE);
		$this->load->view('admin/header');
		$this->load->view('admin/old_review-table', $data);
		$this->load->view('admin/footer');
        }

        public function newupdate(){
	        $data = $this->Add_order_model->review_update($_POST);
            if($data){
                $this->session->set_flashdata("success"," Review Updated");
            }else{
                $this->session->set_flashdata("error","Error! Data deletion error.");
            }
            redirect("admin/Review");
        }
	

	public function delete($id)
	{
		$data = $this->Add_order_model->deletex($id);
		if($data == 1){
			$this->session->set_flashdata("success"," Review is Removed Successfully");
				redirect('admin/Reviews');
		}else{
			$this->session->set_flashdata("error"," Something is Wrong");
			redirect('admin/Reviews');
		}
	}

	public function delete_old($id)
	{
		$data = $this->Add_order_model->delete_old_X($id);
		if($data == 1){
			$this->session->set_flashdata("success"," Review is Removed Successfully");
				redirect('admin/Reviews/old');
		}else{
			$this->session->set_flashdata("error"," Something is Wrong");
			redirect('admin/Reviews/old');
		}
	}
}
