Works on products variants
Fix: uniformize table name, prepare to move fields "label, description and note" in llx_product_lang
This commit is contained in:
parent
9431c471ca
commit
65fdbc3696
File diff suppressed because one or more lines are too long
@ -876,7 +876,8 @@ class Form
|
|||||||
if ($conf->global->MAIN_MULTILANGS)
|
if ($conf->global->MAIN_MULTILANGS)
|
||||||
{
|
{
|
||||||
$sqld = "SELECT d.fk_product, d.label";
|
$sqld = "SELECT d.fk_product, d.label";
|
||||||
$sqld.= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_det as d ";
|
$sqld.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
|
$sqld.= ", ".MAIN_DB_PREFIX."product_lang as d";
|
||||||
$sqld.= " WHERE d.fk_product = p.rowid";
|
$sqld.= " WHERE d.fk_product = p.rowid";
|
||||||
$sqld.= " AND p.entity = ".$conf->entity;
|
$sqld.= " AND p.entity = ".$conf->entity;
|
||||||
$sqld.= " AND p.envente = 1";
|
$sqld.= " AND p.envente = 1";
|
||||||
|
|||||||
@ -102,7 +102,7 @@ class box_produits extends ModeleBoxes {
|
|||||||
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
||||||
{
|
{
|
||||||
$sqld = "SELECT label";
|
$sqld = "SELECT label";
|
||||||
$sqld.= " FROM ".MAIN_DB_PREFIX."product_det";
|
$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sqld.= " WHERE fk_product=".$objp->rowid;
|
$sqld.= " WHERE fk_product=".$objp->rowid;
|
||||||
$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
|
$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
|
||||||
$sqld.= " LIMIT 1";
|
$sqld.= " LIMIT 1";
|
||||||
|
|||||||
@ -113,8 +113,10 @@ class box_services_vendus extends ModeleBoxes {
|
|||||||
// Multilangs
|
// Multilangs
|
||||||
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
||||||
{
|
{
|
||||||
$sqld = "SELECT label FROM ".MAIN_DB_PREFIX."product_det";
|
$sqld = "SELECT label";
|
||||||
$sqld.= " WHERE fk_product=".$objp->pid." AND lang='". $langs->getDefaultLang() ."'";
|
$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
|
$sqld.= " WHERE fk_product=".$objp->pid;
|
||||||
|
$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
|
||||||
$sqld.= " LIMIT 1";
|
$sqld.= " LIMIT 1";
|
||||||
|
|
||||||
$resultd = $db->query($sqld);
|
$resultd = $db->query($sqld);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004-2005 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-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 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
|
||||||
@ -357,7 +357,8 @@ else
|
|||||||
array('from'=>'2.4.0', 'to'=>'2.5.0'),
|
array('from'=>'2.4.0', 'to'=>'2.5.0'),
|
||||||
array('from'=>'2.5.0', 'to'=>'2.6.0'),
|
array('from'=>'2.5.0', 'to'=>'2.6.0'),
|
||||||
array('from'=>'2.6.0', 'to'=>'2.7.0'),
|
array('from'=>'2.6.0', 'to'=>'2.7.0'),
|
||||||
array('from'=>'2.7.0', 'to'=>'2.8.0')
|
array('from'=>'2.7.0', 'to'=>'2.8.0'),
|
||||||
|
array('from'=>'2.8.0', 'to'=>'2.9.0')
|
||||||
);
|
);
|
||||||
|
|
||||||
$count=0;
|
$count=0;
|
||||||
|
|||||||
@ -6,3 +6,10 @@
|
|||||||
-- when current version is 2.8.0 or higher.
|
-- when current version is 2.8.0 or higher.
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_product_det RENAME TO llx_product_lang;
|
||||||
|
ALTER TABLE llx_product_lang ADD UNIQUE INDEX uk_product_lang (fk_product, lang);
|
||||||
|
ALTER TABLE llx_product_lang ADD CONSTRAINT fk_product_lang_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
|
||||||
|
|
||||||
|
ALTER TABLE llx_product ADD COLUMN virtual tinyint DEFAULT 0 NOT NULL AFTER tms;
|
||||||
|
ALTER TABLE llx_product ADD COLUMN fk_parent integer DEFAULT 0 AFTER virtual;
|
||||||
|
|||||||
@ -25,6 +25,8 @@ create table llx_product
|
|||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
datec datetime,
|
datec datetime,
|
||||||
tms timestamp,
|
tms timestamp,
|
||||||
|
virtual tinyint DEFAULT 0 NOT NULL, -- value 0 for physical product, 1 for virtual product
|
||||||
|
fk_parent integer DEFAULT 0, -- virtual product id
|
||||||
ref varchar(32) NOT NULL,
|
ref varchar(32) NOT NULL,
|
||||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
label varchar(255) NOT NULL,
|
label varchar(255) NOT NULL,
|
||||||
|
|||||||
25
htdocs/install/mysql/tables/llx_product_lang.key.sql
Normal file
25
htdocs/install/mysql/tables/llx_product_lang.key.sql
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-- ============================================================================
|
||||||
|
-- Copyright (C) 2010 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
|
||||||
|
-- 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$
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_product_lang ADD UNIQUE INDEX uk_product_lang (fk_product, lang);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_product_lang ADD CONSTRAINT fk_product_lang_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
|
||||||
@ -1,5 +1,6 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
-- Copyright (C) 2005-2010 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
|
||||||
@ -19,7 +20,7 @@
|
|||||||
-- $Id$
|
-- $Id$
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
|
||||||
create table llx_product_det
|
create table llx_product_lang
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
fk_product integer DEFAULT 0 NOT NULL,
|
fk_product integer DEFAULT 0 NOT NULL,
|
||||||
@ -530,7 +530,7 @@ class Product extends CommonObject
|
|||||||
$sqlb.= " WHERE fk_product = ".$id;
|
$sqlb.= " WHERE fk_product = ".$id;
|
||||||
$resultb = $this->db->query($sqlb);
|
$resultb = $this->db->query($sqlb);
|
||||||
|
|
||||||
$sqlc = "DELETE from ".MAIN_DB_PREFIX."product_det";
|
$sqlc = "DELETE from ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sqlc.= " WHERE fk_product = ".$id;
|
$sqlc.= " WHERE fk_product = ".$id;
|
||||||
$resultc = $this->db->query($sqlc);
|
$resultc = $this->db->query($sqlc);
|
||||||
|
|
||||||
@ -582,7 +582,7 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
foreach ($langs_available as $value)
|
foreach ($langs_available as $value)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_det";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sql.= " WHERE fk_product=".$this->id." AND lang='".$value."'";
|
$sql.= " WHERE fk_product=".$this->id." AND lang='".$value."'";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -591,7 +591,7 @@ class Product extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($this->db->num_rows($result)) // si aucune ligne dans la base
|
if ($this->db->num_rows($result)) // si aucune ligne dans la base
|
||||||
{
|
{
|
||||||
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_det";
|
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sql2.= " SET label='".addslashes($this->libelle)."',";
|
$sql2.= " SET label='".addslashes($this->libelle)."',";
|
||||||
$sql2.= " description='".addslashes($this->description)."',";
|
$sql2.= " description='".addslashes($this->description)."',";
|
||||||
$sql2.= " note='".addslashes($this->note)."'";
|
$sql2.= " note='".addslashes($this->note)."'";
|
||||||
@ -599,7 +599,7 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_det (fk_product, lang, label, description, note)";
|
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description, note)";
|
||||||
$sql2.= " VALUES(".$this->id.",'".$value."','". addslashes($this->libelle);
|
$sql2.= " VALUES(".$this->id.",'".$value."','". addslashes($this->libelle);
|
||||||
$sql2.= "','".addslashes($this->description);
|
$sql2.= "','".addslashes($this->description);
|
||||||
$sql2.= "','".addslashes($this->note)."')";
|
$sql2.= "','".addslashes($this->note)."')";
|
||||||
@ -610,7 +610,7 @@ class Product extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($this->db->num_rows($result)) // si aucune ligne dans la base
|
if ($this->db->num_rows($result)) // si aucune ligne dans la base
|
||||||
{
|
{
|
||||||
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_det";
|
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sql2.= " SET label='".addslashes($this->multilangs["$value"]["libelle"])."',";
|
$sql2.= " SET label='".addslashes($this->multilangs["$value"]["libelle"])."',";
|
||||||
$sql2.= " description='".addslashes($this->multilangs["$value"]["description"])."',";
|
$sql2.= " description='".addslashes($this->multilangs["$value"]["description"])."',";
|
||||||
$sql2.= " note='".addslashes($this->multilangs["$value"]["note"])."'";
|
$sql2.= " note='".addslashes($this->multilangs["$value"]["note"])."'";
|
||||||
@ -618,7 +618,7 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_det (fk_product, lang, label, description, note)";
|
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description, note)";
|
||||||
$sql2.= " VALUES(".$this->id.",'".$value."','". addslashes($this->multilangs["$value"]["libelle"]);
|
$sql2.= " VALUES(".$this->id.",'".$value."','". addslashes($this->multilangs["$value"]["libelle"]);
|
||||||
$sql2.= "','".addslashes($this->multilangs["$value"]["description"]);
|
$sql2.= "','".addslashes($this->multilangs["$value"]["description"]);
|
||||||
$sql2.= "','".addslashes($this->multilangs["$value"]["note"])."')";
|
$sql2.= "','".addslashes($this->multilangs["$value"]["note"])."')";
|
||||||
@ -649,7 +649,7 @@ class Product extends CommonObject
|
|||||||
$current_lang = $langs->getDefaultLang(); // sinon on choisi la langue par defaut
|
$current_lang = $langs->getDefaultLang(); // sinon on choisi la langue par defaut
|
||||||
|
|
||||||
$sql = "SELECT lang, label, description, note";
|
$sql = "SELECT lang, label, description, note";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_det";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sql.= " WHERE fk_product=".$this->id;
|
$sql.= " WHERE fk_product=".$this->id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|||||||
@ -195,8 +195,11 @@ if ($result)
|
|||||||
//Multilangs
|
//Multilangs
|
||||||
if ($conf->global->MAIN_MULTILANGS)
|
if ($conf->global->MAIN_MULTILANGS)
|
||||||
{
|
{
|
||||||
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det";
|
$sql = "SELECT label";
|
||||||
$sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
|
$sql.= " WHERE fk_product=".$objp->rowid;
|
||||||
|
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
||||||
|
|
||||||
$resultd = $db->query($sql);
|
$resultd = $db->query($sql);
|
||||||
if ($resultd)
|
if ($resultd)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -308,9 +308,12 @@ if ($resql)
|
|||||||
// Multilangs
|
// Multilangs
|
||||||
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
||||||
{
|
{
|
||||||
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det";
|
$sql = "SELECT label";
|
||||||
$sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
|
$sql.= " WHERE fk_product=".$objp->rowid;
|
||||||
|
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
||||||
$sql.= " LIMIT 1";
|
$sql.= " LIMIT 1";
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -110,10 +110,11 @@ if ($result)
|
|||||||
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
||||||
{
|
{
|
||||||
$sql = "SELECT label";
|
$sql = "SELECT label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_det";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sql.= " WHERE fk_product=".$objp->rowid;
|
$sql.= " WHERE fk_product=".$objp->rowid;
|
||||||
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
||||||
$sql.= " LIMIT 1";
|
$sql.= " LIMIT 1";
|
||||||
|
|
||||||
$resultp = $db->query($sql);
|
$resultp = $db->query($sql);
|
||||||
if ($resultp)
|
if ($resultp)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -233,10 +233,11 @@ if ($resql)
|
|||||||
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
||||||
{
|
{
|
||||||
$sql = "SELECT label";
|
$sql = "SELECT label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_det";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sql.= " WHERE fk_product=".$objp->rowid;
|
$sql.= " WHERE fk_product=".$objp->rowid;
|
||||||
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
||||||
$sql.= " LIMIT 1";
|
$sql.= " LIMIT 1";
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -385,7 +385,7 @@ else
|
|||||||
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
||||||
{
|
{
|
||||||
$sql = "SELECT label";
|
$sql = "SELECT label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_det";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
|
||||||
$sql.= " WHERE fk_product=".$objp->rowid;
|
$sql.= " WHERE fk_product=".$objp->rowid;
|
||||||
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
|
||||||
$sql.= " LIMIT 1";
|
$sql.= " LIMIT 1";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user