<?php
//error_reporting(0);
require_once(LIB_PATH.DS.'database2.php');
class ONLINEPAY2 extends DatabaseObject2 {
	protected static $table_name="form_data24";
	public $id;
	public $dept;
	public $dept_id;
	public $txt_ref;

	public $txt_fee;
	public $status;
	public $responsecode;
	public $datetime;
	
	public $acc_id;
	public $formno;
	public $passport;
	public $title;
	public $phone;
	public $dob;
	public $sex;
	public $hometown;
	public $state;
	public $lga;
	public $nationality;
	public $religion;
	public $marital;
	
	public $surname;
	public $othernames;
	public $department;
	public $level;
	public $date;
	
	public $session;
	public $semester;
	public $ses_sem_id;
	public $amount;
	


//********************************GET ALL DEPARTMENT ****************************************************************

public static function showdept(){
    global $database2;
    
    $sql = "SELECT * from department";
    
   return $result_array = self::find_by_sql($sql);
}

//******************************** GET ALL PAYMENT FEES FOR EACH LEVEL***********************************************

public static function allfee($table,$amount){
global $database2;
   // $sql = "SELECT t.formno,s.*,p.status,p.amount,p.txt_ref,p.datetime FROM form_data t INNER JOIN student_account s ON t.acc_id = s.id INNER JOIN $table p ON p.acc_id=t.acc_id WHERE s.level='HND' AND p.responsecode = '00' AND p.amount='$amount' ORDER BY datetime " ;
$sql = "SELECT f.formno, s.surname, s.othernames, s.level,p.status, p.amount, p.txt_ref, p.datetime FROM ";
 $sql.= " $table p INNER JOIN student_account s ON p.acc_id = s.id ";
 $sql.=" INNER JOIN form_data f ON p.acc_id=f.acc_id ";
 $sql .=" WHERE s.level='ND' AND p.responsecode = '00' AND p.amount='$amount' ORDER BY datetime " ;

return self::find_by_sql($sql);

    
}

public static function showsession(){
global $database;
$sql = "SELECT  distinct (session) FROM session_semester" ;
return self::find_by_sql($sql);
}

public static function searchbyprog($level = "", $prog = ""){
    global $database;
    $sql = "SELECT f.formno,s.surname,s.othernames,s.level, s.department,s.date FROM student_account s INNER JOIN form_data24 f ON s.id=f.acc_id 
    WHERE f.formno LIKE '{$prog}%' AND s.level='{$level}' AND f.passport!='' ORDER BY s.department";
    return self::find_by_sql($sql);
}


public static function puallschoolfee($table, $level="", $session=""){
global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%PU%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;
}


public static function pushowallschoolfee($table, $level="", $session=""){
global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%PU%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;
}

public static function dpshowallschoolfee($table, $level="", $session=""){
global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%DP%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;
}

public static function dpallschoolfee($table, $level="", $session="",$form=""){
global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%DP%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;
}

public static function fthnd1showallschoolfee($table, $level="", $session=""){
 
 global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%FT%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;   
}


public static function dphnd1showallschoolfee($table, $level="", $session=""){
 
 global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%DP%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;   
}



public static function fthnd2showallschoolfee($table, $level="", $session=""){
 
 global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%FT%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;   
}


public static function dphnd2showallschoolfee($table, $level="", $session=""){
 
 global $database;
    $sql = "SELECT count(*) as allSchl FROM $table WHERE level='{$level}' and session = '{$session}' and responsecode = '00' and formno like '%DP%' ";
    
     $result_array = self::find_by_sql($sql);
return !empty($result_array)? array_shift($result_array):
false;   
}
// END OF GET


public static function searchbydate($table, $amount, $start_date,$end_date){
global $database;
//$start_date = date('yyyy-mm-dd', $start_date);
//$end_date = date('yyyy-mm-dd', $end_date);
$sql = "SELECT t.*,s.* FROM $table t INNER JOIN student_account s ON t.acc_id = s.id  WHERE t.responsecode = '00' AND t.amount='$amount' AND datetime BETWEEN date('{$start_date}') AND date('{$end_date}') ORDER BY datetime " ;
return self::find_by_sql($sql);
}

public static function searchbyprogramme($tab, $prog, $level){
   global $database; 
    $sql = "SELECT * FROM $tab WHERE formno LIKE '%$prog%' AND level='{$level}' AND responsecode = '00'";
    return self::find_by_sql($sql);
}
public static function searchbydatesessionlevel($table,$level, $session, $start_date,$end_date){
global $database;

$sql = "SELECT * FROM $table WHERE level='{$level}' AND session = '{$session}' AND responsecode = '00' AND datetime BETWEEN date('{$start_date}') AND date('{$end_date}') " ;
return self::find_by_sql($sql);
}



}
$onlinepay2 = new ONLINEPAY2();
?>