public function getQueryRegistration(Convention $convention)
 {
     $qb = $this->createQueryBuilder('registration');
     $alias = current($qb->getRootAliases());
     $qb->andWhere($qb->expr()->eq($alias . '.convention', $convention->getId()));
     return $qb;
 }
 public function invoiceAction(Convention $convention, Request $request)
 {
     $registrations = $convention->getRegistrations();
     $zip = new ZipArchive();
     $title = $convention->getSlug();
     $filename = tempnam('/tmp/', 'ritsiGA-' . $title . '-');
     unlink($filename);
     if ($zip->open($filename, ZIPARCHIVE::CREATE) !== true) {
         throw new \Exception("cannot open <{$filename}>\n");
     }
     if (false === $zip->addEmptyDir($title)) {
         throw new \Exception("cannot add empty dir {$title}\n");
     }
     $route_dir = $this->container->getParameter('kernel.root_dir');
     foreach ($registrations as $registration) {
         $single_file = $route_dir . '/../private/documents/invoices/' . $registration->getId() . '.pdf';
         if (false === file_exists($single_file)) {
             continue;
         }
         $name = $registration->getId();
         if (false === $zip->addFile($single_file, implode('/', array($title, $name . '.pdf')))) {
             throw new \Exception("cannot add file\n");
         }
     }
     if (false === $zip->close()) {
         throw new \Exception("cannot close <{$filename}>\n");
     }
     $response = new BinaryFileResponse($filename);
     $response->trustXSendfileTypeHeader();
     $response->prepare($request);
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $convention->getSlug() . '-facturas.zip', iconv('UTF-8', 'ASCII//TRANSLIT', $convention->getSlug() . '-facturas.zip'));
     return $response;
 }
示例#3
0
 /**
  * Returns the base url of a convention
  *
  *
  * @param Convention $convention
  * @return string
  */
 public function conventionURL(Convention $convention)
 {
     $request = $this->requestStack->getCurrentRequest();
     $domain = $convention->getDomain();
     $url = str_replace('http://', '', $request->getUri());
     $url_complete = "http://" . $domain . "." . $url;
     return $url_complete;
 }
示例#4
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     $context = $this->router->getContext();
     preg_match('/^\\/convention\\/([a-z]\\w+)/', $context->getPathInfo(), $matches);
     $code = isset($matches[1]) ? $matches[1] : $this->baseCode;
     if (!$context->hasParameter('code')) {
         $context->setParameter('code', $code);
     }
     if ($this->baseCode == $code) {
         $site = new Convention();
         $site->setDomain('ritsi');
         $this->siteManager->setCurrentSite($site);
         return;
     }
     $site = $this->em->getRepository('AppBundle:Convention')->findOneBy(array('domain' => $code));
     if (!$site) {
         throw new NotFoundHttpException(sprintf('No site for code "%s"', $code));
     }
     $this->siteManager->setCurrentSite($site);
 }
示例#5
0
 /**
  * @Given existen las asambleas:
  */
 public function thereAreConventions(TableNode $tableNode)
 {
     foreach ($tableNode->getHash() as $conventionHash) {
         $convention = new Convention();
         $convention->setName($conventionHash['nombre']);
         $convention->setStartsAt(new \DateTime($conventionHash['fechaInicio']));
         $convention->setEndsAt(new \DateTime($conventionHash['fechaFin']));
         $convention->setDomain($conventionHash['dominio']);
         $convention->setEmail($this->faker->email);
         $this->getEntityManager()->persist($convention);
     }
     $this->getEntityManager()->flush();
 }
 public function getQueryConvention(Convention $convention)
 {
     $qb = $this->createQueryBuilder('convention');
     return $qb->where('convention.id=:id')->setParameter('id', $convention->getId());
 }
示例#7
0
 /**
  * OrganizerRole constructor.
  * @param Convention $convention
  */
 public function __construct(Convention $convention)
 {
     $this->role = 'ROLE_RITSIGA_ORGANIZER_' . strtoupper($convention->getDomain());
 }
 /**
  * OrganizerRole constructor.
  *
  * @param Convention $convention
  */
 public function __construct(Convention $convention)
 {
     $this->role = 'ROLE_RITSIGA_ORGANIZER_' . $convention->getSlug();
     $this->code = $convention->getSlug();
 }