<?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 InquiryMgmt.
 *
 * @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 InquiryMgmt
{
    /**
     * @var public $inquiry_id This is the Employee Id feteched from the database(employee_master).
     */
    public $inquiry_id;
	
	/**
     * @var public $inquierorg_name This is the Employee name.
     */
	public $inquierorg_name;
	
	/**
     * @var public $employee_curaddress This is the Employee current address.
     */
	public $inquier_address;
	
	/**
     * @var public $inquier_phoneno This is the Employee phone.
     */
	public $inquier_phoneno;

	/**
     * @var public $inquier_mobileno This is the Employee mobile.
     */
	public $inquier_mobileno;

	/**
     * @var public $inquier_email This is the Employee email id.
     */
	 public $inquier_faxno;
	 
	public $inquier_email;
	
	public $inquier_url;

	/**
     * @var public $district_id This is the Employee Basic salary.
     */
	public $district_id;
	
	
	/**
     * @var public $contactperson This is the Employee Basic salary.
     */
	public $contactperson;
	
	
	/**
     * @var public $comment This is the Employee Basic salary.
     */
	public $comment;
	
	
	/**
     * @var public $product_ids This is the Employee Basic salary.
     */
	public $product_ids;
	/**
     * @var public $appointmentdate This is the Employee birthdate.
     */
	public $appointmentdate;

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

	/**
     * @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.
     */
	public $createdon;
	
	/**
     * Constructor to inialize inquiry_count to zero
     *
     */
    function InquiryMgmt()
    {
        $this->bullet = "<font size='2'>&raquo;</font>";
        $this->bullet = htmlentities($this->bullet);
        $this->inquiry_count=0;
    }

    /**
     * This function is used to get a particular record.
     *
     * @param integer $inquiry_id This is the database inquiry_id.
     *
     * @return array
     */
    /*function getRecordById($inquiry_id,$company_id)
    {
        $qry = "select * from employee_master where 1=1 ";

        if ($inquiry_id!="") {
            $qry.=" and inquiry_id=$inquiry_id ";
        }
		if ($company_id!="") {
            $condition=" and company_id=$company_id ";
        }
		$qry.=$condition;

        $out=dbQuery($qry);

		if(dbRows($out)>0) {
            $this->inquiry_count=1;

            $row=dbArray($out);
            extract($row);

			$this->inquiry_id			= ($inquiry_id);
			$this->company_id			= ($company_id);
			$this->inquierorg_name		= ($inquierorg_name);
			$this->designation_id		= ($designation_id);
			$this->appointmentdate	= ($appointmentdate);
			$this->appointmenttime	= ($appointmenttime);
			$this->district_id		= ($district_id);
			$this->inquier_address		= ($inquier_address);
			$this->inquier_mobileno		= ($inquier_mobileno);
			$this->inquier_phoneno		= ($inquier_phoneno);
			$this->inquier_email		= ($inquier_email);

			dbFreeResult($out);
        }
    }*/
		
	/**
     * This is a function for getting the total no of 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 Total Records Found
     */
    /*function getCountRecords($limit=0,$start=0,$condition="",$order_field="",$order_type="")
    {
		$this->inquiry_count=0;
		
       	$qry = "SELECT COUNT(*) AS Count
				FROM employee_master em 
				WHERE em.company_id   = '".$_SESSION["cCompany_id"]."' ";
		
		if ($condition != "" ) {
            $qry.= $condition;
        }
		
        $out=dbQuery($qry);

        if (dbRows($out)>0) {
			$row=dbArray($out);
            extract($row);		
            $this->inquiry_count=$Count;            
			dbFreeResult($out);	
        }
		return $this->inquiry_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 * from
				lms_inquiry			  
			  	WHERE company_id   = '".$_SESSION["cCompany_id"]."' "; 
					   					   				
		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 ;		
    }
		
		
		
	

    /**
     * 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 .= "inquierorg_name='"	  .Escape($this->inquierorg_name)."',";
		$Qry1 .= "inquier_address='" .replaceHtmlEditor(Escape($this->inquier_address))."',";	
		$Qry1 .= "inquier_phoneno='"	  .Escape($this->inquier_phoneno)."',";	
		$Qry1 .= "inquier_mobileno='"  .Escape($this->inquier_mobileno)."',";	
		$Qry1 .= "inquier_faxno='"  .Escape($this->inquier_faxno)."',";	
		$Qry1 .= "inquier_email='"	  .Escape($this->inquier_email)."',";
		$Qry1 .= "inquier_url='"	  .Escape($this->inquier_url)."',";
		$Qry1 .= "district_id='"  .Escape($this->district_id)."',";
		$Qry1 .= "contactperson='"  .Escape($this->contactperson)."',";
		$Qry1 .= "appointmentdate=    STR_TO_DATE('".Escape($this->appointmentdate)."','$SQLDateFormat'),";			
		$Qry1 .= "appointmenttime='"	  .Escape($this->appointmenttime)."',";
		$Qry1 .= "comment='"	 .replaceHtmlEditor(Escape($this->comment))."',";
		$Qry1 .= "product_ids='"	  .Escape($this->product_ids)."',";
		$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_inquiry set ". $Qry1 ." ";
			//echo $qry;		
			dbQuery($qry);
			$this->inquiry_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 .= "inquierorg_name='"	  .Escape($this->inquierorg_name)."',";
		$Qry1 .= "inquier_address='" .replaceHtmlEditor(Escape($this->inquier_address))."',";	
		$Qry1 .= "inquier_phoneno='"	  .Escape($this->inquier_phoneno)."',";	
		$Qry1 .= "inquier_mobileno='"  .Escape($this->inquier_mobileno)."',";	
		$Qry1 .= "inquier_faxno='"  .Escape($this->inquier_faxno)."',";	
		$Qry1 .= "inquier_email='"	  .Escape($this->inquier_email)."',";
		$Qry1 .= "inquier_url='"	  .Escape($this->inquier_url)."',";
		$Qry1 .= "district_id='"  .Escape($this->district_id)."',";
		$Qry1 .= "contactperson='"  .Escape($this->contactperson)."',";
		$Qry1 .= "appointmentdate= STR_TO_DATE('".Escape($this->appointmentdate)."','$SQLDateFormat'),";			
		$Qry1 .= "appointmenttime='"	  .Escape($this->appointmenttime)."',";
		$Qry1 .= "comment='"	  .Escape($this->comment)."',";
		$Qry1 .= "product_ids='"	  .Escape($this->product_ids)."',";
		$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_inquiry set " . $Qry1 . " where inquiry_id=".$this->inquiry_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_inquiry 
             	where inquiry_id in (".$this->inquiry_id.") 
				and company_id='".$_SESSION["cCompany_id"]."'";
        dbQuery($qry);
   	}
	
	
}
?>