Example #1
0
                $reportID = intval($_REQUEST['reportID']);
                $status = $_REQUEST['status'];
                $mine = intval($_REQUEST['mine']);
                $entity = intval($_REQUEST['entity']) > 1 ? intval($_REQUEST['entity']) : null;
                $templateID = intval($_REQUEST['templateID']);
                $period = intval($_REQUEST['period']);
                if (!in_array($status, ['Approved', 'Rejected', 'Not Approved'])) {
                    exit(json_encode(['success' => false, 'message' => 'Please select a valid status.']));
                }
                $dbaccess->approveSubmission($reportID, $status, $mine, $entity, $templateID, $period);
                print json_encode($dbaccess->getSubmittedReports(date('Y')));
            } else {
                print json_encode(['success' => false, 'message' => 'You do not have permission to approve or reject a submission.']);
            }
            break;
        case 'download-receipt':
            $id = $_REQUEST['id'];
            \ZP\ZP::downloadItem($id);
            break;
        case 'delete-receipt':
            $id = $_REQUEST['id'];
            if (strlen(trim($id))) {
                $dbaccess->deleteReceipt($id);
            } else {
                print json_encode(['success' => false, 'error' => 'Please ensure you select a valid receipt']);
            }
            break;
        default:
            print json_encode(["success" => false, 'exception' => 'Invalid action']);
    }
}