diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index b70ceeb33e4..d63f29f961d 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -20,7 +20,7 @@ /** * \file htdocs/compta/deplacement/fiche.php - * \brief Page fiche d'un deplacement + * \brief Page to show a trip card * \version $Id$ */ require("./pre.inc.php"); @@ -66,6 +66,8 @@ if ($_POST["action"] == 'add' && $user->rights->deplacement->creer) { if (! $_POST["cancel"]) { + $error=0; + $deplacement = new Deplacement($db); $deplacement->date = dol_mktime(12, 0, 0, @@ -78,16 +80,34 @@ if ($_POST["action"] == 'add' && $user->rights->deplacement->creer) $deplacement->socid = $_POST["socid"]; $deplacement->fk_user = $_POST["fk_user"]; - $id = $deplacement->create($user); - - if ($id > 0) + if ($deplacement->type == '-1') // Otherwise it is TF_LUNCH,... { - Header ( "Location: fiche.php?id=".$id); - exit; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; + $error++; + } + if (! ($deplacement->fk_user > 0)) + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Person")).'
'; + $error++; + } + + if (! $error) + { + $id = $deplacement->create($user); + + if ($id > 0) + { + Header ( "Location: fiche.php?id=".$id); + exit; + } + else + { + $mesg=$deplacement->error; + $_GET["action"]='create'; + } } else { - $mesg=$deplacement->error; $_GET["action"]='create'; } } @@ -157,29 +177,31 @@ if ($_GET["action"] == 'create') print ''; print ""; - print ''; - - print ""; - print ''; print ""; - print ''; print ""; - print ''; + print ""; + print ''; + print ''; - print ''; print '
'.$langs->trans("CompanyVisited").''; - print $html->select_societes($_GET["socid"],'socid','',1); - print '
'.$langs->trans("Type").''; + print ''.$langs->trans("Type").''; print $html->select_type_fees($_GET["type"],'type',1); print '
'.$langs->trans("Person").''; + print ''.$langs->trans("Person").''; print $html->select_users($_GET["fk_user"],'fk_user',1); print '
'.$langs->trans("Date").''; + print ''.$langs->trans("Date").''; print $html->select_date('','','','','','add'); print '
'.$langs->trans("CompanyVisited").''; + print $html->select_societes($_GET["socid"],'socid','',1); + print '
'.$langs->trans("FeesKilometersOrAmout").'
 '; - print '
'; + + print '
    '; + print ''; } else @@ -226,28 +248,31 @@ else print ''; print ""; - print ''.$langs->trans("Type").''; - print $html->select_type_fees($deplacement->type,'type',1); + print ''.$langs->trans("Type").''; + print $html->select_type_fees($deplacement->type,'type',0); print ''; + print ""; + print ''.$langs->trans("Person").''; + print $html->select_users($deplacement->fk_user,'fk_user',0); + print ''; + + print ''.$langs->trans("Date").''; + print $html->select_date($deplacement->date,'','','','','update'); + print ''; + print ''.$langs->trans("FeesKilometersOrAmout").''; + print ""; print ''.$langs->trans("CompanyVisited").''; print $html->select_societes($soc->id,'socid','',1); print ''; - print ""; - print ''.$langs->trans("Person").''; - print $html->select_users($deplacement->fk_user,'fk_user',1); - print ''; - - print ''.$langs->trans("Date").''; - print $html->select_date($deplacement->date,'','','','','update'); - print ''; - print ''.$langs->trans("FeesKilometersOrAmout").''; - - print '   '; - print ''; print ''; + + print '
  '; + print ''; + print '
'; + print ''; print ''; @@ -275,11 +300,6 @@ else print ''.$langs->trans("Type").''.$langs->trans($deplacement->type).''; - print ''.$langs->trans("CompanyVisited").''; - print ''; - if ($soc->id) print $soc->getNomUrl(1); - print ''; - print ''.$langs->trans("Person").''; $userfee=new User($db,$deplacement->fk_user); $userfee->fetch(); @@ -290,6 +310,11 @@ else print dol_print_date($deplacement->date); print ''; + print ''.$langs->trans("CompanyVisited").''; + print ''; + if ($soc->id) print $soc->getNomUrl(1); + print ''; + print ''.$langs->trans("FeesKilometersOrAmout").''.$deplacement->km.''; print "";