|
@@ -0,0 +1,77 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace FTTHBundle\Controller;
|
|
|
+
|
|
|
+use WorkflowBundle\Controller\CRUDController;
|
|
|
+use Symfony\Component\HttpFoundation\Response;
|
|
|
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
+use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
|
|
+
|
|
|
+class ONUCRUDController extends CRUDController
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * List action.
|
|
|
+ *
|
|
|
+ * @return Response
|
|
|
+ *
|
|
|
+ * @throws AccessDeniedException If access is not granted
|
|
|
+ */
|
|
|
+ public function listAction()
|
|
|
+ {
|
|
|
+ $request = $this->getRequest();
|
|
|
+
|
|
|
+ $this->admin->checkAccess('list');
|
|
|
+
|
|
|
+ $preResponse = $this->preList($request);
|
|
|
+ if ($preResponse !== null) {
|
|
|
+ return $preResponse;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($listMode = $request->get('_list_mode')) {
|
|
|
+ $this->admin->setListMode($listMode);
|
|
|
+ }
|
|
|
+
|
|
|
+ $datagrid = $this->admin->getDatagrid();
|
|
|
+ $clientsIds = array();
|
|
|
+ foreach($datagrid->getResults() as $object) {
|
|
|
+ if($object->getClientId())
|
|
|
+ $clientsIds[$object->getClientId()] = $object->getClientId();
|
|
|
+ }
|
|
|
+
|
|
|
+ $_clients = array();
|
|
|
+ if($this->container->hasParameter('client') && $clientsIds) {
|
|
|
+ $clientApi = $this->getParameter('client');
|
|
|
+ $webservice = $this->get("webservice");
|
|
|
+ $filters = array("qb-ids" => implode(",",$clientsIds), 'qb-criteria' => true);
|
|
|
+ $clients = $webservice->getData($clientApi, $filters);
|
|
|
+ if($clients)
|
|
|
+ foreach($clients as $client) {
|
|
|
+ $_clients[$client['id']] = "{$client['id']} - {$client['name']}";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($_clients) {
|
|
|
+ foreach($datagrid->getResults() as $object) {
|
|
|
+ if($object->getClientId() && isset($_clients[$object->getClientId()]))
|
|
|
+ $object->setClientId($_clients[$object->getClientId()]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $formView = $datagrid->getForm()->createView();
|
|
|
+
|
|
|
+ // set the theme for the current Admin Form
|
|
|
+ $this->setFormTheme($formView, $this->admin->getFilterTheme());
|
|
|
+
|
|
|
+ return $this->render($this->admin->getTemplate('list'), array(
|
|
|
+ 'action' => 'list',
|
|
|
+ 'form' => $formView,
|
|
|
+ 'datagrid' => $datagrid,
|
|
|
+ 'csrf_token' => $this->getCsrfToken('sonata.batch'),
|
|
|
+ 'export_formats' => $this->has('sonata.admin.admin_exporter') ?
|
|
|
+ $this->get('sonata.admin.admin_exporter')->getAvailableFormats($this->admin) :
|
|
|
+ $this->admin->getExportFormats(),
|
|
|
+ ), null);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|