 <?php
// error_reporting(E_ALL);
// ini_set('display_errors',1);
 require_once("../includes/initialize.php");
 


    $tag = $_GET['type'];
 
 if ($tag=='certificate_tranzact1'){
     $tag='certificate_tranzact';
 }

       $start_date=$_POST['start_date'];
       $end_date=$_POST['end_date'];
         $portal=$_POST['portal'];
        // $tag=$_GET['tag'];


 
     $portal= $_POST['portal'];
   
  if (($portal=='') OR ($portal=='2')){
   $start_date = $_POST['start_date'];
   $end_date = $_POST['end_date'];
  

        $allsession = ONLINEPAY::find_omoluabi_cert_name("certificate_tranzact", $start_date, $end_date);
    
  }else{
      
  }
    

      header("Content-Type: text/csv");
      header("Content-Disposition: attachment; filename=$portal".".csv");
      header("Cache-Control: no-cache, no-store, must-revalidate");
      header("Pragma: no-cache");
      header("Expires: 0");
      ob_end_clean();
      $output = fopen("php://output", "w");
     
     fputcsv($output, array("","","","","CERTIFICATE PAYMENT LIST","","","",""));
 
  
     fputcsv($output, array("SN","MATRIC NO","PROGRAMME TYPE","TRANSACTION REF","FULL NAME","DEPARTMENT","LEVEL","AMOUNT","PAYMENT DATE"));
 
 
  $sn=0;$totalamount=0;
    foreach($allsession as $studentdata){
    
            $sn++;
            $formno = $studentdata->matricno;
            $transref=$studentdata->txt_ref;
            $surname=strtoupper($studentdata->fullname);
     
            $department=strtoupper($studentdata->department);
            $level=strtoupper($studentdata->level);
            $ptype=strtoupper($studentdata->ptype);
            $amount=$studentdata->amount;
             $totalamount+=$studentdata->amount;
            $datetime=$studentdata->datetime;
		    
		  
                          
		    
		 
 
        fputcsv($output,array($sn,$formno,$ptype,$transref,$surname,$department,$level,$amount,$datetime));
            
    
 }
 
         fputcsv($output,array('','','','','','','Total Amount',$totalamount,''));
     
     
//  echo json($output);
  fclose($output);
// }
?>