Skip to content
Snippets Groups Projects
Verified Commit 9ffdf037 authored by Damien's avatar Damien
Browse files

FEAT #39 Refactoring reports

parent ee6d66e9
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"History\\" : "src/app/history/", "History\\" : "src/app/history/",
"Parameter\\" : "src/app/parameter/", "Parameter\\" : "src/app/parameter/",
"Priority\\" : "src/app/priority/", "Priority\\" : "src/app/priority/",
"Report\\" : "src/app/report/",
"Resource\\" : "src/app/resource/", "Resource\\" : "src/app/resource/",
"Status\\" : "src/app/status/", "Status\\" : "src/app/status/",
......
...@@ -118,8 +118,8 @@ $app->get('/administration/notifications/{id}', \Notifications\Controllers\Notif ...@@ -118,8 +118,8 @@ $app->get('/administration/notifications/{id}', \Notifications\Controllers\Notif
//Baskets //Baskets
$app->get('/baskets', \Basket\controllers\BasketController::class . ':get'); $app->get('/baskets', \Basket\controllers\BasketController::class . ':get');
$app->get('/baskets/{id}', \Basket\controllers\BasketController::class . ':getById');
$app->post('/baskets', \Basket\controllers\BasketController::class . ':create'); $app->post('/baskets', \Basket\controllers\BasketController::class . ':create');
$app->get('/baskets/{id}', \Basket\controllers\BasketController::class . ':getById');
$app->put('/baskets/{id}', \Basket\controllers\BasketController::class . ':update'); $app->put('/baskets/{id}', \Basket\controllers\BasketController::class . ':update');
$app->delete('/baskets/{id}', \Basket\controllers\BasketController::class . ':delete'); $app->delete('/baskets/{id}', \Basket\controllers\BasketController::class . ':delete');
$app->get('/baskets/{id}/groups', \Basket\controllers\BasketController::class . ':getGroups'); $app->get('/baskets/{id}/groups', \Basket\controllers\BasketController::class . ':getGroups');
...@@ -132,11 +132,11 @@ $app->put('/sortedBaskets/{id}', \Basket\controllers\BasketController::class . ' ...@@ -132,11 +132,11 @@ $app->put('/sortedBaskets/{id}', \Basket\controllers\BasketController::class . '
//statuses //statuses
$app->get('/statuses', \Status\controllers\StatusController::class . ':get'); $app->get('/statuses', \Status\controllers\StatusController::class . ':get');
$app->get('/administration/statuses/new', \Status\controllers\StatusController::class . ':getNewInformations');
$app->get('/statuses/{identifier}', \Status\controllers\StatusController::class . ':getByIdentifier');
$app->post('/statuses', \Status\controllers\StatusController::class . ':create'); $app->post('/statuses', \Status\controllers\StatusController::class . ':create');
$app->get('/statuses/{identifier}', \Status\controllers\StatusController::class . ':getByIdentifier');
$app->put('/statuses/{identifier}', \Status\controllers\StatusController::class . ':update'); $app->put('/statuses/{identifier}', \Status\controllers\StatusController::class . ':update');
$app->delete('/statuses/{identifier}', \Status\controllers\StatusController::class . ':delete'); $app->delete('/statuses/{identifier}', \Status\controllers\StatusController::class . ':delete');
$app->get('/administration/statuses/new', \Status\controllers\StatusController::class . ':getNewInformations');
//groups //groups
$app->get('/groups', \Core\Controllers\GroupController::class . ':get'); $app->get('/groups', \Core\Controllers\GroupController::class . ':get');
...@@ -220,11 +220,11 @@ $app->put('/priorities/{id}', \Priority\controllers\PriorityController::class . ...@@ -220,11 +220,11 @@ $app->put('/priorities/{id}', \Priority\controllers\PriorityController::class .
$app->delete('/priorities/{id}', \Priority\controllers\PriorityController::class . ':delete'); $app->delete('/priorities/{id}', \Priority\controllers\PriorityController::class . ':delete');
//History //History
$app->get('/administration/history/eventDate/{date}', \History\controllers\HistoryController::class . ':getForAdministration'); $app->get('/administration/history/eventDate/{date}', \History\controllers\HistoryController::class . ':getForAdministration'); //TODO No date
$app->get('/histories/users/{userSerialId}', \History\controllers\HistoryController::class . ':getByUserId'); $app->get('/histories/users/{userSerialId}', \History\controllers\HistoryController::class . ':getByUserId');
//HistoryBatch //HistoryBatch
$app->get('/administration/historyBatch/eventDate/{date}', \History\controllers\HistoryController::class . ':getBatchForAdministration'); $app->get('/administration/historyBatch/eventDate/{date}', \History\controllers\HistoryController::class . ':getBatchForAdministration');//TODO No date
//actions //actions
$app->get('/actions', \Action\controllers\ActionController::class . ':get'); $app->get('/actions', \Action\controllers\ActionController::class . ':get');
...@@ -242,8 +242,8 @@ $app->put('/notifications/{id}', \Notifications\Controllers\NotificationControll ...@@ -242,8 +242,8 @@ $app->put('/notifications/{id}', \Notifications\Controllers\NotificationControll
$app->delete('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':delete'); $app->delete('/notifications/{id}', \Notifications\Controllers\NotificationController::class . ':delete');
//Reports //Reports
$app->get('/reports/groups/{groupId}', \Core\Controllers\ReportController::class . ':getByGroupId'); $app->get('/reports/groups/{groupId}', \Report\controllers\ReportController::class . ':getByGroupId');
$app->put('/reports/groups/{groupId}', \Core\Controllers\ReportController::class . ':updateForGroupId'); $app->put('/reports/groups/{groupId}', \Report\controllers\ReportController::class . ':updateForGroupId');
//Listinstance //Listinstance
$app->get('/listinstance/{id}', \Core\Controllers\ListinstanceController::class . ':getById'); $app->get('/listinstance/{id}', \Core\Controllers\ListinstanceController::class . ':getById');
...@@ -258,6 +258,6 @@ $app->post('/templates/{id}/duplicate', \Templates\Controllers\TemplateControlle ...@@ -258,6 +258,6 @@ $app->post('/templates/{id}/duplicate', \Templates\Controllers\TemplateControlle
$app->get('/links/resId/{resId}', \Core\Controllers\LinkController::class . ':getByResId'); $app->get('/links/resId/{resId}', \Core\Controllers\LinkController::class . ':getByResId');
//liste documents //liste documents
$app->get('/res/listDocs/{clause}/{select}', \Core\Controllers\ResController::class . ':getListDocs'); $app->get('/res/listDocs/{clause}/{select}', \Resource\controllers\ResController::class . ':getListDocs');//TODO No clause
$app->run(); $app->run();
...@@ -10,23 +10,22 @@ ...@@ -10,23 +10,22 @@
/** /**
* @brief Report Controller * @brief Report Controller
* @author dev@maarch.org * @author dev@maarch.org
* @ingroup core
*/ */
namespace Core\Controllers; namespace Report\controllers;
use Core\Models\GroupModel; use Core\Models\GroupModel;
use Core\Models\ServiceModel; use Core\Models\ServiceModel;
use Psr\Http\Message\RequestInterface; use Report\models\ReportModel;
use Psr\Http\Message\ResponseInterface; use Slim\Http\Request;
use Core\Models\ReportModel; use Slim\Http\Response;
class ReportController class ReportController
{ {
public function getByGroupId(RequestInterface $request, ResponseInterface $response, $aArgs) public function getByGroupId(Request $request, Response $response, array $aArgs)
{ {
if (!ServiceModel::hasService(['id' => 'admin_reports', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { if (!ServiceModel::hasService(['id' => 'admin_reports', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
} }
...@@ -40,9 +39,9 @@ class ReportController ...@@ -40,9 +39,9 @@ class ReportController
return $response->withJson(['reports' => $reports]); return $response->withJson(['reports' => $reports]);
} }
public function updateForGroupId(RequestInterface $request, ResponseInterface $response, $aArgs) public function updateForGroupId(Request $request, Response $response, array $aArgs)
{ {
if (!ServiceModel::hasService(['id' => 'admin_reports', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { if (!ServiceModel::hasService(['id' => 'admin_reports', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
} }
...@@ -75,7 +74,7 @@ class ReportController ...@@ -75,7 +74,7 @@ class ReportController
ReportModel::deleteForGroupId(['groupId' => $aArgs['groupId'], 'reportIds' => $reportIdsToDelete]); ReportModel::deleteForGroupId(['groupId' => $aArgs['groupId'], 'reportIds' => $reportIdsToDelete]);
} }
return $response->withJson(['success' => _SAVED_CHANGE]); return $response->withJson(['success' => 'success']);
} }
} }
...@@ -8,14 +8,12 @@ ...@@ -8,14 +8,12 @@
*/ */
/** /**
* @brief Attachment Model * @brief Report Model
* @author dev@maarch.org * @author dev@maarch.org
* @ingroup core
*/ */
namespace Core\Models; namespace Report\models;
class ReportModel extends ReportModelAbstract class ReportModel extends ReportModelAbstract
{ {
// Do your stuff in this class
} }
...@@ -8,12 +8,15 @@ ...@@ -8,12 +8,15 @@
*/ */
/** /**
* @brief Reports Model * @brief Report Model Abstract
* @author dev@maarch.org * @author dev@maarch.org
* @ingroup core
*/ */
namespace Core\Models; namespace Report\models;
use Core\Models\CoreConfigModel;
use Core\Models\DatabaseModel;
use Core\Models\ValidatorModel;
class ReportModelAbstract class ReportModelAbstract
{ {
...@@ -30,21 +33,21 @@ class ReportModelAbstract ...@@ -30,21 +33,21 @@ class ReportModelAbstract
} }
$reports = []; $reports = [];
$xmlfile = simplexml_load_file($path);
$xmlfile = simplexml_load_file($path);
if ($xmlfile) { if ($xmlfile) {
foreach ($xmlfile->REPORT as $value) { foreach ($xmlfile->REPORT as $value) {
if ((string)$value->ENABLED == "true") { if ((string)$value->ENABLED == "true") {
$reports[] = [ $reports[] = [
'id' => (string)$value->ID, 'id' => (string)$value->ID,
'label' => constant((string)$value->LABEL), 'label' => constant((string)$value->LABEL),
'desc' => constant((string)$value->DESCRIPTION), 'desc' => constant((string)$value->DESCRIPTION),
'url' => (string)$value->URL, 'url' => (string)$value->URL,
'in_menu_reports' =>(string)$value->IN_MENU_REPORTS, 'in_menu_reports' => (string)$value->IN_MENU_REPORTS,
'origin' => (string)$value->ORIGIN, 'origin' => (string)$value->ORIGIN,
'module' => (string)$value->MODULE, 'module' => (string)$value->MODULE,
'module_label' => (string)$value->MODULE_LABEL, 'module_label' => (string)$value->MODULE_LABEL,
'checked' => false 'checked' => false
]; ];
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment