Works on migration of relationship tables

This commit is contained in:
Regis Houssin 2009-12-12 09:13:41 +00:00
parent e777fd039f
commit cf3f719a71
8 changed files with 64 additions and 266 deletions

View File

@ -1399,32 +1399,6 @@ INSERT INTO `llx_chargesociales` VALUES (1,'2002-05-15 00:00:00','Acompte 1er Tr
/*!40000 ALTER TABLE `llx_chargesociales` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_co_exp`
--
DROP TABLE IF EXISTS `llx_co_exp`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `llx_co_exp` (
`rowid` int(11) NOT NULL auto_increment,
`fk_commande` int(11) NOT NULL default '0',
`fk_expedition` int(11) NOT NULL default '0',
PRIMARY KEY (`rowid`),
KEY `fk_commande` (`fk_commande`),
KEY `fk_expedition` (`fk_expedition`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
--
-- Dumping data for table `llx_co_exp`
--
LOCK TABLES `llx_co_exp` WRITE;
/*!40000 ALTER TABLE `llx_co_exp` DISABLE KEYS */;
/*!40000 ALTER TABLE `llx_co_exp` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_co_fa`
--
@ -1451,32 +1425,6 @@ LOCK TABLES `llx_co_fa` WRITE;
/*!40000 ALTER TABLE `llx_co_fa` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_co_liv`
--
DROP TABLE IF EXISTS `llx_co_liv`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `llx_co_liv` (
`rowid` int(11) NOT NULL auto_increment,
`fk_commande` int(11) NOT NULL default '0',
`fk_livraison` int(11) NOT NULL default '0',
PRIMARY KEY (`rowid`),
KEY `fk_commande` (`fk_commande`),
KEY `fk_livraison` (`fk_livraison`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
--
-- Dumping data for table `llx_co_liv`
--
LOCK TABLES `llx_co_liv` WRITE;
/*!40000 ALTER TABLE `llx_co_liv` DISABLE KEYS */;
/*!40000 ALTER TABLE `llx_co_liv` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_co_pr`
--
@ -3846,58 +3794,6 @@ LOCK TABLES `llx_paiementfourn_facturefourn` WRITE;
/*!40000 ALTER TABLE `llx_paiementfourn_facturefourn` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_pr_exp`
--
DROP TABLE IF EXISTS `llx_pr_exp`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `llx_pr_exp` (
`rowid` int(11) NOT NULL auto_increment,
`fk_propal` int(11) NOT NULL default '0',
`fk_expedition` int(11) NOT NULL default '0',
PRIMARY KEY (`rowid`),
KEY `fk_propal` (`fk_propal`),
KEY `fk_expedition` (`fk_expedition`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
--
-- Dumping data for table `llx_pr_exp`
--
LOCK TABLES `llx_pr_exp` WRITE;
/*!40000 ALTER TABLE `llx_pr_exp` DISABLE KEYS */;
/*!40000 ALTER TABLE `llx_pr_exp` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_pr_liv`
--
DROP TABLE IF EXISTS `llx_pr_liv`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `llx_pr_liv` (
`rowid` int(11) NOT NULL auto_increment,
`fk_propal` int(11) NOT NULL default '0',
`fk_livraison` int(11) NOT NULL default '0',
PRIMARY KEY (`rowid`),
KEY `fk_propal` (`fk_propal`),
KEY `fk_livraison` (`fk_livraison`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
--
-- Dumping data for table `llx_pr_liv`
--
LOCK TABLES `llx_pr_liv` WRITE;
/*!40000 ALTER TABLE `llx_pr_liv` DISABLE KEYS */;
/*!40000 ALTER TABLE `llx_pr_liv` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_prelevement_bons`
--

View File

@ -134,64 +134,68 @@ class Expedition extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition";
$sql.= " SET ref = '(PROV".$this->id.")'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("Expedition::create sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
// Insertion des lignes
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
{
if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0)
{
$error++;
}
}
if (! $error && $this->id && $this->origin_id)
{
$ret = $this->add_object_linked();
if (!$ret)
{
$error++;
}
if ($conf->commande->enabled)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id;
if (! $this->db->query($sql))
{
$error++;
}
}
else
{
// TODO definir un statut
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id;
if (! $this->db->query($sql))
{
$error++;
}
}
}
if (! $error)
{
$this->db->commit();
return $this->id;
}
else
{
$error++;
$this->error=$this->db->lasterror()." - sql=$sql";
$this->db->rollback();
return -3;
}
}
else
{
$error++;
$this->error=$this->db->lasterror()." - sql=$sql";
$this->db->rollback();
return -2;
}
{
// Insertion des lignes
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
{
if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0)
{
$error++;
}
}
if (! $error && $this->id && $this->origin_id)
{
$ret = $this->add_object_linked();
if (!$ret)
{
$error++;
}
if ($conf->commande->enabled)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id;
dol_syslog("Expedition::create sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
{
$error++;
}
}
else
{
// TODO definir un statut
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id;
dol_syslog("Expedition::create sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
{
$error++;
}
}
}
if (! $error)
{
$this->db->commit();
return $this->id;
}
else
{
$error++;
$this->error=$this->db->lasterror()." - sql=$sql";
$this->db->rollback();
return -3;
}
}
else
{
$error++;
$this->error=$this->db->lasterror()." - sql=$sql";
$this->db->rollback();
return -2;
}
}
else
{

View File

@ -1,24 +0,0 @@
-- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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_co_liv ADD INDEX idx_co_liv_fk_commande (fk_commande);
ALTER TABLE llx_co_liv ADD INDEX idx_co_liv_fk_livraison (fk_livraison);

View File

@ -1,27 +0,0 @@
-- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 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$
-- ===================================================================
create table llx_co_liv
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_commande integer NOT NULL,
fk_livraison integer NOT NULL
)type=innodb;

View File

@ -1,24 +0,0 @@
-- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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_pr_liv ADD INDEX idx_pr_liv_fk_propal (fk_propal);
ALTER TABLE llx_pr_liv ADD INDEX idx_pr_liv_fk_livraison (fk_livraison);

View File

@ -1,27 +0,0 @@
-- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 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$
-- ===================================================================
create table llx_pr_liv
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_propal integer NOT NULL,
fk_livraison integer NOT NULL
)type=innodb;

View File

@ -236,9 +236,9 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"]))
migrate_relationship_tables($db,$langs,$conf,'pr_exp','fk_propal','propal','fk_expedition','shipping');
//migrate_relationship_tables($db,$langs,$conf,'pr_liv','fk_propal','propal','fk_livraison','delivery');
migrate_relationship_tables($db,$langs,$conf,'pr_liv','fk_propal','propal','fk_livraison','delivery');
//migrate_relationship_tables($db,$langs,$conf,'co_liv','fk_commande','commande','fk_livraison','delivery');
migrate_relationship_tables($db,$langs,$conf,'co_liv','fk_commande','commande','fk_livraison','delivery');
//migrate_relationship_tables($db,$langs,$conf,'co_pr','fk_propale','propal','fk_commande','commande');

View File

@ -164,7 +164,7 @@ class Livraison extends CommonObject
$error++;
}
if (! $conf->expedition->enabled)
if (! $conf->expedition_bon->enabled)
{
if ($conf->commande->enabled)
{