$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 { $code = HTTP_Status::BAD_REQUEST; $err = HTTP_Status::BAD_REQUEST_MSG; if (isset($response)) { $code = $response['code']; $err = $response['message']; } attd_error($code, $err); } }
header('Content-Type: application/json'); echo $try; exit; } if ('GET' == $_SERVER['REQUEST_METHOD']) { if (!isset($_SESSION['login']) || $_SESSION['login'] !== true) { attd_error(HTTP_Status::UNAUTHORIZED); } else { if (!ctype_digit($_SESSION['faculty_id']) && !Privilege_Master::is_super($_SESSION['privilege_id']) || empty($_SERVER['HTTP_REFERER'])) { attd_error(HTTP_Status::FORBIDDEN); } } parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $queries); if (empty($queries['mst']) || !ctype_digit($queries['mst'])) { attd_error(HTTP_Status::BAD_REQUEST); } if (getMstMetaData($metadata, $queries['mst']) && (isset($_GET['step2']) && !empty($_GET['stud_id']) && getLectureWiseAttendanceOfStudByMst($response, $queries['mst'], $_GET['stud_id']) || isset($_GET['step2']) && !empty($_GET['lec_id']) && getStudentAttendanceByLec($response, $_GET['lec_id']) || !isset($_GET['lecwise']) && getStudentWiseAttendanceByMst($response, $queries['mst']) || getLectureWiseAttendanceByMst($response, $queries['mst']))) { if (isset($metadata) && !isset($_GET['step2'])) { $response['metadata'] = $metadata; } $response = json_encode($response); header('Content-Length: ' . strlen($response)); header('Content-Type: application/json'); echo $response; } else { if (!isset($response)) { $response = $metadata; } attd_error($response['code'], isset($response['message']) ? $response['message'] : ""); } }
$db->beginTransaction(); $obj = new Lectures(array('lec_date' => $lec_date, 'attd_mst_id' => $queries['mst'])); $db->insert($obj); $db->prepare(); $db->execute(); $lec_id = $db->getLastGeneratedValue(); $db->setInsert(new Attendance()); $abs_objs = array(); foreach ($students['data'] as $stud) { //$ids[]=$stud['stud_id']; $presence = 1; if (in_array($stud['stud_id'], $abs_ids)) { $presence = 0; } $abs_objs[] = new Attendance(array('lec_id' => $lec_id, 'stud_id' => $stud['stud_id'], 'presence' => $presence)); } $db->multiInsert($abs_objs); $db->execute(); $db->commit(); echo json_encode(array('done' => true, 'final' => 'Attendance Added Successfully!')); } catch (\Exception $e) { $db->rollback(); $message = $e->getPrevious() ? $e->getPrevious()->getMessage() : $e->getMessage(); $code = $e->getPrevious() ? $e->getPrevious()->getCode() : $e->getCode(); $err = "Error Code: " . $code . " <br/>Detailed Info: " . $message; attd_error(HTTP_Status::INTERNAL_SERVER_ERROR, $err); } } else { attd_error($students['code'], isset($students['message']) ? $students['message'] : ""); } }