Travel reimburse feature added
This commit is contained in:
51
pub/api/v1/office/travel-reimburse/configure/index.php
Normal file
51
pub/api/v1/office/travel-reimburse/configure/index.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use api\classes\API_portalsettings;
|
||||
use api\classes\API_office_travel_reimburse;
|
||||
|
||||
session_start();
|
||||
|
||||
require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_portalsettings.php";
|
||||
require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_office_travel_reimburse.php";
|
||||
|
||||
|
||||
$API_portalsettings = new API_portalsettings();
|
||||
|
||||
if (!$GLOBALS['modules_enabled']['office']) {
|
||||
echo '405 Not Allowed';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($API_portalsettings->request_method === 'GET') {
|
||||
$API_portalsettings->checkPermissions('office-travel-reimburse', 'RO');
|
||||
|
||||
$travel_reimbursements = $API_portalsettings->getTravelReimburseSettings();
|
||||
|
||||
$API_portalsettings->apiOutput($code = 200, $travel_reimbursements);
|
||||
|
||||
} elseif ($API_portalsettings->request_method === 'PUT') {
|
||||
|
||||
$API_portalsettings->checkPermissions('admin-portalsettings', 'RW');
|
||||
|
||||
$API_office_travel_reimburse = new API_office_travel_reimburse();
|
||||
|
||||
# Edit the portal settings of the platform
|
||||
$requiredFields = [
|
||||
'office_travelreimburse_cents_homework_incl' => ['type' => 'int'],
|
||||
'office_travelreimburse_cents_homework_excl' => ['type' => 'int'],
|
||||
'office_travelreimburse_cents_business_incl' => ['type' => 'int'],
|
||||
'office_travelreimburse_cents_business_excl' => ['type' => 'int'],
|
||||
'portal_uuid' => ['type' => 'uuid'],
|
||||
];
|
||||
|
||||
if (count($API_portalsettings->getPortalSettings()) !== 1) {
|
||||
$API_portalsettings->apiOutput(400, ['error' => 'Invalid portal_uuid']);
|
||||
}
|
||||
|
||||
$API_portalsettings->validateData($requiredFields);
|
||||
|
||||
# Update the permission
|
||||
$API_portalsettings->updatePortalSettingsOfficeTravelReimburse();
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user