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

class Rent extends CI_Controller {

	 function __construct()
     {
          parent::__construct();
         // $this->load->database();
          $this->load->model('reminder_model');
          $this->load->model('common');

          $this->load->helper(array('form', 'url','string'));
          $this->load->library('form_validation');
          $this->load->library('session');
     }

	public function index()
	{
		$data['reminderlist'] =$this->common->readdatafromcollectionwhereclause("Rent");
		// echo "<pre>";
		// print_r($data);
		// echo "</pre>";
		// exit;
		$this->template->template_render('rent_management',$data);
	}

function rentrequest(){
		$data['reminderlist'] =$this->common->readdatafromcollectionwhereclause("RentACar");
		// echo "<pre>";
		// print_r($data);
		// echo "</pre>";
		// exit;
		$this->template->template_render('rentrequest',$data);
}


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

		redirect('rent');
	}
	public function view_rentrequest($id){
		$data['id']=$id;
		
		$data["driverdetails"] = $this->common->readdatadocument("Rent",$id);
		


		 $this->template->template_render('viewrentreq', $data);

	}

//editReminder
	public function editrentrequest($id){


		$data['id']=$id;
		
		$data["driverdetails"] = $this->common->readdatadocument("Rent",$id);
		


		 $this->template->template_render('editrentreq', $data);


	}




	public function addrent()
	{


		$this->template->template_render('addrent');
	}
	public function insertrent()
	{
		$data=$this->input->post();
		
		$testxss = xssclean($_POST);
		if($testxss){		

 $uniqueentity=time()*1000;





			$response = $this->common->adddatamodel("Rent",$uniqueentity,$data);
			if($response) {
				$this->session->set_flashdata('successmessage', 'New reminder added successfully..');
			} else {
				$this->session->set_flashdata('warningmessage', validation_errors());
			}
			redirect('rent');
		} else {
			$this->session->set_flashdata('warningmessage', 'Error! Your input are not allowed.Please try again');
			redirect('reminder');
		}
	}
	public function deletereminder()
	{
		$r_id = $this->uri->segment(3);
		$returndata = $this->common->deletedatamodel('Rent',$r_id);
		if($returndata) {
			$this->session->set_flashdata('successmessage', 'Reminder deleted successfully..');
			redirect('rent');
		} else {
			$this->session->set_flashdata('warningmessage', 'Error..! Try again..');
		    redirect('rent');
		}
	}
//deleterrequestrent
	public function deleterrequestrent()
	{
		$r_id = $this->uri->segment(3);
		$returndata = $this->common->deletedatamodel('RentACar',$r_id);
		if($returndata) {
			$this->session->set_flashdata('successmessage', 'Reminder deleted successfully..');
			redirect('rent/rentrequest');
		} else {
			$this->session->set_flashdata('warningmessage', 'Error..! Try again..');
		    redirect('rent/rentrequest');
		}
	}
}
