<?php
/**
 * This is a class file used for Employee operations.
 *
 * PHP version 5
 *
 * @category Admin_Tool
 * @package  Admin_Tool
 * @author   Aum Infosys <admin@auminfosys.com>
 * @license  Aum Infosys
 * @version  CVS:1.0.1
 * @link     http://auminfosys.com/
 * @filesource
 */

/**
 * This is a class named SupportInquiryMgmt.
 *
 * @category Employee Management System
 * @package  Employee Management System
 * @author   Aum Infosys <admin@auminfosys.com>
 * @license  Aum Infosys
 * @version  Release: 1.0.1
 * @link     http://auminfosys.com/
 *
 */

class SupportInquiryMgmt
{
    /**
     * @var public $supportinquiry_id This is the Employee Id feteched from the database(employee_master).
     */
    public $supportinquiry_id;
	
	/**
     * @var public $customer_id This is the Employee Basic salary.
     */
	public $customer_id;

	public $supportinquiry_problem;
	/**
     * @var public $supportinquiry_date This is the Employee birthdate.
     */
	public $supportinquiry_date;

	/**
     * @var public $employee_schooljoindate This is the Employee school join date.
     */
	public $supportinquiry_time;

	/**
     * @var public $company_id This is the school id.
     */
	public $company_id;
	
	/**
     * @var public $login_id This is the Employee login id.
     */
	public $createdby;
	
	/**
     * @var public $createdon This is the Employee createdon.
     */
	 
    function SupportInquiryMgmt()
    {
        $this->bullet = "<font size='2'>&raquo;</font>";
        $this->bullet = htmlentities($this->bullet);
        $this->inquiry_count=0;
    }

/**
     * This is a function for getting the all records with/without condition
     *
     * @param integer $limit This is the limit of number or records.
     * @param integer $start This is the starting location of records.
     * @param string  $condition This is the condition for fetching records.	 
     * @param string  $order_field This is the field for fetching records orderby.	 
     * @param string  $order_type This is the order direction to fetch records orderby.	 	 
     *
     * @return Mix Result Set
     */
   function getCountRecords($limit=0,$start=0,$condition="",$order_field="",$order_type="")
    {
	  $this->employee_count=0;
		
	  $qry = "SELECT 	
	  			Count(*) AS Count	  
			  FROM 
			  lms_supportinquiry ls Left Join lms_customer c 
			  ON ls.customer_id=c.customer_id 		  
			  WHERE    							
				1=1 "; 
		
		if ($condition != "" ) {
            $qry.= $condition;
        }
		
		 $out=dbQuery($qry);

        if (dbRows($out)>0) {
			$row=dbArray($out);
            extract($row);		
            $this->employee_count=$Count;            
			dbFreeResult($out);	
        }
		return $this->employee_count;	
    }	

    
	/**
     * This is a function for getting the all records with/without condition
     *
     * @param integer $limit This is the limit of number or records.
     * @param integer $start This is the starting location of records.
     * @param string  $condition This is the condition for fetching records.	 
     * @param string  $order_field This is the field for fetching records orderby.	 
     * @param string  $order_type This is the order direction to fetch records orderby.	 	 
     *
     * @return Mix Result Set
     */
    function getAllRecords($limit=0,$start=0,$condition="",$order_field="",$order_type="")
    {
		$this->inquiry_count=0;
		
		$qry = "SELECT ls.*,c.customer_orgname 
				FROM 
				lms_supportinquiry ls Left Join lms_customer c 
				ON ls.customer_id=c.customer_id 
				WHERE 1=1 ";
		
		
					   					   				
		if ($condition != "" ) {
            $qry.= $condition;
        }
		
		if ($order_field !="" && $order_type !="") {
            $qry.= " order by $order_field $order_type";
        }

        if (intval($limit) > 0 && intval($start) >=0) {
            $qry.= " Limit $start , $limit";
        }
		
		//print $qry;
		$out=dbQuery($qry);
		
        if (dbRows($out)>0) {
            $this->inquiry_count=dbRows($out);
			return $out;							
        }
		return $out;		
    }
		
		
		
	

    /**
     * This is a function for adding new record for Employee.
     *
     * @return void The redirect file name and the message are passed.
     *
     */
    function add()
    {
		global $SQLDateFormat;
		
		$Qry1 = "";
		$Qry1 .= "customer_id='"	  .Escape($this->customer_id)."',";
		$Qry1 .= "supportinquiry_date=    STR_TO_DATE('".Escape($this->supportinquiry_date)."','$SQLDateFormat'),";			
		$Qry1 .= "supportinquiry_time='"	  .Escape($this->supportinquiry_time)."',";
		$Qry1 .= "supportinquiry_problem='"	 .replaceHtmlEditor(Escape($this->supportinquiry_problem))."',";
		$Qry1 .= "company_id='"	  .Escape($_SESSION['cCompany_id'])."',";		
		$Qry1 .= "createdby='"	      .Escape($_SESSION['cUserId'])."',";			
		$Qry1 .= "createdon='"	      .Escape(date('Y-m-d h:i:s'))."',";
					
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1)-1);
			$qry = "insert into lms_supportinquiry set ". $Qry1 ." ";
			//echo $qry;		
			dbQuery($qry);
			$this->supportinquiry_id=dbInsertedId();
		}
	}

    /**
     * This is a function for editing a Employee record.
     *
     * @return void The redirect file name and the message are passed.
     *
     */
    function edit()
    {
			global $SQLDateFormat;
			
			$Qry1 = "";
			$Qry1 .= "customer_id='"	  .Escape($this->customer_id)."',";
			$Qry1 .= "supportinquiry_date=    STR_TO_DATE('".Escape($this->supportinquiry_date)."','$SQLDateFormat'),";			
			$Qry1 .= "supportinquiry_time='"	  .Escape($this->supportinquiry_time)."',";
			$Qry1 .= "supportinquiry_problem='"	 .replaceHtmlEditor(Escape($this->supportinquiry_problem))."',";
			$Qry1 .= "company_id='"	  .Escape($_SESSION['cCompany_id'])."',";		
			$Qry1 .= "createdby='"	      .Escape($_SESSION['cUserId'])."',";			
			$Qry1 .= "createdon='"	      .Escape(date('Y-m-d h:i:s'))."',";
				
            if ($Qry1 != "") {
                $Qry1 = substr($Qry1, 0, strlen($Qry1)-1);
                $qry = "update lms_supportinquiry set " . $Qry1 . " where supportinquiry_id=".$this->supportinquiry_id. " and company_id = '".$_SESSION['cCompany_id']."' ";
                dbQuery($qry);
            }
	}
	
	/**
     * This is a function for deleting the Employee record.
     *
     * @return void The redirect file name and the message are passed.
     *
     */
    function delete()
    {		
		$qry = "delete from  lms_supportinquiry 
             	where supportinquiry_id in (".$this->supportinquiry_id.") 
				and company_id='".$_SESSION["cCompany_id"]."'";
        dbQuery($qry);
   	}
	
	
}
?>