<?php

//require 'dao/Global.php';
if(isset($_FILES['file']))
{
	print_r($_FILES);

//Globals
  $globals = $global->get_all_globals();
  $a_year_id = $globals[0]['a_year_id'];
  $semester_id = $globals[0]['semester_id'];
  $track_id = $globals[0]['track_id'];

echo $filename=$_FILES["file"]["tmp_name"];
$ext=substr($filename,strrpos($filename,"."),(strlen($filename)-strrpos($filename,".")));

//we check,file must be have csv extention
// if($ext=="csv")
// {
  $file = fopen($filename, "r");
         while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
         {
         	
          $sn = $emapData[0];
          $student_id = $emapData[1];
           $student_name = $emapData[2];
           $class = $emapData[3];
          $class_id = $_POST['cid'];
          $attitude = $emapData[4];
          $interest = $emapData[5];
          $conduct = $emapData[6];
          $attendance = $emapData[7];


        $data = array("student_id"=>$student_id,"class"=>$class_id,
                      "conduct"=>$conduct,"interest"=>$interest,
                      "attitude"=>$attitude,"attendance"=>$attendance,
                      "a_year_id"=>$a_year_id,"semester_id"=>$semester_id);
        print_r($data);
        
           $success =  $admission->attendance($data);
           if ($success) {
           	echo 0;
           }else{
           	echo 1;
           }
           
         }
         fclose($file);
         echo 3;
// }
// else {
//     echo "Error: Please Upload only CSV File";
// }


}

?>