Add date search ability to action.php transactionsearch

master
Skylar Ittner 6 years ago
parent 9e6d4dfa0a
commit a5f369fe00

@ -328,16 +328,25 @@ switch ($VARS['action']) {
break;
case "transactionsearch":
header("Content-Type: application/json");
if (!is_empty($VARS['q'])) {
$where = [];
if (!empty($VARS['q'])) {
$where["AND"]["OR"] = [
"txid" => $VARS['q'],
"name[~]" => $VARS['q'],
"email[~]" => $VARS['q'],
"phone[~]" => $VARS['q']
];
} else {
exit(json_encode(["status" => "ERROR", "transactions" => false]));
}
$start = date('Y-m-d H:i:s', 946684800); // Jan 1 2000
$end = date('Y-m-d H:i:s');
if (!empty($VARS['start']) && strtotime($VARS['start']) !== FALSE) {
$start = date('Y-m-d H:i:s', strtotime($VARS['start']));
}
if (!empty($VARS['end']) && strtotime($VARS['end']) !== FALSE) {
$end = date('Y-m-d H:i:s', strtotime($VARS['end']));
}
$where["AND"]['txdate[>=]'] = $start;
$where["AND"]['txdate[<=]'] = $end;
$where["LIMIT"] = 50;
$transactions = $database->select('transactions', [

Loading…
Cancel
Save