Skip to content
Snippets Groups Projects
Commit 94be4ec8 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Avoid error in migration from 3.1 version.

Fix: Suggested migration choice was ko from x.y.z to x.y.z+1
parent 6a84a7f9
Branches
Tags
No related merge requests found
......@@ -45,8 +45,8 @@
* @param string $price_base_type HT=on calcule sur le HT, TTC=on calcule sur le TTC
* @param int $info_bits Miscellaneous informations on line
* @param int $type 0/1=Product/service
* @param string $seller Thirdparty seller (we need $seller->country_code property). Provided only if seller is the supplier.
* @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate function)
* @param string $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc.
* @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate function).
* @return result[ 0=total_ht,
* 1=total_vat,
* 2=total_ttc,
......
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
......@@ -393,24 +393,32 @@ else
foreach ($migrationscript as $migarray)
{
$count++;
$version=preg_split('/[\.-]/',DOL_VERSION);
$versionfrom=$migarray['from'];
$versionto=$migarray['to'];
$newversionfrom=preg_replace('/(\.[0-9]+)$/i','.*',$versionfrom);
$newversionto=preg_replace('/(\.[0-9]+)$/i','.*',$versionto);
$versionarray=preg_split('/[\.-]/',$version);
$dolibarrversionfromarray=preg_split('/[\.-]/',$versionfrom);
$dolibarrversiontoarray=preg_split('/[\.-]/',$versionto);
$version=preg_split('/[\.-]/',DOL_VERSION);
// Define string newversionxxx that are used for text to show
$newversionfrom=preg_replace('/(\.[0-9]+)$/i','.*',$versionfrom);
$newversionto=preg_replace('/(\.[0-9]+)$/i','.*',$versionto);
$newversionfrombis='';
if (versioncompare($dolibarrversiontoarray,$version) < -2) $newversionfrombis=' '.$langs->trans("or").' '.$versionto;
if (versioncompare($dolibarrversiontoarray,$version) < -2) // From x.y.z -> x.y.z+1
{
$newversionfrombis=' '.$langs->trans("or").' '.$versionto;
}
print '<tr class="listofchoices"><td class="listofchoices nowrap" align="center"><b>'.$langs->trans("Upgrade").'<br>'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'</b></td>';
print '<td class="listofchoices">';
print $langs->trans("UpgradeDesc");
if ($ok)
{
if (count($dolibarrlastupgradeversionarray) >= 2) // If a database access is available and a version x.y already available
if (count($dolibarrlastupgradeversionarray) >= 2) // If a database access is available and last upgrade version is known
{
// Now we check if this is the first qualified choice
if ($allowupgrade && empty($foundrecommandedchoice) && versioncompare($dolibarrversiontoarray,$dolibarrlastupgradeversionarray) > 0)
if ($allowupgrade && empty($foundrecommandedchoice) &&
(versioncompare($dolibarrversiontoarray,$dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray,$version) < -2)
)
{
print '<br>';
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
......
......@@ -1459,7 +1459,7 @@ function migrate_price_propal($db,$langs,$conf)
}
/**
* Mise a jour des totaux lignes de propal
* Update total of contract lines
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
......@@ -1470,6 +1470,10 @@ function migrate_price_contrat($db,$langs,$conf)
{
$db->begin();
$tmpmysoc=new Societe($db);
$tmpmysoc->setMysoc($conf);
if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id=0; // Ti not have this set to '' or will make sql syntax error.
print '<tr><td colspan="4">';
print '<br>';
......@@ -1506,7 +1510,7 @@ function migrate_price_contrat($db,$langs,$conf)
//$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis
$contratligne->rowid=$rowid;
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,0,'HT',$info_bits,0);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,0,'HT',$info_bits,0,$tmpmysoc);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment