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

class Store extends CI_Controller {
    function __construct()
 	{
	    parent::__construct();
		$this->load->helper('url');
		$this->load->helper('form');
		$this->load->library('session');
		$this->load->model('common');
		$this->load->database();
		$this->load->library(array('form_validation','template'));
	}

	public function index()   
	{
		
		if($this->session->userdata('session_data') ==""){
			redirect(base_url().'login');
		}
		$id = $this->session->userdata('session_data')['userId'];
	if($id ==""){
		redirect(base_url().'login');
	}
	
		$data["disputesData"] = $this->common->readdatafromcollectionwhereclause("Restaurant","userId","=",$id);

		$this->load->view('dispute', $data); 
	}

//updatedisputedata
	public function updatedisputedata($id){

		$data["promotions"] = $this->common->updatedatamodel("Disputes",$id,$this->input->post());
		$this->session->set_flashdata('successmessage', 'Disputes has been updated successfully');

		redirect('dispute');
	}

	
	public function deletedispute($id)   
	{
		$this->common->deletedatamodel("Disputes", $id);
		$this->session->set_flashdata('successmessage', 'Disputes Deleted');
		redirect('dispute');
	}
	



public function resturentlogin($id){		
		$d= $this->common->readdatadocument("Restaurant",$id);
		$this->session->set_userdata('restid', $id);
		$this->session->set_userdata('restname', $d['name']);
		$this->session->set_userdata('reslist', true);
		redirect(base_url().'dashboard');

	}


	public function addDispute()   
	{
		$response = $this->common->adddatamodel("Disputes", $this->input->post('ticketNo'), $this->input->post());
 		if ($response) {
 			$this->session->set_flashdata('successmessage', 'Dispute Added Successfuly');
 		} else {
 			$this->session->set_flashdata('warningmessage', 'Error! Something went wrong');
 		}
		redirect('dispute'); 			
	}

	public function resolveDispute($id)   
	{
		$data["status"] = FALSE;
		$response = $this->common->updatedatamodel("Disputes", $id, $data);
 		if ($response) {
 			$this->session->set_flashdata('successmessage', 'Dispute Resolved Successfuly');
 		} else {
 			$this->session->set_flashdata('warningmessage', 'Error! Something went wrong');
 		}
		redirect('dispute'); 			
	}	
	
}
