diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index 5f79e3d8fc2..df105d458e9 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -350,7 +350,6 @@ else
print '
';
if ($allowinstall)
{
- //print ''.$langs->trans("Start").' '; // To restore licence page
print ''.$langs->trans("Start").' ';
}
else
diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php
index ac07c28b335..e403b6c94ff 100644
--- a/htdocs/install/etape1.php
+++ b/htdocs/install/etape1.php
@@ -71,23 +71,23 @@ if (! is_writable($conffile))
// Check parameters
if (empty($_POST["db_type"]))
{
- print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'
';
- $error++;
+ print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'
';
+ $error++;
}
if (empty($_POST["db_host"]))
{
- print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'
';
- $error++;
+ print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'
';
+ $error++;
}
if (empty($_POST["db_name"]))
{
- print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'
';
- $error++;
+ print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'
';
+ $error++;
}
if (empty($_POST["db_user"]))
{
- print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'
';
- $error++;
+ print ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'
';
+ $error++;
}
if (! empty($_POST["db_port"]) && ! is_numeric($_POST["db_port"]))
{
@@ -99,13 +99,13 @@ if (! empty($_POST["db_port"]) && ! is_numeric($_POST["db_port"]))
// Remove last / into dans main_dir
if (substr($main_dir, dol_strlen($main_dir) -1) == "/")
{
- $main_dir = substr($main_dir, 0, dol_strlen($main_dir)-1);
+ $main_dir = substr($main_dir, 0, dol_strlen($main_dir)-1);
}
// Remove last / into dans main_url
if (! empty($_POST["main_url"]) && substr($_POST["main_url"], dol_strlen($_POST["main_url"]) -1) == "/")
{
- $_POST["main_url"] = substr($_POST["main_url"], 0, dol_strlen($_POST["main_url"])-1);
+ $_POST["main_url"] = substr($_POST["main_url"], 0, dol_strlen($_POST["main_url"])-1);
}
// Directory for generated documents (invoices, orders, ecm, etc...)
@@ -116,289 +116,289 @@ if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; }
// Test database connexion
if (! $error)
{
- $result=@include_once($main_dir."/lib/databases/".$_POST["db_type"].".class.php");
- if ($result)
- {
- // If we ask database or user creation we need to connect as root
- if (! empty($_POST["db_create_database"]) && ! $userroot)
- {
- print ''.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$_POST["db_name"]).'
';
- print ' ';
- if (empty($db->connected)) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
- }
- if (! empty($_POST["db_create_user"]) && ! $userroot)
- {
- print ''.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$_POST["db_user"]).'
';
- print ' ';
- if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
- }
+ $result=@include_once($main_dir."/lib/databases/".$_POST["db_type"].".class.php");
+ if ($result)
+ {
+ // If we ask database or user creation we need to connect as root
+ if (! empty($_POST["db_create_database"]) && ! $userroot)
+ {
+ print ''.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$_POST["db_name"]).'
';
+ print ' ';
+ if (empty($db->connected)) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
+ }
+ if (! empty($_POST["db_create_user"]) && ! $userroot)
+ {
+ print ''.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$_POST["db_user"]).'
';
+ print ' ';
+ if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
+ }
- // If we need root access
- if (! $error && (! empty($_POST["db_create_database"]) || ! empty($_POST["db_create_user"])))
- {
- $databasefortest=$_POST["db_name"];
- if (! empty($_POST["db_create_database"]))
- {
- if ($_POST["db_type"] == 'mysql' || $_POST["db_type"] == 'mysqli')
- {
- $databasefortest='mysql';
- }
- elseif ($_POST["db_type"] == 'pgsql')
- {
- $databasefortest='postgres';
- }
- else
- {
- $databasefortest='mssql';
- }
- }
- //print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
+ // If we need root access
+ if (! $error && (! empty($_POST["db_create_database"]) || ! empty($_POST["db_create_user"])))
+ {
+ $databasefortest=$_POST["db_name"];
+ if (! empty($_POST["db_create_database"]))
+ {
+ if ($_POST["db_type"] == 'mysql' || $_POST["db_type"] == 'mysqli')
+ {
+ $databasefortest='mysql';
+ }
+ elseif ($_POST["db_type"] == 'pgsql')
+ {
+ $databasefortest='postgres';
+ }
+ else
+ {
+ $databasefortest='mssql';
+ }
+ }
+ //print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
$db=getDoliDBInstance($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest,$_POST["db_port"]);
- dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
- //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
+ dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
+ //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
- if (empty($_POST["db_create_database"]) && $db->connected && ! $db->database_selected)
- {
- print ''.$langs->trans("ErrorConnectedButDatabaseNotFound",$_POST["db_name"]).'
';
- print ' ';
- if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
- }
- elseif ($db->error && ! (! empty($_POST["db_create_database"]) && $db->connected))
- {
- print ''.$db->error.'
';
- if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
- }
- }
- // If we need simple access
- if (! $error && (empty($_POST["db_create_database"]) && empty($_POST["db_create_user"])))
- {
+ if (empty($_POST["db_create_database"]) && $db->connected && ! $db->database_selected)
+ {
+ print ''.$langs->trans("ErrorConnectedButDatabaseNotFound",$_POST["db_name"]).'
';
+ print ' ';
+ if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
+ }
+ elseif ($db->error && ! (! empty($_POST["db_create_database"]) && $db->connected))
+ {
+ print ''.$db->error.'
';
+ if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
+ }
+ }
+ // If we need simple access
+ if (! $error && (empty($_POST["db_create_database"]) && empty($_POST["db_create_user"])))
+ {
$db=getDoliDBInstance($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"],$_POST["db_port"]);
if ($db->error)
- {
- print ''.$db->error.'
';
- if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
- }
- }
- }
- else
- {
- print " \nFailed to include_once(\"".$main_dir."/lib/databases/".$_POST["db_type"].".class.php\") \n";
- print ''.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'
';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
- }
+ {
+ print ''.$db->error.'
';
+ if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
+ }
+ }
+ }
+ else
+ {
+ print " \nFailed to include_once(\"".$main_dir."/lib/databases/".$_POST["db_type"].".class.php\") \n";
+ print ''.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'
';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
+ }
}
else
{
- if (isset($db)) print $db->lasterror();
- if (isset($db) && ! $db->connected) print ' '.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
+ if (isset($db)) print $db->lasterror();
+ if (isset($db) && ! $db->connected) print ' '.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
}
if (! $error && $db->connected)
{
- if (! empty($_POST["db_create_database"]))
- {
- $result=$db->select_db($_POST["db_name"]);
- if ($result)
- {
- print ''.$langs->trans("ErrorDatabaseAlreadyExists",$_POST["db_name"]).'
';
- print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters");
- $error++;
- }
- }
+ if (! empty($_POST["db_create_database"]))
+ {
+ $result=$db->select_db($_POST["db_name"]);
+ if ($result)
+ {
+ print ''.$langs->trans("ErrorDatabaseAlreadyExists",$_POST["db_name"]).'
';
+ print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters");
+ $error++;
+ }
+ }
}
// Define $defaultCharacterSet and $defaultCollationConnection
if (! $error && $db->connected)
{
- if (! empty($_POST["db_create_database"])) // If we create database, we force default value
- {
- $defaultCharacterSet=$db->forcecharset;
- $defaultCollationConnection=$db->forcecollate;
- }
- else // If already created, we take current value
- {
- $defaultCharacterSet=$db->getDefaultCharacterSetDatabase();
- $defaultCollationConnection=$db->getDefaultCollationDatabase();
- }
+ if (! empty($_POST["db_create_database"])) // If we create database, we force default value
+ {
+ $defaultCharacterSet=$db->forcecharset;
+ $defaultCollationConnection=$db->forcecollate;
+ }
+ else // If already created, we take current value
+ {
+ $defaultCharacterSet=$db->getDefaultCharacterSetDatabase();
+ $defaultCollationConnection=$db->getDefaultCollationDatabase();
+ }
- print ' ';
- print ' ';
- $_POST['dolibarr_main_db_character_set']=$defaultCharacterSet;
- $_POST['dolibarr_main_db_collation']=$defaultCollationConnection;
+ print ' ';
+ print ' ';
+ $_POST['dolibarr_main_db_character_set']=$defaultCharacterSet;
+ $_POST['dolibarr_main_db_collation']=$defaultCollationConnection;
}
// Create config file
if (! $error && $db->connected && $action == "set")
{
- umask(0);
- foreach($_POST as $cle=>$valeur)
- {
- if (! preg_match('/^db_pass/i',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
- }
+ umask(0);
+ foreach($_POST as $cle=>$valeur)
+ {
+ if (! preg_match('/^db_pass/i',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
+ }
- // Show title of step
- print ''.$langs->trans("ConfigurationFile").' ';
- print '';
+ // Show title of step
+ print ''.$langs->trans("ConfigurationFile").' ';
+ print '';
- // Check parameter main_dir
- if (! $error)
- {
- if (! is_dir($main_dir))
- {
- dolibarr_install_syslog("etape1: Repertoire '".$main_dir."' inexistant ou non accessible");
+ // Check parameter main_dir
+ if (! $error)
+ {
+ if (! is_dir($main_dir))
+ {
+ dolibarr_install_syslog("etape1: Repertoire '".$main_dir."' inexistant ou non accessible");
- print "";
- print $langs->trans("ErrorDirDoesNotExists",$main_dir).' ';
- print $langs->trans("ErrorWrongValueForParameter",$langs->trans("WebPagesDirectory")).' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
- print ' ';
- print $langs->trans("Error");
- print " ";
- $error++;
- }
- }
+ print "";
+ print $langs->trans("ErrorDirDoesNotExists",$main_dir).' ';
+ print $langs->trans("ErrorWrongValueForParameter",$langs->trans("WebPagesDirectory")).' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
+ print ' ';
+ print $langs->trans("Error");
+ print " ";
+ $error++;
+ }
+ }
- if (! $error)
- {
- dolibarr_install_syslog("etape1: Directory '".$main_dir."' exists");
- }
+ if (! $error)
+ {
+ dolibarr_install_syslog("etape1: Directory '".$main_dir."' exists");
+ }
- // Create subdirectory main_data_dir
- if (! $error)
- {
- // Create directory for documents
- if (! is_dir($main_data_dir))
- {
- dol_mkdir($main_data_dir);
- }
+ // Create subdirectory main_data_dir
+ if (! $error)
+ {
+ // Create directory for documents
+ if (! is_dir($main_data_dir))
+ {
+ dol_mkdir($main_data_dir);
+ }
- if (! is_dir($main_data_dir))
- {
- print "".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
- print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
- print ' ';
- print ''.$langs->trans("Error").' ';
- print " ";
- print ' '.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').' ';
- $error++;
- }
- else
- {
- // Create .htaccess file in document directory
- $pathhtaccess=$main_data_dir.'/.htaccess';
- if (! file_exists($pathhtaccess))
- {
- dolibarr_install_syslog("etape1: .htaccess file does not exists, we create it in '".$main_data_dir."'");
- $handlehtaccess=@fopen($pathhtaccess,'w');
- if ($handlehtaccess)
- {
- fwrite($handlehtaccess,'Order allow,deny'."\n");
- fwrite($handlehtaccess,'Deny from all'."\n");
+ if (! is_dir($main_data_dir))
+ {
+ print "".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
+ print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
+ print ' ';
+ print ''.$langs->trans("Error").' ';
+ print " ";
+ print ' '.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').' ';
+ $error++;
+ }
+ else
+ {
+ // Create .htaccess file in document directory
+ $pathhtaccess=$main_data_dir.'/.htaccess';
+ if (! file_exists($pathhtaccess))
+ {
+ dolibarr_install_syslog("etape1: .htaccess file does not exists, we create it in '".$main_data_dir."'");
+ $handlehtaccess=@fopen($pathhtaccess,'w');
+ if ($handlehtaccess)
+ {
+ fwrite($handlehtaccess,'Order allow,deny'."\n");
+ fwrite($handlehtaccess,'Deny from all'."\n");
- fclose($handlehtaccess);
- dolibarr_install_syslog("etape1: .htaccess file created");
- }
- }
+ fclose($handlehtaccess);
+ dolibarr_install_syslog("etape1: .htaccess file created");
+ }
+ }
- // Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification
- $dir[0] = $main_data_dir."/mycompany";
- $dir[1] = $main_data_dir."/users";
- $dir[2] = $main_data_dir."/custom";
- $dir[3] = $main_data_dir."/facture";
- $dir[4] = $main_data_dir."/propale";
- $dir[5] = $main_data_dir."/ficheinter";
- $dir[6] = $main_data_dir."/produit";
+ // Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification
+ $dir[0] = $main_data_dir."/mycompany";
+ $dir[1] = $main_data_dir."/users";
+ $dir[2] = $main_data_dir."/custom";
+ $dir[3] = $main_data_dir."/facture";
+ $dir[4] = $main_data_dir."/propale";
+ $dir[5] = $main_data_dir."/ficheinter";
+ $dir[6] = $main_data_dir."/produit";
- // Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas
- $num=count($dir);
- for ($i = 0; $i < $num; $i++)
- {
- if (is_dir($dir[$i]))
- {
- dolibarr_install_syslog("etape1: Directory '".$dir[$i]."' exists");
- }
- else
- {
- if (create_exdir($dir[$i]) < 0)
- {
- print "";
- print "Failed to create directory: ".$dir[$i];
- print ' ';
- print $langs->trans("Error");
- print " ";
- $error++;
- }
- else
- {
- dolibarr_install_syslog("etape1: Directory '".$dir[$i]."' created");
- }
- }
- }
- if ($error)
- {
- print "".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
- print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
- print ' ';
- print ''.$langs->trans("Error").' ';
- print " ";
- print ' '.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').' ';
- }
- }
- }
+ // Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas
+ $num=count($dir);
+ for ($i = 0; $i < $num; $i++)
+ {
+ if (is_dir($dir[$i]))
+ {
+ dolibarr_install_syslog("etape1: Directory '".$dir[$i]."' exists");
+ }
+ else
+ {
+ if (create_exdir($dir[$i]) < 0)
+ {
+ print "";
+ print "Failed to create directory: ".$dir[$i];
+ print ' ';
+ print $langs->trans("Error");
+ print " ";
+ $error++;
+ }
+ else
+ {
+ dolibarr_install_syslog("etape1: Directory '".$dir[$i]."' created");
+ }
+ }
+ }
+ if ($error)
+ {
+ print "".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
+ print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
+ print ' ';
+ print ''.$langs->trans("Error").' ';
+ print " ";
+ print ' '.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').' ';
+ }
+ }
+ }
- // Force https
- $main_force_https = ((GETPOST("main_force_https") && ( GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1) ) ? '1' : '0');
+ // Force https
+ $main_force_https = ((GETPOST("main_force_https") && ( GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1) ) ? '1' : '0');
- // Use alternative directory
- $main_use_alt_dir = ((GETPOST("main_use_alt_dir") && ( GETPOST("main_use_alt_dir") == "on" || GETPOST("main_use_alt_dir") == 1) ) ? '' : '#');
+ // Use alternative directory
+ $main_use_alt_dir = ((GETPOST("main_use_alt_dir") && ( GETPOST("main_use_alt_dir") == "on" || GETPOST("main_use_alt_dir") == 1) ) ? '' : '#');
- // Alternative root directory name
- $main_alt_dir_name = ((GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '') ? GETPOST("main_alt_dir_name") : 'custom');
+ // Alternative root directory name
+ $main_alt_dir_name = ((GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '') ? GETPOST("main_alt_dir_name") : 'custom');
- // Write conf file on disk
- if (! $error)
- {
- // Save old conf file on disk
- if (file_exists("$conffile"))
- {
- // We must ignore errors as an existing old file may already exists and not be replacable or
- // the installer (like for ubuntu) may not have permission to create another file than conf.php.
- // Also no other process must be able to read file or we expose the new file so content with password.
- @dol_copy($conffile, $conffile.'.old', '0400');
- }
+ // Write conf file on disk
+ if (! $error)
+ {
+ // Save old conf file on disk
+ if (file_exists("$conffile"))
+ {
+ // We must ignore errors as an existing old file may already exists and not be replacable or
+ // the installer (like for ubuntu) may not have permission to create another file than conf.php.
+ // Also no other process must be able to read file or we expose the new file so content with password.
+ @dol_copy($conffile, $conffile.'.old', '0400');
+ }
- $error+=write_conf_file($conffile);
- }
+ $error+=write_conf_file($conffile);
+ }
- // Write main.inc.php and master.inc.php into documents/custom dir
- $error+=write_main_file($main_data_dir.'/custom/main.inc.php',$main_dir);
- $error+=write_master_file($main_data_dir.'/custom/master.inc.php',$main_dir);
+ // Write main.inc.php and master.inc.php into documents/custom dir
+ $error+=write_main_file($main_data_dir.'/custom/main.inc.php',$main_dir);
+ $error+=write_master_file($main_data_dir.'/custom/master.inc.php',$main_dir);
- // Create database and admin user database
- if (! $error)
- {
- // We reload configuration file
- conf($dolibarr_main_document_root);
+ // Create database and admin user database
+ if (! $error)
+ {
+ // We reload configuration file
+ conf($dolibarr_main_document_root);
print '';
print $langs->trans("ConfFileReload");
@@ -406,246 +406,246 @@ if (! $error && $db->connected && $action == "set")
print ' '.$langs->trans("OK").' ';
- $userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
- $passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
+ $userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
+ $passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
- // Si creation utilisateur admin demandee, on le cree
- if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
- {
- dolibarr_install_syslog("etape1: Create database user: ".$dolibarr_main_db_user);
+ // Si creation utilisateur admin demandee, on le cree
+ if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
+ {
+ dolibarr_install_syslog("etape1: Create database user: ".$dolibarr_main_db_user);
- //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
- $databasefortest=$conf->db->name;
- if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
- {
- $databasefortest='mysql';
- }
- else if ($conf->db->type == 'pgsql')
- {
- $databasefortest='postgres';
- }
- else if ($conf->db->type == 'mssql')
- {
- $databasefortest='mssql';
- }
+ //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
+ $databasefortest=$conf->db->name;
+ if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
+ {
+ $databasefortest='mysql';
+ }
+ else if ($conf->db->type == 'pgsql')
+ {
+ $databasefortest='postgres';
+ }
+ else if ($conf->db->type == 'mssql')
+ {
+ $databasefortest='mssql';
+ }
- // Creation handler de base, verification du support et connexion
+ // Creation handler de base, verification du support et connexion
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,$databasefortest,$conf->db->port);
if ($db->error)
- {
- print ''.$db->error.'
';
- $error++;
- }
+ {
+ print ''.$db->error.'
';
+ $error++;
+ }
- if (! $error)
- {
- if ($db->connected)
- {
- $result=$db->DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name);
+ if (! $error)
+ {
+ if ($db->connected)
+ {
+ $result=$db->DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name);
- if ($result > 0)
- {
+ if ($result > 0)
+ {
- print '';
- print $langs->trans("UserCreation").' : ';
- print $dolibarr_main_db_user;
- print ' ';
- print ''.$langs->trans("OK").' ';
- }
- else
- {
- if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
- || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
- {
- dolibarr_install_syslog("etape1: User already exists");
- print '';
- print $langs->trans("UserCreation").' : ';
- print $dolibarr_main_db_user;
- print ' ';
- print ''.$langs->trans("LoginAlreadyExists").' ';
- }
- else
- {
- dolibarr_install_syslog("etape1: Failed to create user");
- print '';
- print $langs->trans("UserCreation").' : ';
- print $dolibarr_main_db_user;
- print ' ';
- print ''.$langs->trans("Error").' '.$db->error()." ";
- }
- }
+ print '';
+ print $langs->trans("UserCreation").' : ';
+ print $dolibarr_main_db_user;
+ print ' ';
+ print ''.$langs->trans("OK").' ';
+ }
+ else
+ {
+ if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
+ || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
+ {
+ dolibarr_install_syslog("etape1: User already exists");
+ print '';
+ print $langs->trans("UserCreation").' : ';
+ print $dolibarr_main_db_user;
+ print ' ';
+ print ''.$langs->trans("LoginAlreadyExists").' ';
+ }
+ else
+ {
+ dolibarr_install_syslog("etape1: Failed to create user");
+ print '';
+ print $langs->trans("UserCreation").' : ';
+ print $dolibarr_main_db_user;
+ print ' ';
+ print ''.$langs->trans("Error").' '.$db->error()." ";
+ }
+ }
- $db->close();
- }
- else
- {
- print '';
- print $langs->trans("UserCreation").' : ';
- print $dolibarr_main_db_user;
- print ' ';
- print ''.$langs->trans("Error").' ';
- print ' ';
+ $db->close();
+ }
+ else
+ {
+ print '';
+ print $langs->trans("UserCreation").' : ';
+ print $dolibarr_main_db_user;
+ print ' ';
+ print ''.$langs->trans("Error").' ';
+ print ' ';
- // Affiche aide diagnostique
- print ' ';
- print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
- print ' ';
- print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
- print ' ';
+ // Affiche aide diagnostique
+ print ' ';
+ print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
+ print ' ';
+ print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
+ print ' ';
- $error++;
- }
- }
- } // Fin si "creation utilisateur"
+ $error++;
+ }
+ }
+ } // Fin si "creation utilisateur"
- // If database creation is asked, we create it
- if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on"))
- {
- dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG);
+ // If database creation is asked, we create it
+ if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on"))
+ {
+ dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG);
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port);
- if ($db->connected)
- {
- $result=$db->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
+ if ($db->connected)
+ {
+ $result=$db->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
- if ($result)
- {
- print '';
- print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
- print $dolibarr_main_db_name;
- print ' ';
- print "".$langs->trans("OK")." ";
+ if ($result)
+ {
+ print '';
+ print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
+ print $dolibarr_main_db_name;
+ print ' ';
+ print "".$langs->trans("OK")." ";
- $check1=$db->getDefaultCharacterSetDatabase();
- $check2=$db->getDefaultCollationDatabase();
- dolibarr_install_syslog('etape1: Note that default server was charset='.$check1.' collation='.$check2, LOG_DEBUG);
+ $check1=$db->getDefaultCharacterSetDatabase();
+ $check2=$db->getDefaultCollationDatabase();
+ dolibarr_install_syslog('etape1: Note that default server was charset='.$check1.' collation='.$check2, LOG_DEBUG);
- // If values differs, we save conf file again
- //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('etape1: Value for character_set is not the one asked for database creation', LOG_WARNING);
- //if ($check2 != $dolibarr_main_db_collation) dolibarr_install_syslog('etape1: Value for collation is not the one asked for database creation', LOG_WARNING);
- }
- else
- {
- // Affiche aide diagnostique
- print ' ';
- print $langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name).' ';
- print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate");
- print ' ';
- print ' ';
+ // If values differs, we save conf file again
+ //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('etape1: Value for character_set is not the one asked for database creation', LOG_WARNING);
+ //if ($check2 != $dolibarr_main_db_collation) dolibarr_install_syslog('etape1: Value for collation is not the one asked for database creation', LOG_WARNING);
+ }
+ else
+ {
+ // Affiche aide diagnostique
+ print ' ';
+ print $langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name).' ';
+ print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate");
+ print ' ';
+ print ' ';
- dolibarr_install_syslog('etape1: Failed to create database '.$dolibarr_main_db_name.' '.$db->lasterrno().' '.$db->lasterror(), LOG_ERR);
- $error++;
- }
- $db->close();
- }
- else {
- print '';
- print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
- print $dolibarr_main_db_name;
- print ' ';
- print ''.$langs->trans("Error").' ';
- print ' ';
+ dolibarr_install_syslog('etape1: Failed to create database '.$dolibarr_main_db_name.' '.$db->lasterrno().' '.$db->lasterror(), LOG_ERR);
+ $error++;
+ }
+ $db->close();
+ }
+ else {
+ print '';
+ print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
+ print $dolibarr_main_db_name;
+ print ' ';
+ print ''.$langs->trans("Error").' ';
+ print ' ';
- // Affiche aide diagnostique
- print ' ';
- print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
- print ' ';
- print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
- print ' ';
+ // Affiche aide diagnostique
+ print ' ';
+ print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
+ print ' ';
+ print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
+ print ' ';
- $error++;
- }
- } // Fin si "creation database"
+ $error++;
+ }
+ } // Fin si "creation database"
- // We testOn test maintenant l'acces par le user base dolibarr
- if (! $error)
- {
- dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name, LOG_DEBUG);
- //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
+ // We testOn test maintenant l'acces par le user base dolibarr
+ if (! $error)
+ {
+ dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name, LOG_DEBUG);
+ //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
- if ($db->connected == 1)
- {
- // si acces serveur ok et acces base ok, tout est ok, on ne va pas plus loin, on a meme pas utilise le compte root.
- if ($db->database_selected == 1)
- {
- dolibarr_install_syslog("etape1: connexion to server by user ".$conf->db->user." is ok", LOG_DEBUG);
- print "";
- print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
- print $dolibarr_main_db_host;
- print " ";
- print $langs->trans("OK");
- print " ";
+ if ($db->connected == 1)
+ {
+ // si acces serveur ok et acces base ok, tout est ok, on ne va pas plus loin, on a meme pas utilise le compte root.
+ if ($db->database_selected == 1)
+ {
+ dolibarr_install_syslog("etape1: connexion to server by user ".$conf->db->user." is ok", LOG_DEBUG);
+ print "";
+ print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
+ print $dolibarr_main_db_host;
+ print " ";
+ print $langs->trans("OK");
+ print " ";
- dolibarr_install_syslog("etape1: connexion to database : ".$conf->db->name.", by user : ".$conf->db->user." is ok", LOG_DEBUG);
- print "";
- print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
- print $dolibarr_main_db_name;
- print " ";
- print $langs->trans("OK");
- print " ";
+ dolibarr_install_syslog("etape1: connexion to database : ".$conf->db->name.", by user : ".$conf->db->user." is ok", LOG_DEBUG);
+ print "";
+ print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
+ print $dolibarr_main_db_name;
+ print " ";
+ print $langs->trans("OK");
+ print " ";
- $error = 0;
- }
- else
- {
- dolibarr_install_syslog("etape1: connexion to server by user ".$conf->db->user." is ok", LOG_DEBUG);
- print "";
- print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
- print $dolibarr_main_db_host;
- print " ";
- print $langs->trans("OK");
- print " ";
+ $error = 0;
+ }
+ else
+ {
+ dolibarr_install_syslog("etape1: connexion to server by user ".$conf->db->user." is ok", LOG_DEBUG);
+ print "";
+ print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
+ print $dolibarr_main_db_host;
+ print " ";
+ print $langs->trans("OK");
+ print " ";
- dolibarr_install_syslog("etape1: connexion to database ".$conf->db->name.", by user : ".$conf->db->user." has failed", LOG_ERR);
- print "";
- print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
- print $dolibarr_main_db_name;
- print ' ';
- print $langs->trans("Error");
- print " ";
+ dolibarr_install_syslog("etape1: connexion to database ".$conf->db->name.", by user : ".$conf->db->user." has failed", LOG_ERR);
+ print "";
+ print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
+ print $dolibarr_main_db_name;
+ print ' ';
+ print $langs->trans("Error");
+ print " ";
- // Affiche aide diagnostique
- print ' ';
- print $langs->trans('CheckThatDatabasenameIsCorrect',$dolibarr_main_db_name).' ';
- print $langs->trans('IfAlreadyExistsCheckOption').' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
- print ' ';
+ // Affiche aide diagnostique
+ print ' ';
+ print $langs->trans('CheckThatDatabasenameIsCorrect',$dolibarr_main_db_name).' ';
+ print $langs->trans('IfAlreadyExistsCheckOption').' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
+ print ' ';
- $error++;
- }
- }
- else
- {
- dolibarr_install_syslog("etape1: la connexion au serveur par le user ".$conf->db->user." est rate");
- print "";
- print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
- print $dolibarr_main_db_host;
- print ' ';
- print ''.$db->error.'';
- print " ";
+ $error++;
+ }
+ }
+ else
+ {
+ dolibarr_install_syslog("etape1: la connexion au serveur par le user ".$conf->db->user." est rate");
+ print "";
+ print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
+ print $dolibarr_main_db_host;
+ print ' ';
+ print ''.$db->error.'';
+ print " ";
- // Affiche aide diagnostique
- print ' ';
- print $langs->trans("ErrorConnection",$conf->db->host,$conf->db->name,$conf->db->user);
- print $langs->trans('IfLoginDoesNotExistsCheckCreateUser').' ';
- print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
- print ' ';
+ // Affiche aide diagnostique
+ print ' ';
+ print $langs->trans("ErrorConnection",$conf->db->host,$conf->db->name,$conf->db->user);
+ print $langs->trans('IfLoginDoesNotExistsCheckCreateUser').' ';
+ print $langs->trans("ErrorGoBackAndCorrectParameters").' ';
+ print ' ';
- $error++;
- }
- }
- }
+ $error++;
+ }
+ }
+ }
- print '
';
+ print '
';
}
?>
@@ -674,57 +674,60 @@ pFooter($error,$setuplang,'jsinfo');
/**
* Create main file. No particular permissions are set by installer.
*
- * @param string $mainfile Full path name of main file to generate/update
- * @param string $main_dir Full path name to main.inc.php file
+ * @param string $mainfile Full path name of main file to generate/update
+ * @param string $main_dir Full path name to main.inc.php file
+ * @return void
*/
function write_main_file($mainfile,$main_dir)
{
- $fp = fopen("$mainfile", "w");
- if($fp)
- {
- clearstatcache();
+ $fp = fopen("$mainfile", "w");
+ if($fp)
+ {
+ clearstatcache();
fputs($fp, '');
- fclose($fp);
- }
+ fputs($fp, '?>');
+ fclose($fp);
+ }
}
/**
* Create master file. No particular permissions are set by installer.
*
- * @param string $masterfile Full path name of master file to generate/update
- * @param string $main_dir Full path name to master.inc.php file
+ * @param string $masterfile Full path name of master file to generate/update
+ * @param string $main_dir Full path name to master.inc.php file
+ * @return void
*/
function write_master_file($masterfile,$main_dir)
{
- $fp = fopen("$masterfile", "w");
- if($fp)
- {
- clearstatcache();
+ $fp = fopen("$masterfile", "w");
+ if($fp)
+ {
+ clearstatcache();
fputs($fp, '');
- fclose($fp);
- }
+ fputs($fp, '?>');
+ fclose($fp);
+ }
}
/**
* Save configuration file. No particular permissions are set by installer.
*
- * @param conffile Path to conf file to generate/update
+ * @param string $conffile Path to conf file to generate/update
+ * @return void
*/
function write_conf_file($conffile)
{
- global $conf,$langs;
- global $_POST,$main_dir,$main_data_dir,$main_force_https,$main_use_alt_dir,$main_alt_dir_name;
- global $dolibarr_main_url_root,$dolibarr_main_document_root,$dolibarr_main_data_root,$dolibarr_main_db_host;
- global $dolibarr_main_db_port,$dolibarr_main_db_name,$dolibarr_main_db_user,$dolibarr_main_db_pass;
- global $dolibarr_main_db_type,$dolibarr_main_db_character_set,$dolibarr_main_db_collation,$dolibarr_main_authentication;
+ global $conf,$langs;
+ global $_POST,$main_dir,$main_data_dir,$main_force_https,$main_use_alt_dir,$main_alt_dir_name;
+ global $dolibarr_main_url_root,$dolibarr_main_document_root,$dolibarr_main_data_root,$dolibarr_main_db_host;
+ global $dolibarr_main_db_port,$dolibarr_main_db_name,$dolibarr_main_db_user,$dolibarr_main_db_pass;
+ global $dolibarr_main_db_type,$dolibarr_main_db_character_set,$dolibarr_main_db_collation,$dolibarr_main_authentication;
global $conffile,$conffiletoshow,$conffiletoshowshort;
global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH;
global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
@@ -732,35 +735,35 @@ function write_conf_file($conffile)
global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
- $error=0;
+ $error=0;
- $key = md5(uniqid(mt_rand(),TRUE)); // Genere un hash d'un nombre aleatoire
+ $key = md5(uniqid(mt_rand(),TRUE)); // Genere un hash d'un nombre aleatoire
- $fp = fopen("$conffile", "w");
- if($fp)
- {
- clearstatcache();
+ $fp = fopen("$conffile", "w");
+ if($fp)
+ {
+ clearstatcache();
- fputs($fp, ''.$langs->trans("Database").'';
+ print ''.$langs->trans("Database").' ';
- print '';
- $error=0;
+ print '';
+ $error=0;
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1)
- {
- print "";
- print $langs->trans("ServerConnection")." : ".$conf->db->host." ".$langs->trans("OK")." ";
- $ok = 1 ;
- }
- else
- {
- print "Failed to connect to server : ".$conf->db->host." ".$langs->trans("Error")." ";
- }
+ {
+ print "";
+ print $langs->trans("ServerConnection")." : ".$conf->db->host." ".$langs->trans("OK")." ";
+ $ok = 1 ;
+ }
+ else
+ {
+ print "Failed to connect to server : ".$conf->db->host." ".$langs->trans("Error")." ";
+ }
- if ($ok)
- {
- if($db->database_selected == 1)
- {
- dolibarr_install_syslog("etape2: Connexion successful to database : ".$conf->db->name);
- }
- else
- {
+ if ($ok)
+ {
+ if($db->database_selected == 1)
+ {
+ dolibarr_install_syslog("etape2: Connexion successful to database : ".$conf->db->name);
+ }
+ else
+ {
dolibarr_install_syslog("etape2: Connexion failed to database : ".$conf->db->name);
- print "Failed to select database ".$conf->db->name." ".$langs->trans("Error")." ";
- $ok = 0 ;
- }
- }
+ print "Failed to select database ".$conf->db->name." ".$langs->trans("Error")." ";
+ $ok = 0 ;
+ }
+ }
- // Affiche version
- if ($ok)
- {
- $version=$db->getVersion();
- $versionarray=$db->getVersionArray();
- print ''.$langs->trans("DatabaseVersion").' ';
- print ''.$version.' ';
- //print ''.join('.',$versionarray).' ';
+ // Affiche version
+ if ($ok)
+ {
+ $version=$db->getVersion();
+ $versionarray=$db->getVersionArray();
+ print ''.$langs->trans("DatabaseVersion").' ';
+ print ''.$version.' ';
+ //print ''.join('.',$versionarray).' ';
print ''.$langs->trans("DatabaseName").' ';
print ''.$db->database_name.' ';
//print ''.join('.',$versionarray).' ';
- }
+ }
- $requestnb=0;
+ $requestnb=0;
- // To disable some code
- $createtables=1;
- $createkeys=1;
- $createfunctions=1;
- $createdata=1;
+ // To disable some code
+ $createtables=1;
+ $createkeys=1;
+ $createfunctions=1;
+ $createdata=1;
- // To say sql requests are escaped for mysql so we need to unescape them
- $db->unescapeslashquot=1;
+ // To say sql requests are escaped for mysql so we need to unescape them
+ $db->unescapeslashquot=1;
- /**************************************************************************************
- *
- * Chargement fichiers tables/*.sql (non *.key.sql)
- * A faire avant les fichiers *.key.sql
- *
- ***************************************************************************************/
- if ($ok && $createtables)
- {
- // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
- $dir = "mysql/tables/";
+ /**************************************************************************************
+ *
+ * Chargement fichiers tables/*.sql (non *.key.sql)
+ * A faire avant les fichiers *.key.sql
+ *
+ ***************************************************************************************/
+ if ($ok && $createtables)
+ {
+ // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
+ $dir = "mysql/tables/";
- $ok = 0;
- $handle=opendir($dir);
- dolibarr_install_syslog("Open tables directory ".$dir." handle=".$handle,LOG_DEBUG);
- $tablefound = 0;
- $tabledata=array();
+ $ok = 0;
+ $handle=opendir($dir);
+ dolibarr_install_syslog("Open tables directory ".$dir." handle=".$handle,LOG_DEBUG);
+ $tablefound = 0;
+ $tabledata=array();
if (is_resource($handle))
{
- while (($file = readdir($handle))!==false)
- {
- if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file))
- {
- $tablefound++;
- $tabledata[]=$file;
- }
- }
- closedir($handle);
+ while (($file = readdir($handle))!==false)
+ {
+ if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file))
+ {
+ $tablefound++;
+ $tabledata[]=$file;
+ }
+ }
+ closedir($handle);
}
- // Sort list of sql files on alphabetical order (load order is important)
- sort($tabledata);
- foreach($tabledata as $file)
- {
- $name = substr($file, 0, dol_strlen($file) - 4);
- $buffer = '';
- $fp = fopen($dir.$file,"r");
- if ($fp)
- {
- while (!feof($fp))
- {
- $buf = fgets($fp, 4096);
- if (substr($buf, 0, 2) <> '--')
- {
- $buf=preg_replace('/--(.+)*/','',$buf);
- $buffer .= $buf;
- }
- }
- fclose($fp);
+ // Sort list of sql files on alphabetical order (load order is important)
+ sort($tabledata);
+ foreach($tabledata as $file)
+ {
+ $name = substr($file, 0, dol_strlen($file) - 4);
+ $buffer = '';
+ $fp = fopen($dir.$file,"r");
+ if ($fp)
+ {
+ while (!feof($fp))
+ {
+ $buf = fgets($fp, 4096);
+ if (substr($buf, 0, 2) <> '--')
+ {
+ $buf=preg_replace('/--(.+)*/','',$buf);
+ $buffer .= $buf;
+ }
+ }
+ fclose($fp);
- $buffer=trim($buffer);
- if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb
- {
- $buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer);
- }
+ $buffer=trim($buffer);
+ if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb
+ {
+ $buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer);
+ }
- //print "Creation de la table $name/td>";
- $requestnb++;
- if ($conf->file->character_set_client == "UTF-8")
- {
- $buffer=utf8_encode($buffer);
- }
+ //print " Creation de la table $name/td>";
+ $requestnb++;
+ if ($conf->file->character_set_client == "UTF-8")
+ {
+ $buffer=utf8_encode($buffer);
+ }
- dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
- $resql=$db->query($buffer,0,'dml');
- if ($resql)
- {
- // print " OK requete ==== $buffer ";
- $db->free($resql);
- }
- else
- {
- if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
- $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
- {
- //print "Deja existante ";
- }
- else
- {
- print "".$langs->trans("CreateTableAndPrimaryKey",$name);
- print " \n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
- print "\n ";
- print "".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()." ";
- $error++;
- }
- }
- }
- else
- {
- print "".$langs->trans("CreateTableAndPrimaryKey",$name);
- print " ";
- print "".$langs->trans("Error")." Failed to open file ".$dir.$file." ";
- $error++;
- dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
- }
- }
+ dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
+ $resql=$db->query($buffer,0,'dml');
+ if ($resql)
+ {
+ // print "OK requete ==== $buffer ";
+ $db->free($resql);
+ }
+ else
+ {
+ if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
+ $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
+ {
+ //print "Deja existante ";
+ }
+ else
+ {
+ print "".$langs->trans("CreateTableAndPrimaryKey",$name);
+ print " \n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
+ print "\n ";
+ print "".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()." ";
+ $error++;
+ }
+ }
+ }
+ else
+ {
+ print "".$langs->trans("CreateTableAndPrimaryKey",$name);
+ print " ";
+ print "".$langs->trans("Error")." Failed to open file ".$dir.$file." ";
+ $error++;
+ dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
+ }
+ }
- if ($tablefound)
- {
- if ($error == 0)
- {
- print '';
- print $langs->trans("TablesAndPrimaryKeysCreation").' '.$langs->trans("OK").' ';
- $ok = 1;
- }
- }
- else
- {
- print "".$langs->trans("ErrorFailedToFindSomeFiles",$dir)." ".$langs->trans("Error")." ";
- dolibarr_install_syslog("Failed to find files to create database in directory ".$dir,LOG_ERR);
- }
- }
+ if ($tablefound)
+ {
+ if ($error == 0)
+ {
+ print '';
+ print $langs->trans("TablesAndPrimaryKeysCreation").' '.$langs->trans("OK").' ';
+ $ok = 1;
+ }
+ }
+ else
+ {
+ print "".$langs->trans("ErrorFailedToFindSomeFiles",$dir)." ".$langs->trans("Error")." ";
+ dolibarr_install_syslog("Failed to find files to create database in directory ".$dir,LOG_ERR);
+ }
+ }
- /***************************************************************************************
- *
- * Chargement fichiers tables/*.key.sql
- * A faire apres les fichiers *.sql
- *
- ***************************************************************************************/
- if ($ok && $createkeys)
- {
- // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
- $dir = "mysql/tables/";
+ /***************************************************************************************
+ *
+ * Chargement fichiers tables/*.key.sql
+ * A faire apres les fichiers *.sql
+ *
+ ***************************************************************************************/
+ if ($ok && $createkeys)
+ {
+ // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
+ $dir = "mysql/tables/";
- $okkeys = 0;
- $handle=opendir($dir);
- dolibarr_install_syslog("Open keys directory ".$dir." handle=".$handle,LOG_DEBUG);
- $tablefound = 0;
- $tabledata=array();
+ $okkeys = 0;
+ $handle=opendir($dir);
+ dolibarr_install_syslog("Open keys directory ".$dir." handle=".$handle,LOG_DEBUG);
+ $tablefound = 0;
+ $tabledata=array();
if (is_resource($handle))
{
- while (($file = readdir($handle))!==false)
- {
- if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file))
- {
- $tablefound++;
- $tabledata[]=$file;
- }
- }
- closedir($handle);
+ while (($file = readdir($handle))!==false)
+ {
+ if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file))
+ {
+ $tablefound++;
+ $tabledata[]=$file;
+ }
+ }
+ closedir($handle);
}
- // Sort list of sql files on alphabetical order (load order is important)
- sort($tabledata);
- foreach($tabledata as $file)
- {
- $name = substr($file, 0, dol_strlen($file) - 4);
- //print "Creation de la table $name ";
- $buffer = '';
- $fp = fopen($dir.$file,"r");
- if ($fp)
- {
- while (!feof($fp))
- {
- $buf = fgets($fp, 4096);
+ // Sort list of sql files on alphabetical order (load order is important)
+ sort($tabledata);
+ foreach($tabledata as $file)
+ {
+ $name = substr($file, 0, dol_strlen($file) - 4);
+ //print "Creation de la table $name ";
+ $buffer = '';
+ $fp = fopen($dir.$file,"r");
+ if ($fp)
+ {
+ while (!feof($fp))
+ {
+ $buf = fgets($fp, 4096);
- // Cas special de lignes autorisees pour certaines versions uniquement
- if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i',$buf,$reg))
- {
- $versioncommande=explode('.',$reg[1]);
- //print var_dump($versioncommande);
- //print var_dump($versionarray);
- if (count($versioncommande) && count($versionarray)
- && versioncompare($versioncommande,$versionarray) <= 0)
- {
- // Version qualified, delete SQL comments
- $buf=preg_replace('/^--\sV([0-9\.]+)/i','',$buf);
- //print "Ligne $i qualifiee par version: ".$buf.' ';
- }
- }
- if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i',$buf,$reg))
- {
- $versioncommande=explode('.',$reg[1]);
- //print var_dump($versioncommande);
- //print var_dump($versionarray);
- if (count($versioncommande) && count($versionarray)
- && versioncompare($versioncommande,$versionarray) <= 0)
- {
- // Version qualified, delete SQL comments
- $buf=preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i','',$buf);
- //print "Ligne $i qualifiee par version: ".$buf.' ';
- }
- }
+ // Cas special de lignes autorisees pour certaines versions uniquement
+ if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i',$buf,$reg))
+ {
+ $versioncommande=explode('.',$reg[1]);
+ //print var_dump($versioncommande);
+ //print var_dump($versionarray);
+ if (count($versioncommande) && count($versionarray)
+ && versioncompare($versioncommande,$versionarray) <= 0)
+ {
+ // Version qualified, delete SQL comments
+ $buf=preg_replace('/^--\sV([0-9\.]+)/i','',$buf);
+ //print "Ligne $i qualifiee par version: ".$buf.' ';
+ }
+ }
+ if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i',$buf,$reg))
+ {
+ $versioncommande=explode('.',$reg[1]);
+ //print var_dump($versioncommande);
+ //print var_dump($versionarray);
+ if (count($versioncommande) && count($versionarray)
+ && versioncompare($versioncommande,$versionarray) <= 0)
+ {
+ // Version qualified, delete SQL comments
+ $buf=preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i','',$buf);
+ //print "Ligne $i qualifiee par version: ".$buf.' ';
+ }
+ }
- // Ajout ligne si non commentaire
- if (! preg_match('/^--/i',$buf)) $buffer .= $buf;
- }
- fclose($fp);
+ // Ajout ligne si non commentaire
+ if (! preg_match('/^--/i',$buf)) $buffer .= $buf;
+ }
+ fclose($fp);
- // Si plusieurs requetes, on boucle sur chaque
- $listesql=explode(';',$buffer);
- foreach ($listesql as $req)
- {
- $buffer=trim($req);
- if ($buffer)
- {
- //print "Creation des cles et index de la table $name: '$buffer' ";
- $requestnb++;
- if ($conf->file->character_set_client == "UTF-8")
- {
- $buffer=utf8_encode($buffer);
- }
+ // Si plusieurs requetes, on boucle sur chaque
+ $listesql=explode(';',$buffer);
+ foreach ($listesql as $req)
+ {
+ $buffer=trim($req);
+ if ($buffer)
+ {
+ //print "Creation des cles et index de la table $name: '$buffer' ";
+ $requestnb++;
+ if ($conf->file->character_set_client == "UTF-8")
+ {
+ $buffer=utf8_encode($buffer);
+ }
- dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
- $resql=$db->query($buffer,0,'dml');
- if ($resql)
- {
- //print "OK requete ==== $buffer ";
- $db->free($resql);
- }
- else
- {
- if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
- $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
- $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
- $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
- preg_match('/duplicate key name/i',$db->error()))
- {
- //print "Deja existante ";
- $key_exists = 1;
- }
- else
- {
- print "".$langs->trans("CreateOtherKeysForTable",$name);
- print " \n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
- print "\n ";
- print "".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()." ";
- $error++;
- }
- }
- }
- }
- }
- else
- {
- print "".$langs->trans("CreateOtherKeysForTable",$name);
- print " ";
- print "".$langs->trans("Error")." Failed to open file ".$dir.$file." ";
- $error++;
- dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
- }
- }
+ dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
+ $resql=$db->query($buffer,0,'dml');
+ if ($resql)
+ {
+ //print "OK requete ==== $buffer ";
+ $db->free($resql);
+ }
+ else
+ {
+ if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
+ $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
+ $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
+ $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
+ preg_match('/duplicate key name/i',$db->error()))
+ {
+ //print "Deja existante ";
+ $key_exists = 1;
+ }
+ else
+ {
+ print "".$langs->trans("CreateOtherKeysForTable",$name);
+ print " \n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
+ print "\n ";
+ print "".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()." ";
+ $error++;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ print "".$langs->trans("CreateOtherKeysForTable",$name);
+ print " ";
+ print "".$langs->trans("Error")." Failed to open file ".$dir.$file." ";
+ $error++;
+ dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
+ }
+ }
- if ($tablefound && $error == 0)
- {
- print '';
- print $langs->trans("OtherKeysCreation").' '.$langs->trans("OK").' ';
- $okkeys = 1;
- }
- }
+ if ($tablefound && $error == 0)
+ {
+ print '';
+ print $langs->trans("OtherKeysCreation").' '.$langs->trans("OK").' ';
+ $okkeys = 1;
+ }
+ }
- /***************************************************************************************
- *
- * Chargement fichier functions.sql
- *
- ***************************************************************************************/
- if ($ok && $createfunctions)
- {
- // For this file, we use directory according to database type
- if ($choix==1) $dir = "mysql/functions/";
- elseif ($choix==2) $dir = "pgsql/functions/";
- elseif ($choix==3) $dir = "mssql/functions/";
+ /***************************************************************************************
+ *
+ * Chargement fichier functions.sql
+ *
+ ***************************************************************************************/
+ if ($ok && $createfunctions)
+ {
+ // For this file, we use directory according to database type
+ if ($choix==1) $dir = "mysql/functions/";
+ elseif ($choix==2) $dir = "pgsql/functions/";
+ elseif ($choix==3) $dir = "mssql/functions/";
- // Creation donnees
- $file = "functions.sql";
- if (file_exists($dir.$file))
- {
- $fp = fopen($dir.$file,"r");
- dolibarr_install_syslog("Open function file ".$dir.$file." handle=".$fp,LOG_DEBUG);
- if ($fp)
- {
- $buffer='';
- while (!feof($fp))
- {
- $buf = fgets($fp, 4096);
- if (substr($buf, 0, 2) <> '--')
- {
- $buffer .= $buf."§";
- }
- }
- fclose($fp);
- }
- //$buffer=preg_replace('/;\';/',";'§",$buffer);
+ // Creation donnees
+ $file = "functions.sql";
+ if (file_exists($dir.$file))
+ {
+ $fp = fopen($dir.$file,"r");
+ dolibarr_install_syslog("Open function file ".$dir.$file." handle=".$fp,LOG_DEBUG);
+ if ($fp)
+ {
+ $buffer='';
+ while (!feof($fp))
+ {
+ $buf = fgets($fp, 4096);
+ if (substr($buf, 0, 2) <> '--')
+ {
+ $buffer .= $buf."§";
+ }
+ }
+ fclose($fp);
+ }
+ //$buffer=preg_replace('/;\';/',";'§",$buffer);
- // If several requests, we loop on each of them
- $listesql=explode('§',$buffer);
- foreach ($listesql as $buffer)
- {
- $buffer=trim($buffer);
- if ($buffer)
- {
- dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
- print "\n";
- $resql=$db->query($buffer,0,'dml');
- if ($resql)
- {
- $ok = 1;
- $db->free($resql);
- }
- else
- {
- if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
- || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
- {
- //print "Insert line : ".$buffer." \n";
- }
- else
- {
- $ok = 0;
+ // If several requests, we loop on each of them
+ $listesql=explode('§',$buffer);
+ foreach ($listesql as $buffer)
+ {
+ $buffer=trim($buffer);
+ if ($buffer)
+ {
+ dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
+ print "\n";
+ $resql=$db->query($buffer,0,'dml');
+ if ($resql)
+ {
+ $ok = 1;
+ $db->free($resql);
+ }
+ else
+ {
+ if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
+ || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
+ {
+ //print "Insert line : ".$buffer." \n";
+ }
+ else
+ {
+ $ok = 0;
print "".$langs->trans("FunctionsCreation");
print " \n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
print "\n ";
print "".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()." ";
$error++;
- }
- }
- }
- }
+ }
+ }
+ }
+ }
- print "".$langs->trans("FunctionsCreation")." ";
- if ($ok)
- {
- print "".$langs->trans("OK")." ";
- }
- else
- {
- print "".$langs->trans("Error")." ";
- $ok = 1 ;
- }
+ print "".$langs->trans("FunctionsCreation")." ";
+ if ($ok)
+ {
+ print "".$langs->trans("OK")." ";
+ }
+ else
+ {
+ print "".$langs->trans("Error")." ";
+ $ok = 1 ;
+ }
- }
- }
+ }
+ }
- /***************************************************************************************
- *
- * Load files data/*.sql
- *
- ***************************************************************************************/
- if ($ok && $createdata)
- {
- // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
- $dir = "mysql/data/";
+ /***************************************************************************************
+ *
+ * Load files data/*.sql
+ *
+ ***************************************************************************************/
+ if ($ok && $createdata)
+ {
+ // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
+ $dir = "mysql/data/";
- // Insert data
- $handle=opendir($dir);
- dolibarr_install_syslog("Open directory data ".$dir." handle=".$handle,LOG_DEBUG);
- $tablefound = 0;
- $tabledata=array();
+ // Insert data
+ $handle=opendir($dir);
+ dolibarr_install_syslog("Open directory data ".$dir." handle=".$handle,LOG_DEBUG);
+ $tablefound = 0;
+ $tabledata=array();
if (is_resource($handle))
{
- while (($file = readdir($handle))!==false)
- {
- if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file))
- {
- $tablefound++;
- $tabledata[]=$file;
- }
- }
+ while (($file = readdir($handle))!==false)
+ {
+ if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file))
+ {
+ $tablefound++;
+ $tabledata[]=$file;
+ }
+ }
closedir($handle);
}
- // Sort list of data files on alphabetical order (load order is important)
- sort($tabledata);
- foreach($tabledata as $file)
- {
- $name = substr($file, 0, dol_strlen($file) - 4);
- $fp = fopen($dir.$file,"r");
- dolibarr_install_syslog("Open data file ".$dir.$file." handle=".$fp,LOG_DEBUG);
- if ($fp)
- {
- $arrayofrequests=array();
+ // Sort list of data files on alphabetical order (load order is important)
+ sort($tabledata);
+ foreach($tabledata as $file)
+ {
+ $name = substr($file, 0, dol_strlen($file) - 4);
+ $fp = fopen($dir.$file,"r");
+ dolibarr_install_syslog("Open data file ".$dir.$file." handle=".$fp,LOG_DEBUG);
+ if ($fp)
+ {
+ $arrayofrequests=array();
$linefound=0;
$linegroup=0;
$sizeofgroup=1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1.
- // Load all requests
- while (!feof($fp))
- {
- $buffer = fgets($fp, 4096);
- $buffer = trim($buffer);
- if ($buffer)
- {
- if (substr($buffer, 0, 2) == '--') continue;
+ // Load all requests
+ while (!feof($fp))
+ {
+ $buffer = fgets($fp, 4096);
+ $buffer = trim($buffer);
+ if ($buffer)
+ {
+ if (substr($buffer, 0, 2) == '--') continue;
- if ($linefound && ($linefound % $sizeofgroup) == 0)
- {
+ if ($linefound && ($linefound % $sizeofgroup) == 0)
+ {
$linegroup++;
- }
+ }
if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup]=$buffer;
else $arrayofrequests[$linegroup].=" ".$buffer;
- $linefound++;
- }
+ $linefound++;
+ }
}
fclose($fp);
@@ -538,43 +538,43 @@ if ($action == "set")
// We loop on each requests
foreach($arrayofrequests as $buffer)
{
- //dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
- $resql=$db->query($buffer);
- if ($resql)
- {
- $ok = 1;
- //$db->free($resql); // Not required as request we launch here does not return memory needs.
- }
- else
- {
- if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
- {
- //print "Insertion ligne : $buffer ";
- }
- else
- {
- $ok = 0;
- print $langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()." ";
- }
- }
- }
- }
- }
+ //dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
+ $resql=$db->query($buffer);
+ if ($resql)
+ {
+ $ok = 1;
+ //$db->free($resql); // Not required as request we launch here does not return memory needs.
+ }
+ else
+ {
+ if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ {
+ //print " Insertion ligne : $buffer ";
+ }
+ else
+ {
+ $ok = 0;
+ print $langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()." ";
+ }
+ }
+ }
+ }
+ }
- print " ".$langs->trans("ReferenceDataLoading")." ";
- if ($ok)
- {
- print "".$langs->trans("OK")." ";
- }
- else
- {
- print "".$langs->trans("Error")." ";
- $ok = 1 ;
- }
- }
- print '
';
+ print "".$langs->trans("ReferenceDataLoading")." ";
+ if ($ok)
+ {
+ print "".$langs->trans("OK")." ";
+ }
+ else
+ {
+ print "".$langs->trans("Error")." ";
+ $ok = 1 ;
+ }
+ }
+ print '
';
- $db->close();
+ $db->close();
}
dolibarr_install_syslog("--- install/etape2.php end", LOG_INFO);
diff --git a/htdocs/install/etape4.php b/htdocs/install/etape4.php
index 76c9329f4c0..d022fcba77a 100644
--- a/htdocs/install/etape4.php
+++ b/htdocs/install/etape4.php
@@ -73,36 +73,36 @@ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db-
if ($db->ok == 1)
{
- print ' '.$langs->trans("DolibarrAdminLogin").' : ';
- print ' ';
- print ''.$langs->trans("Password").' : ';
- print ' ';
- print ''.$langs->trans("PasswordAgain").' : ';
- print ' ';
- print '';
+ print ''.$langs->trans("DolibarrAdminLogin").' : ';
+ print ' ';
+ print ''.$langs->trans("Password").' : ';
+ print ' ';
+ print ''.$langs->trans("PasswordAgain").' : ';
+ print ' ';
+ print '';
- if (isset($_GET["error"]) && $_GET["error"] == 1)
- {
- print ' ';
- print ''.$langs->trans("PasswordsMismatch").'
';
- $err=0; // We show button
- }
+ if (isset($_GET["error"]) && $_GET["error"] == 1)
+ {
+ print ' ';
+ print ''.$langs->trans("PasswordsMismatch").'
';
+ $err=0; // We show button
+ }
- if (isset($_GET["error"]) && $_GET["error"] == 2)
- {
- print ' ';
- print '';
- print $langs->trans("PleaseTypePassword");
- print '
';
- $err=0; // We show button
- }
+ if (isset($_GET["error"]) && $_GET["error"] == 2)
+ {
+ print ' ';
+ print '';
+ print $langs->trans("PleaseTypePassword");
+ print '
';
+ $err=0; // We show button
+ }
- if (isset($_GET["error"]) && $_GET["error"] == 3)
- {
- print ' ';
- print ''.$langs->trans("PleaseTypeALogin").'
';
- $err=0; // We show button
- }
+ if (isset($_GET["error"]) && $_GET["error"] == 3)
+ {
+ print ' ';
+ print ''.$langs->trans("PleaseTypeALogin").'
';
+ $err=0; // We show button
+ }
}
diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php
index 9bb613b1159..638e0674453 100644
--- a/htdocs/install/etape5.php
+++ b/htdocs/install/etape5.php
@@ -38,8 +38,8 @@ $langs->setDefaultLang($setuplang);
$targetversion=DOL_VERSION; // It it's last upgrade
if (isset($_POST["action"]) && preg_match('/upgrade/i',$_POST["action"])) // If it's an old upgrade
{
- $tmp=explode('_',$_POST["action"],2);
- if ($tmp[0]=='upgrade' && ! empty($tmp[1])) $targetversion=$tmp[1];
+ $tmp=explode('_',$_POST["action"],2);
+ if ($tmp[0]=='upgrade' && ! empty($tmp[1])) $targetversion=$tmp[1];
}
$langs->load("admin");
@@ -74,23 +74,23 @@ dolibarr_install_syslog("--- etape5: Entering etape5.php page", LOG_INFO);
// If install, check pass and pass_verif used to create admin account
if ($action == "set")
{
- if ($_POST["pass"] <> $_POST["pass_verif"])
- {
- Header("Location: etape4.php?error=1&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
- exit;
- }
+ if ($_POST["pass"] <> $_POST["pass_verif"])
+ {
+ Header("Location: etape4.php?error=1&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
+ exit;
+ }
- if (dol_strlen(trim($_POST["pass"])) == 0)
- {
- Header("Location: etape4.php?error=2&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
- exit;
- }
+ if (dol_strlen(trim($_POST["pass"])) == 0)
+ {
+ Header("Location: etape4.php?error=2&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
+ exit;
+ }
- if (dol_strlen(trim($_POST["login"])) == 0)
- {
- Header("Location: etape4.php?error=3&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
- exit;
- }
+ if (dol_strlen(trim($_POST["login"])) == 0)
+ {
+ Header("Location: etape4.php?error=3&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
+ exit;
+ }
}
@@ -111,187 +111,187 @@ if (! GETPOST("versionfrom") && ! GETPOST("versionto") && ! is_writable($conffil
if ($action == "set" || preg_match('/upgrade/i',$action))
{
- print '';
- $error=0;
+ print '';
+ $error=0;
- // If password is encoded, we decode it
- if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
- {
- require_once($dolibarr_main_document_root."/lib/security.lib.php");
- if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
- {
- $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
- $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
- $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
- }
- else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
- }
+ // If password is encoded, we decode it
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
+ {
+ require_once($dolibarr_main_document_root."/lib/security.lib.php");
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
+ {
+ $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
+ $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
+ $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
+ }
+ else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ }
- $conf->db->type = $dolibarr_main_db_type;
- $conf->db->host = $dolibarr_main_db_host;
- $conf->db->port = $dolibarr_main_db_port;
- $conf->db->name = $dolibarr_main_db_name;
- $conf->db->user = $dolibarr_main_db_user;
- $conf->db->pass = $dolibarr_main_db_pass;
- $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption)?$dolibarr_main_db_encryption:'';
- $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey)?$dolibarr_main_db_cryptkey:'';
+ $conf->db->type = $dolibarr_main_db_type;
+ $conf->db->host = $dolibarr_main_db_host;
+ $conf->db->port = $dolibarr_main_db_port;
+ $conf->db->name = $dolibarr_main_db_name;
+ $conf->db->user = $dolibarr_main_db_user;
+ $conf->db->pass = $dolibarr_main_db_pass;
+ $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption)?$dolibarr_main_db_encryption:'';
+ $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey)?$dolibarr_main_db_cryptkey:'';
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
- $ok = 0;
+ $ok = 0;
- // If first install
- if ($action == "set")
- {
- // Active module user
- $modName='modUser';
- $file = $modName . ".class.php";
- dolibarr_install_syslog('install/etape5.php Load module user '.DOL_DOCUMENT_ROOT ."/includes/modules/".$file, LOG_INFO);
- include_once(DOL_DOCUMENT_ROOT ."/includes/modules/".$file);
- $objMod = new $modName($db);
- $result=$objMod->init();
+ // If first install
+ if ($action == "set")
+ {
+ // Active module user
+ $modName='modUser';
+ $file = $modName . ".class.php";
+ dolibarr_install_syslog('install/etape5.php Load module user '.DOL_DOCUMENT_ROOT ."/includes/modules/".$file, LOG_INFO);
+ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/".$file);
+ $objMod = new $modName($db);
+ $result=$objMod->init();
if (! $result) print 'ERROR in activating module file='.$file;
- if ($db->connected == 1)
- {
- $conf->setValues($db);
+ if ($db->connected == 1)
+ {
+ $conf->setValues($db);
- // Create user
- include_once(DOL_DOCUMENT_ROOT ."/user/class/user.class.php");
+ // Create user
+ include_once(DOL_DOCUMENT_ROOT ."/user/class/user.class.php");
- $createuser=new User($db);
- $createuser->id=0;
+ $createuser=new User($db);
+ $createuser->id=0;
- $newuser = new User($db);
- $newuser->nom='SuperAdmin';
- $newuser->prenom='';
- $newuser->login=$_POST["login"];
- $newuser->pass=$_POST["pass"];
- $newuser->admin=1;
- $newuser->entity=0;
+ $newuser = new User($db);
+ $newuser->nom='SuperAdmin';
+ $newuser->prenom='';
+ $newuser->login=$_POST["login"];
+ $newuser->pass=$_POST["pass"];
+ $newuser->admin=1;
+ $newuser->entity=0;
- $conf->global->USER_MAIL_REQUIRED=0; // Force global option to be sure to create a new user with no email
- $result=$newuser->create($createuser,1);
- if ($result > 0)
- {
- print $langs->trans("AdminLoginCreatedSuccessfuly",$_POST["login"])." ";
- $success = 1;
- }
- else
- {
- if ($newuser->error == 'ErrorLoginAlreadyExists')
- {
- dolibarr_install_syslog('install/etape5.php AdminLoginAlreadyExists', LOG_WARNING);
- print ''.$langs->trans("AdminLoginAlreadyExists",$_POST["login"])."
";
- $success = 1;
- }
- else
- {
- dolibarr_install_syslog('install/etape5.php FailedToCreateAdminLogin '.$newuser->error, LOG_ERR);
- print ''.$langs->trans("FailedToCreateAdminLogin").' '.$newuser->error.'
';
- }
- }
+ $conf->global->USER_MAIL_REQUIRED=0; // Force global option to be sure to create a new user with no email
+ $result=$newuser->create($createuser,1);
+ if ($result > 0)
+ {
+ print $langs->trans("AdminLoginCreatedSuccessfuly",$_POST["login"])." ";
+ $success = 1;
+ }
+ else
+ {
+ if ($newuser->error == 'ErrorLoginAlreadyExists')
+ {
+ dolibarr_install_syslog('install/etape5.php AdminLoginAlreadyExists', LOG_WARNING);
+ print ''.$langs->trans("AdminLoginAlreadyExists",$_POST["login"])."
";
+ $success = 1;
+ }
+ else
+ {
+ dolibarr_install_syslog('install/etape5.php FailedToCreateAdminLogin '.$newuser->error, LOG_ERR);
+ print ''.$langs->trans("FailedToCreateAdminLogin").' '.$newuser->error.'
';
+ }
+ }
- if ($success)
- {
- $db->begin();
+ if ($success)
+ {
+ $db->begin();
- dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
- $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'");
- if (! $resql) dol_print_error($db,'Error in setup program');
- $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when install',0)");
- if (! $resql) dol_print_error($db,'Error in setup program');
- $conf->global->MAIN_VERSION_LAST_INSTALL=$targetversion;
+ dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
+ $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'");
+ if (! $resql) dol_print_error($db,'Error in setup program');
+ $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when install',0)");
+ if (! $resql) dol_print_error($db,'Error in setup program');
+ $conf->global->MAIN_VERSION_LAST_INSTALL=$targetversion;
- if ($useforcedwizard)
- {
- dolibarr_install_syslog('install/etape5.php set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG);
- $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'");
- if (! $resql) dol_print_error($db,'Error in setup program');
- $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING',1).",".$db->encrypt(1,1).",'chaine',1,'Disable install warnings',0)");
- if (! $resql) dol_print_error($db,'Error in setup program');
- $conf->global->MAIN_REMOVE_INSTALL_WARNING=1;
- }
+ if ($useforcedwizard)
+ {
+ dolibarr_install_syslog('install/etape5.php set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG);
+ $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'");
+ if (! $resql) dol_print_error($db,'Error in setup program');
+ $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING',1).",".$db->encrypt(1,1).",'chaine',1,'Disable install warnings',0)");
+ if (! $resql) dol_print_error($db,'Error in setup program');
+ $conf->global->MAIN_REMOVE_INSTALL_WARNING=1;
+ }
- // If we ask to force some modules to be enabled
- if (! empty($force_install_module))
- {
- if (! defined('DOL_DOCUMENT_ROOT') && ! empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT',$dolibarr_main_document_root);
- if (! defined('DOL_DOCUMENT_ROOT_ALT') && ! empty($dolibarr_main_document_root_alt)) define('DOL_DOCUMENT_ROOT_ALT',$dolibarr_main_document_root_alt);
+ // If we ask to force some modules to be enabled
+ if (! empty($force_install_module))
+ {
+ if (! defined('DOL_DOCUMENT_ROOT') && ! empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT',$dolibarr_main_document_root);
+ if (! defined('DOL_DOCUMENT_ROOT_ALT') && ! empty($dolibarr_main_document_root_alt)) define('DOL_DOCUMENT_ROOT_ALT',$dolibarr_main_document_root_alt);
- $tmparray=explode(',',$force_install_module);
- foreach ($tmparray as $modtoactivate)
- {
- $modtoactivatenew=preg_replace('/\.class\.php$/i','',$modtoactivate);
+ $tmparray=explode(',',$force_install_module);
+ foreach ($tmparray as $modtoactivate)
+ {
+ $modtoactivatenew=preg_replace('/\.class\.php$/i','',$modtoactivate);
$file=$modtoactivatenew.'.class.php';
- dolibarr_install_syslog('install/etape5.php Activate module file='.$file);
+ dolibarr_install_syslog('install/etape5.php Activate module file='.$file);
$res=dol_include_once("/includes/modules/".$file);
$res=Activate($modtoactivatenew,1);
if (! $result) print 'ERROR in activating module file='.$file;
- }
- }
+ }
+ }
- dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_DEBUG);
- $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'");
- if (! $resql) dol_print_error($db,'Error in setup program');
+ dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_DEBUG);
+ $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'");
+ if (! $resql) dol_print_error($db,'Error in setup program');
- $db->commit();
- }
- }
- else
- {
- print $langs->trans("ErrorFailedToConnect")." ";
- }
- }
- // If upgrade
- elseif (preg_match('/upgrade/i',$action))
- {
- if ($db->connected == 1)
- {
- $conf->setValues($db);
+ $db->commit();
+ }
+ }
+ else
+ {
+ print $langs->trans("ErrorFailedToConnect")." ";
+ }
+ }
+ // If upgrade
+ elseif (preg_match('/upgrade/i',$action))
+ {
+ if ($db->connected == 1)
+ {
+ $conf->setValues($db);
- // Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database
- $tagdatabase=false;
- if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase=true; // We don't know what it was before, so now we consider we are version choosed.
- else
- {
- $mainversionlastupgradearray=preg_split('/[.-]/',$conf->global->MAIN_VERSION_LAST_UPGRADE);
- $targetversionarray=preg_split('/[.-]/',$targetversion);
- if (versioncompare($targetversionarray,$mainversionlastupgradearray) > 0) $tagdatabase=true;
- }
+ // Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database
+ $tagdatabase=false;
+ if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase=true; // We don't know what it was before, so now we consider we are version choosed.
+ else
+ {
+ $mainversionlastupgradearray=preg_split('/[.-]/',$conf->global->MAIN_VERSION_LAST_UPGRADE);
+ $targetversionarray=preg_split('/[.-]/',$targetversion);
+ if (versioncompare($targetversionarray,$mainversionlastupgradearray) > 0) $tagdatabase=true;
+ }
- if ($tagdatabase)
- {
- dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion, LOG_DEBUG);
- $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'");
- if (! $resql) dol_print_error($db,'Error in setup program');
- $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_UPGRADE',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version for last upgrade',0)");
- if (! $resql) dol_print_error($db,'Error in setup program');
- $conf->global->MAIN_VERSION_LAST_UPGRADE=$targetversion;
- }
- else
- {
- dolibarr_install_syslog('install/etape5.php We run an upgrade to version '.$targetversion.' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'. We keep MAIN_VERSION_LAST_UPGRADE as it is.', LOG_DEBUG);
- }
- }
- else
- {
- print $langs->trans("ErrorFailedToConnect")." ";
- }
- }
- else
- {
- dol_print_error('','install/etape5.php Unknown choice of action');
- }
+ if ($tagdatabase)
+ {
+ dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion, LOG_DEBUG);
+ $resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'");
+ if (! $resql) dol_print_error($db,'Error in setup program');
+ $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_UPGRADE',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version for last upgrade',0)");
+ if (! $resql) dol_print_error($db,'Error in setup program');
+ $conf->global->MAIN_VERSION_LAST_UPGRADE=$targetversion;
+ }
+ else
+ {
+ dolibarr_install_syslog('install/etape5.php We run an upgrade to version '.$targetversion.' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'. We keep MAIN_VERSION_LAST_UPGRADE as it is.', LOG_DEBUG);
+ }
+ }
+ else
+ {
+ print $langs->trans("ErrorFailedToConnect")." ";
+ }
+ }
+ else
+ {
+ dol_print_error('','install/etape5.php Unknown choice of action');
+ }
- // May fail if parameter already defined
- $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_LANG_DEFAULT',1).",".$db->encrypt($setuplang,1).",'chaine',0,'Default language',1)");
- //if (! $resql) dol_print_error($db,'Error in setup program');
+ // May fail if parameter already defined
+ $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_LANG_DEFAULT',1).",".$db->encrypt($setuplang,1).",'chaine',0,'Default language',1)");
+ //if (! $resql) dol_print_error($db,'Error in setup program');
- print '
';
+ print '
';
- $db->close();
+ $db->close();
}
print " ";
@@ -302,104 +302,104 @@ print " ";
// If first install
if ($action == "set")
{
- if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
- {
- // Install is finished
- print $langs->trans("SystemIsInstalled")." ";
+ if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
+ {
+ // Install is finished
+ print $langs->trans("SystemIsInstalled")." ";
- $createlock=0;
+ $createlock=0;
- if (! empty($force_install_lockinstall))
- {
- // Install is finished, we create the lock file
- $lockfile=DOL_DATA_ROOT.'/install.lock';
- $fp = @fopen($lockfile, "w");
- if ($fp)
- {
+ if (! empty($force_install_lockinstall))
+ {
+ // Install is finished, we create the lock file
+ $lockfile=DOL_DATA_ROOT.'/install.lock';
+ $fp = @fopen($lockfile, "w");
+ if ($fp)
+ {
if ($force_install_lockinstall == 1) $force_install_lockinstall=444; // For backward compatibility
fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
- fclose($fp);
- @chmod($lockfile, octdec($force_install_lockinstall));
- $createlock=1;
- }
- }
- if (empty($createlock))
- {
- print ''.$langs->trans("WarningRemoveInstallDir")."
";
- }
+ fclose($fp);
+ @chmod($lockfile, octdec($force_install_lockinstall));
+ $createlock=1;
+ }
+ }
+ if (empty($createlock))
+ {
+ print ''.$langs->trans("WarningRemoveInstallDir")."
";
+ }
- print " ";
+ print " ";
- print $langs->trans("YouNeedToPersonalizeSetup")." ";
+ print $langs->trans("YouNeedToPersonalizeSetup")." ";
- print '';
- print $langs->trans("GoToSetupArea");
- print ' ';
- }
- else
- {
- // If here MAIN_VERSION_LAST_UPGRADE is not empty
- print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.' ';
- print $langs->trans("VersionProgram").': '.DOL_VERSION.' ';
- print $langs->trans("MigrationNotFinished").' ';
- print " ";
+ print '';
+ print $langs->trans("GoToSetupArea");
+ print ' ';
+ }
+ else
+ {
+ // If here MAIN_VERSION_LAST_UPGRADE is not empty
+ print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.' ';
+ print $langs->trans("VersionProgram").': '.DOL_VERSION.' ';
+ print $langs->trans("MigrationNotFinished").' ';
+ print " ";
- print '';
- print $langs->trans("GoToUpgradePage");
- print ' ';
- }
+ print '';
+ print $langs->trans("GoToUpgradePage");
+ print ' ';
+ }
}
// If upgrade
elseif (preg_match('/upgrade/i',$action))
{
- if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
- {
- // Upgrade is finished
- print $langs->trans("SystemIsUpgraded")." ";
+ if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
+ {
+ // Upgrade is finished
+ print $langs->trans("SystemIsUpgraded")." ";
- $createlock=0;
+ $createlock=0;
- if (! empty($force_install_lockinstall))
- {
- // Upgrade is finished, we create the lock file
- $lockfile=DOL_DATA_ROOT.'/install.lock';
- $fp = @fopen($lockfile, "w");
- if ($fp)
- {
+ if (! empty($force_install_lockinstall))
+ {
+ // Upgrade is finished, we create the lock file
+ $lockfile=DOL_DATA_ROOT.'/install.lock';
+ $fp = @fopen($lockfile, "w");
+ if ($fp)
+ {
if ($force_install_lockinstall == 1) $force_install_lockinstall=444; // For backward compatibility
- fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
- fclose($fp);
+ fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
+ fclose($fp);
@chmod($lockfile, octdec($force_install_lockinstall));
- $createlock=1;
- }
- }
- if (empty($createlock))
- {
- print ''.$langs->trans("WarningRemoveInstallDir")."
";
- }
+ $createlock=1;
+ }
+ }
+ if (empty($createlock))
+ {
+ print ''.$langs->trans("WarningRemoveInstallDir")."
";
+ }
- print " ";
+ print " ";
- print '';
- print $langs->trans("GoToDolibarr");
- print ' ';
- }
- else
- {
- // If here MAIN_VERSION_LAST_UPGRADE is not empty
- print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.' ';
- print $langs->trans("VersionProgram").': '.DOL_VERSION.' ';
+ print '';
+ print $langs->trans("GoToDolibarr");
+ print ' ';
+ }
+ else
+ {
+ // If here MAIN_VERSION_LAST_UPGRADE is not empty
+ print $langs->trans("VersionLastUpgrade").': '.$conf->global->MAIN_VERSION_LAST_UPGRADE.' ';
+ print $langs->trans("VersionProgram").': '.DOL_VERSION.' ';
- print " ";
+ print " ";
- print '';
- print $langs->trans("GoToUpgradePage");
- print ' ';
- }
+ print '';
+ print $langs->trans("GoToUpgradePage");
+ print ' ';
+ }
}
else
{
- dol_print_error('','install/etape5.php Unknown choice of action');
+ dol_print_error('','install/etape5.php Unknown choice of action');
}
diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php
index 3a7f117fbe2..9c7141eb407 100644
--- a/htdocs/install/fileconf.php
+++ b/htdocs/install/fileconf.php
@@ -80,7 +80,8 @@ if (! empty($force_install_message))
}
?>
-
+
@@ -88,46 +89,44 @@ if (! empty($force_install_message))
-
+
- ';
- print $langs->trans("WebPagesDirectory");
- print " ";
+ ';
+ print $langs->trans("WebPagesDirectory");
+ print " ";
- if(! isset($dolibarr_main_url_root) || dol_strlen($dolibarr_main_url_root) == 0)
- {
- //print "x".$_SERVER["SCRIPT_FILENAME"]." y".$_SERVER["DOCUMENT_ROOT"];
+ if(! isset($dolibarr_main_url_root) || dol_strlen($dolibarr_main_url_root) == 0)
+ {
+ //print "x".$_SERVER["SCRIPT_FILENAME"]." y".$_SERVER["DOCUMENT_ROOT"];
- // Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
- // ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
- if (preg_match('/^php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i',$_SERVER["SCRIPT_FILENAME"]))
- {
- $dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
+ // Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
+ // ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
+ if (preg_match('/^php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i',$_SERVER["SCRIPT_FILENAME"]))
+ {
+ $dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
- if (! preg_match('/[\\/]dolibarr[\\/]htdocs$/i',$dolibarr_main_document_root))
- {
- $dolibarr_main_document_root.="/dolibarr/htdocs";
- }
- }
- else
- {
- $dolibarr_main_document_root = substr($_SERVER["SCRIPT_FILENAME"],0,dol_strlen($_SERVER["SCRIPT_FILENAME"]) - 21);
- // Nettoyage du path propose
- // Gere les chemins windows avec double "\"
- $dolibarr_main_document_root = str_replace('\\\\','/',$dolibarr_main_document_root);
+ if (! preg_match('/[\\/]dolibarr[\\/]htdocs$/i',$dolibarr_main_document_root))
+ {
+ $dolibarr_main_document_root.="/dolibarr/htdocs";
+ }
+ }
+ else
+ {
+ $dolibarr_main_document_root = substr($_SERVER["SCRIPT_FILENAME"],0,dol_strlen($_SERVER["SCRIPT_FILENAME"]) - 21);
+ // Nettoyage du path propose
+ // Gere les chemins windows avec double "\"
+ $dolibarr_main_document_root = str_replace('\\\\','/',$dolibarr_main_document_root);
- // Supprime les slash ou antislash de fins
- $dolibarr_main_document_root = preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
- }
- }
- ?>
-
-
+ ';
print ' ';
- ?>
-
+ ?>
-
+
trans("DocumentsDirectory"); ?>
@@ -158,12 +157,10 @@ if (! empty($force_install_message))
}
}
?>
-
- ';
print ' ';
- ?>
-
+ ?>
-
-
+
+
trans("URLRoot"); ?>
-
- ';
print ' ';
- ?>
-
+ ?>
-
+
trans("ForceHttps"); ?>
-
+
@@ -259,56 +254,56 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
$defaultype=! empty($dolibarr_main_db_type)?$dolibarr_main_db_type:($force_install_type?$force_install_type:'mysqli');
- $modules = array();
- $nbok = $nbko = 0;
- $option='';
+ $modules = array();
+ $nbok = $nbko = 0;
+ $option='';
- // Scan les drivers
+ // Scan les drivers
$dir=DOL_DOCUMENT_ROOT.'/lib/databases';
$handle=opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle))!==false)
- {
- if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php/i',$file,$reg))
- {
- $type=$reg[1];
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle))!==false)
+ {
+ if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php/i',$file,$reg))
+ {
+ $type=$reg[1];
- // Version min de la base
- $versionbasemin=array();
- if ($type=='mysql') { $versionbasemin=array(3,1,0); $testfunction='mysql_connect'; }
- if ($type=='mysqli') { $versionbasemin=array(4,1,0); $testfunction='mysqli_connect'; }
- if ($type=='pgsql') { $versionbasemin=array(8,4,0); $testfunction='pg_connect'; }
- if ($type=='mssql') { $versionbasemin=array(2000); $testfunction='mssql_connect'; }
+ // Version min de la base
+ $versionbasemin=array();
+ if ($type=='mysql') { $versionbasemin=array(3,1,0); $testfunction='mysql_connect'; }
+ if ($type=='mysqli') { $versionbasemin=array(4,1,0); $testfunction='mysqli_connect'; }
+ if ($type=='pgsql') { $versionbasemin=array(8,4,0); $testfunction='pg_connect'; }
+ if ($type=='mssql') { $versionbasemin=array(2000); $testfunction='mssql_connect'; }
- // Remarques
- $note='';
- if ($type=='mysql') $note='(Mysql >= '.versiontostring($versionbasemin).')';
- if ($type=='mysqli') $note='(Mysql >= '.versiontostring($versionbasemin).')';
- if ($type=='pgsql') $note='(Postgresql >= '.versiontostring($versionbasemin).')';
- if ($type=='mssql') $note='(SQL Server >= '.versiontostring($versionbasemin).')';
+ // Remarques
+ $note='';
+ if ($type=='mysql') $note='(Mysql >= '.versiontostring($versionbasemin).')';
+ if ($type=='mysqli') $note='(Mysql >= '.versiontostring($versionbasemin).')';
+ if ($type=='pgsql') $note='(Postgresql >= '.versiontostring($versionbasemin).')';
+ if ($type=='mssql') $note='(SQL Server >= '.versiontostring($versionbasemin).')';
- // Switch to mysql if mysqli is not present
- if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';
+ // Switch to mysql if mysqli is not present
+ if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';
- // Affiche ligne dans liste
- $option.='';
- $option.=$type.' ';
- if ($note) $option.=' '.$note;
- // Experimental
- if ($type=='pgsql') $option.=' '.$langs->trans("Experimental");
- elseif ($type=='mssql') $option.=' '.$langs->trans("Experimental");
- // No available
- elseif (! function_exists($testfunction)) $option.=' - '.$langs->trans("FunctionNotAvailableInThisPHP");
- $option.=' ';
- }
- }
- }
+ // Affiche ligne dans liste
+ $option.='';
+ $option.=$type.' ';
+ if ($note) $option.=' '.$note;
+ // Experimental
+ if ($type=='pgsql') $option.=' '.$langs->trans("Experimental");
+ elseif ($type=='mssql') $option.=' '.$langs->trans("Experimental");
+ // No available
+ elseif (! function_exists($testfunction)) $option.=' - '.$langs->trans("FunctionNotAvailableInThisPHP");
+ $option.=' ';
+ }
+ }
+ }
- if ($force_install_noedit && $force_install_type) print ' ';
- print '';
+ if ($force_install_noedit && $force_install_type) print ' ';
+ print '';
print $option;
print ' ';
@@ -320,10 +315,11 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
trans("Server"); ?>
-
value="">
- '; ?>
+ '; ?>
@@ -332,10 +328,11 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
trans("Port"); ?>
-
value="">
- '; ?>
+ '; ?>
@@ -343,9 +340,11 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
- trans("DatabaseName"); ?>
+ trans("DatabaseName"); ?>
+
-
@@ -364,7 +363,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
trans("Login"); ?>
-
@@ -372,7 +372,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
trans("Password"); ?>
-
@@ -381,7 +382,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
trans("CreateUser"); ?>
- >
@@ -390,8 +392,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
@@ -401,10 +403,10 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
trans("Login"); ?>
-
-
trans("Password"); ?>
-
-
@@ -519,9 +522,9 @@ function jscheckparam()
}
-close(); Not database connexion yet
+ // $db->close(); Not database connexion yet
-pFooter($err,$setuplang,'jscheckparam');
-?>
+ pFooter($err,$setuplang,'jscheckparam');
+ ?>
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index 8221c7c67b6..062ce74d612 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -49,29 +49,29 @@ $_REQUEST["logtohtml"]=1;
// et non path absolu.
if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
{
- $_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"];
+ $_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"];
}
// Definition des constantes syslog
if (function_exists("define_syslog_variables"))
{
- if (version_compare(PHP_VERSION, '5.3.0', '<'))
- {
- define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
- }
+ if (version_compare(PHP_VERSION, '5.3.0', '<'))
+ {
+ define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
+ }
}
else
{
- // Pour PHP sans syslog (comme sous Windows)
- define('LOG_EMERG',0);
- define('LOG_ALERT',1);
- define('LOG_CRIT',2);
- define('LOG_ERR',3);
- define('LOG_WARNING',4);
- define('LOG_NOTICE',5);
- define('LOG_INFO',6);
- define('LOG_DEBUG',7);
+ // Pour PHP sans syslog (comme sous Windows)
+ define('LOG_EMERG',0);
+ define('LOG_ALERT',1);
+ define('LOG_CRIT',2);
+ define('LOG_ERR',3);
+ define('LOG_WARNING',4);
+ define('LOG_NOTICE',5);
+ define('LOG_INFO',6);
+ define('LOG_DEBUG',7);
}
$includeconferror='';
@@ -89,44 +89,44 @@ $conffiletoshow = "htdocs/conf/conf.php";
if (! defined('DONOTLOADCONF') && file_exists($conffile))
{
- $result=include_once($conffile); // Load conf file
- if ($result)
- {
- //if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
+ $result=include_once($conffile); // Load conf file
+ if ($result)
+ {
+ //if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
- // Remove last / or \ on directories or url value
- if (! empty($dolibarr_main_document_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root)) $dolibarr_main_document_root=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
- if (! empty($dolibarr_main_url_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root)) $dolibarr_main_url_root=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root);
- if (! empty($dolibarr_main_data_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_data_root)) $dolibarr_main_data_root=preg_replace('/[\\/]+$/','',$dolibarr_main_data_root);
- if (! empty($dolibarr_main_document_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root_alt);
- if (! empty($dolibarr_main_url_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root_alt);
+ // Remove last / or \ on directories or url value
+ if (! empty($dolibarr_main_document_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root)) $dolibarr_main_document_root=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
+ if (! empty($dolibarr_main_url_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root)) $dolibarr_main_url_root=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root);
+ if (! empty($dolibarr_main_data_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_data_root)) $dolibarr_main_data_root=preg_replace('/[\\/]+$/','',$dolibarr_main_data_root);
+ if (! empty($dolibarr_main_document_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root_alt);
+ if (! empty($dolibarr_main_url_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root_alt);
- // Create conf object
- if (! empty($dolibarr_main_document_root))
- {
- $result=conf($dolibarr_main_document_root);
- }
- // Load database driver
- if ($result)
- {
- if (! empty($dolibarr_main_document_root) && ! empty($dolibarr_main_db_type))
- {
- $result=include_once($dolibarr_main_document_root . "/lib/databases/".$dolibarr_main_db_type.".class.php");
- if (! $result)
- {
- $includeconferror='ErrorBadValueForDolibarrMainDBType';
- }
- }
- }
- else
- {
- $includeconferror='ErrorBadValueForDolibarrMainDocumentRoot';
- }
- }
- else
- {
- $includeconferror='ErrorBadFormatForConfFile';
- }
+ // Create conf object
+ if (! empty($dolibarr_main_document_root))
+ {
+ $result=conf($dolibarr_main_document_root);
+ }
+ // Load database driver
+ if ($result)
+ {
+ if (! empty($dolibarr_main_document_root) && ! empty($dolibarr_main_db_type))
+ {
+ $result=include_once($dolibarr_main_document_root . "/lib/databases/".$dolibarr_main_db_type.".class.php");
+ if (! $result)
+ {
+ $includeconferror='ErrorBadValueForDolibarrMainDBType';
+ }
+ }
+ }
+ else
+ {
+ $includeconferror='ErrorBadValueForDolibarrMainDocumentRoot';
+ }
+ }
+ else
+ {
+ $includeconferror='ErrorBadFormatForConfFile';
+ }
}
$conf->global->MAIN_LOGTOHTML=1;
@@ -138,11 +138,11 @@ define('DOL_CLASS_PATH', 'class/'); // Filsystem pat
define('DOL_DATA_ROOT',(isset($dolibarr_main_data_root)?$dolibarr_main_data_root:''));
if (! empty($dolibarr_main_document_root_alt))
{
- define('DOL_DOCUMENT_ROOT_ALT', $dolibarr_main_document_root_alt); // Filesystem paths to alternate core php (alternate htdocs)
+ define('DOL_DOCUMENT_ROOT_ALT', $dolibarr_main_document_root_alt); // Filesystem paths to alternate core php (alternate htdocs)
}
define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root)?$dolibarr_main_url_root:'')); // URL relative root
$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
-$suburi = strstr ($uri, '/'); // $suburi contains url without domain
+$suburi = strstr($uri, '/'); // $suburi contains url without domain
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
@@ -170,33 +170,33 @@ if (! empty($dolibarr_main_document_root_alt))
// Security check
if (preg_match('/install.lock/i',$_SERVER["SCRIPT_FILENAME"]))
{
- print 'Install pages have been disabled for security reason (directory renamed with .lock suffix).';
+ print 'Install pages have been disabled for security reason (directory renamed with .lock suffix).';
if (! empty($dolibarr_main_url_root))
{
- print 'Click on following link. ';
- print '';
- print 'Click here to go to Dolibarr';
- print ' ';
+ print 'Click on following link. ';
+ print '';
+ print 'Click here to go to Dolibarr';
+ print ' ';
}
- exit;
+ exit;
}
$lockfile=DOL_DATA_ROOT.'/install.lock';
if (constant('DOL_DATA_ROOT') && file_exists($lockfile))
{
- print 'Install pages have been disabled for security reason (by lock file install.lock into dolibarr root directory). ';
- if (! empty($dolibarr_main_url_root))
- {
- print 'Click on following link. ';
- print 'If you always reach this page, you must remove install.lock file manually. ';
- print '';
- print 'Click here to go to Dolibarr';
- print ' ';
- }
+ print 'Install pages have been disabled for security reason (by lock file install.lock into dolibarr root directory). ';
+ if (! empty($dolibarr_main_url_root))
+ {
+ print 'Click on following link. ';
+ print 'If you always reach this page, you must remove install.lock file manually. ';
+ print '';
+ print 'Click here to go to Dolibarr';
+ print ' ';
+ }
else
{
print 'If you always reach this page, you must remove install.lock file manually. ';
}
- exit;
+ exit;
}
@@ -205,37 +205,37 @@ $conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
- if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
- else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
- else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
- else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
- else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
- //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
+ if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
+ else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
+ else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
+ else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
+ else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
+ //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
if (! defined('SYSLOG_FILE_NO_ERROR'))
{
- define('SYSLOG_FILE_NO_ERROR',1);
+ define('SYSLOG_FILE_NO_ERROR',1);
}
// Removed magic_quotes
if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6
{
- if (get_magic_quotes_gpc())
- {
- // Forcing parameter setting magic_quotes_gpc and cleaning parameters
- // (Otherwise he would have for each position, condition
- // Reading stripslashes variable according to state get_magic_quotes_gpc).
- // Off mode (recommended, you just do $db->escape when an insert / update.
- function stripslashes_deep($value)
- {
- return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
- }
- $_GET = array_map('stripslashes_deep', $_GET);
- $_POST = array_map('stripslashes_deep', $_POST);
- $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
- $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
- @set_magic_quotes_runtime(0);
- }
+ if (get_magic_quotes_gpc())
+ {
+ // Forcing parameter setting magic_quotes_gpc and cleaning parameters
+ // (Otherwise he would have for each position, condition
+ // Reading stripslashes variable according to state get_magic_quotes_gpc).
+ // Off mode (recommended, you just do $db->escape when an insert / update.
+ function stripslashes_deep($value)
+ {
+ return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
+ }
+ $_GET = array_map('stripslashes_deep', $_GET);
+ $_POST = array_map('stripslashes_deep', $_POST);
+ $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
+ $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
+ @set_magic_quotes_runtime(0);
+ }
}
// Defini objet langs
@@ -247,168 +247,172 @@ $bc[true]=' class="bg2"';
/**
- * \brief Load conf file (file must exists)
- * \param dolibarr_main_document_root Root directory of Dolibarr bin files
- * \return int <0 if KO, >0 if OK
+ * Load conf file (file must exists)
+ *
+ * @param string $dolibarr_main_document_root Root directory of Dolibarr bin files
+ * @return int <0 if KO, >0 if OK
*/
function conf($dolibarr_main_document_root)
{
- global $conf;
- global $dolibarr_main_db_type;
- global $dolibarr_main_db_host;
- global $dolibarr_main_db_port;
- global $dolibarr_main_db_name;
- global $dolibarr_main_db_user;
- global $dolibarr_main_db_pass;
- global $character_set_client;
+ global $conf;
+ global $dolibarr_main_db_type;
+ global $dolibarr_main_db_host;
+ global $dolibarr_main_db_port;
+ global $dolibarr_main_db_name;
+ global $dolibarr_main_db_user;
+ global $dolibarr_main_db_pass;
+ global $character_set_client;
- $return=include_once($dolibarr_main_document_root."/core/class/conf.class.php");
- if (! $return) return -1;
+ $return=include_once($dolibarr_main_document_root."/core/class/conf.class.php");
+ if (! $return) return -1;
- $conf=new Conf();
- $conf->db->type = trim($dolibarr_main_db_type);
- $conf->db->host = trim($dolibarr_main_db_host);
- $conf->db->port = trim($dolibarr_main_db_port);
- $conf->db->name = trim($dolibarr_main_db_name);
- $conf->db->user = trim($dolibarr_main_db_user);
- $conf->db->pass = trim($dolibarr_main_db_pass);
+ $conf=new Conf();
+ $conf->db->type = trim($dolibarr_main_db_type);
+ $conf->db->host = trim($dolibarr_main_db_host);
+ $conf->db->port = trim($dolibarr_main_db_port);
+ $conf->db->name = trim($dolibarr_main_db_name);
+ $conf->db->user = trim($dolibarr_main_db_user);
+ $conf->db->pass = trim($dolibarr_main_db_pass);
- if (empty($character_set_client)) $character_set_client="UTF-8";
- $conf->file->character_set_client=strtoupper($character_set_client);
- if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set='latin1'; // Old installation
- $conf->db->character_set=$dolibarr_main_db_character_set;
- if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation='latin1_swedish_ci'; // Old installation
- $conf->db->dolibarr_main_db_collation=$dolibarr_main_db_collation;
- if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
- $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
- if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
- $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
+ if (empty($character_set_client)) $character_set_client="UTF-8";
+ $conf->file->character_set_client=strtoupper($character_set_client);
+ if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set='latin1'; // Old installation
+ $conf->db->character_set=$dolibarr_main_db_character_set;
+ if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation='latin1_swedish_ci'; // Old installation
+ $conf->db->dolibarr_main_db_collation=$dolibarr_main_db_collation;
+ if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
+ $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
+ if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
+ $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
- // Forcage du log pour les install et mises a jour
- $conf->syslog->enabled=1;
- $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
- if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
- {
- if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
- else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
- else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
- else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
- else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
- //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
- }
- if (! defined('SYSLOG_FILE_NO_ERROR'))
- {
- define('SYSLOG_FILE_NO_ERROR',1);
- }
+ // Forcage du log pour les install et mises a jour
+ $conf->syslog->enabled=1;
+ $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
+ if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
+ {
+ if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
+ else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
+ else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
+ else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
+ else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
+ //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
+ }
+ if (! defined('SYSLOG_FILE_NO_ERROR'))
+ {
+ define('SYSLOG_FILE_NO_ERROR',1);
+ }
- return 1;
+ return 1;
}
/**
* Show header of install pages
*
- * @param $soutitre
- * @param $next
- * @param $action Action code ('set' or 'upgrade')
- * @param $param
+ * @param string $soutitre Sous titre
+ * @param string $next Next
+ * @param string $action Action code ('set' or 'upgrade')
+ * @param string $param Param
+ * @return void
*/
function pHeader($soutitre,$next,$action='set',$param='')
{
- global $conf;
- global $langs;
- $langs->load("main");
- $langs->load("admin");
+ global $conf;
+ global $langs;
+ $langs->load("main");
+ $langs->load("admin");
- // On force contenu dans format sortie
- header("Content-type: text/html; charset=".$conf->file->character_set_client);
+ // On force contenu dans format sortie
+ header("Content-type: text/html; charset=".$conf->file->character_set_client);
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ' '."\n";
- print ' '."\n";
- print ' '."\n";
- print ''."\n";
- print ''."\n";
- print ''.$langs->trans("DolibarrSetup").' '."\n";
- print ''."\n";
- print ''."\n";
- print ''.$langs->trans("DolibarrSetup");
- if ($soutitre) {
- print ' - '.$soutitre;
- }
- print ' '."\n";
+ print ''."\n";
+ print ''."\n";
+ print ''."\n";
+ print ' '."\n";
+ print ' '."\n";
+ print ' '."\n";
+ print ''."\n";
+ print ''."\n";
+ print ''.$langs->trans("DolibarrSetup").' '."\n";
+ print ''."\n";
+ print ''."\n";
+ print ''.$langs->trans("DolibarrSetup");
+ if ($soutitre) {
+ print ' - '.$soutitre;
+ }
+ print ' '."\n";
- print ''."\n";
+ print ''."\n";
- // If there is some logs in buffer to show
- if (isset($conf->logbuffer) && count($conf->logbuffer))
- {
- print "\n";
- print "\n";
- print "\n";
- }
+ // If there is some logs in buffer to show
+ if (isset($conf->logbuffer) && count($conf->logbuffer))
+ {
+ print "\n";
+ print "\n";
+ print "\n";
+ }
- print ''."\n";
- print ''."\n";
+ print ''."\n";
+ print ''."\n";
}
/**
* Log function for install pages
*
- * @param $message
- * @param $level
+ * @param string $message Message
+ * @param int $level Level of log
+ * @return void
*/
function dolibarr_install_syslog($message, $level=LOG_DEBUG)
{
- if (! defined('LOG_DEBUG')) define('LOG_DEBUG',6);
- dol_syslog($message,$level);
+ if (! defined('LOG_DEBUG')) define('LOG_DEBUG',6);
+ dol_syslog($message,$level);
}
?>
\ No newline at end of file
diff --git a/htdocs/install/licence.php b/htdocs/install/licence.php
deleted file mode 100644
index b2663d45556..00000000000
--- a/htdocs/install/licence.php
+++ /dev/null
@@ -1,68 +0,0 @@
-
- * Copyright (C) 2005-2010 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, see .
- */
-
-/**
- * \file htdocs/install/licence.php
- * \ingroup install
- * \brief Page to show licence (Removed from install process to save time)
- */
-
-include_once("./inc.php");
-require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
-
-$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto');
-$langs->setDefaultLang($setuplang);
-
-$langs->load("install");
-
-// Init "forced values" to nothing. "forced values" are used after an doliwamp install wizard.
-$useforcedwizard=false;
-if (file_exists("./install.forced.php")) { $useforcedwizard=true; include_once("./install.forced.php"); }
-else if (file_exists("/etc/dolibarr/install.forced.php")) { $useforcedwizard=include_once("/etc/dolibarr/install.forced.php"); }
-
-dolibarr_install_syslog("Licence: Entering licence.php page");
-
-
-/*
- * View
- */
-
-pHeader($langs->trans("License"),"fileconf");
-
-// Test if we can run a first install process
-if (! is_writable($conffile))
-{
- print $langs->trans("ConfFileIsNotWritable",$conffiletoshow);
- pFooter(1,$setuplang,'jscheckparam');
- exit;
-}
-
-//print '';
-$result=dol_print_file($langs,"html/gpl.html",1);
-if (! $result)
-{
- print ''."\n";
- print '';
- print ' '."\n";
-}
-//print ' ';
-
-pFooter(0,$setuplang);
-?>
diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php
index 8c0b774c728..cc9b87b9a3f 100644
--- a/htdocs/install/repair.php
+++ b/htdocs/install/repair.php
@@ -76,14 +76,14 @@ $error=0;
// If password is encoded, we decode it
if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
{
- require_once($dolibarr_main_document_root."/lib/security.lib.php");
- if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
- {
- $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
- $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
- $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
- }
- else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ require_once($dolibarr_main_document_root."/lib/security.lib.php");
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
+ {
+ $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
+ $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
+ $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
+ }
+ else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
// $conf is already instancied inside inc.php
@@ -98,44 +98,44 @@ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db-
if ($db->connected == 1)
{
- print '';
- print $langs->trans("ServerConnection")." : $dolibarr_main_db_host ".$langs->trans("OK")." ";
- dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
- $ok = 1;
+ print '';
+ print $langs->trans("ServerConnection")." : $dolibarr_main_db_host ".$langs->trans("OK")." ";
+ dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
+ $ok = 1;
}
else
{
- print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->transnoentities("Error")." ";
- dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
- $ok = 0;
+ print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->transnoentities("Error")." ";
+ dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
+ $ok = 0;
}
if ($ok)
{
- if($db->database_selected == 1)
- {
- print '';
- print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name." ".$langs->trans("OK")." ";
- dolibarr_install_syslog("repair: Database connection successfull : $dolibarr_main_db_name");
- $ok=1;
- }
- else
- {
- print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->trans("Error")." ";
- dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
- $ok=0;
- }
+ if($db->database_selected == 1)
+ {
+ print '';
+ print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name." ".$langs->trans("OK")." ";
+ dolibarr_install_syslog("repair: Database connection successfull : $dolibarr_main_db_name");
+ $ok=1;
+ }
+ else
+ {
+ print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->trans("Error")." ";
+ dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
+ $ok=0;
+ }
}
// Affiche version
if ($ok)
{
- $version=$db->getVersion();
- $versionarray=$db->getVersionArray();
- print ''.$langs->trans("ServerVersion").' ';
- print ''.$version.' ';
- dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerVersion")." : $version");
- //print ''.join('.',$versionarray).' ';
+ $version=$db->getVersion();
+ $versionarray=$db->getVersionArray();
+ print ''.$langs->trans("ServerVersion").' ';
+ print ''.$version.' ';
+ dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerVersion")." : $version");
+ //print ''.join('.',$versionarray).' ';
}
// Force l'affichage de la progression
@@ -148,47 +148,47 @@ flush();
*/
if ($ok)
{
- if ($choix==1) $dir = "mysql/migration/";
- elseif ($choix==2) $dir = "pgsql/migration/";
- else $dir = "mssql/migration/";
+ if ($choix==1) $dir = "mysql/migration/";
+ elseif ($choix==2) $dir = "pgsql/migration/";
+ else $dir = "mssql/migration/";
- $filelist=array();
- $i = 0;
- $ok = 0;
- $from='^'.$versionfrom;
- $to=$versionto.'\.sql$';
+ $filelist=array();
+ $i = 0;
+ $ok = 0;
+ $from='^'.$versionfrom;
+ $to=$versionto.'\.sql$';
- // Recupere list fichier
- $filesindir=array();
- $handle=opendir($dir);
+ // Recupere list fichier
+ $filesindir=array();
+ $handle=opendir($dir);
if (is_resource($handle))
{
- while (($file = readdir($handle))!==false)
- {
- if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
- }
+ while (($file = readdir($handle))!==false)
+ {
+ if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
+ }
}
- sort($filesindir);
+ sort($filesindir);
- foreach($filesindir as $file)
- {
- if (preg_match('/repair/i',$file))
- {
- $filelist[]=$file;
- }
- }
+ foreach($filesindir as $file)
+ {
+ if (preg_match('/repair/i',$file))
+ {
+ $filelist[]=$file;
+ }
+ }
- // Boucle sur chaque fichier
- foreach($filelist as $file)
- {
- print '';
- print $langs->trans("ChoosedMigrateScript").' '.$file.' ';
+ // Boucle sur chaque fichier
+ foreach($filelist as $file)
+ {
+ print '';
+ print $langs->trans("ChoosedMigrateScript").' '.$file.' ';
- $name = substr($file, 0, dol_strlen($file) - 4);
+ $name = substr($file, 0, dol_strlen($file) - 4);
- // Run sql script
- $ok=run_sql($dir.$file, 0, '', 1);
- }
+ // Run sql script
+ $ok=run_sql($dir.$file, 0, '', 1);
+ }
}
print '
';
diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php
index 328ed9ad531..2e1f99eedc0 100644
--- a/htdocs/install/upgrade.php
+++ b/htdocs/install/upgrade.php
@@ -25,7 +25,7 @@
include_once("./inc.php");
if (! file_exists($conffile))
{
- print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
+ print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
require_once($conffile); if (! isset($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
require_once($dolibarr_main_document_root."/lib/admin.lib.php");
@@ -71,272 +71,272 @@ $actiondone=0;
// Action to launch the repair or migrate script
if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
{
- $actiondone=1;
+ $actiondone=1;
- print ''.$langs->trans("DatabaseMigration").' ';
+ print ''.$langs->trans("DatabaseMigration").' ';
- if (! $versionfrom && ! $versionto)
- {
- print 'Parameter versionfrom or version to missing. Upgrade is launched from page install/index.php (like a first install) instead of install/upgrade.php
';
- exit;
- }
+ if (! $versionfrom && ! $versionto)
+ {
+ print 'Parameter versionfrom or version to missing. Upgrade is launched from page install/index.php (like a first install) instead of install/upgrade.php
';
+ exit;
+ }
- print '';
- $error=0;
+ print '';
+ $error=0;
- // If password is encoded, we decode it
- if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
- {
- require_once($dolibarr_main_document_root."/lib/security.lib.php");
- if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
- {
- $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
- $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
- $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
- }
- else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
- }
+ // If password is encoded, we decode it
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
+ {
+ require_once($dolibarr_main_document_root."/lib/security.lib.php");
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
+ {
+ $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
+ $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
+ $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
+ }
+ else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ }
- // $conf is already instancied inside inc.php
- $conf->db->type = $dolibarr_main_db_type;
- $conf->db->host = $dolibarr_main_db_host;
- $conf->db->port = $dolibarr_main_db_port;
- $conf->db->name = $dolibarr_main_db_name;
- $conf->db->user = $dolibarr_main_db_user;
- $conf->db->pass = $dolibarr_main_db_pass;
+ // $conf is already instancied inside inc.php
+ $conf->db->type = $dolibarr_main_db_type;
+ $conf->db->host = $dolibarr_main_db_host;
+ $conf->db->port = $dolibarr_main_db_port;
+ $conf->db->name = $dolibarr_main_db_name;
+ $conf->db->user = $dolibarr_main_db_user;
+ $conf->db->pass = $dolibarr_main_db_pass;
- // Load type and crypt key
- if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
- $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
- if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
- $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
+ // Load type and crypt key
+ if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
+ $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
+ if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
+ $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1)
- {
- print '';
- print $langs->trans("ServerConnection")." : $dolibarr_main_db_host ".$langs->trans("OK")." \n";
- dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
- $ok = 1;
- }
- else
- {
- print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->transnoentities("Error")." \n";
- dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
- $ok = 0;
- }
+ {
+ print '';
+ print $langs->trans("ServerConnection")." : $dolibarr_main_db_host ".$langs->trans("OK")." \n";
+ dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
+ $ok = 1;
+ }
+ else
+ {
+ print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->transnoentities("Error")." \n";
+ dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
+ $ok = 0;
+ }
- if ($ok)
- {
- if($db->database_selected == 1)
- {
- print '';
- print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name." ".$langs->trans("OK")." \n";
- dolibarr_install_syslog("upgrade: Database connection successfull : $dolibarr_main_db_name");
- $ok=1;
- }
- else
- {
- print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->trans("Error")." \n";
- dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
- $ok=0;
- }
- }
+ if ($ok)
+ {
+ if($db->database_selected == 1)
+ {
+ print '';
+ print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name." ".$langs->trans("OK")." \n";
+ dolibarr_install_syslog("upgrade: Database connection successfull : $dolibarr_main_db_name");
+ $ok=1;
+ }
+ else
+ {
+ print "".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)." ".$langs->trans("Error")." \n";
+ dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
+ $ok=0;
+ }
+ }
- // Affiche version
- if ($ok)
- {
- $version=$db->getVersion();
- $versionarray=$db->getVersionArray();
- print ''.$langs->trans("ServerVersion").' ';
- print ''.$version.' ';
- dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version");
- //print ''.join('.',$versionarray).' ';
- }
+ // Affiche version
+ if ($ok)
+ {
+ $version=$db->getVersion();
+ $versionarray=$db->getVersionArray();
+ print ''.$langs->trans("ServerVersion").' ';
+ print ''.$version.' ';
+ dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version");
+ //print ''.join('.',$versionarray).' ';
+ }
- // Force l'affichage de la progression
- print ''.$langs->trans("PleaseBePatient").' ';
- flush();
+ // Force l'affichage de la progression
+ print ''.$langs->trans("PleaseBePatient").' ';
+ flush();
- /*
- * Delete duplicates in table categorie_association
- */
- $couples=array();
- $filles=array();
- $sql = "SELECT fk_categorie_mere, fk_categorie_fille";
- $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association";
- dolibarr_install_syslog("upgrade: search duplicate sql=".$sql);
- $resql = $db->query($sql);
- if ($resql)
- {
- $num=$db->num_rows($resql);
- while ($obj=$db->fetch_object($resql))
- {
- if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent).
- {
- if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
- {
- $filles[$obj->fk_categorie_fille]=1; // Set record for this child
- $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille);
- }
- }
- }
+ /*
+ * Delete duplicates in table categorie_association
+ */
+ $couples=array();
+ $filles=array();
+ $sql = "SELECT fk_categorie_mere, fk_categorie_fille";
+ $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association";
+ dolibarr_install_syslog("upgrade: search duplicate sql=".$sql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num=$db->num_rows($resql);
+ while ($obj=$db->fetch_object($resql))
+ {
+ if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent).
+ {
+ if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
+ {
+ $filles[$obj->fk_categorie_fille]=1; // Set record for this child
+ $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille);
+ }
+ }
+ }
- dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples));
+ dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples));
- // If there is duplicates couples or child with two parents
- if (count($couples) > 0 && $num > count($couples))
- {
- $error=0;
+ // If there is duplicates couples or child with two parents
+ if (count($couples) > 0 && $num > count($couples))
+ {
+ $error=0;
- $db->begin();
+ $db->begin();
- $sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
- dolibarr_install_syslog("upgrade: delete association sql=".$sql);
- $resqld=$db->query($sql);
- if ($resqld)
- {
- foreach($couples as $key => $val)
- {
- $sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
- $sql.=" VALUES(".$val['mere'].", ".$val['fille'].")";
- dolibarr_install_syslog("upgrade: insert association sql=".$sql);
- $resqli=$db->query($sql);
- if (! $resqli) $error++;
- }
- }
+ $sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
+ dolibarr_install_syslog("upgrade: delete association sql=".$sql);
+ $resqld=$db->query($sql);
+ if ($resqld)
+ {
+ foreach($couples as $key => $val)
+ {
+ $sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
+ $sql.=" VALUES(".$val['mere'].", ".$val['fille'].")";
+ dolibarr_install_syslog("upgrade: insert association sql=".$sql);
+ $resqli=$db->query($sql);
+ if (! $resqli) $error++;
+ }
+ }
- if (! $error)
- {
- print ''.$langs->trans("RemoveDuplicates").' ';
- print ''.$langs->trans("Success").' ('.$num.'=>'.count($couples).') ';
- $db->commit();
- }
- else
- {
- print ''.$langs->trans("RemoveDuplicates").' ';
- print ''.$langs->trans("Failed").' ';
- $db->rollback();
- }
- }
- }
- else
- {
- print ''.$langs->trans("Error").'
';
- }
+ if (! $error)
+ {
+ print ''.$langs->trans("RemoveDuplicates").' ';
+ print ''.$langs->trans("Success").' ('.$num.'=>'.count($couples).') ';
+ $db->commit();
+ }
+ else
+ {
+ print ''.$langs->trans("RemoveDuplicates").' ';
+ print ''.$langs->trans("Failed").' ';
+ $db->rollback();
+ }
+ }
+ }
+ else
+ {
+ print ''.$langs->trans("Error").'
';
+ }
- /*
- * Remove deprecated indexes and constraints for Mysql
- */
- if ($ok && preg_match('/mysql/',$db->type))
- {
- $versioncommande=explode('.','4.0');
- if (count($versioncommande) && count($versionarray)
- && versioncompare($versioncommande,$versionarray) <= 0) // Si mysql >= 4.0
- {
- // Suppression vieilles contraintes sans noms et en doubles
- // Les contraintes indesirables ont un nom qui commence par 0_ ou se termine par ibfk_999
- $listtables=array( 'llx_adherent_options',
+ /*
+ * Remove deprecated indexes and constraints for Mysql
+ */
+ if ($ok && preg_match('/mysql/',$db->type))
+ {
+ $versioncommande=explode('.','4.0');
+ if (count($versioncommande) && count($versionarray)
+ && versioncompare($versioncommande,$versionarray) <= 0) // Si mysql >= 4.0
+ {
+ // Suppression vieilles contraintes sans noms et en doubles
+ // Les contraintes indesirables ont un nom qui commence par 0_ ou se termine par ibfk_999
+ $listtables=array( 'llx_adherent_options',
'llx_bank_class',
'llx_c_ecotaxe',
'llx_c_methode_commande_fournisseur', // table renamed
'llx_c_input_method');
- $listtables = $db->DDLListTables($conf->db->name,'');
- foreach ($listtables as $val)
- {
- //print "x".$val." ";
- $sql = "SHOW CREATE TABLE ".$val;
- $resql = $db->query($sql);
- if ($resql)
- {
- $values=$db->fetch_array($resql);
- $i=0;
- $createsql=$values[1];
- while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i',$createsql,$reg) && $i < 100)
- {
- $sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
- $resqldrop = $db->query($sqldrop);
- if ($resqldrop)
- {
- print ''.$sqldrop."; \n";
- }
- $createsql=preg_replace('/CONSTRAINT `'.$reg[1].'`/i','XXX',$createsql);
- $i++;
- }
- $db->free($resql);
- }
- else
- {
- if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE')
- {
- print ''.$sql.' : '.$db->lasterror()." \n";
- }
- }
- }
- }
- }
+ $listtables = $db->DDLListTables($conf->db->name,'');
+ foreach ($listtables as $val)
+ {
+ //print "x".$val." ";
+ $sql = "SHOW CREATE TABLE ".$val;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $values=$db->fetch_array($resql);
+ $i=0;
+ $createsql=$values[1];
+ while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i',$createsql,$reg) && $i < 100)
+ {
+ $sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
+ $resqldrop = $db->query($sqldrop);
+ if ($resqldrop)
+ {
+ print ''.$sqldrop."; \n";
+ }
+ $createsql=preg_replace('/CONSTRAINT `'.$reg[1].'`/i','XXX',$createsql);
+ $i++;
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE')
+ {
+ print ''.$sql.' : '.$db->lasterror()." \n";
+ }
+ }
+ }
+ }
+ }
- /*
- * Load sql files
- */
- if ($ok)
- {
- $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver
+ /*
+ * Load sql files
+ */
+ if ($ok)
+ {
+ $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver
- $filelist=array();
- $i = 0;
- $ok = 0;
- $from='^'.$versionfrom;
- $to=$versionto.'\.sql$';
+ $filelist=array();
+ $i = 0;
+ $ok = 0;
+ $from='^'.$versionfrom;
+ $to=$versionto.'\.sql$';
- // Get files list
- $filesindir=array();
- $handle=opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle))!==false)
- {
- if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
- }
- sort($filesindir);
- }
- else
- {
- print ''.$langs->trans("ErrorCanNotReadDir",$dir).'
';
- }
+ // Get files list
+ $filesindir=array();
+ $handle=opendir($dir);
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle))!==false)
+ {
+ if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
+ }
+ sort($filesindir);
+ }
+ else
+ {
+ print ''.$langs->trans("ErrorCanNotReadDir",$dir).'
';
+ }
- // Define which file to run
- foreach($filesindir as $file)
- {
- if (preg_match('/'.$from.'/i',$file))
- {
- $filelist[]=$file;
- }
- else if (preg_match('/'.$to.'/i',$file)) // First test may be false if we migrate from x.y.* to x.y.*
- {
- $filelist[]=$file;
- }
- }
+ // Define which file to run
+ foreach($filesindir as $file)
+ {
+ if (preg_match('/'.$from.'/i',$file))
+ {
+ $filelist[]=$file;
+ }
+ else if (preg_match('/'.$to.'/i',$file)) // First test may be false if we migrate from x.y.* to x.y.*
+ {
+ $filelist[]=$file;
+ }
+ }
- // Boucle sur chaque fichier
- foreach($filelist as $file)
- {
- print '';
- print $langs->trans("ChoosedMigrateScript").' '.$file.' '."\n";
+ // Boucle sur chaque fichier
+ foreach($filelist as $file)
+ {
+ print '';
+ print $langs->trans("ChoosedMigrateScript").' '.$file.' '."\n";
- $name = substr($file, 0, dol_strlen($file) - 4);
+ $name = substr($file, 0, dol_strlen($file) - 4);
- // Run sql script
- $ok=run_sql($dir.$file, 0, '', 1);
- }
- }
+ // Run sql script
+ $ok=run_sql($dir.$file, 0, '', 1);
+ }
+ }
- print '
';
+ print '
';
- if ($db->connected) $db->close();
+ if ($db->connected) $db->close();
}
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 879711c0408..9a629cfe06f 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -26,7 +26,7 @@
include_once('./inc.php');
if (! file_exists($conffile))
{
- print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
+ print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
require_once($conffile); if (! isset($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
require_once($dolibarr_main_document_root . '/compta/facture/class/facture.class.php');
@@ -80,207 +80,207 @@ pHeader('','etape5',GETPOST("action"),'versionfrom='.$versionfrom.'&versionto='.
if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
{
- print ''.$langs->trans('DataMigration').' ';
+ print ''.$langs->trans('DataMigration').' ';
- print '';
+ print '';
- // If password is encoded, we decode it
- if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
- {
- require_once($dolibarr_main_document_root."/lib/security.lib.php");
- if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
- {
- $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
- $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
- $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
- }
- else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
- }
+ // If password is encoded, we decode it
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
+ {
+ require_once($dolibarr_main_document_root."/lib/security.lib.php");
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
+ {
+ $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
+ $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
+ $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
+ }
+ else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ }
- // $conf is already instancied inside inc.php
- $conf->db->type = $dolibarr_main_db_type;
- $conf->db->host = $dolibarr_main_db_host;
- $conf->db->port = $dolibarr_main_db_port;
- $conf->db->name = $dolibarr_main_db_name;
- $conf->db->user = $dolibarr_main_db_user;
- $conf->db->pass = $dolibarr_main_db_pass;
+ // $conf is already instancied inside inc.php
+ $conf->db->type = $dolibarr_main_db_type;
+ $conf->db->host = $dolibarr_main_db_host;
+ $conf->db->port = $dolibarr_main_db_port;
+ $conf->db->name = $dolibarr_main_db_name;
+ $conf->db->user = $dolibarr_main_db_user;
+ $conf->db->pass = $dolibarr_main_db_pass;
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected != 1)
- {
- print ''.$langs->trans("ErrorFailedToConnectToDatabase",$conf->db->name).' '.$langs->trans('Error').' ';
- dolibarr_install_syslog('upgrade2: Failed to connect to database : '.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR);
- $error++;
- }
+ {
+ print ''.$langs->trans("ErrorFailedToConnectToDatabase",$conf->db->name).' '.$langs->trans('Error').' ';
+ dolibarr_install_syslog('upgrade2: Failed to connect to database : '.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR);
+ $error++;
+ }
- if (! $error)
- {
- if($db->database_selected == 1)
- {
- dolibarr_install_syslog('upgrade2: Database connection successfull : '.$dolibarr_main_db_name);
- }
- else
- {
- $error++;
- }
- }
+ if (! $error)
+ {
+ if($db->database_selected == 1)
+ {
+ dolibarr_install_syslog('upgrade2: Database connection successfull : '.$dolibarr_main_db_name);
+ }
+ else
+ {
+ $error++;
+ }
+ }
- if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
- $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
- if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
- $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
+ if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
+ $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
+ if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
+ $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
- // Chargement config
- if (! $error) $conf->setValues($db);
+ // Chargement config
+ if (! $error) $conf->setValues($db);
- /***************************************************************************************
- *
- * Migration des donnees
- *
- ***************************************************************************************/
- if (! $error)
- {
- // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
- // Version to install is DOL_VERSION
- $dolibarrlastupgradeversionarray=preg_split('/[\.-]/',isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:$conf->global->MAIN_VERSION_LAST_INSTALL);
+ /***************************************************************************************
+ *
+ * Migration des donnees
+ *
+ ***************************************************************************************/
+ if (! $error)
+ {
+ // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
+ // Version to install is DOL_VERSION
+ $dolibarrlastupgradeversionarray=preg_split('/[\.-]/',isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:$conf->global->MAIN_VERSION_LAST_INSTALL);
- $db->begin();
+ $db->begin();
- // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec
- // dans la 1ere colonne, la description de l'action a faire
- // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error'
+ // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec
+ // dans la 1ere colonne, la description de l'action a faire
+ // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error'
- $versiontoarray=explode('.',$versionto);
+ $versiontoarray=explode('.',$versionto);
- $afterversionarray=explode('.','2.0.0');
- $beforeversionarray=explode('.','2.7.9');
- if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
- {
- // Script pour V2 -> V2.1
- migrate_paiements($db,$langs,$conf);
+ $afterversionarray=explode('.','2.0.0');
+ $beforeversionarray=explode('.','2.7.9');
+ if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
+ {
+ // Script pour V2 -> V2.1
+ migrate_paiements($db,$langs,$conf);
- migrate_contracts_det($db,$langs,$conf);
+ migrate_contracts_det($db,$langs,$conf);
- migrate_contracts_date1($db,$langs,$conf);
+ migrate_contracts_date1($db,$langs,$conf);
- migrate_contracts_date2($db,$langs,$conf);
+ migrate_contracts_date2($db,$langs,$conf);
- migrate_contracts_date3($db,$langs,$conf);
+ migrate_contracts_date3($db,$langs,$conf);
- migrate_contracts_open($db,$langs,$conf);
+ migrate_contracts_open($db,$langs,$conf);
- migrate_modeles($db,$langs,$conf);
+ migrate_modeles($db,$langs,$conf);
- migrate_price_propal($db,$langs,$conf);
+ migrate_price_propal($db,$langs,$conf);
- migrate_price_commande($db,$langs,$conf);
+ migrate_price_commande($db,$langs,$conf);
- migrate_price_commande_fournisseur($db,$langs,$conf);
+ migrate_price_commande_fournisseur($db,$langs,$conf);
- migrate_price_contrat($db,$langs,$conf);
+ migrate_price_contrat($db,$langs,$conf);
- migrate_paiementfourn_facturefourn($db,$langs,$conf);
+ migrate_paiementfourn_facturefourn($db,$langs,$conf);
- // Script pour V2.1 -> V2.2
- migrate_paiements_orphelins_1($db,$langs,$conf);
+ // Script pour V2.1 -> V2.2
+ migrate_paiements_orphelins_1($db,$langs,$conf);
- migrate_paiements_orphelins_2($db,$langs,$conf);
+ migrate_paiements_orphelins_2($db,$langs,$conf);
- migrate_links_transfert($db,$langs,$conf);
+ migrate_links_transfert($db,$langs,$conf);
- // Script pour V2.2 -> V2.4
- migrate_commande_expedition($db,$langs,$conf);
+ // Script pour V2.2 -> V2.4
+ migrate_commande_expedition($db,$langs,$conf);
- migrate_commande_livraison($db,$langs,$conf);
+ migrate_commande_livraison($db,$langs,$conf);
- migrate_detail_livraison($db,$langs,$conf);
+ migrate_detail_livraison($db,$langs,$conf);
- // Script pour V2.5 -> V2.6
- migrate_stocks($db,$langs,$conf);
+ // Script pour V2.5 -> V2.6
+ migrate_stocks($db,$langs,$conf);
- // Script pour V2.6 -> V2.7
- migrate_menus($db,$langs,$conf);
+ // Script pour V2.6 -> V2.7
+ migrate_menus($db,$langs,$conf);
- migrate_commande_deliveryaddress($db,$langs,$conf);
+ migrate_commande_deliveryaddress($db,$langs,$conf);
- migrate_restore_missing_links($db,$langs,$conf);
+ migrate_restore_missing_links($db,$langs,$conf);
- migrate_directories($db,$langs,$conf,'/compta','/banque');
+ migrate_directories($db,$langs,$conf,'/compta','/banque');
- migrate_directories($db,$langs,$conf,'/societe','/mycompany');
+ migrate_directories($db,$langs,$conf,'/societe','/mycompany');
- // Reload modules
+ // Reload modules
migrate_reload_modules($db,$langs,$conf);
// Reload menus
migrate_reload_menu($db,$langs,$conf,$versionto);
- }
+ }
- // Script for VX (X<2.8) -> V2.8
- $afterversionarray=explode('.','2.7.9');
- $beforeversionarray=explode('.','2.8.9');
- //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray);
- if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
- {
+ // Script for VX (X<2.8) -> V2.8
+ $afterversionarray=explode('.','2.7.9');
+ $beforeversionarray=explode('.','2.8.9');
+ //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray);
+ if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
+ {
migrate_price_facture($db,$langs,$conf); // Code of this function works for 2.8+ because need a field tva_tx
- migrate_relationship_tables($db,$langs,$conf,'co_exp','fk_commande','commande','fk_expedition','shipping');
+ 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');
+ 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');
+ migrate_relationship_tables($db,$langs,$conf,'co_pr','fk_propale','propal','fk_commande','commande');
- migrate_relationship_tables($db,$langs,$conf,'fa_pr','fk_propal','propal','fk_facture','facture');
+ migrate_relationship_tables($db,$langs,$conf,'fa_pr','fk_propal','propal','fk_facture','facture');
- migrate_relationship_tables($db,$langs,$conf,'co_fa','fk_commande','commande','fk_facture','facture');
+ migrate_relationship_tables($db,$langs,$conf,'co_fa','fk_commande','commande','fk_facture','facture');
- migrate_project_user_resp($db,$langs,$conf);
+ migrate_project_user_resp($db,$langs,$conf);
- migrate_project_task_actors($db,$langs,$conf);
+ migrate_project_task_actors($db,$langs,$conf);
- // Reload modules
+ // Reload modules
migrate_reload_modules($db,$langs,$conf);
// Reload menus
migrate_reload_menu($db,$langs,$conf,$versionto);
- }
+ }
- // Script for VX (X<2.9) -> V2.9
- $afterversionarray=explode('.','2.8.9');
- $beforeversionarray=explode('.','2.9.9');
- if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
- {
- migrate_project_task_time($db,$langs,$conf);
+ // Script for VX (X<2.9) -> V2.9
+ $afterversionarray=explode('.','2.8.9');
+ $beforeversionarray=explode('.','2.9.9');
+ if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
+ {
+ migrate_project_task_time($db,$langs,$conf);
- migrate_customerorder_shipping($db,$langs,$conf);
+ migrate_customerorder_shipping($db,$langs,$conf);
- migrate_shipping_delivery($db,$langs,$conf);
+ migrate_shipping_delivery($db,$langs,$conf);
- migrate_shipping_delivery2($db,$langs,$conf);
+ migrate_shipping_delivery2($db,$langs,$conf);
- // Reload modules
+ // Reload modules
migrate_reload_modules($db,$langs,$conf);
// Reload menus
migrate_reload_menu($db,$langs,$conf,$versionto);
- }
+ }
// Script for VX (X<3.0) -> V3.0
$afterversionarray=explode('.','2.9.9');
$beforeversionarray=explode('.','3.0.9');
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
{
- // Reload modules
+ // Reload modules
migrate_reload_modules($db,$langs,$conf);
// Reload menus
@@ -319,22 +319,22 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
print ' '.$langs->trans("MigrationFinished").' ';
// On commit dans tous les cas.
- // La procedure etant concue pour pouvoir passer plusieurs fois quelquesoit la situation.
- $db->commit();
- $db->close();
+ // La procedure etant concue pour pouvoir passer plusieurs fois quelquesoit la situation.
+ $db->commit();
+ $db->close();
- // Actions for all version (not in database)
- migrate_delete_old_files($db,$langs,$conf);
+ // Actions for all version (not in database)
+ migrate_delete_old_files($db,$langs,$conf);
- migrate_delete_old_dir($db,$langs,$conf);
- }
+ migrate_delete_old_dir($db,$langs,$conf);
+ }
- print '
';
+ print '
';
}
else
{
- print ''.$langs->trans('ErrorWrongParameters').'
';
- $error++;
+ print ''.$langs->trans('ErrorWrongParameters').'
';
+ $error++;
}
@@ -343,362 +343,377 @@ pFooter($error,$setuplang);
/**
* Reporte liens vers une facture de paiements sur table de jointure (lien n-n paiements factures)
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @return void
*/
function migrate_paiements($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationPaymentsUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationPaymentsUpdate')." \n";
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement","fk_facture");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- $sql = "SELECT p.rowid, p.fk_facture, p.amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
- $sql .= " WHERE p.fk_facture > 0";
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement","fk_facture");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $sql = "SELECT p.rowid, p.fk_facture, p.amount";
+ $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
+ $sql .= " WHERE p.fk_facture > 0";
- $resql = $db->query($sql);
+ $resql = $db->query($sql);
- dolibarr_install_syslog("upgrade2::migrate_paiements sql=".$sql);
- if ($resql)
- {
- $i = 0;
- $row = array();
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2::migrate_paiements sql=".$sql);
+ if ($resql)
+ {
+ $i = 0;
+ $row = array();
+ $num = $db->num_rows($resql);
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- $row[$i][0] = $obj->rowid ;
- $row[$i][1] = $obj->fk_facture;
- $row[$i][2] = $obj->amount;
- $i++;
- }
- }
- else
- {
- dol_print_error($db);
- }
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ $row[$i][0] = $obj->rowid ;
+ $row[$i][1] = $obj->fk_facture;
+ $row[$i][2] = $obj->amount;
+ $i++;
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
- if ($num)
- {
- print $langs->trans('MigrationPaymentsNumberToUpdate', $num)." \n";
- if ($db->begin())
- {
- $res = 0;
- $num=count($row);
- for ($i = 0; $i < $num; $i++)
- {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
- $sql.= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")";
+ if ($num)
+ {
+ print $langs->trans('MigrationPaymentsNumberToUpdate', $num)." \n";
+ if ($db->begin())
+ {
+ $res = 0;
+ $num=count($row);
+ for ($i = 0; $i < $num; $i++)
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
+ $sql.= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")";
- $res += $db->query($sql);
+ $res += $db->query($sql);
- $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".$row[$i][0];
+ $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".$row[$i][0];
- $res += $db->query($sql);
+ $res += $db->query($sql);
- print $langs->trans('MigrationProcessPaymentUpdate', $row[$i][0])." \n";
- }
- }
+ print $langs->trans('MigrationProcessPaymentUpdate', $row[$i][0])." \n";
+ }
+ }
- if ($res == (2 * count($row)))
- {
- $db->commit();
- print $langs->trans('MigrationSuccessfullUpdate')." ";
- }
- else
- {
- $db->rollback();
- print $langs->trans('MigrationUpdateFailed').' ';
- }
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingToUpdate')." \n";
- }
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingToUpdate')." \n";
- }
+ if ($res == (2 * count($row)))
+ {
+ $db->commit();
+ print $langs->trans('MigrationSuccessfullUpdate')." ";
+ }
+ else
+ {
+ $db->rollback();
+ print $langs->trans('MigrationUpdateFailed').' ';
+ }
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingToUpdate')." \n";
+ }
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingToUpdate')." \n";
+ }
- print ' ';
+ print '';
}
/**
* Corrige paiement orphelins (liens paumes suite a bugs)
* Pour verifier s'il reste des orphelins:
* select * 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)
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @return void
*/
function migrate_paiements_orphelins_1($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationPaymentsUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationPaymentsUpdate')." \n";
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement","fk_facture");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
- $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
- $sql.= " bu2.url_id as socid";
- $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)";
- $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid";
- $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')";
- $sql.= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid";
- $sql.= " AND b.rappro = 1";
- $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)";
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement","fk_facture");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
+ $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
+ $sql.= " bu2.url_id as socid";
+ $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)";
+ $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid";
+ $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')";
+ $sql.= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid";
+ $sql.= " AND b.rappro = 1";
+ $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)";
- $resql = $db->query($sql);
+ $resql = $db->query($sql);
- dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_1 sql=".$sql);
- $row = array();
- if ($resql)
- {
- $i = $j = 0;
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_1 sql=".$sql);
+ $row = array();
+ if ($resql)
+ {
+ $i = $j = 0;
+ $num = $db->num_rows($resql);
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas
- {
- $row[$j]['paymentid'] = $obj->rowid ; // paymentid
- $row[$j]['pamount'] = $obj->pamount;
- $row[$j]['fk_bank'] = $obj->fk_bank;
- $row[$j]['bamount'] = $obj->bamount;
- $row[$j]['socid'] = $obj->socid;
- $row[$j]['datec'] = $obj->datec;
- $j++;
- }
- $i++;
- }
- }
- else
- {
- dol_print_error($db);
- }
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas
+ {
+ $row[$j]['paymentid'] = $obj->rowid ; // paymentid
+ $row[$j]['pamount'] = $obj->pamount;
+ $row[$j]['fk_bank'] = $obj->fk_bank;
+ $row[$j]['bamount'] = $obj->bamount;
+ $row[$j]['socid'] = $obj->socid;
+ $row[$j]['datec'] = $obj->datec;
+ $j++;
+ }
+ $i++;
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
- if (count($row))
- {
- print $langs->trans('OrphelinsPaymentsDetectedByMethod', 1).': '.count($row)." \n";
- $db->begin();
+ if (count($row))
+ {
+ print $langs->trans('OrphelinsPaymentsDetectedByMethod', 1).': '.count($row)." \n";
+ $db->begin();
- $res = 0;
- $num=count($row);
- for ($i = 0; $i < $num; $i++)
- {
- if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
+ $res = 0;
+ $num=count($row);
+ for ($i = 0; $i < $num; $i++)
+ {
+ if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
- // On cherche facture sans lien paiement et du meme montant et pour meme societe.
- $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f";
- $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
- $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount'];
- $sql.=" AND pf.fk_facture IS NULL";
- $sql.=" ORDER BY f.fk_statut";
- //print $sql.' ';
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- //print 'Nb of invoice found for this amount and company :'.$num.' ';
- if ($num >= 1)
- {
- $obj=$db->fetch_object($resql);
- $facid=$obj->rowid;
+ // On cherche facture sans lien paiement et du meme montant et pour meme societe.
+ $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
+ $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount'];
+ $sql.=" AND pf.fk_facture IS NULL";
+ $sql.=" ORDER BY f.fk_statut";
+ //print $sql.' ';
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ //print 'Nb of invoice found for this amount and company :'.$num.' ';
+ if ($num >= 1)
+ {
+ $obj=$db->fetch_object($resql);
+ $facid=$obj->rowid;
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
- $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
+ $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")";
- $res += $db->query($sql);
+ $res += $db->query($sql);
- print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])." \n";
- }
- }
- else
- {
- print 'ERROR';
- }
- }
+ print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])." \n";
+ }
+ }
+ else
+ {
+ print 'ERROR';
+ }
+ }
- if ($res > 0)
- {
- print $langs->trans('MigrationSuccessfullUpdate')." ";
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
- }
+ if ($res > 0)
+ {
+ print $langs->trans('MigrationSuccessfullUpdate')." ";
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
+ }
- $db->commit();
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
- }
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
- }
+ $db->commit();
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
+ }
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
+ }
- print ' ';
+ print '';
}
/**
* Corrige paiement orphelins (liens paumes suite a bugs)
* Pour verifier s'il reste des orphelins:
* select * 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)
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @return void
*/
function migrate_paiements_orphelins_2($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationPaymentsUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationPaymentsUpdate')." \n";
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement","fk_facture");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
- $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
- $sql.= " bu2.url_id as socid";
- $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)";
- $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid";
- $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')";
- $sql.= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid";
- $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)";
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement","fk_facture");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
+ $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
+ $sql.= " bu2.url_id as socid";
+ $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)";
+ $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid";
+ $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')";
+ $sql.= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid";
+ $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)";
- $resql = $db->query($sql);
+ $resql = $db->query($sql);
- dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_2 sql=".$sql);
- $row = array();
- if ($resql)
- {
- $i = $j = 0;
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_2 sql=".$sql);
+ $row = array();
+ if ($resql)
+ {
+ $i = $j = 0;
+ $num = $db->num_rows($resql);
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas
- {
- $row[$j]['paymentid'] = $obj->rowid ; // paymentid
- $row[$j]['pamount'] = $obj->pamount;
- $row[$j]['fk_bank'] = $obj->fk_bank;
- $row[$j]['bamount'] = $obj->bamount;
- $row[$j]['socid'] = $obj->socid;
- $row[$j]['datec'] = $obj->datec;
- $j++;
- }
- $i++;
- }
- }
- else
- {
- dol_print_error($db);
- }
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas
+ {
+ $row[$j]['paymentid'] = $obj->rowid ; // paymentid
+ $row[$j]['pamount'] = $obj->pamount;
+ $row[$j]['fk_bank'] = $obj->fk_bank;
+ $row[$j]['bamount'] = $obj->bamount;
+ $row[$j]['socid'] = $obj->socid;
+ $row[$j]['datec'] = $obj->datec;
+ $j++;
+ }
+ $i++;
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
- $nberr=0;
+ $nberr=0;
- $num=count($row);
- if ($num)
- {
- print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)." \n";
- $db->begin();
+ $num=count($row);
+ if ($num)
+ {
+ print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)." \n";
+ $db->begin();
- $res = 0;
- for ($i = 0; $i < $num; $i++)
- {
- if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
+ $res = 0;
+ for ($i = 0; $i < $num; $i++)
+ {
+ if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
- // On cherche facture sans lien paiement et du meme montant et pour meme societe.
- $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f";
- $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
- $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount'];
- $sql.=" AND pf.fk_facture IS NULL";
- $sql.=" ORDER BY f.fk_statut";
- //print $sql.' ';
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- //print 'Nb of invoice found for this amount and company :'.$num.' ';
- if ($num >= 1)
- {
- $obj=$db->fetch_object($resql);
- $facid=$obj->rowid;
+ // On cherche facture sans lien paiement et du meme montant et pour meme societe.
+ $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
+ $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount'];
+ $sql.=" AND pf.fk_facture IS NULL";
+ $sql.=" ORDER BY f.fk_statut";
+ //print $sql.' ';
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ //print 'Nb of invoice found for this amount and company :'.$num.' ';
+ if ($num >= 1)
+ {
+ $obj=$db->fetch_object($resql);
+ $facid=$obj->rowid;
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
- $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")";
- $res += $db->query($sql);
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
+ $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")";
+ $res += $db->query($sql);
- print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])." \n";
- }
- }
- else
- {
- print 'ERROR';
- $nberr++;
- }
- }
+ print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])." \n";
+ }
+ }
+ else
+ {
+ print 'ERROR';
+ $nberr++;
+ }
+ }
- if ($res > 0)
- {
- print $langs->trans('MigrationSuccessfullUpdate')." ";
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
- }
+ if ($res > 0)
+ {
+ print $langs->trans('MigrationSuccessfullUpdate')." ";
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
+ }
- $db->commit();
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
- }
+ $db->commit();
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
+ }
- // Delete obsolete fields fk_facture
- $db->begin();
+ // Delete obsolete fields fk_facture
+ $db->begin();
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiement DROP COLUMN fk_facture";
- $db->query($sql);
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiement DROP COLUMN fk_facture";
+ $db->query($sql);
- if (!$nberr)
- {
- $db->commit();
- }
- else
- {
- print 'ERROR';
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
- }
+ if (!$nberr)
+ {
+ $db->commit();
+ }
+ else
+ {
+ print 'ERROR';
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
+ }
- print ' ';
+ print '';
}
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)
- Poru chaque rep, test si
- select count(*) from llx_bank where rowid = obj->fk_bank
- select count(*) from llx_bank_url where url_id = 128 and type='payment'
- Si partout 0, on efface ligne de llx_paiement
- */
+ /*
+ 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
+ select count(*) from llx_bank where rowid = obj->fk_bank
+ select count(*) from llx_bank_url where url_id = 128 and type='payment'
+ Si partout 0, on efface ligne de llx_paiement
+ */
}
@@ -707,168 +722,168 @@ function migrate_paiements_orphelins_3($db,$langs,$conf)
*/
function migrate_contracts_det($db,$langs,$conf)
{
- print '';
+ print ' ';
- $nberr=0;
+ $nberr=0;
- print ' ';
- print ''.$langs->trans('MigrationContractsUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationContractsUpdate')." \n";
- $sql = "SELECT c.rowid as cref, c.date_contrat, c.statut, c.mise_en_service, c.fin_validite, c.date_cloture, c.fk_product, c.fk_facture, c.fk_user_author,";
- $sql.= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid";
- $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p";
- $sql.= " ON c.fk_product = p.rowid";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd";
- $sql.= " ON c.rowid=cd.fk_contrat";
- $sql.= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL";
- $resql = $db->query($sql);
+ $sql = "SELECT c.rowid as cref, c.date_contrat, c.statut, c.mise_en_service, c.fin_validite, c.date_cloture, c.fk_product, c.fk_facture, c.fk_user_author,";
+ $sql.= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p";
+ $sql.= " ON c.fk_product = p.rowid";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd";
+ $sql.= " ON c.rowid=cd.fk_contrat";
+ $sql.= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL";
+ $resql = $db->query($sql);
- dolibarr_install_syslog("upgrade2::migrate_contracts_det sql=".$sql);
- if ($resql)
- {
- $i = 0;
- $row = array();
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2::migrate_contracts_det sql=".$sql);
+ if ($resql)
+ {
+ $i = 0;
+ $row = array();
+ $num = $db->num_rows($resql);
- if ($num)
- {
- print $langs->trans('MigrationContractsNumberToUpdate', $num)." \n";
- $db->begin();
+ if ($num)
+ {
+ print $langs->trans('MigrationContractsNumberToUpdate', $num)." \n";
+ $db->begin();
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet (";
- $sql.= "fk_contrat, fk_product, statut, label, description,";
- $sql.= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,";
- $sql.= "subprice, price_ht, fk_user_author, fk_user_ouverture)";
- $sql.= " VALUES (";
- $sql.= $obj->cref.",".($obj->fk_product?$obj->fk_product:0).",";
- $sql.= ($obj->mise_en_service?"4":"0").",";
- $sql.= "'".$db->escape($obj->label)."', null,";
- $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":($obj->date_contrat?"'".$obj->date_contrat."'":"null")).",";
- $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":"null").",";
- $sql.= ($obj->fin_validite?"'".$obj->fin_validite."'":"null").",";
- $sql.= "'".$obj->tva_tx."', 1,";
- $sql.= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.",";
- $sql.= ($obj->mise_en_service?$obj->fk_user_author:"null");
- $sql.= ")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet (";
+ $sql.= "fk_contrat, fk_product, statut, label, description,";
+ $sql.= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,";
+ $sql.= "subprice, price_ht, fk_user_author, fk_user_ouverture)";
+ $sql.= " VALUES (";
+ $sql.= $obj->cref.",".($obj->fk_product?$obj->fk_product:0).",";
+ $sql.= ($obj->mise_en_service?"4":"0").",";
+ $sql.= "'".$db->escape($obj->label)."', null,";
+ $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":($obj->date_contrat?"'".$obj->date_contrat."'":"null")).",";
+ $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":"null").",";
+ $sql.= ($obj->fin_validite?"'".$obj->fin_validite."'":"null").",";
+ $sql.= "'".$obj->tva_tx."', 1,";
+ $sql.= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.",";
+ $sql.= ($obj->mise_en_service?$obj->fk_user_author:"null");
+ $sql.= ")";
- if ($db->query($sql))
- {
- print $langs->trans('MigrationContractsLineCreation', $obj->cref)." \n";
- }
- else
- {
- dol_print_error($db);
- $nberr++;
- }
+ if ($db->query($sql))
+ {
+ print $langs->trans('MigrationContractsLineCreation', $obj->cref)." \n";
+ }
+ else
+ {
+ dol_print_error($db);
+ $nberr++;
+ }
- $i++;
- }
+ $i++;
+ }
- if (! $nberr)
- {
- // $db->rollback();
- $db->commit();
- print $langs->trans('MigrationSuccessfullUpdate')." ";
- }
- else
- {
- $db->rollback();
- print $langs->trans('MigrationUpdateFailed').' ';
- }
- }
- else
- {
- print $langs->trans('MigrationContractsNothingToUpdate')." \n";
- }
- }
- else
- {
- print $langs->trans('MigrationContractsFieldDontExist')." \n";
- // dol_print_error($db);
- }
+ if (! $nberr)
+ {
+ // $db->rollback();
+ $db->commit();
+ print $langs->trans('MigrationSuccessfullUpdate')." ";
+ }
+ else
+ {
+ $db->rollback();
+ print $langs->trans('MigrationUpdateFailed').' ';
+ }
+ }
+ else
+ {
+ print $langs->trans('MigrationContractsNothingToUpdate')." \n";
+ }
+ }
+ else
+ {
+ print $langs->trans('MigrationContractsFieldDontExist')." \n";
+ // dol_print_error($db);
+ }
- print ' ';
+ print '';
}
function migrate_links_transfert($db,$langs,$conf)
{
- print '';
+ print ' ';
- $nberr=0;
+ $nberr=0;
- print ' ';
- print ''.$langs->trans('MigrationBankTransfertsUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationBankTransfertsUpdate')." \n";
- $sql = "SELECT ba.rowid as barowid, bb.rowid as bbrowid";
- $sql.= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid";
- $sql.= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account";
- $sql.= " AND ba.datev = bb.datev AND ba.datec = bb.datec";
- $sql.= " AND bu.fk_bank IS NULL";
- $resql = $db->query($sql);
+ $sql = "SELECT ba.rowid as barowid, bb.rowid as bbrowid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid";
+ $sql.= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account";
+ $sql.= " AND ba.datev = bb.datev AND ba.datec = bb.datec";
+ $sql.= " AND bu.fk_bank IS NULL";
+ $resql = $db->query($sql);
- dolibarr_install_syslog("upgrade2::migrate_links_transfert sql=".$sql);
- if ($resql)
- {
- $i = 0;
- $row = array();
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2::migrate_links_transfert sql=".$sql);
+ if ($resql)
+ {
+ $i = 0;
+ $row = array();
+ $num = $db->num_rows($resql);
- if ($num)
- {
- print $langs->trans('MigrationBankTransfertsToUpdate', $num)." \n";
- $db->begin();
+ if ($num)
+ {
+ print $langs->trans('MigrationBankTransfertsToUpdate', $num)." \n";
+ $db->begin();
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (";
- $sql.= "fk_bank, url_id, url, label, type";
- $sql.= ")";
- $sql.= " VALUES (";
- $sql.= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'";
- $sql.= ")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (";
+ $sql.= "fk_bank, url_id, url, label, type";
+ $sql.= ")";
+ $sql.= " VALUES (";
+ $sql.= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'";
+ $sql.= ")";
- print $sql.' ';
- dolibarr_install_syslog("migrate_links_transfert sql=".$sql);
+ print $sql.' ';
+ dolibarr_install_syslog("migrate_links_transfert sql=".$sql);
- if (! $db->query($sql))
- {
- dol_print_error($db);
- $nberr++;
- }
+ if (! $db->query($sql))
+ {
+ dol_print_error($db);
+ $nberr++;
+ }
- $i++;
- }
+ $i++;
+ }
- if (! $nberr)
- {
- // $db->rollback();
- $db->commit();
- print $langs->trans('MigrationSuccessfullUpdate')." ";
- }
- else
- {
- $db->rollback();
- print $langs->trans('MigrationUpdateFailed').' ';
- }
- }
- else {
- print $langs->trans('MigrationBankTransfertsNothingToUpdate')." \n";
- }
- }
- else
- {
- dol_print_error($db);
- }
+ if (! $nberr)
+ {
+ // $db->rollback();
+ $db->commit();
+ print $langs->trans('MigrationSuccessfullUpdate')." ";
+ }
+ else
+ {
+ $db->rollback();
+ print $langs->trans('MigrationUpdateFailed').' ';
+ }
+ }
+ else {
+ print $langs->trans('MigrationBankTransfertsNothingToUpdate')." \n";
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
- print ' ';
+ print '';
}
/*
@@ -876,30 +891,30 @@ function migrate_links_transfert($db,$langs,$conf)
*/
function migrate_contracts_date1($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')." \n";
- $sql="update llx_contrat set date_contrat=tms where date_contrat is null";
- dolibarr_install_syslog("upgrade2::migrate_contracts_date1 sql=".$sql);
- $resql = $db->query($sql);
- if (! $resql) dol_print_error($db);
- if ($db->affected_rows($resql) > 0)
- print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')." \n";
- else
- print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')." \n";
+ $sql="update llx_contrat set date_contrat=tms where date_contrat is null";
+ dolibarr_install_syslog("upgrade2::migrate_contracts_date1 sql=".$sql);
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+ if ($db->affected_rows($resql) > 0)
+ print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')." \n";
+ else
+ print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')." \n";
- $sql="update llx_contrat set datec=tms where datec is null";
- dolibarr_install_syslog("upgrade2::migrate_contracts_date1 sql=".$sql);
- $resql = $db->query($sql);
- if (! $resql) dol_print_error($db);
- if ($db->affected_rows($resql) > 0)
- print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')." \n";
- else
- print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')." \n";
+ $sql="update llx_contrat set datec=tms where datec is null";
+ dolibarr_install_syslog("upgrade2::migrate_contracts_date1 sql=".$sql);
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+ if ($db->affected_rows($resql) > 0)
+ print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')." \n";
+ else
+ print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')." \n";
- print ' ';
+ print '';
}
/*
@@ -907,63 +922,63 @@ function migrate_contracts_date1($db,$langs,$conf)
*/
function migrate_contracts_date2($db,$langs,$conf)
{
- print '';
+ print ' ';
- $nberr=0;
+ $nberr=0;
- print ' ';
- print ''.$langs->trans('MigrationContractsInvalidDatesUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationContractsInvalidDatesUpdate')." \n";
- $sql = "SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin";
- $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c,";
- $sql.= " ".MAIN_DB_PREFIX."contratdet as cd";
- $sql.= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL";
- $sql.= " GROUP BY c.rowid, c.date_contrat";
- $resql = $db->query($sql);
+ $sql = "SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin";
+ $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c,";
+ $sql.= " ".MAIN_DB_PREFIX."contratdet as cd";
+ $sql.= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL";
+ $sql.= " GROUP BY c.rowid, c.date_contrat";
+ $resql = $db->query($sql);
- dolibarr_install_syslog("upgrade2::migrate_contracts_date2 sql=".$sql);
- if ($resql)
- {
- $i = 0;
- $row = array();
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2::migrate_contracts_date2 sql=".$sql);
+ if ($resql)
+ {
+ $i = 0;
+ $row = array();
+ $num = $db->num_rows($resql);
- if ($num)
- {
- $nbcontratsmodifie=0;
- $db->begin();
+ if ($num)
+ {
+ $nbcontratsmodifie=0;
+ $db->begin();
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- if ($obj->date_contrat > $obj->datemin)
- {
- print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)." \n";
- $sql ="UPDATE ".MAIN_DB_PREFIX."contrat";
- $sql.=" SET date_contrat='".$obj->datemin."'";
- $sql.=" WHERE rowid=".$obj->cref;
- $resql2=$db->query($sql);
- if (! $resql2) dol_print_error($db);
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj->date_contrat > $obj->datemin)
+ {
+ print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)." \n";
+ $sql ="UPDATE ".MAIN_DB_PREFIX."contrat";
+ $sql.=" SET date_contrat='".$obj->datemin."'";
+ $sql.=" WHERE rowid=".$obj->cref;
+ $resql2=$db->query($sql);
+ if (! $resql2) dol_print_error($db);
- $nbcontratsmodifie++;
- }
- $i++;
- }
+ $nbcontratsmodifie++;
+ }
+ $i++;
+ }
- $db->commit();
+ $db->commit();
- if ($nbcontratsmodifie)
- print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)." \n";
- else
- print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')." \n";
- }
- }
- else
- {
- dol_print_error($db);
- }
+ if ($nbcontratsmodifie)
+ print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)." \n";
+ else
+ print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')." \n";
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
- print ' ';
+ print '';
}
/*
@@ -971,21 +986,21 @@ function migrate_contracts_date2($db,$langs,$conf)
*/
function migrate_contracts_date3($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')." \n";
- $sql="update llx_contrat set datec=date_contrat where datec is null or datec > date_contrat";
- dolibarr_install_syslog("upgrade2::migrate_contracts_date3 sql=".$sql);
- $resql = $db->query($sql);
- if (! $resql) dol_print_error($db);
- if ($db->affected_rows($resql) > 0)
- print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')." \n";
- else
- print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')." \n";
+ $sql="update llx_contrat set datec=date_contrat where datec is null or datec > date_contrat";
+ dolibarr_install_syslog("upgrade2::migrate_contracts_date3 sql=".$sql);
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+ if ($db->affected_rows($resql) > 0)
+ print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')." \n";
+ else
+ print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')." \n";
- print ' ';
+ print '';
}
/*
@@ -993,165 +1008,170 @@ function migrate_contracts_date3($db,$langs,$conf)
*/
function migrate_contracts_open($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationReopeningContracts')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationReopeningContracts')." \n";
- $sql = "SELECT c.rowid as cref FROM llx_contrat as c, llx_contratdet as cd";
- $sql.= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat";
- dolibarr_install_syslog("upgrade2::migrate_contracts_open sql=".$sql);
- $resql = $db->query($sql);
- if (! $resql) dol_print_error($db);
- if ($db->affected_rows($resql) > 0) {
- $i = 0;
- $row = array();
- $num = $db->num_rows($resql);
+ $sql = "SELECT c.rowid as cref FROM llx_contrat as c, llx_contratdet as cd";
+ $sql.= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat";
+ dolibarr_install_syslog("upgrade2::migrate_contracts_open sql=".$sql);
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+ if ($db->affected_rows($resql) > 0) {
+ $i = 0;
+ $row = array();
+ $num = $db->num_rows($resql);
- if ($num)
- {
- $nbcontratsmodifie=0;
- $db->begin();
+ if ($num)
+ {
+ $nbcontratsmodifie=0;
+ $db->begin();
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- print $langs->trans('MigrationReopenThisContract', $obj->cref)." \n";
- $sql ="UPDATE ".MAIN_DB_PREFIX."contrat";
- $sql.=" SET statut=1";
- $sql.=" WHERE rowid=".$obj->cref;
- $resql2=$db->query($sql);
- if (! $resql2) dol_print_error($db);
+ print $langs->trans('MigrationReopenThisContract', $obj->cref)." \n";
+ $sql ="UPDATE ".MAIN_DB_PREFIX."contrat";
+ $sql.=" SET statut=1";
+ $sql.=" WHERE rowid=".$obj->cref;
+ $resql2=$db->query($sql);
+ if (! $resql2) dol_print_error($db);
- $nbcontratsmodifie++;
+ $nbcontratsmodifie++;
- $i++;
- }
+ $i++;
+ }
- $db->commit();
+ $db->commit();
- if ($nbcontratsmodifie)
- print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)." \n";
- else
- print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
- }
- }
- else print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
+ if ($nbcontratsmodifie)
+ print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)." \n";
+ else
+ print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
+ }
+ }
+ else print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
- print ' ';
+ print '';
}
/**
* Factures fournisseurs
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @return void
*/
function migrate_paiementfourn_facturefourn($db,$langs,$conf)
{
- global $bc;
+ global $bc;
- print '';
- print ' ';
- print ''.$langs->trans('SuppliersInvoices')." \n";
- print ' ';
+ print '';
+ print ' ';
+ print ''.$langs->trans('SuppliersInvoices')." \n";
+ print ' ';
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiementfourn","fk_facture_fourn");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- $error=0;
- $nb=0;
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiementfourn","fk_facture_fourn");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $error=0;
+ $nb=0;
- $select_sql = 'SELECT rowid, fk_facture_fourn, amount';
- $select_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn';
- $select_sql.= ' WHERE fk_facture_fourn IS NOT NULL';
+ $select_sql = 'SELECT rowid, fk_facture_fourn, amount';
+ $select_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn';
+ $select_sql.= ' WHERE fk_facture_fourn IS NOT NULL';
- dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn sql=".$select_sql);
- $select_resql = $db->query($select_sql);
- if ($select_resql)
- {
- $select_num = $db->num_rows($select_resql);
- $i=0;
- $var = true;
+ dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn sql=".$select_sql);
+ $select_resql = $db->query($select_sql);
+ if ($select_resql)
+ {
+ $select_num = $db->num_rows($select_resql);
+ $i=0;
+ $var = true;
- // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn
- while (($i < $select_num) && (! $error))
- {
- $var = !$var;
- $select_obj = $db->fetch_object($select_resql);
+ // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn
+ while (($i < $select_num) && (! $error))
+ {
+ $var = !$var;
+ $select_obj = $db->fetch_object($select_resql);
- // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons.
- $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn';
- $check_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn';
- $check_sql.= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn;
- $check_resql = $db->query($check_sql);
- if ($check_resql)
- {
- $check_num = $db->num_rows($check_resql);
- if ($check_num == 0)
- {
- $db->begin();
+ // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons.
+ $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn';
+ $check_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn';
+ $check_sql.= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn;
+ $check_resql = $db->query($check_sql);
+ if ($check_resql)
+ {
+ $check_num = $db->num_rows($check_resql);
+ if ($check_num == 0)
+ {
+ $db->begin();
- if ($nb == 0)
- {
- print ''.$langs->trans('SuppliersInvoices').' ';
- print 'fk_paiementfourn fk_facturefourn '.$langs->trans('Amount').' ';
- }
+ if ($nb == 0)
+ {
+ print ''.$langs->trans('SuppliersInvoices').' ';
+ print 'fk_paiementfourn fk_facturefourn '.$langs->trans('Amount').' ';
+ }
- print '';
- print ''.$select_obj->rowid.' '.$select_obj->fk_facture_fourn.' '.$select_obj->amount.' ';
+ print ' ';
+ print ''.$select_obj->rowid.' '.$select_obj->fk_facture_fourn.' '.$select_obj->amount.' ';
- $insert_sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn SET ';
- $insert_sql.= ' fk_paiementfourn = \''.$select_obj->rowid.'\',';
- $insert_sql.= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\',';
- $insert_sql.= ' amount = \''.$select_obj->amount.'\'';
- $insert_resql = $db->query($insert_sql);
+ $insert_sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn SET ';
+ $insert_sql.= ' fk_paiementfourn = \''.$select_obj->rowid.'\',';
+ $insert_sql.= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\',';
+ $insert_sql.= ' amount = \''.$select_obj->amount.'\'';
+ $insert_resql = $db->query($insert_sql);
- if ($insert_resql)
- {
- $nb++;
- print ''.$langs->trans("OK").' ';
- }
- else
- {
- print 'Error on insert ';
- $error++;
- }
- print ' ';
- }
- }
- else
- {
- $error++;
- }
- $i++;
- }
- }
- else
- {
- $error++;
- }
+ if ($insert_resql)
+ {
+ $nb++;
+ print ''.$langs->trans("OK").' ';
+ }
+ else
+ {
+ print 'Error on insert ';
+ $error++;
+ }
+ print '';
+ }
+ }
+ else
+ {
+ $error++;
+ }
+ $i++;
+ }
+ }
+ else
+ {
+ $error++;
+ }
- if (!$error)
- {
- if (!$nb)
- {
- print ''.$langs->trans("AlreadyDone").' ';
- }
- $db->commit();
+ if (!$error)
+ {
+ if (!$nb)
+ {
+ print ''.$langs->trans("AlreadyDone").' ';
+ }
+ $db->commit();
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiementfourn DROP COLUMN fk_facture_fourn";
- $db->query($sql);
- }
- else
- {
- print ''.$langs->trans("Error").' ';
- $db->rollback();
- }
- }
- else
- {
- print ''.$langs->trans("AlreadyDone").' ';
- }
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiementfourn DROP COLUMN fk_facture_fourn";
+ $db->query($sql);
+ }
+ else
+ {
+ print ''.$langs->trans("Error").' ';
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print ''.$langs->trans("AlreadyDone").' ';
+ }
}
/*
@@ -1159,110 +1179,110 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
*/
function migrate_price_facture($db,$langs,$conf)
{
- $err=0;
+ $err=0;
$db->begin();
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationInvoice')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationInvoice')." \n";
- // Liste des lignes facture non a jour
- $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as tva_taux, fd.total_ttc, fd.info_bits,";
- $sql.= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f";
- $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f";
- $sql.= " WHERE fd.fk_facture = f.rowid";
- $sql.= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)";
- //print $sql;
+ // Liste des lignes facture non a jour
+ $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as tva_taux, fd.total_ttc, fd.info_bits,";
+ $sql.= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f";
+ $sql.= " WHERE fd.fk_facture = f.rowid";
+ $sql.= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)";
+ //print $sql;
- dolibarr_install_syslog("upgrade2::migrate_price_facture sql=".$sql);
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ dolibarr_install_syslog("upgrade2::migrate_price_facture sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
- $total_ttc_f = $obj->total_ttc_f;
- $info_bits = $obj->info_bits;
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+ $total_ttc_f = $obj->total_ttc_f;
+ $info_bits = $obj->info_bits;
- // On met a jour les 3 nouveaux champs
- $facligne= new FactureLigne($db);
- $facligne->fetch($rowid);
+ // On met a jour les 3 nouveaux champs
+ $facligne= new FactureLigne($db);
+ $facligne->fetch($rowid);
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva, 0, 0,$remise_percent_global,'HT',$info_bits);
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva, 0, 0,$remise_percent_global,'HT',$info_bits);
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
- $facligne->total_ht = $total_ht;
- $facligne->total_tva = $total_tva;
- $facligne->total_ttc = $total_ttc;
+ $facligne->total_ht = $total_ht;
+ $facligne->total_tva = $total_tva;
+ $facligne->total_ttc = $total_ttc;
- dolibarr_install_syslog("upgrade2: Line $rowid: facid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $facligne->update_total();
+ dolibarr_install_syslog("upgrade2: Line $rowid: facid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $facligne->update_total();
- /* On touche a facture mere uniquement si total_ttc = 0 */
- if (! $total_ttc_f)
- {
- $facture = new Facture($db);
- $facture->id=$obj->facid;
+ /* On touche a facture mere uniquement si total_ttc = 0 */
+ if (! $total_ttc_f)
+ {
+ $facture = new Facture($db);
+ $facture->id=$obj->facid;
- if ( $facture->fetch($facture->id) >= 0)
- {
- if ( $facture->update_price() > 0 )
- {
- //print $facture->id;
- }
- else
- {
- print "Error id=".$facture->id;
- $err++;
- }
- }
- else
- {
- print "Error #3";
- $err++;
- }
- }
- print " ";
+ if ( $facture->fetch($facture->id) >= 0)
+ {
+ if ( $facture->update_price() > 0 )
+ {
+ //print $facture->id;
+ }
+ else
+ {
+ print "Error id=".$facture->id;
+ $err++;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ }
+ print " ";
- $i++;
- }
- }
- else
- {
- print $langs->trans("AlreadyDone");
- }
- $db->free($resql);
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans("AlreadyDone");
+ }
+ $db->free($resql);
- $db->commit();
- }
- else
- {
- print "Error #1 ".$db->error();
- $err++;
+ $db->commit();
+ }
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
- $db->rollback();
- }
+ $db->rollback();
+ }
- print ' ';
+ print ' ';
- print ' ';
+ print '';
}
/*
@@ -1270,102 +1290,102 @@ function migrate_price_facture($db,$langs,$conf)
*/
function migrate_price_propal($db,$langs,$conf)
{
- $db->begin();
+ $db->begin();
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationProposal')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationProposal')." \n";
- // Liste des lignes propal non a jour
- $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as tva_taux, pd.info_bits,";
- $sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global";
- $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p";
- $sql.= " WHERE pd.fk_propal = p.rowid";
- $sql.= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)";
+ // Liste des lignes propal non a jour
+ $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as tva_taux, pd.info_bits,";
+ $sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global";
+ $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p";
+ $sql.= " WHERE pd.fk_propal = p.rowid";
+ $sql.= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)";
- dolibarr_install_syslog("upgrade2::migrate_price_propal sql=".$sql);
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ dolibarr_install_syslog("upgrade2::migrate_price_propal sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
- $info_bits = $obj->info_bits;
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+ $info_bits = $obj->info_bits;
- // On met a jour les 3 nouveaux champs
- $propalligne= new PropaleLigne($db);
- $propalligne->fetch($rowid);
+ // On met a jour les 3 nouveaux champs
+ $propalligne= new PropaleLigne($db);
+ $propalligne->fetch($rowid);
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
- $propalligne->total_ht = $total_ht;
- $propalligne->total_tva = $total_tva;
- $propalligne->total_ttc = $total_ttc;
+ $propalligne->total_ht = $total_ht;
+ $propalligne->total_tva = $total_tva;
+ $propalligne->total_ttc = $total_ttc;
- dolibarr_install_syslog("upgrade2: Line $rowid: propalid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $propalligne->update_total($rowid);
+ dolibarr_install_syslog("upgrade2: Line $rowid: propalid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $propalligne->update_total($rowid);
- /* On touche pas a propal mere
- $propal = new Propal($db);
- $propal->id=$obj->rowid;
- if ( $propal->fetch($propal->id) >= 0 )
- {
- if ( $propal->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$propal->id;
- $err++;
- }
- }
- else
- {
- print "Error #3";
- $err++;
- }
- */
- $i++;
- }
- }
- else
- {
- print $langs->trans("AlreadyDone");
- }
+ /* On touche pas a propal mere
+ $propal = new Propal($db);
+ $propal->id=$obj->rowid;
+ if ( $propal->fetch($propal->id) >= 0 )
+ {
+ if ( $propal->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$propal->id;
+ $err++;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans("AlreadyDone");
+ }
- $db->free($resql);
+ $db->free($resql);
- $db->commit();
- }
- else
- {
- print "Error #1 ".$db->error();
- $err++;
+ $db->commit();
+ }
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
- $db->rollback();
- }
+ $db->rollback();
+ }
- print ' ';
+ print ' ';
- print ' ';
+ print '';
}
/*
@@ -1373,103 +1393,103 @@ function migrate_price_propal($db,$langs,$conf)
*/
function migrate_price_contrat($db,$langs,$conf)
{
- $db->begin();
+ $db->begin();
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationContract')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationContract')." \n";
- // Liste des lignes contrat non a jour
- $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
- $sql.= " c.rowid as contratid";
- $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
- $sql.= " WHERE cd.fk_contrat = c.rowid";
- $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)";
+ // Liste des lignes contrat non a jour
+ $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
+ $sql.= " c.rowid as contratid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
+ $sql.= " WHERE cd.fk_contrat = c.rowid";
+ $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)";
- dolibarr_install_syslog("upgrade2::migrate_price_contrat sql=".$sql);
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ dolibarr_install_syslog("upgrade2::migrate_price_contrat sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
- $info_bits = $obj->info_bits;
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+ $info_bits = $obj->info_bits;
- // On met a jour les 3 nouveaux champs
- $contratligne= new ContratLigne($db);
- //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis
- $contratligne->rowid=$rowid;
+ // On met a jour les 3 nouveaux champs
+ $contratligne= new ContratLigne($db);
+ //$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,$remise_percent_global,'HT',$info_bits);
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
- $contratligne->total_ht = $total_ht;
- $contratligne->total_tva = $total_tva;
- $contratligne->total_ttc = $total_ttc;
+ $contratligne->total_ht = $total_ht;
+ $contratligne->total_tva = $total_tva;
+ $contratligne->total_ttc = $total_ttc;
- dolibarr_install_syslog("upgrade2: Line $rowid: contratdetid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $contratligne->update_total($rowid);
+ dolibarr_install_syslog("upgrade2: Line $rowid: contratdetid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $contratligne->update_total($rowid);
- /* On touche pas a contrat mere
- $propal = new Propal($db);
- $propal->id=$obj->rowid;
- if ( $propal->fetch($propal->id) >= 0 )
- {
- if ( $propal->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$propal->id;
- $err++;
- }
- }
- else
- {
- print "Error #3";
- $err++;
- }
- */
- $i++;
- }
- }
- else
- {
- print $langs->trans("AlreadyDone");
- }
+ /* On touche pas a contrat mere
+ $propal = new Propal($db);
+ $propal->id=$obj->rowid;
+ if ( $propal->fetch($propal->id) >= 0 )
+ {
+ if ( $propal->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$propal->id;
+ $err++;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans("AlreadyDone");
+ }
- $db->free($resql);
+ $db->free($resql);
- $db->commit();
- }
- else
- {
- print "Error #1 ".$db->error();
- $err++;
+ $db->commit();
+ }
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
- $db->rollback();
- }
+ $db->rollback();
+ }
- print ' ';
+ print ' ';
- print ' ';
+ print '';
}
/*
@@ -1477,111 +1497,111 @@ function migrate_price_contrat($db,$langs,$conf)
*/
function migrate_price_commande($db,$langs,$conf)
{
- $db->begin();
+ $db->begin();
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationOrder')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationOrder')." \n";
- // Liste des lignes commande non a jour
- $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
- $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
- $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c";
- $sql.= " WHERE cd.fk_commande = c.rowid";
- $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
+ // Liste des lignes commande non a jour
+ $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
+ $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c";
+ $sql.= " WHERE cd.fk_commande = c.rowid";
+ $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
- dolibarr_install_syslog("upgrade2::migrate_price_commande sql=".$sql);
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ dolibarr_install_syslog("upgrade2::migrate_price_commande sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
- $info_bits = $obj->info_bits;
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+ $info_bits = $obj->info_bits;
- // On met a jour les 3 nouveaux champs
- $commandeligne= new OrderLine($db);
- $commandeligne->fetch($rowid);
+ // On met a jour les 3 nouveaux champs
+ $commandeligne= new OrderLine($db);
+ $commandeligne->fetch($rowid);
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
- $commandeligne->total_ht = $total_ht;
- $commandeligne->total_tva = $total_tva;
- $commandeligne->total_ttc = $total_ttc;
+ $commandeligne->total_ht = $total_ht;
+ $commandeligne->total_tva = $total_tva;
+ $commandeligne->total_ttc = $total_ttc;
- dolibarr_install_syslog("upgrade2: Line $rowid: commandeid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $commandeligne->update_total($rowid);
+ dolibarr_install_syslog("upgrade2: Line $rowid: commandeid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $commandeligne->update_total($rowid);
- /* On touche pas a facture mere
- $commande = new Commande($db);
- $commande->id = $obj->rowid;
- if ( $commande->fetch($commande->id) >= 0 )
- {
- if ( $commande->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$commande->id;
- $err++;
- }
- }
- else
- {
- print "Error #3";
- $err++;
- }
- */
- $i++;
- }
- }
- else
- {
- print $langs->trans("AlreadyDone");
- }
+ /* On touche pas a facture mere
+ $commande = new Commande($db);
+ $commande->id = $obj->rowid;
+ if ( $commande->fetch($commande->id) >= 0 )
+ {
+ if ( $commande->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$commande->id;
+ $err++;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans("AlreadyDone");
+ }
- $db->free($resql);
+ $db->free($resql);
- /*
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
- $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0";
- $resql=$db->query($sql);
- if (! $resql)
- {
- dol_print_error($db);
- }
- */
+ /*
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
+ $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0";
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($db);
+ }
+ */
- $db->commit();
- }
- else
- {
- print "Error #1 ".$db->error();
- $err++;
+ $db->commit();
+ }
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
- $db->rollback();
- }
+ $db->rollback();
+ }
- print ' ';
+ print ' ';
- print ' ';
+ print '';
}
/*
@@ -1589,111 +1609,111 @@ function migrate_price_commande($db,$langs,$conf)
*/
function migrate_price_commande_fournisseur($db,$langs,$conf)
{
- $db->begin();
+ $db->begin();
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationSupplierOrder')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationSupplierOrder')." \n";
- // Liste des lignes commande non a jour
- $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
- $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c";
- $sql.= " WHERE cd.fk_commande = c.rowid";
- $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
+ // Liste des lignes commande non a jour
+ $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
+ $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c";
+ $sql.= " WHERE cd.fk_commande = c.rowid";
+ $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
- dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur sql=".$sql);
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
- $info_bits = $obj->info_bits;
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+ $info_bits = $obj->info_bits;
- // On met a jour les 3 nouveaux champs
- $commandeligne= new CommandeFournisseurLigne($db);
- $commandeligne->fetch($rowid);
+ // On met a jour les 3 nouveaux champs
+ $commandeligne= new CommandeFournisseurLigne($db);
+ $commandeligne->fetch($rowid);
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
- $commandeligne->total_ht = $total_ht;
- $commandeligne->total_tva = $total_tva;
- $commandeligne->total_ttc = $total_ttc;
+ $commandeligne->total_ht = $total_ht;
+ $commandeligne->total_tva = $total_tva;
+ $commandeligne->total_ttc = $total_ttc;
- dolibarr_install_syslog("upgrade2: Line $rowid: commandeid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $commandeligne->update_total($rowid);
+ dolibarr_install_syslog("upgrade2: Line $rowid: commandeid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $commandeligne->update_total($rowid);
- /* On touche pas a facture mere
- $commande = new Commande($db);
- $commande->id = $obj->rowid;
- if ( $commande->fetch($commande->id) >= 0 )
- {
- if ( $commande->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$commande->id;
- $err++;
- }
- }
- else
- {
- print "Error #3";
- $err++;
- }
- */
- $i++;
- }
- }
- else
- {
- print $langs->trans("AlreadyDone");
- }
+ /* On touche pas a facture mere
+ $commande = new Commande($db);
+ $commande->id = $obj->rowid;
+ if ( $commande->fetch($commande->id) >= 0 )
+ {
+ if ( $commande->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$commande->id;
+ $err++;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans("AlreadyDone");
+ }
- $db->free($resql);
+ $db->free($resql);
- /*
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
- $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
- $resql=$db->query($sql);
- if (! $resql)
- {
- dol_print_error($db);
- }
- */
+ /*
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
+ $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($db);
+ }
+ */
- $db->commit();
- }
- else
- {
- print "Error #1 ".$db->error();
- $err++;
+ $db->commit();
+ }
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
- $db->rollback();
- }
+ $db->rollback();
+ }
- print ' ';
+ print ' ';
- print ' ';
+ print '';
}
/*
@@ -1701,51 +1721,51 @@ function migrate_price_commande_fournisseur($db,$langs,$conf)
*/
function migrate_modeles($db,$langs,$conf)
{
- //print ' ';
- //print ''.$langs->trans('UpdateModelsTable')." \n";
+ //print ' ';
+ //print ''.$langs->trans('UpdateModelsTable')." \n";
- dolibarr_install_syslog("upgrade2::migrate_modeles");
+ dolibarr_install_syslog("upgrade2::migrate_modeles");
- if (! empty($conf->facture->enabled))
- {
- include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php');
- $modellist=ModelePDFFactures::liste_modeles($db);
- if (count($modellist)==0)
- {
- // Aucun model par defaut.
- $sql=" insert into llx_document_model(nom,type) values('crabe','invoice')";
- $resql = $db->query($sql);
- if (! $resql) dol_print_error($db);
- }
- }
+ if (! empty($conf->facture->enabled))
+ {
+ include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php');
+ $modellist=ModelePDFFactures::liste_modeles($db);
+ if (count($modellist)==0)
+ {
+ // Aucun model par defaut.
+ $sql=" insert into llx_document_model(nom,type) values('crabe','invoice')";
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+ }
+ }
- if (! empty($conf->commande->enabled))
- {
- include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php');
- $modellist=ModelePDFCommandes::liste_modeles($db);
- if (count($modellist)==0)
- {
- // Aucun model par defaut.
- $sql=" insert into llx_document_model(nom,type) values('einstein','order')";
- $resql = $db->query($sql);
- if (! $resql) dol_print_error($db);
- }
- }
+ if (! empty($conf->commande->enabled))
+ {
+ include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php');
+ $modellist=ModelePDFCommandes::liste_modeles($db);
+ if (count($modellist)==0)
+ {
+ // Aucun model par defaut.
+ $sql=" insert into llx_document_model(nom,type) values('einstein','order')";
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+ }
+ }
- if (! empty($conf->expedition->enabled))
- {
- include_once(DOL_DOCUMENT_ROOT.'/includes/modules/expedition/pdf/ModelePdfExpedition.class.php');
- $modellist=ModelePDFExpedition::liste_modeles($db);
- if (count($modellist)==0)
- {
- // Aucun model par defaut.
- $sql=" insert into llx_document_model(nom,type) values('rouget','shipping')";
- $resql = $db->query($sql);
- if (! $resql) dol_print_error($db);
- }
- }
+ if (! empty($conf->expedition->enabled))
+ {
+ include_once(DOL_DOCUMENT_ROOT.'/includes/modules/expedition/pdf/ModelePdfExpedition.class.php');
+ $modellist=ModelePDFExpedition::liste_modeles($db);
+ if (count($modellist)==0)
+ {
+ // Aucun model par defaut.
+ $sql=" insert into llx_document_model(nom,type) values('rouget','shipping')";
+ $resql = $db->query($sql);
+ if (! $resql) dol_print_error($db);
+ }
+ }
- //print $langs->trans("AlreadyDone");
+ //print $langs->trans("AlreadyDone");
}
@@ -1754,71 +1774,71 @@ function migrate_modeles($db,$langs,$conf)
*/
function migrate_commande_expedition($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_commande_expedition");
+ dolibarr_install_syslog("upgrade2::migrate_commande_expedition");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationShipmentOrderMatching')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationShipmentOrderMatching')." \n";
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","fk_commande");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- $error = 0;
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","fk_commande");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $error = 0;
- $db->begin();
+ $db->begin();
- $sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e";
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)";
- $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
- $resql2=$db->query($sql);
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)";
+ $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
+ $resql2=$db->query($sql);
- if (!$resql2)
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
- }
+ if (!$resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ }
- if ($error == 0)
- {
- $db->commit();
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande";
- print $langs->trans('FieldRenamed')." \n";
- $db->query($sql);
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
- print ' ';
+ if ($error == 0)
+ {
+ $db->commit();
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande";
+ print $langs->trans('FieldRenamed')." \n";
+ $db->query($sql);
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ print '';
}
/*
@@ -1826,87 +1846,87 @@ function migrate_commande_expedition($db,$langs,$conf)
*/
function migrate_commande_livraison($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_commande_livraison");
+ dolibarr_install_syslog("upgrade2::migrate_commande_livraison");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationDeliveryOrderMatching')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationDeliveryOrderMatching')." \n";
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","fk_commande");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- $error = 0;
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","fk_commande");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $error = 0;
- $db->begin();
+ $db->begin();
- $sql = "SELECT l.rowid, l.fk_commande";
- $sql.= ", c.ref_client, c.date_livraison";
- $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
- $sql.= " WHERE c.rowid = l.fk_commande";
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $sql = "SELECT l.rowid, l.fk_commande";
+ $sql.= ", c.ref_client, c.date_livraison";
+ $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
+ $sql.= " WHERE c.rowid = l.fk_commande";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)";
- $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
- $resql2=$db->query($sql);
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)";
+ $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
+ $resql2=$db->query($sql);
- if ($resql2)
- {
- $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
- $sqlu.= " ref_client='".$obj->ref_client."'";
- $sqlu.= ", date_livraison='".$obj->date_livraison."'";
- $sqlu.= " WHERE rowid = ".$obj->rowid;
- $resql3=$db->query($sqlu);
- if (!$resql3)
- {
- $error++;
- dol_print_error($db);
- }
- }
- else
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
- }
+ if ($resql2)
+ {
+ $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
+ $sqlu.= " ref_client='".$obj->ref_client."'";
+ $sqlu.= ", date_livraison='".$obj->date_livraison."'";
+ $sqlu.= " WHERE rowid = ".$obj->rowid;
+ $resql3=$db->query($sqlu);
+ if (!$resql3)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ }
+ else
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ }
- if ($error == 0)
- {
- $db->commit();
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande";
- print $langs->trans('FieldRenamed')." \n";
- $db->query($sql);
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
- print ' ';
+ if ($error == 0)
+ {
+ $db->commit();
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande";
+ print $langs->trans('FieldRenamed')." \n";
+ $db->query($sql);
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ print '';
}
/*
@@ -1914,116 +1934,116 @@ function migrate_commande_livraison($db,$langs,$conf)
*/
function migrate_detail_livraison($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_detail_livraison");
+ dolibarr_install_syslog("upgrade2::migrate_detail_livraison");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationDeliveryDetail')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationDeliveryDetail')." \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");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- $error = 0;
+ // 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");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $error = 0;
- $db->begin();
+ $db->begin();
- $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht";
- $sql.= ", ld.fk_livraison";
- $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
- $sql.= " WHERE ld.fk_commande_ligne = cd.rowid";
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht";
+ $sql.= ", ld.fk_livraison";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
+ $sql.= " WHERE ld.fk_commande_ligne = cd.rowid";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET";
- $sql.= " fk_product=".$obj->fk_product;
- $sql.= ",description='".$db->escape($obj->description)."'";
- $sql.= ",subprice='".$obj->subprice."'";
- $sql.= ",total_ht='".$obj->total_ht."'";
- $sql.= " WHERE fk_commande_ligne = ".$obj->rowid;
- $resql2=$db->query($sql);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET";
+ $sql.= " fk_product=".$obj->fk_product;
+ $sql.= ",description='".$db->escape($obj->description)."'";
+ $sql.= ",subprice='".$obj->subprice."'";
+ $sql.= ",total_ht='".$obj->total_ht."'";
+ $sql.= " WHERE fk_commande_ligne = ".$obj->rowid;
+ $resql2=$db->query($sql);
- if ($resql2)
- {
- $sql = "SELECT total_ht";
- $sql.= " FROM ".MAIN_DB_PREFIX."livraison";
- $sql.= " WHERE rowid = ".$obj->fk_livraison;
- $resql3=$db->query($sql);
+ if ($resql2)
+ {
+ $sql = "SELECT total_ht";
+ $sql.= " FROM ".MAIN_DB_PREFIX."livraison";
+ $sql.= " WHERE rowid = ".$obj->fk_livraison;
+ $resql3=$db->query($sql);
- if ($resql3)
- {
- $obju = $db->fetch_object($resql3);
- $total_ht = $obju->total_ht + $obj->total_ht;
+ if ($resql3)
+ {
+ $obju = $db->fetch_object($resql3);
+ $total_ht = $obju->total_ht + $obj->total_ht;
- $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
- $sqlu.= " total_ht='".$total_ht."'";
- $sqlu.= " WHERE rowid=".$obj->fk_livraison;
- $resql4=$db->query($sqlu);
- if (!$resql4)
- {
- $error++;
- dol_print_error($db);
- }
- }
- else
- {
- $error++;
- dol_print_error($db);
- }
- }
- else
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
+ $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
+ $sqlu.= " total_ht='".$total_ht."'";
+ $sqlu.= " WHERE rowid=".$obj->fk_livraison;
+ $resql4=$db->query($sqlu);
+ if (!$resql4)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ }
+ else
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ }
+ else
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
- }
+ }
- if ($error == 0)
- {
- $db->commit();
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer";
- print $langs->trans('FieldRenamed')." \n";
- $db->query($sql);
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet","fk_origin_line");
- $obj = $db->fetch_object($result);
- if (!$obj)
- {
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison";
- $db->query($sql);
- }
- print $langs->trans('AlreadyDone')." \n";
- }
- print ' ';
+ if ($error == 0)
+ {
+ $db->commit();
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer";
+ print $langs->trans('FieldRenamed')." \n";
+ $db->query($sql);
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet","fk_origin_line");
+ $obj = $db->fetch_object($result);
+ if (!$obj)
+ {
+ $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison";
+ $db->query($sql);
+ }
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ print '';
}
/*
@@ -2031,68 +2051,68 @@ function migrate_detail_livraison($db,$langs,$conf)
*/
function migrate_stocks($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_stocks");
+ dolibarr_install_syslog("upgrade2::migrate_stocks");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationStockDetail')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationStockDetail')." \n";
- $error = 0;
+ $error = 0;
- $db->begin();
+ $db->begin();
- $sql = "SELECT SUM(reel) as total, fk_product";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
- $sql.= " GROUP BY fk_product";
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $sql = "SELECT SUM(reel) as total, fk_product";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
+ $sql.= " GROUP BY fk_product";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sql = "UPDATE ".MAIN_DB_PREFIX."product SET";
- $sql.= " stock = '".$obj->total."'";
- $sql.= " WHERE rowid=".$obj->fk_product;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."product SET";
+ $sql.= " stock = '".$obj->total."'";
+ $sql.= " WHERE rowid=".$obj->fk_product;
- $resql2=$db->query($sql);
- if ($resql2)
- {
+ $resql2=$db->query($sql);
+ if ($resql2)
+ {
- }
- else
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
+ }
+ else
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
- }
+ }
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
- print ' ';
+ print '';
}
/*
@@ -2100,75 +2120,75 @@ function migrate_stocks($db,$langs,$conf)
*/
function migrate_menus($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_menus");
+ dolibarr_install_syslog("upgrade2::migrate_menus");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationMenusDetail')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationMenusDetail')." \n";
- $error = 0;
+ $error = 0;
- if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint"))
- {
- $db->begin();
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint"))
+ {
+ $db->begin();
- $sql = "SELECT m.rowid, mc.action";
- $sql.= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m";
- $sql.= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid";
- $sql.= " AND m.enabled = '1'";
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ $sql = "SELECT m.rowid, mc.action";
+ $sql.= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m";
+ $sql.= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid";
+ $sql.= " AND m.enabled = '1'";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
- $sql.= " enabled = '".$obj->action."'";
- $sql.= " WHERE rowid=".$obj->rowid;
- $sql.= " AND enabled = '1'";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
+ $sql.= " enabled = '".$obj->action."'";
+ $sql.= " WHERE rowid=".$obj->rowid;
+ $sql.= " AND enabled = '1'";
- $resql2=$db->query($sql);
- if ($resql2)
- {
+ $resql2=$db->query($sql);
+ if ($resql2)
+ {
- }
- else
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
- }
+ }
+ else
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ }
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- print ' ';
+ print '';
}
/*
@@ -2177,77 +2197,77 @@ function migrate_menus($db,$langs,$conf)
*/
function migrate_commande_deliveryaddress($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_commande_deliveryaddress");
+ dolibarr_install_syslog("upgrade2::migrate_commande_deliveryaddress");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationDeliveryAddress')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationDeliveryAddress')." \n";
- $error = 0;
+ $error = 0;
- if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp"))
- {
- $db->begin();
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp"))
+ {
+ $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";
+ $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)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ 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;
+ $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
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ $resql2=$db->query($sql);
+ if (!$resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- print ' ';
+ print '';
}
/*
@@ -2256,152 +2276,152 @@ function migrate_commande_deliveryaddress($db,$langs,$conf)
*/
function migrate_restore_missing_links($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_restore_missing_links");
+ dolibarr_install_syslog("upgrade2::migrate_restore_missing_links");
- if (($db->type == 'mysql' || $db->type == 'mysqli'))
- {
- if (versioncompare($db->getVersionArray(),array(4,0)) < 0)
- {
- dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action");
- return 0;
- }
- }
- print '';
+ if (($db->type == 'mysql' || $db->type == 'mysqli'))
+ {
+ if (versioncompare($db->getVersionArray(),array(4,0)) < 0)
+ {
+ dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action");
+ return 0;
+ }
+ }
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationFixData')." (1) \n";
+ print ' ';
+ print ''.$langs->trans('MigrationFixData')." (1) \n";
- $error = 0;
+ $error = 0;
- // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1.
- $table1='facturedet'; $field1='fk_remise_except';
- $table2='societe_remise_except'; $field2='fk_facture_line';
+ // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1.
+ $table1='facturedet'; $field1='fk_remise_except';
+ $table2='societe_remise_except'; $field2='fk_facture_line';
- $db->begin();
+ $db->begin();
- $sql = "SELECT t1.rowid, t1.".$field1." as field";
- $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1";
- $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN";
- $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2";
- $sql.= " WHERE t1.rowid = t2.".$field2.")";
+ $sql = "SELECT t1.rowid, t1.".$field1." as field";
+ $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1";
+ $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN";
+ $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2";
+ $sql.= " WHERE t1.rowid = t2.".$field2.")";
- dolibarr_install_syslog("upgrade2:migrate_restore_missing_links DIRECTION 1 sql=".$sql);
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2:migrate_restore_missing_links DIRECTION 1 sql=".$sql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. ';
- $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET";
- $sql.= " ".$field2." = '".$obj->rowid."'";
- $sql.= " WHERE rowid=".$obj->field;
+ print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. ';
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET";
+ $sql.= " ".$field2." = '".$obj->rowid."'";
+ $sql.= " WHERE rowid=".$obj->field;
- $resql2=$db->query($sql);
- if (! $resql2)
- {
- $error++;
- dol_print_error($db);
- }
- //print ". ";
- $i++;
- }
+ $resql2=$db->query($sql);
+ if (! $resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ //print ". ";
+ $i++;
+ }
- }
- else print $langs->trans('AlreadyDone')." \n";
+ }
+ else print $langs->trans('AlreadyDone')." \n";
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
- print ' ';
+ print '';
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationFixData')." (2) \n";
+ print ' ';
+ print ''.$langs->trans('MigrationFixData')." (2) \n";
- // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2.
- $table2='facturedet'; $field2='fk_remise_except';
- $table1='societe_remise_except'; $field1='fk_facture_line';
+ // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2.
+ $table2='facturedet'; $field2='fk_remise_except';
+ $table1='societe_remise_except'; $field1='fk_facture_line';
- $db->begin();
+ $db->begin();
- $sql = "SELECT t1.rowid, t1.".$field1." as field";
- $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1";
- $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN";
- $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2";
- $sql.= " WHERE t1.rowid = t2.".$field2.")";
+ $sql = "SELECT t1.rowid, t1.".$field1." as field";
+ $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1";
+ $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN";
+ $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2";
+ $sql.= " WHERE t1.rowid = t2.".$field2.")";
- dolibarr_install_syslog("upgrade2:migrate_restore_missing_links DIRECTION 2 sql=".$sql);
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ dolibarr_install_syslog("upgrade2:migrate_restore_missing_links DIRECTION 2 sql=".$sql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. ';
- $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET";
- $sql.= " ".$field2." = '".$obj->rowid."'";
- $sql.= " WHERE rowid=".$obj->field;
+ print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. ';
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET";
+ $sql.= " ".$field2." = '".$obj->rowid."'";
+ $sql.= " WHERE rowid=".$obj->field;
- $resql2=$db->query($sql);
- if (! $resql2)
- {
- $error++;
- dol_print_error($db);
- }
- //print ". ";
- $i++;
- }
+ $resql2=$db->query($sql);
+ if (! $resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ //print ". ";
+ $i++;
+ }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
- print ' ';
+ print '';
}
/*
@@ -2409,91 +2429,91 @@ function migrate_restore_missing_links($db,$langs,$conf)
*/
function migrate_project_user_resp($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_project_user_resp");
+ dolibarr_install_syslog("upgrade2::migrate_project_user_resp");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationProjectUserResp')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationProjectUserResp')." \n";
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."projet","fk_user_resp");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- $error = 0;
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."projet","fk_user_resp");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ $error = 0;
- $db->begin();
+ $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);
+ $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);
+ 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.= ")";
+ $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 ". ";
+ if ($obj->fk_user_resp > 0)
+ {
+ $resql2=$db->query($sql2);
+ if (!$resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ }
+ print ". ";
- $i++;
- }
- }
+ $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')." \n";
- }
- print ' ';
+ 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')." \n";
+ }
+ print '';
}
/*
@@ -2501,86 +2521,86 @@ function migrate_project_user_resp($db,$langs,$conf)
*/
function migrate_project_task_actors($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_project_task_actors");
+ dolibarr_install_syslog("upgrade2::migrate_project_task_actors");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationProjectTaskActors')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationProjectTaskActors')." \n";
- if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors"))
- {
- $error = 0;
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors"))
+ {
+ $error = 0;
- $db->begin();
+ $db->begin();
- $sql = "SELECT fk_projet_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors";
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $sql = "SELECT fk_projet_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($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->fk_projet_task;
- $sql2.= ", '180'";
- $sql2.= ", ".$obj->fk_user;
- $sql2.= ")";
+ $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->fk_projet_task;
+ $sql2.= ", '180'";
+ $sql2.= ", ".$obj->fk_user;
+ $sql2.= ")";
- $resql2=$db->query($sql2);
+ $resql2=$db->query($sql2);
- if (!$resql2)
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
- }
+ if (!$resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ }
- if ($error == 0)
- {
- $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors";
- 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 ' ';
+ if ($error == 0)
+ {
+ $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors";
+ 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 '';
}
/*
@@ -2588,90 +2608,90 @@ function migrate_project_task_actors($db,$langs,$conf)
*/
function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcetype,$fk_target,$targettype)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationRelationshipTables',MAIN_DB_PREFIX.$table)." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationRelationshipTables',MAIN_DB_PREFIX.$table)." \n";
- $error = 0;
+ $error = 0;
- if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table))
- {
- dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table);
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table))
+ {
+ dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table);
- $db->begin();
+ $db->begin();
- $sqlSelect = "SELECT ".$fk_source.", ".$fk_target;
- $sqlSelect.= " FROM ".MAIN_DB_PREFIX.$table;
+ $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);
+ $resql = $db->query($sqlSelect);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($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.= ")";
+ $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";
- }
+ $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";
- }
+ 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 ' ';
+ print '';
}
/*
@@ -2679,115 +2699,115 @@ function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcet
*/
function migrate_project_task_time($db,$langs,$conf)
{
- dolibarr_install_syslog("upgrade2::migrate_project_task_time");
+ dolibarr_install_syslog("upgrade2::migrate_project_task_time");
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationProjectTaskTime')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationProjectTaskTime')." \n";
- $error = 0;
+ $error = 0;
- $db->begin();
+ $db->begin();
- $sql = "SELECT rowid, fk_task, task_duration";
- $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time";
- $resql = $db->query($sql);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $sql = "SELECT rowid, fk_task, task_duration";
+ $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- $totaltime = array();
- $oldtime = 0;
+ if ($num)
+ {
+ $totaltime = array();
+ $oldtime = 0;
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- if ($obj->task_duration > 0)
- {
- // convert to second
- // only for int time and float time ex: 1,75 for 1h45
- list($hour,$min) = explode('.',$obj->task_duration);
- $hour = $hour*60*60;
- $min = ($min/100)*60*60;
- $newtime = $hour+$min;
+ if ($obj->task_duration > 0)
+ {
+ // convert to second
+ // only for int time and float time ex: 1,75 for 1h45
+ list($hour,$min) = explode('.',$obj->task_duration);
+ $hour = $hour*60*60;
+ $min = ($min/100)*60*60;
+ $newtime = $hour+$min;
- $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
- $sql2.= " task_duration = ".$newtime;
- $sql2.= " WHERE rowid = ".$obj->rowid;
+ $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
+ $sql2.= " task_duration = ".$newtime;
+ $sql2.= " WHERE rowid = ".$obj->rowid;
- $resql2=$db->query($sql2);
- if (!$resql2)
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $oldtime++;
- if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime;
- else $totaltime[$obj->fk_task] = $newtime;
- }
- else
- {
- if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration;
- else $totaltime[$obj->fk_task] = $obj->task_duration;
- }
+ $resql2=$db->query($sql2);
+ if (!$resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $oldtime++;
+ if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime;
+ else $totaltime[$obj->fk_task] = $newtime;
+ }
+ else
+ {
+ if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration;
+ else $totaltime[$obj->fk_task] = $obj->task_duration;
+ }
- $i++;
- }
+ $i++;
+ }
- if ($error == 0)
- {
- if ($oldtime > 0)
- {
- foreach($totaltime as $taskid => $total_duration)
- {
- $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
- $sql.= " duration_effective = ".$total_duration;
- $sql.= " WHERE rowid = ".$taskid;
+ if ($error == 0)
+ {
+ if ($oldtime > 0)
+ {
+ foreach($totaltime as $taskid => $total_duration)
+ {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
+ $sql.= " duration_effective = ".$total_duration;
+ $sql.= " WHERE rowid = ".$taskid;
- $resql=$db->query($sql);
- if (!$resql)
- {
- $error++;
- dol_print_error($db);
- }
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
- }
- else
- {
- dol_print_error($db);
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
- }
- else
- {
- dol_print_error($db);
- }
+ $resql=$db->query($sql);
+ if (!$resql)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
- print ' ';
+ print '';
}
/*
@@ -2795,95 +2815,95 @@ function migrate_project_task_time($db,$langs,$conf)
*/
function migrate_customerorder_shipping($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationCustomerOrderShipping')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationCustomerOrderShipping')." \n";
- $error = 0;
+ $error = 0;
- $result1 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","ref_customer");
- $result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","date_delivery");
- $obj1 = $db->fetch_object($result1);
- $obj2 = $db->fetch_object($result2);
- if (!$obj1 && !$obj2)
- {
- dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping");
+ $result1 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","ref_customer");
+ $result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","date_delivery");
+ $obj1 = $db->fetch_object($result1);
+ $obj2 = $db->fetch_object($result2);
+ if (!$obj1 && !$obj2)
+ {
+ dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping");
- $db->begin();
+ $db->begin();
- $sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity";
- $sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition";
+ $sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity";
+ $sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition";
- if ($db->query($sqlAdd1) && $db->query($sqlAdd2))
- {
- $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison";
- $sqlSelect.= " FROM ".MAIN_DB_PREFIX."expedition as e";
- $sqlSelect.= ", ".MAIN_DB_PREFIX."element_element as el";
- $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'";
- $sqlSelect.= " WHERE e.rowid = el.fk_target";
- $sqlSelect.= " AND el.targettype = 'shipping'";
+ if ($db->query($sqlAdd1) && $db->query($sqlAdd2))
+ {
+ $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison";
+ $sqlSelect.= " FROM ".MAIN_DB_PREFIX."expedition as e";
+ $sqlSelect.= ", ".MAIN_DB_PREFIX."element_element as el";
+ $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'";
+ $sqlSelect.= " WHERE e.rowid = el.fk_target";
+ $sqlSelect.= " AND el.targettype = 'shipping'";
- $resql = $db->query($sqlSelect);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $resql = $db->query($sqlSelect);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
- $sqlUpdate.= " ref_customer = '".$obj->ref_client."'";
- $sqlUpdate.= ", date_delivery = '".($obj->date_livraison?$obj->date_livraison:'null')."'";
- $sqlUpdate.= " WHERE rowid = ".$obj->shipping_id;
+ $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
+ $sqlUpdate.= " ref_customer = '".$obj->ref_client."'";
+ $sqlUpdate.= ", date_delivery = '".($obj->date_livraison?$obj->date_livraison:'null')."'";
+ $sqlUpdate.= " WHERE rowid = ".$obj->shipping_id;
- $result=$db->query($sqlUpdate);
- if (! $result)
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ $result=$db->query($sqlUpdate);
+ if (! $result)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- print ' ';
+ print '';
}
/*
@@ -2891,105 +2911,105 @@ function migrate_customerorder_shipping($db,$langs,$conf)
*/
function migrate_shipping_delivery($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationShippingDelivery')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationShippingDelivery')." \n";
- $error = 0;
+ $error = 0;
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","fk_expedition");
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- dolibarr_install_syslog("upgrade2::migrate_shipping_delivery");
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","fk_expedition");
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ dolibarr_install_syslog("upgrade2::migrate_shipping_delivery");
- $db->begin();
+ $db->begin();
- $sqlSelect = "SELECT rowid, fk_expedition";
- $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison";
- $sqlSelect.= " WHERE fk_expedition is not null";
+ $sqlSelect = "SELECT rowid, fk_expedition";
+ $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison";
+ $sqlSelect.= " WHERE fk_expedition is not null";
- $resql = $db->query($sqlSelect);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $resql = $db->query($sqlSelect);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($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_expedition;
- $sqlInsert.= ", 'shipping'";
- $sqlInsert.= ", ".$obj->rowid;
- $sqlInsert.= ", 'delivery'";
- $sqlInsert.= ")";
+ $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
+ $sqlInsert.= "fk_source";
+ $sqlInsert.= ", sourcetype";
+ $sqlInsert.= ", fk_target";
+ $sqlInsert.= ", targettype";
+ $sqlInsert.= ") VALUES (";
+ $sqlInsert.= $obj->fk_expedition;
+ $sqlInsert.= ", 'shipping'";
+ $sqlInsert.= ", ".$obj->rowid;
+ $sqlInsert.= ", 'delivery'";
+ $sqlInsert.= ")";
- $result=$db->query($sqlInsert);
- if ($result)
- {
- $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL";
- $sqlUpdate.= " WHERE rowid = ".$obj->rowid;
+ $result=$db->query($sqlInsert);
+ if ($result)
+ {
+ $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL";
+ $sqlUpdate.= " WHERE rowid = ".$obj->rowid;
- $result=$db->query($sqlUpdate);
- if (! $result)
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- }
- else
- {
- $error++;
- dol_print_error($db);
- }
- $i++;
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ $result=$db->query($sqlUpdate);
+ if (! $result)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ }
+ else
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- if ($error == 0)
- {
- $sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'";
- $db->query($sqlDelete);
+ if ($error == 0)
+ {
+ $sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'";
+ $db->query($sqlDelete);
- $db->commit();
+ $db->commit();
- // DDL commands must not be inside a transaction
- $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_expedition";
- $db->query($sqlDrop);
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ // DDL commands must not be inside a transaction
+ $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_expedition";
+ $db->query($sqlDrop);
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- print ' ';
+ print '';
}
/*
@@ -2998,78 +3018,78 @@ function migrate_shipping_delivery($db,$langs,$conf)
*/
function migrate_shipping_delivery2($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationShippingDelivery2')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationShippingDelivery2')." \n";
- $error = 0;
+ $error = 0;
- dolibarr_install_syslog("upgrade2::migrate_shipping_delivery2");
+ dolibarr_install_syslog("upgrade2::migrate_shipping_delivery2");
- $db->begin();
+ $db->begin();
- $sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery";
- $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison as l,";
- $sqlSelect.= " ".MAIN_DB_PREFIX."element_element as el,";
- $sqlSelect.= " ".MAIN_DB_PREFIX."expedition as e";
- $sqlSelect.= " WHERE l.rowid = el.fk_target";
- $sqlSelect.= " AND el.targettype = 'delivery'";
- $sqlSelect.= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'";
- $sqlSelect.= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null
- // Add condition to know if we never migrate this record
- $sqlSelect.= " AND (l.ref_customer IS NULL".($db->type!='pgsql'?" or l.ref_customer = ''":"").")";
- $sqlSelect.= " AND (l.date_delivery IS NULL".($db->type!='pgsql'?" or l.date_delivery = ''":"").")";
+ $sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery";
+ $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison as l,";
+ $sqlSelect.= " ".MAIN_DB_PREFIX."element_element as el,";
+ $sqlSelect.= " ".MAIN_DB_PREFIX."expedition as e";
+ $sqlSelect.= " WHERE l.rowid = el.fk_target";
+ $sqlSelect.= " AND el.targettype = 'delivery'";
+ $sqlSelect.= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'";
+ $sqlSelect.= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null
+ // Add condition to know if we never migrate this record
+ $sqlSelect.= " AND (l.ref_customer IS NULL".($db->type!='pgsql'?" or l.ref_customer = ''":"").")";
+ $sqlSelect.= " AND (l.date_delivery IS NULL".($db->type!='pgsql'?" or l.date_delivery = ''":"").")";
- $resql = $db->query($sqlSelect);
- if ($resql)
- {
- $i = 0;
- $num = $db->num_rows($resql);
+ $resql = $db->query($sqlSelect);
+ if ($resql)
+ {
+ $i = 0;
+ $num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
- $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
- $sqlUpdate.= " ref_customer = '".$obj->ref_customer."',";
- $sqlUpdate.= " date_delivery = ".($obj->date_delivery?"'".$obj->date_delivery."'":'null');
- $sqlUpdate.= " WHERE rowid = ".$obj->delivery_id;
+ $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
+ $sqlUpdate.= " ref_customer = '".$obj->ref_customer."',";
+ $sqlUpdate.= " date_delivery = ".($obj->date_delivery?"'".$obj->date_delivery."'":'null');
+ $sqlUpdate.= " WHERE rowid = ".$obj->delivery_id;
- $result=$db->query($sqlUpdate);
- if (! $result)
- {
- $error++;
- dol_print_error($db);
- }
- print ". ";
- $i++;
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
+ $result=$db->query($sqlUpdate);
+ if (! $result)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ print ". ";
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- if ($error == 0)
- {
- $db->commit();
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
+ if ($error == 0)
+ {
+ $db->commit();
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
- print ' ';
+ print '';
}
/*
@@ -3077,79 +3097,91 @@ function migrate_shipping_delivery2($db,$langs,$conf)
*/
function migrate_actioncomm_element($db,$langs,$conf)
{
- print '';
+ print ' ';
- print ' ';
- print ''.$langs->trans('MigrationActioncommElement')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationActioncommElement')." \n";
- $elements = array( 'propal' => 'propalrowid',
+ $elements = array( 'propal' => 'propalrowid',
'order' => 'fk_commande',
'invoice' => 'fk_facture',
'contract' => 'fk_contract',
'order_supplier' => 'fk_supplier_order',
'invoice_supplier' => 'fk_supplier_invoice'
- );
+ );
- foreach($elements as $type => $field)
- {
- $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm",$field);
- $obj = $db->fetch_object($result);
- if ($obj)
- {
- dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field);
+ foreach($elements as $type => $field)
+ {
+ $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm",$field);
+ $obj = $db->fetch_object($result);
+ if ($obj)
+ {
+ dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field);
- $db->begin();
+ $db->begin();
- $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET ";
- $sql.= "fk_element = ".$field.", elementtype = '".$type."'";
- $sql.= " WHERE ".$field." IS NOT NULL";
- $sql.= " AND fk_element IS NULL";
- $sql.= " AND elementtype IS NULL";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET ";
+ $sql.= "fk_element = ".$field.", elementtype = '".$type."'";
+ $sql.= " WHERE ".$field." IS NOT NULL";
+ $sql.= " AND fk_element IS NULL";
+ $sql.= " AND elementtype IS NULL";
- $resql = $db->query($sql);
- if ($resql)
- {
- $db->commit();
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $db->commit();
- // DDL commands must not be inside a transaction
- // We will drop at next version because a migrate should be runnable several times if it fails.
- //$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."actioncomm DROP COLUMN ".$field;
- //$db->query($sqlDrop);
- //print ". ";
- }
- else
- {
- dol_print_error($db);
- $db->rollback();
- }
- }
- else
- {
- print $langs->trans('AlreadyDone')." \n";
- }
- }
+ // DDL commands must not be inside a transaction
+ // We will drop at next version because a migrate should be runnable several times if it fails.
+ //$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."actioncomm DROP COLUMN ".$field;
+ //$db->query($sqlDrop);
+ //print ". ";
+ }
+ else
+ {
+ dol_print_error($db);
+ $db->rollback();
+ }
+ }
+ else
+ {
+ print $langs->trans('AlreadyDone')." \n";
+ }
+ }
- print ' ';
+ print '';
}
/**
* Migration directory
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @param string $oldname Old name
+ * @param string $newname New name
+ * @return void
*/
function migrate_directories($db,$langs,$conf,$oldname,$newname)
{
- dolibarr_install_syslog("upgrade2::migrate_directories");
+ dolibarr_install_syslog("upgrade2::migrate_directories");
- if (is_dir(DOL_DATA_ROOT.$oldname) && ! file_exists(DOL_DATA_ROOT.$newname))
- {
- dolibarr_install_syslog("upgrade2::migrate_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname);
- @rename(DOL_DATA_ROOT.$oldname,DOL_DATA_ROOT.$newname);
- }
+ if (is_dir(DOL_DATA_ROOT.$oldname) && ! file_exists(DOL_DATA_ROOT.$newname))
+ {
+ dolibarr_install_syslog("upgrade2::migrate_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname);
+ @rename(DOL_DATA_ROOT.$oldname,DOL_DATA_ROOT.$newname);
+ }
}
-/*
- * Delete depracted files
+/**
+ * Delete deprecated files
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @return void
*/
function migrate_delete_old_files($db,$langs,$conf)
{
@@ -3203,8 +3235,13 @@ function migrate_delete_old_files($db,$langs,$conf)
return $result;
}
-/*
+/**
* Remove deprecated directories
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @return void
*/
function migrate_delete_old_dir($db,$langs,$conf)
{
@@ -3236,10 +3273,15 @@ function migrate_delete_old_dir($db,$langs,$conf)
}
-/*
+/**
* Disable/Reenable features modules.
* We must do this when internal menu of module or permissions has changed
* or when triggers have moved.
+ *
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @return void
*/
function migrate_reload_modules($db,$langs,$conf)
{
@@ -3250,9 +3292,9 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Agenda");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modAgenda.class.php');
if ($res) {
- $mod=new modAgenda($db);
- $mod->remove('noboxes');
- $mod->init('noboxes');
+ $mod=new modAgenda($db);
+ $mod->remove('noboxes');
+ $mod->init('noboxes');
}
}
if (! empty($conf->global->MAIN_MODULE_PHENIX))
@@ -3260,9 +3302,9 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Phenix");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modPhenix.class.php');
if ($res) {
- $mod=new modPhenix($db);
- $mod->remove('noboxes');
- $mod->init();
+ $mod=new modPhenix($db);
+ $mod->remove('noboxes');
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_WEBCALENDAR))
@@ -3270,9 +3312,9 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Webcalendar");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modWebcalendar.class.php');
if ($res) {
- $mod=new modWebcalendar($db);
- $mod->remove('noboxes');
- $mod->init();
+ $mod=new modWebcalendar($db);
+ $mod->remove('noboxes');
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_MANTIS))
@@ -3280,9 +3322,9 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Mantis");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modMantis.class.php');
if ($res) {
- $mod=new modMantis($db);
- $mod->remove('noboxes');
- $mod->init();
+ $mod=new modMantis($db);
+ $mod->remove('noboxes');
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_SOCIETE))
@@ -3290,9 +3332,9 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Societe");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modSociete.class.php');
if ($res) {
- $mod=new modSociete($db);
- $mod->remove('noboxes');
- $mod->init('noboxes');
+ $mod=new modSociete($db);
+ $mod->remove('noboxes');
+ $mod->init('noboxes');
}
}
if (! empty($conf->global->MAIN_MODULE_PRODUIT)) // Permission has changed into 2.7
@@ -3300,39 +3342,39 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Produit");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modProduct.class.php');
if ($res) {
- $mod=new modProduct($db);
- //$mod->remove('noboxes');
- $mod->init();
+ $mod=new modProduct($db);
+ //$mod->remove('noboxes');
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_SERVICE)) // Permission has changed into 2.7
{
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Service");
if ($res) {
- $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modService.class.php');
- $mod=new modService($db);
- //$mod->remove('noboxes');
- $mod->init();
+ $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modService.class.php');
+ $mod=new modService($db);
+ //$mod->remove('noboxes');
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_COMMANDE)) // Permission has changed into 2.9
{
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Commande");
if ($res) {
- $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modCommande.class.php');
- $mod=new modCommande($db);
- //$mod->remove('noboxes');
- $mod->init();
+ $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modCommande.class.php');
+ $mod=new modCommande($db);
+ //$mod->remove('noboxes');
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_FACTURE)) // Permission has changed into 2.9
{
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Facture");
if ($res) {
- $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modFacture.class.php');
- $mod=new modFacture($db);
- //$mod->remove('noboxes');
- $mod->init();
+ $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modFacture.class.php');
+ $mod=new modFacture($db);
+ //$mod->remove('noboxes');
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_FOURNISSEUR)) // Permission has changed into 2.9
@@ -3340,20 +3382,20 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Fournisseur");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modFournisseur.class.php');
if ($res) {
- $mod=new modFournisseur($db);
- //$mod->remove('noboxes');
- $mod->init();
+ $mod=new modFournisseur($db);
+ //$mod->remove('noboxes');
+ $mod->init();
}
}
- if (! empty($conf->global->MAIN_MODULE_USER)) // Permission has changed into 3.0
+ if (! empty($conf->global->MAIN_MODULE_USER)) // Permission has changed into 3.0
{
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module User");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modUser.class.php');
if ($res) {
- $mod=new modUser($db);
- //$mod->remove('noboxes'); // We need to remove because id of module has changed
- $mod->init();
+ $mod=new modUser($db);
+ //$mod->remove('noboxes'); // We need to remove because id of module has changed
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_DEPLACEMENT)) // Permission has changed into 3.0
@@ -3361,9 +3403,9 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Deplacement");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modDeplacement.class.php');
if ($res) {
- $mod=new modDeplacement($db);
- //$mod->remove('noboxes'); // We need to remove because a permission id has been removed
- $mod->init();
+ $mod=new modDeplacement($db);
+ //$mod->remove('noboxes'); // We need to remove because a permission id has been removed
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_DON)) // Permission has changed into 3.0
@@ -3371,19 +3413,19 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Don");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modDon.class.php');
if ($res) {
- $mod=new modDon($db);
- //$mod->remove('noboxes'); // We need to remove because a permission id has been removed
- $mod->init();
+ $mod=new modDon($db);
+ //$mod->remove('noboxes'); // We need to remove because a permission id has been removed
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_ECM)) // Permission has changed into 3.0 and 3.1
{
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ECM");
if ($res) {
- $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modECM.class.php');
- $mod=new modECM($db);
- $mod->remove('noboxes'); // We need to remove because a permission id has been removed
- $mod->init();
+ $res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modECM.class.php');
+ $mod=new modECM($db);
+ $mod->remove('noboxes'); // We need to remove because a permission id has been removed
+ $mod->init();
}
}
if (! empty($conf->global->MAIN_MODULE_PAYBOX)) // Permission has changed into 3.0
@@ -3391,9 +3433,9 @@ function migrate_reload_modules($db,$langs,$conf)
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Paybox");
$res=@include_once(DOL_DOCUMENT_ROOT.'/includes/modules/modPaybox.class.php');
if ($res) {
- $mod=new modPaybox($db);
- $mod->remove('noboxes'); // We need to remove because id of module has changed
- $mod->init();
+ $mod=new modPaybox($db);
+ $mod->remove('noboxes'); // We need to remove because id of module has changed
+ $mod->init();
}
}
@@ -3404,10 +3446,11 @@ function migrate_reload_modules($db,$langs,$conf)
/**
* Reload menu if dynamic menus, if modified by version
*
- * @param $db
- * @param $langs
- * @param $conf
- * @param $versionto
+ * @param DoliDB $db Database handler
+ * @param Translate $langs Object langs
+ * @param Conf $conf Object conf
+ * @param string $versionto Version target
+ * @return void
*/
function migrate_reload_menu($db,$langs,$conf,$versionto)
{
@@ -3420,20 +3463,20 @@ function migrate_reload_menu($db,$langs,$conf,$versionto)
$versiontoarray=explode('.',$versionto);
// Script for VX (X<2.9) -> V2.9
- $afterversionarray=explode('.','2.8.9');
- $beforeversionarray=explode('.','2.9.9');
- if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
- {
- $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers
- }
+ $afterversionarray=explode('.','2.8.9');
+ $beforeversionarray=explode('.','2.9.9');
+ if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
+ {
+ $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers
+ }
// Script for VX (X<3.2) -> V3.2
- $afterversionarray=explode('.','3.1.9');
- $beforeversionarray=explode('.','3.2.9');
- if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
- {
- $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers
- }
+ $afterversionarray=explode('.','3.1.9');
+ $beforeversionarray=explode('.','3.2.9');
+ if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
+ {
+ $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers
+ }
foreach ($listofmenuhandler as $key => $val)
{