/*var_dump(authLec($response,$queries['mst'],array($_POST['lec_id'])));
 	var_dump($response);*/
 $flag = false;
 if (!authMst($response, $queries['mst'], $_SESSION['faculty_id'])) {
     attd_error(HTTP_Status::FORBIDDEN);
 }
 if (!empty($_POST['c']) && !empty($_POST['stud_id']) && authStud($response, $queries['mst'], array($_POST['stud_id']))) {
     $ids = array();
     foreach ($_POST['c'] as $v) {
         $ids[] = $v['lec_id'];
     }
     if (authLec($response, $queries['mst'], $ids)) {
         $flag = true;
     }
 } else {
     if (!empty($_POST['lec_id']) && !empty($_POST['c']) && authLec($response, $queries['mst'], array($_POST['lec_id']))) {
         $ids = array();
         foreach ($_POST['c'] as $v) {
             $ids[] = $v['stud_id'];
         }
         if (authStud($response, $queries['mst'], $ids)) {
             $flag = true;
         }
     }
 }
 if (!empty($_POST['stud_id']) && $flag && updateByStudId($response, $_POST['stud_id'], $_POST['c']) || !empty($_POST['lec_id']) && $flag && updateByLecId($response, $_POST['lec_id'], $_POST['c'])) {
     $response = json_encode(array('done' => true, 'final' => 'Attendance Updated Successfully!'));
     header('Content-Length: ' . strlen($response));
     header('Content-Type: application/json');
     echo $response;
 } else {
     }
     if (authLec($response, $queries['mst'], $ids)) {
         $flag = true;
     }
 } else {
     if (!empty($_POST['lec_id']) && !empty($_POST['c']) && authLec($response, $queries['mst'], array($_POST['lec_id']))) {
         $ids = array();
         foreach ($_POST['c'] as $v) {
             $ids[] = $v['stud_id'];
         }
         if (authStud($response, $queries['mst'], $ids)) {
             $flag = true;
         }
     }
 }
 if (!empty($_POST['del']) && !empty($_POST['lec_id']) && authLec($response, $queries['mst'], array($_POST['lec_id'])) && deleteLecture($response, $_POST['lec_id'])) {
     $response = json_encode(array('done' => true, 'final' => 'Lecture deleted successfully!'));
     header('Content-Length: ' . strlen($response));
     header('Content-Type: application/json');
     echo $response;
 } else {
     if (!empty($_POST['stud_id']) && $flag && updateByStudId($response, $_POST['stud_id'], $_POST['c']) || !empty($_POST['lec_id']) && $flag && updateByLecId($response, $_POST['lec_id'], $_POST['c'])) {
         $response = json_encode(array('done' => true, 'final' => 'Attendance Updated Successfully!'));
         header('Content-Length: ' . strlen($response));
         header('Content-Type: application/json');
         echo $response;
     } else {
         $code = HTTP_Status::BAD_REQUEST;
         $err = HTTP_Status::BAD_REQUEST_MSG;
         if (isset($response)) {
             $code = $response['code'];