<?php

/**
 * This is a class file used for allowances 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 allowancesMgmt.
 *
 * @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 allowancesMgmt
{
    /**
     * @var public $allowances_id This is the Payscale Id feteched from the database(cms_allowances).
     */

    public $allowances_id;

    /**
     * @var public $allowances_name This is the Current payscale feteched from the database(cms_allowances).
     */

    public $allowances_name;

    /**
     * @var public $allowances_name This is the allowances_percentage feteched from the database(cms_allowances).
     */

    public $allowances_percentage;

    /**
     * @var public $allowances_value This is the grade pay.
     */

    public $allowances_value;


    public $allowances_count;



    function allowancesMgmt()
    {
        $this->bullet = "<font size='2'>&raquo;</font>";
        $this->bullet = htmlentities($this->bullet);
        $this->allowances_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->school_count = 0;

        $qry = "SELECT * FROM cms_allowances 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->allowances_count = dbRows($out);
            return $out;
        }
        return $out;
    }

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

        $Qry1 .= "allowances_name='" . Escape($this->allowances_name) . "',";
        $Qry1 .= "allowances_percentage='" . Escape($this->allowances_percentage) . "',";
        $Qry1 .= "allowances_value='" . Escape($this->allowances_value) . "',";
        $Qry1 .= "blnBackup = '0',";

        if ($Qry1 != "") {
            $Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
            $qry = "insert into cms_allowances set " . $Qry1 . " ";
            dbQuery($qry);
            $this->allowances_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 .= "allowances_id='" . Escape($this->allowances_id) . "',";
        $Qry1 .= "allowances_name='" . Escape($this->allowances_name) . "',";
        $Qry1 .= "allowances_percentage='" . Escape($this->allowances_percentage) . "',";
        $Qry1 .= "allowances_value='" . Escape($this->allowances_value) . "',";
        $Qry1 .= "blnBackup = '0',";

        if ($Qry1 != "") {
            $Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
            $qry = "update cms_allowances set " . $Qry1 . " where allowances_id=" . $this->allowances_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_allowances
             	where allowances_id in (" . $this->deleteallowances_Id . ") ";
        dbQuery($qry);
    }
}
?>