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

class New_orders 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();
		$this->load->view('admin/header');
		$this->load->view('admin/order-table', $data);
		$this->load->view('admin/footer');
	}

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

	

	

	public function mark($id){
		$data = $this->Add_order_model->select($id);
		if($data == 1){
			$this->session->set_flashdata("success"," Order is Completed Successfully");
				redirect('admin/New_orders');
		}else{
			$this->session->set_flashdata("error"," Something is Wrong");
			redirect('admin/New_orders');
		}
	}

	

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

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