Пример #1
0
 /**
  * @Route("/")
  */
 public function indexAction(Request $request)
 {
     $source = new Entity('ChamiloNotebookBundle:CNotebook');
     $course = $this->getCourse();
     /* @var $grid \APY\DataGridBundle\Grid\Grid */
     $grid = $this->get('grid');
     /*$tableAlias = $source->getTableAlias();
       $source->manipulateQuery(function (QueryBuilder $query) use ($tableAlias, $course) {
               $query->andWhere($tableAlias . '.cId = '.$course->getId());
               //$query->resetDQLPart('orderBy');
           }
       );*/
     /** @var NotebookRepository $repository */
     $repository = $this->getRepository();
     $resources = $repository->getResourceByCourse($course);
     $source->setData($resources);
     $grid->setSource($source);
     //$grid->hideFilters();
     $grid->setLimits(5);
     //$grid->isReadyForRedirect();
     //$grid->setMaxResults(1);
     //$grid->setLimits(2);
     /*$grid->getColumn('id')->manipulateRenderCell(
           function ($value, $row, $router) use ($course) {
               //$router = $this->get('router');
               return $router->generate(
                   'chamilo_notebook_show',
                   array('id' => $row->getField('id'), 'course' => $course)
               );
           }
       );*/
     if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) {
         $deleteMassAction = new MassAction('Delete', 'chamilo.controller.notebook:deleteMassAction', true, array('course' => $request->get('course')));
         $grid->addMassAction($deleteMassAction);
     }
     $myRowAction = new RowAction($this->trans('View'), 'chamilo_notebook_show', false, '_self', array('class' => 'btn btn-default'));
     $myRowAction->setRouteParameters(array('course' => $course, 'id'));
     $grid->addRowAction($myRowAction);
     if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) {
         $myRowAction = new RowAction($this->trans('Edit'), 'chamilo_notebook_edit', false, '_self', array('class' => 'btn btn-info'));
         $myRowAction->setRouteParameters(array('course' => $course, 'id'));
         $grid->addRowAction($myRowAction);
         $myRowAction = new RowAction($this->trans('Delete'), 'chamilo_notebook_delete', false, '_self', array('class' => 'btn btn-danger', 'form_delete' => true));
         $myRowAction->setRouteParameters(array('course' => $course, 'id'));
         $grid->addRowAction($myRowAction);
     }
     $grid->addExport(new CSVExport($this->trans('CSV Export'), 'export', array('course' => $course)));
     $grid->addExport(new ExcelExport($this->trans('Excel Export'), 'export', array('course' => $course)));
     return $grid->getGridResponse('ChamiloNotebookBundle:Notebook:index.html.twig');
 }
Пример #2
0
 /**
  * @Route("/")
  */
 public function indexAction(Request $request)
 {
     $source = new Entity('ChamiloNotebookBundle:CNotebook');
     $course = $this->getCourse();
     /* @var $grid \APY\DataGridBundle\Grid\Grid */
     $grid = $this->get('grid');
     /** @var NotebookRepository $repository */
     $repository = $this->getRepository();
     $resources = $repository->getResourceByCourse($course);
     $source->setData($resources);
     $grid->setSource($source);
     //$grid->hideFilters();
     $grid->setLimits(5);
     //$grid->isReadyForRedirect();
     // Delete Mass
     if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) {
         $deleteMassAction = new MassAction('Delete', 'chamilo_notebook.controller.notebook:deleteMassAction', true, array('course' => $request->get('course')));
         $grid->addMassAction($deleteMassAction);
     }
     // Show
     $myRowAction = new RowAction($this->trans('View'), 'chamilo_notebook_show', false, '_self', array('class' => 'btn btn-default'));
     $myRowAction->setRouteParameters(array('course' => $course, 'id'));
     $grid->addRowAction($myRowAction);
     if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) {
         // Edit
         $myRowAction = new RowAction($this->trans('Edit'), 'chamilo_notebook_edit', false, '_self', array('class' => 'btn btn-info'));
         $myRowAction->setRouteParameters(array('course' => $course, 'id'));
         $grid->addRowAction($myRowAction);
         // Delete
         $myRowAction = new RowAction($this->trans('Delete'), 'chamilo_notebook_delete', false, '_self', array('class' => 'btn btn-danger', 'form_delete' => true));
         $myRowAction->setRouteParameters(array('course' => $course, 'id'));
         $grid->addRowAction($myRowAction);
     }
     // Exports
     $grid->addExport(new CSVExport($this->trans('CSV Export'), 'export', array('course' => $course)));
     $grid->addExport(new ExcelExport($this->trans('Excel Export'), 'export', array('course' => $course)));
     return $grid->getGridResponse('ChamiloNotebookBundle:Notebook:index.html.twig');
 }