public function exportpdf() { if ($this->data['users']->role != "admin") { exit; } $classArray = array(); $classes = classes::get(); foreach ($classes as $class) { $classArray[$class->id] = $class->className; } $header = array('Full Name', 'User Name', 'E-mail', 'Gender', 'Address', 'Mobile No', 'Class'); $data = array(); $student = User::where('role', 'student')->get(); foreach ($student as $value) { $data[] = array($value->fullName, $value->username . "(" . $value->studentRollId . ")", $value->email, $value->gender, $value->address, $value->mobileNo, isset($classArray[$value->studentClass]) ? $classArray[$value->studentClass] : ""); } $pdf = new FPDF(); $pdf->SetFont('Arial', '', 10); $pdf->AddPage(); // Header foreach ($header as $col) { $pdf->Cell(40, 7, $col, 1); } $pdf->Ln(); // Data foreach ($data as $row) { foreach ($row as $col) { $pdf->Cell(40, 6, $col, 1); } $pdf->Ln(); } $pdf->Output(); exit; }
function export($type) { if ($this->data['users']->role != "admin") { exit; } if ($type == "excel") { $classArray = array(); $classes = classes::get(); foreach ($classes as $class) { $classArray[$class->id] = $class->className; } $data = array(1 => array('Title', 'Description', 'Student', 'Amount', 'Date', 'Status')); $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')->get(); foreach ($payments as $value) { if ($value->paymentStatus == 1) { $paymentStatus = "PAID"; } else { $paymentStatus = "UNPAID"; } $data[] = array($value->paymentTitle, $value->paymentDescription, $value->fullName, $value->paymentAmount, $value->paymentDate, $paymentStatus); } $xls = new Excel_XML('UTF-8', false, 'Students Sheet'); $xls->addArray($data); $xls->generateXML('Students-Sheet'); } elseif ($type == "pdf") { $classArray = array(); $classes = classes::get(); foreach ($classes as $class) { $classArray[$class->id] = $class->className; } $header = array('Title', 'Description', 'Student', 'Amount', 'Date', 'Status'); $data = array(); $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')->get(); foreach ($payments as $value) { if ($value->paymentStatus == 1) { $paymentStatus = "PAID"; } else { $paymentStatus = "UNPAID"; } $data[] = array($value->paymentTitle, $value->paymentDescription, $value->fullName, $value->paymentAmount, $value->paymentDate, $paymentStatus); } $pdf = new FPDF(); $pdf->SetFont('Arial', '', 10); $pdf->AddPage(); // Header foreach ($header as $col) { $pdf->Cell(40, 7, $col, 1); } $pdf->Ln(); // Data foreach ($data as $row) { foreach ($row as $col) { $pdf->Cell(40, 6, $col, 1); } $pdf->Ln(); } $pdf->Output(); } exit; }
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); }
function export($id, $type) { if ($this->data['users']->role != "admin") { exit; } if ($type == "excel") { $classArray = array(); $classes = classes::get(); foreach ($classes as $class) { $classArray[$class->id] = $class->className; } $data = array(1 => array('Student Roll', 'Full Name', 'Date took', 'Exam Grade')); $grades = \DB::table('onlineExamsGrades')->where('examId', $id)->leftJoin('users', 'users.id', '=', 'onlineExamsGrades.studentId')->select('onlineExamsGrades.id as id', 'onlineExamsGrades.examGrade as examGrade', 'onlineExamsGrades.examDate as examDate', 'users.fullName as fullName', 'users.id as studentId', 'users.studentRollId as studentRollId')->get(); foreach ($grades as $value) { $data[] = array($value->studentRollId, $value->fullName, date("m/d/y", $value->examDate), $value->examGrade); } $xls = new Excel_XML('UTF-8', false, 'Exam grades Sheet'); $xls->addArray($data); $xls->generateXML('Exam grades Sheet'); } elseif ($type == "pdf") { $classArray = array(); $classes = classes::get(); foreach ($classes as $class) { $classArray[$class->id] = $class->className; } $header = array('Student Roll', 'Full Name', 'Date took', 'Exam Grade'); $data = array(); $grades = \DB::table('onlineExamsGrades')->where('examId', $id)->leftJoin('users', 'users.id', '=', 'onlineExamsGrades.studentId')->select('onlineExamsGrades.id as id', 'onlineExamsGrades.examGrade as examGrade', 'onlineExamsGrades.examDate as examDate', 'users.fullName as fullName', 'users.id as studentId', 'users.studentRollId as studentRollId')->get(); foreach ($grades as $value) { $data[] = array($value->studentRollId, $value->fullName, date("m/d/y", $value->examDate), $value->examGrade); } $pdf = new FPDF(); $pdf->SetFont('Arial', '', 10); $pdf->AddPage(); // Header foreach ($header as $col) { $pdf->Cell(60, 7, $col, 1); } $pdf->Ln(); // Data foreach ($data as $row) { foreach ($row as $col) { $pdf->Cell(60, 6, $col, 1); } $pdf->Ln(); } $pdf->Output(); } exit; }