Fix: errors in expedition module migration
This commit is contained in:
parent
61ac018214
commit
3087b6c0fc
@ -22,7 +22,7 @@
|
|||||||
\file htdocs/install/upgrade2.php
|
\file htdocs/install/upgrade2.php
|
||||||
\brief Effectue la migration de donnees diverses
|
\brief Effectue la migration de donnees diverses
|
||||||
\version $Id$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once('./inc.php');
|
include_once('./inc.php');
|
||||||
if (file_exists($conffile)) include_once($conffile);
|
if (file_exists($conffile)) include_once($conffile);
|
||||||
@ -511,13 +511,13 @@ function migrate_paiements_orphelins_2($db,$langs,$conf)
|
|||||||
function migrate_paiements_orphelins_3($db,$langs,$conf)
|
function migrate_paiements_orphelins_3($db,$langs,$conf)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
select p.rowid from llx_paiement as p left join llx_paiement_facture as pf on pf.fk_paiement=p.rowid WHERE pf.rowid IS NULL AND (p.fk_facture = 0 OR p.fk_facture IS NULL)
|
select p.rowid from llx_paiement as p left join llx_paiement_facture as pf on pf.fk_paiement=p.rowid WHERE pf.rowid IS NULL AND (p.fk_facture = 0 OR p.fk_facture IS NULL)
|
||||||
Poru chaque rep, test si
|
Poru chaque rep, test si
|
||||||
select count(*) from llx_bank where rowid = obj->fk_bank
|
select count(*) from llx_bank where rowid = obj->fk_bank
|
||||||
select count(*) from llx_bank_url where url_id = 128 and type='payment'
|
select count(*) from llx_bank_url where url_id = 128 and type='payment'
|
||||||
Si partout 0, on efface ligne de llx_paiement
|
Si partout 0, on efface ligne de llx_paiement
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1614,8 +1614,6 @@ function migrate_module_menus($db,$langs,$conf)
|
|||||||
*/
|
*/
|
||||||
function migrate_commande_expedition($db,$langs,$conf)
|
function migrate_commande_expedition($db,$langs,$conf)
|
||||||
{
|
{
|
||||||
if ($conf->expedition->enabled)
|
|
||||||
{
|
|
||||||
print '<tr><td colspan="4">';
|
print '<tr><td colspan="4">';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@ -1625,12 +1623,15 @@ function migrate_commande_expedition($db,$langs,$conf)
|
|||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
if ($obj)
|
if ($obj)
|
||||||
{
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$error = 0;
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -1653,10 +1654,13 @@ function migrate_commande_expedition($db,$langs,$conf)
|
|||||||
print ". ";
|
print ". ";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($error == 0)
|
if ($error == 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande";
|
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande";
|
||||||
|
print $langs->trans('FieldRenamed')."<br>\n";
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1664,10 +1668,10 @@ function migrate_commande_expedition($db,$langs,$conf)
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db);
|
dolibarr_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1675,7 +1679,6 @@ function migrate_commande_expedition($db,$langs,$conf)
|
|||||||
print $langs->trans('AlreadyDone')."<br>\n";
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1683,8 +1686,6 @@ function migrate_commande_expedition($db,$langs,$conf)
|
|||||||
*/
|
*/
|
||||||
function migrate_commande_livraison($db,$langs,$conf)
|
function migrate_commande_livraison($db,$langs,$conf)
|
||||||
{
|
{
|
||||||
if ($conf->livraison_bon->enabled)
|
|
||||||
{
|
|
||||||
print '<tr><td colspan="4">';
|
print '<tr><td colspan="4">';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@ -1694,6 +1695,10 @@ function migrate_commande_livraison($db,$langs,$conf)
|
|||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
if ($obj)
|
if ($obj)
|
||||||
{
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$sql = "SELECT l.rowid, l.fk_commande";
|
$sql = "SELECT l.rowid, l.fk_commande";
|
||||||
$sql.= ", c.ref_client, c.date_livraison";
|
$sql.= ", c.ref_client, c.date_livraison";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
|
||||||
@ -1702,13 +1707,10 @@ function migrate_commande_livraison($db,$langs,$conf)
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$error = 0;
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
@ -1738,10 +1740,13 @@ function migrate_commande_livraison($db,$langs,$conf)
|
|||||||
print ". ";
|
print ". ";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($error == 0)
|
if ($error == 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande";
|
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande";
|
||||||
|
print $langs->trans('FieldRenamed')."<br>\n";
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1749,10 +1754,10 @@ function migrate_commande_livraison($db,$langs,$conf)
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db);
|
dolibarr_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1760,7 +1765,6 @@ function migrate_commande_livraison($db,$langs,$conf)
|
|||||||
print $langs->trans('AlreadyDone')."<br>\n";
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1768,17 +1772,21 @@ function migrate_commande_livraison($db,$langs,$conf)
|
|||||||
*/
|
*/
|
||||||
function migrate_detail_livraison($db,$langs,$conf)
|
function migrate_detail_livraison($db,$langs,$conf)
|
||||||
{
|
{
|
||||||
if ($conf->livraison->enabled)
|
|
||||||
{
|
|
||||||
print '<tr><td colspan="4">';
|
print '<tr><td colspan="4">';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<b>'.$langs->trans('MigrationDeliveryDetail')."</b><br>\n";
|
print '<b>'.$langs->trans('MigrationDeliveryDetail')."</b><br>\n";
|
||||||
|
|
||||||
|
// This is done if field fk_commande_ligne exists.
|
||||||
|
// If not this means migration was already done.
|
||||||
$result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet","fk_commande_ligne");
|
$result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet","fk_commande_ligne");
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
if ($obj)
|
if ($obj)
|
||||||
{
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht";
|
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht";
|
||||||
$sql.= ", ld.fk_livraison";
|
$sql.= ", ld.fk_livraison";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
|
||||||
@ -1787,13 +1795,10 @@ function migrate_detail_livraison($db,$langs,$conf)
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$error = 0;
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
@ -1843,10 +1848,13 @@ function migrate_detail_livraison($db,$langs,$conf)
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ($error == 0)
|
if ($error == 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer";
|
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer";
|
||||||
|
print $langs->trans('FieldRenamed')."<br>\n";
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1854,10 +1862,10 @@ function migrate_detail_livraison($db,$langs,$conf)
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db);
|
dolibarr_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1872,10 +1880,9 @@ function migrate_detail_livraison($db,$langs,$conf)
|
|||||||
print $langs->trans('AlreadyDone')."<br>\n";
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A faire egalement: Modif statut paye et fk_facture des factures payés completement
|
/* A faire egalement: Modif statut paye et fk_facture des factures payes completement
|
||||||
|
|
||||||
On recherche facture incorrecte:
|
On recherche facture incorrecte:
|
||||||
select f.rowid, f.total_ttc as t1, sum(pf.amount) as t2 from llx_facture as f, llx_paiement_facture as pf where pf.fk_facture=f.rowid and f.fk_statut in(2,3) and paye=0 and close_code is null group by f.rowid
|
select f.rowid, f.total_ttc as t1, sum(pf.amount) as t2 from llx_facture as f, llx_paiement_facture as pf where pf.fk_facture=f.rowid and f.fk_statut in(2,3) and paye=0 and close_code is null group by f.rowid
|
||||||
|
|||||||
@ -143,7 +143,10 @@ MigrationPaymentsNothingUpdatable=No more payments that can be corrected
|
|||||||
|
|
||||||
# Contracts Update
|
# Contracts Update
|
||||||
MigrationContractsUpdate=Contract data correction
|
MigrationContractsUpdate=Contract data correction
|
||||||
|
MigrationContractsNumberToUpdate=%s contract(s) to update
|
||||||
|
MigrationContractsLineCreation=Create contract line for contract ref %s
|
||||||
MigrationContractsNothingToUpdate=No more things to do
|
MigrationContractsNothingToUpdate=No more things to do
|
||||||
|
MigrationContractsFieldDontExist=Field fk_facture does not exists anymore. Nothing to do.
|
||||||
|
|
||||||
# Contracts Empty Dates Update
|
# Contracts Empty Dates Update
|
||||||
MigrationContractsEmptyDatesUpdate=Contract empty date correction
|
MigrationContractsEmptyDatesUpdate=Contract empty date correction
|
||||||
@ -172,4 +175,8 @@ MigrationReopeningContractsNothingToUpdate=No closed contract to open
|
|||||||
MigrationBankTransfertsUpdate=Update links between bank transaction and a bank transfert
|
MigrationBankTransfertsUpdate=Update links between bank transaction and a bank transfert
|
||||||
MigrationBankTransfertsNothingToUpdate=All links are up to date
|
MigrationBankTransfertsNothingToUpdate=All links are up to date
|
||||||
|
|
||||||
|
# Migration delivery
|
||||||
|
MigrationShipmentOrderMatching=Sendings receipt update
|
||||||
|
MigrationDeliveryOrderMatching=Delivery receipt update
|
||||||
|
MigrationDeliveryDetail=Delivery update
|
||||||
|
|
||||||
|
|||||||
@ -177,5 +177,8 @@ MigrationReopeningContractsNothingToUpdate=Pas ou plus de contrats
|
|||||||
MigrationBankTransfertsUpdate=Mise a jour des liens entre ecriture bancaire et un transfert entre compte
|
MigrationBankTransfertsUpdate=Mise a jour des liens entre ecriture bancaire et un transfert entre compte
|
||||||
MigrationBankTransfertsNothingToUpdate=Aucun lien non à jour
|
MigrationBankTransfertsNothingToUpdate=Aucun lien non à jour
|
||||||
|
|
||||||
|
# Migration delivery
|
||||||
|
MigrationShipmentOrderMatching=Mise a jour bon expedition
|
||||||
|
MigrationDeliveryOrderMatching=Mise a jour bon reception
|
||||||
|
MigrationDeliveryDetail=Mise a jour bon reception
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user