<?php
  class CTEACHER{

    var $id;
    var $eName;
    var $pfx;
    var $cName;
    var $section;
    var $position;
    var $password;
    var $administrator;
    var $level;

	function __construct(){}

    function setTeacher($pfield,$pval){
	  global $conn;
	  global $CLIENTID;
		
      $query = "SELECT * FROM ".$CLIENTID."_attendace_staff WHERE $pfield='$pval'";
      $result = mysqli_query($conn,$query);
      $num = mysqli_num_rows($result);
	  
	  if($num>0){
	  while($myrow = mysqli_fetch_array($result)){
		  $this->id = $myrow["id"];
		  $this->eName = $myrow["eName"];
		  $this->pfx = $myrow["pfx"];
		  $this->cName = $myrow["cName"];
		  $this->section = $myrow["section"];
		  $this->position = $myrow["position"];
		  $this->password = $myrow["password"];
		  $this->administrator = $myrow["administrator"];
//		  $this->level=$this->getLevel($this->administrator);
	  }
	  }
    }

	  /*
    function getLevel($lvl){
	  global $conn;
      $query = "SELECT * FROM xoops_sps_level WHERE level='$lvl'";
      $result = mysqli_query($conn,$query);
	  while($myrow = mysqli_fetch_array($result)){
		  $level =  $myrow["level"];
		  if($level==""){
			$level = "0";
		  }
	  }
      return $level;
    }
	*/

	
	
	//----- start time of punchin ----------
	function getStartT($wk){
	
      global $conn;
	  global $CLIENTID;
        
	  $query = "SELECT * FROM ".$CLIENTID."_attendace_timetable WHERE secid='" . $this->section . "' AND wkDay=$wk";
	  $result = mysqli_query($conn,$query);
	  $num = mysqli_num_rows($result);
	  
	  if($num>0){
        while($myrow = mysqli_fetch_array($result)){
            $output = $myrow["pcInTime"];
        }
	    return $output;
	  }else{
	    return "";
	  }
	
	}
	
	//------- end time of punchin ---------
	function getEndT($wk){
	
      global $conn;
	  global $CLIENTID;
		
	  $query = "SELECT * FROM ".$CLIENTID."_attendace_timetable WHERE secid='" . $this->section . "' AND wkDay=$wk";
	  $result = mysqli_query($conn,$query);
	  $num = mysqli_num_rows($result);
	  
	  if($num>0){
          while($myrow = mysqli_fetch_array($result)){
              $output = $myrow["pcOutTime"];
          }
	    return $output;
	  }else{
	    return "";
	  }
	
	}

  }
?>
<?php
  function getTeaList(){
	  
    global $conn;
	global $CLIENTID;
	  
    $query = "SELECT * FROM ".$CLIENTID."_attendace_staff WHERE id NOT IN ('admin','pejabat') AND userID<>'1' ORDER BY ename";
    $result = mysqli_query($conn,$query);
    $num = mysqli_num_rows($result);
    $i=0;
    while($myrow = mysqli_fetch_array($result)){

      $tid = $myrow["id"];
      $tename = $myrow["eName"];
      $tcname = $myrow["cName"];
	  $tsection = $myrow["section"];

      $arrOutput[$tid]["ename"] = $tename;
      $arrOutput[$tid]["cname"] = $tcname;
	  $arrOutput[$tid]["section"] = $tsection;

      $i++;
    }

    return $arrOutput;
  }
?>
<?php
  function getTeaListOfDate($pdate){
	  
    global $conn;
	global $CLIENTID;
	  
    $query = "SELECT * FROM ".$CLIENTID."_attendace_punchrecord WHERE staffId NOT IN ('admin','pejabat') AND punchDate='$pdate'";
    $result = mysqli_query($conn,$query);
    $num = mysqli_num_rows($result);
    $i=0;
    while($myrow = mysqli_fetch_array($result)){

      $tid = $myrow["staffId"];
      $arrOutput[$i] = $tid;

      $i++;
    }

    return $arrOutput;
  }
?>