<?php

/**
 * This is a class file used for Designation 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 SubjectMgmt.
 *
 * @category School Management System
 * @package  School Management System
 * @author   Aum Infosys <admin@auminfosys.com>
 * @license  Aum Infosys
 * @version  Release: 1.0.1
 * @link     http://auminfosys.com/
 *
 */



class DesignationMgmt
{
    /**
     * @var public $designation_id This is the district Id feteched from the database(cms_designation).
     */

    public $designation_id;



    /**
     * @var public $designation_nameeng This is the Distric Name in english feteched from the database(cms_designation).
     */

    public $designation_nameeng;

    /**
     * @var public $designation_nameguj This is the District name in gujarati.
     */
    public $designation_nameguj;

    /**
     * @var public $designation_count This is the Distict Count.
     */
    public $designation_count;

    /**
     * @var public $designation_type This is the login of the user.
     */
    public $designation_type;


    /**
     * @var public $designation_priority This is the Date and time when the distri created.
     */
    public $designation_priority;



    function DesignationMgmt()
    {
        $this->bullet = "<font size='2'>&raquo;</font>";
        $this->bullet = htmlentities($this->bullet);
        $this->designation_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 getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
    {
        $this->designation_count = 0;

        $qry = "SELECT * FROM cms_designation 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";
        }

        $out = dbQuery($qry);

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

        }
        return $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->user_count = 0;

        $qry = "SELECT Count(*) AS Count FROM cms_designation where 1=1 ";

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


        $out = dbQuery($qry);

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




    /**
     * This is a function for adding new record for District.
     *
     * @return void The redirect file name and the message are passed.
     *
     */
    function add()
    {
        $Qry1 = "";

        $Qry1 .= "designation_nameeng='" . Escape($this->designation_nameeng) . "',";
        //		$Qry1 .= "designation_nameguj='"	      .Escape($this->designation_nameguj)."',";
        $Qry1 .= " dept_type='" . Escape($this->designation_type) . "',";
        $Qry1 .= "designation_priority='" . Escape($this->designation_priority) . "',";
        //		$Qry1 .= "blnBackup = '0',";			

        if ($Qry1 != "") {
            $Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
            $qry = "insert into cms_designation set " . $Qry1 . " ";

            //      echo $qry; exit;
            dbQuery($qry);
            $this->designation_id = dbInsertedId();
        }
    }

    /**
     * This is a function for editing a Subject record.
     *
     * @return void The redirect file name and the message are passed.
     *
     */
    function edit()
    {
        $Qry1 = "";
        $Qry1 .= "designation_nameeng='" . Escape($this->designation_nameeng) . "',";
        //		$Qry1 .= "designation_nameguj='"	      .Escape($this->designation_nameguj)."',";
        $Qry1 .= " dept_type ='" . Escape($this->designation_type) . "',";
        $Qry1 .= "designation_priority='" . Escape($this->designation_priority) . "',";
        //	$Qry1 .= "blnBackup = '0',";		

        if ($Qry1 != "") {
            $Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
            $qry = "update cms_designation set " . $Qry1 . " where  designation_id=" . $this->designation_id;

            dbQuery($qry);
        }
    }
    /**
     * This is a function for deleting the subject record.
     *
     * @return void The redirect file name and the message are passed.
     *
     */
    function delete()
    {
        $qry = "delete from  cms_designation
             	where designation_id in (" . $this->deletedesignation_id . ")  ";
        dbQuery($qry);
    }

}
?>