* Copyright (C) 2004-2006 Laurent Destailleur * * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/compta/deplacement/fiche.php \brief Page fiche d'un déplacement */ require("./pre.inc.php"); $langs->load("trips"); $id=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; $mesg = ''; /* * Actions */ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") { $deplacement = new Deplacement($db); $deplacement->delete($_GET["id"]); Header("Location: index.php"); exit; } if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $deplacement = new Deplacement($db); $deplacement->date = mktime(12, 1 , 1, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $deplacement->km = $_POST["km"]; $deplacement->socid = $_POST["socid"]; $deplacement->userid = $user->id; //$_POST["km"]; $id = $deplacement->create($user); if ($id > 0) { Header ( "Location: fiche.php?id=".$id); exit; } else { dolibarr_print_error($db,$deplacement->error); } } if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel")) { $deplacement = new Deplacement($db); $result = $deplacement->fetch($_POST["id"]); $deplacement->date = mktime(12, 1 , 1, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $deplacement->km = $_POST["km"]; $result = $deplacement->update($user); if ($result > 0) { Header ( "Location: fiche.php?id=".$_POST["id"]); exit; } else { print $mesg=$langs->trans("ErrorUnknown"); } } llxHeader(); $html = new Form($db); /* * Action create */ if ($_GET["action"] == 'create') { print "
\n"; print ''; print_fiche_titre($langs->trans("NewTrip")); print ''; print ''; print ""; print ''; print ""; print ''; print ''; print ''; print '
'.$langs->trans("Person").''.$user->fullname.'
'.$langs->trans("CompanyVisited").''; print $html->select_societes($_GET["socid"]); print '
'.$langs->trans("Date").''; print $html->select_date('','','','','','add'); print '
'.$langs->trans("Kilometers").'
 '; print '
'; print '
'; } else { if ($id) { $deplacement = new Deplacement($db); $result = $deplacement->fetch($id); if ($result) { if ($mesg) print "$mesg
"; if ($_GET["action"] == 'edit') { $h=0; $head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$deplacement->id"; $head[$h][1] = $langs->trans("TripCard"); dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").' '.$deplacement->id); print "
\n"; print ''; print ''; print ''; $soc = new Societe($db); $soc->fetch($deplacement->socid); print ''; print ""; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Personn").''.$user->fullname.'
'.$langs->trans("CompanyVisited").''; print $html->select_societes($soc->id); print '
'.$langs->trans("Date").''; print $html->select_date($deplacement->date,'','','','','update'); print '
'.$langs->trans("Kilometers").'
  '; print '
'; print '
'; print ''; } else { $h=0; $head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$deplacement->id"; $head[$h][1] = $langs->trans("TripCard"); dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").' '.$deplacement->id); /* * Confirmation de la suppression du déplacement */ if ($_GET["action"] == 'delete') { $html = new Form($db); $html->form_confirm("fiche.php?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete"); print '
'; } $soc = new Societe($db); $soc->fetch($deplacement->socid); print ''; print ''; print ''; print ''; print ''; print "
'.$langs->trans("Personn").''.$user->fullname.'
'.$langs->trans("CompanyVisited").''.$soc->getNomUrl(1).'
'.$langs->trans("Date").''; print dolibarr_print_date($deplacement->date); print '
'.$langs->trans("Kilometers").''.$deplacement->km.'
"; print ''; } } else { dolibarr_print_error($db); } } } /* * Barre d'actions * */ print '
'; if ($_GET["action"] != 'create' && $_GET["action"] != 'edit') { print ''.$langs->trans('Edit').''; print ''.$langs->trans('Delete').''; } print '
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>