Fix: uniformize code

This commit is contained in:
Regis Houssin 2011-10-23 14:55:37 +02:00
parent 504882fa8c
commit a7deb7c23a
8 changed files with 195 additions and 185 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -23,6 +23,7 @@
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/trip.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/class/deplacement.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
if ($conf->projet->enabled)
@ -35,21 +36,23 @@ $langs->load("trips");
// Security check
$id=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
$id = GETPOST('id');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'deplacement', $id,'');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
$mesg = '';
$object = new Deplacement($db);
/*
* Actions
*/
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->deplacement->supprimer)
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer)
{
$deplacement = new Deplacement($db);
$result=$deplacement->delete($_GET["id"]);
$result=$object->delete($id);
if ($result >= 0)
{
Header("Location: index.php");
@ -57,11 +60,11 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user-
}
else
{
$mesg=$deplacement->error;
$mesg=$object->error;
}
}
if ($_POST["action"] == 'add' && $user->rights->deplacement->creer)
if ($action == 'add' && $user->rights->deplacement->creer)
{
if (! $_POST["cancel"])
{
@ -72,26 +75,25 @@ if ($_POST["action"] == 'add' && $user->rights->deplacement->creer)
$_POST["reday"],
$_POST["reyear"]);
$deplacement = new Deplacement($db);
$deplacement->date = $dated;
$deplacement->km = $_POST["km"];
$deplacement->type = $_POST["type"];
$deplacement->socid = $_POST["socid"];
$deplacement->fk_user = $_POST["fk_user"];
$deplacement->note = $_POST["note"];
$deplacement->note_public = $_POST["note_public"];
$object->date = $dated;
$object->km = $_POST["km"];
$object->type = $_POST["type"];
$object->socid = $_POST["socid"];
$object->fk_user = $_POST["fk_user"];
$object->note = $_POST["note"];
$object->note_public = $_POST["note_public"];
if (! $deplacement->date)
if (! $object->date)
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date"));
$error++;
}
if ($deplacement->type == '-1') // Otherwise it is TF_LUNCH,...
if ($object->type == '-1') // Otherwise it is TF_LUNCH,...
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$error++;
}
if (! ($deplacement->fk_user > 0))
if (! ($object->fk_user > 0))
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Person")).'</div>';
$error++;
@ -99,22 +101,22 @@ if ($_POST["action"] == 'add' && $user->rights->deplacement->creer)
if (! $error)
{
$id = $deplacement->create($user);
$id = $object->create($user);
if ($id > 0)
{
Header("Location: fiche.php?id=".$id);
Header("Location: " . $_SERVER["PHP_SELF"] . "?id=".$id);
exit;
}
else
{
$mesg=$deplacement->error;
$_GET["action"]='create';
$mesg=$object->error;
$action='create';
}
}
else
{
$_GET["action"]='create';
$action='create';
}
}
else
@ -124,45 +126,44 @@ if ($_POST["action"] == 'add' && $user->rights->deplacement->creer)
}
}
if ($_POST["action"] == 'update' && $user->rights->deplacement->creer)
if ($action == 'update' && $user->rights->deplacement->creer)
{
if (empty($_POST["cancel"]))
{
$deplacement = new Deplacement($db);
$result = $deplacement->fetch($_POST["id"]);
$result = $object->fetch($id);
$deplacement->date = dol_mktime(12, 0 , 0,
$object->date = dol_mktime(12, 0 , 0,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]);
$deplacement->km = $_POST["km"];
$deplacement->type = $_POST["type"];
$deplacement->fk_user = $_POST["fk_user"];
$deplacement->socid = $_POST["socid"];
$result = $deplacement->update($user);
$object->km = $_POST["km"];
$object->type = $_POST["type"];
$object->fk_user = $_POST["fk_user"];
$object->socid = $_POST["socid"];
$result = $object->update($user);
if ($result > 0)
{
Header("Location: fiche.php?id=".$_POST["id"]);
Header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
$mesg=$deplacement->error;
$mesg=$object->error;
}
}
else
{
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]);
Header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
}
// Set into a project
if ($_POST['action'] == 'classin')
if ($action == 'classin')
{
$trip = new Deplacement($db);
$trip->fetch($_GET['id']);
$trip->fetch($id);
$result=$trip->setProject($_POST['projectid']);
if ($result < 0) dol_print_error($db,$trip->error);
}
@ -180,7 +181,7 @@ $html = new Form($db);
/*
* Action create
*/
if ($_GET["action"] == 'create')
if ($action == 'create')
{
print_fiche_titre($langs->trans("NewTrip"));
@ -191,7 +192,7 @@ if ($_GET["action"] == 'create')
$_POST["reday"],
$_POST["reyear"]);
print "<form name='add' action=\"fiche.php\" method=\"post\">\n";
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
@ -257,40 +258,24 @@ else
{
if ($id)
{
$deplacement = new Deplacement($db);
$result = $deplacement->fetch($id);
$result = $object->fetch($id);
if ($result > 0)
{
if ($mesg) print $mesg."<br>";
dol_htmloutput_mesg($mesg);
$h=0;
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$deplacement->id";
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/note.php?id=$deplacement->id";
$head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note';
$h++;
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/info.php?id=$deplacement->id";
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
$head = trip_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip');
if ($_GET["action"] == 'edit')
{
$soc = new Societe($db);
if ($deplacement->socid)
if ($object->socid)
{
$soc->fetch($deplacement->socid);
$soc->fetch($object->socid);
}
print "<form name='update' action=\"fiche.php\" method=\"post\">\n";
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$id.'">';
@ -300,28 +285,28 @@ else
// Ref
print "<tr>";
print '<td width="20%">'.$langs->trans("Ref").'</td><td>';
print $deplacement->ref;
print $object->ref;
print '</td></tr>';
// Type
print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
print $html->select_type_fees($_POST["type"]?$_POST["type"]:$deplacement->type,'type',0);
print $html->select_type_fees($_POST["type"]?$_POST["type"]:$object->type,'type',0);
print '</td></tr>';
// Who
print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
print $html->select_users($_POST["fk_user"]?$_POST["fk_user"]:$deplacement->fk_user,'fk_user',0);
print $html->select_users($_POST["fk_user"]?$_POST["fk_user"]:$object->fk_user,'fk_user',0);
print '</td></tr>';
// Date
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
print $html->select_date($deplacement->date,'','','','','update');
print $html->select_date($object->date,'','','','','update');
print '</td></tr>';
// Km
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" class="flat" size="10" value="'.$deplacement->km.'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" class="flat" size="10" value="'.$object->km.'"></td></tr>';
// Where
print "<tr>";
@ -344,40 +329,40 @@ else
/*
* Confirmation de la suppression du deplacement
*/
if ($_GET["action"] == 'delete')
if ($action == 'delete')
{
$ret=$html->form_confirm("fiche.php?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete");
if ($ret == 'html') print '<br>';
}
$soc = new Societe($db);
if ($deplacement->socid) $soc->fetch($deplacement->socid);
if ($object->socid) $soc->fetch($object->socid);
print '<table class="border" width="100%">';
// Ref
print "<tr>";
print '<td width="20%">'.$langs->trans("Ref").'</td><td>';
print $html->showrefnav($deplacement,'id','',1,'rowid','ref','');
print $html->showrefnav($object,'id','',1,'rowid','ref','');
print '</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans($deplacement->type).'</td></tr>';
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans($object->type).'</td></tr>';
// Who
print '<tr><td>'.$langs->trans("Person").'</td><td>';
$userfee=new User($db);
$userfee->fetch($deplacement->fk_user);
$userfee->fetch($object->fk_user);
print $userfee->getNomUrl(1);
print '</td></tr>';
// Date
print '<tr><td>'.$langs->trans("Date").'</td><td>';
print dol_print_date($deplacement->date,'day');
print dol_print_date($object->date,'day');
print '</td></tr>';
// Km/Price
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td><td>'.$deplacement->km.'</td></tr>';
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td><td>'.$object->km.'</td></tr>';
// Where
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';
@ -397,7 +382,7 @@ else
print '</td>';
if ($_GET['action'] != 'classify')
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;id='.$deplacement->id.'">';
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;id='.$object->id.'">';
print img_edit($langs->trans('SetProject'),1);
print '</a></td>';
}
@ -405,18 +390,18 @@ else
print '</td><td colspan="3">';
if ($_GET['action'] == 'classify')
{
$html->form_project($_SERVER['PHP_SELF'].'?id='.$deplacement->id, $deplacement->socid, $deplacement->fk_project,'projectid');
$html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid');
}
else
{
$html->form_project($_SERVER['PHP_SELF'].'?id='.$deplacement->id, $deplacement->socid, $deplacement->fk_project,'none');
$html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none');
}
print '</td>';
print '</tr>';
}
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$deplacement->getLibStatut(4).'</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
print "</table>";
@ -439,7 +424,7 @@ else
print '<div class="tabsAction">';
if ($_GET["action"] != 'create' && $_GET["action"] != 'edit')
if ($action != 'create' && $action != 'edit')
{
if ($user->rights->deplacement->creer)
{

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -32,7 +32,7 @@ $langs->load("users");
$langs->load("trips");
// Security check
$socid = $_GET["socid"]?$_GET["socid"]:'';
$socid = GETPOST('socid');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'deplacement','','');

View File

@ -17,60 +17,45 @@
*/
/**
* \file htdocs/compta/deplacement/info.php
* \ingroup facture
* \brief Page to show a trip information
* \file htdocs/compta/deplacement/info.php
* \ingroup trip
* \brief Page to show a trip information
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/trip.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/class/deplacement.class.php");
$langs->load("trips");
// Security check
$id = GETPOST('id');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'deplacement', $id, '');
/*
* View
*/
llxHeader();
if ($id)
{
$deplacement = new Deplacement($db);
$deplacement->fetch($_GET["id"], $user);
$deplacement->info($_GET["id"]);
if ($deplacement > 0)
{
if ($mesg) print $mesg."<br>";
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/fiche.php?id='.$_GET["id"];
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/note.php?id='.$_GET["id"];
$head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note';
$h++;
$object = new Deplacement($db);
$object->fetch($id);
$object->info($id);
$head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/info.php?id='.$_GET["id"];
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
$head = trip_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip');
dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip');
print '<table width="100%"><tr><td>';
dol_print_object_info($deplacement);
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
}
else
{
dol_print_error($db);
}
}
$db->close();

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -32,7 +32,7 @@ $langs->load("users");
$langs->load("trips");
// Security check
$socid = $_GET["socid"]?$_GET["socid"]:'';
$socid = GETPOST('socid');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'deplacement','','');

View File

@ -23,42 +23,38 @@
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/trip.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/class/deplacement.class.php");
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
if (!$user->rights->deplacement->lire)
accessforbidden();
$langs->load("companies");
$langs->load("bills");
$langs->load("trips");
// Securiy check
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$socid = $user->societe_id;
}
$id = GETPOST('id');
$ref = GETPOST('ref');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'deplacement', $id, '');
$trip = new Deplacement($db);
$object = new Deplacement($db);
/******************************************************************************/
/* Actions */
/******************************************************************************/
if ($_POST["action"] == 'update_public' && $user->rights->deplacement->creer)
if ($action == 'update_public' && $user->rights->deplacement->creer)
{
$db->begin();
$trip->fetch($_GET["id"]);
$object->fetch($id);
$res=$trip->update_note_public($_POST["note_public"],$user);
$res=$object->update_note_public($_POST["note_public"]);
if ($res < 0)
{
$mesg='<div class="error">'.$fac->error.'</div>';
$mesg='<div class="error">'.$object->error.'</div>';
$db->rollback();
}
else
@ -67,16 +63,16 @@ if ($_POST["action"] == 'update_public' && $user->rights->deplacement->creer)
}
}
if ($_POST["action"] == 'update' && $user->rights->deplacement->creer)
if ($action == 'update' && $user->rights->deplacement->creer)
{
$db->begin();
$trip->fetch($_GET["id"]);
$object->fetch($id);
$res=$trip->update_note($_POST["note"],$user);
$res=$object->update_note($_POST["note"]);
if ($res < 0)
{
$mesg='<div class="error">'.$fac->error.'</div>';
$mesg='<div class="error">'.$object->error.'</div>';
$db->rollback();
}
else
@ -95,53 +91,34 @@ llxHeader();
$html = new Form($db);
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
$trip = new Deplacement($db);
$trip->fetch($id,$ref);
$object->fetch($id, $ref);
$soc = new Societe($db);
$soc->fetch($trip->socid);
$soc->fetch($object->socid);
$h=0;
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$trip->id";
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/note.php?id=$trip->id";
$head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note';
$h++;
$head[$h][0] = DOL_URL_ROOT."/compta/deplacement/info.php?id=$deplacement->id";
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
$head = trip_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("TripCard"), 0, 'trip');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">';
$morehtmlref='';
print $html->showrefnav($trip,'ref','',1,'ref','ref',$morehtmlref);
print $html->showrefnav($object,'ref','',1,'ref','ref',$morehtmlref);
print '</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans($trip->type).'</td></tr>';
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans($object->type).'</td></tr>';
// Who
print "<tr>";
print '<td>'.$langs->trans("Person").'</td><td>';
$userfee=new User($db);
$userfee->fetch($trip->fk_user);
$userfee->fetch($object->fk_user);
print $userfee->getNomUrl(1);
print '</td></tr>';
@ -153,18 +130,18 @@ if ($id > 0 || ! empty($ref))
// Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
if ($action == 'edit')
{
print '<form method="post" action="note.php?id='.$trip->id.'">';
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="8">'.$trip->note_public."</textarea><br>";
print '<textarea name="note_public" cols="80" rows="8">'.$object->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($trip->note_public?nl2br($trip->note_public):"&nbsp;");
print ($object->note_public?nl2br($object->note_public):"&nbsp;");
}
print "</td></tr>";
@ -173,18 +150,18 @@ if ($id > 0 || ! empty($ref))
{
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
if ($action == 'edit')
{
print '<form method="post" action="note.php?id='.$trip->id.'">';
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note" cols="80" rows="8">'.$trip->note."</textarea><br>";
print '<textarea name="note" cols="80" rows="8">'.$object->note."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($trip->note?nl2br($trip->note):"&nbsp;");
print ($object->note?nl2br($object->note):"&nbsp;");
}
print "</td></tr>";
}
@ -198,9 +175,9 @@ if ($id > 0 || ! empty($ref))
print '</div>';
print '<div class="tabsAction">';
if ($user->rights->deplacement->creer && $_GET["action"] <> 'edit')
if ($action <> 'edit' && $user->rights->deplacement->creer)
{
print "<a class=\"butAction\" href=\"note.php?id=$trip->id&amp;action=edit\">".$langs->trans('Modify')."</a>";
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id .'&amp;action=edit">' . $langs->trans('Modify') . '</a>';
}
print "</div>";

View File

@ -67,3 +67,5 @@ ALTER TABLE llx_product_fournisseur_price DROP FOREIGN KEY fk_product_fournisseu
DROP TABLE IF EXISTS llx_pos_tmp;
ALTER TABLE llx_deplacement ADD COLUMN fk_user_modif integer AFTER fk_user_author;

View File

@ -1,7 +1,7 @@
-- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009-2011 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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
@ -21,14 +21,14 @@
create table llx_deplacement
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) DEFAULT NULL, -- Ref donation (TODO change to NOT NULL)
entity integer DEFAULT 1 NOT NULL, -- multi company id
ref varchar(30) DEFAULT NULL, -- Ref donation (TODO change to NOT NULL)
entity integer DEFAULT 1 NOT NULL, -- multi company id
datec datetime NOT NULL,
tms timestamp,
dated datetime,
fk_user integer NOT NULL,
fk_user_author integer,
fk_user_modif integer, -- utilisateur qui a modifie l'info
fk_user_modif integer, -- utilisateur qui a modifie l'info
type varchar(12) NOT NULL,
fk_statut integer DEFAULT 1 NOT NULL,
km real,

61
htdocs/lib/trip.lib.php Normal file
View File

@ -0,0 +1,61 @@
<?php
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
*
* 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, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/lib/trip.lib.php
* \brief Ensemble de fonctions de base pour les deplacements
*/
/**
* Enter description here...
*
* @param $object
* @return array
*/
function trip_prepare_head($object)
{
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/fiche.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/note.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'trip');
$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
return $head;
}
?>