public function search($keyword, $page = 1) { $toReturn = array(); if ($this->data['users']->role == "admin") { $toReturn['payments'] = \DB::table('payments')->leftJoin('users', 'users.id', '=', 'payments.paymentStudent')->select('payments.id as id', 'payments.paymentTitle as paymentTitle', 'payments.paymentDescription as paymentDescription', 'payments.paymentAmount as paymentAmount', 'payments.paymentStatus as paymentStatus', 'payments.paymentDate as paymentDate', 'payments.paymentStudent as studentId', 'users.fullName as fullName')->where('payments.paymentTitle', 'LIKE', '%' . $keyword . '%')->orWhere('payments.paymentDescription', 'LIKE', '%' . $keyword . '%')->orWhere('fullName', 'LIKE', '%' . $keyword . '%')->orderBy('id', 'DESC')->take('20')->skip(20 * ($page - 1))->get(); $toReturn['totalItems'] = \DB::table('payments')->leftJoin('users', 'users.id', '=', 'payments.paymentStudent')->select('payments.id as id', 'payments.paymentTitle as paymentTitle', 'payments.paymentDescription as paymentDescription', 'payments.paymentAmount as paymentAmount', 'payments.paymentStatus as paymentStatus', 'payments.paymentDate as paymentDate', 'payments.paymentStudent as studentId', 'users.fullName as fullName')->where('payments.paymentTitle', 'LIKE', '%' . $keyword . '%')->orWhere('payments.paymentDescription', 'LIKE', '%' . $keyword . '%')->orWhere('fullName', 'LIKE', '%' . $keyword . '%')->count(); } elseif ($this->data['users']->role == "student") { $toReturn['payments'] = \DB::table('payments')->where('paymentStudent', $this->data['users']->id)->leftJoin('users', 'users.id', '=', 'payments.paymentStudent')->select('payments.id as id', 'payments.paymentTitle as paymentTitle', 'payments.paymentDescription as paymentDescription', 'payments.paymentAmount as paymentAmount', 'payments.paymentStatus as paymentStatus', 'payments.paymentDate as paymentDate', 'payments.paymentStudent as studentId', 'users.fullName as fullName')->where('payments.paymentTitle', 'LIKE', '%' . $keyword . '%')->orWhere('payments.paymentDescription', 'LIKE', '%' . $keyword . '%')->orWhere('users.fullName', 'LIKE', '%' . $keyword . '%')->orderBy('id', 'DESC')->take('20')->skip(20 * ($page - 1))->get(); $toReturn['totalItems'] = \DB::table('payments')->where('paymentStudent', $this->data['users']->id)->leftJoin('users', 'users.id', '=', 'payments.paymentStudent')->select('payments.id as id', 'payments.paymentTitle as paymentTitle', 'payments.paymentDescription as paymentDescription', 'payments.paymentAmount as paymentAmount', 'payments.paymentStatus as paymentStatus', 'payments.paymentDate as paymentDate', 'payments.paymentStudent as studentId', 'users.fullName as fullName')->where('payments.paymentTitle', 'LIKE', '%' . $keyword . '%')->orWhere('payments.paymentDescription', 'LIKE', '%' . $keyword . '%')->orWhere('users.fullName', 'LIKE', '%' . $keyword . '%')->count(); } elseif ($this->data['users']->role == "parent") { $studentId = array(); $parentOf = json_decode($this->data['users']->parentOf, true); if (is_array($parentOf)) { while (list($key, $value) = each($parentOf)) { $studentId[] = $value['id']; } } $toReturn['payments'] = \DB::table('payments')->whereIn('paymentStudent', $studentId)->leftJoin('users', 'users.id', '=', 'payments.paymentStudent')->select('payments.id as id', 'payments.paymentTitle as paymentTitle', 'payments.paymentDescription as paymentDescription', 'payments.paymentAmount as paymentAmount', 'payments.paymentStatus as paymentStatus', 'payments.paymentDate as paymentDate', 'payments.paymentStudent as studentId', 'users.fullName as fullName')->where('payments.paymentTitle', 'LIKE', '%' . $keyword . '%')->orWhere('payments.paymentDescription', 'LIKE', '%' . $keyword . '%')->orWhere('users.fullName', 'LIKE', '%' . $keyword . '%')->orderBy('id', 'DESC')->take('20')->skip(20 * ($page - 1))->get(); $toReturn['totalItems'] = \DB::table('payments')->whereIn('paymentStudent', $studentId)->leftJoin('users', 'users.id', '=', 'payments.paymentStudent')->select('payments.id as id', 'payments.paymentTitle as paymentTitle', 'payments.paymentDescription as paymentDescription', 'payments.paymentAmount as paymentAmount', 'payments.paymentStatus as paymentStatus', 'payments.paymentDate as paymentDate', 'payments.paymentStudent as studentId', 'users.fullName as fullName')->where('payments.paymentTitle', 'LIKE', '%' . $keyword . '%')->orWhere('payments.paymentDescription', 'LIKE', '%' . $keyword . '%')->orWhere('users.fullName', 'LIKE', '%' . $keyword . '%')->count(); } $classes = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get(); $toReturn['classes'] = array(); foreach ($classes as $class) { $toReturn['classes'][$class->id] = $class->className; } $toReturn['students'] = User::where('role', 'student')->where('activated', '1')->get()->toArray(); return $toReturn; }
public function listAll() { $toReturn['exams'] = examsList::where('examAcYear', $this->panelInit->selectAcYear)->get()->toArray(); if ($this->data['users']->role == "teacher") { $toReturn['classes'] = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->where('classTeacher', 'LIKE', '%"' . $this->data['users']->id . '"%')->get()->toArray(); } else { $toReturn['classes'] = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get()->toArray(); } $toReturn['userRole'] = $this->data['users']->role; $newrole = $this->data['users']->newrole; $newrole_array = json_decode($newrole); $params = permissions::where('moduleId', 1)->where('permission', 1)->get(); $uniparam = array(5, 6, 7, 8, 15); if ($toReturn['userRole'] == "teacher") { if (array_intersect($newrole_array, $uniparam)) { $toReturn['access'] = 1; } else { $toReturn['access'] = 0; } } elseif ($toReturn['userRole'] == "admin") { $toReturn['access'] = 1; } else { $toReturn['access'] = 0; } $toReturn['newuserRole'] = $this->data['users']->newrole; return $toReturn; }
public function preAttendaceStats() { $toReturn = array(); $classes = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get(); $toReturn['classes'] = array(); $subjList = array(); foreach ($classes as $class) { $class['classSubjects'] = json_decode($class['classSubjects'], true); if (is_array($class['classSubjects'])) { foreach ($class['classSubjects'] as $subject) { $subjList[] = $subject; } } $toReturn['classes'][$class->id] = $class->className; } $subjList = array_unique($subjList); if ($this->data['panelInit']->settingsArray['attendanceModel'] == "subject") { $toReturn['subjects'] = array(); if (count($subjList) > 0) { $subjects = subject::whereIN('id', $subjList)->get(); foreach ($subjects as $subject) { $toReturn['subjects'][$subject->id] = $subject->subjectTitle; } } } $toReturn['role'] = $this->data['users']->role; $toReturn['attendanceModel'] = $this->data['panelInit']->settingsArray['attendanceModel']; return $toReturn; }
function fetch($id) { $classDetail = classes::where('id', $id)->first()->toArray(); $classDetail['classTeacher'] = json_decode($classDetail['classTeacher']); $classDetail['classSubjects'] = json_decode($classDetail['classSubjects']); return $classDetail; }
public function listAll() { $toReturn = array(); $toReturn['classes'] = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get()->toArray(); $toReturn['subject'] = subject::get()->toArray(); $toReturn['days'] = $arrayOfDays = array(0 => $this->panelInit->language['Sunday'], 1 => $this->panelInit->language['Monday'], 2 => $this->panelInit->language['Tuesday'], 3 => $this->panelInit->language['Wednesday'], 4 => $this->panelInit->language['Thurusday'], 5 => $this->panelInit->language['Friday'], 6 => $this->panelInit->language['Saturday']); $toReturn['userRole'] = $this->data['users']->role; return $toReturn; }
public function listAll() { $toReturn = array(); $toReturn['classes'] = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get()->toArray(); $classesArray = array(); while (list(, $class) = each($toReturn['classes'])) { $classesArray[$class['id']] = array("classTitle" => $class['className'], "subjects" => json_decode($class['classSubjects'])); } if ($this->data['users']->role == "teacher") { $subjects = subject::where('teacherId', $this->data['users']->id)->get()->toArray(); } else { $subjects = subject::get()->toArray(); } $subjectArray = array(); while (list(, $subject) = each($subjects)) { $subjectArray[$subject['id']] = $subject['subjectTitle']; } $toReturn['onlineExams'] = array(); $onlineExams = new onlineExams(); if ($this->data['users']->role == "teacher") { $onlineExams = $onlineExams->where('examTeacher', $this->data['users']->id); } if ($this->data['users']->role == "student") { $onlineExams = $onlineExams->where('examClass', 'LIKE', '%"' . $this->data['users']->studentClass . '"%'); } $onlineExams = $onlineExams->where('exAcYear', $this->panelInit->selectAcYear); $onlineExams = $onlineExams->get(); foreach ($onlineExams as $key => $onlineExam) { $classId = json_decode($onlineExam->examClass); if ($this->data['users']->role == "student" and !in_array($this->data['users']->studentClass, $classId)) { continue; } $toReturn['onlineExams'][$key]['id'] = $onlineExam->id; $toReturn['onlineExams'][$key]['examTitle'] = $onlineExam->examTitle; $toReturn['onlineExams'][$key]['examDescription'] = $onlineExam->examDescription; if (isset($subjectArray[$onlineExam->examSubject])) { $toReturn['onlineExams'][$key]['examSubject'] = $subjectArray[$onlineExam->examSubject]; } $toReturn['onlineExams'][$key]['ExamEndDate'] = date("F j, Y", $onlineExam->ExamEndDate); $toReturn['onlineExams'][$key]['ExamShowGrade'] = $onlineExam->ExamShowGrade; $toReturn['onlineExams'][$key]['classes'] = ""; while (list(, $value) = each($classId)) { if (isset($classesArray[$value])) { $toReturn['onlineExams'][$key]['classes'] .= $classesArray[$value]['classTitle'] . ", "; } } } $toReturn['userRole'] = $this->data['users']->role; return $toReturn; }
public function listAll() { $toReturn = array(); $toReturn['classes'] = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get()->toArray(); $classesArray = array(); while (list(, $class) = each($toReturn['classes'])) { $classesArray[$class['id']] = $class['className']; } $toReturn['subject'] = subject::get()->toArray(); $subjectArray = array(); while (list(, $subject) = each($toReturn['subject'])) { $subjectArray[$subject['id']] = $subject['subjectTitle']; } $toReturn['materials'] = array(); $studyMaterial = new studyMaterial(); if ($this->data['users']->role == "student") { $studyMaterial = $studyMaterial->where('class_id', 'LIKE', '%"' . $this->data['users']->studentClass . '"%'); } if ($this->data['users']->role == "teacher") { $studyMaterial = $studyMaterial->where('teacher_id', $this->data['users']->id); } $studyMaterial = $studyMaterial->get(); foreach ($studyMaterial as $key => $material) { $classId = json_decode($material->class_id); if ($this->data['users']->role == "student" and !in_array($this->data['users']->studentClass, $classId)) { continue; } $toReturn['materials'][$key]['id'] = $material->id; $toReturn['materials'][$key]['subjectId'] = $material->subject_id; $toReturn['materials'][$key]['subject'] = $subjectArray[$material->subject_id]; $toReturn['materials'][$key]['material_title'] = $material->material_title; $toReturn['materials'][$key]['material_description'] = $material->material_description; $toReturn['materials'][$key]['material_file'] = $material->material_file; $toReturn['materials'][$key]['classes'] = ""; if (is_array($classId)) { while (list(, $value) = each($classId)) { if (isset($classesArray[$value])) { $toReturn['materials'][$key]['classes'] .= $classesArray[$value] . ", "; } } } } $toReturn['userRole'] = $this->data['users']->role; return $toReturn; exit; }
function profile($id) { $data = User::where('role', 'student')->where('id', $id)->first()->toArray(); $data['birthday'] = date('m/d/Y', $data['birthday']); if ($data['studentClass'] != "" and $data['studentClass'] != "0") { $class = classes::where('id', $data['studentClass'])->first(); } $return = array(); $return['title'] = $data['fullName'] . " " . $this->panelInit->language['Profile']; $return['content'] = "<div class='text-center'>"; if ($data['photo'] == "") { $return['content'] .= "<img src='uploads/profile/user.png'/>"; } else { $return['content'] .= "<img width='200' src='uploads/profile/" . $data['photo'] . "'/><br/>" . "<h3>" . $data['fullName'] . "</h3>"; } $return['content'] .= "</div>"; $return['content'] .= "<h4>" . $this->panelInit->language['studentInfo'] . "</h4>"; $return['content'] .= "<table class='table table-bordered'><tbody>\n <tr>\n <td>" . $this->panelInit->language['FullName'] . "</td>\n <td>" . $data['fullName'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['rollid'] . "</td>\n <td>" . $data['studentRollId'] . "</td>\n </tr>"; if (isset($class)) { $return['content'] .= "<tr>\n\t <td>" . $this->panelInit->language['class'] . "</td>\n\t <td>" . $class->className . "</td>\n\t </tr>"; } $return['content'] .= "<tr>\n <td>" . $this->panelInit->language['username'] . "</td>\n <td>" . $data['username'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['email'] . "</td>\n <td>" . $data['email'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['Birthday'] . "</td>\n <td>" . $data['birthday'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['Gender'] . "</td>\n <td>" . $data['gender'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['Address'] . "</td>\n <td>" . $data['address'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['phoneNo'] . "</td>\n <td>" . $data['phoneNo'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['mobileNo'] . "</td>\n <td>" . $data['mobileNo'] . "</td>\n </tr>\n\n </tbody></table>"; return $return; }
public function getStats($date = "") { if ($date == "") { $date = date('m/Y'); } $date = explode("/", $date); $toReturn = array(); $classes = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get(); $toReturn['classes'] = array(); $subjList = array(); foreach ($classes as $class) { $class['classSubjects'] = json_decode($class['classSubjects'], true); if (is_array($class['classSubjects'])) { foreach ($class['classSubjects'] as $subject) { $subjList[] = $subject; } } $toReturn['classes'][$class->id] = $class->className; } $subjList = array_unique($subjList); if ($this->data['panelInit']->settingsArray['attendanceModel'] == "subject") { $toReturn['subjects'] = array(); if (count($subjList) > 0) { $subjects = subject::whereIN('id', $subjList)->get(); foreach ($subjects as $subject) { $toReturn['subjects'][$subject->id] = $subject->subjectTitle; } } } $toReturn['role'] = $this->data['users']->role; $toReturn['attendanceModel'] = $this->data['panelInit']->settingsArray['attendanceModel']; if ($this->data['users']->role == "admin" || $this->data['users']->role == "teacher") { $attendanceArray = attendance::where('date', 'like', $date[0] . "%")->where('date', 'like', "%" . $date[1])->orderBy('date')->get(); foreach ($attendanceArray as $value) { $dateHere = str_replace("/" . $date[1], "", $value->date); $dateHere = str_replace($date[0] . "/", "", $dateHere); $dateHere = preg_replace('/^0/', "", $dateHere); if (!isset($toReturn['attendance'][$dateHere][0])) { $toReturn['attendance'][$dateHere][0] = 0; $toReturn['attendance'][$dateHere][1] = 0; $toReturn['attendance'][$dateHere][2] = 0; $toReturn['attendance'][$dateHere][3] = 0; $toReturn['attendance'][$dateHere][4] = 0; } $toReturn['attendance'][$dateHere][$value->status]++; } $attendanceArrayToday = attendance::where('date', date('m/d/Y'))->get(); if ($this->data['panelInit']->settingsArray['attendanceModel'] == "subject") { foreach ($attendanceArrayToday as $value) { if (isset($toReturn['subjects'][$value->subjectId])) { if (!isset($toReturn['attendanceDay'][$toReturn['subjects'][$value->subjectId]])) { $toReturn['attendanceDay'][$toReturn['subjects'][$value->subjectId]] = 0; } $toReturn['attendanceDay'][$toReturn['subjects'][$value->subjectId]]++; } } } else { foreach ($attendanceArrayToday as $value) { if (isset($toReturn['classes'][$value->classId])) { if (!isset($toReturn['attendanceDay'][$toReturn['classes'][$value->classId]])) { $toReturn['attendanceDay'][$toReturn['classes'][$value->classId]] = 0; } $toReturn['attendanceDay'][$toReturn['classes'][$value->classId]]++; } } } } elseif ($this->data['users']->role == "student") { $attendanceArray = attendance::where('studentId', $this->data['users']->id)->where('date', 'like', $date[0] . "%")->where('date', 'like', "%" . $date[1])->get(); foreach ($attendanceArray as $value) { $toReturn['studentAttendance'][] = array("date" => $value->date, "status" => $value->status, "subject" => isset($toReturn['subjects'][$value->subjectId]) ? $toReturn['subjects'][$value->subjectId] : ""); } } elseif ($this->data['users']->role == "parent") { if ($this->data['users']->parentOf != "") { $parentOf = json_decode($this->data['users']->parentOf, true); $ids = array(); while (list(, $value) = each($parentOf)) { $ids[] = $value['id']; } $studentArray = User::where('role', 'student')->whereIn('id', $ids)->get(); foreach ($studentArray as $stOne) { $students[$stOne->id] = array('name' => $stOne->fullName, 'studentRollId' => $stOne->studentRollId); } if (count($ids) > 0) { $attendanceArray = attendance::whereIn('studentId', $ids)->where('date', 'like', $date[0] . "%")->where('date', 'like', "%" . $date[1])->get(); foreach ($attendanceArray as $value) { if (!isset($toReturn['studentAttendance'][$value->studentId])) { $toReturn['studentAttendance'][$value->studentId]['n'] = $students[$value->studentId]; $toReturn['studentAttendance'][$value->studentId]['d'] = array(); } $toReturn['studentAttendance'][$value->studentId]['d'][] = array("date" => $value->date, "status" => $value->status, "subject" => $value->subjectId); } } } } return $toReturn; }
public function proceed() { if (Input::get('nextStep') == "1") { if (filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) { if (!Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => 1, 'role' => 'admin'))) { $loginError = false; $this->data['loginError'] = "loginError"; } } else { if (!Auth::attempt(array('username' => Input::get('email'), 'password' => Input::get('password'), 'activated' => 1, 'role' => 'admin'))) { $loginError = false; $this->data['loginError'] = "loginError"; } } if (!isset($loginError)) { file_put_contents('app/storage/meta/lc', Input::get('cpc')); if ($this->sbApi() == "err") { @unlink('app/storage/meta/lc'); $this->data['installErrors'][] = "Purchase code is missing"; $loginError = false; $this->data['loginError'] = "loginError"; } } $this->data['currStep'] = "welcome"; if (!isset($loginError)) { $this->data['currStep'] = "1"; $this->data['nextStep'] = "2"; $testData = uniqid(); @file_put_contents("uploads/assignments/test", $testData); @file_put_contents("uploads/books/test", $testData); @file_put_contents("uploads/cache/test", $testData); @file_put_contents("uploads/media/test", $testData); @file_put_contents("uploads/profile/test", $testData); @file_put_contents("uploads/studyMaterial/test", $testData); @file_put_contents("uploads/assignmentsAnswers/test", $testData); @file_put_contents("app/storage/cache/test", $testData); @file_put_contents("app/storage/logs/test", $testData); @file_put_contents("app/storage/meta/test", $testData); @file_put_contents("app/storage/sessions/test", $testData); @file_put_contents("app/storage/views/test", $testData); if (@file_get_contents("uploads/assignments/test") != $testData) { $this->data['perrors'][] = "uploads/assignments"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "uploads/assignments"; } if (@file_get_contents("uploads/books/test") != $testData) { $this->data['perrors'][] = "uploads/books"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "uploads/books"; } if (@file_get_contents("uploads/cache/test") != $testData) { $this->data['perrors'][] = "uploads/cache"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "uploads/cache"; } if (@file_get_contents("uploads/media/test") != $testData) { $this->data['perrors'][] = "uploads/media"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "uploads/media"; } if (@file_get_contents("uploads/profile/test") != $testData) { $this->data['perrors'][] = "uploads/profile"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "uploads/profile"; } if (@file_get_contents("uploads/studyMaterial/test") != $testData) { $this->data['perrors'][] = "uploads/studyMaterial"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "uploads/studyMaterial"; } if (@file_get_contents("uploads/assignmentsAnswers/test") != $testData) { $this->data['perrors'][] = "uploads/assignmentsAnswers"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "uploads/assignmentsAnswers"; } if (@file_get_contents("app/storage/cache/test") != $testData) { $this->data['perrors'][] = "app/storage/cache"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "app/storage/cache"; } if (@file_get_contents("app/storage/logs/test") != $testData) { $this->data['perrors'][] = "app/storage/logs"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "app/storage/logs"; } if (@file_get_contents("app/storage/meta/test") != $testData) { $this->data['perrors'][] = "app/storage/meta"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "app/storage/meta"; } if (@file_get_contents("app/storage/sessions/test") != $testData) { $this->data['perrors'][] = "app/storage/sessions"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "app/storage/sessions"; } if (@file_get_contents("app/storage/views/test") != $testData) { $this->data['perrors'][] = "app/storage/views"; $this->data['nextStep'] = "1"; } else { $this->data['success'][] = "app/storage/views"; } } } if (Input::get('nextStep') == "2") { $this->data['currStep'] = "2"; $this->data['nextStep'] = "3"; $testInstalled = settings::where('fieldName', 'thisVersion')->first(); if ($testInstalled->fieldValue == "1.2" || $testInstalled->fieldValue == "1.3") { //Upgrade from first version to 1.4 DB::unprepared(file_get_contents('app/storage/dbsqlUp14')); $settings = settings::where('fieldName', 'thisVersion')->first(); $settings->fieldValue = '1.4'; $settings->save(); $testInstalled->fieldValue = "1.4"; } if ($testInstalled->fieldValue == "1.4") { //Upgrade from first version to 1.4 DB::unprepared(file_get_contents('app/storage/dbsqlUp20')); //Classes and relation with subjects $classes = classes::get(); foreach ($classes as $class) { $classesUpdateArray = array(); $subjects = subject::where('classId', $class->id)->get(); foreach ($subjects as $subject) { $classesUpdateArray[] = $subject->id; } $classesUpdateArray = json_encode($classesUpdateArray); classes::where('id', $class->id)->update(array('classSubjects' => $classesUpdateArray)); unset($classesUpdateArray); } //create academic years $users = User::where('role', 'student')->get(); foreach ($users as $user) { $studentAcademicYears = new studentAcademicYears(); $studentAcademicYears->studentId = $user->id; $studentAcademicYears->academicYearId = 1; $studentAcademicYears->classId = $user->studentClass; $studentAcademicYears->save(); } DB::unprepared('ALTER TABLE `subject` CHANGE `teacherId` `teacherId` int(250) NOT NULL after `subjectTitle` ,DROP COLUMN `classId` ;'); $settings = settings::where('fieldName', 'thisVersion')->first(); $settings->fieldValue = '2.0'; $settings->save(); } } if (Input::get('nextStep') == "3") { $this->data['currStep'] = "3"; $settings = settings::where('fieldName', 'thisVersion')->first(); $settings->fieldValue = '1.4'; $settings->save(); } return View::make('upgrade', $this->data); }
public function subjectList($classes = "") { $subjectList = array(); $classesCount = 1; if ($classes == "") { $classes = Input::get('classes'); if (!Input::has('classes')) { return $subjectList; } } if (is_array($classes)) { $classes = classes::whereIn('id', $classes)->get()->toArray(); $classesCount = count($classes); } else { $classes = classes::where('id', $classes)->get()->toArray(); } while (list(, $value) = each($classes)) { $value['classSubjects'] = json_decode($value['classSubjects'], true); if (is_array($value['classSubjects'])) { while (list(, $value2) = each($value['classSubjects'])) { $subjectList[] = $value2; } } } if ($classesCount == 1) { $finalClasses = $subjectList; } else { $subjectList = array_count_values($subjectList); $finalClasses = array(); while (list($key, $value) = each($subjectList)) { if ($value == $classesCount) { $finalClasses[] = $key; } } } if (count($finalClasses) > 0) { return subject::whereIn('id', $finalClasses)->get()->toArray(); } return array(); }
public function listAll() { $toReturn = array(); $toReturn['classes'] = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get()->toArray(); $classesArray = array(); while (list(, $class) = each($toReturn['classes'])) { $classesArray[$class['id']] = $class['className']; } $toReturn['assignments'] = array(); if (count($classesArray) > 0) { $assignments = new assignments(); if ($this->data['users']->role == "student") { $assignments = $assignments->where('classId', 'LIKE', '%"' . $this->data['users']->studentClass . '"%'); } else { while (list($key, ) = each($classesArray)) { $assignments = $assignments->orWhere('classId', 'LIKE', '%"' . $key . '"%'); } } if ($this->data['users']->role == "teacher") { $assignments = $assignments->where('teacherId', $this->data['users']->id); } $assignments = $assignments->get(); foreach ($assignments as $key => $assignment) { $classId = json_decode($assignment->classId); if ($this->data['users']->role == "student" and !in_array($this->data['users']->studentClass, $classId)) { continue; } $toReturn['assignments'][$key]['id'] = $assignment->id; $toReturn['assignments'][$key]['subjectId'] = $assignment->subjectId; $toReturn['assignments'][$key]['AssignTitle'] = $assignment->AssignTitle; $toReturn['assignments'][$key]['AssignDescription'] = $assignment->AssignDescription; $toReturn['assignments'][$key]['AssignFile'] = $assignment->AssignFile; $toReturn['assignments'][$key]['AssignDeadLine'] = $assignment->AssignDeadLine; $toReturn['assignments'][$key]['classes'] = ""; while (list(, $value) = each($classId)) { if (isset($classesArray[$value])) { $toReturn['assignments'][$key]['classes'] .= $classesArray[$value] . ", "; } } } } $toReturn['userRole'] = $this->data['users']->role; $newrole = $this->data['users']->newrole; $newrole_array = json_decode($newrole); $params = permissions::where('moduleId', 1)->where('permission', 1)->get(); foreach ($params as $param) { $uniparam[] = $param->roleId; } if ($toReturn['userRole'] == "teacher") { if (array_intersect($newrole_array, $uniparam)) { $toReturn['access'] = 1; } else { $toReturn['access'] = 0; } } elseif ($toReturn['userRole'] == "admin") { $toReturn['access'] = 1; } else { $toReturn['access'] = 0; } $toReturn['newuserRole'] = $this->data['users']->newrole; return $toReturn; }
public function registerClasses() { return classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get(); }
function profile($id) { $data = User::where('role', 'student')->where('id', $id)->first()->toArray(); $data['birthday'] = date('m/d/Y', $data['birthday']); if ($data['studentClass'] != "" and $data['studentClass'] != "0") { $class = classes::where('id', $data['studentClass'])->first(); } $return = array(); $return['title'] = $data['fullName'] . " " . $this->panelInit->language['Profile']; $return['content'] = "<div class='text-center'>"; $return['content'] .= "<img alt='" . $data['fullName'] . "' class='user-image img-circle' style='width:70px; height:70px;' src='dashboard/profileImage/" . $data['id'] . "'>"; $return['content'] .= "</div>"; $return['content'] .= "<h4>" . $this->panelInit->language['studentInfo'] . "</h4>"; $return['content'] .= "<table class='table table-bordered'><tbody>\n <tr>\n <td>" . $this->panelInit->language['FullName'] . "</td>\n <td>" . $data['fullName'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['rollid'] . "</td>\n <td>" . $data['studentRollId'] . "</td>\n </tr>"; if (isset($class)) { $return['content'] .= "<tr>\n\t <td>" . $this->panelInit->language['class'] . "</td>\n\t <td>" . $class->className . "</td>\n\t </tr>"; } $return['content'] .= "<tr>\n <td>" . $this->panelInit->language['username'] . "</td>\n <td>" . $data['username'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['email'] . "</td>\n <td>" . $data['email'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['Birthday'] . "</td>\n <td>" . $data['birthday'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['Gender'] . "</td>\n <td>" . $data['gender'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['Address'] . "</td>\n <td>" . $data['address'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['phoneNo'] . "</td>\n <td>" . $data['phoneNo'] . "</td>\n </tr>\n <tr>\n <td>" . $this->panelInit->language['mobileNo'] . "</td>\n <td>" . $data['mobileNo'] . "</td>\n </tr>\n\n </tbody></table>"; return $return; }