Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
95dfcf4c
Commit
95dfcf4c
authored
5 years ago
by
Guillaume Heurtier
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #13049 TIME 0:30 added preprocess close with fields
parent
38b7b9f2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rest/index.php
+1
-0
1 addition, 0 deletions
rest/index.php
src/app/action/controllers/PreProcessActionController.php
+81
-0
81 additions, 0 deletions
src/app/action/controllers/PreProcessActionController.php
with
82 additions
and
0 deletions
rest/index.php
+
1
−
0
View file @
95dfcf4c
...
...
@@ -413,6 +413,7 @@ $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/ac
$app
->
post
(
'/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkGiveParallelOpinion'
,
\Action\controllers\PreProcessActionController
::
class
.
':checkGiveParallelOpinion'
);
$app
->
post
(
'/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkRejectVisa'
,
\Action\controllers\PreProcessActionController
::
class
.
':checkRejectVisa'
);
$app
->
post
(
'/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkInterruptResetVisa'
,
\Action\controllers\PreProcessActionController
::
class
.
':checkInterruptResetVisa'
);
$app
->
post
(
'/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkCloseWithFieldsAction'
,
\Action\controllers\PreProcessActionController
::
class
.
':checkCloseWithFieldsAction'
);
//Search
$app
->
get
(
'/search'
,
\Search\controllers\SearchController
::
class
.
':get'
);
...
...
This diff is collapsed.
Click to expand it.
src/app/action/controllers/PreProcessActionController.php
+
81
−
0
View file @
95dfcf4c
...
...
@@ -13,18 +13,21 @@
namespace
Action\controllers
;
use
AcknowledgementReceipt\models\AcknowledgementReceiptModel
;
use
Action\models\ActionModel
;
use
Attachment\models\AttachmentModel
;
use
Basket\models\BasketModel
;
use
Basket\models\GroupBasketRedirectModel
;
use
Contact\controllers\ContactController
;
use
Contact\models\ContactModel
;
use
Convert\controllers\ConvertPdfController
;
use
CustomField\models\CustomFieldModel
;
use
Docserver\models\DocserverModel
;
use
Doctype\models\DoctypeModel
;
use
Entity\models\EntityModel
;
use
Entity\models\ListInstanceModel
;
use
ExternalSignatoryBook\controllers\MaarchParapheurController
;
use
Group\models\GroupModel
;
use
IndexingModel\models\IndexingModelFieldModel
;
use
Note\models\NoteModel
;
use
Parameter\models\ParameterModel
;
use
Resource\controllers\ResController
;
...
...
@@ -1340,6 +1343,84 @@ class PreProcessActionController
return
$response
->
withJson
([
'isDestinationChanging'
=>
$changeDestination
]);
}
public
static
function
checkCloseWithFieldsAction
(
Request
$request
,
Response
$response
,
array
$args
)
{
$body
=
$request
->
getParsedBody
();
if
(
!
Validator
::
arrayType
()
->
notEmpty
()
->
validate
(
$body
[
'resources'
]))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Body resources is empty or not an array'
]);
}
$errors
=
ResourceListController
::
listControl
([
'groupId'
=>
$args
[
'groupId'
],
'userId'
=>
$args
[
'userId'
],
'basketId'
=>
$args
[
'basketId'
],
'currentUserId'
=>
$GLOBALS
[
'id'
]]);
if
(
!
empty
(
$errors
[
'errors'
]))
{
return
$response
->
withStatus
(
$errors
[
'code'
])
->
withJson
([
'errors'
=>
$errors
[
'errors'
]]);
}
$body
[
'resources'
]
=
array_slice
(
$body
[
'resources'
],
0
,
500
);
if
(
!
ResController
::
hasRightByResId
([
'resId'
=>
$body
[
'resources'
],
'userId'
=>
$GLOBALS
[
'id'
]]))
{
return
$response
->
withStatus
(
403
)
->
withJson
([
'errors'
=>
'Document out of perimeter'
]);
}
$body
[
'resources'
]
=
PreProcessActionController
::
getNonLockedResources
([
'resources'
=>
$body
[
'resources'
],
'userId'
=>
$GLOBALS
[
'id'
]]);
$action
=
ActionModel
::
getById
([
'id'
=>
$args
[
'actionId'
],
'select'
=>
[
'required_fields'
]]);
if
(
empty
(
$action
))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Action does not exist'
]);
}
$actionRequiredFields
=
json_decode
(
$action
[
'required_fields'
]);
$canClose
=
[];
$emptyFields
=
[];
foreach
(
$body
[
'resources'
]
as
$resId
)
{
if
(
!
empty
(
$actionRequiredFields
))
{
$resource
=
ResModel
::
getById
([
'resId'
=>
$resId
,
'select'
=>
[
'model_id'
,
'custom_fields'
,
'alt_identifier'
]]);
$model
=
$resource
[
'model_id'
];
$resourceCustomFields
=
json_decode
(
$resource
[
'custom_fields'
],
true
);
$modelFields
=
IndexingModelFieldModel
::
get
([
'select'
=>
[
'identifier'
],
'where'
=>
[
'model_id = ?'
,
"identifier LIKE 'indexingCustomField_%'"
],
'data'
=>
[
$model
]
]);
$modelFields
=
array_column
(
$modelFields
,
'identifier'
);
$emptyList
=
[];
foreach
(
$actionRequiredFields
as
$actionRequiredField
)
{
$idCustom
=
explode
(
"_"
,
$actionRequiredField
)[
1
];
if
(
in_array
(
$actionRequiredField
,
$modelFields
)
&&
empty
(
$resourceCustomFields
[
$idCustom
]))
{
$emptyList
[]
=
$idCustom
;
}
}
if
(
!
empty
(
$emptyList
))
{
$fieldsList
=
[];
$customs
=
CustomFieldModel
::
get
([
'select'
=>
[
'label'
],
'where'
=>
[
'id in (?)'
],
'data'
=>
[
$emptyList
]
]);
foreach
(
$customs
as
$custom
)
{
$fieldsList
[]
=
$custom
[
'label'
];
}
$emptyFields
[]
=
[
'chrono'
=>
$resource
[
'alt_identifier'
],
'fields'
=>
!
empty
(
$fieldsList
)
?
implode
(
", "
,
$fieldsList
)
:
''
];
}
else
{
$canClose
[]
=
$resId
;
}
}
else
{
$canClose
[]
=
$resId
;
}
}
return
$response
->
withJson
([
'emptyFields'
=>
$emptyFields
,
'canClose'
=>
$canClose
]);
}
private
static
function
getNonLockedResources
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'resources'
,
'userId'
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment