Loading module/Oscar/config/routes.yml +1 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,7 @@ contract: exportjson: type: segment options: route: /export-json/:id route: /export-json[/:id] defaults: action: exportJSON Loading module/Oscar/src/Oscar/Controller/ProjectGrantController.php +31 −4 Original line number Diff line number Diff line Loading @@ -264,11 +264,37 @@ class ProjectGrantController extends AbstractOscarController public function exportJSONAction(){ $id = $this->params()->fromRoute('id', null); $ids = $this->params()->fromPost('ids', null); if( $id == null && $ids == null ){ return $this->getResponseInternalError("Données d'exportation incomplètes."); } $json = []; if( $id ){ $activity = $this->getActivityFromRoute(); $json = $this->getActivityService()->exportJson($activity); $json[] = $this->getActivityService()->exportJson($activity); } if( $ids ){ $ids = explode(',', $ids); $result = $this->getEntityManager()->createQueryBuilder()->select('a') ->from(Activity::class, 'a') ->where('a.id IN(:ids)') ->setParameter('ids', $ids) ->getQuery() ->getResult(); foreach ($result as $activity) { $json[] = $this->getActivityService()->exportJson($activity); } } // header('Content-Disposition: attachment; filename=activity-'.$activity->getOscarNum().'.json'); // header('Content-Length: ' . filesize('/tmp/' . $filename)); $filename = 'activity-json.json'; header('Content-Disposition: attachment; filename='.$filename); header('Content-type: application/json'); die(json_encode($json)); } Loading Loading @@ -378,6 +404,7 @@ class ProjectGrantController extends AbstractOscarController die(file_get_contents('/tmp/' . $filename)); } /** Export les données en CSV. */ public function csvAction() { Loading module/Oscar/view/oscar/project-grant/advanced-search.phtml +2 −2 Original line number Diff line number Diff line Loading @@ -433,11 +433,11 @@ </button> </form> <form action="<?= $this->url('contract/csv') ?>" class=" export-selection-area" style="display: none" method="post"> <form action="<?= $this->url('contract/exportjson') ?>" class=" export-selection-area" method="post"> <input type="hidden" name="ids" value="<?= $exportIds ?>"> <button type="submit" href="#" class="btn btn-primary"> <i class="icon-cube"></i> Exporter les <span class="total">X</span> activité(s) selectionée(s) Export JSON </button> </form> <hr /> Loading module/Oscar/src/Oscar/Controller/PersonController.php +1 −1 File changed.Contains only whitespace changes. Show changes Loading
module/Oscar/config/routes.yml +1 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,7 @@ contract: exportjson: type: segment options: route: /export-json/:id route: /export-json[/:id] defaults: action: exportJSON Loading
module/Oscar/src/Oscar/Controller/ProjectGrantController.php +31 −4 Original line number Diff line number Diff line Loading @@ -264,11 +264,37 @@ class ProjectGrantController extends AbstractOscarController public function exportJSONAction(){ $id = $this->params()->fromRoute('id', null); $ids = $this->params()->fromPost('ids', null); if( $id == null && $ids == null ){ return $this->getResponseInternalError("Données d'exportation incomplètes."); } $json = []; if( $id ){ $activity = $this->getActivityFromRoute(); $json = $this->getActivityService()->exportJson($activity); $json[] = $this->getActivityService()->exportJson($activity); } if( $ids ){ $ids = explode(',', $ids); $result = $this->getEntityManager()->createQueryBuilder()->select('a') ->from(Activity::class, 'a') ->where('a.id IN(:ids)') ->setParameter('ids', $ids) ->getQuery() ->getResult(); foreach ($result as $activity) { $json[] = $this->getActivityService()->exportJson($activity); } } // header('Content-Disposition: attachment; filename=activity-'.$activity->getOscarNum().'.json'); // header('Content-Length: ' . filesize('/tmp/' . $filename)); $filename = 'activity-json.json'; header('Content-Disposition: attachment; filename='.$filename); header('Content-type: application/json'); die(json_encode($json)); } Loading Loading @@ -378,6 +404,7 @@ class ProjectGrantController extends AbstractOscarController die(file_get_contents('/tmp/' . $filename)); } /** Export les données en CSV. */ public function csvAction() { Loading
module/Oscar/view/oscar/project-grant/advanced-search.phtml +2 −2 Original line number Diff line number Diff line Loading @@ -433,11 +433,11 @@ </button> </form> <form action="<?= $this->url('contract/csv') ?>" class=" export-selection-area" style="display: none" method="post"> <form action="<?= $this->url('contract/exportjson') ?>" class=" export-selection-area" method="post"> <input type="hidden" name="ids" value="<?= $exportIds ?>"> <button type="submit" href="#" class="btn btn-primary"> <i class="icon-cube"></i> Exporter les <span class="total">X</span> activité(s) selectionée(s) Export JSON </button> </form> <hr /> Loading
module/Oscar/src/Oscar/Controller/PersonController.php +1 −1 File changed.Contains only whitespace changes. Show changes