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

class Studentbiodatamodel extends CI_Model {


function populatedocumets($id){

if($id!=null){
$this->db->select(" * from studentdocuments where studentid= '$id'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();

}else{

  return false;
}

}


}

function uploadimage($data,$img_id)
  
{
   
  if($img_id!=null){
   $this->db->insert('images', $data);
  if ($this->db->affected_rows() > 0) 
      {
  return true;

      }


   else

   {

     return false;

   }
      
     
      
  
  }
}


function getlostfoundbyid($id){

if($id!=null){
$this->db->select(" * from  report where id= '$id'");
$this -> db -> limit(1);
$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}

}


}










function getsuggestionbyid($id){

if($id!=null){
$this->db->select(" * from  suggestions where id= '$id'");
$this -> db -> limit(1);
$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}

}


}




function uploaddstudentocument($data)
{// Query to insert data in database
    //$regnumber = $data['regnumber'];
  
    $this->db->insert('studentdocuments', $data);
  if ($this->db->affected_rows() > 0) 
      {
  return true;

      }


   else

   {

     return false;

   }


}




function addsuggestion($data)
{// Query to insert data in database
    //$regnumber = $data['regnumber'];
  
    $this->db->insert('suggestions', $data);
  if ($this->db->affected_rows() > 0) 
      {
  return true;

      }


   else

   {

     return false;

   }


}





function getcatereportgorybyid($id){

if($id!=null){
$this->db->select(" * from  category where id= '$id'");
$this -> db -> limit(1);
$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}

}


}
function gettypegorybyid($id){

if($id!=null){
$this->db->select(" * from  types where id= '$id'");
$this -> db -> limit(1);
$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result_array();
   


}else{

  return false;
}

}


}
function populateuploadedimages($id){

if($id!=null){
$this->db->select("name from uploadedimages where 	img_id = '$id'");
$this -> db -> limit(1);
$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
  //return true;
}else{

  return false;
}

}

}

function populatelostfoundcategory(){



$bioquery = $this -> db -> get('category');
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}




}
function populatetypeofcategory(){



$bioquery = $this -> db -> get('types');
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}




}


function populatepassoutin(){



$bioquery = $this -> db -> get('gatepass');
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}




}

function addnewissue($data)
{
// Query to insert data in database
  //$regnumber = $data['regnumber'];
  
    $this->db->insert('report', $data);
  if ($this->db->affected_rows() > 0) 
      {
  return true;

      }


   else

   {

     return false;

   }


}

function populatereport(){



$bioquery = $this -> db -> get('report');
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}




}

function populateallsuggestion(){



$bioquery = $this -> db -> get('suggestions');
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}




}



function populatereportbyid($id){

if($id!=null){
$this->db->select("* from report where  userid = '$id'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
  //return true;
}else{

  return false;
}

}

}


function populatesuggestion($id){

if($id!=null){
$this->db->select("* from suggestions where userid = '$id'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
  //return true;
}else{

  return false;
}

}

}



function populatemypropert($id){

if($id!=null){
$this->db->select("* from report where status='store'	and userid = '$id'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
  //return true;
}else{

  return false;
}

}

}



function populateadverts(){


$this->db->select("* from announcement where type='advert'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
  //return true;
}else{

  return false;
}



}




function populateannouncement(){


$this->db->select("* from announcement where type='announcement'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
  //return true;
}else{

  return false;
}



}
function populatemypassout($id){

if($id!=null){
$this->db->select("* from gatepass where type='checkout'	and userid = '$id'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
  //return true;
}else{

  return false;
}

}

}

function addstudentbio($data,$id) 
{

   $this->db->where('id',$id);

   if ( $this->db->update('user',$data) ) 
   {
      return true;
   } else {
     
          return false;
   }
}











function updatestudentstatus($data,$studentid) 
{

   $this->db->where('studentid',$studentid);

   if ( $this->db->update('students',$data) ) 
   {
      return true;
   } else {
     
          return false;
   }
}


function add_profile($data,$id) 
{
   $this->db->where('id',$id);
   $q = $this->db->get('students');

   if ( $q->num_rows() > 0 ) 
   {
      $this->db->where('id',$id);
      $this->db->update('students',$data);
   } else {
     
      $this->db->insert('students',$data);
   }
   $this->db->trans_complete(); 
       if($this->db->trans_status() === TRUE)
	   {// Check Transaction Result successful                          
 
  
  return true;

      }


   else

   {

     return false;

   }
}



function add_registration($data,$regno) 
{
   $this->db->where('regno',$regno);
   $q = $this->db->get('registration');

   if ( $q->num_rows() > 0 ) 
   {
      $this->db->where('regno',$regno);
      $this->db->update('registration',$data);
   } else {
     
      $this->db->insert('registration',$data);
   }
   
   $this->db->trans_complete(); 
       if($this->db->trans_status() === TRUE)
	   {// Check Transaction Result successful                          
 
  
  return true;

      }


   else

   {

     return false;

   }
}



 function add_registrationbyid($data,$id)
    {
    $updatedat = Date('Y-m-d H:i:s') ;
	$this->db->where('id', $id);
	$this->db->set('updatedate', $updatedat);
	
  $this->db->update('registration', $data);
   if ($this->db->affected_rows() > 0) 
      {
  return true;

      }else{
        return false; 
      }
  }


















function populatebiodata($id){

if($id!=null){
$this->db->select(" * from  user where id= '$id'");
$this -> db -> limit(1);
$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result_array();
   


}else{

  return false;
}

}


}
function populatestudentsbyid($id){

if($id!=null){
$this->db->select(" * from  registration where studentid= '$id'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result();
   


}else{

  return false;
}

}


}

function populateallbiodata(){

if($id!=null){
$this->db->select(" * from  students");
$this -> db -> limit(1);
$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result_array();
   


}else{

  return false;
}

}


}

}

 ?>