Works on enhancement of project tasks

Fix: data migration field fk_user_resp of llx_projet to llx_element_contact
This commit is contained in:
Regis Houssin 2010-01-26 14:08:59 +00:00
parent 4345d2563b
commit 69f38173a7
5 changed files with 101 additions and 58 deletions

View File

@ -30,7 +30,6 @@ create table llx_projet
ref varchar(50),
entity integer DEFAULT 1 NOT NULL, -- multi company id
title varchar(255),
fk_user_resp integer, -- responsable du projet
fk_user_creat integer, -- createur du projet
note text,
model_pdf varchar(50)

View File

@ -1,28 +0,0 @@
-- ===========================================================================
-- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
--
-- 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_projet_task_actors
(
fk_projet_task integer NOT NULL,
fk_user integer NOT NULL,
role varchar(5) DEFAULT 'admin',
UNIQUE (fk_projet_task, fk_user)
)type=innodb;

View File

@ -257,6 +257,8 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"]))
migrate_relationship_tables($db,$langs,$conf,'co_fa','fk_commande','commande','fk_facture','facture');
migrate_project_user_resp($db,$langs,$conf);
migrate_project_task_actors($db,$langs,$conf);
}
@ -279,8 +281,6 @@ else
pFooter($error,$setuplang);
/**
* Reporte liens vers une facture de paiements sur table de jointure (lien n-n paiements factures)
*/
@ -367,7 +367,6 @@ function migrate_paiements($db,$langs,$conf)
print '</td></tr>';
}
/**
* Corrige paiement orphelins (liens paumes suite a bugs)
* Pour verifier s'il reste des orphelins:
@ -488,7 +487,6 @@ function migrate_paiements_orphelins_1($db,$langs,$conf)
print '</td></tr>';
}
/**
* Corrige paiement orphelins (liens paumes suite a bugs)
* Pour verifier s'il reste des orphelins:
@ -627,7 +625,6 @@ function migrate_paiements_orphelins_2($db,$langs,$conf)
print '</td></tr>';
}
function migrate_paiements_orphelins_3($db,$langs,$conf)
{
@ -641,7 +638,6 @@ function migrate_paiements_orphelins_3($db,$langs,$conf)
}
/*
* Mise a jour des contrats (gestion du contrat + detail de contrat)
*/
@ -735,7 +731,6 @@ function migrate_contracts_det($db,$langs,$conf)
print '</td></tr>';
}
function migrate_links_transfert($db,$langs,$conf)
{
print '<tr><td colspan="4">';
@ -812,7 +807,6 @@ function migrate_links_transfert($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour des date de contrats non renseignees
*/
@ -844,7 +838,6 @@ function migrate_contracts_date1($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour date contrat avec date min effective mise en service si inferieur
*/
@ -909,7 +902,6 @@ function migrate_contracts_date2($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour des dates de creation de contrat
*/
@ -932,7 +924,6 @@ function migrate_contracts_date3($db,$langs,$conf)
print '</td></tr>';
}
/*
* Reouverture des contrats qui ont au moins une ligne non fermee
*/
@ -987,7 +978,6 @@ function migrate_contracts_open($db,$langs,$conf)
print '</td></tr>';
}
/**
* Factures fournisseurs
*/
@ -1100,8 +1090,6 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
}
}
/*
* Mise a jour des totaux lignes de facture
*/
@ -1211,7 +1199,6 @@ function migrate_price_facture($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour des totaux lignes de propal
*/
@ -1315,8 +1302,6 @@ function migrate_price_propal($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour des totaux lignes de propal
*/
@ -1421,7 +1406,6 @@ function migrate_price_contrat($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour des totaux lignes de commande
*/
@ -1534,7 +1518,6 @@ function migrate_price_commande($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour des totaux lignes de commande fournisseur
*/
@ -1647,7 +1630,6 @@ function migrate_price_commande_fournisseur($db,$langs,$conf)
print '</td></tr>';
}
/*
* Mise a jour des modeles selectionnes
*/
@ -1826,8 +1808,6 @@ function migrate_commande_expedition($db,$langs,$conf)
if ($num)
{
$db->begin();
while ($i < $num)
{
$obj = $db->fetch_object($resql);
@ -2076,8 +2056,6 @@ function migrate_detail_livraison($db,$langs,$conf)
print '</td></tr>';
}
/*
* Migration du champ stock dans produits
*/
@ -2147,8 +2125,6 @@ function migrate_stocks($db,$langs,$conf)
print '</td></tr>';
}
/*
* Migration of menus (use only 1 table instead of 3)
*/
@ -2303,7 +2279,6 @@ function migrate_commande_deliveryaddress($db,$langs,$conf)
print '</td></tr>';
}
/*
* Migration du champ fk_remise_except dans llx_facturedet doit correspondre a
* lien dans llx_societe_remise_except vers llx_facturedet
@ -2458,6 +2433,98 @@ function migrate_restore_missing_links($db,$langs,$conf)
print '</td></tr>';
}
/*
* Migration du champ fk_user_resp de llx_projet vers llx_element_contact
*/
function migrate_project_user_resp($db,$langs,$conf)
{
dolibarr_install_syslog("upgrade2::migrate_project_user_resp");
print '<tr><td colspan="4">';
print '<br>';
print '<b>'.$langs->trans('MigrationProjectUserResp')."</b><br>\n";
$result = $db->DDLDescTable(MAIN_DB_PREFIX."projet","fk_user_resp");
$obj = $db->fetch_object($result);
if ($obj)
{
$error = 0;
$db->begin();
$sql = "SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX."projet";
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num = $db->num_rows($resql);
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact (";
$sql2.= "datecreate";
$sql2.= ", statut";
$sql2.= ", element_id";
$sql2.= ", fk_c_type_contact";
$sql2.= ", fk_socpeople";
$sql2.= ") VALUES (";
$sql2.= $db->idate(dol_now());
$sql2.= ", '4'";
$sql2.= ", ".$obj->rowid;
$sql2.= ", '160'";
$sql2.= ", ".$obj->fk_user_resp;
$sql2.= ")";
if ($obj->fk_user_resp > 0)
{
$resql2=$db->query($sql2);
if (!$resql2)
{
$error++;
dol_print_error($db);
}
}
print ". ";
$i++;
}
}
if ($error == 0)
{
$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."projet DROP COLUMN fk_user_resp";
if ($db->query($sqlDrop))
{
$db->commit();
}
else
{
$db->rollback();
}
}
else
{
$db->rollback();
}
}
else
{
dol_print_error($db);
$db->rollback();
}
}
else
{
print $langs->trans('AlreadyDone')."<br>\n";
}
print '</td></tr>';
}
/*
* Migration de la table llx_projet_task_actors vers llx_element_contact
*/
@ -2636,7 +2703,6 @@ function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcet
print '</td></tr>';
}
/*
* Migration directory
*/

View File

@ -209,4 +209,7 @@ MigrationMenusDetail=Update dynamic menus tables
MigrationDeliveryAddress=Update delivery address in shipments
# Migration project task actors
MigrationProjectTaskActors=Data migration for llx_projet_task_actors table
MigrationProjectTaskActors=Data migration for llx_projet_task_actors table
# Migration project user resp
MigrationProjectUserResp=Data migration field fk_user_resp of llx_projet to llx_element_contact

View File

@ -212,3 +212,6 @@ MigrationDeliveryAddress=Mise a jour des adresses de livraison dans les bons d'e
# Migration project task actors
MigrationProjectTaskActors=Migration de la table llx_projet_task_actors
# Migration project user resp
MigrationProjectUserResp=Migration du champ fk_user_resp de llx_projet vers llx_element_contact