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

class Dispute 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()   
	{
		$data["disputesData"] = $this->common->readdatafromcollectionwhereclause("Disputes");
		$this->template->template_render('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 editDispute($id){


		$data['id']=$id;
		
		$data["reminderdetails"] = $this->common->readdatadocument("Disputes",$id);
		
		 $this->template->template_render('editDispute', $data);


	}


	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'); 			
	}	
	
}
