Works on multi-company
This commit is contained in:
parent
73f6abdeca
commit
a4eea3ec7b
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
/*! \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
|
||||
@ -38,7 +38,7 @@ class ComptaCompte
|
||||
|
||||
/**
|
||||
* \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)
|
||||
*/
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -18,18 +19,18 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/deplacement/deplacement.class.php
|
||||
\ingroup deplacement
|
||||
\brief Fichier de la classe des deplacements
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/compta/deplacement/deplacement.class.php
|
||||
* \ingroup deplacement
|
||||
* \brief Fichier de la classe des deplacements
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
||||
|
||||
/**
|
||||
\class Deplacement
|
||||
\brief Class to manage trips and working credit notes
|
||||
*/
|
||||
* \class Deplacement
|
||||
* \brief Class to manage trips and working credit notes
|
||||
*/
|
||||
class Deplacement extends CommonObject
|
||||
{
|
||||
var $db;
|
||||
@ -43,8 +44,9 @@ class Deplacement extends CommonObject
|
||||
var $socid;
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler acces base de donnees
|
||||
*/
|
||||
function Deplacement($DB)
|
||||
{
|
||||
@ -59,9 +61,12 @@ class Deplacement extends CommonObject
|
||||
* @param unknown_type $user User that creat
|
||||
* @param unknown_type $type Type of record: 0=trip, 1=credit note
|
||||
* @return unknown
|
||||
* @TODO Add ref number
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Check parameters
|
||||
if (empty($this->type) || $this->type < 0)
|
||||
{
|
||||
@ -76,9 +81,19 @@ class Deplacement extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement";
|
||||
$sql.= " (datec, fk_user_author, fk_user, type)";
|
||||
$sql.= " VALUES (".$this->db->idate(mktime()).", ".$user->id.", ".$this->fk_user.", '".$this->type."')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement (";
|
||||
$sql.= "datec";
|
||||
$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);
|
||||
$result = $this->db->query($sql);
|
||||
@ -108,7 +123,6 @@ class Deplacement extends CommonObject
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function update($user)
|
||||
{
|
||||
@ -151,7 +165,7 @@ class Deplacement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function fetch($id)
|
||||
@ -183,7 +197,7 @@ class Deplacement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function delete($id)
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
/**
|
||||
\file htdocs/compta/deplacement/index.php
|
||||
\brief Page liste des déplacements
|
||||
\brief Page liste des deplacements
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
@ -56,16 +56,16 @@ $pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
|
||||
$sql = "SELECT s.nom, s.rowid as socid,"; // Ou
|
||||
$sql.= " d.rowid, d.type, ".$db->pdate("d.dated")." as dd, d.km, "; // Comment
|
||||
$sql.= " u.name, u.firstname"; // Qui
|
||||
$sql = "SELECT s.nom, s.rowid as socid,"; // Ou
|
||||
$sql.= " d.rowid, d.type, ".$db->pdate("d.dated")." as dd, d.km, "; // Comment
|
||||
$sql.= " u.name, u.firstname"; // Qui
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= ", ".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";
|
||||
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.= " AND s.entity = ".$conf->entity;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql.= " AND d.entity = ".$conf->entity;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1 ,$offset);
|
||||
|
||||
|
||||
@ -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_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;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ============================================================================
|
||||
-- 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
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -20,14 +21,16 @@
|
||||
|
||||
create table llx_deplacement
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
datec datetime NOT NULL,
|
||||
tms timestamp,
|
||||
dated datetime,
|
||||
fk_user integer NOT NULL,
|
||||
fk_user_author integer,
|
||||
type varchar(12) NOT NULL,
|
||||
km real,
|
||||
fk_soc integer,
|
||||
note text
|
||||
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
|
||||
datec datetime NOT NULL,
|
||||
tms timestamp,
|
||||
dated datetime,
|
||||
fk_user integer NOT NULL,
|
||||
fk_user_author integer,
|
||||
type varchar(12) NOT NULL,
|
||||
km real,
|
||||
fk_soc integer,
|
||||
note text
|
||||
)type=innodb;
|
||||
|
||||
@ -24,12 +24,12 @@
|
||||
|
||||
create table llx_document_model
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
nom varchar(50),
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
type varchar(20) NOT NULL,
|
||||
libelle varchar(255),
|
||||
description text
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
nom varchar(50),
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
type varchar(20) NOT NULL,
|
||||
libelle varchar(255),
|
||||
description text
|
||||
)type=innodb;
|
||||
|
||||
--
|
||||
|
||||
Loading…
Reference in New Issue
Block a user