Management of fees.
This commit is contained in:
parent
d266c4cc5c
commit
6210818c4e
@ -33,8 +33,11 @@ require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
||||
class Deplacement extends CommonObject
|
||||
{
|
||||
var $db;
|
||||
var $errors;
|
||||
|
||||
var $id;
|
||||
var $user;
|
||||
var $fk_user_author;
|
||||
var $fk_user;
|
||||
var $km;
|
||||
var $note;
|
||||
|
||||
@ -63,12 +66,17 @@ class Deplacement extends CommonObject
|
||||
$this->error='ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->fk_user) || $this->fk_user < 0)
|
||||
{
|
||||
$this->error='ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement";
|
||||
$sql.= " (datec, fk_user_author, fk_user, type)";
|
||||
$sql.= " VALUES (now(), ".$user->id.", ".$user->id.", '".$this->type."')";
|
||||
$sql.= " VALUES (now(), ".$user->id.", ".$this->fk_user.", '".$this->type."')";
|
||||
|
||||
dolibarr_syslog("Deplacement::create sql=".$sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -110,12 +118,17 @@ class Deplacement extends CommonObject
|
||||
$this->error='ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (empty($this->fk_user) || $this->fk_user < 0)
|
||||
{
|
||||
$this->error='ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."deplacement ";
|
||||
$sql .= " SET km = ".$this->km;
|
||||
$sql .= " , dated = '".$this->db->idate($this->date)."'";
|
||||
$sql .= " , type = '".$this->type."'";
|
||||
$sql .= " , fk_user = ".$this->userid;
|
||||
$sql .= " , fk_user = ".$this->fk_user;
|
||||
$sql .= " , fk_soc = ".($this->socid > 0?$this->socid:'null');
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
@ -149,7 +162,7 @@ class Deplacement extends CommonObject
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->date = $obj->dated;
|
||||
$this->userid = $obj->fk_user;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->km = $obj->km;
|
||||
$this->type = $obj->type;
|
||||
|
||||
@ -61,7 +61,8 @@ if ($_POST["action"] == 'add' && $user->rights->deplacement->creer)
|
||||
$deplacement->km = $_POST["km"];
|
||||
$deplacement->type = $_POST["type"];
|
||||
$deplacement->socid = $_POST["socid"];
|
||||
$deplacement->userid = $user->id; //$_POST["km"];
|
||||
$deplacement->fk_user = $_POST["fk_user"];
|
||||
|
||||
$id = $deplacement->create($user);
|
||||
|
||||
if ($id > 0)
|
||||
@ -96,6 +97,7 @@ if ($_POST["action"] == 'update' && $user->rights->deplacement->creer)
|
||||
|
||||
$deplacement->km = $_POST["km"];
|
||||
$deplacement->type = $_POST["type"];
|
||||
$deplacement->fk_user = $_POST["fk_user"];
|
||||
|
||||
$result = $deplacement->update($user);
|
||||
|
||||
@ -135,10 +137,9 @@ if ($_GET["action"] == 'create')
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Person").'</td><td>'.$user->fullname.'</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
|
||||
print '<td width="25%">'.$langs->trans("CompanyVisited").'</td><td>';
|
||||
print $html->select_societes($_GET["socid"],'socid','',1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -147,6 +148,11 @@ if ($_GET["action"] == 'create')
|
||||
print $html->select_type_fees($_GET["type"],'type',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("Person").'</td><td>';
|
||||
print $html->select_users($_GET["fk_user"],'fk_user',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("Date").'</td><td>';
|
||||
print $html->select_date('','','','','','add');
|
||||
@ -187,11 +193,9 @@ else
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($deplacement->socid);
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("Person").'</td><td>'.$user->fullname.'</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
|
||||
print $html->select_societes($soc->id);
|
||||
print $html->select_societes($soc->id,'socid','',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
@ -199,7 +203,12 @@ else
|
||||
print $html->select_type_fees($deplacement->type,'type',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
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>';
|
||||
print $html->select_date($deplacement->date,'','','','','update');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Kilometers").'</td><td><input name="km" class="flat" size="10" value="'.$deplacement->km.'"></td></tr>';
|
||||
@ -236,9 +245,13 @@ else
|
||||
$soc->fetch($deplacement->socid);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Person").'</td><td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$user->id.'">'.$user->fullname.'</a></td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("CompanyVisited").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("Type").'</td><td>'.$langs->trans($deplacement->type).'</td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("Person").'</td><td>';
|
||||
$userfee=new User($db,$deplacement->fk_user);
|
||||
$userfee->fetch();
|
||||
print $userfee->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
print dolibarr_print_date($deplacement->date);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -63,32 +63,33 @@ if ($user->societe_id > 0)
|
||||
}
|
||||
|
||||
$sql = "SELECT s.nom, s.rowid as socid,"; // Ou
|
||||
$sql.= " d.rowid, ".$db->pdate("d.dated")." as dd, d.km, "; // Comment
|
||||
$sql.= " d.rowid, d.type, ".$db->pdate("d.dated")." as dd, d.km, "; // Comment
|
||||
$sql.= " u.name, u.firstname"; // Qui
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."deplacement as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on d.fk_soc = s.rowid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE d.fk_soc = s.rowid AND d.fk_user = u.rowid";
|
||||
$sql.= " WHERE d.fk_user = u.rowid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.rowid = ".$socid;
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1 ,$offset);
|
||||
|
||||
//print $sql;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print_barre_liste($langs->trans("ListOfTrips"), $page, "index.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($langs->trans("ListOfFees"), $page, "index.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print_liste_field_titre($langs->trans("Ref"),"index.php","d.rowid","","&socid=$socid",'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Type"),"index.php","d.type","","&socid=$socid",'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Date"),"index.php","d.dated","","&socid=$socid",'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","&socid=$socid",'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Person"),"index.php","u.name","","&socid=$socid",'',$sortfield,$sortorder);
|
||||
@ -104,6 +105,7 @@ if ($resql)
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowTrip"),"trip").' '.$objp->rowid.'</a></td>';
|
||||
print '<td>'.$langs->trans($objp->type).'</td>';
|
||||
print '<td>'.dolibarr_print_date($objp->dd).'</td>';
|
||||
print '<td>'.$soc->getNomUrl(1).'</a></td>';
|
||||
print '<td align="left"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$objp->firstname.' '.$objp->name.'</a></td>';
|
||||
|
||||
@ -873,8 +873,8 @@ class Form
|
||||
* \param selected Id user preselected
|
||||
* \param htmlname Field name in form
|
||||
* \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
|
||||
* \param disabled If select list must be disabled
|
||||
* \param exclude Liste des id utilisateurs à exclure
|
||||
* \param exclude List of users id to exclude
|
||||
* \param disabled If select list must be disabled
|
||||
*/
|
||||
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0)
|
||||
{
|
||||
|
||||
@ -5,6 +5,7 @@ TripsAndExpenses=Trips and expenses
|
||||
TripCard=Trip card
|
||||
AddTrip=Add trip
|
||||
ListOfTrips=List of trips
|
||||
ListOfFees=List of fees
|
||||
NewTrip=New trip
|
||||
CompanyVisited=Company/fundation visited
|
||||
Kilometers=Kilometers
|
||||
|
||||
@ -5,6 +5,7 @@ TripsAndExpenses=D
|
||||
TripCard=Fiche déplacement
|
||||
AddTrip=Ajouter déplacement
|
||||
ListOfTrips=Liste des déplacements
|
||||
ListOfFees=Liste des notes de frais
|
||||
NewTrip=Nouveau déplacement
|
||||
CompanyVisited=Société/Institution visitée
|
||||
Kilometers=Kilomètres
|
||||
|
||||
@ -1371,6 +1371,13 @@ insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_LOW', '
|
||||
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_MEDIUM', 'Medium', 3);
|
||||
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_HIGH', 'High', 4);
|
||||
|
||||
--
|
||||
-- Type fees
|
||||
--
|
||||
|
||||
insert into llx_c_type_fees (code,libelle,active) values ('TF_OTHER', 'Other', 1);
|
||||
insert into llx_c_type_fees (code,libelle,active) values ('TF_TRIP', 'Trip', 1);
|
||||
insert into llx_c_type_fees (code,libelle,active) values ('TF_LUNCH', 'Lunch', 1);
|
||||
|
||||
|
||||
INSERT INTO llx_const (name,value,type,visible,note) VALUES ('MAIN_AGENDA_ACTIONAUTO_COMPANY_CREATE','1','chaine',0,'');
|
||||
|
||||
@ -313,3 +313,19 @@ ALTER TABLE llx_commande_fournisseurdet DROP COLUMN price;
|
||||
|
||||
alter table llx_adherent modify fk_user_mod integer;
|
||||
alter table llx_adherent modify fk_user_valid integer;
|
||||
|
||||
create table llx_c_type_fees
|
||||
(
|
||||
id integer AUTO_INCREMENT PRIMARY KEY,
|
||||
code varchar(12) UNIQUE NOT NULL,
|
||||
libelle varchar(30),
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
)type=innodb;
|
||||
|
||||
|
||||
alter table llx_deplacement modify type varchar(12) NOT NULL;
|
||||
|
||||
insert into llx_c_type_fees (code,libelle,active) values ('TF_OTHER', 'Other', 1);
|
||||
insert into llx_c_type_fees (code,libelle,active) values ('TF_TRIP', 'Trip', 1);
|
||||
insert into llx_c_type_fees (code,libelle,active) values ('TF_LUNCH', 'Lunch', 1);
|
||||
|
||||
|
||||
28
mysql/tables/llx_c_type_fees.sql
Normal file
28
mysql/tables/llx_c_type_fees.sql
Normal file
@ -0,0 +1,28 @@
|
||||
-- ========================================================================
|
||||
-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2004 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, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ========================================================================
|
||||
|
||||
create table llx_c_type_fees
|
||||
(
|
||||
id integer AUTO_INCREMENT PRIMARY KEY,
|
||||
code varchar(12) UNIQUE NOT NULL,
|
||||
libelle varchar(30),
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
)type=innodb;
|
||||
@ -26,7 +26,7 @@ create table llx_deplacement
|
||||
dated datetime,
|
||||
fk_user integer NOT NULL,
|
||||
fk_user_author integer,
|
||||
type smallint NOT NULL,
|
||||
type varchar(12) NOT NULL,
|
||||
km smallint,
|
||||
fk_soc integer,
|
||||
note text
|
||||
|
||||
Loading…
Reference in New Issue
Block a user