diff --git a/dev/initdemo/initdemo.sql b/dev/initdemo/initdemo.sql index d89a0a9b6e8..30b4cc1ea0e 100644 --- a/dev/initdemo/initdemo.sql +++ b/dev/initdemo/initdemo.sql @@ -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` -- diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 0407a976fee..e014597fbdf 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -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 { diff --git a/htdocs/install/mysql/tables/llx_co_liv.key.sql b/htdocs/install/mysql/tables/llx_co_liv.key.sql deleted file mode 100644 index 7027c42fc35..00000000000 --- a/htdocs/install/mysql/tables/llx_co_liv.key.sql +++ /dev/null @@ -1,24 +0,0 @@ --- =================================================================== --- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2008 Regis Houssin --- Copyright (C) 2009 Laurent Destailleur --- --- 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); diff --git a/htdocs/install/mysql/tables/llx_co_liv.sql b/htdocs/install/mysql/tables/llx_co_liv.sql deleted file mode 100644 index 34c50c583d3..00000000000 --- a/htdocs/install/mysql/tables/llx_co_liv.sql +++ /dev/null @@ -1,27 +0,0 @@ --- =================================================================== --- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2008 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 --- 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; diff --git a/htdocs/install/mysql/tables/llx_pr_liv.key.sql b/htdocs/install/mysql/tables/llx_pr_liv.key.sql deleted file mode 100644 index 61212e4c187..00000000000 --- a/htdocs/install/mysql/tables/llx_pr_liv.key.sql +++ /dev/null @@ -1,24 +0,0 @@ --- =================================================================== --- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2008 Regis Houssin --- Copyright (C) 2009 Laurent Destailleur --- --- 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); diff --git a/htdocs/install/mysql/tables/llx_pr_liv.sql b/htdocs/install/mysql/tables/llx_pr_liv.sql deleted file mode 100644 index 69b39bbe55d..00000000000 --- a/htdocs/install/mysql/tables/llx_pr_liv.sql +++ /dev/null @@ -1,27 +0,0 @@ --- =================================================================== --- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2008 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 --- 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; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 5ba83b54cdc..09613ab4235 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -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'); diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index fa87354ed53..50dcb2545e8 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -164,7 +164,7 @@ class Livraison extends CommonObject $error++; } - if (! $conf->expedition->enabled) + if (! $conf->expedition_bon->enabled) { if ($conf->commande->enabled) {