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
306fadb2
Commit
306fadb2
authored
5 years ago
by
Guillaume Heurtier
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #12072 TIME 0:45 get shippings by res id
parent
d8069841
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rest/index.php
+1
-0
1 addition, 0 deletions
rest/index.php
src/app/shipping/controllers/ShippingController.php
+70
-0
70 additions, 0 deletions
src/app/shipping/controllers/ShippingController.php
src/app/shipping/models/ShippingModel.php
+19
-0
19 additions, 0 deletions
src/app/shipping/models/ShippingModel.php
with
90 additions
and
0 deletions
rest/index.php
+
1
−
0
View file @
306fadb2
...
...
@@ -363,6 +363,7 @@ $app->post('/resources/{resId}/linkedResources', \Resource\controllers\LinkContr
$app
->
delete
(
'/resources/{resId}/linkedResources/{id}'
,
\Resource\controllers\LinkController
::
class
.
':unlinkResources'
);
$app
->
put
(
'/resources/{resId}/unsign'
,
\SignatureBook\controllers\SignatureBookController
::
class
.
':unsignResource'
);
$app
->
get
(
'/resources/{resId}/acknowledgementReceipts'
,
\AcknowledgementReceipt\controllers\AcknowledgementReceiptController
::
class
.
':get'
);
$app
->
get
(
'/resources/{resId}/shippings'
,
\Shipping\controllers\ShippingController
::
class
.
':get'
);
$app
->
get
(
'/res/{resId}/acknowledgementReceipt/{id}'
,
\AcknowledgementReceipt\controllers\AcknowledgementReceiptController
::
class
.
':getAcknowledgementReceipt'
);
$app
->
put
(
'/res/resource/status'
,
\Resource\controllers\ResController
::
class
.
':updateStatus'
);
...
...
This diff is collapsed.
Click to expand it.
src/app/shipping/controllers/ShippingController.php
0 → 100644
+
70
−
0
View file @
306fadb2
<?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 Shipping Controller
* @author dev@maarch.org
*/
namespace
Shipping\controllers
;
use
Attachment\models\AttachmentModel
;
use
Entity\models\EntityModel
;
use
Resource\controllers\ResController
;
use
Respect\Validation\Validator
;
use
Shipping\models\ShippingModel
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
use
User\models\UserModel
;
class
ShippingController
{
public
static
function
get
(
Request
$request
,
Response
$response
,
array
$args
)
{
if
(
!
Validator
::
intVal
()
->
validate
(
$args
[
'resId'
])
||
!
ResController
::
hasRightByResId
([
'resId'
=>
[
$args
[
'resId'
]],
'userId'
=>
$GLOBALS
[
'id'
]]))
{
return
$response
->
withStatus
(
403
)
->
withJson
([
'errors'
=>
'Document out of perimeter'
]);
}
$attachments
=
AttachmentModel
::
get
([
'select'
=>
[
'res_id'
],
'where'
=>
[
'res_id_master = ?'
],
'data'
=>
[
$args
[
'resId'
]]
]);
$attachments
=
array_column
(
$attachments
,
'res_id'
);
$shippingsModel
=
ShippingModel
::
get
([
'select'
=>
[
'*'
],
'where'
=>
[
'(document_id = ? and document_type = ?) or (document_id in (?) and document_type = ?)'
],
'data'
=>
[
$args
[
'resId'
],
'resource'
,
$attachments
,
'attachment'
]
]);
$shippings
=
[];
foreach
(
$shippingsModel
as
$shipping
)
{
$recipientEntityLabel
=
EntityModel
::
getById
([
'id'
=>
$shipping
[
'recipient_entity_id'
],
'select'
=>
[
'entity_label'
]]);
$recipientEntityLabel
=
$recipientEntityLabel
[
'entity_label'
];
$userLabel
=
UserModel
::
getLabelledUserById
([
'id'
=>
$shipping
[
'user_id'
]]);
$shippings
[]
=
[
'id'
=>
$shipping
[
'id'
],
'documentId'
=>
$shipping
[
'document_id'
],
'documentType'
=>
$shipping
[
'document_type'
],
'userId'
=>
$shipping
[
'user_id'
],
'userLabel'
=>
$userLabel
,
'fee'
=>
$shipping
[
'fee'
],
'recipientEntityId'
=>
$shipping
[
'recipient_entity_id'
],
'recipientEntityLabel'
=>
$recipientEntityLabel
];
}
return
$response
->
withJson
(
$shippings
);
}
}
This diff is collapsed.
Click to expand it.
src/app/shipping/models/ShippingModel.php
+
19
−
0
View file @
306fadb2
...
...
@@ -41,4 +41,23 @@ class ShippingModel
return
true
;
}
public
static
function
get
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'select'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'select'
,
'where'
,
'data'
,
'orderBy'
]);
ValidatorModel
::
intType
(
$args
,
[
'limit'
]);
$contacts
=
DatabaseModel
::
select
([
'select'
=>
$args
[
'select'
],
'table'
=>
[
'shippings'
],
'where'
=>
empty
(
$args
[
'where'
])
?
[]
:
$args
[
'where'
],
'data'
=>
empty
(
$args
[
'data'
])
?
[]
:
$args
[
'data'
],
'order_by'
=>
empty
(
$args
[
'orderBy'
])
?
[]
:
$args
[
'orderBy'
],
'offset'
=>
empty
(
$args
[
'offset'
])
?
0
:
$args
[
'offset'
],
'limit'
=>
empty
(
$args
[
'limit'
])
?
0
:
$args
[
'limit'
]
]);
return
$contacts
;
}
}
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