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

class Risk_Model extends CI_Model {
	public function insert(){
		$data=array("name"=>$_POST['name'],
					"address"=>$_POST['address'],
					"email"=>$_POST['emailid'],
					"contact"=>$_POST['contact'],
					"city"=>$_POST['city'],
					"Longitude"=>$_POST['longitude'],
					"Latitude"=>$_POST['latitude'],
					"Inserted_SI"=>$this->session->userdata('id'),
                   "Inserted_BY"=>$this->session->userdata('name'),
                   "Inserted_DT"=>date('Y-m-d H:i:s')
				);
		$this->db->insert('mst_office',$data);
	}
	
	public function low_risk_grid()
	{
	    return $this->db->select('*')->where('tpr.deleted_DT',NULL)->join('mst_guard msg','msg.id = tpr.patient_id')->where('tpr.risk_type',2)->get('tbl_patient_risk tpr')->result();
	    
	}

	public function fetch_data()
	{
	 $this->db->select('*'); 
  	 $this->db->from('mst_office');
  	 $this->db->where('deleted_DT',NULL);
  	 $this->db->order_by('id','DESC');
 	 $query = $this->db->get();
     return $query->result();
	}

	public function display_office_recordsById($id)
	{
		$query=$this->db->query("select * from mst_office where id='".$id."'");
		return $query->result();
	}

	public function update($id)
	{


/*	$n=$this->input->post('name');
		$a=$this->input->post('address');
		$e=$this->input->post('emailid');
		$c=$this->input->post('contact');
		$city=$this->input->post('city');
		$lo=$this->input->post('Longitude');
		$lt=$this->input->post('Latitude');	

	$query=$this->db->query("update mst_office SET name='$n',address='$a',email='$e',contact='$c',
		city='$city',Longitude='lo',Latitude='lt' where id='".$id."'");*/
			
			$data=array("name"=>$_POST['name'],
					   "address"=>$_POST['address'],
					   "email"=>$_POST['emailid'],
					   "contact"=>$_POST['contact'],
					   "city"=>$_POST['city'],
					   "Longitude"=>$_POST['longitude'],
					   "Latitude"=>$_POST['latitude'],
					   "Modify_SI"=>$this->session->userdata('id'),
                   	 "Modify_BY"=>$this->session->userdata('username'),
                    "Modify_DT"=>date('Y-m-d H:i:s'));
       				 $c=$this->db->where('id',$id)->update('mst_office',$data); 
       				 
       				 

	}

	
}
