dolibarr/htdocs/compta/deplacement/fiche.php

225 lines
6.1 KiB
PHP
Raw Normal View History

<?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$
*
*/
2005-01-09 22:20:30 +01:00
/** \file htdocs/compta/deplacement/fiche.php
\brief Page fiche d'un d<EFBFBD>placement
*/
2003-09-02 19:41:30 +02:00
require("./pre.inc.php");
$mesg = '';
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
2003-09-03 02:26:19 +02:00
{
$deplacement = new Deplacement($db);
$deplacement->delete($_GET["id"]);
2003-09-03 02:26:19 +02:00
Header("Location: index.php");
}
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,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]);
2003-09-02 19:41:30 +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);
if ($id)
2003-09-02 19:41:30 +02:00
{
Header ( "Location: fiche.php?id=".$id);
2003-09-02 19:41:30 +02:00
}
else
{
dolibarr_print_error($db);
2003-09-02 19:41:30 +02:00
}
}
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
2003-09-02 19:41:30 +02:00
{
$deplacement = new Deplacement($db);
$result = $deplacement->fetch($_POST["id"]);
2003-09-02 19:41:30 +02:00
$deplacement->date = mktime(12, 1 , 1,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]);
2003-09-02 19:41:30 +02:00
$deplacement->km = $_POST["km"];
2003-09-02 19:41:30 +02:00
$result = $deplacement->update($user);
if ($result > 0)
{
Header ( "Location: fiche.php?id=".$_POST["id"]);
2003-09-02 19:41:30 +02:00
}
else
{
print "Error";
}
}
llxHeader();
/*
*
*
*/
$html = new Form($db);
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">';
2003-09-02 19:41:30 +02:00
print '<div class="titre">Nouveau d<>placement</div><br>';
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>";
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>';
print '<tr><td>Kilom<6F>tres</td><td><input name="km" size="10" value=""></td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
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
{
if ($_GET["id"])
2003-09-02 19:41:30 +02:00
{
$deplacement = new Deplacement($db);
$result = $deplacement->fetch($_GET["id"]);
2003-09-02 19:41:30 +02:00
if ( $result )
{
2003-09-03 02:26:19 +02:00
/*
* Confirmation de la suppression du d<EFBFBD>placement
2003-09-03 02:26:19 +02:00
*
*/
if ($_GET["action"] == 'delete')
2003-09-03 02:26:19 +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");
print '<br>';
2003-09-03 02:26:19 +02:00
}
if ($_GET["action"] == 'edit')
2003-09-02 19:41:30 +02:00
{
print_fiche_titre('Fiche d<>placement', $mesg);
2003-09-02 19:41:30 +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">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
2003-09-02 19:41:30 +02:00
print '<table class="border" width="100%">';
2003-09-02 19:41:30 +02:00
$soc = new Societe($db);
$soc->fetch($deplacement->socid);
2003-09-02 19:41:30 +02:00
print '<tr><td width="20%">Personne</td><td>'.$user->fullname.'</td></tr>';
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>';
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
print '<tr><td>&nbsp;</td><td><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
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
{
print_fiche_titre('Fiche d<>placement', $mesg);
2003-09-02 19:41:30 +02:00
$soc = new Societe($db);
$soc->fetch($deplacement->socid);
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>';
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
{
print "Error:".$db->error();
2003-09-02 19:41:30 +02:00
}
}
}
/*
* Barre d'actions
*
*/
print '<br>';
print '<div class="tabsAction">';
if ($_GET["action"] != 'create')
2003-09-02 19:41:30 +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
print '</div>';
2003-09-02 19:41:30 +02:00
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>