PageRenderTime 26ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Ultra/ControlDocumentoBundle/Controller/PemexController.php

https://gitlab.com/hersan/ultra
PHP | 179 lines | 105 code | 26 blank | 48 comment | 0 complexity | 9fda1d267d9a98552fafdb263c139f80 MD5 | raw file
  1. <?php
  2. namespace Ultra\ControlDocumentoBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  9. /**
  10. * Class PemexController
  11. * @package Ultra\ControlDocumentoBundle\Controller
  12. * @Route("/Pemex", name="pemex")
  13. */
  14. class PemexController extends Controller
  15. {
  16. /**
  17. * @Route("/index", name="pemex_index")
  18. * @Template("ControlDocumentoBundle:Pemex:index.html.twig")
  19. */
  20. public function indexAction()
  21. {
  22. $proyectos = $this->getDoctrine()->getManager()->getRepository('ControlDocumentoBundle:Contrato')->findAll();
  23. //$procedimientos= $this->getDoctrine()->getManager()->getRepository('ControlDocumentoBundle:Documento')->findByCliente(1,1);
  24. $limite=new \DateTime();
  25. $limite->modify("+2 months");
  26. $em = $this->getDoctrine()->getManager();
  27. $query = $em->createQuery(
  28. "SELECT d FROM ControlDocumentoBundle:Documento d
  29. JOIN d.tipoDocumento t JOIN d.condicion c JOIN d.disciplina dis
  30. JOIN dis.area a JOIN a.contrato con JOIN con.cliente cli
  31. WITH c.id = 1 AND d.vigencia< :limite
  32. ")->setParameter('limite', $limite->format('Y-m-d') );
  33. $procedimientos = $query->getResult();
  34. //ladybug_dump_die($procedimientos);
  35. return array(
  36. 'proyectos' => $proyectos,'documentos'=>$procedimientos,'lim'=>$limite
  37. );
  38. }
  39. /**
  40. * @Route("/{type}/manual", name="pemex_manual")
  41. * @Template("ControlDocumentoBundle:Pemex:manual.html.twig")
  42. */
  43. public function manualAction($type)
  44. {
  45. $clientes = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Cliente')->find(2);
  46. //ladybug_dump_die($clientes);
  47. $documentos= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),$type);
  48. //ladybug_dump_die($documentos);
  49. return array(
  50. 'procedimientos' => $documentos
  51. );
  52. //return array();
  53. }
  54. /**
  55. * @Route("/perfiles", name="pemex_perfiles")
  56. * @Template("ControlDocumentoBundle:Pemex:perfil.html.twig")
  57. */
  58. public function perfilAction()
  59. {
  60. $cliente = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Cliente')->find(2);
  61. $documentos = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Perfil')->findByClient($cliente->getId());
  62. //ladybug_dump($documentos);
  63. return array(
  64. 'procedimientos' => $documentos
  65. );
  66. }
  67. /**
  68. * @Route("/{type}/docum", name="pemex_docum")
  69. * @Template("ControlDocumentoBundle:Pemex:docs.html.twig")
  70. */
  71. public function documAction($type)
  72. {
  73. $clientes = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Cliente')->find(2);
  74. //ladybug_dump_die($clientes);
  75. $documentos= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),$type);
  76. //ladybug_dump_die($docu);
  77. return array(
  78. 'procedimientos' => $documentos,
  79. );
  80. //return array();
  81. }
  82. /**
  83. * @Route("/{type}/proc", name="pemex_proc")
  84. * @Template("ControlDocumentoBundle:Pemex:proc.html.twig")
  85. */
  86. public function procAction($type)
  87. {
  88. $clientes = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Cliente')->find(2);
  89. //ladybug_dump_die($clientes);
  90. $documentos= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),$type);
  91. //ladybug_dump_die($docu);
  92. return array(
  93. 'procedimientos' => $documentos,
  94. );
  95. //return array();
  96. }
  97. /**
  98. * @Route("/{type}/regl", name="pemex_regl")
  99. * @Template("ControlDocumentoBundle:Pemex:reglamentos.html.twig")
  100. */
  101. public function reglAction($type)
  102. {
  103. $clientes = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Cliente')->find(2);
  104. //ladybug_dump_die($clientes);
  105. $documentos= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),$type);
  106. //ladybug_dump_die($docu);
  107. return array(
  108. 'procedimientos' => $documentos,
  109. );
  110. //return array();
  111. }
  112. /**
  113. * @Route("/showmpemex", name="pemex_m_pdf")
  114. * @Template("ControlDocumentoBundle:Pemex:showmaestrapemex.html.twig")
  115. */
  116. public function showmpemexAction()
  117. {
  118. $clientes = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Cliente')->find(2);
  119. $perfiles = $this->getDoctrine()->getRepository('ControlDocumentoBundle:Perfil')->findByClient($clientes->getId());
  120. $manuales= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),2);
  121. $documentos= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),6);
  122. $procedimientos= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),1);
  123. $reglamentos= $this->getDoctrine()->getRepository('ControlDocumentoBundle:Documento')->findByCliente($clientes->getId(),5);
  124. $html = $this->renderView('ControlDocumentoBundle:Pemex:showmaestrapemex.html.twig',
  125. array(
  126. 'perfiles' => $perfiles,
  127. 'manuales' => $manuales,
  128. 'documentos' => $documentos,
  129. 'procedimientos' => $procedimientos,
  130. 'reglamentos' => $reglamentos,
  131. ));
  132. $response = new Response (
  133. $this->get('knp_snappy.pdf')->getOutputFromHtml($html,
  134. array('lowquality' => false,
  135. 'print-media-type' => true,
  136. 'encoding' => 'utf-8',
  137. 'page-size' => 'Letter',
  138. 'outline-depth' => 8,
  139. 'orientation' => 'Landscape',
  140. 'title'=> 'listamaestra',
  141. 'user-style-sheet'=> 'css/bootstrap.css',
  142. 'header-left'=>'Hoja [page] de [toPage]',
  143. 'header-font-size'=>8,
  144. )),
  145. 200,
  146. array(
  147. 'Content-Type' => '/home/aloyo/public_html/Ultra/web/pdf',
  148. 'Content-Disposition' => 'attachment; filename="listramaestrapemex.pdf"',
  149. )
  150. );
  151. return $response;
  152. }
  153. }