Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2011-10-23 20:02:39 +02:00
commit 7dd3fec485
13 changed files with 320 additions and 227 deletions

View File

@ -120,15 +120,25 @@ foreach ($modulesdir as $dir)
if ($modName)
{
include_once($dir."/".$file);
$objMod = new $modName($db);
if ($objMod->rights_class) {
include_once($dir.$file);
$objMod = new $modName($db);
$ret=$objMod->insert_permissions(0);
// Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles))
{
foreach($objMod->langfiles as $domain)
{
$langs->load($domain);
}
}
// Load all permissions
if ($objMod->rights_class)
{
$ret=$objMod->insert_permissions(0);
$modules[$objMod->rights_class]=$objMod;
//print "modules[".$objMod->rights_class."]=$objMod;";
}
$modules[$objMod->rights_class]=$objMod;
//print "modules[".$objMod->rights_class."]=$objMod;";
}
}
}
}
@ -137,7 +147,6 @@ foreach ($modulesdir as $dir)
$db->commit();
// Affiche lignes des permissions
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
@ -149,10 +158,11 @@ $sql.= " ORDER BY r.module, r.id";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$var=True;
$old = "";
$num = $db->num_rows($result);
$i = 0;
$var = True;
$oldmod = "";
while ($i < $num)
{
$obj = $db->fetch_object($result);
@ -166,7 +176,7 @@ if ($result)
// Check if permission we found is inside a module definition. If not, we discard it.
$found=false;
foreach($objMod->rights as $key => $val)
foreach($modules[$obj->module]->rights as $key => $val)
{
$rights_class=$objMod->rights_class;
if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms))
@ -180,12 +190,13 @@ if ($result)
$i++;
continue;
}
// Break found, it's a new module to catch
if ($old <> $obj->module)
if ($oldmod <> $obj->module)
{
$objMod=$modules[$obj->module];
$picto=($objMod->picto?$objMod->picto:'generic');
$oldmod = $obj->module;
$objMod = $modules[$obj->module];
$picto = ($objMod->picto?$objMod->picto:'generic');
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
@ -193,7 +204,6 @@ if ($result)
print '<td align="center">'.$langs->trans("Default").'</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
$old = $obj->module;
}
$var=!$var;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010-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
@ -74,7 +74,7 @@ foreach ($conf->file->dol_document_root as $type => $dirroot)
// Load list of modules
foreach($modulesdir as $dir)
{
$handle=opendir($dir);
$handle=@opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)

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,35 +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 = 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.'">';
@ -295,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>";
@ -339,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>';
@ -392,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>';
}
@ -400,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>";
@ -434,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

@ -0,0 +1,64 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 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
* 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/>.
*/
/**
* \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)
{
$object = new Deplacement($db);
$object->fetch($id);
$object->info($id);
$head = trip_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
}
$db->close();
llxFooter();
?>

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,48 +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 = 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>';
@ -148,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>";
@ -168,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>";
}
@ -193,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

@ -742,11 +742,9 @@ class Facture extends CommonObject
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', el.fk_source';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = '".$this->element."'";
$sql.= ' WHERE f.entity = '.$conf->entity;
if ($rowid) $sql.= " AND f.rowid=".$rowid;
if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
@ -761,63 +759,45 @@ class Facture extends CommonObject
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->ref = $obj->facnumber;
$this->ref_client = $obj->ref_client;
$this->ref_ext = $obj->ref_ext;
$this->ref_int = $obj->ref_int;
$this->type = $obj->type;
$this->date = $this->db->jdate($obj->df);
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_validation = $this->db->jdate($obj->datev);
$this->datem = $this->db->jdate($obj->datem);
$this->amount = $obj->amount;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
$this->remise = $obj->remise;
$this->total_ht = $obj->total;
$this->total_tva = $obj->tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
$this->total_ttc = $obj->total_ttc;
$this->paye = $obj->paye;
$this->close_code = $obj->close_code;
$this->close_note = $obj->close_note;
$this->socid = $obj->fk_soc;
$this->statut = $obj->fk_statut;
$this->date_lim_reglement = $this->db->jdate($obj->dlr);
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code;
$this->mode_reglement = $obj->mode_reglement_libelle;
$this->cond_reglement_id = $obj->fk_cond_reglement;
$this->cond_reglement_code = $obj->cond_reglement_code;
$this->cond_reglement = $obj->cond_reglement_libelle;
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
$this->fk_project = $obj->fk_projet;
$this->fk_facture_source = $obj->fk_facture_source;
$this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid;
$this->modelpdf = $obj->model_pdf;
$this->commande_id = $obj->fk_commande;
if ($this->commande_id)
{
$sql = "SELECT ref";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE rowid = ".$this->commande_id;
$resqlcomm = $this->db->query($sql);
if ($resqlcomm)
{
$objc = $this->db->fetch_object($resqlcomm);
$this->commande_ref = $objc->ref;
$this->db->free($resqlcomm);
}
}
$this->id = $obj->rowid;
$this->ref = $obj->facnumber;
$this->ref_client = $obj->ref_client;
$this->ref_ext = $obj->ref_ext;
$this->ref_int = $obj->ref_int;
$this->type = $obj->type;
$this->date = $this->db->jdate($obj->df);
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_validation = $this->db->jdate($obj->datev);
$this->datem = $this->db->jdate($obj->datem);
$this->amount = $obj->amount;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
$this->remise = $obj->remise;
$this->total_ht = $obj->total;
$this->total_tva = $obj->tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
$this->total_ttc = $obj->total_ttc;
$this->paye = $obj->paye;
$this->close_code = $obj->close_code;
$this->close_note = $obj->close_note;
$this->socid = $obj->fk_soc;
$this->statut = $obj->fk_statut;
$this->date_lim_reglement = $this->db->jdate($obj->dlr);
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code;
$this->mode_reglement = $obj->mode_reglement_libelle;
$this->cond_reglement_id = $obj->fk_cond_reglement;
$this->cond_reglement_code = $obj->cond_reglement_code;
$this->cond_reglement = $obj->cond_reglement_libelle;
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
$this->fk_project = $obj->fk_projet;
$this->fk_facture_source = $obj->fk_facture_source;
$this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid;
$this->modelpdf = $obj->model_pdf;
if ($this->statut == 0) $this->brouillon = 1;

View File

@ -1345,11 +1345,14 @@ abstract class CommonObject
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; }
if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; }
if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; }
if ($objecttype == 'fichinter') { $classpath = 'fichinter/class'; $subelement ='fichinter'; $module ='ficheinter'; }
if ($objecttype == 'fichinter') { $classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter'; }
// TODO ajout temporaire - MAXIME MANGIN
if ($objecttype == 'contratabonnement') { $classpath = 'contrat/class'; $subelement = 'contrat'; $module = 'contratabonnement'; }
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; }
if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; }
if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur'; }
if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur'; }
if ($conf->$module->enabled && $element != $this->element)
{

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,13 +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
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;
}
?>

View File

@ -150,7 +150,7 @@ foreach ($conf->file->dol_document_root as $type => $dirroot)
foreach($modulesdir as $dir)
{
$handle=opendir($dir);
$handle=@opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)