25if (!defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL', 1);
28if (!defined(
'NOREQUIREMENU')) {
29 define(
'NOREQUIREMENU',
'1');
31if (!defined(
'NOREQUIREHTML')) {
32 define(
'NOREQUIREHTML',
'1');
34if (!defined(
'NOREQUIREAJAX')) {
35 define(
'NOREQUIREAJAX',
'1');
37if (!defined(
'NOREQUIRESOC')) {
38 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';
47$langs->loadlangs(array(
'errors',
'trips'));
50$fk_c_exp_tax_cat =
GETPOSTINT(
'fk_c_exp_tax_cat');
55$result =
restrictedArea($user,
'expensereport', $fk_expense,
'expensereport');
65$rep->response_status = 0;
67$rep->errorMessage =
'';
70if (empty($fk_expense) || $fk_expense < 0) {
71 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorBadValueForParameter', $fk_expense,
'fk_expense');
72} elseif (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) {
73 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorBadValueForParameter', $fk_c_exp_tax_cat,
'fk_c_exp_tax_cat');
75 $rep->response_status =
'error';
79 if ($expense->fetch($fk_expense) <= 0) {
80 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorRecordNotFound');
81 $rep->response_status =
'error';
83 $userauthor =
new User($db);
84 if ($userauthor->fetch($expense->fk_user_author) <= 0) {
85 $rep->errorMessage = $langs->transnoentitiesnoconv(
'ErrorRecordNotFound');
86 $rep->response_status =
'error';
89 $result = $expense->fetch($fk_expense);
91 $result = $expense->computeTotalKm($fk_c_exp_tax_cat, $qty, $vatrate);
93 $rep->errorMessage = $langs->trans(
'errorComputeTtcOnMileageExpense');
94 $rep->response_status =
'error';
97 $rep->response_status =
'success';
103echo 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.