php-mpos/public/include/pages/api/getusertransactions.inc.php
Sebastian Grewe d4557982ba [FIX] API call for transactions
Fixes #1602 once merged.
2014-01-27 09:13:09 +01:00

33 lines
813 B
PHP

<?php
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
// Check if the API is activated
$api->isActive();
// Check user token
$user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']);
// Fetch transactions
if (isset($_REQUEST['limit']) && $_REQUEST['limit'] < 30) {
$limit = $_REQUEST['limit'];
} else {
// Force limit
$limit = 5;
}
$data['transactions'] = $transaction->getTransactions(0, NULL, 30, $user_id);
// Fetch summary if enabled
if (!$setting->getValue('disable_transactionsummary')) {
$aTransactionSummary = $transaction->getTransactionSummary($user_id);
$data['transactionsummary'] = $aTransactionSummary;
}
// Output JSON format
echo $api->get_json($data);
// Supress master template
$supress_master = 1;
?>