예제 #1
0
 public function getSertificate(UserCourse $userCourse)
 {
     $userCourse->setBallsRoh(24);
     $user = $userCourse->getUser();
     $course = $userCourse->getCourse();
     $rest = $userCourse->getBallsRoh() ? $userCourse->getBallsRoh() % 10 : 0;
     if (in_array($userCourse->getBallsRoh(), array(11, 12, 13, 14, 15, 16, 17, 18, 19))) {
         $ballsRohString = 'баллов';
     } else {
         switch ($rest) {
             case 1:
                 $ballsRohString = 'балл';
                 break;
             case 2:
             case 3:
             case 4:
                 $ballsRohString = 'балла';
                 break;
             default:
                 $ballsRohString = 'баллов';
                 break;
         }
     }
     switch ($userCourse->getPassed()->format('m')) {
         case 1:
             $month = 'января';
             break;
         case 2:
             $month = 'февраля';
             break;
         case 3:
             $month = 'марта';
             break;
         case 4:
             $month = 'апреля';
             break;
         case 5:
             $month = 'мая';
             break;
         case 6:
             $month = 'июня';
             break;
         case 7:
             $month = 'июля';
             break;
         case 8:
             $month = 'августа';
             break;
         case 9:
             $month = 'сентября';
             break;
         case 10:
             $month = 'октября';
             break;
         case 11:
             $month = 'ноября';
             break;
         case 12:
             $month = 'декабря';
             break;
     }
     $date = $userCourse->getPassed()->format('d') . ' ' . $month . ' ' . $userCourse->getPassed()->format('Y');
     //        $mpdfService = $this->$mpdf;
     $mpdfService = $this->container->get('tfox.mpdfport');
     $engine = $this->container->get('templating');
     $html = $engine->render('LearningMainBundle::certificate.html.twig', array('user' => $user, 'course' => $course, 'userCourse' => $userCourse, 'ballsRohString' => $ballsRohString, 'date' => $date));
     $arguments = array('constructorArgs' => array('utf-8', 'A4-L', 5, 5, 5, 5, 5), 'writeHtmlMode' => null, 'writeHtmlInitialise' => null, 'writeHtmlClose' => null, 'outputFilename' => null, 'outputDest' => null);
     $mpdfService->generatePdfResponse($html, $arguments);
 }