Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Controller;
- use AppBundle\Entity\Cliente;
- use AppBundle\Entity\Expediente;
- use AppBundle\Entity\Usuario;
- use AppBundle\Entity\Contacto;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
- use AppBundle\Entity\Recepcion;
- use AppBundle\Form\RecepcionType;
- use Symfony\Component\HttpFoundation\Response;
- /**
- * Recepcion controller.
- *
- * @Route("/recepcion")
- */
- class RecepcionController extends Controller
- {
- /**
- * @Route("/grid")
- * @Template()
- */
- public function gridAction() {
- return array();
- }
- /**
- * @Route("/gridContent", name="_grid_content")
- */
- public function contenidoDelGridAction() {
- $renglones = array();
- $renglones[] = array('id'=>1, 'Item'=>'dcf','Descripcion'=>'Mesa','Cantidad'=>'100','Nro Expediente'=>'1 - 100');
- $renglones[] = array('id'=>2, 'Item'=>'ddc','Descripcion'=>'Silla','Cantidad'=>'23','Nro Expediente'=>'100 - 200');
- $contenidoParaJqGrid = array(
- 'total'=>1,
- 'page'=>1,
- 'records'=>1,
- 'rows'=>$renglones
- );
- return new \Symfony\Component\HttpFoundation\Response(
- json_encode($contenidoParaJqGrid)
- , 200
- , array('content-type'=>'application/json')
- );
- }
- /**
- * Lists all Recepcion entities.
- *
- * @Route("/", name="recepcion")
- * @Method("GET")
- * @Template()
- */
- public function indexAction()
- {
- $em = $this->getDoctrine()->getManager();
- $entities = $em->getRepository('AppBundle:Recepcion')->findAll();
- return array(
- 'entities' => $entities,
- );
- }
- /**
- * Creates a new Recepcion entity.
- *
- * @Route("/", name="recepcion_create")
- * @Method("POST")
- * @Template("AppBundle:Recepcion:new.html.twig")
- */
- public function createAction(Request $request)
- {
- $entity = new Recepcion();
- $form = $this->createCreateForm($entity);
- $form->handleRequest($request);
- if ($form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $em->persist($entity);
- $em->flush();
- return $this->redirect($this->generateUrl('recepcion_show', array('id' => $entity->getIdRecepcion())));
- }
- return array(
- 'entity' => $entity,
- 'form' => $form->createView(),
- );
- }
- /**
- * Creates a form to create a Recepcion entity.
- *
- * @param Recepcion $entity The entity
- *
- * @return \Symfony\Component\Form\Form The form
- */
- private function createCreateForm(Recepcion $entity)
- {
- // $form = $this->createForm()
- $form = $this->createForm(new RecepcionType(), $entity, array(
- 'action' => $this->generateUrl('recepcion_create'),
- 'method' => 'POST',
- ));
- $form->add('submit', 'submit', array('label' => 'Crear','attr' => array('class' => 'btn btn-success')));
- return $form;
- }
- /**
- * Displays a form to create a new Recepcion entity.
- *
- * @Route("/gridData", name = "recepcion_postaction")
- * @Method("POST")
- */
- public function gridDataAction(Request $request)
- {
- $jsonGrid = $request->request->get('localGridData');
- $recepcion_info = $request->request->get('infoRecepcion');
- $em = $this->getDoctrine()->getManager();
- // Extraccion de Informacion de Recepcion
- for($x = 0; $x < sizeof($recepcion_info); $x++) {
- if($recepcion_info[$x]['name'] == 'appbundle_recepcion[fechaRecepcion]')
- $fecha_recepcion = $recepcion_info[$x]['value'];
- if($recepcion_info[$x]['name'] == 'appbundle_recepcion[id]')
- $encargado_recepcion = $recepcion_info[$x]['value'];
- if($recepcion_info[$x]['name'] == 'appbundle_recepcion[idCliente]')
- $cliente_recepcion = $recepcion_info[$x]['value'];
- if($recepcion_info[$x]['name'] == 'appbundle_recepcion[idContacto]')
- $contacto_recepcion = $recepcion_info[$x]['value'];
- }
- $encargado_recepcion = $em->getRepository('AppBundle:Usuario')->find($encargado_recepcion);
- $cliente_recepcion = $em->getRepository('AppBundle:Cliente')->find($cliente_recepcion);
- $contacto_recepcion = $em->getRepository('AppBundle:Contacto')->find($contacto_recepcion);
- $fecha_recepcion = new \DateTime($fecha_recepcion,null);
- $row = new Recepcion();
- $row->setFechaRecepcion($fecha_recepcion);
- $row->setId($encargado_recepcion);
- $row->setIdCliente($cliente_recepcion);
- $row->setIdContacto($contacto_recepcion);
- $em->persist($row);
- $em->flush();
- //Extraccion de Informacion del grid1
- for($x = 0; $x < sizeof($jsonGrid); $x++) {
- $item = $jsonGrid[$x]['Item'];
- $descripcion = $jsonGrid[$x]['Descripcion'];
- $cantidad = $jsonGrid[$x]['Cantidad'];
- }
- // var_dump($fecha_recepcion,$encargado_recepcion,$cliente_recepcion,$contacto_recepcion);
- //var_dump($recepcion_info[0]['value']);
- //
- //
- //var_dump($cantidad);
- // $arrayGrid = json_decode($jsonGrid,true);
- //
- // foreach($arrayGrid AS $prop => $val){
- // echo '<br/>'.'-'.$val;
- // }
- // $uid = $_POST['Descripcion'];
- // $uiadd = json_decode($uid);
- // echo $uiadd;
- // if (isset($_POST["grid-pager"])) {
- // echo $_POST["grid-pager"];
- // }
- $response = new Response(json_encode(array('jsonGrid' => $jsonGrid, 'recepcion_info' => $recepcion_info )));
- $response->headers->set("Content-type", "application/json");
- return $response;
- }
- /**
- * Displays a form to create a new Recepcion entity.
- *
- * @Route("/nroExpedienteSeq", name = "recepcion_nroexpseq")
- * @Method("POST")
- */
- public function nroExpedienteSeqAction(Request $request)
- {
- $qty = $request->request->get("Cantidad");
- var_dump($request->request);
- $minVal = 1; //reemplazar por un query para saber el siguiente valor de la secuencia
- $seq = range($minVal,$minVal-1+$qty);
- $response = new Response(json_encode(array("seq"=> $seq)));
- $response->headers->set("Content-type", "application/json");
- return $response;
- }
- /**
- * Displays a form to create a new Recepcion entity.
- *
- * @Route("/new", name="recepcion_new")
- * @Method("GET")
- * @Template()
- */
- public function newAction()
- {
- $entity = new Recepcion();
- $form = $this->createCreateForm($entity);
- $em = $this->getDoctrine()->getManager();
- $clientes = $em->getRepository('AppBundle:Cliente')->findAll();
- return array(
- 'entity' => $entity,
- 'form' => $form->createView(),
- 'clientes' => $clientes,
- );
- }
- /**
- * Finds and displays a Recepcion entity.
- *
- * @Route("/{id}", name="recepcion_show")
- * @Method("GET")
- * @Template()
- */
- public function showAction($id)
- {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('AppBundle:Recepcion')->find($id);
- if (!$entity) {
- throw $this->createNotFoundException('No se pudo encontrar la entidad Recepcion.');
- }
- $deleteForm = $this->createDeleteForm($id);
- return array(
- 'entity' => $entity,
- 'delete_form' => $deleteForm->createView(),
- );
- }
- /**
- * Displays a form to edit an existing Recepcion entity.
- *
- * @Route("/{id}/edit", name="recepcion_edit")
- * @Method("GET")
- * @Template()
- */
- public function editAction($id)
- {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('AppBundle:Recepcion')->find($id);
- if (!$entity) {
- throw $this->createNotFoundException('No se pudo encontrar la entidad Recepcion.');
- }
- $editForm = $this->createEditForm($entity);
- $deleteForm = $this->createDeleteForm($id);
- return array(
- 'entity' => $entity,
- 'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
- );
- }
- /**
- * Creates a form to edit a Recepcion entity.
- *
- * @param Recepcion $entity The entity
- *
- * @return \Symfony\Component\Form\Form The form
- */
- private function createEditForm(Recepcion $entity)
- {
- $form = $this->createForm(new RecepcionType(), $entity, array(
- 'action' => $this->generateUrl('recepcion_update', array('id' => $entity->getIdRecepcion())),
- 'method' => 'PUT',
- ));
- $form->add('submit', 'submit', array('label' => 'Actualizar','attr' => array('class' => 'btn btn-info')));
- return $form;
- }
- /**
- * Edits an existing Recepcion entity.
- *
- * @Route("/{id}", name="recepcion_update")
- * @Method("PUT")
- * @Template("AppBundle:Recepcion:edit.html.twig")
- */
- public function updateAction(Request $request, $id)
- {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('AppBundle:Recepcion')->find($id);
- if (!$entity) {
- throw $this->createNotFoundException('No se pudo encontrar la entidad Recepcion.');
- }
- $deleteForm = $this->createDeleteForm($id);
- $editForm = $this->createEditForm($entity);
- $editForm->handleRequest($request);
- if ($editForm->isValid()) {
- $em->flush();
- return $this->redirect($this->generateUrl('recepcion_edit', array('id' => $id)));
- }
- return array(
- 'entity' => $entity,
- 'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
- );
- }
- /**
- * Deletes a Recepcion entity.
- *
- * @Route("/{id}", name="recepcion_delete")
- * @Method("DELETE")
- */
- public function deleteAction(Request $request, $id)
- {
- $form = $this->createDeleteForm($id);
- $form->handleRequest($request);
- if ($form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('AppBundle:Recepcion')->find($id);
- if (!$entity) {
- throw $this->createNotFoundException('No se pudo encontrar la entidad Recepcion.');
- }
- $em->remove($entity);
- $em->flush();
- }
- return $this->redirect($this->generateUrl('recepcion'));
- }
- /**
- * Creates a form to delete a Recepcion entity by id.
- *
- * @param mixed $id The entity id
- *
- * @return \Symfony\Component\Form\Form The form
- */
- private function createDeleteForm($id)
- {
- return $this->createFormBuilder()
- ->setAction($this->generateUrl('recepcion_delete', array('id' => $id)))
- ->setMethod('DELETE')
- ->add('submit', 'submit', array('label' => 'Borrar','attr' => array('class' => 'btn btn-danger')))
- ->getForm()
- ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement