/**
  * @Route("/grid", name="lc_admin_person_grid")
  * @Template()
  */
 public function gridAction(Request $request)
 {
     $form = $this->createForm(new PersonFilterFormType());
     $form->handleRequest($request);
     $result['grid'] = null;
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $sql = $em->createQueryBuilder();
         $sql->select('u');
         $sql->from('PROCERGSLoginCidadaoCoreBundle:Person', 'u');
         $sql->where('1=1');
         $parms = $form->getData();
         if (isset($parms['username'][0])) {
             $sql->andWhere('u.cpf like ?1 or LowerUnaccent(u.username) like LowerUnaccent(?1) or LowerUnaccent(u.email) like LowerUnaccent(?1) or LowerUnaccent(u.firstName) like LowerUnaccent(?1) or LowerUnaccent(u.surname) like LowerUnaccent(?1)');
             $sql->setParameter('1', '%' . addcslashes($parms['username'], '\\%_') . '%');
         }
         $sql->addOrderBy('u.id', 'desc');
         $grid = new GridHelper();
         $grid->setId('person-grid');
         $grid->setPerPage(5);
         $grid->setMaxResult(5);
         $grid->setQueryBuilder($sql);
         $grid->setInfiniteGrid(true);
         $grid->setRoute('lc_admin_person_grid');
         $grid->setRouteParams(array($form->getName()));
         return array('grid' => $grid->createView($request));
     }
     return $result;
 }
 /**
  * @Route("/grid", name="lc_admin_app_grid")
  * @Template()
  */
 public function gridAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $sql = $em->getRepository('PROCERGSOAuthBundle:Client')->createQueryBuilder('c')->addOrderBy('c.id', 'desc');
     $grid = new GridHelper();
     $grid->setId('client-grid');
     $grid->setPerPage(15);
     $grid->setMaxResult(15);
     $grid->setQueryBuilder($sql);
     $grid->setInfiniteGrid(true);
     $grid->setRoute('lc_admin_app');
     return array('grid' => $grid->createView($request));
 }
 /**
  * @Route("/grid", name="lc_dev_shout_grid")
  * @Template()
  */
 public function gridAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $sql = $em->getRepository('PROCERGSLoginCidadaoCoreBundle:Notification\\Shout')->createQueryBuilder('c')->where('c.person = :person')->setParameter('person', $this->getUser())->addOrderBy('c.id', 'desc');
     $grid = new GridHelper();
     $grid->setId('shout-grid');
     $grid->setPerPage(5);
     $grid->setMaxResult(5);
     $grid->setQueryBuilder($sql);
     $grid->setInfiniteGrid(true);
     $grid->setRoute('lc_dev_shout_grid');
     return array('grid' => $grid->createView($request));
 }
 /**
  * @Route("/listQuery", name="lc_admin_sugg_list_query")
  * @Template()
  */
 public function listQueryAction(Request $request)
 {
     $form = $this->createForm(new SuggestionFilterFormType());
     $form->handleRequest($request);
     $result['grid'] = null;
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $sql = $em->createQueryBuilder();
         $sql->select('cs.id, cs.createdAt, cs.text shorttext, u.username');
         $sql->from('PROCERGSLoginCidadaoCoreBundle:ClientSuggestion', 'cs');
         $sql->join('PROCERGSLoginCidadaoCoreBundle:Person', 'u', 'WITH', 'cs.person = u');
         $sql->where('1=1');
         $parms = $form->getData();
         if (isset($parms['username'][0])) {
             $sql->andWhere('u.username = ?1');
             $sql->setParameter('1', $parms['username']);
         }
         if (isset($parms['dateini'])) {
             $sql->andWhere('cs.createdAt >= ?2');
             $sql->setParameter('2', $parms['dateini']);
         }
         if (isset($parms['dateend'])) {
             $sql->andWhere('cs.createdAt <= ?3');
             $sql->setParameter('3', $parms['dateend']);
         }
         if (isset($parms['text'][0])) {
             $sql->andWhere("cs.text like ?4");
             $sql->setParameter('4', '%' . addcslashes($parms['text'], '\\%_') . '%');
         }
         $sql->addOrderBy('cs.createdAt');
         $grid = new GridHelper();
         $grid->setId('suggs-grid');
         $grid->setPerPage(5);
         $grid->setMaxResult(5);
         $grid->setQueryBuilder($sql);
         $grid->setInfiniteGrid(true);
         $grid->setRoute('lc_admin_sugg_list_query');
         $grid->setRouteParams(array($form->getName()));
         return array('grid' => $grid->createView($request));
     }
     return $result;
 }
 /**
  * @Route("/placeholder/grid", name="lc_dev_not_placeholder_grid")
  * @Template()
  */
 public function placeholderGridAction(Request $request)
 {
     $categoryId = $request->get('category_id');
     $em = $this->getDoctrine()->getManager();
     $sql = $em->getRepository('PROCERGSLoginCidadaoNotificationBundle:Placeholder')->createQueryBuilder('u')->join('PROCERGSLoginCidadaoNotificationBundle:Category', 'cat', 'with', 'u.category = cat')->join('PROCERGSOAuthBundle:Client', 'c', 'with', 'cat.client = c')->where(':person MEMBER OF c.owners')->andWhere('cat.id = :id')->setParameter('person', $this->getUser())->setParameter('id', $categoryId)->orderBy('u.id', 'desc');
     $grid = new GridHelper();
     $grid->setId('placeholder-grid');
     $grid->setPerPage(2);
     $grid->setMaxResult(2);
     $grid->setQueryBuilder($sql);
     $grid->setInfiniteGrid(true);
     $grid->setRoute('lc_dev_not_placeholder_grid');
     $grid->setRouteParams(array('category_id'));
     return array('grid' => $grid->createView($request));
 }
 /**
  * @Route("/grid/developer", name="lc_dev_client_grid_developer")
  * @Template()
  */
 public function gridDeveloperAction(Request $request)
 {
     $grid = new GridHelper();
     $grid->setId('developer-grid');
     $grid->setPerPage(5);
     $grid->setMaxResult(5);
     $parms = $request->get('ac_data');
     if (isset($parms['person_id']) && !empty($parms['person_id'])) {
         $em = $this->getDoctrine()->getManager();
         $sql = $em->getRepository('PROCERGSLoginCidadaoCoreBundle:Person')->createQueryBuilder('p');
         $sql->where('p.id in(:id)')->setParameter('id', $parms['person_id']);
         $sql->addOrderBy('p.id', 'desc');
         $grid->setQueryBuilder($sql);
     }
     $grid->setInfiniteGrid(true);
     $grid->setRouteParams(array('ac_data'));
     $grid->setRoute('lc_dev_client_grid_developer');
     return array('grid' => $grid->createView($request));
 }
 /**
  * @Route("/profile/doc/rg/list", name="lc_profile_doc_rg_list")
  * @Template()
  */
 public function docRgListAction(Request $request)
 {
     $sql = $this->getDoctrine()->getManager()->getRepository('PROCERGSLoginCidadaoCoreBundle:IdCard')->getGridQuery($this->getUser());
     $grid = new GridHelper();
     $grid->setId('rg-grid');
     $grid->setPerPage(4);
     $grid->setMaxResult(4);
     $grid->setQueryBuilder($sql);
     $grid->setInfiniteGrid(true);
     $grid->setRoute('lc_profile_doc_rg_list');
     return array('grid' => $grid->createView($request));
 }
 /**
  * @Route("/inbox/gridsimple", name="lc_not_inbox_gridsimple")
  * @Template()
  */
 public function gridSimpleAction()
 {
     $request = $this->getRequest();
     $id = $request->get('confignotcli');
     if (!$id) {
         return $this->gridFullAction();
     }
     $sql = $this->getDoctrine()->getManager()->getRepository('PROCERGSLoginCidadaoCoreBundle:Notification\\Notification')->createQueryBuilder('n')->select('n.id, case when n.readDate is null then false else true end isread, n.title, n.shortText shorttext, n.createdAt createdat, c.id client_id, c.name client_name')->join('PROCERGSLoginCidadaoCoreBundle:Notification\\Category', 'cnc', 'WITH', 'n.category = cnc')->join('PROCERGSOAuthBundle:Client', 'c', 'WITH', 'cnc.client = c')->where('n.person = :person and cnc.id = :configNotCli')->setParameter('person', $this->getUser())->setParameter('configNotCli', $id)->orderBy('n.id', 'DESC');
     if ($request->get('client')) {
         $sql->andWhere('c.id = :client')->setParameter('client', $request->get('client'));
     }
     $grid = new GridHelper();
     $grid->setId('simpleOne' . $id);
     $grid->setPerPage(10);
     $grid->setMaxResult(10);
     $grid->setQueryBuilder($sql);
     $grid->setInfinityGrid(true);
     $grid->setRoute('lc_not_inbox_gridsimple');
     $grid->setRouteParams(array('client', 'mode', 'notification', 'confignotcli'));
     return array('grid' => $grid->createView($request));
 }