26if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL', 1);
29if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32if (!defined(
'NOREQUIREHTML')) {
33 define(
'NOREQUIREHTML',
'1');
35if (!defined(
'NOREQUIREAJAX')) {
36 define(
'NOREQUIREAJAX',
'1');
38if (!defined(
'NOREQUIRESOC')) {
39 define(
'NOREQUIRESOC',
'1');
42require
'../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport_ik.class.php';
55$langs->loadlangs(array(
'errors',
'trips'));
58$fk_c_exp_tax_cat =
GETPOSTINT(
'fk_c_exp_tax_cat');
63$result =
restrictedArea($user,
'expensereport', $fk_expense,
'expensereport');
73$rep->response_status = 0;
75$rep->errorMessage =
'';
78if (empty($fk_expense) || $fk_expense < 0) {
79 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorBadValueForParameter', $fk_expense,
'fk_expense');
80} elseif (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) {
81 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorBadValueForParameter', $fk_c_exp_tax_cat,
'fk_c_exp_tax_cat');
83 $rep->response_status =
'error';
87 if ($expense->fetch($fk_expense) <= 0) {
88 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorRecordNotFound');
89 $rep->response_status =
'error';
91 $userauthor =
new User($db);
92 if ($userauthor->fetch($expense->fk_user_author) <= 0) {
93 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorRecordNotFound');
94 $rep->response_status =
'error';
97 $result = $expense->fetch($fk_expense);
99 $result = $expense->computeTotalKm($fk_c_exp_tax_cat, $qty, $vatrate);
101 $rep->errorMessage = $langs->trans(
'errorComputeTtcOnMileageExpense');
102 $rep->response_status =
'error';
104 $rep->data = $result;
105 $rep->response_status =
'success';
111echo json_encode($rep);
Class to manage Trips and Expenses.
Class to manage Dolibarr users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.