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

FEAT #10746 TIME 0:30 Get workflow for document

parent 9c1203d0
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,7 @@ $app->get('/documents', \Document\controllers\DocumentController::class . ':get'
$app->get('/documents/{id}', \Document\controllers\DocumentController::class . ':getById');
$app->get('/documents/{id}/history', \History\controllers\HistoryController::class . ':getByDocumentId');
$app->put('/documents/{id}/actions/{actionId}', \Document\controllers\DocumentController::class . ':setAction');
$app->get('/documents/{id}/workflow', \Workflow\controllers\WorkflowController::class . ':getByDocumentId');
//Languages
$app->get('/languages/{lang}', \SrcCore\controllers\LanguageController::class . ':getByLang');
......
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Workflow Controller
* @author dev@maarch.org
*/
namespace Workflow\controllers;
use Document\controllers\DocumentController;
use Slim\Http\Request;
use Slim\Http\Response;
use User\controllers\UserController;
use User\models\UserModel;
use Workflow\models\WorkflowModel;
class WorkflowController
{
public function getByDocumentId(Request $request, Response $response, array $args)
{
if (!DocumentController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id']]) && !UserController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_documents'])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
}
$rawWorkflow = WorkflowModel::getByDocumentId(['select' => ['*'], 'documentId' => $args['id'], 'orderBy' => ['"order"']]);
$workflow = [];
foreach ($rawWorkflow as $value) {
$workflow[] = [
'userId' => $value['user_id'],
'userDisplay' => UserModel::getLabelledUserById(['id' => $value['user_id']]),
'mode' => $value['mode'],
'order' => $value['order'],
'status' => $value['status'],
'note' => $value['note'],
'processDate' => $value['process_date'],
];
}
return $response->withJson(['workflow' => $workflow]);
}
}
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