function active($id)
 {
     DB::table('academicYear')->update(array('isDefault' => 0));
     $academicYear = academicYear::find($id);
     $academicYear->isDefault = "1";
     $academicYear->save();
     return $this->panelInit->apiOutput(true, $this->panelInit->language['editAcademicYears'], $this->panelInit->language['acYearNowDef'], array("id" => $academicYear->id));
 }
Example #2
0
 public function proceed()
 {
     if (Input::get('nextStep') == "1") {
         $this->data['currStep'] = "1";
         $this->data['nextStep'] = "2";
         try {
             DB::connection()->getDatabaseName();
         } catch (Exception $e) {
             $this->data['dbError'] = $e->getMessage();
             $this->data['nextStep'] = "1";
         }
         $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";
     }
     if (Input::get('nextStep') == "3") {
         $this->data['currStep'] = "3";
         $this->data['nextStep'] = "4";
         if (Input::get('fullName') == "" || Input::get('username') == "" || Input::get('email') == "" || Input::get('password') == "" || Input::get('siteTitle') == "" || Input::get('systemEmail') == "") {
             $this->data['installErrors'][] = "Please fill in all required fields";
             $this->data['currStep'] = "2";
             $this->data['nextStep'] = "3";
         }
         if (Input::get('password') != Input::get('repassword')) {
             $this->data['installErrors'][] = "Password & repassword isn't identical";
             $this->data['currStep'] = "2";
             $this->data['nextStep'] = "3";
         }
         if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL) and Input::get('email') != "") {
             $this->data['installErrors'][] = "invalid e-mail address";
             $this->data['currStep'] = "2";
             $this->data['nextStep'] = "3";
         }
         if (Input::get('cpc') == "") {
             $this->data['installErrors'][] = "Purchase code is missing";
             $this->data['currStep'] = "2";
             $this->data['nextStep'] = "3";
         }
         if (Input::get('yearTitle') == "") {
             $this->data['installErrors'][] = "You must type default academic year";
             $this->data['currStep'] = "2";
             $this->data['nextStep'] = "3";
         }
         if (!isset($this->data['installErrors'])) {
             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";
                 $this->data['currStep'] = "2";
                 $this->data['nextStep'] = "3";
             }
         }
         if (!isset($this->data['installErrors'])) {
             $check = Schema::hasTable('users');
             if (!$check) {
                 DB::unprepared(file_get_contents('app/storage/dbsql'));
             }
             $User = new User();
             $User->username = Input::get('username');
             $User->email = Input::get('email');
             $User->fullName = Input::get('fullName');
             $User->password = Hash::make(Input::get('password'));
             $User->role = "admin";
             $User->save();
             $settings = settings::where('fieldName', 'siteTitle')->first();
             $settings->fieldValue = Input::get('siteTitle');
             $settings->save();
             $settings = settings::where('fieldName', 'systemEmail')->first();
             $settings->fieldValue = Input::get('systemEmail');
             $settings->save();
             $settings = new settings();
             $settings->fieldName = 'finishInstall';
             $settings->fieldValue = '1';
             $settings->save();
             $academicYear = new academicYear();
             $academicYear->yearTitle = Input::get('yearTitle');
             $academicYear->isDefault = "1";
             $academicYear->save();
         }
     }
     return View::make('install', $this->data);
 }
Example #3
0
 public function __construct()
 {
     $this->panelItems = array("dashboard" => array("title" => "dashboard", "icon" => "fa fa-dashboard", "url" => URL::to('#'), "permissions" => array('admin', 'teacher', 'student', 'parent')), "staticContent" => array("title" => "staticPages", "icon" => "fa fa-file-text", "activated" => "staticpagesAct", "url" => "", "permissions" => array('admin', 'teacher', 'student', 'parent'), "children" => array("controlStatic" => array("title" => "controlPages", "url" => URL::to('#static'), "icon" => "fa fa-cog", "permissions" => array('admin')))), "messages" => array("title" => "Messages", "url" => URL::to('#messages'), "icon" => "fa fa-envelope", "permissions" => array('admin', 'teacher', 'student', 'parent')), "calender" => array("title" => "Calender", "url" => URL::to('#calender'), "icon" => "fa fa-calendar", "permissions" => array('admin', 'teacher', 'student', 'parent')), "classSchedule" => array("title" => "classSch", "url" => URL::to('#classschedule'), "icon" => "fa fa-list", "permissions" => array('admin', 'teacher', 'student', 'parent')), "attendance" => array("title" => "Attendance", "url" => "", "icon" => "fa fa-bar-chart", "activated" => "attendanceAct", "permissions" => array('admin', 'teacher'), "children" => array("controlAttendance" => array("title" => "Attendance", "url" => URL::to('#attendance'), "icon" => "fa fa-check", "permissions" => array('admin', 'teacher')), "statsAttendance" => array("title" => "attendanceStats", "url" => URL::to('#attendanceStats'), "icon" => "fa fa-bar-chart", "permissions" => array('admin', 'teacher')))), "vacation" => array("title" => "Vacation", "url" => URL::to('#vacation'), "icon" => "fa fa-coffee", "activated" => "vacationAct", "permissions" => array('teacher', 'student')), "myAttendance" => array("title" => "Attendance", "url" => URL::to('#attendanceStats'), "icon" => "fa fa-bar-chart", "activated" => "attendanceAct", "permissions" => array('student', 'parent')), "staffAttendance" => array("title" => "staffAttendance", "url" => URL::to('#staffAttendance'), "icon" => "fa fa-check", "activated" => "staffAttendanceAct", "permissions" => array('admin')), "library" => array("title" => "Library", "url" => URL::to('#library'), "icon" => "fa fa-folder-open", "activated" => "bookslibraryAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "media" => array("title" => "mediaCenter", "url" => URL::to('#media'), "icon" => "fa fa-video-camera", "activated" => "mediaAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "teachers" => array("title" => "teachers", "url" => URL::to('#teachers'), "icon" => "fa fa-suitcase", "permissions" => array('admin')), "students" => array("title" => "students", "url" => URL::to('#students'), "icon" => "fa fa-users", "permissions" => array('admin', 'teacher', 'parent')), "parents" => array("title" => "parents", "url" => URL::to('#parents'), "icon" => "fa fa-user", "permissions" => array('admin')), "gradelevels" => array("title" => "gradeLevels", "url" => URL::to('#gradeLevels'), "icon" => "fa fa-check-square-o", "permissions" => array('admin')), "materials" => array("title" => "studyMaterial", "url" => URL::to('#materials'), "icon" => "fa fa-book", "activated" => "materialsAct", "permissions" => array('admin', 'teacher', 'student')), "assignments" => array("title" => "Assignments", "url" => URL::to('#assignments'), "icon" => "fa fa-file-pdf-o", "activated" => "assignmentsAct", "permissions" => array('admin', 'teacher', 'student')), "examslist" => array("title" => "examsList", "url" => URL::to('#examsList'), "icon" => "fa fa-graduation-cap", "permissions" => array('admin', 'teacher', 'student', 'parent')), "onlineexams" => array("title" => "onlineExams", "url" => URL::to('#onlineExams'), "icon" => "fa fa-graduation-cap", "activated" => "onlineexamsAct", "permissions" => array('admin', 'teacher', 'student')), "newsboard" => array("title" => "newsboard", "url" => URL::to('#newsboard'), "icon" => "fa fa-bullhorn", "activated" => "newsboardAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "events" => array("title" => "events", "url" => URL::to('#events'), "icon" => "fa fa-clock-o", "activated" => "eventsAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "controlPayments" => array("title" => "Payments", "url" => URL::to('#payments'), "icon" => "fa fa-money", "activated" => "paymentsAct", "permissions" => array('admin', 'student', 'parent')), "transportations" => array("title" => "Transportation", "url" => URL::to('#transports'), "icon" => "fa fa-bus", "activated" => "transportAct", "permissions" => array('admin', 'teacher', 'student', 'parent')), "classes" => array("title" => "classes", "url" => URL::to('#classes'), "icon" => "fa fa-sitemap", "permissions" => array('admin')), "subjects" => array("title" => "Subjects", "url" => URL::to('#subjects'), "icon" => "fa fa-book", "permissions" => array('admin')), "reports" => array("title" => "Reports", "url" => URL::to('#reports'), "icon" => "fa fa-pie-chart", "activated" => "reportsAct", "permissions" => array('admin')), "adminTasks" => array("title" => "adminTasks", "url" => "", "icon" => "fa fa-cog", "permissions" => array('admin'), "children" => array("permissions" => array("title" => "permissions", "url" => URL::to('#permissions'), "icon" => "fa fa-male", "permissions" => array('admin')), "academicyear" => array("title" => "academicyears", "url" => URL::to('#academicYear'), "icon" => "fa fa-calendar-check-o", "permissions" => array('admin')), "promotion" => array("title" => "Promotion", "url" => URL::to('#promotion'), "icon" => "fa fa-arrow-up", "permissions" => array('admin')), "mailsms" => array("title" => "mailsms", "url" => URL::to('#mailsms'), "icon" => "fa fa-send", "permissions" => array('admin')), "mailsmsTemplates" => array("title" => "mailsmsTemplates", "url" => URL::to('#mailsmsTemplates'), "icon" => "fa fa-envelope-o", "permissions" => array('admin')), "polls" => array("title" => "Polls", "url" => URL::to('#polls'), "icon" => "fa fa-tasks", "activated" => "pollsAct", "permissions" => array('admin')), "dormitories" => array("title" => "Dormitories", "url" => URL::to('#dormitories'), "icon" => "fa fa-building-o", "permissions" => array('admin')), "siteSettings" => array("title" => "generalSettings", "url" => URL::to('#settings'), "icon" => "fa fa-cog", "permissions" => array('admin')), "languages" => array("title" => "Languages", "url" => URL::to('#languages'), "icon" => "fa fa-font", "permissions" => array('admin')), "admins" => array("title" => "Administrators", "url" => URL::to('#admins'), "icon" => "fa fa-gears", "permissions" => array('admin')), "terms" => array("title" => "schoolTerms", "url" => URL::to('#terms'), "icon" => "fa fa-file-text-o", "permissions" => array('admin')))));
     $settings = settings::get();
     foreach ($settings as $setting) {
         $this->settingsArray[$setting->fieldName] = $setting->fieldValue;
     }
     if ($this->settingsArray['lastUpdateCheck'] + 86400 < time()) {
         $sb = $this->sbApi();
         if ($sb == "err") {
             exit;
         }
         $latestUpdate = @file_get_contents("http://cr-house.com/apps/schoex/latest");
         $latestUpdate = @json_decode($latestUpdate, true);
         $settings = settings::where('fieldName', 'lastUpdateCheck')->first();
         $settings->fieldValue = time();
         $settings->save();
         if (is_array($latestUpdate)) {
             $settings = settings::where('fieldName', 'latestVersion')->first();
             $settings->fieldValue = $latestUpdate['v'];
             $settings->save();
         }
     }
     $staticPages = staticPages::where('pageActive', '1')->get();
     foreach ($staticPages as $pages) {
         $this->panelItems['staticContent']['children'][md5(uniqid())] = array("title" => $pages->pageTitle, "url" => URL::to('#static') . "/" . $pages->id, "icon" => "fa fa-file-text", "permissions" => array('admin', 'teacher', 'student', 'parent'));
     }
     //Languages
     $defLang = $defLang_ = $this->settingsArray['languageDef'];
     if (isset($this->settingsArray['languageAllow']) and $this->settingsArray['languageAllow'] == "1" and !Auth::guest() and \Auth::user()->defLang != 0) {
         $defLang = \Auth::user()->defLang;
     }
     //Theme
     $this->defTheme = $this->settingsArray['layoutColor'];
     if (isset($this->settingsArray['layoutColorUserChange']) and $this->settingsArray['layoutColorUserChange'] == "1" and !Auth::guest() and \Auth::user()->defTheme != "") {
         $this->defTheme = \Auth::user()->defTheme;
     }
     $language = languages::whereIn('id', array($defLang, 1))->get();
     if (count($language) == 0) {
         $language = languages::whereIn('id', array($defLang_, 1))->get();
     }
     foreach ($language as $value) {
         if ($value->id == 1) {
             $this->language = json_decode($value->languagePhrases, true);
         } else {
             $this->isRTL = $value->isRTL;
             $phrases = json_decode($value->languagePhrases, true);
             while (list($key, $value) = each($phrases)) {
                 $this->language[$key] = $value;
             }
         }
     }
     //Selected academicYear
     if (Session::has('selectAcYear')) {
         $this->selectAcYear = Session::get('selectAcYear');
     } else {
         $currentAcademicYear = academicYear::where('isDefault', '1')->first();
         $this->selectAcYear = $currentAcademicYear->id;
         Session::put('selectAcYear', $this->selectAcYear);
     }
     $this->baseURL = Request::url('index.php');
     if (strpos($this->baseURL, 'index.php') == false) {
         $this->baseURL = URL::to('index.php');
     }
 }
 public function dashboardData()
 {
     $toReturn = array();
     $toReturn['selectedAcYear'] = $this->panelInit->selectAcYear;
     $toReturn['language'] = $this->panelInit->language;
     $toReturn['role'] = $this->data['users']->role;
     $toReturn['stats'] = array();
     $toReturn['stats']['classes'] = classes::count();
     $toReturn['stats']['students'] = User::where('role', 'student')->where('activated', 1)->count();
     $toReturn['stats']['teachers'] = User::where('role', 'teacher')->where('activated', 1)->count();
     $toReturn['stats']['newMessages'] = messagesList::where('userId', $this->data['users']->id)->where('messageStatus', 1)->count();
     $toReturn['messages'] = DB::select(DB::raw("SELECT messagesList.id as id,messagesList.lastMessageDate as lastMessageDate,messagesList.lastMessage as lastMessage,messagesList.messageStatus as messageStatus,users.fullName as fullName,users.id as userId FROM messagesList LEFT JOIN users ON users.id=IF(messagesList.userId = '" . $this->data['users']->id . "',messagesList.toId,messagesList.userId) where userId='" . $this->data['users']->id . "' order by id DESC limit 5"));
     $toReturn['attendanceModel'] = $this->data['panelInit']->settingsArray['attendanceModel'];
     if ($this->data['panelInit']->settingsArray['attendanceModel'] == "subject") {
         $subjects = subject::get();
         foreach ($subjects as $subject) {
             $toReturn['subjects'][$subject->id] = $subject->subjectTitle;
         }
     }
     $date = date('m/Y');
     $date = explode("/", $date);
     if ($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);
                 }
             }
         }
     }
     $toReturn['teacherLeaderBoard'] = User::where('role', 'teacher')->where('isLeaderBoard', '!=', '')->where('isLeaderBoard', '!=', '0')->get()->toArray();
     $toReturn['studentLeaderBoard'] = User::where('role', 'student')->where('isLeaderBoard', '!=', '')->where('isLeaderBoard', '!=', '0')->get()->toArray();
     $toReturn['newsEvents'] = array();
     $newsboard = newsboard::where('newsFor', $this->data['users']->role)->orWhere('newsFor', 'all')->orderBy('id', 'desc')->limit(5)->get();
     foreach ($newsboard as $event) {
         $eventsArray['id'] = $event->id;
         $eventsArray['title'] = $event->newsTitle;
         $eventsArray['type'] = "news";
         $eventsArray['start'] = date("F j, Y", strtotime($event->newsDate));
         $toReturn['newsEvents'][] = $eventsArray;
     }
     $events = events::orderBy('id', 'desc')->where('eventFor', $this->data['users']->role)->orWhere('eventFor', 'all')->limit(5)->get();
     foreach ($events as $event) {
         $eventsArray['id'] = $event->id;
         $eventsArray['title'] = $event->eventTitle;
         $eventsArray['type'] = "event";
         $eventsArray['start'] = date("F j, Y", strtotime($event->eventDate));
         $toReturn['newsEvents'][] = $eventsArray;
     }
     $toReturn['academicYear'] = academicYear::get()->toArray();
     $toReturn['baseUser'] = array("id" => $this->data['users']->id, "fullName" => $this->data['users']->fullName, "username" => $this->data['users']->username);
     $polls = polls::where('pollTarget', $this->data['users']->role)->orWhere('pollTarget', 'all')->where('pollStatus', '1')->first();
     if (count($polls) > 0) {
         $toReturn['polls']['title'] = $polls->pollTitle;
         $toReturn['polls']['id'] = $polls->id;
         $toReturn['polls']['view'] = "vote";
         $userVoted = json_decode($polls->userVoted, true);
         if (is_array($userVoted) and in_array($this->data['users']->id, $userVoted)) {
             $toReturn['polls']['voted'] = true;
             $toReturn['polls']['view'] = "results";
         }
         $toReturn['polls']['items'] = json_decode($polls->pollOptions, true);
         $toReturn['polls']['totalCount'] = 0;
         if (is_array($toReturn['polls']['items']) and count($toReturn['polls']['items']) > 0) {
             while (list($key, $value) = each($toReturn['polls']['items'])) {
                 if (isset($value['count'])) {
                     $toReturn['polls']['totalCount'] += $value['count'];
                 }
                 if (!isset($toReturn['polls']['items'][$key]['prec'])) {
                     $toReturn['polls']['items'][$key]['prec'] = 0;
                 }
             }
         }
     }
     return json_encode($toReturn);
 }
Example #5
0
 function fetch($id)
 {
     $data = User::where('role', 'student')->where('id', $id)->first()->toArray();
     $data['birthday'] = date('m/d/Y', $data['birthday']);
     $data['academicYear'] = array();
     $academicYear = academicYear::get();
     foreach ($academicYear as $value) {
         $data['academicYear'][$value->id] = $value->yearTitle;
     }
     $data['studentAcademicYears'] = array();
     $academicYear = studentAcademicYears::where('studentId', $id)->orderBy('id', 'ASC')->get();
     foreach ($academicYear as $value) {
         $data['studentAcademicYears'][] = array("id" => $value->academicYearId, "default" => $value->classId, "classes" => classes::where('classAcademicYear', $value->academicYearId)->get()->toArray());
     }
     return json_encode($data);
 }