New: early development of multi-company module

This commit is contained in:
Regis Houssin 2009-05-02 14:26:54 +00:00
parent edafd9f333
commit d24d0f0e00
15 changed files with 172 additions and 117 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-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
@ -30,29 +30,18 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/fichinter/fichinter.class.php');
if (!$user->rights->ficheinter->lire) if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php");
accessforbidden();
$langs->load('interventions'); $langs->load('interventions');
require_once(DOL_DOCUMENT_ROOT.'/fichinter/fichinter.class.php'); $fichinterid = isset($_GET["id"])?$_GET["id"]:'';
if ($conf->projet->enabled) // Security check
{ if ($user->societe_id) $socid=$user->societe_id;
require_once(DOL_DOCUMENT_ROOT."/project.class.php"); $result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
}
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
llxHeader(); llxHeader();
$html = new Form($db); $html = new Form($db);
@ -84,6 +73,7 @@ if ($_GET["id"] > 0) {
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'fichinter as fi'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'fichinter as fi';
$sql.= ' WHERE fi.fk_soc = s.rowid'; $sql.= ' WHERE fi.fk_soc = s.rowid';
$sql.= ' AND fi.rowid = '.$fichinter->id; $sql.= ' AND fi.rowid = '.$fichinter->id;
$sql.= ' AND fi.entity = '.$conf->entity;
if ($socid) $sql .= ' AND s.rowid = '.$socid; if ($socid) $sql .= ' AND s.rowid = '.$socid;
$result = $db->query($sql); $result = $db->query($sql);

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -2,8 +2,8 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* *
* 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
@ -37,16 +37,12 @@ $langs->load("other");
$langs->load("fichinter"); $langs->load("fichinter");
$langs->load("companies"); $langs->load("companies");
if (!$user->rights->ficheinter->lire) $fichinterid = isset($_GET["id"])?$_GET["id"]:'';
accessforbidden();
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id) $socid=$user->societe_id;
{ $result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
// Get parameters // Get parameters
$page=$_GET["page"]; $page=$_GET["page"];

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-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
@ -87,6 +87,8 @@ class Fichinter extends CommonObject
*/ */
function create() function create()
{ {
global $conf;
dol_syslog("Fichinter.class::create ref=".$this->ref); dol_syslog("Fichinter.class::create ref=".$this->ref);
if (! is_numeric($this->duree)) { $this->duree = 0; } if (! is_numeric($this->duree)) { $this->duree = 0; }
@ -104,15 +106,26 @@ class Fichinter extends CommonObject
$result=$soc->fetch($this->socid); $result=$soc->fetch($this->socid);
$this->verifyNumRef($soc); $this->verifyNumRef($soc);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datec, ref, fk_user_author, description, model_pdf"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (";
if ($this->projet_id) $sql.= ", fk_projet"; $sql.= "fk_soc";
$sql.= ", datec";
$sql.= ", ref";
$sql.= ", entity";
$sql.= ", fk_user_author";
$sql.= ", description";
$sql.= ", model_pdf";
$sql.= ", fk_projet";
$sql.= ") "; $sql.= ") ";
$sql.= " VALUES (".$this->socid.","; $sql.= " VALUES (";
$sql.= " ".$this->db->idate(mktime()).", '".$this->ref."', ".$this->author; $sql.= $this->socid;
$sql.= ", '".addslashes($this->description)."', '".$this->modelpdf."'"; $sql.= ", ".$this->db->idate(mktime());
if ($this->projet_id) $sql .= ", ".$this->projet_id; $sql.= ", '".$this->ref."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".$this->author;
$sql.= ", '".addslashes($this->description)."'";
$sql.= ", '".$this->modelpdf."'";
$sql.= ", ".($this->projet_id ? $this->projet_id : 0);
$sql.= ")"; $sql.= ")";
$sqlok = 0;
dol_syslog("Fichinter::create sql=".$sql); dol_syslog("Fichinter::create sql=".$sql);
$result=$this->db->query($sql); $result=$this->db->query($sql);
@ -138,6 +151,8 @@ class Fichinter extends CommonObject
*/ */
function update($id) function update($id)
{ {
global $conf;
if (! is_numeric($this->duree)) { $this->duree = 0; } if (! is_numeric($this->duree)) { $this->duree = 0; }
if (! strlen($this->projet_id)) if (! strlen($this->projet_id))
{ {
@ -148,10 +163,11 @@ class Fichinter extends CommonObject
* Insertion dans la base * Insertion dans la base
*/ */
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
$sql .= ", description = '".addslashes($this->description)."'"; $sql.= ", description = '".addslashes($this->description)."'";
$sql .= ", duree = ".$this->duree; $sql.= ", duree = ".$this->duree;
$sql .= ", fk_projet = ".$this->projet_id; $sql.= ", fk_projet = ".$this->projet_id;
$sql .= " WHERE rowid = ".$id; $sql.= " WHERE rowid = ".$id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Fichinter::update sql=".$sql); dol_syslog("Fichinter::update sql=".$sql);
if (! $this->db->query($sql)) if (! $this->db->query($sql))
@ -231,6 +247,7 @@ class Fichinter extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql.= " SET fk_statut = 0"; $sql.= " SET fk_statut = 0";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Fichinter::setDraft sql=".$sql); dol_syslog("Fichinter::setDraft sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -263,8 +280,12 @@ class Fichinter extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql.= " SET fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=".$user->id; $sql.= " SET fk_statut = 1";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= ", date_valid = ".$this->db->idate(mktime());
$sql.= ", fk_user_valid = ".$user->id;
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND fk_statut = 0";
dol_syslog("Fichinter::setValid sql=".$sql); dol_syslog("Fichinter::setValid sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -352,8 +373,10 @@ class Fichinter extends CommonObject
*/ */
function verifyNumRef($soc) function verifyNumRef($soc)
{ {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."fichinter"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref = '".$this->ref."'"; $sql.= " WHERE ref = '".$this->ref."'";
$sql.= " AND entity = ".$conf->entity;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -421,11 +444,16 @@ class Fichinter extends CommonObject
*/ */
function info($id) function info($id)
{ {
global $conf;
$sql = "SELECT f.rowid, "; $sql = "SELECT f.rowid, ";
$sql.= $this->db->pdate("f.datec")." as datec, ".$this->db->pdate("f.date_valid")." as datev"; $sql.= $this->db->pdate("f.datec")." as datec";
$sql.= ", f.fk_user_author, f.fk_user_valid"; $sql.= ", ".$this->db->pdate("f.date_valid")." as datev";
$sql.= ", f.fk_user_author";
$sql.= ", f.fk_user_valid";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$sql.= " WHERE f.rowid = ".$id; $sql.= " WHERE f.rowid = ".$id;
$sql.= " AND f.entity = ".$conf->entity;
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -469,11 +497,16 @@ class Fichinter extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE fk_fichinter = ".$this->id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet";
$sql.= " WHERE fk_fichinter = ".$this->id;
dol_syslog("Fichinter::delete sql=".$sql); dol_syslog("Fichinter::delete sql=".$sql);
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter WHERE rowid = ".$this->id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Fichinter::delete sql=".$sql); dol_syslog("Fichinter::delete sql=".$sql);
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
@ -530,11 +563,15 @@ class Fichinter extends CommonObject
*/ */
function set_date_delivery($user, $date_delivery) function set_date_delivery($user, $date_delivery)
{ {
global $conf;
if ($user->rights->ficheinter->creer) if ($user->rights->ficheinter->creer)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql.= " SET datei = ".$this->db->idate($date_delivery); $sql.= " SET datei = ".$this->db->idate($date_delivery);
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND fk_statut = 0";
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -558,11 +595,15 @@ class Fichinter extends CommonObject
*/ */
function set_description($user, $description) function set_description($user, $description)
{ {
global $conf;
if ($user->rights->ficheinter->creer) if ($user->rights->ficheinter->creer)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql.= " SET description = '".addslashes($description)."'"; $sql.= " SET description = '".addslashes($description)."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND fk_statut = 0";
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -625,11 +666,15 @@ class Fichinter extends CommonObject
*/ */
function initAsSpecimen() function initAsSpecimen()
{ {
global $user,$langs; global $user,$langs,$conf;
// Charge tableau des id de societe socids // Charge tableau des id de societe socids
$socids = array(); $socids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE client = 1";
$sql.= " AND entity = ".$conf->entity;
$sql.= " LIMIT 10";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -646,7 +691,10 @@ class Fichinter extends CommonObject
// Charge tableau des produits prodids // Charge tableau des produits prodids
$prodids = array(); $prodids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
$sql.= " AND entity = ".$conf->entity;
$sql.= " WHERE envente = 1";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -909,6 +957,8 @@ class FichinterLigne
*/ */
function update_total() function update_total()
{ {
global $conf;
$sql = "SELECT SUM(duree) as total_duration"; $sql = "SELECT SUM(duree) as total_duration";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinterdet"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinterdet";
$sql.= " WHERE fk_fichinter=".$this->fk_fichinter; $sql.= " WHERE fk_fichinter=".$this->fk_fichinter;
@ -924,6 +974,7 @@ class FichinterLigne
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql.= " SET duree = ".$total_duration; $sql.= " SET duree = ".$total_duration;
$sql.= " WHERE rowid = ".$this->fk_fichinter; $sql.= " WHERE rowid = ".$this->fk_fichinter;
$sql.= " AND entity ".$conf->entity;
dol_syslog("FichinterLigne::update_total sql=".$sql); dol_syslog("FichinterLigne::update_total sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);

View File

@ -41,7 +41,7 @@ $page=$_GET["page"]?$_GET["page"]:$_POST["page"];
// Security check // Security check
$fichinterid = isset($_GET["id"])?$_GET["id"]:''; $fichinterid = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'ficheinter', $fichinterid,''); $result = restrictedArea($user, 'ficheinter', $fichinterid,'fichinter');
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="fd.date"; if (! $sortfield) $sortfield="fd.date";
@ -73,7 +73,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX
$sql.= ", ".MAIN_DB_PREFIX."fichinter as f)"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
$sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " WHERE f.fk_soc = s.rowid ";
$sql.= " AND s.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if ($search_ref) $sql .= " AND f.ref like '%".addslashes($search_ref)."%'"; if ($search_ref) $sql .= " AND f.ref like '%".addslashes($search_ref)."%'";
if ($search_company) $sql .= " AND s.nom like '%".addslashes($search_company)."%'"; if ($search_company) $sql .= " AND s.nom like '%".addslashes($search_company)."%'";
if ($search_desc) $sql .= " AND (f.description like '%".addslashes($search_desc)."%' OR fd.description like '%".addslashes($search_desc)."%')"; if ($search_desc) $sql .= " AND (f.description like '%".addslashes($search_desc)."%' OR fd.description like '%".addslashes($search_desc)."%')";

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2005-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

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com> /* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-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
@ -24,10 +25,10 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
if ($user->societe_id > 0) // Security check
{ if ($user->societe_id) $socid=$user->societe_id;
$socid = $user->societe_id ; $result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
}
llxHeader(); llxHeader();
@ -52,9 +53,12 @@ $offset = $limit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$sql = "SELECT s.nom,s.rowid as socid, f.description, f.ref,".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, f.duree"; $sql = "SELECT s.nom, s.rowid as socid, f.description, f.ref";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f "; $sql.= ", ".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, f.duree";
$sql .= " WHERE f.fk_soc = s.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."fichinter as f ";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
if ($socid > 0) if ($socid > 0)
@ -68,10 +72,10 @@ if (empty($YY))
$YY=strftime("%Y",time());; $YY=strftime("%Y",time());;
echo "<div class='noprint'>"; echo "<div class='noprint'>";
echo "\n<form action='rapport.php'>"; echo "\n<form action='rapport.php'>";
echo "<input type='hidden' name='socid' value='$socid'>"; echo "<input type='hidden' name='socid' value='".$socid."'>";
echo $langs->trans("Month")." <input name='MM' size='2' value='$MM'>"; echo $langs->trans("Month")." <input name='MM' size='2' value='$MM'>";
echo " Ann&eacute;e <input size='4' name='YY' value='$YY'>"; echo " Ann&eacute;e <input size='4' name='YY' value='$YY'>";
echo "<input type='submit' name='g' value='Genérer le rapport'>"; echo "<input type='submit' name='g' value='G&eacute;n&eacute;rer le rapport'>";
echo "<form>"; echo "<form>";
echo "</div>"; echo "</div>";
@ -86,7 +90,7 @@ else
$m = $MM+1; $m = $MM+1;
$end="$YY-$m-01 00:00:00"; $end="$YY-$m-01 00:00:00";
} }
$sql .= " AND datei >= '$start' AND datei < '$end'" ; $sql .= " AND datei >= '".$start."' AND datei < '".$end."'" ;
$sql .= " ORDER BY $sortfield $sortorder "; $sql .= " ORDER BY $sortfield $sortorder ";
@ -94,14 +98,14 @@ if ( $db->query($sql) )
{ {
$num = $db->num_rows(); $num = $db->num_rows();
$title = $langs->trans("Report")." ".dol_print_date(strtotime($start),"%B %Y"); $title = $langs->trans("Report")." ".dol_print_date(strtotime($start),"%B %Y");
print_barre_liste($title, $page, "rapport.php","&socid=$socid",$sortfield,$sortorder,'',$num); print_barre_liste($title, $page, "rapport.php","&socid=".$socid,$sortfield,$sortorder,'',$num);
$i = 0; $i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="3">'; print '<table class="noborder" width="100%" cellspacing="0" cellpadding="3">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print '<td>Num</td>'; print '<td>Num</td>';
if (empty($socid)) if (empty($socid))
print '<td>Société</td>'; print '<td>'.$langs->trans("Customers").'</td>';
print '<td align="center">'.$langs->trans("Description").'</td>'; print '<td align="center">'.$langs->trans("Description").'</td>';
print '<td align="center">Date</td>'; print '<td align="center">Date</td>';
@ -114,7 +118,7 @@ if ( $db->query($sql) )
$objp = $db->fetch_object(); $objp = $db->fetch_object();
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$objp->fichid\">$objp->ref</a></td>\n"; print '<td><a href="fiche.php?id='.$objp->fichid.'">'.$objp->ref.'</a></td>\n';
if (empty($socid)) if (empty($socid))
{ {
@ -141,5 +145,5 @@ else
} }
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter("$Date$ - $Revision$");
?> ?>

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.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

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-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
@ -72,7 +72,7 @@ class mod_pacific extends ModeleNumRefFicheinter
*/ */
function canBeActivated() function canBeActivated()
{ {
global $langs; global $langs,$conf;
$langs->load("bills"); $langs->load("bills");
@ -80,6 +80,8 @@ class mod_pacific extends ModeleNumRefFicheinter
$sql = "SELECT MAX(ref)"; $sql = "SELECT MAX(ref)";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE entity = ".$conf->entity;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -102,32 +104,34 @@ class mod_pacific extends ModeleNumRefFicheinter
* \param ficheinter Object ficheinter * \param ficheinter Object ficheinter
* \return string Valeur * \return string Valeur
*/ */
function getNextValue($objsoc=0,$ficheinter='') function getNextValue($objsoc=0,$ficheinter='')
{ {
global $db; global $db,$conf;
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé) // D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " WHERE ref like '".$this->prefix."%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = $obj->max;
else $max=0; else $max=0;
}
//$date=time();
$date=$ficheinter->date;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);
return $this->prefix.$yymm."-".$num;
} }
//$date=time();
$date=$ficheinter->date;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);
return $this->prefix.$yymm."-".$num;
}
/** \brief Return next free value /** \brief Return next free value
* \param objsoc Object third party * \param objsoc Object third party
* \param objforref Object for number to search * \param objforref Object for number to search

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-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-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
@ -59,11 +60,14 @@ class ModelePDFFicheinter extends FPDF
*/ */
function liste_modeles($db) function liste_modeles($db)
{ {
global $conf;
$type='ficheinter'; $type='ficheinter';
$liste=array(); $liste=array();
$sql ="SELECT nom as id, nom as lib"; $sql = "SELECT nom as id, nom as lib";
$sql.=" FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.=" WHERE type = '".$type."'"; $sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)

View File

@ -31,6 +31,7 @@ ALTER TABLE llx_facture ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER facnu
ALTER TABLE llx_expedition ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_expedition ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_facture_fourn ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER facnumber; ALTER TABLE llx_facture_fourn ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER facnumber;
ALTER TABLE llx_livraison ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_livraison ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_fichinter ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_rights_def DROP PRIMARY KEY; ALTER TABLE llx_rights_def DROP PRIMARY KEY;
ALTER TABLE llx_user_param DROP INDEX fk_user; ALTER TABLE llx_user_param DROP INDEX fk_user;
@ -52,6 +53,7 @@ ALTER TABLE llx_expedition DROP INDEX idx_expedition_uk_ref;
ALTER TABLE llx_facture_fourn DROP INDEX uk_facture_fourn_ref; ALTER TABLE llx_facture_fourn DROP INDEX uk_facture_fourn_ref;
ALTER TABLE llx_livraison DROP INDEX idx_expedition_uk_ref; ALTER TABLE llx_livraison DROP INDEX idx_expedition_uk_ref;
ALTER TABLE llx_livraison DROP INDEX idx_livraison_uk_ref; ALTER TABLE llx_livraison DROP INDEX idx_livraison_uk_ref;
ALTER TABLE llx_fichinter DROP INDEX ref;
ALTER TABLE llx_rights_def ADD PRIMARY KEY (id, entity); ALTER TABLE llx_rights_def ADD PRIMARY KEY (id, entity);
ALTER TABLE llx_user_param ADD UNIQUE INDEX uk_user_param (fk_user,param,entity); ALTER TABLE llx_user_param ADD UNIQUE INDEX uk_user_param (fk_user,param,entity);
@ -72,4 +74,5 @@ ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_soc (fk_soc,
ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber, entity); ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber, entity);
ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref, entity); ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref, entity);
ALTER TABLE llx_facture_fourn ADD UNIQUE INDEX uk_facture_fourn_ref (facnumber, fk_soc, entity); ALTER TABLE llx_facture_fourn ADD UNIQUE INDEX uk_facture_fourn_ref (facnumber, fk_soc, entity);
ALTER TABLE llx_livraison ADD UNIQUE INDEX idx_livraison_uk_ref (ref, entity); ALTER TABLE llx_livraison ADD UNIQUE INDEX idx_livraison_uk_ref (ref, entity);
ALTER TABLE llx_fichinter ADD UNIQUE INDEX uk_fichinter_ref (ref, entity);

View File

@ -19,5 +19,7 @@
-- =================================================================== -- ===================================================================
ALTER TABLE llx_fichinter ADD UNIQUE INDEX uk_fichinter_ref (ref, entity);
ALTER TABLE llx_fichinter ADD INDEX idx_fichinter_fk_soc (fk_soc); ALTER TABLE llx_fichinter ADD INDEX idx_fichinter_fk_soc (fk_soc);
ALTER TABLE llx_fichinter ADD CONSTRAINT fk_fichinter_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_fichinter ADD CONSTRAINT fk_fichinter_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);

View File

@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2005-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
@ -22,21 +23,21 @@ create table llx_fichinter
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_soc integer NOT NULL, fk_soc integer NOT NULL,
fk_projet integer DEFAULT 0, -- projet auquel est rattache la fiche fk_projet integer DEFAULT 0, -- projet auquel est rattache la fiche
fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche
ref varchar(30) NOT NULL, -- number ref varchar(30) NOT NULL, -- number
entity integer DEFAULT 1 NOT NULL, -- multi company id
tms timestamp, tms timestamp,
datec datetime, -- date de creation datec datetime, -- date de creation
date_valid datetime, -- date de validation date_valid datetime, -- date de validation
datei date, -- date de livraison du bon d'intervention datei date, -- date de livraison du bon d'intervention
fk_user_author integer, -- createur de la fiche fk_user_author integer, -- createur de la fiche
fk_user_valid integer, -- valideur de la fiche fk_user_valid integer, -- valideur de la fiche
fk_statut smallint DEFAULT 0, fk_statut smallint DEFAULT 0,
duree real, -- durée totale de l'intervention duree real, -- durée totale de l'intervention
description text, description text,
note_private text, note_private text,
note_public text, note_public text,
model_pdf varchar(50), model_pdf varchar(50)
UNIQUE INDEX (ref)
)type=innodb; )type=innodb;

View File

@ -21,7 +21,7 @@
-- ============================================================================ -- ============================================================================
ALTER TABLE llx_product ADD UNIQUE uk_product_ref (ref, entity); ALTER TABLE llx_product ADD UNIQUE INDEX uk_product_ref (ref, entity);
ALTER TABLE llx_product ADD INDEX idx_product_barcode (barcode); ALTER TABLE llx_product ADD INDEX idx_product_barcode (barcode);
ALTER TABLE llx_product ADD INDEX idx_product_import_key (import_key); ALTER TABLE llx_product ADD INDEX idx_product_import_key (import_key);