From b3ae6712374e4afd9f191a5505465a56966500f0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 11 Dec 2009 16:31:42 +0000 Subject: [PATCH] Works on migration of relationship tables --- htdocs/commonobject.class.php | 25 ++- htdocs/expedition/expedition.class.php | 59 +++--- htdocs/expedition/fiche.php | 18 +- htdocs/expedition/index.php | 8 +- htdocs/expedition/liste.php | 17 +- .../install/mysql/tables/llx_co_exp.key.sql | 24 --- htdocs/install/mysql/tables/llx_co_exp.sql | 27 --- .../install/mysql/tables/llx_pr_exp.key.sql | 24 --- htdocs/install/mysql/tables/llx_pr_exp.sql | 27 --- htdocs/install/upgrade2.php | 189 ++++++++++++++---- htdocs/langs/en_US/install.lang | 1 + htdocs/langs/fr_FR/install.lang | 1 + 12 files changed, 227 insertions(+), 193 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_co_exp.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_co_exp.sql delete mode 100644 htdocs/install/mysql/tables/llx_pr_exp.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_pr_exp.sql diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index 0c5a64a3cd8..dcd4ff51a83 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -836,14 +836,33 @@ class CommonObject /** * Add objects linked in llx_element_element. */ - function add_object_linked($sourceid,$sourcetype,$targetid,$targettype) + function add_object_linked() { + $this->db->begin(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql.= "fk_source"; $sql.= ", sourcetype"; $sql.= ", fk_target"; $sql.= ", targettype"; $sql.= ") VALUES ("; + $sql.= $this->origin_id; + $sql.= ", '".$this->origin."'"; + $sql.= ", ".$this->id; + $sql.= ", '".$this->element."'"; + $sql.= ")"; + + if ($this->db->query($sql)) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror()." - sql=$sql"; + $this->db->rollback(); + return 0; + } } /** @@ -856,8 +875,8 @@ class CommonObject // Links beetween objects are stored in this table $sql = 'SELECT fk_source, sourcetype, fk_target, targettype'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_element'; - $sql.= " WHERE (fk_source = '".$this->id."' AND sourcetype = 'invoice')"; - $sql.= " OR (fk_target = '".$this->id."' AND targettype = 'invoice')"; + $sql.= " WHERE (fk_source = '".$this->id."' AND sourcetype = '".$this->origin."')"; + $sql.= " OR (fk_target = '".$this->id."' AND targettype = '".$this->element."')"; dol_syslog("CommonObject::load_object_linked sql=".$sql); $resql = $this->db->query($sql); diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index aa85442ec71..0407a976fee 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -38,7 +38,7 @@ class Expedition extends CommonObject { var $db; var $error; - var $element="expedition"; + var $element="shipping"; var $fk_element="fk_expedition"; var $table_element="expedition"; @@ -147,14 +147,14 @@ class Expedition extends CommonObject if (! $error && $this->id && $this->origin_id) { + $ret = $this->add_object_linked(); + if (!$ret) + { + $error++; + } + if ($conf->commande->enabled) { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')'; - if (!$this->db->query($sql)) - { - $error++; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id; if (! $this->db->query($sql)) { @@ -163,12 +163,6 @@ class Expedition extends CommonObject } else { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')'; - if (!$this->db->query($sql)) - { - $error++; - } - // TODO definir un statut $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id; if (! $this->db->query($sql)) @@ -240,27 +234,20 @@ class Expedition extends CommonObject $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison"; $sql.= ", e.fk_expedition_methode, e.tracking_number"; - if ($conf->commande->enabled) - { - $sql.= ", ce.fk_commande as origin_id"; - $sql.= ", c.ref_client"; - } - else - { - $sql.= ", pe.fk_propal as origin_id"; - $sql.= ", p.ref_client"; - } + $sql.= ", el.fk_source as origin_id"; + $sql.= ", ori.ref_client"; if ($conf->livraison_bon->enabled) $sql.=", l.rowid as livraison_id"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target"; if ($conf->commande->enabled) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as ori ON el.fk_source = ori.rowid"; + $sql.= " AND el.sourcetype = 'commande'"; } else { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_exp as pe ON e.rowid = pe.fk_expedition"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as p ON pe.fk_propal = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as ori ON el.fk_source = ori.rowid"; + $sql.= " AND el.sourcetype = 'propal'"; } if ($conf->livraison_bon->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition"; $sql.= " WHERE e.rowid = ".$id; @@ -573,18 +560,25 @@ class Expedition extends CommonObject { $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; + $sql.= " WHERE fk_expedition = ".$this->id; + if ( $this->db->query($sql) ) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."co_exp WHERE rowid = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element"; + $sql.= " WHERE fk_target = ".$this->id; + $sql.= " AND targettype = '".$this->element."'"; + if ( $this->db->query($sql) ) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition"; + $sql.= " WHERE rowid = ".$this->id; + if ( $this->db->query($sql) ) { $this->db->commit(); - // On efface le r�pertoire de pdf provisoire + // On efface le repertoire de pdf provisoire $expref = dol_sanitizeFileName($this->ref); if ($conf->expedition->dir_output) { @@ -612,18 +606,21 @@ class Expedition extends CommonObject } else { + $this->error=$this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } } else { + $this->error=$this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } } else { + $this->error=$this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -1; } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 728e74c6d70..3c4cbc70c77 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -154,9 +154,16 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') { $expedition = new Expedition($db); $expedition->fetch($_GET["id"]); - $expedition->delete(); - Header("Location: liste.php"); - exit; + $result = $expedition->delete(); + if ($result > 0) + { + Header("Location: liste.php"); + exit; + } + else + { + $mesg = $expedition->error; + } } } @@ -535,6 +542,11 @@ else if ($expedition->id > 0) { + if ($mesg) + { + print '
'.$mesg.'
'; + } + $typeobject = $expedition->origin; $origin = $expedition->origin; $expedition->fetch_object(); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 9cd64c7ca4c..548df32107d 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -60,8 +60,8 @@ $sql = "SELECT e.rowid, e.ref"; $sql.= ", s.nom, s.rowid as socid"; $sql.= ", c.ref as commande_ref, c.rowid as commande_id"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; if (!$user->rights->societe->client->voir && !$socid) { @@ -194,8 +194,8 @@ $sql = "SELECT e.rowid, e.ref"; $sql.= ", s.nom, s.rowid as socid"; $sql.= ", c.ref as commande_ref, c.rowid as commande_id"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; if (!$user->rights->societe->client->voir && !$socid) { diff --git a/htdocs/expedition/liste.php b/htdocs/expedition/liste.php index 04b9bd901eb..b12d70d83b8 100644 --- a/htdocs/expedition/liste.php +++ b/htdocs/expedition/liste.php @@ -21,7 +21,7 @@ /** * \file htdocs/expedition/liste.php * \ingroup expedition - * \brief Page de la liste des exp�ditions/livraisons + * \brief Page de la liste des expeditions/livraisons * \version $Id$ */ @@ -53,17 +53,18 @@ llxHeader('',$langs->trans('ListOfSendings'),$helpurl); $sql = "SELECT e.rowid, e.ref,".$db->pdate("e.date_expedition")." as date_expedition, e.fk_statut"; $sql.= ", s.nom as socname, s.rowid as socid"; -$sql.= ", ori.ref as oriref, ori.rowid as oriid"; +$sql.= ", ori.ref as origin_ref, ori.rowid as origin_id"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target"; if ($conf->commande->enabled) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as ori ON ce.fk_commande = ori.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as ori ON el.fk_source = ori.rowid"; + $sql.= " AND el.sourcetype = 'commande'"; } else { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_exp as pe ON e.rowid = pe.fk_expedition"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as ori ON pe.fk_commande = ori.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as ori ON el.fk_source = ori.rowid"; + $sql.= " AND el.sourcetype = 'propal'"; } $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; $sql.= " WHERE s.entity = ".$conf->entity; @@ -123,11 +124,11 @@ if ($resql) print ''.$objp->socname.''; if ($conf->commande->enabled) { - print ''.$objp->oriref.''; + print ''.$objp->origin_ref.''; } else { - print ''.$objp->oriref.''; + print ''.$objp->origin_ref.''; } $now = time(); diff --git a/htdocs/install/mysql/tables/llx_co_exp.key.sql b/htdocs/install/mysql/tables/llx_co_exp.key.sql deleted file mode 100644 index 709f772d686..00000000000 --- a/htdocs/install/mysql/tables/llx_co_exp.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_exp ADD INDEX idx_co_exp_fk_commande (fk_commande); -ALTER TABLE llx_co_exp ADD INDEX idx_co_exp_fk_expedition (fk_expedition); diff --git a/htdocs/install/mysql/tables/llx_co_exp.sql b/htdocs/install/mysql/tables/llx_co_exp.sql deleted file mode 100644 index ea5ae5e0fc1..00000000000 --- a/htdocs/install/mysql/tables/llx_co_exp.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_exp -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_commande integer NOT NULL, - fk_expedition integer NOT NULL -)type=innodb; diff --git a/htdocs/install/mysql/tables/llx_pr_exp.key.sql b/htdocs/install/mysql/tables/llx_pr_exp.key.sql deleted file mode 100644 index 3486e871897..00000000000 --- a/htdocs/install/mysql/tables/llx_pr_exp.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_exp ADD INDEX idx_pr_exp_fk_propal (fk_propal); -ALTER TABLE llx_pr_exp ADD INDEX idx_pr_exp_fk_expedition (fk_expedition); diff --git a/htdocs/install/mysql/tables/llx_pr_exp.sql b/htdocs/install/mysql/tables/llx_pr_exp.sql deleted file mode 100644 index 5758cb2290d..00000000000 --- a/htdocs/install/mysql/tables/llx_pr_exp.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_exp -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_propal integer NOT NULL, - fk_expedition integer NOT NULL -)type=innodb; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index eb048901fea..c7d837aeb86 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -226,10 +226,15 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"])) migrate_restore_missing_links($db,$langs,$conf); - migrate_directories($db,$langs,$conf,'/compta','/banque'); migrate_directories($db,$langs,$conf,'/societe','/mycompany'); + + + // Script pour V2.7 -> V2.8 + migrate_relationship_tables($db,$langs,$conf,'co_exp','fk_commande','commande','fk_expedition','shipping'); + + migrate_relationship_tables($db,$langs,$conf,'pr_exp','fk_propal','propal','fk_expedition','shipping'); // On commit dans tous les cas. @@ -2210,60 +2215,66 @@ function migrate_commande_deliveryaddress($db,$langs,$conf) print ''.$langs->trans('MigrationDeliveryAddress')."
\n"; $error = 0; - - $db->begin(); - - $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."co_exp as ce"; - $sql.= " WHERE c.rowid = ce.fk_commande"; - $sql.= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; - - $resql = $db->query($sql); - if ($resql) + + if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) { - $i = 0; - $num = $db->num_rows($resql); - - if ($num) + $db->begin(); + + $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."co_exp as ce"; + $sql.= " WHERE c.rowid = ce.fk_commande"; + $sql.= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; + + $resql = $db->query($sql); + if ($resql) { - while ($i < $num) + $i = 0; + $num = $db->num_rows($resql); + + if ($num) { - $obj = $db->fetch_object($resql); - - $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql.= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; - $sql.= " WHERE rowid=".$obj->fk_expedition; - - $resql2=$db->query($sql); - if ($resql2) + while ($i < $num) { - + $obj = $db->fetch_object($resql); + + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; + $sql.= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; + $sql.= " WHERE rowid=".$obj->fk_expedition; + + $resql2=$db->query($sql); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; } - else - { - $error++; - dol_print_error($db); - } - print ". "; - $i++; } - - } - - if ($error == 0) - { - $db->commit(); + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + + if ($error == 0) + { + $db->commit(); + } + else + { + $db->rollback(); + } } else { + dol_print_error($db); $db->rollback(); } } else { - dol_print_error($db); - $db->rollback(); + print $langs->trans('AlreadyDone')."
\n"; } print ''; @@ -2401,7 +2412,10 @@ function migrate_restore_missing_links($db,$langs,$conf) } } - else print $langs->trans('AlreadyDone')."
\n"; + else + { + print $langs->trans('AlreadyDone')."
\n"; + } if ($error == 0) { @@ -2421,6 +2435,97 @@ function migrate_restore_missing_links($db,$langs,$conf) print ''; } +/* + * Migration des tables de relation + */ +function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcetype,$fk_target,$targettype) +{ + print ''; + + print '
'; + print ''.$langs->trans('MigrationRelationshipTables',MAIN_DB_PREFIX.$table)."
\n"; + + $error = 0; + + if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) + { + dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); + + $db->begin(); + + $sqlSelect = "SELECT ".$fk_source.", ".$fk_target; + $sqlSelect.= " FROM ".MAIN_DB_PREFIX.$table; + + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; + $sqlInsert.= "fk_source"; + $sqlInsert.= ", sourcetype"; + $sqlInsert.= ", fk_target"; + $sqlInsert.= ", targettype"; + $sqlInsert.= ") VALUES ("; + $sqlInsert.= $obj->$fk_source; + $sqlInsert.= ", '".$sourcetype."'"; + $sqlInsert.= ", ".$obj->$fk_target; + $sqlInsert.= ", '".$targettype."'"; + $sqlInsert.= ")"; + + $result=$db->query($sqlInsert); + if (! $result) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + + if ($error == 0) + { + $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table; + if ($db->query($sqlDrop)) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + $db->rollback(); + } + } + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + + print ''; +} + /* * Migration directory diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index b7e6f585575..6e4b5c9e250 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -147,6 +147,7 @@ MigrationInvoice=Data migration for customers' invoices MigrationContract=Data migration for contracts MigrationSuccessfullUpdate=Upgrade successful MigrationUpdateFailed=Failed upgrade process +MigrationRelationshipTables=Data migration for relationship tables (%s) # Payments Update MigrationPaymentsUpdate=Payment data correction diff --git a/htdocs/langs/fr_FR/install.lang b/htdocs/langs/fr_FR/install.lang index 9f951f8ab9c..1e98e13dd69 100644 --- a/htdocs/langs/fr_FR/install.lang +++ b/htdocs/langs/fr_FR/install.lang @@ -149,6 +149,7 @@ MigrationInvoice=Migration de données sur les factures clients MigrationContract=Migration de données sur les contrats MigrationSuccessfullUpdate=Mise à jour réussie MigrationUpdateFailed=La mise à jour à échouée +MigrationRelationshipTables=Migration des tables de liaison (%s) # Payments Update MigrationPaymentsUpdate=Mise a jour des paiments (lien n-n paiements-factures)