Exemple #1
0
 public function generateCodes(array $data)
 {
     $count = (int) $data['count'];
     $teacherId = $data['teacher_id'];
     $message = $data['message'];
     if (is_null($count) || is_null($teacherId)) {
         return false;
     } else {
         try {
             \DB::beginTransaction();
             $teacher = Authenticator::user($teacherId);
             \PDF::setPrintHeader(false);
             \PDF::setPrintFooter(false);
             \PDF::AddPage();
             for ($i = 0; $i < $count; $i++) {
                 $code = $this->codeRepo->generateCode();
                 $data = array();
                 $data = array_add($data, 'student_code', $code);
                 $data = array_add($data, 'teacher_id', $teacherId);
                 $code = $this->codeRepo->create($data);
                 $code->message = $message;
                 $this->codeRepo->clearModel();
                 $html = View::make('pages.code')->with('code', $code)->render();
                 if ($i % 5 === 0 && $i !== 0) {
                     \PDF::AddPage();
                     \PDF::writeHTML($html, false, false, false, false, 'L');
                 } else {
                     \PDF::writeHTML($html, false, false, false, false, 'L');
                 }
             }
             \PDF::SetCreator('');
             \PDF::SetAuthor('');
             $format = '%s/%s.pdf';
             $subpath = sprintf($format, 'pdfs', $teacherId);
             $format = '/%s/%s';
             $fullpath = sprintf($format, public_path(), $subpath);
             \PDF::Output($fullpath, 'F');
             \DB::commit();
             return $subpath;
         } catch (\Exception $ex) {
             \Log::error($ex);
             \DB::rollback();
             return false;
         }
     }
 }
Exemple #2
0
 public function getHome()
 {
     $userType = Session::get('user_type');
     $view = View::make('pages.home');
     if (strcmp($userType, 'admin') === 0) {
         $activities = $this->activityService->all();
         $parents = $this->parentService->all();
         $teachers = $this->teacherService->all();
         return $view->with('user_type', $userType)->with('user', Authenticator::user())->with('activities', $activities)->with('parents', $parents)->with('teachers', $teachers);
     } else {
         if (strcmp($userType, 'parent') === 0) {
             $user = Authenticator::user();
             $activities = $this->activityService->getActivities($user);
             $avg = $this->activityService->getAvgActivityTime();
             return $view->with('user_type', $userType)->with('user', Authenticator::user())->with('activities', $activities)->with('avg', $avg);
         } else {
             return $view->with('user_type', $userType)->with('user', Authenticator::user());
         }
     }
 }
 public function getChange()
 {
     $user = Authenticator::user();
     return View::make('pages.pwd')->with('user', $user);
 }