<?php
include("../../db.php");

header("Access-Control-Allow-Origin: * ");


$abc = $_POST['json'];
$idata = json_decode($abc, true);


$class = $idata['class'];
$section = $idata['section'];
$session = $idata['session'];
$school_id = $idata['school_id'];
// $image_name=$idata['image_name'];
// $base = $idata['image'];
$image_name_list = $idata['image_list'];

foreach ($image_name_list as $img_str){

    $aryData = array("class" => $class, "section" => $section, "timetable_file" => $img_str,
                     "session" => $session, "school_id" => $school_id,);

    $flgUp = $db->insertAry("app_timetable", $aryData);
}


if (!is_null($flgUp)) {
    echo json_encode(array('status' => 1, 'msg' => ' Data Added Successfully..!'));
} else {
    echo json_encode(array('status' => 0, 'msg' => 'Data not added..!'));
}


/*
// Decode Image
  	 if($base!=null){
  	     
    	   $binary=base64_decode($base);}
  	  else{
   	 $binary=null;
   	     }
		 
    header('Content-Type: bitmap; charset=utf-8');
	$file_nm='../../uploads/notice/'.$image_name;
	

    // Images will be saved under 'uploads/notice' folder   
	$file = fopen($file_nm, 'wb');
	
    // Create File
	if($binary!=null){
    		$x=fwrite($file, $binary);
		}
	fclose($file);
	
	// upload file end



$aryData = array(
    "class" => $class,
    "section" => $section,
    "timetable_file" => $image_name,
    "session" => $session,
    "school_id" => $school_id,

);


$flgUp = $db->insertAry("app_timetable", $aryData);

if (!is_null($flgUp)) {
    echo json_encode(array('status' => 1, 'msg' => ' Data Added Successfully..!'));

} else {
    echo json_encode(array('status' => 0, 'msg' => 'Data not added..!'));
}


*/


?>