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>
|
2008-02-25 17:30:43 +01:00
|
|
|
|
* Copyright (C) 2004-2008 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.
|
|
|
|
|
|
*/
|
2004-11-06 15:46:34 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
/**
|
2008-05-26 01:46:19 +02:00
|
|
|
|
\file htdocs/compta/deplacement/fiche.php
|
|
|
|
|
|
\brief Page fiche d'un deplacement
|
|
|
|
|
|
\version $Id$
|
2004-11-06 15:46:34 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
require("./pre.inc.php");
|
|
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$langs->load("trips");
|
|
|
|
|
|
|
2008-02-25 17:30:43 +01:00
|
|
|
|
// Security check
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$id=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
|
2008-02-25 21:03:21 +01:00
|
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
2008-03-01 02:26:41 +01:00
|
|
|
|
$result = restrictedArea($user, 'deplacement', $id,'');
|
2005-04-27 23:53:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
$mesg = '';
|
|
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Actions
|
|
|
|
|
|
*/
|
2008-02-25 17:30:43 +01:00
|
|
|
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->deplacement->supprimer)
|
2003-09-03 02:26:19 +02:00
|
|
|
|
{
|
2006-11-11 02:50:38 +01:00
|
|
|
|
$deplacement = new Deplacement($db);
|
|
|
|
|
|
$deplacement->delete($_GET["id"]);
|
|
|
|
|
|
Header("Location: index.php");
|
|
|
|
|
|
exit;
|
2003-09-03 02:26:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2008-02-25 17:30:43 +01:00
|
|
|
|
if ($_POST["action"] == 'add' && $user->rights->deplacement->creer)
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2008-02-25 17:30:43 +01:00
|
|
|
|
if (! $_POST["cancel"])
|
2006-11-11 02:50:38 +01:00
|
|
|
|
{
|
2008-02-25 17:30:43 +01:00
|
|
|
|
$deplacement = new Deplacement($db);
|
|
|
|
|
|
|
|
|
|
|
|
$deplacement->date = dolibarr_mktime(12, 0, 0,
|
|
|
|
|
|
$_POST["remonth"],
|
|
|
|
|
|
$_POST["reday"],
|
|
|
|
|
|
$_POST["reyear"]);
|
|
|
|
|
|
|
|
|
|
|
|
$deplacement->km = $_POST["km"];
|
2008-05-26 01:46:19 +02:00
|
|
|
|
$deplacement->type = $_POST["type"];
|
2008-02-25 17:30:43 +01:00
|
|
|
|
$deplacement->socid = $_POST["socid"];
|
2008-05-26 02:03:51 +02:00
|
|
|
|
$deplacement->fk_user = $_POST["fk_user"];
|
|
|
|
|
|
|
2008-02-25 17:30:43 +01:00
|
|
|
|
$id = $deplacement->create($user);
|
|
|
|
|
|
|
|
|
|
|
|
if ($id > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Header ( "Location: fiche.php?id=".$id);
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2008-05-26 01:46:19 +02:00
|
|
|
|
$mesg=$deplacement->error;
|
|
|
|
|
|
$_GET["action"]='create';
|
2008-02-25 17:30:43 +01:00
|
|
|
|
}
|
2006-11-11 02:50:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2008-02-25 17:30:43 +01:00
|
|
|
|
Header ( "Location: index.php");
|
|
|
|
|
|
exit;
|
2006-11-11 02:50:38 +01:00
|
|
|
|
}
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2008-02-25 17:30:43 +01:00
|
|
|
|
if ($_POST["action"] == 'update' && $user->rights->deplacement->creer)
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2008-06-04 02:19:36 +02:00
|
|
|
|
if (empty($_POST["cancel"]))
|
2006-11-11 02:50:38 +01:00
|
|
|
|
{
|
2008-02-25 17:30:43 +01:00
|
|
|
|
$deplacement = new Deplacement($db);
|
|
|
|
|
|
$result = $deplacement->fetch($_POST["id"]);
|
|
|
|
|
|
|
|
|
|
|
|
$deplacement->date = dolibarr_mktime(12, 0 , 0,
|
|
|
|
|
|
$_POST["remonth"],
|
|
|
|
|
|
$_POST["reday"],
|
|
|
|
|
|
$_POST["reyear"]);
|
|
|
|
|
|
|
|
|
|
|
|
$deplacement->km = $_POST["km"];
|
2008-05-26 01:46:19 +02:00
|
|
|
|
$deplacement->type = $_POST["type"];
|
2008-05-26 02:03:51 +02:00
|
|
|
|
$deplacement->fk_user = $_POST["fk_user"];
|
2008-02-25 17:30:43 +01:00
|
|
|
|
|
|
|
|
|
|
$result = $deplacement->update($user);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result > 0)
|
|
|
|
|
|
{
|
2008-05-26 01:46:19 +02:00
|
|
|
|
Header("Location: fiche.php?id=".$_POST["id"]);
|
2008-02-25 17:30:43 +01:00
|
|
|
|
exit;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2008-05-26 01:46:19 +02:00
|
|
|
|
$mesg=$deplacement->error;
|
2008-02-25 17:30:43 +01:00
|
|
|
|
}
|
2006-11-11 02:50:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2008-06-04 02:19:36 +02:00
|
|
|
|
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]);
|
2008-02-25 17:30:43 +01:00
|
|
|
|
exit;
|
2006-11-11 02:50:38 +01:00
|
|
|
|
}
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
llxHeader();
|
|
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$html = new Form($db);
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
/*
|
2005-04-27 23:53:41 +02:00
|
|
|
|
* Action create
|
2003-09-02 19:41:30 +02:00
|
|
|
|
*/
|
2004-07-24 00:29:26 +02:00
|
|
|
|
if ($_GET["action"] == 'create')
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2005-07-02 14:16:33 +02:00
|
|
|
|
print_fiche_titre($langs->trans("NewTrip"));
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2008-05-26 01:46:19 +02:00
|
|
|
|
if ($mesg) print $mesg."<br>";
|
|
|
|
|
|
|
|
|
|
|
|
print "<form name='add' action=\"fiche.php\" method=\"post\">\n";
|
|
|
|
|
|
print '<input type="hidden" name="action" value="add">';
|
|
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '<table class="border" width="100%">';
|
2004-07-24 00:29:26 +02:00
|
|
|
|
|
|
|
|
|
|
print "<tr>";
|
2008-05-26 02:03:51 +02:00
|
|
|
|
print '<td width="25%">'.$langs->trans("CompanyVisited").'</td><td>';
|
2008-05-26 01:46:19 +02:00
|
|
|
|
print $html->select_societes($_GET["socid"],'socid','',1);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2008-05-26 01:46:19 +02:00
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td>'.$langs->trans("Type").'</td><td>';
|
|
|
|
|
|
print $html->select_type_fees($_GET["type"],'type',1);
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2008-05-26 02:03:51 +02:00
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td>'.$langs->trans("Person").'</td><td>';
|
|
|
|
|
|
print $html->select_users($_GET["fk_user"],'fk_user',1);
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print "<tr>";
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '<td>'.$langs->trans("Date").'</td><td>';
|
2006-03-01 17:59:18 +01:00
|
|
|
|
print $html->select_date('','','','','','add');
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2008-05-27 10:50:35 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" size="10" value=""></td></tr>';
|
2006-11-11 02:50:38 +01:00
|
|
|
|
print '<tr><td colspan="2" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
|
|
|
|
|
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '</table>';
|
2006-11-11 02:50:38 +01:00
|
|
|
|
print '</form>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-04-27 23:53:41 +02:00
|
|
|
|
if ($id)
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
|
|
|
|
|
$deplacement = new Deplacement($db);
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$result = $deplacement->fetch($id);
|
|
|
|
|
|
if ($result)
|
2006-11-11 02:50:38 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
2008-05-26 01:46:19 +02:00
|
|
|
|
if ($mesg) print $mesg."<br>";
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
if ($_GET["action"] == 'edit')
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$h=0;
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$deplacement->id";
|
|
|
|
|
|
$head[$h][1] = $langs->trans("TripCard");
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").' '.$deplacement->id);
|
|
|
|
|
|
|
2006-03-01 17:59:18 +01:00
|
|
|
|
print "<form name='update' action=\"fiche.php\" method=\"post\">\n";
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '<input type="hidden" name="id" value="'.$id.'">';
|
2006-11-11 02:50:38 +01: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
|
|
|
|
|
2008-04-16 15:45:44 +02:00
|
|
|
|
print "<tr>";
|
2008-06-04 02:19:36 +02:00
|
|
|
|
print '<td width="20%">'.$langs->trans("CompanyVisited").'</td><td>';
|
2008-05-26 02:03:51 +02:00
|
|
|
|
print $html->select_societes($soc->id,'socid','',1);
|
2008-04-16 15:45:44 +02:00
|
|
|
|
print '</td></tr>';
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2008-05-26 01:46:19 +02:00
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td>'.$langs->trans("Type").'</td><td>';
|
|
|
|
|
|
print $html->select_type_fees($deplacement->type,'type',1);
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2008-05-26 02:03:51 +02:00
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td>'.$langs->trans("Person").'</td><td>';
|
|
|
|
|
|
print $html->select_users($deplacement->fk_user,'fk_user',1);
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
2006-03-01 17:59:18 +01:00
|
|
|
|
print $html->select_date($deplacement->date,'','','','','update');
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '</td></tr>';
|
2008-05-27 10:50:35 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" class="flat" size="10" value="'.$deplacement->km.'"></td></tr>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
|
2005-12-03 01:36:02 +01:00
|
|
|
|
print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
print '</table>';
|
2005-12-03 01:36:02 +01:00
|
|
|
|
print '</form>';
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '</div>';
|
2006-11-11 02:50:38 +01:00
|
|
|
|
}
|
2003-09-02 19:41:30 +02:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$h=0;
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$deplacement->id";
|
|
|
|
|
|
$head[$h][1] = $langs->trans("TripCard");
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").' '.$deplacement->id);
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* Confirmation de la suppression du d<EFBFBD>placement
|
|
|
|
|
|
*/
|
|
|
|
|
|
if ($_GET["action"] == 'delete')
|
|
|
|
|
|
{
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
$html = new Form($db);
|
|
|
|
|
|
$html->form_confirm("fiche.php?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete");
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '<br>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
$soc = new Societe($db);
|
|
|
|
|
|
$soc->fetch($deplacement->socid);
|
2004-07-24 00:29:26 +02:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '<table class="border" width="100%">';
|
2006-06-03 16:47:05 +02:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("CompanyVisited").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
|
2008-06-04 02:19:36 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans($deplacement->type).'</td></tr>';
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Person").'</td><td>';
|
2008-05-26 02:03:51 +02:00
|
|
|
|
$userfee=new User($db,$deplacement->fk_user);
|
|
|
|
|
|
$userfee->fetch();
|
|
|
|
|
|
print $userfee->getNomUrl(1);
|
|
|
|
|
|
print '</td></tr>';
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("Date").'</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>';
|
2008-05-27 10:50:35 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td><td>'.$deplacement->km.'</td></tr>';
|
2005-12-03 01:36:02 +01:00
|
|
|
|
print "</table>";
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
print '</div>';
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
2006-11-11 02:50:38 +01:00
|
|
|
|
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-04-27 23:53:41 +02:00
|
|
|
|
dolibarr_print_error($db);
|
2003-09-02 19:41:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-24 00:29:26 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* Barre d'actions
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
if ($_GET["action"] != 'create' && $_GET["action"] != 'edit')
|
2003-09-02 19:41:30 +02:00
|
|
|
|
{
|
2008-01-11 00:59:58 +01:00
|
|
|
|
print '<a class="butAction" href="fiche.php?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
|
2007-05-26 20:16:58 +02:00
|
|
|
|
print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$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();
|
|
|
|
|
|
|
2005-04-27 23:53:41 +02:00
|
|
|
|
llxFooter('$Date$ - $Revision$');
|
2003-09-02 19:41:30 +02:00
|
|
|
|
?>
|