Works on multi-company

This commit is contained in:
Regis Houssin 2009-12-10 13:08:19 +00:00
parent 73f6abdeca
commit a4eea3ec7b
6 changed files with 62 additions and 42 deletions

View File

@ -25,7 +25,7 @@
/*! \class ComptaCompte /*! \class ComptaCompte
\brief Classe permettant la gestion des comptes généraux de compta \brief Classe permettant la gestion des comptes generaux de compta
*/ */
class ComptaCompte class ComptaCompte
@ -38,7 +38,7 @@ class ComptaCompte
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param DB handler accès base de données * \param DB handler acces base de donnees
* \param id id compte (0 par defaut) * \param id id compte (0 par defaut)
*/ */
@ -49,7 +49,7 @@ class ComptaCompte
} }
/** /**
* \brief Insère le produit en base * \brief Insere le produit en base
* \param user utilisateur qui effectue l'insertion * \param user utilisateur qui effectue l'insertion
*/ */

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,18 +19,18 @@
*/ */
/** /**
\file htdocs/compta/deplacement/deplacement.class.php * \file htdocs/compta/deplacement/deplacement.class.php
\ingroup deplacement * \ingroup deplacement
\brief Fichier de la classe des deplacements * \brief Fichier de la classe des deplacements
\version $Id$ * \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
/** /**
\class Deplacement * \class Deplacement
\brief Class to manage trips and working credit notes * \brief Class to manage trips and working credit notes
*/ */
class Deplacement extends CommonObject class Deplacement extends CommonObject
{ {
var $db; var $db;
@ -43,8 +44,9 @@ class Deplacement extends CommonObject
var $socid; var $socid;
/* /**
* Constructor * \brief Constructeur de la classe
* \param DB handler acces base de donnees
*/ */
function Deplacement($DB) function Deplacement($DB)
{ {
@ -59,9 +61,12 @@ class Deplacement extends CommonObject
* @param unknown_type $user User that creat * @param unknown_type $user User that creat
* @param unknown_type $type Type of record: 0=trip, 1=credit note * @param unknown_type $type Type of record: 0=trip, 1=credit note
* @return unknown * @return unknown
* @TODO Add ref number
*/ */
function create($user) function create($user)
{ {
global $conf;
// Check parameters // Check parameters
if (empty($this->type) || $this->type < 0) if (empty($this->type) || $this->type < 0)
{ {
@ -76,9 +81,19 @@ class Deplacement extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement (";
$sql.= " (datec, fk_user_author, fk_user, type)"; $sql.= "datec";
$sql.= " VALUES (".$this->db->idate(mktime()).", ".$user->id.", ".$this->fk_user.", '".$this->type."')"; $sql.= ", entity";
$sql.= ", fk_user_author";
$sql.= ", fk_user";
$sql.= ", type";
$sql.= ") VALUES (";
$sql.= $this->db->idate(mktime());
$sql.= ", ".$conf->entity;
$sql.= ", ".$user->id;
$sql.= ", ".$this->fk_user;
$sql.= ", '".$this->type."'";
$sql.= ")";
dol_syslog("Deplacement::create sql=".$sql, LOG_DEBUG); dol_syslog("Deplacement::create sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -107,7 +122,6 @@ class Deplacement extends CommonObject
} }
/** /**
*
* *
*/ */
function update($user) function update($user)
@ -151,7 +165,7 @@ class Deplacement extends CommonObject
} }
} }
/** /**
* *
*/ */
function fetch($id) function fetch($id)
@ -183,7 +197,7 @@ class Deplacement extends CommonObject
} }
} }
/* /**
* *
*/ */
function delete($id) function delete($id)

View File

@ -21,7 +21,7 @@
/** /**
\file htdocs/compta/deplacement/index.php \file htdocs/compta/deplacement/index.php
\brief Page liste des déplacements \brief Page liste des deplacements
\version $Id$ \version $Id$
*/ */
@ -56,16 +56,16 @@ $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$sql = "SELECT s.nom, s.rowid as socid,"; // Ou $sql = "SELECT s.nom, s.rowid as socid,"; // Ou
$sql.= " d.rowid, d.type, ".$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 $sql.= " u.name, u.firstname"; // Qui
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= ", ".MAIN_DB_PREFIX."deplacement as d"; $sql.= ", ".MAIN_DB_PREFIX."deplacement as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on d.fk_soc = s.rowid"; $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"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE d.fk_user = u.rowid"; $sql.= " WHERE d.fk_user = u.rowid";
$sql.= " AND s.entity = ".$conf->entity; $sql.= " AND d.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1 ,$offset); $sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1 ,$offset);

View File

@ -11,3 +11,6 @@ ALTER TABLE llx_don ADD COLUMN ref varchar(30) DEFAULT NULL AFTER rowid;
ALTER TABLE llx_don ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_don ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_stock_mouvement ADD COLUMN label varchar(128); ALTER TABLE llx_stock_mouvement ADD COLUMN label varchar(128);
ALTER TABLE llx_deplacement ADD COLUMN ref varchar(30) DEFAULT NULL AFTER rowid;
ALTER TABLE llx_deplacement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;

View File

@ -1,5 +1,6 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@ -20,14 +21,16 @@
create table llx_deplacement create table llx_deplacement
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
datec datetime NOT NULL, ref varchar(30) DEFAULT NULL, -- Ref donation (TODO change to NOT NULL)
tms timestamp, entity integer DEFAULT 1 NOT NULL, -- multi company id
dated datetime, datec datetime NOT NULL,
fk_user integer NOT NULL, tms timestamp,
fk_user_author integer, dated datetime,
type varchar(12) NOT NULL, fk_user integer NOT NULL,
km real, fk_user_author integer,
fk_soc integer, type varchar(12) NOT NULL,
note text km real,
fk_soc integer,
note text
)type=innodb; )type=innodb;

View File

@ -24,12 +24,12 @@
create table llx_document_model create table llx_document_model
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
nom varchar(50), nom varchar(50),
entity integer DEFAULT 1 NOT NULL, -- multi company id entity integer DEFAULT 1 NOT NULL, -- multi company id
type varchar(20) NOT NULL, type varchar(20) NOT NULL,
libelle varchar(255), libelle varchar(255),
description text description text
)type=innodb; )type=innodb;
-- --