コード例 #1
0
 public function create()
 {
     $mailsms = new mailsms();
     if (Input::get('userType') == "users") {
         $mailsms->mailTo = json_encode(Input::get('selectedUsers'));
     } else {
         $mailsms->mailTo = Input::get('userType');
     }
     $mailsms->mailType = Input::get('sendForm');
     $messageData = " ";
     if (Input::get('messageTitle') != "") {
         $messageData .= Input::get('messageTitle');
     }
     if (Input::get('messageContent') != "") {
         $messageData .= htmlspecialchars(Input::get('messageContent'), ENT_QUOTES);
     }
     $mailsms->messageData = $messageData;
     $mailsms->messageDate = date("F j, Y, g:i a");
     $mailsms->messageSender = $this->data['users']->fullName . " [ " . $this->data['users']->id . " ] ";
     $mailsms->save();
     if (Input::get('userType') == "teachers") {
         $sedList = User::where('role', 'teacher')->get();
     }
     if (Input::get('userType') == "students") {
         if (!Input::get('classId') || Input::get('classId') == "" || Input::get('classId') == "0") {
             $sedList = User::where('role', 'student')->get();
         } else {
             $sedList = User::where('role', 'student')->where('studentClass', Input::get('classId'))->get();
         }
     }
     if (Input::get('userType') == "parents") {
         $sedList = User::where('role', 'parent')->get();
     }
     if (Input::get('userType') == "users") {
         $usersList = array();
         $selectedUsers = Input::get('selectedUsers');
         foreach ($selectedUsers as $user) {
             $usersList[] = $user['id'];
         }
         $sedList = User::whereIn('id', $usersList)->get();
     }
     $SmsHandler = new MailSmsHandler();
     if (Input::get('sendForm') == "email") {
         foreach ($sedList as $user) {
             $SmsHandler->mail($user->email, Input::get('messageTitle'), Input::get('messageContent'), $user->fullName);
         }
     }
     if (Input::get('sendForm') == "sms") {
         foreach ($sedList as $user) {
             if ($user->mobileNo != "") {
                 $SmsHandler->sms($user->mobileNo, strip_tags(Input::get('messageContent')));
             }
         }
     }
     return $this->listAll();
 }
コード例 #2
0
 function notifications($id)
 {
     if ($this->data['users']->role != "admin") {
         exit;
     }
     if ($this->panelInit->settingsArray['examDetailsNotif'] == "0") {
         return json_encode(array("jsTitle" => $this->panelInit->language['examDetailsNot'], "jsMessage" => $this->panelInit->language['adjustExamNot']));
     }
     $examsList = examsList::where('id', $id)->first();
     $subjectArray = array();
     $subject = subject::get();
     foreach ($subject as $value) {
         $subjectArray[$value->id] = $value->subjectTitle;
     }
     $usersArray = array();
     if ($this->data['panelInit']->settingsArray['examDetailsNotifTo'] == "parent" || $this->data['panelInit']->settingsArray['examDetailsNotifTo'] == "both") {
         $users = User::where('role', 'student')->orWhere('role', 'parent')->get();
     } else {
         $users = User::where('role', 'student')->get();
     }
     foreach ($users as $value) {
         if ($value->parentOf == "" and $value->role == "parent") {
             continue;
         }
         if (!isset($usersArray[$value->id])) {
             $usersArray[$value->id] = array();
         }
         if ($value->parentOf != "") {
             $value->parentOf = json_decode($value->parentOf);
             if (!is_array($value->parentOf)) {
                 continue;
             }
             if (count($value->parentOf) > 0) {
                 $usersArray[$value->id]['parents'] = array();
             }
             foreach ($value->parentOf as $parentOf) {
                 $usersArray[$parentOf->id]['parents'][$value->id] = array('username' => $value->username, "email" => $value->email, "fullName" => $value->fullName, "mobileNo" => $value->mobileNo);
             }
         }
         $usersArray[$value->id]['student'] = array('username' => $value->username, "studentRollId" => $value->studentRollId, "mobileNo" => $value->mobileNo, "email" => $value->email, "fullName" => $value->fullName);
     }
     $return['marks'] = array();
     $examMarks = examMarks::where('examId', $id)->get();
     foreach ($examMarks as $value) {
         if (!isset($return['marks'][$value->studentId])) {
             $return['marks'][$value->studentId] = array();
         }
         if (isset($subjectArray[$value->subjectId])) {
             $return['marks'][$value->studentId][$subjectArray[$value->subjectId]] = array("examMark" => $value->examMark, "attendanceMark" => $value->attendanceMark, "markComments" => $value->markComments);
         }
     }
     $mailTemplate = mailsmsTemplates::where('templateTitle', 'Exam Details')->first();
     if ($this->panelInit->settingsArray['examDetailsNotif'] == "mail" || $this->panelInit->settingsArray['examDetailsNotif'] == "mailsms") {
         $mail = true;
     }
     if ($this->panelInit->settingsArray['examDetailsNotif'] == "sms" || $this->panelInit->settingsArray['examDetailsNotif'] == "mailsms") {
         $sms = true;
     }
     $sms = true;
     $MailSmsHandler = new MailSmsHandler();
     while (list($key, $value) = each($return['marks'])) {
         if (isset($mail)) {
             $studentTemplate = $mailTemplate->templateMail;
             $examGradesTable = "";
             while (list($keyG, $valueG) = each($value)) {
                 if ($valueG['examMark'] == "" and $valueG['attendanceMark'] == "") {
                     continue;
                 }
                 $examGradesTable .= $keyG . " Grade : " . $valueG['examMark'] . " - Attendance : " . $valueG['attendanceMark'] . " - Comments : " . $valueG['markComments'] . "<br/>";
             }
             if ($examGradesTable == "") {
                 continue;
             }
             $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{examTitle}", "{examDescription}", "{examDate}", "{schoolTitle}", "{examGradesTable}");
             $replaceArray = array($usersArray[$key]['student']['fullName'], $usersArray[$key]['student']['studentRollId'], $usersArray[$key]['student']['email'], $usersArray[$key]['student']['username'], $examsList->examTitle, $examsList->examDescription, $examsList->examDate, $this->panelInit->settingsArray['siteTitle'], $examGradesTable);
             $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
             $MailSmsHandler->mail($usersArray[$key]['student']['email'], "Exam grade details", $studentTemplate, $usersArray[$key]['student']['fullName']);
             if (isset($usersArray[$key]['parents'])) {
                 while (list($keyP, $valueP) = each($usersArray[$key]['parents'])) {
                     //	$MailSmsHandler->mail($valueP['email'],"Exam grade details",$studentTemplate,$usersArray[$key]['student']['fullName']);
                 }
             }
         }
         if (isset($sms)) {
             $studentTemplate = $mailTemplate->templateSMS;
             $examGradesTable = "";
             reset($value);
             while (list($keyG, $valueG) = each($value)) {
                 if ($valueG['examMark'] == "" and $valueG['attendanceMark'] == "") {
                     continue;
                 }
                 $examGradesTable .= $keyG . " Grade : " . $valueG['examMark'] . " - Attendance : " . $valueG['attendanceMark'] . " ";
             }
             if ($examGradesTable == "") {
                 continue;
             }
             $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{examTitle}", "{examDescription}", "{examDate}", "{schoolTitle}", "{examGradesTable}");
             $replaceArray = array($usersArray[$key]['student']['fullName'], $usersArray[$key]['student']['studentRollId'], $usersArray[$key]['student']['email'], $usersArray[$key]['student']['username'], $examsList->examTitle, $examsList->examDescription, $examsList->examDate, $this->panelInit->settingsArray['siteTitle'], $examGradesTable);
             $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
             if ($usersArray[$key]['student']['mobileNo'] != "") {
                 $MailSmsHandler->sms($usersArray[$key]['student']['mobileNo'], $studentTemplate);
             }
             if (isset($usersArray[$key]['parents'])) {
                 reset($usersArray[$key]['parents']);
                 while (list($keyP, $valueP) = each($usersArray[$key]['parents'])) {
                     if (trim($valueP['mobileNo']) != "") {
                         $MailSmsHandler->sms($valueP['mobileNo'], $studentTemplate);
                     }
                 }
             }
         }
     }
     return $this->panelInit->apiOutput(true, $this->panelInit->language['examDetailsNot'], $this->panelInit->language['examNotSent']);
 }
コード例 #3
0
 public function saveAttendance()
 {
     if ($this->data['users']->role != "admin" and $this->data['users']->role != "teacher") {
         exit;
     }
     $attendanceList = array();
     if ($this->data['panelInit']->settingsArray['attendanceModel'] == "subject") {
         $attendanceArray = attendance::where('classId', Input::get('classId'))->where('subjectId', Input::get('subject'))->where('date', Input::get('attendanceDay'))->get();
     } else {
         $attendanceArray = attendance::where('classId', Input::get('classId'))->where('date', Input::get('attendanceDay'))->get();
     }
     foreach ($attendanceArray as $stAttendance) {
         $attendanceList[$stAttendance->studentId] = $stAttendance->status;
     }
     $vacationArray = array();
     $vacationList = vacation::where('vacDate', Input::get('attendanceDay'))->where('acYear', $this->panelInit->selectAcYear)->where('role', 'student')->get();
     foreach ($vacationList as $vacation) {
         $vacationArray[$vacation->userid] = $vacation->id;
     }
     if ($this->panelInit->settingsArray['absentNotif'] == "mail" || $this->panelInit->settingsArray['absentNotif'] == "mailsms") {
         $mail = true;
     }
     if ($this->panelInit->settingsArray['absentNotif'] == "sms" || $this->panelInit->settingsArray['absentNotif'] == "mailsms") {
         $sms = true;
     }
     if (isset($mail) || isset($sms)) {
         $mailTemplate = mailsmsTemplates::where('templateTitle', 'Student Absent')->first();
     }
     $stAttendance = Input::get('stAttendance');
     while (list($key, $value) = each($stAttendance)) {
         if (isset($vacationArray[$key])) {
             $vacationEdit = vacation::where('id', $vacationArray[$key])->first();
             $vacationEdit->acceptedVacation = $value['vacationStat'];
             $vacationEdit->save();
             if ($value['vacationStat'] == 1) {
                 $value['attendance'] = "9";
             }
         }
         if (isset($value['attendance']) and strlen($value['attendance']) > 0) {
             if (!isset($attendanceList[$key])) {
                 $attendanceN = new attendance();
                 $attendanceN->classId = Input::get('classId');
                 $attendanceN->date = Input::get('attendanceDay');
                 $attendanceN->studentId = $key;
                 $attendanceN->status = $value['attendance'];
                 if ($this->data['panelInit']->settingsArray['attendanceModel'] == "subject") {
                     $attendanceN->subjectId = Input::get('subject');
                 }
                 $attendanceN->save();
                 if ($value['attendance'] != "1" and $this->panelInit->settingsArray['absentNotif'] != "0") {
                     $parents = User::where('parentOf', 'like', '%"' . $key . '"%')->get();
                     $student = User::where('id', $key)->first();
                     $absentStatus = "";
                     switch ($value['attendance']) {
                         case '0':
                             $absentStatus = $this->panelInit->language['Absent'];
                             break;
                         case '2':
                             $absentStatus = $this->panelInit->language['Late'];
                             break;
                         case '3':
                             $absentStatus = $this->panelInit->language['LateExecuse'];
                             break;
                         case '4':
                             $absentStatus = $this->panelInit->language['earlyDismissal'];
                             break;
                         case '9':
                             $absentStatus = $this->panelInit->language['acceptedVacation'];
                             break;
                     }
                     $MailSmsHandler = new MailSmsHandler();
                     foreach ($parents as $parent) {
                         if (isset($mail)) {
                             $studentTemplate = $mailTemplate->templateMail;
                             $examGradesTable = "";
                             $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{parentName}", "{parentEmail}", "{absentDate}", "{absentStatus}", "{schoolTitle}");
                             $replaceArray = array($student->fullName, $student->studentRollId, $student->email, $student->username, $parent->fullName, $parent->email, Input::get('attendanceDay'), $absentStatus, $this->panelInit->settingsArray['siteTitle']);
                             $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
                             $MailSmsHandler->mail($parent->email, $this->panelInit->language['absentReport'], $studentTemplate);
                         }
                         if (isset($sms) and $parent->mobileNo != "") {
                             $studentTemplate = $mailTemplate->templateSMS;
                             $examGradesTable = "";
                             $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{parentName}", "{parentEmail}", "{absentDate}", "{absentStatus}", "{schoolTitle}");
                             $replaceArray = array($student->fullName, $student->studentRollId, $student->email, $student->username, $parent->fullName, $parent->email, Input::get('attendanceDay'), $absentStatus, $this->panelInit->settingsArray['siteTitle']);
                             $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
                             $MailSmsHandler->sms($parent->mobileNo, $studentTemplate);
                         }
                     }
                 }
             } else {
                 if ($attendanceList[$key] != $value['attendance']) {
                     $attendanceN = attendance::where('studentId', $key)->where('date', Input::get('attendanceDay'))->where('classId', Input::get('classId'))->first();
                     $attendanceN->status = $value['attendance'];
                     if ($this->data['panelInit']->settingsArray['attendanceModel'] == "subject") {
                         $attendanceN->subjectId = Input::get('subject');
                     }
                     $attendanceN->save();
                     if ($value['attendance'] != "1" and $this->panelInit->settingsArray['absentNotif'] != "0") {
                         $parents = User::where('parentOf', 'like', '%"' . $key . '"%')->get();
                         $student = User::where('id', $key)->first();
                         $absentStatus = "";
                         switch ($value['attendance']) {
                             case '0':
                                 $absentStatus = $this->panelInit->language['Absent'];
                                 break;
                             case '2':
                                 $absentStatus = $this->panelInit->language['Late'];
                                 break;
                             case '3':
                                 $absentStatus = $this->panelInit->language['LateExecuse'];
                                 break;
                             case '4':
                                 $absentStatus = $this->panelInit->language['earlyDismissal'];
                                 break;
                             case '9':
                                 $absentStatus = $this->panelInit->language['acceptedVacation'];
                                 break;
                         }
                         $MailSmsHandler = new MailSmsHandler();
                         foreach ($parents as $parent) {
                             if (isset($mail)) {
                                 $studentTemplate = $mailTemplate->templateMail;
                                 $examGradesTable = "";
                                 $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{parentName}", "{parentEmail}", "{absentDate}", "{absentStatus}", "{schoolTitle}");
                                 $replaceArray = array($student->fullName, $student->studentRollId, $student->email, $student->username, $parent->fullName, $parent->email, Input::get('attendanceDay'), $absentStatus, $this->panelInit->settingsArray['siteTitle']);
                                 $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
                                 $MailSmsHandler->mail($parent->email, $this->panelInit->language['absentReport'], $studentTemplate);
                             }
                             if (isset($sms) and $parent->mobileNo != "") {
                                 $studentTemplate = $mailTemplate->templateSMS;
                                 $examGradesTable = "";
                                 $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{parentName}", "{parentEmail}", "{absentDate}", "{absentStatus}", "{schoolTitle}");
                                 $replaceArray = array($student->fullName, $student->studentRollId, $student->email, $student->username, $parent->fullName, $parent->email, Input::get('attendanceDay'), $absentStatus, $this->panelInit->settingsArray['siteTitle']);
                                 $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
                                 $MailSmsHandler->sms($parent->mobileNo, $studentTemplate);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $this->panelInit->apiOutput(true, "Attendance", $this->panelInit->language['attendanceSaved']);
 }