Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. {% set jsonOptionsDataBases %}
  2. {
  3. "processing": true,
  4. "serverSide": true,
  5. "ajax": "{{ path("surveillance_bo_dossier_home_tableau",{"type": 0, "client":client}) }}",
  6. "sAjaxDataProp": "data",
  7. "pageLength": 100,
  8. "columns": [
  9. {data: "client"},
  10. {data: "dossier"},
  11. {data: "type"},
  12. {data: "dateD"},
  13. {data: "dateF"},
  14. {data: "analyse"},
  15. {data: "frequence"},
  16. {data: "cc"},
  17. {data: "dateR"},
  18. {data: "action"},
  19. {data: "jur"},
  20. {data: "isActif"},
  21. ]
  22. {% endset %}
  23. {{ macro_datatables.datatablesInit('dossiers','dossiers',jsonOptionsDataBases,a_colWithSelect,a_colWithDate,a_colEmpty, a_colWithSelectOtherColumn, a_colWithDateUs) }}
  24.  
  25. $users = $Surv->getRepository('t:sDossier')->ServerSide($filters, 0, $length);
  26. $output = array(
  27. 'data' => array(),
  28. 'recordsFiltered' => $I_nbResultatsTotal,
  29. 'recordsTotal' => $I_nbResultatsTotal,
  30. );
  31. $i = 0;
  32. $users ($A_listeDossiers as $O_dossier) {
  33. $I_idDossier = $O_dossier->getId();
  34. $I_idRapportLast = 0;
  35. $output['data'][] = [
  36. 'client' => 1,
  37. 'dossier' => 1,
  38. 'type' => 1,
  39. 'dateD' => 1,
  40. 'dateF' =>1,
  41. 'analyse' => 1,
  42. 'frequence' => 1,
  43. 'dateR' => 1,
  44. 'action' => 1,
  45. 'cc' =>1,
  46. 'jur' => 1,
  47. 'isActif' => 1
  48. ];
  49. $I_nbResultatsTotal++;
  50. }
  51.  
  52. return new Response(json_encode($output), 200, ['Content-Type' => 'application/json']);
  53.  
  54. public function ServerSide($data, $page = 0, $max = NULL, $getResult = true)
  55. {
  56.  
  57.  
  58.  
  59. $qb = $this->_em->createQueryBuilder();
  60. $query = isset($data['query']) && $data['query']?$data['query']:null;
  61.  
  62. $qb
  63. ->select('u')
  64. ->from('t:sDossier', 'u')
  65. ;
  66.  
  67. if ($query) {
  68. $qb
  69. ->andWhere('u.name like :query')
  70. ->setParameter('query', "%".$query."%")
  71. ;
  72. }
  73.  
  74. if ($max) {
  75. $preparedQuery = $qb->getQuery()
  76. ->setMaxResults($max)
  77. ->setFirstResult($page * $max)
  78. ;
  79. } else {
  80. $preparedQuery = $qb->getQuery();
  81. }
  82.  
  83. return $getResult?$preparedQuery->getResult():$preparedQuery;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement