Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
900ca5a1
Commit
900ca5a1
authored
Sep 23, 2017
by
Karamel
Browse files
Add get ticket route.
parent
81b40812
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/http/routes/ticket.php
View file @
900ca5a1
...
...
@@ -6,6 +6,33 @@ use \Pasteque\Server\System\API\APICaller;
use
\
Pasteque\Server\System\API\APIResult
;
use
\
Pasteque\Server\System\DAO\DAOCondition
;
/** Get a single ticket. */
$app
->
GET
(
'/api/ticket/{cashregister}/{number}'
,
function
(
$request
,
$response
,
$args
)
{
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
$cashRes
=
APICaller
::
run
(
$ptApp
,
'cashRegister'
,
'get'
,
$args
[
'cashregister'
]);
if
(
$cashRes
->
getStatus
()
!=
APIResult
::
STATUS_CALL_OK
)
{
return
$response
->
withApiResult
(
$cashRes
);
}
$cashRegister
=
$cashRes
->
getContent
();
if
(
$cashRegister
===
null
)
{
return
$response
->
withStatus
(
404
,
'Cash register not found'
);
}
$apiRes
=
APICaller
::
run
(
$ptApp
,
'ticket'
,
'search'
,
[
new
DAOCondition
(
'cashRegister'
,
'='
,
$cashRegister
),
new
DAOCondition
(
'number'
,
'='
,
$args
[
'number'
])]);
if
(
$apiRes
->
getStatus
()
==
APIResult
::
STATUS_CALL_OK
)
{
$ticket
=
$apiRes
->
getContent
();
if
(
count
(
$ticket
)
>
0
)
{
return
$response
->
withAPIResult
(
APIResult
::
success
(
$ticket
[
0
]));
}
else
{
$response
->
withStatus
(
404
,
'Ticket not found'
);
}
}
return
$response
->
withApiResult
(
$apiRes
);
});
/** Get tickets from a session. */
$app
->
GET
(
'/api/ticket/session/{cashregister}/{sequence}'
,
function
(
$request
,
$response
,
$args
)
{
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment