Fix Expense report | VAT disable in Dolibarr, traduction of code_libelle & presentation

This commit is contained in:
aspangaro 2016-08-02 07:47:15 +02:00
parent dd2e43754e
commit f232ae9160
2 changed files with 18 additions and 12 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
* 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
@ -831,6 +831,7 @@ if ($action == "addline" && $user->rights->expensereport->creer)
$object_ligne = new ExpenseReportLine($db);
$vatrate = GETPOST('vatrate');
$object_ligne->comments = GETPOST('comments');
$qty = GETPOST('qty','int');
if (empty($qty)) $qty=1;
@ -843,10 +844,13 @@ if ($action == "addline" && $user->rights->expensereport->creer)
$object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees');
$object_ligne->fk_c_tva = GETPOST('fk_c_tva');
// if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
if (empty($vatrate)) $vatrate = "0.000";
$object_ligne->vatrate = price2num($vatrate);
$object_ligne->fk_projet = $fk_projet;
if (! GETPOST('fk_c_type_fees') > 0)
{
@ -854,10 +858,11 @@ if ($action == "addline" && $user->rights->expensereport->creer)
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$action='';
}
if (GETPOST('vatrate') < 0 || GETPOST('vatrate') == '')
if ($vatrate < 0 || $vatrate == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors');
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors');
$action='';
}
@ -1096,7 +1101,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
print '<tbody>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("DateStart").'</td>';
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("DateStart").'</td>';
print '<td>';
$form->select_date($date_start?$date_start:-1,'date_debut',0,0,0,'',1,1);
print '</td>';
@ -1211,7 +1216,7 @@ else
$linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print '</td></tr>';
@ -1374,7 +1379,7 @@ else
$linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="2">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="2">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print '</td></tr>';
@ -1683,7 +1688,8 @@ else
}
print '</td>';
}
print '<td style="text-align:center;">'.$langs->trans("TF_".strtoupper(empty($objp->type_fees_libelle)?'OTHER':$objp->type_fees_libelle)).'</td>';
// print '<td style="text-align:center;">'.$langs->trans("TF_".strtoupper(empty($objp->type_fees_libelle)?'OTHER':$objp->type_fees_libelle)).'</td>';
print '<td style="text-align:center;">'.($langs->trans(($objp->type_fees_code)) == $objp->type_fees_code ? $objp->type_fees_libelle : $langs->trans(($objp->type_fees_code))).'</td>';
print '<td style="text-align:left;">'.$objp->comments.'</td>';
print '<td style="text-align:right;">'.vatrate($objp->vatrate,true).'</td>';
print '<td style="text-align:right;">'.price($objp->value_unit).'</td>';
@ -1789,7 +1795,7 @@ else
print '<td align="center">'.$langs->trans('Date').'</td>';
if (! empty($conf->projet->enabled)) print '<td>'.$langs->trans('Project').'</td>';
print '<td align="center">'.$langs->trans('Type').'</td>';
print '<td>'.$langs->trans('Description').'</td>';
print '<td colspan="2">'.$langs->trans('Description').'</td>';
print '<td align="right">'.$langs->trans('VAT').'</td>';
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
print '<td align="right">'.$langs->trans('Qty').'</td>';
@ -1807,7 +1813,7 @@ else
// Select project
if (! empty($conf->projet->enabled))
{
print '<td>';
print '<td align="center">';
$formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, 1);
print '</td>';
}
@ -1818,7 +1824,7 @@ else
print '</td>';
// Add comments
print '<td>';
print '<td colspan="2">';
print '<textarea class="flat_ndf centpercent" name="comments">'.$comments.'</textarea>';
print '</td>';

View File

@ -40,7 +40,7 @@ $result = restrictedArea($user, 'expensereport', $id, '');
* View
*/
llxHeader();
llxHeader('', $langs->trans("ExpenseReport"));
if ($id)
{