diff --git a/htdocs/fichinter/apercu.php b/htdocs/fichinter/apercu.php index b47cdc59b1e..80035237ef9 100644 --- a/htdocs/fichinter/apercu.php +++ b/htdocs/fichinter/apercu.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2005-2009 Regis Houssin * * 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 @@ -30,29 +30,18 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); - -if (!$user->rights->ficheinter->lire) - accessforbidden(); +require_once(DOL_DOCUMENT_ROOT.'/fichinter/fichinter.class.php'); +if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php"); $langs->load('interventions'); -require_once(DOL_DOCUMENT_ROOT.'/fichinter/fichinter.class.php'); +$fichinterid = isset($_GET["id"])?$_GET["id"]:''; -if ($conf->projet->enabled) -{ - require_once(DOL_DOCUMENT_ROOT."/project.class.php"); -} +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); -/* - * Sécurité accés client -*/ -if ($user->societe_id > 0) -{ - $action = ''; - $socid = $user->societe_id; -} - llxHeader(); $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.= ' WHERE fi.fk_soc = s.rowid'; $sql.= ' AND fi.rowid = '.$fichinter->id; + $sql.= ' AND fi.entity = '.$conf->entity; if ($socid) $sql .= ' AND s.rowid = '.$socid; $result = $db->query($sql); diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index f147a1fad11..d44f2363da6 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007-2009 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 1c33508c127..07cbbfb2a24 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -2,8 +2,8 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005 Regis Houssin - * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005 Simon TOSSER * * 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 @@ -37,16 +37,12 @@ $langs->load("other"); $langs->load("fichinter"); $langs->load("companies"); -if (!$user->rights->ficheinter->lire) - accessforbidden(); +$fichinterid = isset($_GET["id"])?$_GET["id"]:''; // Security check -if ($user->societe_id > 0) -{ - unset($_GET["action"]); - $action=''; - $socid = $user->societe_id; -} +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); + // Get parameters $page=$_GET["page"]; diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 0bb789362df..cfd5cf27b70 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2005-2009 Regis Houssin * * 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 @@ -87,6 +87,8 @@ class Fichinter extends CommonObject */ function create() { + global $conf; + dol_syslog("Fichinter.class::create ref=".$this->ref); if (! is_numeric($this->duree)) { $this->duree = 0; } @@ -104,15 +106,26 @@ class Fichinter extends CommonObject $result=$soc->fetch($this->socid); $this->verifyNumRef($soc); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datec, ref, fk_user_author, description, model_pdf"; - if ($this->projet_id) $sql.= ", fk_projet"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter ("; + $sql.= "fk_soc"; + $sql.= ", datec"; + $sql.= ", ref"; + $sql.= ", entity"; + $sql.= ", fk_user_author"; + $sql.= ", description"; + $sql.= ", model_pdf"; + $sql.= ", fk_projet"; $sql.= ") "; - $sql.= " VALUES (".$this->socid.","; - $sql.= " ".$this->db->idate(mktime()).", '".$this->ref."', ".$this->author; - $sql.= ", '".addslashes($this->description)."', '".$this->modelpdf."'"; - if ($this->projet_id) $sql .= ", ".$this->projet_id; + $sql.= " VALUES ("; + $sql.= $this->socid; + $sql.= ", ".$this->db->idate(mktime()); + $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.= ")"; - $sqlok = 0; dol_syslog("Fichinter::create sql=".$sql); $result=$this->db->query($sql); @@ -138,6 +151,8 @@ class Fichinter extends CommonObject */ function update($id) { + global $conf; + if (! is_numeric($this->duree)) { $this->duree = 0; } if (! strlen($this->projet_id)) { @@ -148,10 +163,11 @@ class Fichinter extends CommonObject * Insertion dans la base */ $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; - $sql .= ", description = '".addslashes($this->description)."'"; - $sql .= ", duree = ".$this->duree; - $sql .= ", fk_projet = ".$this->projet_id; - $sql .= " WHERE rowid = ".$id; + $sql.= ", description = '".addslashes($this->description)."'"; + $sql.= ", duree = ".$this->duree; + $sql.= ", fk_projet = ".$this->projet_id; + $sql.= " WHERE rowid = ".$id; + $sql.= " AND entity = ".$conf->entity; dol_syslog("Fichinter::update sql=".$sql); if (! $this->db->query($sql)) @@ -231,6 +247,7 @@ class Fichinter extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql.= " SET fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id; + $sql.= " AND entity = ".$conf->entity; dol_syslog("Fichinter::setDraft sql=".$sql); $resql=$this->db->query($sql); @@ -263,8 +280,12 @@ class Fichinter extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; - $sql.= " SET fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=".$user->id; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + $sql.= " SET fk_statut = 1"; + $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); $resql=$this->db->query($sql); @@ -352,8 +373,10 @@ class Fichinter extends CommonObject */ 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.= " AND entity = ".$conf->entity; $result = $this->db->query($sql); if ($result) @@ -421,11 +444,16 @@ class Fichinter extends CommonObject */ function info($id) { + global $conf; + $sql = "SELECT f.rowid, "; - $sql.= $this->db->pdate("f.datec")." as datec, ".$this->db->pdate("f.date_valid")." as datev"; - $sql.= ", f.fk_user_author, f.fk_user_valid"; + $sql.= $this->db->pdate("f.datec")." as datec"; + $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.= " WHERE f.rowid = ".$id; + $sql.= " AND f.entity = ".$conf->entity; $result = $this->db->query($sql); @@ -469,11 +497,16 @@ class Fichinter extends CommonObject $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); 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); if ( $this->db->query($sql) ) { @@ -530,11 +563,15 @@ class Fichinter extends CommonObject */ function set_date_delivery($user, $date_delivery) { + global $conf; + if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $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)) { @@ -558,11 +595,15 @@ class Fichinter extends CommonObject */ function set_description($user, $description) { + global $conf; + if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $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)) { @@ -625,11 +666,15 @@ class Fichinter extends CommonObject */ function initAsSpecimen() { - global $user,$langs; + global $user,$langs,$conf; // Charge tableau des id de societe socids $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); if ($resql) { @@ -646,7 +691,10 @@ class Fichinter extends CommonObject // Charge tableau des produits prodids $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); if ($resql) { @@ -909,6 +957,8 @@ class FichinterLigne */ function update_total() { + global $conf; + $sql = "SELECT SUM(duree) as total_duration"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinterdet"; $sql.= " WHERE fk_fichinter=".$this->fk_fichinter; @@ -924,6 +974,7 @@ class FichinterLigne $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql.= " SET duree = ".$total_duration; $sql.= " WHERE rowid = ".$this->fk_fichinter; + $sql.= " AND entity ".$conf->entity; dol_syslog("FichinterLigne::update_total sql=".$sql); $resql=$this->db->query($sql); diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 248b1908348..8165987e0cb 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -41,7 +41,7 @@ $page=$_GET["page"]?$_GET["page"]:$_POST["page"]; // Security check $fichinterid = isset($_GET["id"])?$_GET["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 (! $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.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.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_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)."%')"; diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 840ce9590ee..291cc4f949e 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2009 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 4b43e1a14c8..6ef8f2663a4 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2009 Regis Houssin * * 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 diff --git a/htdocs/fichinter/rapport.php b/htdocs/fichinter/rapport.php index a72c9c187b0..92a232e6ddf 100644 --- a/htdocs/fichinter/rapport.php +++ b/htdocs/fichinter/rapport.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004 Laurent Destailleur +/* Copyright (C) 2003 Xavier DUTOIT + * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin * * 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 @@ -24,10 +25,10 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); -if ($user->societe_id > 0) -{ - $socid = $user->societe_id ; -} +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); + llxHeader(); @@ -52,9 +53,12 @@ $offset = $limit * $page ; $pageprev = $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 .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f "; -$sql .= " WHERE f.fk_soc = s.rowid"; +$sql = "SELECT s.nom, s.rowid as socid, f.description, f.ref"; +$sql.= ", ".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, f.duree"; +$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) @@ -68,10 +72,10 @@ if (empty($YY)) $YY=strftime("%Y",time());; echo "
"; echo "\n
"; -echo ""; +echo ""; echo $langs->trans("Month")." "; echo " Année "; -echo ""; +echo ""; echo ""; echo "
"; @@ -86,7 +90,7 @@ else $m = $MM+1; $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 "; @@ -94,14 +98,14 @@ if ( $db->query($sql) ) { $num = $db->num_rows(); $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; print ''; print ""; print ''; if (empty($socid)) - print ''; + print ''; print ''; print ''; @@ -114,7 +118,7 @@ if ( $db->query($sql) ) $objp = $db->fetch_object(); $var=!$var; print ""; - print "\n"; + print '\n'; if (empty($socid)) { @@ -141,5 +145,5 @@ else } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter("$Date$ - $Revision$"); ?> diff --git a/htdocs/includes/modules/fichinter/mod_arctic.php b/htdocs/includes/modules/fichinter/mod_arctic.php index f15d067e1a6..a0dc5c63c5b 100644 --- a/htdocs/includes/modules/fichinter/mod_arctic.php +++ b/htdocs/includes/modules/fichinter/mod_arctic.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) * * 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 diff --git a/htdocs/includes/modules/fichinter/mod_pacific.php b/htdocs/includes/modules/fichinter/mod_pacific.php index 8798749b80a..7cea35f9d65 100644 --- a/htdocs/includes/modules/fichinter/mod_pacific.php +++ b/htdocs/includes/modules/fichinter/mod_pacific.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2005-2009 Regis Houssin * * 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 @@ -72,7 +72,7 @@ class mod_pacific extends ModeleNumRefFicheinter */ function canBeActivated() { - global $langs; + global $langs,$conf; $langs->load("bills"); @@ -80,6 +80,8 @@ class mod_pacific extends ModeleNumRefFicheinter $sql = "SELECT MAX(ref)"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; + $sql.= " WHERE entity = ".$conf->entity; + $resql=$db->query($sql); if ($resql) { @@ -102,32 +104,34 @@ class mod_pacific extends ModeleNumRefFicheinter * \param ficheinter Object ficheinter * \return string Valeur */ - function getNextValue($objsoc=0,$ficheinter='') + function getNextValue($objsoc=0,$ficheinter='') { - global $db; - - // D'abord on récupère la valeur max (réponse immédiate car champ indéxé) - $posindice=8; - $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; + global $db,$conf; + + // D'abord on récupère la valeur max (réponse immédiate car champ indéxé) + $posindice=8; + + $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " WHERE ref like '".$this->prefix."%'"; + $sql.= " AND entity = ".$conf->entity; $resql=$db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($obj) $max = $obj->max; - else $max=0; - } - - //$date=time(); - $date=$ficheinter->date; - $yymm = strftime("%y%m",$date); - $num = sprintf("%04s",$max+1); - - return $this->prefix.$yymm."-".$num; + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = $obj->max; + else $max=0; } + //$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 * \param objsoc Object third party * \param objforref Object for number to search diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index 056dc548d8d..c60866272ca 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin * * 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 @@ -59,11 +60,14 @@ class ModelePDFFicheinter extends FPDF */ function liste_modeles($db) { + global $conf; + $type='ficheinter'; $liste=array(); - $sql ="SELECT nom as id, nom as lib"; - $sql.=" FROM ".MAIN_DB_PREFIX."document_model"; - $sql.=" WHERE type = '".$type."'"; + $sql = "SELECT nom as id, nom as lib"; + $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql.= " WHERE type = '".$type."'"; + $sql.= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql index e0ddcc59640..4e855f355a6 100644 --- a/mysql/migration/2.6.0-2.7.0.sql +++ b/mysql/migration/2.6.0-2.7.0.sql @@ -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_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_fichinter ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_rights_def DROP PRIMARY KEY; 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_livraison DROP INDEX idx_expedition_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_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_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_livraison ADD UNIQUE INDEX idx_livraison_uk_ref (ref, entity); \ No newline at end of file +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); \ No newline at end of file diff --git a/mysql/tables/llx_fichinter.key.sql b/mysql/tables/llx_fichinter.key.sql index 40b6ecd255e..1e3f21d0eb7 100644 --- a/mysql/tables/llx_fichinter.key.sql +++ b/mysql/tables/llx_fichinter.key.sql @@ -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 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); diff --git a/mysql/tables/llx_fichinter.sql b/mysql/tables/llx_fichinter.sql index 96d546b1c21..dcc1c0be79a 100644 --- a/mysql/tables/llx_fichinter.sql +++ b/mysql/tables/llx_fichinter.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2001-2007 Rodolphe Quiedeville +-- Copyright (C) 2005-2009 Regis Houssin -- -- 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 @@ -22,21 +23,21 @@ create table llx_fichinter ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_soc integer NOT NULL, - fk_projet integer DEFAULT 0, -- projet auquel est rattache la fiche - fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche - ref varchar(30) NOT NULL, -- number + fk_projet integer DEFAULT 0, -- projet auquel est rattache la fiche + fk_contrat integer DEFAULT 0, -- contrat auquel est rattache la fiche + ref varchar(30) NOT NULL, -- number + entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp, - datec datetime, -- date de creation - date_valid datetime, -- date de validation - datei date, -- date de livraison du bon d'intervention - fk_user_author integer, -- createur de la fiche - fk_user_valid integer, -- valideur de la fiche + datec datetime, -- date de creation + date_valid datetime, -- date de validation + datei date, -- date de livraison du bon d'intervention + fk_user_author integer, -- createur de la fiche + fk_user_valid integer, -- valideur de la fiche fk_statut smallint DEFAULT 0, - duree real, -- durée totale de l'intervention + duree real, -- durée totale de l'intervention description text, note_private text, note_public text, - model_pdf varchar(50), - - UNIQUE INDEX (ref) + model_pdf varchar(50) + )type=innodb; diff --git a/mysql/tables/llx_product.key.sql b/mysql/tables/llx_product.key.sql index 7e9a3ffc3f4..28c68879a48 100644 --- a/mysql/tables/llx_product.key.sql +++ b/mysql/tables/llx_product.key.sql @@ -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_import_key (import_key);
NumSociété'.$langs->trans("Customers").''.$langs->trans("Description").'Date
fichid\">$objp->ref'.$objp->ref.'