* Copyright (C) 2017 ATM Consulting * Copyright (C) 2017 Pierre-Henry Favre * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/expensereport_ik.php * \ingroup expensereport * \brief Page to display expense tax ik */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); $error = 0; $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); $ikoffset = GETPOST('ikoffset', 'int'); $coef = GETPOST('coef', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); $fk_range = GETPOST('fk_range', 'int'); $expIk = new ExpenseReportIk($db); if (!$user->admin) { accessforbidden(); } /* * Actions */ if ($action == 'updateik') { if ($id > 0) { $result = $expIk->fetch($id); if ($result < 0) { dol_print_error('', $expIk->error, $expIk->errors); } } $expIk->setValues($_POST); $result = $expIk->create($user); if ($result > 0) { setEventMessages('SetupSaved', null, 'mesgs'); header('Location: '.$_SERVER['PHP_SELF']); exit; } else { setEventMessages($expIk->error, $expIk->errors, 'errors'); } } elseif ($action == 'delete') { // TODO add confirm if ($id > 0) { $result = $expIk->fetch($id); if ($result < 0) { dol_print_error('', $expIk->error, $expIk->errors); } $expIk->delete($user); } header('Location: '.$_SERVER['PHP_SELF']); exit; } $rangesbycateg = $expIk->getAllRanges(); /* * View */ llxHeader('', $langs->trans("ExpenseReportsSetup")); $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); print dol_get_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip'); echo ''.$langs->trans('ExpenseReportIkDesc').''; print '

'; echo '
'; echo ''; if ($action == 'edit') { echo ''; echo ''; echo ''; echo ''; } echo ''; foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) { $title = ($Tab['active'] == 1) ? $langs->trans($Tab['label']) : $form->textwithpicto($langs->trans($Tab['label']), $langs->trans('expenseReportCatDisabled'), 1, 'help', '', 0, 3); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if ($Tab['active'] == 0) { continue; } $tranche = 1; foreach ($Tab['ranges'] as $k => $range) { if (isset($Tab['ranges'][$k + 1])) { $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k + 1]->range_ik - 1)); } else { $label = $langs->trans('expenseReportRangeMoreThan', $range->range_ik); } if ($range->range_active == 0) { $label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3); } echo ''; // Label echo ''; // Offset echo ''; // Coef echo ''; // Total for one echo ''; // Action echo ''; echo ''; } } echo '
'.$title.''.$langs->trans('expenseReportOffset').''.$langs->trans('expenseReportCoef').''.$langs->trans('expenseReportTotalForFive').' 
['.$langs->trans('RangeNum', $tranche++).'] - '.$label.''; if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) { echo ''; } else { echo $range->ik->ikoffset; } echo ''; if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) { echo ''; } else { echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); } echo ''.$langs->trans('expenseReportPrintExample', price($range->ik->ikoffset + 5 * $range->ik->coef)).''; if ($range->range_active == 1) { if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) { echo ''; echo ''; } else { echo ''.img_edit().''; if (!empty($range->ik->id)) { echo ''.img_delete().''; } // TODO add delete link } } echo '
'; echo '
'; print dol_get_fiche_end(); // End of page llxFooter(); $db->close();