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

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);

$status = 0;
$msg = 'Unknown error';

$ct_id = $_POST['ct_id'];
$rem   = $_POST['remark'];
$admin_id = $_POST['admin_id'];
$dates = json_decode($_POST['date_list'],true);

foreach ($dates as $date) {

    $array = array("admin_id" => $admin_id, "leave_status" => $date['status'], "remarks" => $rem);

    $flgIn = $db->updateAry("teacher_leave", $array, "where date = '$date[date]' and content_id = '$ct_id' ");

}

if ($flgIn > 0) {
    $status = 1;
    $msg = 'Record updated successfully';
} else {
    $msg = "Unable to update info...! Please try again later";
}

echo json_encode(array("status" => $status, "msg" => "$msg", "fgg"=>$flgIn));