2004-10-19 22:35:36 +02:00
|
|
|
|
<?php
|
2005-01-09 22:20:30 +01:00
|
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-09-02 19:41:30 +02:00
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-11-06 15:46:34 +01:00
|
|
|
|
|
2005-01-09 22:20:30 +01:00
|
|
|
|
/** \file htdocs/compta/deplacement/fiche.php
|
2004-11-06 15:46:34 +01:00
|
|
|
|
\brief Page fiche d'un d<EFBFBD>placement
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
require("./pre.inc.php");
|
|
|
|
|
|
|
|
|
|
|
|
$mesg = '';
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
|
2003-09-03 02:26:19 +02:00
|
|
|
|
{
|
|
|
|
|
|
$deplacement = new Deplacement($db);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
$deplacement->delete($_GET["id"]);
|
2003-09-03 02:26:19 +02:00
|
|
|
|
Header("Location: index.php");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-08-29 18:11:37 +02:00
|
|
|
|
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
|
|
|
|
|
$deplacement = new Deplacement($db);
|
|
|
|
|
|
|
|
|
|
|
|
$deplacement->date = mktime(12, 1 , 1,
|
2004-07-24 00:29:26 +02:00
|
|
|
|
$_POST["remonth"],
|
|
|
|
|
|
$_POST["reday"],
|
|
|
|
|
|
$_POST["reyear"]);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
$deplacement->km = $_POST["km"];
|
|
|
|
|
|
$deplacement->socid = $_POST["soc_id"];
|
|
|
|
|
|
$deplacement->userid = $user->id; //$_POST["km"];
|
2003-09-02 19:41:30 +02:00
|
|
|
|
$id = $deplacement->create($user);
|
|
|
|
|
|
|
2004-11-06 15:46:34 +01:00
|
|
|
|
if ($id)
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2004-11-06 15:46:34 +01:00
|
|
|
|
Header ( "Location: fiche.php?id=".$id);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-11-06 15:46:34 +01:00
|
|
|
|
dolibarr_print_error($db);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-08-29 18:11:37 +02:00
|
|
|
|
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
|
|
|
|
|
$deplacement = new Deplacement($db);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
$result = $deplacement->fetch($_POST["id"]);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
|
|
|
|
|
$deplacement->date = mktime(12, 1 , 1,
|
2004-07-24 00:29:26 +02:00
|
|
|
|
$_POST["remonth"],
|
|
|
|
|
|
$_POST["reday"],
|
|
|
|
|
|
$_POST["reyear"]);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
$deplacement->km = $_POST["km"];
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
|
|
|
|
|
$result = $deplacement->update($user);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result > 0)
|
|
|
|
|
|
{
|
2004-07-24 00:29:26 +02:00
|
|
|
|
Header ( "Location: fiche.php?id=".$_POST["id"]);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print "Error";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
llxHeader();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
$html = new Form($db);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
if ($_GET["action"] == 'create')
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
|
|
|
|
|
print "<form action=\"fiche.php\" method=\"post\">\n";
|
|
|
|
|
|
print '<input type="hidden" name="action" value="add">';
|
2004-07-24 00:29:26 +02:00
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '<div class="titre">Nouveau d<>placement</div><br>';
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print '<table class="border" width="100%" cellspacing="0" cellpadding="3">';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '<tr><td width="20%">Personne</td><td>'.$user->fullname.'</td></tr>';
|
2004-07-24 00:29:26 +02:00
|
|
|
|
|
|
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td>Soci<63>t<EFBFBD> visit<69>e</td><td>';
|
|
|
|
|
|
print $html->select_societes();
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td>Date du d<>placement</td><td>';
|
|
|
|
|
|
print $html->select_date();
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print '<tr><td>Kilom<6F>tres</td><td><input name="km" size="10" value=""></td></tr>';
|
2004-08-29 18:11:37 +02:00
|
|
|
|
print '<tr><td> </td><td><input type="submit" value="'.$langs->trans("Save").'"> ';
|
|
|
|
|
|
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '</table>';
|
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-07-24 00:29:26 +02:00
|
|
|
|
if ($_GET["id"])
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
|
|
|
|
|
$deplacement = new Deplacement($db);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
$result = $deplacement->fetch($_GET["id"]);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
|
|
|
|
|
if ( $result )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2003-09-03 02:26:19 +02:00
|
|
|
|
/*
|
2004-07-24 00:29:26 +02:00
|
|
|
|
* Confirmation de la suppression du d<EFBFBD>placement
|
2003-09-03 02:26:19 +02:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
if ($_GET["action"] == 'delete')
|
2003-09-03 02:26:19 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print_fiche_titre("Suppression d<>placement ",$message);
|
|
|
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
$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");
|
2004-11-06 15:46:34 +01:00
|
|
|
|
|
|
|
|
|
|
print '<br>';
|
2003-09-03 02:26:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
if ($_GET["action"] == 'edit')
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print_fiche_titre('Fiche d<>placement', $mesg);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print "<form action=\"fiche.php\" method=\"post\">\n";
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
2004-11-06 15:46:34 +01:00
|
|
|
|
print '<table class="border" width="100%">';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
|
|
|
|
|
$soc = new Societe($db);
|
|
|
|
|
|
$soc->fetch($deplacement->socid);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '<tr><td width="20%">Personne</td><td>'.$user->fullname.'</td></tr>';
|
2004-07-24 00:29:26 +02:00
|
|
|
|
|
|
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td>Soci<63>t<EFBFBD> visit<69>e</td><td>';
|
|
|
|
|
|
print $html->select_societes($soc->id);
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '<tr><td>Date du d<>placement</td><td>';
|
|
|
|
|
|
print $html->select_date($deplacement->date);
|
|
|
|
|
|
print '</td></tr>';
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print '<tr><td>Kilom<6F>tres</td><td><input name="km" size="10" value="'.$deplacement->km.'"></td></tr>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
2004-08-29 18:11:37 +02:00
|
|
|
|
print '<tr><td> </td><td><input type="submit" value="'.$langs->trans("Save").'"> ';
|
|
|
|
|
|
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '</table>';
|
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print_fiche_titre('Fiche d<>placement', $mesg);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
|
|
|
|
|
$soc = new Societe($db);
|
|
|
|
|
|
$soc->fetch($deplacement->socid);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
|
|
|
|
|
|
print '<table class="border" width="100%" cellspacing="0" cellpadding="3">';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '<tr><td width="20%">Personne</td><td>'.$user->fullname.'</td></tr>';
|
|
|
|
|
|
print '<tr><td width="20%">Soci<63>t<EFBFBD> visit<69>e</td><td>'.$soc->nom_url.'</td></tr>';
|
|
|
|
|
|
print '<tr><td>Date du d<>placement</td><td>';
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print dolibarr_print_date($deplacement->date);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
print '<tr><td>Kilom<6F>tres</td><td>'.$deplacement->km.'</td></tr>';
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print "Error:".$db->error();
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* Barre d'actions
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
|
|
|
|
|
|
|
if ($_GET["action"] != 'create')
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2004-07-31 14:16:28 +02:00
|
|
|
|
print '<a class="tabAction" href="fiche.php?action=edit&id='.$_GET["id"].'">'.$langs->trans('Edit').'</a>';
|
2005-01-09 22:20:30 +01:00
|
|
|
|
print '<a class="butDelete" href="fiche.php?action=delete&id='.$_GET["id"].'">'.$langs->trans('Delete').'</a>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
2003-09-03 02:26:19 +02:00
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print '</div>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
|
|
|
|
|
?>
|