<?php
include("../../db.php");
error_reporting(E_ALL);
header("Access-Control-Allow-Origin: * ");

$abc = $_POST['json'];

$idata = json_decode($abc, true);
// print_r($idata);

$id = $_REQUEST['id'];
$admin_id = $_REQUEST['admin_id'];
$status = $_REQUEST['leave_status'];
$update_value = $_REQUEST['update_value'];

$remarks = $_REQUEST['remarks'];
$date = date("Y-m-d");

$x = $idata;
foreach ($idata as $x) {

    $ids = $x['id'];
    $update_value = $x['update_value'];

    if ($update_value == '1') {
        $aryData = array(
            "admin_id" => $x['admin_id'],
            "remarks" => $x['remarks'],
        );
    } else {
        $aryData = array(
            "admin_id" => $x['admin_id'],
            "leave_status" => $x['leave_status']
        );

    }

    $insert_complain = $db->updateAry("teacher_leave", $aryData, "where id='$ids' ");

}

//$insert_complain=$db->insertAry("teacher_leave",$aryData);

if ($insert_complain > 0) {
    $msg = "leave remarks Added successfully.!";
}

if ($msg != "") {
    echo json_encode(array('status' => 1, 'msg' => 'Done', "data" => $msg));
} else {
    echo json_encode(array('status' => 0, 'msg' => 'Leave remarks not Added. Please try again later..!'));
}