* Copyright (C) 2004-2005 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"); $mesg = ''; if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") { $deplacement = new Deplacement($db); $deplacement->delete($_GET["id"]); Header("Location: index.php"); } 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["soc_id"]; $deplacement->userid = $user->id; //$_POST["km"]; $id = $deplacement->create($user); if ($id) { Header ( "Location: fiche.php?id=".$id); } else { dolibarr_print_error($db); } } 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"]); } else { print "Error"; } } llxHeader(); /* * * */ $html = new Form($db); if ($_GET["action"] == 'create') { print "
\n"; print ''; print '
Nouveau déplacement

'; print ''; print ''; print ""; print ''; print ""; print ''; print ''; print ''; print '
Personne'.$user->fullname.'
Société visitée'; print $html->select_societes(); print '
Date du déplacement'; print $html->select_date(); print '
Kilomètres
  '; print '
'; print '
'; } else { if ($_GET["id"]) { $deplacement = new Deplacement($db); $result = $deplacement->fetch($_GET["id"]); if ( $result ) { /* * Confirmation de la suppression du déplacement * */ if ($_GET["action"] == 'delete') { print_fiche_titre("Suppression déplacement ",$message); print '
'; $html = new Form($db); $html->form_confirm("fiche.php?id=".$_GET["id"],"Supprimer ce déplacement","Etes-vous sûr de vouloir supprimer ce déplacement ?","confirm_delete"); print '
'; } if ($_GET["action"] == 'edit') { print_fiche_titre('Fiche déplacement', $mesg); print "
\n"; print ''; print ''; print ''; $soc = new Societe($db); $soc->fetch($deplacement->socid); print ''; print ""; print ''; print ''; print ''; print ''; print '
Personne'.$user->fullname.'
Société visitée'; print $html->select_societes($soc->id); print '
Date du déplacement'; print $html->select_date($deplacement->date); print '
Kilomètres
  '; print '
'; print '
'; } else { print_fiche_titre('Fiche déplacement', $mesg); $soc = new Societe($db); $soc->fetch($deplacement->socid); print ''; print ''; print ''; print ''; print ''; print "
Personne'.$user->fullname.'
Société visitée'.$soc->nom_url.'
Date du déplacement'; print dolibarr_print_date($deplacement->date); print '
Kilomètres'.$deplacement->km.'
"; } } else { print "Error:".$db->error(); } } } /* * Barre d'actions * */ print '
'; print '
'; if ($_GET["action"] != 'create') { print ''.$langs->trans('Edit').''; print ''.$langs->trans('Delete').''; } print '
'; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>