<?php
error_reporting(1);
set_time_limit(0);
session_start();
if(!$_SESSION['USER_NAME'])
{
	header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
	exit;
}
include '../Basic.php';

$time = time();
DisplayHeader(".:".ProgramTitle().":.");
$width = 'width=40%';
$tab='Students Payment';
PopTable('header',$tab,$width);
//echo get_school_id();echo "<br>";
//echo get_school_year();echo "<br>";
?>
<form  name="mass_stud_pay" action="action.php" method="post" enctype="multipart/form-data" id="mass_stud_pay">
	Choose Csv File
<input type="file" name="csvUpload" value="" id='file_type' accept=".csv">
</br></br>
 <input type="submit" value="Upload">
</form>
<div class="csv_result"></div>
<div class="btn btn-info reset_btn" style="text-align: end;"><button id='reset_form' class='btn btn-info pull-right '>Reset</button></div>
<script>
jQuery(document).ready(function(){
	var url =  window.location.href;
	var ais_pos =  url.indexOf("ais")
	var csvurl = url.substring(0, ais_pos);
	//alert(csvurl); return false;
	//alert(csvurl+'ais/modules/mod_users/userCSVUpload.php');return false;
	//alert('hhhh');
	jQuery("form[name='mass_stud_pay']").submit(function(e){
    	e.preventDefault();
    	//alert('helllo');
    	var formdata = new FormData(jQuery(this)[0]);
    	jQuery.ajax({
        	//url: 'https://arrupe.ac.zw/acis/ais/modules/mod_users/userCSVUpload.php',
        	url: csvurl+'ais/modules/mod_billing/bilcsvupload.php',
        	type: "POST",
        	data: formdata,
        	//dataType: 'JSON',
        	error: function(xhr, textStatus) {
           		console.log(textStatus);
        	},
        	success:function(data){
            	jQuery('.csv_result').html(data);
            
            },
            processData: false,
            contentType: false,
            cache: false,
        });
    });
		/*********** rest page *****************/
	document.getElementById("reset_form").addEventListener("click", function() {
    		document.getElementById("mass_stud_pay").reset();
         	jQuery(".csv_result").html('');
                		
	});

	/**************************************/
});
</script>
<?php
echo PopTable('footer');

?>