<?php

/**
 * This is a class file used for Project 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 WorkMgmt
{
    /**
     * @var public $designation_id This is the district Id feteched from the database(sms_designation).
     */
    public $work_id;
	
	/**
     * @var public $designation_nameeng This is the Distric Name in english feteched from the database(sms_designation).
     */
    public $work_details;
    
	/**
     * @var public $bullet This is the District name in gujarati.
     */
    public $bullet;
	
	/**
     * @var public $designation_count This is the Distict Count.
     */
    public $work_count;
	

	function WorkMgmt()
    {
        $this->bullet = "<font size='2'>&raquo;</font>";
        $this->bullet = htmlentities($this->bullet);
        $this->work_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->work_count=0;
		
        $qry = "SELECT * FROM lms_work where 1=1  and login_id =".$_SESSION['cUserId'];
		
		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->work_count=dbRows($out);
			return $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 lms_work where 1=1  ";
		
		if ($condition != "" ) {
            $qry.= $condition;
        }
		
	
        $out=dbQuery($qry);

        if (dbRows($out)>0) {
			$row=dbArray($out);
            extract($row);		
            $this->work_count=$Count;            
			dbFreeResult($out);
        }
		return $this->work_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 .= "work_details='"	.Escape($this->work_details)."',";
			$Qry1 .= "hours='"	.Escape($this->hours)."',";
				$Qry1 .= "login_id='"			 .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_work set " . $Qry1 . " ";
                dbQuery($qry);
                $this->work_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 .= "hours='"	.Escape($this->hours)."',";
		   $Qry1 .= "createdon='"			 .Escape(date('Y-m-d h:i:s'))."',";
			$Qry1 .= "work_details='"	.Escape($this->work_details)."',";
			$Qry1 .= "login_id='"			 .Escape($_SESSION['cUserId'])."',";		
				
            if ($Qry1 != "") {
                $Qry1 = substr($Qry1, 0, strlen($Qry1)-1);               
				$qry = "update lms_work set " . $Qry1 . " where  work_id=".$this->work_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 lms_work
             	where work_id in (".$this->work_id.")  ";
		dbQuery($qry);     
    }

}	
?>