2005-10-28 22:26:33 +02:00
< ? php
2016-02-22 18:45:00 +01:00
/* Copyright ( C ) 2005 Marc Barilley / Ocebo < marc @ ocebo . com >
2018-07-09 13:02:01 +02:00
* Copyright ( C ) 2005 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2011 Regis Houssin < regis . houssin @ inodbox . com >
2016-02-22 18:45:00 +01:00
* Copyright ( C ) 2010 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2015 - 2016 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2023-03-08 11:00:58 +01:00
* Copyright ( C ) 2023 Gauthier VERDOL < gauthier . verdol @ atm - consulting . fr >
2024-03-19 00:46:03 +01:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
2024-07-08 21:45:35 +02:00
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2005-10-28 22:26:33 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-10-28 22:26:33 +02:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2014-01-15 19:12:55 +01:00
*
2018-07-09 13:02:01 +02:00
* Upgrade2 scripts can be ran from command line with syntax :
2014-01-15 19:12:55 +01:00
*
* cd htdocs / install
2018-07-09 13:02:01 +02:00
* php upgrade . php 3.4 . 0 3.5 . 0 [ dirmodule | ignoredbversion ]
* php upgrade2 . php 3.4 . 0 3.5 . 0 [ MAIN_MODULE_NAME1_TO_ENABLE , MAIN_MODULE_NAME2_TO_ENABLE ]
*
* And for final step :
* php step5 . php 3.4 . 0 3.5 . 0
2014-01-15 19:12:55 +01:00
*
* Return code is 0 if OK , > 0 if error
2018-07-09 13:02:01 +02:00
*
* Note : To just enable a module from command line , use this syntax :
* php upgrade2 . php 0.0 . 0 0.0 . 0 [ MAIN_MODULE_NAME1_TO_ENABLE , MAIN_MODULE_NAME2_TO_ENABLE ]
2005-10-28 22:26:33 +02:00
*/
/**
2009-04-29 20:02:50 +02:00
* \file htdocs / install / upgrade2 . php
2010-11-11 00:54:59 +01:00
* \brief Upgrade some data
2009-04-29 20:02:50 +02:00
*/
2005-10-28 22:26:33 +02:00
2023-02-02 12:58:12 +01:00
define ( 'ALLOWED_IF_UPGRADE_UNLOCK_FOUND' , 1 );
2012-08-23 02:46:16 +02:00
include_once 'inc.php' ;
2021-02-22 15:18:01 +01:00
if ( ! file_exists ( $conffile )) {
2020-10-28 17:49:52 +01:00
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").' ;
2009-09-11 17:23:42 +02:00
}
2016-04-17 15:39:46 +02:00
require_once $conffile ;
2020-04-10 10:59:32 +02:00
require_once $dolibarr_main_document_root . '/compta/facture/class/facture.class.php' ;
require_once $dolibarr_main_document_root . '/comm/propal/class/propal.class.php' ;
require_once $dolibarr_main_document_root . '/contrat/class/contrat.class.php' ;
require_once $dolibarr_main_document_root . '/commande/class/commande.class.php' ;
require_once $dolibarr_main_document_root . '/fourn/class/fournisseur.commande.class.php' ;
require_once $dolibarr_main_document_root . '/core/lib/price.lib.php' ;
require_once $dolibarr_main_document_root . '/core/class/menubase.class.php' ;
require_once $dolibarr_main_document_root . '/core/lib/files.lib.php' ;
2005-10-28 22:26:33 +02:00
2016-02-22 18:45:00 +01:00
global $langs ;
2020-04-10 10:59:32 +02:00
$grant_query = '' ;
2015-07-06 15:29:58 +02:00
$step = 2 ;
2005-10-28 22:26:33 +02:00
$error = 0 ;
2007-11-28 22:24:36 +01:00
// Cette page peut etre longue. On augmente le delai autorise.
2005-10-28 22:26:33 +02:00
// Ne fonctionne que si on est pas en safe_mode.
2020-04-10 10:59:32 +02:00
$err = error_reporting ();
2005-10-28 22:26:33 +02:00
error_reporting ( 0 );
2023-11-27 11:46:58 +01:00
if ( getDolGlobalString ( 'MAIN_OVERRIDE_TIME_LIMIT' )) {
2019-11-02 13:20:32 +01:00
@ set_time_limit (( int ) $conf -> global -> MAIN_OVERRIDE_TIME_LIMIT );
2021-02-22 15:18:01 +01:00
} else {
@ set_time_limit ( 600 );
}
2005-10-28 22:26:33 +02:00
error_reporting ( $err );
2023-12-04 12:36:19 +01:00
$setuplang = GETPOST ( " selectlang " , 'aZ09' , 3 ) ? GETPOST ( " selectlang " , 'aZ09' , 3 ) : 'auto' ;
2005-10-30 02:07:00 +01:00
$langs -> setDefaultLang ( $setuplang );
2023-12-04 12:36:19 +01:00
$versionfrom = GETPOST ( " versionfrom " , 'alpha' , 3 ) ? GETPOST ( " versionfrom " , 'alpha' , 3 ) : ( empty ( $argv [ 1 ]) ? '' : $argv [ 1 ]);
$versionto = GETPOST ( " versionto " , 'alpha' , 3 ) ? GETPOST ( " versionto " , 'alpha' , 3 ) : ( empty ( $argv [ 2 ]) ? '' : $argv [ 2 ]);
$enablemodules = GETPOST ( " enablemodules " , 'alpha' , 3 ) ? GETPOST ( " enablemodules " , 'alpha' , 3 ) : ( empty ( $argv [ 3 ]) ? '' : $argv [ 3 ]);
2005-10-30 02:07:00 +01:00
2018-10-01 08:22:23 +02:00
$langs -> loadLangs ( array ( " admin " , " install " , " bills " , " suppliers " ));
2005-10-28 22:26:33 +02:00
2021-02-22 15:18:01 +01:00
if ( $dolibarr_main_db_type == 'mysqli' ) {
$choix = 1 ;
}
if ( $dolibarr_main_db_type == 'pgsql' ) {
$choix = 2 ;
}
if ( $dolibarr_main_db_type == 'mssql' ) {
$choix = 3 ;
}
2006-08-06 01:55:10 +02:00
2005-10-28 22:26:33 +02:00
2018-07-09 13:02:01 +02:00
dolibarr_install_syslog ( " --- upgrade2: entering upgrade2.php page " . $versionfrom . " " . $versionto . " " . $enablemodules );
2021-02-22 15:18:01 +01:00
if ( ! is_object ( $conf )) {
dolibarr_install_syslog ( " upgrade2: conf file not initialized " , LOG_ERR );
}
2006-06-17 16:13:49 +02:00
2009-08-14 02:30:43 +02:00
/*
2010-08-31 23:40:42 +02:00
* View
2009-08-14 02:30:43 +02:00
*/
2021-02-22 15:18:01 +01:00
if (( ! $versionfrom || preg_match ( '/version/' , $versionfrom )) && ( ! $versionto || preg_match ( '/version/' , $versionto ))) {
2016-05-18 00:44:55 +02:00
print 'Error: Parameter versionfrom or versionto missing or having a bad format.' . " \n " ;
2018-07-09 13:02:01 +02:00
print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)' . " \n " ;
2014-11-18 19:03:02 +01:00
// Test if batch mode
$sapi_type = php_sapi_name ();
$script_file = basename ( __FILE__ );
2019-11-14 12:09:15 +01:00
$path = __DIR__ . '/' ;
2021-02-22 15:18:01 +01:00
if ( substr ( $sapi_type , 0 , 3 ) == 'cli' ) {
2018-07-09 13:02:01 +02:00
print 'Syntax from command line: ' . $script_file . " x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...] \n " ;
2024-11-28 21:54:09 +01:00
print 'Example, upgrade from 19 to 20: ' . $script_file . " 19.0.0 20.0.0 \n " ;
print 'Example, enable a module only: ' . $script_file . " 0.0.0 0.0.0 MAIN_MODULE_Adherent \n " ;
2024-11-28 21:48:55 +01:00
print " \n " ;
2014-11-18 19:03:02 +01:00
}
exit ;
}
2014-11-06 13:46:12 +01:00
2023-12-04 12:36:19 +01:00
pHeader ( '' , 'step5' , GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'upgrade' , 'versionfrom=' . $versionfrom . '&versionto=' . $versionto , '' , 'main-inside main-inside-borderbottom' );
2005-10-28 22:26:33 +02:00
2021-02-22 15:18:01 +01:00
if ( ! GETPOST ( 'action' , 'aZ09' ) || preg_match ( '/upgrade/i' , GETPOST ( 'action' , 'aZ09' ))) {
2021-04-30 15:34:02 +02:00
print '<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> ' ;
2021-02-27 12:45:07 +01:00
print '<span class="inline-block">' . $langs -> trans ( 'DataMigration' ) . '</span></h3>' ;
2020-10-28 17:49:52 +01:00
2021-04-30 15:34:02 +02:00
print '<table border="0" width="100%">' ;
2020-10-28 17:49:52 +01:00
// If password is encoded, we decode it
2022-09-21 03:31:58 +02:00
if (( ! empty ( $dolibarr_main_db_pass ) && preg_match ( '/crypted:/i' , $dolibarr_main_db_pass )) || ! empty ( $dolibarr_main_db_encrypted_pass )) {
2020-10-28 17:49:52 +01:00
require_once $dolibarr_main_document_root . '/core/lib/security.lib.php' ;
2022-09-21 03:31:58 +02:00
if ( ! empty ( $dolibarr_main_db_pass ) && preg_match ( '/crypted:/i' , $dolibarr_main_db_pass )) {
2020-10-28 17:49:52 +01:00
$dolibarr_main_db_pass = preg_replace ( '/crypted:/i' , '' , $dolibarr_main_db_pass );
$dolibarr_main_db_pass = dol_decode ( $dolibarr_main_db_pass );
2024-01-11 10:07:06 +01:00
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass ; // We need to set this as it is used to know the password was initially encrypted
2021-02-22 15:18:01 +01:00
} else {
$dolibarr_main_db_pass = dol_decode ( $dolibarr_main_db_encrypted_pass );
}
2020-10-28 17:49:52 +01:00
}
2024-01-13 19:48:41 +01:00
// $conf is already instantiated inside inc.php
2020-10-28 17:49:52 +01:00
$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 ;
2023-06-24 04:04:02 +02:00
$db = getDoliDBInstance ( $conf -> db -> type , $conf -> db -> host , $conf -> db -> user , $conf -> db -> pass , $conf -> db -> name , ( int ) $conf -> db -> port );
2020-10-28 17:49:52 +01:00
2021-02-22 15:18:01 +01:00
if ( ! $db -> connected ) {
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' . $langs -> trans ( " ErrorFailedToConnectToDatabase " , $conf -> db -> name ) . '</td><td class="right">' . $langs -> trans ( 'Error' ) . '</td></tr>' ;
dolibarr_install_syslog ( 'upgrade2: failed to connect to database :' . $conf -> db -> name . ' on ' . $conf -> db -> host . ' for user ' . $conf -> db -> user , LOG_ERR );
$error ++ ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
if ( $db -> database_selected ) {
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( 'upgrade2: database connection successful :' . $dolibarr_main_db_name );
} else {
$error ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( empty ( $dolibarr_main_db_encryption )) {
$dolibarr_main_db_encryption = 0 ;
}
2020-10-28 17:49:52 +01:00
$conf -> db -> dolibarr_main_db_encryption = $dolibarr_main_db_encryption ;
2021-02-22 15:18:01 +01:00
if ( empty ( $dolibarr_main_db_cryptkey )) {
$dolibarr_main_db_cryptkey = '' ;
}
2020-10-28 17:49:52 +01:00
$conf -> db -> dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey ;
2022-05-10 14:03:09 +02:00
// Load global conf
$conf -> setValues ( $db );
2022-05-09 15:24:46 +02:00
$listofentities = array ( 1 );
2020-10-28 17:49:52 +01:00
2021-09-22 12:48:05 +02:00
// Create the global $hookmanager object
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php' ;
$hookmanager = new HookManager ( $db );
2022-05-10 12:56:22 +02:00
$hookmanager -> initHooks ( array ( 'upgrade2' ));
$parameters = array ( 'versionfrom' => $versionfrom , 'versionto' => $versionto );
$object = new stdClass ();
$action = " upgrade " ;
$reshook = $hookmanager -> executeHooks ( 'doUpgradeBefore' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2022-05-09 15:24:46 +02:00
if ( $reshook >= 0 && is_array ( $hookmanager -> resArray )) {
// Example: $hookmanager->resArray = array(2, 3, 10);
$listofentities = array_unique ( array_merge ( $listofentities , $hookmanager -> resArray ));
}
2021-09-22 12:48:05 +02:00
2020-10-28 17:49:52 +01:00
/***************************************************************************************
2021-02-22 15:18:01 +01:00
*
* Migration of data
*
***************************************************************************************/
2017-06-06 01:34:25 +02:00
2022-05-09 15:24:46 +02:00
// Force to execute this at begin to avoid the new core code into Dolibarr to be broken.
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'user ADD COLUMN birth date' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'user ADD COLUMN dateemployment date' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'user ADD COLUMN dateemploymentend date' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'user ADD COLUMN default_range integer' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'user ADD COLUMN default_c_exp_tax_cat integer' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'extrafields ADD COLUMN langs varchar(24)' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'extrafields ADD COLUMN fieldcomputed text' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'extrafields ADD COLUMN fielddefault varchar(255)' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . " extrafields ADD COLUMN enabled varchar(255) DEFAULT '1' " ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'extrafields ADD COLUMN help text' ;
$db -> query ( $sql , 1 );
$sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . 'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL' ;
$db -> query ( $sql , 1 );
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
$db -> begin ();
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
foreach ( $listofentities as $entity ) {
// Set $conf context for entity
$conf -> setEntityValues ( $db , $entity );
// Reset forced setup after the setValues
if ( defined ( 'SYSLOG_FILE' )) {
$conf -> global -> SYSLOG_FILE = constant ( 'SYSLOG_FILE' );
}
$conf -> global -> MAIN_ENABLE_LOG_TO_HTML = 1 ;
2020-10-28 17:49:52 +01:00
2024-10-03 19:40:34 +02:00
$versiontoarray = array ();
$versionranarray = array ();
2022-05-09 15:24:46 +02:00
if ( ! $error ) {
if ( count ( $listofentities ) > 1 ) {
print '<tr><td colspan="4">*** ' . $langs -> trans ( " Entity " ) . ' ' . $entity . '</td></tr>' . " \n " ;
}
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
// 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 : ( isset ( $conf -> global -> MAIN_VERSION_LAST_INSTALL ) ? $conf -> global -> MAIN_VERSION_LAST_INSTALL : '' ));
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
// 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'
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
$versiontoarray = explode ( '.' , $versionto );
$versionranarray = explode ( '.' , DOL_VERSION );
2020-10-28 17:49:52 +01:00
2008-05-21 05:53:52 +02:00
2022-05-09 15:24:46 +02:00
$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 );
2005-10-28 22:26:33 +02:00
2022-05-09 15:24:46 +02:00
migrate_contracts_det ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_contracts_date1 ( $db , $langs , $conf );
2018-07-03 20:08:55 +02:00
2022-05-09 15:24:46 +02:00
migrate_contracts_date2 ( $db , $langs , $conf );
2018-07-03 20:08:55 +02:00
2022-05-09 15:24:46 +02:00
migrate_contracts_date3 ( $db , $langs , $conf );
2018-07-03 20:08:55 +02:00
2022-05-09 15:24:46 +02:00
migrate_contracts_open ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_modeles ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_price_propal ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_price_commande ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_price_commande_fournisseur ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_price_contrat ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_paiementfourn_facturefourn ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
// Script pour V2.1 -> V2.2
migrate_paiements_orphelins_1 ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_paiements_orphelins_2 ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_links_transfert ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
// Script pour V2.2 -> V2.4
migrate_commande_expedition ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_commande_livraison ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_detail_livraison ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
// Script pour V2.5 -> V2.6
migrate_stocks ( $db , $langs , $conf );
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
// Script pour V2.6 -> V2.7
migrate_menus ( $db , $langs , $conf );
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
migrate_commande_deliveryaddress ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_restore_missing_links ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_rename_directories ( $db , $langs , $conf , '/compta' , '/banque' );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_rename_directories ( $db , $langs , $conf , '/societe' , '/mycompany' );
}
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
// Script for 2.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
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_relationship_tables ( $db , $langs , $conf , 'co_exp' , 'fk_commande' , 'commande' , 'fk_expedition' , 'shipping' );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_relationship_tables ( $db , $langs , $conf , 'pr_exp' , 'fk_propal' , 'propal' , 'fk_expedition' , 'shipping' );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_relationship_tables ( $db , $langs , $conf , 'pr_liv' , 'fk_propal' , 'propal' , 'fk_livraison' , 'delivery' );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_relationship_tables ( $db , $langs , $conf , 'co_liv' , 'fk_commande' , 'commande' , 'fk_livraison' , 'delivery' );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_relationship_tables ( $db , $langs , $conf , 'co_pr' , 'fk_propale' , 'propal' , 'fk_commande' , 'commande' );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_relationship_tables ( $db , $langs , $conf , 'fa_pr' , 'fk_propal' , 'propal' , 'fk_facture' , 'facture' );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_relationship_tables ( $db , $langs , $conf , 'co_fa' , 'fk_commande' , 'commande' , 'fk_facture' , 'facture' );
2011-09-29 22:21:57 +02:00
2022-05-09 15:24:46 +02:00
migrate_project_user_resp ( $db , $langs , $conf );
2010-10-06 11:52:58 +02:00
2022-05-09 15:24:46 +02:00
migrate_project_task_actors ( $db , $langs , $conf );
}
2009-12-23 16:26:29 +01:00
2022-05-09 15:24:46 +02:00
// Script for 2.9
$afterversionarray = explode ( '.' , '2.8.9' );
$beforeversionarray = explode ( '.' , '2.9.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
2023-03-08 11:00:58 +01:00
migrate_element_time ( $db , $langs , $conf );
2009-12-12 21:41:27 +01:00
2022-05-09 15:24:46 +02:00
migrate_customerorder_shipping ( $db , $langs , $conf );
2009-12-23 16:26:29 +01:00
2022-05-09 15:24:46 +02:00
migrate_shipping_delivery ( $db , $langs , $conf );
2009-12-23 16:26:29 +01:00
2022-05-09 15:24:46 +02:00
migrate_shipping_delivery2 ( $db , $langs , $conf );
}
2009-12-23 16:26:29 +01:00
2022-05-09 15:24:46 +02:00
// Script for 3.0
$afterversionarray = explode ( '.' , '2.9.9' );
$beforeversionarray = explode ( '.' , '3.0.9' );
2024-10-03 19:40:34 +02:00
//if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
// No particular code
//}
2009-12-12 21:41:27 +01:00
2022-05-09 15:24:46 +02:00
// Script for 3.1
$afterversionarray = explode ( '.' , '3.0.9' );
$beforeversionarray = explode ( '.' , '3.1.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_rename_directories ( $db , $langs , $conf , '/rss' , '/externalrss' );
2010-02-28 15:16:46 +01:00
2022-05-09 15:24:46 +02:00
migrate_actioncomm_element ( $db , $langs , $conf );
}
2010-02-28 15:16:46 +01:00
2022-05-09 15:24:46 +02:00
// Script for 3.2
$afterversionarray = explode ( '.' , '3.1.9' );
$beforeversionarray = explode ( '.' , '3.2.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_price_contrat ( $db , $langs , $conf );
2010-03-13 00:40:39 +01:00
2022-05-09 15:24:46 +02:00
migrate_mode_reglement ( $db , $langs , $conf );
2010-03-20 14:09:59 +01:00
2022-05-09 15:24:46 +02:00
migrate_clean_association ( $db , $langs , $conf );
}
2010-03-20 14:09:59 +01:00
2022-05-09 15:24:46 +02:00
// Script for 3.3
$afterversionarray = explode ( '.' , '3.2.9' );
$beforeversionarray = explode ( '.' , '3.3.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_categorie_association ( $db , $langs , $conf );
}
2010-03-20 14:09:59 +01:00
2022-05-09 15:24:46 +02:00
// Script for 3.4
// No specific scripts
2010-04-24 19:37:55 +02:00
2022-05-09 15:24:46 +02:00
// Tasks to do always and only into last targeted version
$afterversionarray = explode ( '.' , '3.6.9' ); // target is after this
$beforeversionarray = explode ( '.' , '3.7.9' ); // target is before this
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_event_assignement ( $db , $langs , $conf );
}
2009-11-04 22:41:08 +01:00
2022-05-09 15:24:46 +02:00
// Scripts for 3.9
$afterversionarray = explode ( '.' , '3.7.9' );
$beforeversionarray = explode ( '.' , '3.8.9' );
2024-10-03 19:40:34 +02:00
//if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
// No particular code
//}
2022-05-09 15:24:46 +02:00
// Scripts for 4.0
$afterversionarray = explode ( '.' , '3.9.9' );
$beforeversionarray = explode ( '.' , '4.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_rename_directories ( $db , $langs , $conf , '/fckeditor' , '/medias' );
}
2011-06-06 13:37:59 +02:00
2022-05-09 15:24:46 +02:00
// Scripts for 5.0
$afterversionarray = explode ( '.' , '4.0.9' );
$beforeversionarray = explode ( '.' , '5.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
// Migrate to add entity value into llx_societe_remise
migrate_remise_entity ( $db , $langs , $conf );
2011-02-02 14:29:54 +01:00
2022-05-09 15:24:46 +02:00
// Migrate to add entity value into llx_societe_remise_except
migrate_remise_except_entity ( $db , $langs , $conf );
}
2012-04-07 02:24:32 +02:00
2022-05-09 15:24:46 +02:00
// Scripts for 6.0
$afterversionarray = explode ( '.' , '5.0.9' );
$beforeversionarray = explode ( '.' , '6.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
2022-08-28 14:18:51 +02:00
if ( isModEnabled ( 'multicompany' )) {
2022-05-09 15:24:46 +02:00
global $multicompany_transverse_mode ;
// Only if the transverse mode is not used
if ( empty ( $multicompany_transverse_mode )) {
// Migrate to add entity value into llx_user_rights
migrate_user_rights_entity ( $db , $langs , $conf );
// Migrate to add entity value into llx_usergroup_rights
migrate_usergroup_rights_entity ( $db , $langs , $conf );
}
2020-10-28 17:49:52 +01:00
}
}
2012-03-03 16:44:05 +01:00
2022-05-09 15:24:46 +02:00
// Scripts for 7.0
$afterversionarray = explode ( '.' , '6.0.9' );
$beforeversionarray = explode ( '.' , '7.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
// Migrate contact association
migrate_event_assignement_contact ( $db , $langs , $conf );
2011-02-02 14:29:54 +01:00
2022-05-09 15:24:46 +02:00
migrate_reset_blocked_log ( $db , $langs , $conf );
}
2012-10-08 19:27:02 +02:00
2022-05-09 15:24:46 +02:00
// Scripts for 8.0
$afterversionarray = explode ( '.' , '7.0.9' );
$beforeversionarray = explode ( '.' , '8.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_rename_directories ( $db , $langs , $conf , '/contracts' , '/contract' );
}
// Scripts for 9.0
$afterversionarray = explode ( '.' , '8.0.9' );
$beforeversionarray = explode ( '.' , '9.0.9' );
2024-10-03 19:40:34 +02:00
//if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
//migrate_user_photospath();
//}
2022-05-09 15:24:46 +02:00
// Scripts for 11.0
$afterversionarray = explode ( '.' , '10.0.9' );
$beforeversionarray = explode ( '.' , '11.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_users_socialnetworks ();
migrate_members_socialnetworks ();
migrate_contacts_socialnetworks ();
migrate_thirdparties_socialnetworks ();
}
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
// Scripts for 14.0
$afterversionarray = explode ( '.' , '13.0.9' );
$beforeversionarray = explode ( '.' , '14.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_export_import_profiles ( 'export' );
migrate_export_import_profiles ( 'import' );
}
// Scripts for 16.0
$afterversionarray = explode ( '.' , '15.0.9' );
$beforeversionarray = explode ( '.' , '16.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
2022-09-21 03:56:16 +02:00
migrate_user_photospath ();
2022-05-09 15:24:46 +02:00
migrate_user_photospath2 ();
}
2022-10-07 12:02:53 +02:00
// Scripts for 17.0
$afterversionarray = explode ( '.' , '16.0.9' );
$beforeversionarray = explode ( '.' , '17.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
2023-01-02 02:23:28 +01:00
migrate_contractdet_rank ();
}
// Scripts for 18.0
2023-04-02 08:28:56 +02:00
$afterversionarray = explode ( '.' , '17.0.9' );
2023-01-02 02:23:28 +01:00
$beforeversionarray = explode ( '.' , '18.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
2022-10-07 12:02:53 +02:00
migrate_contractdet_rank ();
}
2023-10-31 13:31:02 +01:00
// Scripts for 19.0
/*
$afterversionarray = explode ( '.' , '18.0.9' );
$beforeversionarray = explode ( '.' , '19.0.9' );
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
}
*/
2024-11-13 23:58:12 +01:00
// Scripts for 20.0
2024-11-14 23:32:33 +01:00
/* $afterversionarray = explode ( '.' , '19.0.9' );
2024-11-13 23:58:12 +01:00
$beforeversionarray = explode ( '.' , '20.0.9' );
2024-11-14 23:32:33 +01:00
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
} */
// Scripts for 21.0
$afterversionarray = explode ( '.' , '20.0.9' );
$beforeversionarray = explode ( '.' , '21.0.9' );
2024-11-13 23:58:12 +01:00
if ( versioncompare ( $versiontoarray , $afterversionarray ) >= 0 && versioncompare ( $versiontoarray , $beforeversionarray ) <= 0 ) {
migrate_productlot_path ();
}
2020-10-28 17:49:52 +01:00
}
2013-10-26 16:18:28 +02:00
2022-05-09 15:24:46 +02:00
// Code executed only if migration is LAST ONE. Must always be done.
if ( versioncompare ( $versiontoarray , $versionranarray ) >= 0 || versioncompare ( $versiontoarray , $versionranarray ) <= - 3 ) {
// Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version)
$listofmodule = array (
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_ACCOUNTING' => 'newboxdefonly' ,
'MAIN_MODULE_AGENDA' => 'newboxdefonly' ,
'MAIN_MODULE_BOM' => 'menuonly' ,
'MAIN_MODULE_BANQUE' => 'menuonly' ,
'MAIN_MODULE_BARCODE' => 'newboxdefonly' ,
'MAIN_MODULE_CRON' => 'newboxdefonly' ,
'MAIN_MODULE_COMMANDE' => 'newboxdefonly' ,
'MAIN_MODULE_BLOCKEDLOG' => 'noboxes' ,
'MAIN_MODULE_DEPLACEMENT' => 'newboxdefonly' ,
'MAIN_MODULE_DON' => 'newboxdefonly' ,
'MAIN_MODULE_ECM' => 'newboxdefonly' ,
'MAIN_MODULE_EXTERNALSITE' => 'newboxdefonly' ,
'MAIN_MODULE_EXPENSEREPORT' => 'newboxdefonly' ,
'MAIN_MODULE_FACTURE' => 'newboxdefonly' ,
'MAIN_MODULE_FOURNISSEUR' => 'newboxdefonly' ,
'MAIN_MODULE_FICHEINTER' => 'newboxdefonly' ,
'MAIN_MODULE_HOLIDAY' => 'newboxdefonly' ,
2024-08-31 12:32:47 +02:00
'MAIN_MODULE_LOAN' => 'newboxdefonly' ,
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_MARGIN' => 'menuonly' ,
'MAIN_MODULE_MRP' => 'menuonly' ,
'MAIN_MODULE_OPENSURVEY' => 'newboxdefonly' ,
'MAIN_MODULE_PAYBOX' => 'newboxdefonly' ,
'MAIN_MODULE_PRINTING' => 'newboxdefonly' ,
'MAIN_MODULE_PRODUIT' => 'newboxdefonly' ,
'MAIN_MODULE_RECRUITMENT' => 'menuonly' ,
'MAIN_MODULE_RESOURCE' => 'noboxes' ,
'MAIN_MODULE_SALARIES' => 'newboxdefonly' ,
'MAIN_MODULE_SERVICE' => 'newboxdefonly' ,
'MAIN_MODULE_SYSLOG' => 'newboxdefonly' ,
'MAIN_MODULE_SOCIETE' => 'newboxdefonly' ,
'MAIN_MODULE_STRIPE' => 'menuonly' ,
'MAIN_MODULE_TICKET' => 'newboxdefonly' ,
'MAIN_MODULE_TAKEPOS' => 'newboxdefonly' ,
'MAIN_MODULE_USER' => 'newboxdefonly' , //This one must be always done and only into last targeted version)
'MAIN_MODULE_VARIANTS' => 'newboxdefonly' ,
'MAIN_MODULE_WEBSITE' => 'newboxdefonly' ,
2022-05-09 15:24:46 +02:00
);
$result = migrate_reload_modules ( $db , $langs , $conf , $listofmodule );
if ( $result < 0 ) {
$error ++ ;
}
// Reload menus (this must be always and only into last targeted version)
$result = migrate_reload_menu ( $db , $langs , $conf );
if ( $result < 0 ) {
$error ++ ;
}
2020-10-28 17:49:52 +01:00
}
2021-07-06 11:54:32 +02:00
2022-05-09 15:24:46 +02:00
// Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...'
// In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line.
if ( ! $error && $enablemodules ) {
// Reload modules (this must be always done and only into last targeted version)
$listofmodules = array ();
$enablemodules = preg_replace ( '/enablemodules=/' , '' , $enablemodules );
$tmplistofmodules = explode ( ',' , $enablemodules );
foreach ( $tmplistofmodules as $value ) {
$listofmodules [ $value ] = 'forceactivate' ;
}
$resultreloadmodules = migrate_reload_modules ( $db , $langs , $conf , $listofmodules , 1 );
if ( $resultreloadmodules < 0 ) {
$error ++ ;
}
2021-07-06 11:54:32 +02:00
}
2022-02-22 21:24:34 +01:00
2022-05-09 15:24:46 +02:00
// Can call a dedicated external upgrade process with hook doUpgradeAfterDB()
if ( ! $error ) {
2024-03-19 00:46:03 +01:00
$parameters = array ( 'versionfrom' => $versionfrom , 'versionto' => $versionto , 'conf' => $conf );
2022-05-09 15:24:46 +02:00
$object = new stdClass ();
$action = " upgrade " ;
$reshook = $hookmanager -> executeHooks ( 'doUpgradeAfterDB' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $hookmanager -> resNbOfHooks > 0 ) {
if ( $reshook < 0 ) {
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'UpgradeExternalModule' ) . '</b>: ' ;
print $hookmanager -> error ;
print " <!-- ( " . $reshook . " ) --> " ;
print '</td></tr>' ;
} else {
print '<tr class="trforrunsql"><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'UpgradeExternalModule' ) . ' (DB)</b>: <span class="ok">OK</span>' ;
print " <!-- ( " . $reshook . " ) --> " ;
print '</td></tr>' ;
}
} else {
2022-08-31 22:14:20 +02:00
//if (!empty($conf->modules))
2022-05-09 15:24:46 +02:00
if ( ! empty ( $conf -> modules_parts [ 'hooks' ])) { // If there is at least one module with one hook, we show message to say nothing was done
print '<tr class="trforrunsql"><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'UpgradeExternalModule' ) . '</b>: ' . $langs -> trans ( " NodoUpgradeAfterDB " );
print '</td></tr>' ;
}
}
2022-02-22 21:24:34 +01:00
}
2020-10-28 17:49:52 +01:00
}
2017-06-06 01:34:25 +02:00
2022-05-09 15:24:46 +02:00
print '</table>' ;
2021-07-06 11:54:32 +02:00
2022-05-09 15:24:46 +02:00
if ( ! $error ) {
// Set constant to ask to remake a new ping to inform about upgrade (if first ping was done and OK)
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID' " ;
$db -> query ( $sql , 1 );
2017-09-09 16:49:26 +02:00
}
2017-06-01 12:26:17 +02:00
2022-05-09 15:24:46 +02:00
// We always commit.
// Process is designed so we can run it several times whatever is situation.
$db -> commit ();
2020-12-16 15:10:11 +01:00
2022-05-09 15:24:46 +02:00
/***************************************************************************************
*
* Migration of files
*
***************************************************************************************/
foreach ( $listofentities as $entity ) {
// Set $conf context for entity
$conf -> setEntityValues ( $db , $entity );
// Reset forced setup after the setValues
if ( defined ( 'SYSLOG_FILE' )) {
$conf -> global -> SYSLOG_FILE = constant ( 'SYSLOG_FILE' );
2020-12-16 15:10:11 +01:00
}
2022-05-09 15:24:46 +02:00
$conf -> global -> MAIN_ENABLE_LOG_TO_HTML = 1 ;
2020-10-28 17:49:52 +01:00
2022-05-09 15:24:46 +02:00
// Copy directory medias
$srcroot = DOL_DOCUMENT_ROOT . '/install/medias' ;
$destroot = DOL_DATA_ROOT . '/medias' ;
2024-09-10 01:02:56 +02:00
dolCopyDir ( $srcroot , $destroot , '0' , 0 );
2022-05-09 15:24:46 +02:00
// Actions for all versions (no database change but delete some files and directories)
migrate_delete_old_files ( $db , $langs , $conf );
migrate_delete_old_dir ( $db , $langs , $conf );
// Actions for all versions (no database change but create some directories)
dol_mkdir ( DOL_DATA_ROOT . '/bank' );
// Actions for all versions (no database change but rename some directories)
migrate_rename_directories ( $db , $langs , $conf , '/banque/bordereau' , '/bank/checkdeposits' );
2024-03-19 00:46:03 +01:00
$parameters = array ( 'versionfrom' => $versionfrom , 'versionto' => $versionto , 'conf' => $conf );
2020-10-28 17:49:52 +01:00
$object = new stdClass ();
$action = " upgrade " ;
2022-05-09 15:24:46 +02:00
$reshook = $hookmanager -> executeHooks ( 'doUpgradeAfterFiles' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-22 15:18:01 +01:00
if ( $hookmanager -> resNbOfHooks > 0 ) {
if ( $reshook < 0 ) {
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'UpgradeExternalModule' ) . '</b>: ' ;
print $hookmanager -> error ;
print " <!-- ( " . $reshook . " ) --> " ;
print '</td></tr>' ;
} else {
2021-02-27 12:45:07 +01:00
print '<tr class="trforrunsql"><td colspan="4">' ;
2022-05-09 15:24:46 +02:00
print '<b>' . $langs -> trans ( 'UpgradeExternalModule' ) . ' (Files)</b>: <span class="ok">OK</span>' ;
2020-10-28 17:49:52 +01:00
print " <!-- ( " . $reshook . " ) --> " ;
print '</td></tr>' ;
}
} else {
2022-08-31 22:14:20 +02:00
//if (!empty($conf->modules))
2021-02-22 15:18:01 +01:00
if ( ! empty ( $conf -> modules_parts [ 'hooks' ])) { // If there is at least one module with one hook, we show message to say nothing was done
2021-02-27 12:45:07 +01:00
print '<tr class="trforrunsql"><td colspan="4">' ;
2022-05-09 15:24:46 +02:00
print '<b>' . $langs -> trans ( 'UpgradeExternalModule' ) . '</b>: ' . $langs -> trans ( " NodoUpgradeAfterFiles " );
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
}
}
}
$db -> close ();
2021-02-27 12:45:07 +01:00
$silent = 0 ;
if ( ! $silent ) {
print '<table width="100%">' ;
print '<tr><td style="width: 30%">' . $langs -> trans ( " MigrationFinished " ) . '</td>' ;
print '<td class="right">' ;
if ( $error == 0 ) {
//print '<span class="ok">'.$langs->trans("OK").'</span> - '; // $error = 0 does not mean there is no error (error are not always trapped)
} else {
print '<span class="error">' . $langs -> trans ( " Error " ) . '</span> - ' ;
}
//if (!empty($conf->use_javascript_ajax)) { // use_javascript_ajax is not defined
2021-11-29 15:09:18 +01:00
print ' < script type = " text/javascript " >
2021-02-27 12:45:07 +01:00
jQuery ( document ) . ready ( function () {
function init_trrunsql ()
{
console . log ( " toggle .trforrunsql " );
jQuery ( " .trforrunsql " ) . toggle ();
}
init_trrunsql ();
jQuery ( " .trforrunsqlshowhide " ) . click ( function () {
init_trrunsql ();
});
});
</ script > ' ;
print '<a class="trforrunsqlshowhide" href="#">' . $langs -> trans ( " ShowHideDetails " ) . '</a>' ;
//}
print '</td></tr>' . " \n " ;
print '</table>' ;
}
//print '<div><br>'.$langs->trans("MigrationFinished").'</div>';
2020-05-21 15:05:19 +02:00
} else {
2020-10-28 17:49:52 +01:00
print '<div class="error">' . $langs -> trans ( 'ErrorWrongParameters' ) . '</div>' ;
$error ++ ;
2005-10-28 22:26:33 +02:00
}
2019-11-14 12:09:15 +01:00
$ret = 0 ;
2021-02-22 15:18:01 +01:00
if ( $error && isset ( $argv [ 1 ])) {
$ret = 1 ;
}
2018-04-12 19:13:06 +02:00
dolibarr_install_syslog ( " Exit " . $ret );
2005-10-28 22:26:33 +02:00
2015-07-06 16:33:45 +02:00
dolibarr_install_syslog ( " --- upgrade2: end " );
2019-11-14 12:09:15 +01:00
pFooter ( $error ? 2 : 0 , $setuplang );
2005-10-28 22:26:33 +02:00
2021-02-22 15:18:01 +01:00
if ( $db -> connected ) {
$db -> close ();
}
2012-04-04 20:37:16 +02:00
// Return code if ran from command line
2021-02-22 15:18:01 +01:00
if ( $ret ) {
exit ( $ret );
}
2012-04-04 20:37:16 +02:00
2005-10-28 22:26:33 +02:00
/**
2024-08-07 01:20:43 +02:00
* Records payment links for an invoice in a join table ( link n <--> n for payments <--> invoices )
2011-09-29 22:21:57 +02:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2005-10-28 22:26:33 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_paiements ( $db , $langs , $conf )
2005-10-28 22:26:33 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationPaymentsUpdate' ) . " </b><br> \n " ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " paiement " , " fk_facture " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
$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 );
2024-10-03 19:40:34 +02:00
$row = array ();
$num = 0 ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_paiements " );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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 );
}
2021-02-22 15:18:01 +01:00
if ( $num ) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'MigrationPaymentsNumberToUpdate' , $num ) . " <br> \n " ;
2024-10-03 19:40:34 +02:00
$res = 0 ;
2021-02-22 15:18:01 +01:00
if ( $db -> begin ()) {
2020-10-28 17:49:52 +01:00
$num = count ( $row );
2021-02-22 15:18:01 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2020-10-28 17:49:52 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " paiement_facture (fk_facture, fk_paiement, amount) " ;
2021-08-28 03:09:18 +02:00
$sql .= " VALUES ( " . (( int ) $row [ $i ][ 1 ]) . " , " . (( int ) $row [ $i ][ 0 ]) . " , " . (( float ) $row [ $i ][ 2 ]) . " ) " ;
2020-10-28 17:49:52 +01:00
$res += $db -> query ( $sql );
2021-03-30 03:37:54 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " paiement SET fk_facture = 0 WHERE rowid = " . (( int ) $row [ $i ][ 0 ]);
2020-10-28 17:49:52 +01:00
$res += $db -> query ( $sql );
print $langs -> trans ( 'MigrationProcessPaymentUpdate' , $row [ $i ][ 0 ]) . " <br> \n " ;
}
}
2024-10-03 19:40:34 +02:00
if ( is_array ( $row ) && $res == ( 2 * count ( $row ))) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
print $langs -> trans ( 'MigrationSuccessfullUpdate' ) . " <br> " ;
} else {
$db -> rollback ();
print $langs -> trans ( 'MigrationUpdateFailed' ) . '<br>' ;
}
} else {
print $langs -> trans ( 'MigrationPaymentsNothingToUpdate' ) . " <br> \n " ;
}
} else {
print $langs -> trans ( 'MigrationPaymentsNothingToUpdate' ) . " <br> \n " ;
}
print '</td></tr>' ;
2005-10-28 22:26:33 +02:00
}
2007-05-24 00:39:52 +02:00
/**
2024-08-07 01:20:43 +02:00
* Repair orphan payments ( lost relations due to bugs )
* Query to check if there are still orphans :
2007-05-24 00:39:52 +02:00
* 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 )
2011-09-29 22:21:57 +02:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2007-05-24 00:39:52 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_paiements_orphelins_1 ( $db , $langs , $conf )
2007-05-24 00:39:52 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationPaymentsUpdate' ) . " </b><br> \n " ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " paiement " , " fk_facture " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
// 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 " . MAIN_DB_PREFIX . " paiement_facture as pf ON pf.fk_paiement = p.rowid " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " 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 );
dolibarr_install_syslog ( " upgrade2::migrate_paiements_orphelins_1 " );
$row = array ();
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = $j = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
2021-02-22 15:18:01 +01:00
if ( $obj -> pamount == $obj -> bamount && $obj -> socid ) { // Pour etre sur d'avoir bon cas
2020-10-28 17:49:52 +01:00
$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 );
}
2021-02-22 15:18:01 +01:00
if ( count ( $row )) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'OrphelinsPaymentsDetectedByMethod' , 1 ) . ': ' . count ( $row ) . " <br> \n " ;
$db -> begin ();
$res = 0 ;
$num = count ( $row );
2021-02-22 15:18:01 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2023-10-08 23:19:49 +02:00
if ( getDolGlobalInt ( 'MAIN_FEATURES_LEVEL' ) == 2 ) {
2021-02-22 15:18:01 +01:00
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' ] . '<br>' ;
}
2020-10-28 17:49:52 +01:00
2024-08-07 01:20:43 +02:00
// Look for invoices without payment relations with the same amount and same comppany
2020-10-28 17:49:52 +01:00
$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 " ;
2021-08-23 18:56:46 +02:00
$sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = " . (( int ) $row [ $i ][ 'socid' ]) . " AND total_ttc = " . (( float ) $row [ $i ][ 'pamount' ]);
2020-10-28 17:49:52 +01:00
$sql .= " AND pf.fk_facture IS NULL " ;
$sql .= " ORDER BY f.fk_statut " ;
//print $sql.'<br>';
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
//print 'Nb of invoice found for this amount and company :'.$num.'<br>';
2021-02-22 15:18:01 +01:00
if ( $num >= 1 ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$facid = $obj -> rowid ;
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " paiement_facture (fk_facture, fk_paiement, amount) " ;
2021-08-28 03:09:18 +02:00
$sql .= " VALUES ( " . (( int ) $facid ) . " , " . (( int ) $row [ $i ][ 'paymentid' ]) . " , " . (( float ) $row [ $i ][ 'pamount' ]) . " ) " ;
2020-10-28 17:49:52 +01:00
$res += $db -> query ( $sql );
print $langs -> trans ( 'MigrationProcessPaymentUpdate' , 'facid=' . $facid . '-paymentid=' . $row [ $i ][ 'paymentid' ] . '-amount=' . $row [ $i ][ 'pamount' ]) . " <br> \n " ;
}
} else {
print 'ERROR' ;
}
}
2021-02-22 15:18:01 +01:00
if ( $res > 0 ) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'MigrationSuccessfullUpdate' ) . " <br> " ;
} else {
print $langs -> trans ( 'MigrationPaymentsNothingUpdatable' ) . " <br> \n " ;
}
$db -> commit ();
} else {
print $langs -> trans ( 'MigrationPaymentsNothingUpdatable' ) . " <br> \n " ;
}
} else {
print $langs -> trans ( 'MigrationPaymentsNothingUpdatable' ) . " <br> \n " ;
}
print '</td></tr>' ;
2007-05-25 22:02:23 +02:00
}
/**
2024-08-07 01:20:43 +02:00
* Repair orphan payments ( lost relations due to bugs )
* Query to check if there are still orphans :
2007-05-25 22:02:23 +02:00
* 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 )
2011-09-29 22:21:57 +02:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2007-05-25 22:02:23 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_paiements_orphelins_2 ( $db , $langs , $conf )
2007-05-25 22:02:23 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationPaymentsUpdate' ) . " </b><br> \n " ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " paiement " , " fk_facture " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
// 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 " . MAIN_DB_PREFIX . " paiement_facture as pf ON pf.fk_paiement = p.rowid " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " 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 );
dolibarr_install_syslog ( " upgrade2::migrate_paiements_orphelins_2 " );
$row = array ();
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = $j = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
2021-02-22 15:18:01 +01:00
if ( $obj -> pamount == $obj -> bamount && $obj -> socid ) { // Pour etre sur d'avoir bon cas
2020-10-28 17:49:52 +01:00
$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 ;
$num = count ( $row );
2021-02-22 15:18:01 +01:00
if ( $num ) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'OrphelinsPaymentsDetectedByMethod' , 2 ) . ': ' . count ( $row ) . " <br> \n " ;
$db -> begin ();
$res = 0 ;
2021-02-22 15:18:01 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2023-10-08 23:19:49 +02:00
if ( getDolGlobalInt ( 'MAIN_FEATURES_LEVEL' ) == 2 ) {
2021-08-23 18:56:46 +02:00
print '* ' . $row [ $i ][ 'datec' ] . ' paymentid=' . $row [ $i ][ 'paymentid' ] . ' pamount=' . $row [ $i ][ 'pamount' ] . ' fk_bank=' . $row [ $i ][ 'fk_bank' ] . ' ' . $row [ $i ][ 'bamount' ] . ' socid=' . $row [ $i ][ 'socid' ] . '<br>' ;
2021-02-22 15:18:01 +01:00
}
2020-10-28 17:49:52 +01:00
2024-08-07 01:20:43 +02:00
// Look for invoices without payment relations with the same amount and same comppany
2020-10-28 17:49:52 +01:00
$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 " ;
2021-08-23 18:56:46 +02:00
$sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = " . (( int ) $row [ $i ][ 'socid' ]) . " AND total_ttc = " . (( float ) $row [ $i ][ 'pamount' ]);
2020-10-28 17:49:52 +01:00
$sql .= " AND pf.fk_facture IS NULL " ;
$sql .= " ORDER BY f.fk_statut " ;
//print $sql.'<br>';
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
//print 'Nb of invoice found for this amount and company :'.$num.'<br>';
2021-02-22 15:18:01 +01:00
if ( $num >= 1 ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$facid = $obj -> rowid ;
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " paiement_facture (fk_facture, fk_paiement, amount) " ;
2021-08-28 03:09:18 +02:00
$sql .= " VALUES ( " . (( int ) $facid ) . " , " . (( int ) $row [ $i ][ 'paymentid' ]) . " , " . (( float ) $row [ $i ][ 'pamount' ]) . " ) " ;
2021-08-23 18:56:46 +02:00
2020-10-28 17:49:52 +01:00
$res += $db -> query ( $sql );
print $langs -> trans ( 'MigrationProcessPaymentUpdate' , 'facid=' . $facid . '-paymentid=' . $row [ $i ][ 'paymentid' ] . '-amount=' . $row [ $i ][ 'pamount' ]) . " <br> \n " ;
}
} else {
print 'ERROR' ;
$nberr ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $res > 0 ) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'MigrationSuccessfullUpdate' ) . " <br> " ;
} else {
print $langs -> trans ( 'MigrationPaymentsNothingUpdatable' ) . " <br> \n " ;
}
$db -> commit ();
} else {
print $langs -> trans ( 'MigrationPaymentsNothingUpdatable' ) . " <br> \n " ;
}
// Delete obsolete fields fk_facture
$db -> begin ();
$sql = " ALTER TABLE " . MAIN_DB_PREFIX . " paiement DROP COLUMN fk_facture " ;
$db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $nberr ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
print 'ERROR' ;
$db -> rollback ();
}
} else {
print $langs -> trans ( 'MigrationPaymentsNothingUpdatable' ) . " <br> \n " ;
}
print '</td></tr>' ;
2007-05-24 00:39:52 +02:00
}
2007-05-25 22:02:23 +02:00
2012-02-10 15:56:41 +01:00
/**
2005-10-28 22:26:33 +02:00
* Mise a jour des contrats ( gestion du contrat + detail de contrat )
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2005-10-28 22:26:33 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_contracts_det ( $db , $langs , $conf )
2005-10-28 22:26:33 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
2005-10-28 22:26:33 +02:00
2020-10-28 17:49:52 +01:00
$nberr = 0 ;
2007-10-30 00:11:42 +01:00
2020-10-28 17:49:52 +01:00
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationContractsUpdate' ) . " </b><br> \n " ;
$sql = " SELECT c.rowid as cref, c.date_contrat, c.statut, 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 " );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$row = array ();
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'MigrationContractsNumberToUpdate' , $num ) . " <br> \n " ;
$db -> begin ();
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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 ( " ;
2021-08-28 03:09:18 +02:00
$sql .= (( int ) $obj -> cref ) . " , " . ( $obj -> fk_product ? (( int ) $obj -> fk_product ) : 0 ) . " , " ;
2020-10-28 17:49:52 +01:00
$sql .= " 0, " ;
$sql .= " ' " . $db -> escape ( $obj -> label ) . " ', null, " ;
2021-08-28 03:09:18 +02:00
$sql .= ( $obj -> date_contrat ? " ' " . $db -> idate ( $db -> jdate ( $obj -> date_contrat )) . " ' " : " null " ) . " , " ;
2020-10-28 17:49:52 +01:00
$sql .= " null, " ;
$sql .= " null, " ;
2021-08-28 03:09:18 +02:00
$sql .= (( float ) $obj -> tva_tx ) . " , 1, " ;
$sql .= (( float ) $obj -> price ) . " , " . (( float ) $obj -> price ) . " , " . (( int ) $obj -> fk_user_author ) . " , " ;
2020-10-28 17:49:52 +01:00
$sql .= " null " ;
$sql .= " ) " ;
2021-02-22 15:18:01 +01:00
if ( $db -> query ( $sql )) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'MigrationContractsLineCreation' , $obj -> cref ) . " <br> \n " ;
} else {
dol_print_error ( $db );
$nberr ++ ;
}
$i ++ ;
}
2021-02-22 15:18:01 +01:00
if ( ! $nberr ) {
2020-10-28 17:49:52 +01:00
// $db->rollback();
$db -> commit ();
print $langs -> trans ( 'MigrationSuccessfullUpdate' ) . " <br> " ;
} else {
$db -> rollback ();
print $langs -> trans ( 'MigrationUpdateFailed' ) . '<br>' ;
}
} else {
print $langs -> trans ( 'MigrationContractsNothingToUpdate' ) . " <br> \n " ;
}
} else {
print $langs -> trans ( 'MigrationContractsFieldDontExist' ) . " <br> \n " ;
// dol_print_error($db);
}
print '</td></tr>' ;
}
/**
* Function to migrate links into llx_bank_url
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
function migrate_links_transfert ( $db , $langs , $conf )
{
print '<tr><td colspan="4">' ;
$nberr = 0 ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationBankTransfertsUpdate' ) . " </b><br> \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 );
dolibarr_install_syslog ( " upgrade2::migrate_links_transfert " );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$row = array ();
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
2020-10-28 17:49:52 +01:00
print $langs -> trans ( 'MigrationBankTransfertsToUpdate' , $num ) . " <br> \n " ;
$db -> begin ();
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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/line.php?rowid=', '(banktransfert)', 'banktransfert' " ;
$sql .= " ) " ;
2021-09-03 11:00:14 +02:00
//print $sql.'<br>';
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " migrate_links_transfert " );
2021-02-22 15:18:01 +01:00
if ( ! $db -> query ( $sql )) {
2020-10-28 17:49:52 +01:00
dol_print_error ( $db );
$nberr ++ ;
}
$i ++ ;
}
2021-02-22 15:18:01 +01:00
if ( ! $nberr ) {
2020-10-28 17:49:52 +01:00
// $db->rollback();
$db -> commit ();
print $langs -> trans ( 'MigrationSuccessfullUpdate' ) . " <br> " ;
} else {
$db -> rollback ();
print $langs -> trans ( 'MigrationUpdateFailed' ) . '<br>' ;
}
} else {
print $langs -> trans ( 'MigrationBankTransfertsNothingToUpdate' ) . " <br> \n " ;
}
} else {
dol_print_error ( $db );
}
print '</td></tr>' ;
}
/**
2007-11-28 22:24:36 +01:00
* Mise a jour des date de contrats non renseignees
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2005-10-28 22:26:33 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_contracts_date1 ( $db , $langs , $conf )
2005-10-28 22:26:33 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationContractsEmptyDatesUpdate' ) . " </b><br> \n " ;
$sql = " update " . MAIN_DB_PREFIX . " contrat set date_contrat=tms where date_contrat is null " ;
dolibarr_install_syslog ( " upgrade2::migrate_contracts_date1 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
dol_print_error ( $db );
}
if ( $db -> affected_rows ( $resql ) > 0 ) {
print $langs -> trans ( 'MigrationContractsEmptyDatesUpdateSuccess' ) . " <br> \n " ;
} else {
print $langs -> trans ( 'MigrationContractsEmptyDatesNothingToUpdate' ) . " <br> \n " ;
}
2020-10-28 17:49:52 +01:00
$sql = " update " . MAIN_DB_PREFIX . " contrat set datec=tms where datec is null " ;
dolibarr_install_syslog ( " upgrade2::migrate_contracts_date1 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
dol_print_error ( $db );
}
if ( $db -> affected_rows ( $resql ) > 0 ) {
print $langs -> trans ( 'MigrationContractsEmptyCreationDatesUpdateSuccess' ) . " <br> \n " ;
} else {
print $langs -> trans ( 'MigrationContractsEmptyCreationDatesNothingToUpdate' ) . " <br> \n " ;
}
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
2005-10-28 22:26:33 +02:00
}
2020-05-03 22:47:43 +02:00
/**
* Update contracts with date min real if service date is lower
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Language
* @ param Conf $conf Conf
* @ return void
2005-10-28 22:26:33 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_contracts_date2 ( $db , $langs , $conf )
2005-10-28 22:26:33 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
$nberr = 0 ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationContractsInvalidDatesUpdate' ) . " </b><br> \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 );
dolibarr_install_syslog ( " upgrade2::migrate_contracts_date2 " );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$row = array ();
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
2020-10-28 17:49:52 +01:00
$nbcontratsmodifie = 0 ;
$db -> begin ();
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
2021-02-22 15:18:01 +01:00
if ( $obj -> date_contrat > $obj -> datemin ) {
2020-10-28 17:49:52 +01:00
$datemin = $db -> jdate ( $obj -> datemin );
print $langs -> trans ( 'MigrationContractsInvalidDateFix' , $obj -> cref , $obj -> date_contrat , $obj -> datemin ) . " <br> \n " ;
$sql = " UPDATE " . MAIN_DB_PREFIX . " contrat " ;
$sql .= " SET date_contrat=' " . $db -> idate ( $datemin ) . " ' " ;
2021-06-09 15:36:47 +02:00
$sql .= " WHERE rowid = " . (( int ) $obj -> cref );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
dol_print_error ( $db );
}
2020-10-28 17:49:52 +01:00
$nbcontratsmodifie ++ ;
}
$i ++ ;
}
$db -> commit ();
2021-02-22 15:18:01 +01:00
if ( $nbcontratsmodifie ) {
print $langs -> trans ( 'MigrationContractsInvalidDatesNumber' , $nbcontratsmodifie ) . " <br> \n " ;
} else {
print $langs -> trans ( 'MigrationContractsInvalidDatesNothingToUpdate' ) . " <br> \n " ;
}
2020-10-28 17:49:52 +01:00
}
} else {
dol_print_error ( $db );
}
print '</td></tr>' ;
2005-10-28 22:26:33 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2007-11-28 22:24:36 +01:00
* Mise a jour des dates de creation de contrat
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2005-10-28 22:26:33 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_contracts_date3 ( $db , $langs , $conf )
2005-10-28 22:26:33 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
2008-05-21 05:53:52 +02:00
2020-10-28 17:49:52 +01:00
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationContractsIncoherentCreationDateUpdate' ) . " </b><br> \n " ;
2008-05-21 05:53:52 +02:00
2020-10-28 17:49:52 +01:00
$sql = " update " . MAIN_DB_PREFIX . " contrat set datec=date_contrat where datec is null or datec > date_contrat " ;
dolibarr_install_syslog ( " upgrade2::migrate_contracts_date3 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
dol_print_error ( $db );
}
if ( $db -> affected_rows ( $resql ) > 0 ) {
print $langs -> trans ( 'MigrationContractsIncoherentCreationDateUpdateSuccess' ) . " <br> \n " ;
} else {
print $langs -> trans ( 'MigrationContractsIncoherentCreationDateNothingToUpdate' ) . " <br> \n " ;
}
2006-08-20 04:06:48 +02:00
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
2005-10-28 22:26:33 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2007-11-28 22:24:36 +01:00
* Reouverture des contrats qui ont au moins une ligne non fermee
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2005-10-28 22:26:33 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_contracts_open ( $db , $langs , $conf )
2005-10-28 22:26:33 +02:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationReopeningContracts' ) . " </b><br> \n " ;
$sql = " SELECT c.rowid as cref FROM " . MAIN_DB_PREFIX . " contrat as c, " . MAIN_DB_PREFIX . " 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 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
dol_print_error ( $db );
}
2020-10-28 17:49:52 +01:00
if ( $db -> affected_rows ( $resql ) > 0 ) {
$i = 0 ;
$row = array ();
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
2020-10-28 17:49:52 +01:00
$nbcontratsmodifie = 0 ;
$db -> begin ();
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
print $langs -> trans ( 'MigrationReopenThisContract' , $obj -> cref ) . " <br> \n " ;
$sql = " UPDATE " . MAIN_DB_PREFIX . " contrat " ;
2021-06-09 15:36:47 +02:00
$sql .= " SET statut = 1 " ;
$sql .= " WHERE rowid = " . (( int ) $obj -> cref );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
dol_print_error ( $db );
}
2020-10-28 17:49:52 +01:00
$nbcontratsmodifie ++ ;
$i ++ ;
}
$db -> commit ();
2021-02-22 15:18:01 +01:00
if ( $nbcontratsmodifie ) {
print $langs -> trans ( 'MigrationReopenedContractsNumber' , $nbcontratsmodifie ) . " <br> \n " ;
} else {
print $langs -> trans ( 'MigrationReopeningContractsNothingToUpdate' ) . " <br> \n " ;
}
2020-10-28 17:49:52 +01:00
}
2021-02-22 15:18:01 +01:00
} else {
print $langs -> trans ( 'MigrationReopeningContractsNothingToUpdate' ) . " <br> \n " ;
}
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
2005-10-28 22:26:33 +02:00
}
/**
* Factures fournisseurs
2011-09-29 22:21:57 +02:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2005-10-28 22:26:33 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_paiementfourn_facturefourn ( $db , $langs , $conf )
2005-10-28 22:26:33 +02:00
{
2020-10-28 17:49:52 +01:00
global $bc ;
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'SuppliersInvoices' ) . " </b><br> \n " ;
print '</td></tr>' ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " paiementfourn " , " fk_facture_fourn " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
$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' ;
dolibarr_install_syslog ( " upgrade2::migrate_paiementfourn_facturefourn " );
$select_resql = $db -> query ( $select_sql );
2021-02-22 15:18:01 +01:00
if ( $select_resql ) {
2020-10-28 17:49:52 +01:00
$select_num = $db -> num_rows ( $select_resql );
$i = 0 ;
// Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn
2021-02-22 15:18:01 +01:00
while (( $i < $select_num ) && ( ! $error )) {
2020-10-28 17:49:52 +01:00
$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' ;
2021-03-30 17:45:15 +02:00
$check_sql .= ' WHERE fk_paiementfourn = ' . (( int ) $select_obj -> rowid ) . ' AND fk_facturefourn = ' . (( int ) $select_obj -> fk_facture_fourn );
2020-10-28 17:49:52 +01:00
$check_resql = $db -> query ( $check_sql );
2021-02-22 15:18:01 +01:00
if ( $check_resql ) {
2020-10-28 17:49:52 +01:00
$check_num = $db -> num_rows ( $check_resql );
2021-02-22 15:18:01 +01:00
if ( $check_num == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> begin ();
2021-02-22 15:18:01 +01:00
if ( $nb == 0 ) {
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4" class="nowrap"><b>' . $langs -> trans ( 'SuppliersInvoices' ) . '</b></td></tr>' ;
print '<tr><td>fk_paiementfourn</td><td>fk_facturefourn</td><td>' . $langs -> trans ( 'Amount' ) . '</td><td> </td></tr>' ;
}
print '<tr class="oddeven">' ;
print '<td>' . $select_obj -> rowid . '</td><td>' . $select_obj -> fk_facture_fourn . '</td><td>' . $select_obj -> amount . '</td>' ;
$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 );
2021-02-22 15:18:01 +01:00
if ( $insert_resql ) {
2020-10-28 17:49:52 +01:00
$nb ++ ;
2020-11-26 11:09:35 +01:00
print '<td><span class="ok">' . $langs -> trans ( " OK " ) . '</span></td>' ;
2020-10-28 17:49:52 +01:00
} else {
2020-11-26 11:09:35 +01:00
print '<td><span class="error">Error on insert</span></td>' ;
2020-10-28 17:49:52 +01:00
$error ++ ;
}
print '</tr>' ;
}
} else {
$error ++ ;
}
$i ++ ;
}
} else {
$error ++ ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
if ( ! $nb ) {
2020-10-28 17:49:52 +01:00
print '<tr><td>' . $langs -> trans ( " AlreadyDone " ) . '</td></tr>' ;
}
$db -> commit ();
$sql = " ALTER TABLE " . MAIN_DB_PREFIX . " paiementfourn DROP COLUMN fk_facture_fourn " ;
$db -> query ( $sql );
} else {
print '<tr><td>' . $langs -> trans ( " Error " ) . '</td></tr>' ;
$db -> rollback ();
}
} else {
print '<tr><td>' . $langs -> trans ( " AlreadyDone " ) . '</td></tr>' ;
}
2005-10-28 22:26:33 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2019-07-05 21:50:35 +02:00
* Update total of invoice lines
2012-03-03 16:44:05 +01:00
*
2012-02-10 15:56:41 +01:00
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2006-06-17 01:55:20 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_price_facture ( $db , $langs , $conf )
2006-06-17 01:55:20 +02:00
{
2020-10-28 17:49:52 +01:00
$err = 0 ;
$tmpmysoc = new Societe ( $db );
$tmpmysoc -> setMysoc ( $conf );
$db -> begin ();
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationInvoice' ) . " </b><br> \n " ;
// List of invoice lines not up to date
$sql = " SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as vatrate, 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 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$rowid = $obj -> rowid ;
$qty = $obj -> qty ;
$pu = $obj -> subprice ;
$vatrate = $obj -> vatrate ;
$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 );
$result = calcul_price_total ( $qty , $pu , $remise_percent , $vatrate , 0 , 0 , $remise_percent_global , 'HT' , $info_bits , $facligne -> product_type , $tmpmysoc );
$total_ht = $result [ 0 ];
$total_tva = $result [ 1 ];
$total_ttc = $result [ 2 ];
2024-11-04 12:32:13 +01:00
$facligne -> total_ht = ( float ) $total_ht ;
$facligne -> total_tva = ( float ) $total_tva ;
$facligne -> total_ttc = ( float ) $total_ttc ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2: line " . $rowid . " : facid= " . $obj -> facid . " pu= " . $pu . " qty= " . $qty . " vatrate= " . $vatrate . " remise_percent= " . $remise_percent . " remise_global= " . $remise_percent_global . " -> " . $total_ht . " , " . $total_tva . " , " . $total_ttc );
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$facligne -> update_total ();
/* On touche a facture mere uniquement si total_ttc = 0 */
2021-02-22 15:18:01 +01:00
if ( ! $total_ttc_f ) {
2020-10-28 17:49:52 +01:00
$facture = new Facture ( $db );
$facture -> id = $obj -> facid ;
2021-02-22 15:18:01 +01:00
if ( $facture -> fetch ( $facture -> id ) >= 0 ) {
if ( $facture -> update_price () > 0 ) {
2020-10-28 17:49:52 +01:00
//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 );
$db -> commit ();
} else {
print " Error #1 " . $db -> error ();
$err ++ ;
$db -> rollback ();
}
print '<br>' ;
print '</td></tr>' ;
2006-06-17 01:55:20 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2019-07-05 21:50:35 +02:00
* Update total of proposal lines
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2006-06-17 03:53:32 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_price_propal ( $db , $langs , $conf )
2006-06-17 03:53:32 +02:00
{
2021-02-22 15:18:01 +01:00
$tmpmysoc = new Societe ( $db );
2015-12-17 19:37:24 +01:00
$tmpmysoc -> setMysoc ( $conf );
2016-07-07 12:19:20 +02:00
2020-10-28 17:49:52 +01:00
$db -> begin ();
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationProposal' ) . " </b><br> \n " ;
// List of proposal lines not up to date
$sql = " SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as vatrate, 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 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$rowid = $obj -> rowid ;
$qty = $obj -> qty ;
$pu = $obj -> subprice ;
$vatrate = $obj -> vatrate ;
$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 );
$result = calcul_price_total ( $qty , $pu , $remise_percent , $vatrate , 0 , 0 , $remise_percent_global , 'HT' , $info_bits , $propalligne -> product_type , $tmpmysoc );
$total_ht = $result [ 0 ];
$total_tva = $result [ 1 ];
$total_ttc = $result [ 2 ];
2024-11-04 12:32:13 +01:00
$propalligne -> total_ht = ( float ) $total_ht ;
$propalligne -> total_tva = ( float ) $total_tva ;
$propalligne -> total_ttc = ( float ) $total_ttc ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2: Line " . $rowid . " : propalid= " . $obj -> rowid . " pu= " . $pu . " qty= " . $qty . " vatrate= " . $vatrate . " remise_percent= " . $remise_percent . " remise_global= " . $remise_percent_global . " -> " . $total_ht . " , " . $total_tva . " , " . $total_ttc );
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$propalligne -> update_total ();
$i ++ ;
}
} else {
print $langs -> trans ( " AlreadyDone " );
}
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> free ( $resql );
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
print " Error #1 " . $db -> error ();
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> rollback ();
}
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
print '<br>' ;
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
2007-07-07 18:38:58 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2014-02-08 14:55:27 +01:00
* Update total of contract lines
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2007-07-07 18:38:58 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_price_contrat ( $db , $langs , $conf )
2007-07-07 18:38:58 +02:00
{
2020-10-28 17:49:52 +01:00
$db -> begin ();
2011-09-29 22:21:57 +02:00
2021-02-22 15:18:01 +01:00
$tmpmysoc = new Societe ( $db );
2014-02-08 14:55:27 +01:00
$tmpmysoc -> setMysoc ( $conf );
2021-02-22 15:18:01 +01:00
if ( empty ( $tmpmysoc -> country_id )) {
$tmpmysoc -> country_id = 0 ; // Ti not have this set to '' or will make sql syntax error.
}
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationContract' ) . " </b><br> \n " ;
// List of contract lines not up to date
$sql = " SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, 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 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$rowid = $obj -> rowid ;
$qty = $obj -> qty ;
$pu = $obj -> subprice ;
$vatrate = $obj -> vatrate ;
$remise_percent = $obj -> remise_percent ;
$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 -> fetch ( $rowid );
$result = calcul_price_total ( $qty , $pu , $remise_percent , $vatrate , 0 , 0 , 0 , 'HT' , $info_bits , $contratligne -> product_type , $tmpmysoc );
$total_ht = $result [ 0 ];
$total_tva = $result [ 1 ];
$total_ttc = $result [ 2 ];
2024-11-04 12:32:13 +01:00
$contratligne -> total_ht = ( float ) $total_ht ;
$contratligne -> total_tva = ( float ) $total_tva ;
$contratligne -> total_ttc = ( float ) $total_ttc ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2: Line " . $rowid . " : contratdetid= " . $obj -> rowid . " pu= " . $pu . " qty= " . $qty . " vatrate= " . $vatrate . " remise_percent= " . $remise_percent . " -> " . $total_ht . " , " . $total_tva . " , " . $total_ttc );
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$contratligne -> update_total ();
$i ++ ;
}
} else {
print $langs -> trans ( " AlreadyDone " );
}
$db -> free ( $resql );
$db -> commit ();
} else {
print " Error #1 " . $db -> error ();
$db -> rollback ();
}
print '<br>' ;
print '</td></tr>' ;
2006-06-17 03:53:32 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2019-07-05 21:50:35 +02:00
* Update total of sales order lines
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2006-06-17 03:53:32 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_price_commande ( $db , $langs , $conf )
2006-06-17 03:53:32 +02:00
{
2020-10-28 17:49:52 +01:00
$db -> begin ();
$tmpmysoc = new Societe ( $db );
$tmpmysoc -> setMysoc ( $conf );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationOrder' ) . " </b><br> \n " ;
// List of sales orders lines not up to date
$sql = " SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, 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 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$rowid = $obj -> rowid ;
$qty = $obj -> qty ;
$pu = $obj -> subprice ;
$vatrate = $obj -> vatrate ;
$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 );
$result = calcul_price_total ( $qty , $pu , $remise_percent , $vatrate , 0 , 0 , $remise_percent_global , 'HT' , $info_bits , $commandeligne -> product_type , $tmpmysoc );
$total_ht = $result [ 0 ];
$total_tva = $result [ 1 ];
$total_ttc = $result [ 2 ];
2024-11-04 12:32:13 +01:00
$commandeligne -> total_ht = ( float ) $total_ht ;
$commandeligne -> total_tva = ( float ) $total_tva ;
$commandeligne -> total_ttc = ( float ) $total_ttc ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2: Line " . $rowid . " : commandeid= " . $obj -> rowid . " pu= " . $pu . " qty= " . $qty . " vatrate= " . $vatrate . " remise_percent= " . $remise_percent . " remise_global= " . $remise_percent_global . " -> " . $total_ht . " , " . $total_tva . " , " . $total_ttc );
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$commandeligne -> update_total ();
$i ++ ;
}
} else {
print $langs -> trans ( " AlreadyDone " );
}
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> free ( $resql );
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
/*
2021-02-22 15:18:01 +01:00
$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 );
}
*/
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
print " Error #1 " . $db -> error ();
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> rollback ();
}
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
print '<br>' ;
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
2006-06-17 03:53:32 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2019-07-05 21:50:35 +02:00
* Update total of purchase order lines
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2008-03-07 11:34:16 +01:00
*/
2019-01-27 15:20:16 +01:00
function migrate_price_commande_fournisseur ( $db , $langs , $conf )
2008-03-07 11:34:16 +01:00
{
2023-11-30 17:44:45 +01:00
global $mysoc ;
2020-10-28 17:49:52 +01:00
$db -> begin ();
$tmpmysoc = new Societe ( $db );
$tmpmysoc -> setMysoc ( $conf );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationSupplierOrder' ) . " </b><br> \n " ;
// List of purchase order lines not up to date
$sql = " SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, 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 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$rowid = $obj -> rowid ;
$qty = $obj -> qty ;
$pu = $obj -> subprice ;
$vatrate = $obj -> vatrate ;
$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 );
2023-08-30 09:33:34 +02:00
$result = calcul_price_total ( $qty , $pu , $remise_percent , $vatrate , 0 , 0 , $remise_percent_global , 'HT' , $info_bits , $commandeligne -> product_type , $mysoc );
2020-10-28 17:49:52 +01:00
$total_ht = $result [ 0 ];
$total_tva = $result [ 1 ];
$total_ttc = $result [ 2 ];
2024-11-04 12:32:13 +01:00
$commandeligne -> total_ht = ( float ) $total_ht ;
$commandeligne -> total_tva = ( float ) $total_tva ;
$commandeligne -> total_ttc = ( float ) $total_ttc ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2: Line " . $rowid . " : commandeid= " . $obj -> rowid . " pu= " . $pu . " qty= " . $qty . " vatrate= " . $vatrate . " remise_percent= " . $remise_percent . " remise_global= " . $remise_percent_global . " -> " . $total_ht . " , " . $total_tva . " , " . $total_ttc );
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$commandeligne -> update_total ();
$i ++ ;
}
} else {
print $langs -> trans ( " AlreadyDone " );
}
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> free ( $resql );
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
/*
2021-02-22 15:18:01 +01:00
$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 );
}
*/
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
print " Error #1 " . $db -> error ();
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
$db -> rollback ();
}
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
print '<br>' ;
2011-09-29 22:21:57 +02:00
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
2008-03-07 11:34:16 +01:00
}
2012-02-10 15:56:41 +01:00
/**
2006-06-03 01:20:36 +02:00
* Mise a jour des modeles selectionnes
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2006-06-03 01:20:36 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_modeles ( $db , $langs , $conf )
2006-06-03 01:20:36 +02:00
{
2020-10-28 17:49:52 +01:00
//print '<br>';
//print '<b>'.$langs->trans('UpdateModelsTable')."</b><br>\n";
dolibarr_install_syslog ( " upgrade2::migrate_modeles " );
2024-02-27 15:30:37 +01:00
if ( isModEnabled ( 'invoice' )) {
2020-10-28 17:49:52 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php' ;
$modellist = ModelePDFFactures :: liste_modeles ( $db );
2021-02-22 15:18:01 +01:00
if ( count ( $modellist ) == 0 ) {
2024-01-13 19:48:41 +01:00
// Aucun model par default.
2020-10-28 17:49:52 +01:00
$sql = " insert into " . MAIN_DB_PREFIX . " document_model(nom,type) values('crabe','invoice') " ;
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
dol_print_error ( $db );
}
2020-10-28 17:49:52 +01:00
}
}
2024-02-27 15:30:37 +01:00
if ( isModEnabled ( 'order' )) {
2020-10-28 17:49:52 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php' ;
$modellist = ModelePDFCommandes :: liste_modeles ( $db );
2021-02-22 15:18:01 +01:00
if ( count ( $modellist ) == 0 ) {
2024-01-13 19:48:41 +01:00
// Aucun model par default.
2020-10-28 17:49:52 +01:00
$sql = " insert into " . MAIN_DB_PREFIX . " document_model(nom,type) values('einstein','order') " ;
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
dol_print_error ( $db );
}
2020-10-28 17:49:52 +01:00
}
}
2024-03-12 11:07:18 +01:00
if ( isModEnabled ( " shipping " )) {
2020-10-28 17:49:52 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/expedition/modules_expedition.php' ;
2023-08-05 14:09:11 +02:00
$modellist = ModelePdfExpedition :: liste_modeles ( $db );
2021-02-22 15:18:01 +01:00
if ( count ( $modellist ) == 0 ) {
2024-01-13 19:48:41 +01:00
// Aucun model par default.
2020-10-28 17:49:52 +01:00
$sql = " insert into " . MAIN_DB_PREFIX . " document_model(nom,type) values('rouget','shipping') " ;
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
dol_print_error ( $db );
}
2020-10-28 17:49:52 +01:00
}
}
//print $langs->trans("AlreadyDone");
2006-06-03 01:20:36 +02:00
}
2007-12-11 21:08:53 +01:00
2012-02-10 15:56:41 +01:00
/**
2024-01-13 19:48:41 +01:00
* Correspondence des expeditions et des commandes clients dans la table llx_co_exp
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2008-01-17 11:27:59 +01:00
*/
2019-01-27 15:20:16 +01:00
function migrate_commande_expedition ( $db , $langs , $conf )
2008-01-17 11:27:59 +01:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_commande_expedition " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationShipmentOrderMatching' ) . " </b><br> \n " ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " expedition " , " fk_commande " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
$error = 0 ;
$db -> begin ();
$sql = " SELECT e.rowid, e.fk_commande FROM " . MAIN_DB_PREFIX . " expedition as e " ;
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " co_exp (fk_expedition,fk_commande) " ;
2021-08-28 03:09:18 +02:00
$sql .= " VALUES ( " . (( int ) $obj -> rowid ) . " , " . (( int ) $obj -> fk_commande ) . " ) " ;
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
$sql = " ALTER TABLE " . MAIN_DB_PREFIX . " expedition DROP COLUMN fk_commande " ;
print $langs -> trans ( 'FieldRenamed' ) . " <br> \n " ;
$db -> query ( $sql );
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
2008-01-17 11:27:59 +01:00
}
2012-02-10 15:56:41 +01:00
/**
2024-01-13 19:48:41 +01:00
* Correspondence des livraisons et des commandes clients dans la table llx_co_liv
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2008-01-21 20:17:46 +01:00
*/
2019-01-27 15:20:16 +01:00
function migrate_commande_livraison ( $db , $langs , $conf )
2008-01-21 20:17:46 +01:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_commande_livraison " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationDeliveryOrderMatching' ) . " </b><br> \n " ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " livraison " , " fk_commande " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
$error = 0 ;
$db -> begin ();
2020-11-16 12:20:18 +01:00
$sql = " SELECT l.rowid, l.fk_commande, " ;
$sql .= " c.ref_client, c.date_livraison as delivery_date " ;
2020-10-28 17:49:52 +01:00
$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 );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " co_liv (fk_livraison,fk_commande) " ;
2021-08-28 03:09:18 +02:00
$sql .= " VALUES ( " . (( int ) $obj -> rowid ) . " , " . (( int ) $obj -> fk_commande ) . " ) " ;
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql2 ) {
2020-11-16 12:20:18 +01:00
$delivery_date = $db -> jdate ( $obj -> delivery_date );
2020-10-28 17:49:52 +01:00
$sqlu = " UPDATE " . MAIN_DB_PREFIX . " livraison SET " ;
2021-08-28 03:09:18 +02:00
$sqlu .= " ref_client = ' " . $db -> escape ( $obj -> ref_client ) . " ' " ;
$sqlu .= " , date_livraison = ' " . $db -> idate ( $delivery_date ) . " ' " ;
2021-08-27 18:18:50 +02:00
$sqlu .= " WHERE rowid = " . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
$resql3 = $db -> query ( $sqlu );
2021-02-22 15:18:01 +01:00
if ( ! $resql3 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
} else {
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
$sql = " ALTER TABLE " . MAIN_DB_PREFIX . " livraison DROP COLUMN fk_commande " ;
print $langs -> trans ( 'FieldRenamed' ) . " <br> \n " ;
$db -> query ( $sql );
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
2008-01-21 20:17:46 +01:00
}
2012-02-10 15:56:41 +01:00
/**
2009-09-25 12:53:58 +02:00
* Migration des details commandes dans les details livraisons
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2008-01-21 20:17:46 +01:00
*/
2019-01-27 15:20:16 +01:00
function migrate_detail_livraison ( $db , $langs , $conf )
2008-01-21 20:17:46 +01:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_detail_livraison " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationDeliveryDetail' ) . " </b><br> \n " ;
// This is done if field fk_commande_ligne exists.
// If not this means migration was already done.
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " livraisondet " , " fk_commande_ligne " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
$error = 0 ;
$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 );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sql = " UPDATE " . MAIN_DB_PREFIX . " livraisondet SET " ;
2021-08-27 18:18:50 +02:00
$sql .= " fk_product = " . (( int ) $obj -> fk_product );
$sql .= " ,description = ' " . $db -> escape ( $obj -> description ) . " ' " ;
$sql .= " ,subprice = " . price2num ( $obj -> subprice );
$sql .= " ,total_ht = " . price2num ( $obj -> total_ht );
$sql .= " WHERE fk_commande_ligne = " . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql2 ) {
2020-10-28 17:49:52 +01:00
$sql = " SELECT total_ht " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " livraison " ;
2021-03-30 19:12:07 +02:00
$sql .= " WHERE rowid = " . (( int ) $obj -> fk_livraison );
2020-10-28 17:49:52 +01:00
$resql3 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql3 ) {
2020-10-28 17:49:52 +01:00
$obju = $db -> fetch_object ( $resql3 );
$total_ht = $obju -> total_ht + $obj -> total_ht ;
$sqlu = " UPDATE " . MAIN_DB_PREFIX . " livraison SET " ;
2021-08-27 18:18:50 +02:00
$sqlu .= " total_ht = " . price2num ( $total_ht , 'MT' );
$sqlu .= " WHERE rowid = " . (( int ) $obj -> fk_livraison );
2020-10-28 17:49:52 +01:00
$resql4 = $db -> query ( $sqlu );
2021-02-22 15:18:01 +01:00
if ( ! $resql4 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
} else {
$error ++ ;
dol_print_error ( $db );
}
} else {
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
$sql = " ALTER TABLE " . MAIN_DB_PREFIX . " livraisondet CHANGE fk_commande_ligne fk_origin_line integer " ;
print $langs -> trans ( 'FieldRenamed' ) . " <br> \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 );
2021-02-22 15:18:01 +01:00
if ( ! $obj ) {
2020-10-28 17:49:52 +01:00
$sql = " ALTER TABLE " . MAIN_DB_PREFIX . " livraisondet ADD COLUMN fk_origin_line integer after fk_livraison " ;
$db -> query ( $sql );
}
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
2008-01-21 20:17:46 +01:00
}
2012-02-10 15:56:41 +01:00
/**
2009-02-06 07:26:45 +01:00
* Migration du champ stock dans produits
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2009-02-06 07:26:45 +01:00
*/
2019-01-27 15:20:16 +01:00
function migrate_stocks ( $db , $langs , $conf )
2009-02-06 07:26:45 +01:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_stocks " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationStockDetail' ) . " </b><br> \n " ;
$error = 0 ;
$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 );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sql = " UPDATE " . MAIN_DB_PREFIX . " product SET " ;
2021-08-27 18:18:50 +02:00
$sql .= " stock = " . price2num ( $obj -> total , 'MS' );
$sql .= " WHERE rowid = " . (( int ) $obj -> fk_product );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql2 ) {
2020-10-28 17:49:52 +01:00
} else {
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
2009-02-06 07:26:45 +01:00
}
2012-02-10 15:56:41 +01:00
/**
2009-05-27 15:39:09 +02:00
* Migration of menus ( use only 1 table instead of 3 )
2012-02-10 15:56:41 +01:00
* 2.6 -> 2.7
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2009-05-27 15:39:09 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_menus ( $db , $langs , $conf )
2009-05-27 15:39:09 +02:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_menus " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationMenusDetail' ) . " </b><br> \n " ;
$error = 0 ;
2021-02-22 15:18:01 +01:00
if ( $db -> DDLInfoTable ( MAIN_DB_PREFIX . " menu_constraint " )) {
2020-10-28 17:49:52 +01:00
$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 );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sql = " UPDATE " . MAIN_DB_PREFIX . " menu SET " ;
$sql .= " enabled = ' " . $db -> escape ( $obj -> action ) . " ' " ;
2021-08-27 18:18:50 +02:00
$sql .= " WHERE rowid = " . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
$sql .= " AND enabled = '1' " ;
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql2 ) {
2020-10-28 17:49:52 +01:00
} else {
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
2009-05-27 15:39:09 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2009-07-08 16:50:16 +02:00
* Migration du champ fk_adresse_livraison dans expedition
2010-07-29 14:37:09 +02:00
* 2.6 -> 2.7
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2009-07-08 16:50:16 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_commande_deliveryaddress ( $db , $langs , $conf )
2009-07-08 16:50:16 +02:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_commande_deliveryaddress " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationDeliveryAddress' ) . " </b><br> \n " ;
$error = 0 ;
2021-02-22 15:18:01 +01:00
if ( $db -> DDLInfoTable ( MAIN_DB_PREFIX . " co_exp " )) {
2020-10-28 17:49:52 +01:00
$db -> begin ();
$sql = " SELECT c.fk_adresse_livraison, ce.fk_expedition " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commande as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " co_exp as ce " ;
$sql .= " WHERE c.rowid = ce.fk_commande " ;
$sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0 " ;
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sql = " UPDATE " . MAIN_DB_PREFIX . " expedition SET " ;
$sql .= " fk_adresse_livraison = ' " . $db -> escape ( $obj -> fk_adresse_livraison ) . " ' " ;
2021-08-27 18:18:50 +02:00
$sql .= " WHERE rowid = " . (( int ) $obj -> fk_expedition );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
2009-07-08 16:50:16 +02:00
}
2012-02-10 15:56:41 +01:00
/**
2009-08-22 05:09:52 +02:00
* Migration du champ fk_remise_except dans llx_facturedet doit correspondre a
2024-08-07 01:20:43 +02:00
* Link in `llx_societe_remise_except` to `llx_facturedet`
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
2023-12-06 15:46:39 +01:00
* @ return integer Return integer < 0 if KO , 0 = Bad version , > 0 if OK
2009-08-22 05:09:52 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_restore_missing_links ( $db , $langs , $conf )
2009-08-22 05:09:52 +02:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_restore_missing_links " );
2009-08-22 05:09:52 +02:00
2021-02-22 15:18:01 +01:00
if (( $db -> type == 'mysql' || $db -> type == 'mysqli' )) {
if ( versioncompare ( $db -> getVersionArray (), array ( 4 , 0 )) < 0 ) {
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action " );
return 0 ;
}
}
print '<tr><td colspan="4">' ;
2010-01-26 15:08:59 +01:00
2020-10-28 17:49:52 +01:00
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationFixData' ) . " </b> (1)<br> \n " ;
2010-01-26 14:28:25 +01:00
2020-10-28 17:49:52 +01:00
$error = 0 ;
2009-12-11 17:31:42 +01:00
2010-03-01 17:42:02 +01:00
2020-10-28 17:49:52 +01:00
// Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1.
2023-12-04 12:36:19 +01:00
$table1 = 'facturedet' ;
$field1 = 'fk_remise_except' ;
$table2 = 'societe_remise_except' ;
$field2 = 'fk_facture_line' ;
2020-10-28 17:49:52 +01:00
$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 . " ) " ;
dolibarr_install_syslog ( " upgrade2::migrate_restore_missing_links DIRECTION 1 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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.<br>' ;
2024-10-29 02:18:17 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . $db -> sanitize ( $table2 ) . " SET " ;
$sql .= " " . $db -> sanitize ( $field2 ) . " = ' " . $db -> escape ( $obj -> rowid ) . " ' " ;
2021-06-14 13:51:09 +02:00
$sql .= " WHERE rowid = " . (( int ) $obj -> field );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
//print '. ';
2020-10-28 17:49:52 +01:00
$i ++ ;
}
2021-02-22 15:18:01 +01:00
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2020-10-28 17:49:52 +01:00
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationFixData' ) . " </b> (2)<br> \n " ;
// Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2.
2023-12-04 12:36:19 +01:00
$table2 = 'facturedet' ;
$field2 = 'fk_remise_except' ;
$table1 = 'societe_remise_except' ;
$field1 = 'fk_facture_line' ;
2020-10-28 17:49:52 +01:00
$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 . " ) " ;
dolibarr_install_syslog ( " upgrade2::migrate_restore_missing_links DIRECTION 2 " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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.<br>' ;
2024-10-29 02:18:17 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . $db -> sanitize ( $table2 ) . " SET " ;
$sql .= " " . $db -> sanitize ( $field2 ) . " = ' " . $db -> escape ( $obj -> rowid ) . " ' " ;
2021-06-14 13:51:09 +02:00
$sql .= " WHERE rowid = " . (( int ) $obj -> field );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
//print '. ';
2020-10-28 17:49:52 +01:00
$i ++ ;
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
2023-05-30 13:21:07 +02:00
return ( $error ? - 1 : 1 );
2020-10-28 17:49:52 +01:00
}
/**
* Migration du champ fk_user_resp de llx_projet vers llx_element_contact
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
function migrate_project_user_resp ( $db , $langs , $conf )
{
dolibarr_install_syslog ( " upgrade2::migrate_project_user_resp " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationProjectUserResp' ) . " </b><br> \n " ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " projet " , " fk_user_resp " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
$error = 0 ;
$db -> begin ();
$sql = " SELECT rowid, fk_user_resp FROM " . MAIN_DB_PREFIX . " projet " ;
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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 .= " ) " ;
2021-02-22 15:18:01 +01:00
if ( $obj -> fk_user_resp > 0 ) {
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql2 );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$sqlDrop = " ALTER TABLE " . MAIN_DB_PREFIX . " projet DROP COLUMN fk_user_resp " ;
2021-02-22 15:18:01 +01:00
if ( $db -> query ( $sqlDrop )) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
}
/**
* Migration de la table llx_projet_task_actors vers llx_element_contact
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
function migrate_project_task_actors ( $db , $langs , $conf )
{
dolibarr_install_syslog ( " upgrade2::migrate_project_task_actors " );
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationProjectTaskActors' ) . " </b><br> \n " ;
2021-02-22 15:18:01 +01:00
if ( $db -> DDLInfoTable ( MAIN_DB_PREFIX . " projet_task_actors " )) {
2020-10-28 17:49:52 +01:00
$error = 0 ;
$db -> begin ();
$sql = " SELECT fk_projet_task as fk_project_task, fk_user FROM " . MAIN_DB_PREFIX . " projet_task_actors " ;
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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_project_task ;
$sql2 .= " , '180' " ;
$sql2 .= " , " . $obj -> fk_user ;
$sql2 .= " ) " ;
$resql2 = $db -> query ( $sql2 );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$sqlDrop = " DROP TABLE " . MAIN_DB_PREFIX . " projet_task_actors " ;
2021-02-22 15:18:01 +01:00
if ( $db -> query ( $sqlDrop )) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
}
/**
* Migration des tables de relation
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ param string $table Table name
2024-03-23 15:28:25 +01:00
* @ param string $fk_source Id of element source ( name of field )
2020-10-28 17:49:52 +01:00
* @ param string $sourcetype Type of element source
2024-03-23 15:28:25 +01:00
* @ param string $fk_target Id of element target
2020-10-28 17:49:52 +01:00
* @ param string $targettype Type of element target
* @ return void
*/
function migrate_relationship_tables ( $db , $langs , $conf , $table , $fk_source , $sourcetype , $fk_target , $targettype )
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationRelationshipTables' , MAIN_DB_PREFIX . $table ) . " </b><br> \n " ;
$error = 0 ;
2021-02-22 15:18:01 +01:00
if ( $db -> DDLInfoTable ( MAIN_DB_PREFIX . $table )) {
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_relationship_tables table = " . MAIN_DB_PREFIX . $table );
$db -> begin ();
$sqlSelect = " SELECT " . $fk_source . " , " . $fk_target ;
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . $table ;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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 .= " , ' " . $db -> escape ( $sourcetype ) . " ' " ;
$sqlInsert .= " , " . $obj -> $fk_target ;
$sqlInsert .= " , ' " . $db -> escape ( $targettype ) . " ' " ;
$sqlInsert .= " ) " ;
$result = $db -> query ( $sqlInsert );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$sqlDrop = " DROP TABLE " . MAIN_DB_PREFIX . $table ;
2021-02-22 15:18:01 +01:00
if ( $db -> query ( $sqlDrop )) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
} else {
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
}
/**
* Migrate duration in seconds
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2023-03-08 11:00:58 +01:00
function migrate_element_time ( $db , $langs , $conf )
2020-10-28 17:49:52 +01:00
{
2023-03-08 11:00:58 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_element_time " );
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationProjectTaskTime' ) . " </b><br> \n " ;
$error = 0 ;
$db -> begin ();
2023-03-08 11:00:58 +01:00
$sql = " SELECT rowid, fk_element, element_duration " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " element_time " ;
2020-10-28 17:49:52 +01:00
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
2020-10-28 17:49:52 +01:00
$totaltime = array ();
$oldtime = 0 ;
2021-02-22 15:18:01 +01:00
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
2023-03-08 11:00:58 +01:00
if ( $obj -> element_duration > 0 ) {
2020-10-28 17:49:52 +01:00
// convert to second
2024-08-15 16:57:02 +02:00
// only for int time and float time ex: 1.75 for 1h45
2023-03-08 11:00:58 +01:00
list ( $hour , $min ) = explode ( '.' , $obj -> element_duration );
2024-08-15 16:57:02 +02:00
$hour = ( int ) $hour * 60 * 60 ;
$min = ( int ) (( float ) ( '.' . $min )) * 3600 ;
2020-10-28 17:49:52 +01:00
$newtime = $hour + $min ;
2023-03-08 11:00:58 +01:00
$sql2 = " UPDATE " . MAIN_DB_PREFIX . " element_time SET " ;
$sql2 .= " element_duration = " . (( int ) $newtime );
2021-06-09 15:36:47 +02:00
$sql2 .= " WHERE rowid = " . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
$resql2 = $db -> query ( $sql2 );
2021-02-22 15:18:01 +01:00
if ( ! $resql2 ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$oldtime ++ ;
2023-03-08 11:00:58 +01:00
if ( ! empty ( $totaltime [ $obj -> fk_element ])) {
$totaltime [ $obj -> fk_element ] += $newtime ;
2021-02-22 15:18:01 +01:00
} else {
2023-03-08 11:00:58 +01:00
$totaltime [ $obj -> fk_element ] = $newtime ;
2021-02-22 15:18:01 +01:00
}
2020-10-28 17:49:52 +01:00
} else {
2023-03-08 11:00:58 +01:00
if ( ! empty ( $totaltime [ $obj -> fk_element ])) {
$totaltime [ $obj -> fk_element ] += $obj -> element_duration ;
2021-02-22 15:18:01 +01:00
} else {
2023-03-08 11:00:58 +01:00
$totaltime [ $obj -> fk_element ] = $obj -> element_duration ;
2021-02-22 15:18:01 +01:00
}
2020-10-28 17:49:52 +01:00
}
$i ++ ;
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
if ( $oldtime > 0 ) {
foreach ( $totaltime as $taskid => $total_duration ) {
2020-10-28 17:49:52 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " projet_task SET " ;
2021-06-09 15:36:47 +02:00
$sql .= " duration_effective = " . (( int ) $total_duration );
2021-03-30 19:12:07 +02:00
$sql .= " WHERE rowid = " . (( int ) $taskid );
2020-10-28 17:49:52 +01:00
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
} else {
dol_print_error ( $db );
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
} else {
dol_print_error ( $db );
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
$db -> rollback ();
}
print '</td></tr>' ;
}
/**
* Migrate order ref_customer and date_delivery fields to llx_expedition
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
function migrate_customerorder_shipping ( $db , $langs , $conf )
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationCustomerOrderShipping' ) . " </b><br> \n " ;
$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 );
2021-02-22 15:18:01 +01:00
if ( ! $obj1 && ! $obj2 ) {
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_customerorder_shipping " );
$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 " ;
2021-02-22 15:18:01 +01:00
if ( $db -> query ( $sqlAdd1 ) && $db -> query ( $sqlAdd2 )) {
2020-11-16 12:20:18 +01:00
$sqlSelect = " SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison as delivery_date " ;
2020-10-28 17:49:52 +01:00
$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 );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " expedition SET " ;
$sqlUpdate .= " ref_customer = ' " . $db -> escape ( $obj -> ref_client ) . " ' " ;
2020-11-16 12:20:18 +01:00
$sqlUpdate .= " , date_delivery = ' " . $db -> escape ( $obj -> delivery_date ? $obj -> delivery_date : 'null' ) . " ' " ;
2021-06-09 15:36:47 +02:00
$sqlUpdate .= " WHERE rowid = " . (( int ) $obj -> shipping_id );
2020-10-28 17:49:52 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$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' ) . " <br> \n " ;
}
print '</td></tr>' ;
}
/**
* Migrate link stored into fk_expedition into llx_element_element
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
function migrate_shipping_delivery ( $db , $langs , $conf )
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationShippingDelivery' ) . " </b><br> \n " ;
$error = 0 ;
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " livraison " , " fk_expedition " );
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_shipping_delivery " );
$db -> begin ();
$sqlSelect = " SELECT rowid, fk_expedition " ;
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " livraison " ;
$sqlSelect .= " WHERE fk_expedition is not null " ;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$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 .= " ) " ;
$result = $db -> query ( $sqlInsert );
2021-02-22 15:18:01 +01:00
if ( $result ) {
2020-10-28 17:49:52 +01:00
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " livraison SET fk_expedition = NULL " ;
2021-08-27 18:18:50 +02:00
$sqlUpdate .= " WHERE rowid = " . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
} else {
$error ++ ;
dol_print_error ( $db );
}
$i ++ ;
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$sqlDelete = " DELETE FROM " . MAIN_DB_PREFIX . " element_element WHERE sourcetype = 'commande' AND targettype = 'delivery' " ;
$db -> query ( $sqlDelete );
2010-03-13 16:52:30 +01:00
2020-10-28 17:49:52 +01:00
$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' ) . " <br> \n " ;
}
print '</td></tr>' ;
2010-03-13 16:52:30 +01:00
}
2012-02-10 15:56:41 +01:00
/**
2010-07-27 20:33:41 +02:00
* We try to complete field ref_customer and date_delivery that are empty into llx_livraison .
* We set them with value from llx_expedition .
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2010-03-13 16:52:30 +01:00
*/
2019-01-27 15:20:16 +01:00
function migrate_shipping_delivery2 ( $db , $langs , $conf )
2010-03-13 16:52:30 +01:00
{
2020-10-28 17:49:52 +01:00
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationShippingDelivery2' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_shipping_delivery2 " );
$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 = '' " : " " ) . " ) " ;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " livraison SET " ;
$sqlUpdate .= " ref_customer = ' " . $db -> escape ( $obj -> ref_customer ) . " ', " ;
$sqlUpdate .= " date_delivery = " . ( $obj -> date_delivery ? " ' " . $db -> escape ( $obj -> date_delivery ) . " ' " : 'null' );
2021-08-27 18:18:50 +02:00
$sqlUpdate .= " WHERE rowid = " . (( int ) $obj -> delivery_id );
2020-10-28 17:49:52 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2020-10-28 17:49:52 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2020-10-28 17:49:52 +01:00
$i ++ ;
}
} else {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( $error == 0 ) {
2020-10-28 17:49:52 +01:00
$db -> commit ();
} else {
dol_print_error ( $db );
$db -> rollback ();
}
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
2010-03-13 16:52:30 +01:00
}
2012-02-10 15:56:41 +01:00
/**
2011-06-04 15:12:44 +02:00
* Migrate link stored into fk_xxxx into fk_element and elementtype
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2011-06-04 15:12:44 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_actioncomm_element ( $db , $langs , $conf )
2011-06-04 15:12:44 +02:00
{
2011-12-08 11:11:22 +01:00
print '<tr><td colspan="4">' ;
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationActioncommElement' ) . " </b><br> \n " ;
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
$elements = array (
'propal' => 'propalrowid' ,
'order' => 'fk_commande' ,
'invoice' => 'fk_facture' ,
'contract' => 'fk_contract' ,
'order_supplier' => 'fk_supplier_order' ,
'invoice_supplier' => 'fk_supplier_invoice'
);
2012-03-03 16:44:05 +01:00
2021-02-22 15:18:01 +01:00
foreach ( $elements as $type => $field ) {
2019-01-27 11:55:16 +01:00
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " actioncomm " , $field );
2011-12-08 11:11:22 +01:00
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) {
2019-11-14 12:09:15 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_actioncomm_element field= " . $field );
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
$db -> begin ();
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " actioncomm SET " ;
2024-10-29 02:18:17 +01:00
$sql .= " fk_element = " . $db -> sanitize ( $field ) . " , elementtype = ' " . $db -> escape ( $type ) . " ' " ;
$sql .= " WHERE " . $db -> sanitize ( $field ) . " IS NOT NULL " ;
2019-11-14 12:09:15 +01:00
$sql .= " AND fk_element IS NULL " ;
$sql .= " AND elementtype IS NULL " ;
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2011-12-08 11:11:22 +01:00
$db -> commit ();
2012-03-03 16:44:05 +01:00
2023-12-13 12:46:23 +01:00
// DDL commands must not be inside a transaction
2011-12-08 11:11:22 +01:00
// 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);
2024-03-05 00:15:33 +01:00
//print '. ';
2020-05-21 15:05:19 +02:00
} else {
2011-12-08 11:11:22 +01:00
dol_print_error ( $db );
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2011-12-08 11:11:22 +01:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
}
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
print '</td></tr>' ;
}
2011-09-29 22:21:57 +02:00
2012-02-10 15:56:41 +01:00
/**
2011-12-08 11:11:22 +01:00
* Migrate link stored into fk_mode_reglement
2012-02-10 15:56:41 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
2011-12-08 11:11:22 +01:00
*/
2019-01-27 15:20:16 +01:00
function migrate_mode_reglement ( $db , $langs , $conf )
2011-12-08 11:11:22 +01:00
{
print '<tr><td colspan="4">' ;
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationPaymentMode' ) . " </b><br> \n " ;
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
$elements = array (
2019-11-14 12:09:15 +01:00
'old_id' => array ( 5 , 8 , 9 , 10 , 11 ),
'new_id' => array ( 50 , 51 , 52 , 53 , 54 ),
'code' => array ( 'VAD' , 'TRA' , 'LCR' , 'FAC' , 'PRO' ),
'tables' => array ( 'commande_fournisseur' , 'commande' , 'facture_rec' , 'facture' , 'propal' )
2011-12-08 11:11:22 +01:00
);
2019-11-14 12:09:15 +01:00
$count = 0 ;
2012-03-03 16:44:05 +01:00
2021-02-22 15:18:01 +01:00
foreach ( $elements [ 'old_id' ] as $key => $old_id ) {
2019-11-14 12:09:15 +01:00
$error = 0 ;
2012-03-03 16:44:05 +01:00
2019-11-14 12:09:15 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_mode_reglement code= " . $elements [ 'code' ][ $key ]);
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
$sqlSelect = " SELECT id " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " c_paiement " ;
2021-03-30 19:12:07 +02:00
$sqlSelect .= " WHERE id = " . (( int ) $old_id );
2020-09-19 22:59:04 +02:00
$sqlSelect .= " AND code = ' " . $db -> escape ( $elements [ 'code' ][ $key ]) . " ' " ;
2011-12-08 11:11:22 +01:00
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2011-12-08 11:11:22 +01:00
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
2012-02-16 18:52:07 +01:00
$count ++ ;
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
$db -> begin ();
2012-03-03 16:44:05 +01:00
2021-03-30 19:12:07 +02:00
$sqla = " UPDATE " . MAIN_DB_PREFIX . " paiement SET " ;
2021-03-30 21:04:12 +02:00
$sqla .= " fk_paiement = " . (( int ) $elements [ 'new_id' ][ $key ]);
2021-03-30 19:12:07 +02:00
$sqla .= " WHERE fk_paiement = " . (( int ) $old_id );
$sqla .= " AND fk_paiement IN (SELECT id FROM " . MAIN_DB_PREFIX . " c_paiement WHERE id = " . (( int ) $old_id ) . " AND code = ' " . $db -> escape ( $elements [ 'code' ][ $key ]) . " ') " ;
2012-12-27 01:20:47 +01:00
$resqla = $db -> query ( $sqla );
2021-03-30 19:12:07 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " c_paiement SET " ;
$sql .= " id = " . (( int ) $elements [ 'new_id' ][ $key ]);
$sql .= " WHERE id = " . (( int ) $old_id );
2020-09-19 22:59:04 +02:00
$sql .= " AND code = ' " . $db -> escape ( $elements [ 'code' ][ $key ]) . " ' " ;
2011-12-08 11:11:22 +01:00
$resql = $db -> query ( $sql );
2012-12-27 01:20:47 +01:00
2021-02-22 15:18:01 +01:00
if ( $resqla && $resql ) {
foreach ( $elements [ 'tables' ] as $table ) {
2011-12-08 11:11:22 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . $table . " SET " ;
2021-03-30 21:04:12 +02:00
$sql .= " fk_mode_reglement = " . (( int ) $elements [ 'new_id' ][ $key ]);
2021-03-30 19:12:07 +02:00
$sql .= " WHERE fk_mode_reglement = " . (( int ) $old_id );
2011-12-08 11:11:22 +01:00
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resql ) {
2011-12-08 11:11:22 +01:00
dol_print_error ( $db );
$error ++ ;
2011-09-29 22:21:57 +02:00
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2011-12-08 11:11:22 +01:00
}
2012-03-03 16:44:05 +01:00
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2011-12-08 11:11:22 +01:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2011-12-08 11:11:22 +01:00
dol_print_error ( $db );
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2011-12-08 11:11:22 +01:00
dol_print_error ( $db );
$db -> rollback ();
}
}
}
}
2012-03-03 16:44:05 +01:00
2021-02-22 15:18:01 +01:00
if ( $count == 0 ) {
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2012-03-03 16:44:05 +01:00
2011-12-08 11:11:22 +01:00
print '</td></tr>' ;
2011-06-04 15:12:44 +02:00
}
2017-06-06 01:34:25 +02:00
/**
* Delete duplicates in table categorie_association
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2020-04-25 19:13:20 +02:00
function migrate_clean_association ( $db , $langs , $conf )
2017-06-06 01:34:25 +02:00
{
2020-10-28 17:49:52 +01:00
$result = $db -> DDLDescTable ( MAIN_DB_PREFIX . " categorie_association " );
2021-02-22 15:18:01 +01:00
if ( $result ) { // result defined for version 3.2 or -
2020-10-28 17:49:52 +01:00
$obj = $db -> fetch_object ( $result );
2021-02-22 15:18:01 +01:00
if ( $obj ) { // It table categorie_association exists
2020-10-28 17:49:52 +01:00
$couples = array ();
2024-01-13 19:48:41 +01:00
$children = array ();
2020-10-28 17:49:52 +01:00
$sql = " SELECT fk_categorie_mere, fk_categorie_fille " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " categorie_association " ;
dolibarr_install_syslog ( " upgrade: search duplicate " );
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2020-10-28 17:49:52 +01:00
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
while ( $obj = $db -> fetch_object ( $resql )) {
2024-01-13 19:48:41 +01:00
if ( ! isset ( $children [ $obj -> fk_categorie_fille ])) { // Only one record as child (a child has only on parent).
2021-02-22 15:18:01 +01:00
if ( $obj -> fk_categorie_mere != $obj -> fk_categorie_fille ) {
2024-01-13 19:48:41 +01:00
$children [ $obj -> fk_categorie_fille ] = 1 ; // Set record for this child
2024-03-19 00:46:03 +01:00
$couples [ $obj -> fk_categorie_mere . '_' . $obj -> fk_categorie_fille ] = array ( 'mere' => $obj -> fk_categorie_mere , 'fille' => $obj -> fk_categorie_fille );
2020-10-28 17:49:52 +01:00
}
}
}
dolibarr_install_syslog ( " upgrade: result is num= " . $num . " count(couples)= " . count ( $couples ));
// If there is duplicates couples or child with two parents
2021-02-22 15:18:01 +01:00
if ( count ( $couples ) > 0 && $num > count ( $couples )) {
2020-10-28 17:49:52 +01:00
$error = 0 ;
$db -> begin ();
// We delete all
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " categorie_association " ;
dolibarr_install_syslog ( " upgrade: delete association " );
$resqld = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resqld ) {
2020-10-28 17:49:52 +01:00
// And we insert only each record once
2021-02-22 15:18:01 +01:00
foreach ( $couples as $key => $val ) {
2020-10-28 17:49:52 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " categorie_association(fk_categorie_mere,fk_categorie_fille) " ;
2021-08-28 03:09:18 +02:00
$sql .= " VALUES( " . (( int ) $val [ 'mere' ]) . " , " . (( int ) $val [ 'fille' ]) . " ) " ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade: insert association " );
$resqli = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( ! $resqli ) {
$error ++ ;
}
2020-10-28 17:49:52 +01:00
}
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2020-10-28 17:49:52 +01:00
print '<tr><td>' . $langs -> trans ( " MigrationCategorieAssociation " ) . '</td>' ;
print '<td class="right">' . $langs -> trans ( " RemoveDuplicates " ) . ' ' . $langs -> trans ( " Success " ) . ' (' . $num . '=>' . count ( $couples ) . ')</td></tr>' ;
$db -> commit ();
} else {
print '<tr><td>' . $langs -> trans ( " MigrationCategorieAssociation " ) . '</td>' ;
print '<td class="right">' . $langs -> trans ( " RemoveDuplicates " ) . ' ' . $langs -> trans ( " Failed " ) . '</td></tr>' ;
$db -> rollback ();
}
}
} else {
print '<tr><td>' . $langs -> trans ( " Error " ) . '</td>' ;
print '<td class="right"><div class="error">' . $db -> lasterror () . '</div></td></tr>' ;
}
}
}
2017-06-06 01:34:25 +02:00
}
2012-10-08 19:27:02 +02:00
/**
* Migrate categorie association
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_categorie_association ( $db , $langs , $conf )
2012-10-08 19:27:02 +02:00
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationCategorieAssociation' ) . " </b><br> \n " ;
$error = 0 ;
2021-02-22 15:18:01 +01:00
if ( $db -> DDLInfoTable ( MAIN_DB_PREFIX . " categorie_association " )) {
2012-10-08 19:27:02 +02:00
dolibarr_install_syslog ( " upgrade2::migrate_categorie_association " );
$db -> begin ();
$sqlSelect = " SELECT fk_categorie_mere, fk_categorie_fille " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " categorie_association " ;
2012-10-08 19:27:02 +02:00
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2012-10-08 19:27:02 +02:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2012-10-08 19:27:02 +02:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " categorie SET " ;
2021-06-09 15:36:47 +02:00
$sqlUpdate .= " fk_parent = " . (( int ) $obj -> fk_categorie_mere );
$sqlUpdate .= " WHERE rowid = " . (( int ) $obj -> fk_categorie_fille );
2012-10-08 19:27:02 +02:00
2019-11-14 12:09:15 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2012-10-08 19:27:02 +02:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2012-10-08 19:27:02 +02:00
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2012-10-08 19:27:02 +02:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2012-10-08 19:27:02 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2012-10-08 19:27:02 +02:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2012-10-08 19:27:02 +02:00
dol_print_error ( $db );
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2012-10-08 19:27:02 +02:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
print '</td></tr>' ;
}
2010-03-20 14:09:59 +01:00
2015-01-15 02:06:04 +01:00
/**
2024-01-13 19:48:41 +01:00
* Migrate event assignment to owner
2015-01-15 02:06:04 +01:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_event_assignement ( $db , $langs , $conf )
2015-01-15 02:06:04 +01:00
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationEvents' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_event_assignement " );
$db -> begin ();
$sqlSelect = " SELECT a.id, a.fk_user_action " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a " ;
$sqlSelect .= " LEFT JOIN " . MAIN_DB_PREFIX . " actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action " ;
$sqlSelect .= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM " . MAIN_DB_PREFIX . " actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user') " ;
$sqlSelect .= " ORDER BY a.id " ;
2015-01-15 02:06:04 +01:00
//print $sqlSelect;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2015-01-15 02:06:04 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2015-01-15 02:06:04 +01:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm_resources(fk_actioncomm, element_type, fk_element) " ;
2021-08-28 03:09:18 +02:00
$sqlUpdate .= " VALUES( " . (( int ) $obj -> id ) . " , 'user', " . (( int ) $obj -> fk_user_action ) . " ) " ;
2015-01-15 02:06:04 +01:00
2019-11-14 12:09:15 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2015-01-15 02:06:04 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2015-01-15 02:06:04 +01:00
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2015-01-15 02:06:04 +01:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2015-01-15 02:06:04 +01:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2015-01-15 02:06:04 +01:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2015-01-15 02:06:04 +01:00
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
}
2017-06-06 17:43:22 +02:00
/**
2024-01-13 19:48:41 +01:00
* Migrate event assignment to owner
2017-06-06 17:43:22 +02:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_event_assignement_contact ( $db , $langs , $conf )
2017-06-06 17:43:22 +02:00
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationEventsContact' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_event_assignement " );
$db -> begin ();
$sqlSelect = " SELECT a.id, a.fk_contact " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a " ;
$sqlSelect .= " LEFT JOIN " . MAIN_DB_PREFIX . " actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact " ;
$sqlSelect .= " WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM " . MAIN_DB_PREFIX . " actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople') " ;
$sqlSelect .= " ORDER BY a.id " ;
2017-06-06 17:43:22 +02:00
//print $sqlSelect;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2017-06-06 17:43:22 +02:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2017-06-06 17:43:22 +02:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm_resources(fk_actioncomm, element_type, fk_element) " ;
2021-08-28 03:09:18 +02:00
$sqlUpdate .= " VALUES( " . (( int ) $obj -> id ) . " , 'socpeople', " . (( int ) $obj -> fk_contact ) . " ) " ;
2017-06-06 17:43:22 +02:00
2019-11-14 12:09:15 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2017-06-06 17:43:22 +02:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2017-06-06 17:43:22 +02:00
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-06-06 17:43:22 +02:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2017-06-06 17:43:22 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2017-06-06 17:43:22 +02:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2017-06-06 17:43:22 +02:00
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
}
2017-12-15 15:15:14 +01:00
/**
* Migrate to reset the blocked log for V7 + algorithm
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_reset_blocked_log ( $db , $langs , $conf )
2017-12-15 15:15:14 +01:00
{
2017-12-15 22:14:28 +01:00
global $user ;
2017-12-15 15:15:14 +01:00
require_once DOL_DOCUMENT_ROOT . '/blockedlog/class/blockedlog.class.php' ;
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationResetBlockedLog' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_reset_blocked_log " );
$db -> begin ();
$sqlSelect = " SELECT DISTINCT entity " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " blockedlog " ;
2017-12-15 15:15:14 +01:00
//print $sqlSelect;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2017-12-15 15:15:14 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2017-12-15 15:15:14 +01:00
$obj = $db -> fetch_object ( $resql );
print 'Process entity ' . $obj -> entity ;
2021-08-27 18:18:50 +02:00
$sqlSearch = " SELECT count(rowid) as nb FROM " . MAIN_DB_PREFIX . " blockedlog WHERE action = 'MODULE_SET' and entity = " . (( int ) $obj -> entity );
2017-12-15 15:15:14 +01:00
$resqlSearch = $db -> query ( $sqlSearch );
2021-02-22 15:18:01 +01:00
if ( $resqlSearch ) {
2017-12-15 15:15:14 +01:00
$objSearch = $db -> fetch_object ( $resqlSearch );
//var_dump($objSearch);
2021-02-22 15:18:01 +01:00
if ( $objSearch && $objSearch -> nb == 0 ) {
2017-12-15 15:15:14 +01:00
print ' - Record for entity must be reset...' ;
$sqlUpdate = " DELETE FROM " . MAIN_DB_PREFIX . " blockedlog " ;
2021-08-27 18:18:50 +02:00
$sqlUpdate .= " WHERE entity = " . (( int ) $obj -> entity );
2019-11-14 12:09:15 +01:00
$resqlUpdate = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $resqlUpdate ) {
2017-12-15 15:15:14 +01:00
$error ++ ;
dol_print_error ( $db );
2020-05-21 15:05:19 +02:00
} else {
2017-12-15 15:15:14 +01:00
// Add set line
2019-11-14 12:09:15 +01:00
$object = new stdClass ();
2017-12-15 15:15:14 +01:00
$object -> id = 1 ;
$object -> element = 'module' ;
$object -> ref = 'systemevent' ;
$object -> entity = $obj -> entity ;
$object -> date = dol_now ();
2019-11-14 12:09:15 +01:00
$b = new BlockedLog ( $db );
2017-12-15 15:15:14 +01:00
$b -> setObjectData ( $object , 'MODULE_SET' , 0 );
$res = $b -> create ( $user );
2019-11-14 12:09:15 +01:00
if ( $res <= 0 ) {
2017-12-15 15:15:14 +01:00
$error ++ ;
}
}
2020-05-21 15:05:19 +02:00
} else {
2018-02-20 05:53:53 +01:00
print ' - ' . $langs -> trans ( 'AlreadyInV7' ) . '<br>' ;
2017-12-15 15:15:14 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2017-12-15 15:15:14 +01:00
dol_print_error ( $db );
}
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-12-15 15:15:14 +01:00
print $langs -> trans ( 'NothingToDo' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2017-12-15 15:15:14 +01:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2017-12-15 15:15:14 +01:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2017-12-15 15:15:14 +01:00
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
}
2016-07-07 12:43:02 +02:00
/**
* Migrate to add entity value into llx_societe_remise
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_remise_entity ( $db , $langs , $conf )
2016-07-07 12:43:02 +02:00
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationRemiseEntity' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_remise_entity " );
$db -> begin ();
$sqlSelect = " SELECT sr.rowid, s.entity " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " societe_remise as sr, " . MAIN_DB_PREFIX . " societe as s " ;
$sqlSelect .= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity " ;
2016-07-07 12:43:02 +02:00
//print $sqlSelect;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2016-07-07 12:43:02 +02:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2016-07-07 12:43:02 +02:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " societe_remise SET " ;
2019-11-14 12:09:15 +01:00
$sqlUpdate .= " entity = " . $obj -> entity ;
2021-08-27 18:18:50 +02:00
$sqlUpdate .= " WHERE rowid = " . (( int ) $obj -> rowid );
2016-07-07 12:43:02 +02:00
2019-11-14 12:09:15 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2016-07-07 12:43:02 +02:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2016-07-07 12:43:02 +02:00
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:43:02 +02:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2016-07-07 12:43:02 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:43:02 +02:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:43:02 +02:00
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
}
2016-07-07 12:19:20 +02:00
/**
* Migrate to add entity value into llx_societe_remise_except
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_remise_except_entity ( $db , $langs , $conf )
2016-07-07 12:19:20 +02:00
{
print '<tr><td colspan="4">' ;
print '<br>' ;
print '<b>' . $langs -> trans ( 'MigrationRemiseExceptEntity' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_remise_except_entity " );
$db -> begin ();
$sqlSelect = " SELECT sr.rowid, sr.fk_soc, sr.fk_facture_source, sr.fk_facture, sr.fk_facture_line " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " societe_remise_except as sr " ;
2016-07-07 12:19:20 +02:00
//print $sqlSelect;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2016-07-07 12:19:20 +02:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2016-07-07 12:19:20 +02:00
$obj = $db -> fetch_object ( $resql );
2021-02-22 15:18:01 +01:00
if ( ! empty ( $obj -> fk_facture_source ) || ! empty ( $obj -> fk_facture )) {
2016-07-07 12:19:20 +02:00
$fk_facture = ( ! empty ( $obj -> fk_facture_source ) ? $obj -> fk_facture_source : $obj -> fk_facture );
$sqlSelect2 = " SELECT f.entity " ;
2019-11-14 12:09:15 +01:00
$sqlSelect2 .= " FROM " . MAIN_DB_PREFIX . " facture as f " ;
2021-03-30 19:12:07 +02:00
$sqlSelect2 .= " WHERE f.rowid = " . (( int ) $fk_facture );
2021-02-22 15:18:01 +01:00
} elseif ( ! empty ( $obj -> fk_facture_line )) {
2016-07-07 12:19:20 +02:00
$sqlSelect2 = " SELECT f.entity " ;
2019-11-14 12:09:15 +01:00
$sqlSelect2 .= " FROM " . MAIN_DB_PREFIX . " facture as f, " . MAIN_DB_PREFIX . " facturedet as fd " ;
2021-03-30 19:12:07 +02:00
$sqlSelect2 .= " WHERE fd.rowid = " . (( int ) $obj -> fk_facture_line );
2019-11-14 12:09:15 +01:00
$sqlSelect2 .= " AND fd.fk_facture = f.rowid " ;
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:19:20 +02:00
$sqlSelect2 = " SELECT s.entity " ;
2019-11-14 12:09:15 +01:00
$sqlSelect2 .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
2021-03-30 19:12:07 +02:00
$sqlSelect2 .= " WHERE s.rowid = " . (( int ) $obj -> fk_soc );
2016-07-07 12:19:20 +02:00
}
$resql2 = $db -> query ( $sqlSelect2 );
2021-02-22 15:18:01 +01:00
if ( $resql2 ) {
if ( $db -> num_rows ( $resql2 ) > 0 ) {
2016-07-07 12:19:20 +02:00
$obj2 = $db -> fetch_object ( $resql2 );
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " societe_remise_except SET " ;
2021-08-27 18:18:50 +02:00
$sqlUpdate .= " entity = " . (( int ) $obj2 -> entity );
$sqlUpdate .= " WHERE rowid = " . (( int ) $obj -> rowid );
2016-07-07 12:19:20 +02:00
2019-11-14 12:09:15 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2016-07-07 12:19:20 +02:00
$error ++ ;
dol_print_error ( $db );
}
}
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:19:20 +02:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2016-07-07 12:19:20 +02:00
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:19:20 +02:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2016-07-07 12:19:20 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:19:20 +02:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:19:20 +02:00
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
}
2018-02-14 14:30:39 +01:00
/**
* Migrate to add entity value into llx_user_rights
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_user_rights_entity ( $db , $langs , $conf )
2018-02-14 14:30:39 +01:00
{
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'MigrationUserRightsEntity' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_user_rights_entity " );
$db -> begin ();
$sqlSelect = " SELECT u.rowid, u.entity " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " user as u " ;
$sqlSelect .= " WHERE u.entity > 1 " ;
2018-02-14 14:30:39 +01:00
//print $sqlSelect;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2018-02-14 14:30:39 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2018-02-14 14:30:39 +01:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " user_rights SET " ;
2021-08-27 18:18:50 +02:00
$sqlUpdate .= " entity = " . (( int ) $obj -> entity );
$sqlUpdate .= " WHERE fk_user = " . (( int ) $obj -> rowid );
2018-02-14 14:30:39 +01:00
2019-11-14 12:09:15 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2018-02-14 14:30:39 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2018-02-14 14:30:39 +01:00
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2018-02-14 14:30:39 +01:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2018-02-14 14:30:39 +01:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2018-02-14 14:30:39 +01:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2018-02-14 14:30:39 +01:00
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
}
/**
* Migrate to add entity value into llx_usergroup_rights
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
* @ return void
*/
2019-01-27 15:20:16 +01:00
function migrate_usergroup_rights_entity ( $db , $langs , $conf )
2018-02-14 14:30:39 +01:00
{
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'MigrationUserGroupRightsEntity' ) . " </b><br> \n " ;
$error = 0 ;
dolibarr_install_syslog ( " upgrade2::migrate_usergroup_rights_entity " );
$db -> begin ();
$sqlSelect = " SELECT u.rowid, u.entity " ;
2019-11-14 12:09:15 +01:00
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . " usergroup as u " ;
$sqlSelect .= " WHERE u.entity > 1 " ;
2018-02-14 14:30:39 +01:00
//print $sqlSelect;
$resql = $db -> query ( $sqlSelect );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
2018-02-14 14:30:39 +01:00
$i = 0 ;
$num = $db -> num_rows ( $resql );
2021-02-22 15:18:01 +01:00
if ( $num ) {
while ( $i < $num ) {
2018-02-14 14:30:39 +01:00
$obj = $db -> fetch_object ( $resql );
$sqlUpdate = " UPDATE " . MAIN_DB_PREFIX . " usergroup_rights SET " ;
2021-08-27 18:18:50 +02:00
$sqlUpdate .= " entity = " . (( int ) $obj -> entity );
$sqlUpdate .= " WHERE fk_usergroup = " . (( int ) $obj -> rowid );
2018-02-14 14:30:39 +01:00
2019-11-14 12:09:15 +01:00
$result = $db -> query ( $sqlUpdate );
2021-02-22 15:18:01 +01:00
if ( ! $result ) {
2018-02-14 14:30:39 +01:00
$error ++ ;
dol_print_error ( $db );
}
2024-03-05 00:15:33 +01:00
print '. ' ;
2018-02-14 14:30:39 +01:00
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2018-02-14 14:30:39 +01:00
print $langs -> trans ( 'AlreadyDone' ) . " <br> \n " ;
}
2021-02-22 15:18:01 +01:00
if ( ! $error ) {
2016-07-07 12:19:20 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:19:20 +02:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2016-07-07 12:19:20 +02:00
dol_print_error ( $db );
$db -> rollback ();
}
print '</td></tr>' ;
}
2010-04-24 19:37:55 +02:00
/**
2009-12-08 11:54:12 +01:00
* Migration directory
2011-09-29 22:21:57 +02:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
2016-10-05 22:24:14 +02:00
* @ param string $oldname Old name ( relative to DOL_DATA_ROOT )
* @ param string $newname New name ( relative to DOL_DATA_ROOT )
2011-09-29 22:21:57 +02:00
* @ return void
2009-11-04 22:41:08 +01:00
*/
2018-11-17 15:21:24 +01:00
function migrate_rename_directories ( $db , $langs , $conf , $oldname , $newname )
2009-11-04 22:41:08 +01:00
{
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_rename_directories " );
2009-11-04 22:41:08 +01:00
2021-02-22 15:18:01 +01:00
if ( is_dir ( DOL_DATA_ROOT . $oldname ) && ! file_exists ( DOL_DATA_ROOT . $newname )) {
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_rename_directories move " . DOL_DATA_ROOT . $oldname . ' into ' . DOL_DATA_ROOT . $newname );
@ rename ( DOL_DATA_ROOT . $oldname , DOL_DATA_ROOT . $newname );
}
2009-11-04 22:41:08 +01:00
}
2011-09-29 22:21:57 +02:00
/**
* Delete deprecated files
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
2023-01-04 11:36:46 +01:00
* @ return boolean
2010-08-01 23:42:57 +02:00
*/
2018-11-16 17:58:14 +01:00
function migrate_delete_old_files ( $db , $langs , $conf )
2010-08-01 23:42:57 +02:00
{
2023-01-04 11:36:46 +01:00
$ret = true ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_delete_old_files " );
// List of files to delete
$filetodeletearray = array (
2023-09-04 23:48:23 +02:00
'/core/ajax/ajaxcompanies.php' ,
2020-10-28 17:49:52 +01:00
'/core/triggers/interface_demo.class.php' ,
'/core/menus/barre_left/default.php' ,
'/core/menus/barre_top/default.php' ,
'/core/modules/modComptabiliteExpert.class.php' ,
'/core/modules/modCommercial.class.php' ,
'/core/modules/modProduit.class.php' ,
'/core/modules/modSkype.class.php' ,
'/core/triggers/interface_modWebcalendar_Webcalsynchro.class.php' ,
'/core/triggers/interface_modCommande_Ecotax.class.php' ,
'/core/triggers/interface_modCommande_fraisport.class.php' ,
'/core/triggers/interface_modPropale_PropalWorkflow.class.php' ,
2022-09-11 15:11:56 +02:00
'/core/triggers/interface_99_modWebhook_WebhookTriggers.class.php' ,
'/core/triggers/interface_99_modZapier_ZapierTriggers.class.php' ,
2020-10-28 17:49:52 +01:00
'/core/menus/smartphone/iphone.lib.php' ,
'/core/menus/smartphone/iphone_backoffice.php' ,
'/core/menus/smartphone/iphone_frontoffice.php' ,
'/core/menus/standard/auguria_backoffice.php' ,
'/core/menus/standard/auguria_frontoffice.php' ,
'/core/menus/standard/eldy_backoffice.php' ,
'/core/menus/standard/eldy_frontoffice.php' ,
2023-08-31 22:51:21 +02:00
'/core/modules/export/export_excel.modules.php' ,
'/core/modules/export/export_csv.modules.php' ,
'/core/modules/export/exportcsv.modules.php' ,
'/core/modules/export/export_excel2007new.modules.php' ,
'/core/modules/facture/pdf_crabe.modules.php' ,
'/core/modules/facture/pdf_oursin.modules.php' ,
2020-10-28 17:49:52 +01:00
'/core/modules/mailings/contacts2.modules.php' ,
'/core/modules/mailings/contacts3.modules.php' ,
'/core/modules/mailings/contacts4.modules.php' ,
'/core/modules/mailings/framboise.modules.php' ,
'/core/modules/mailings/dolibarr_services_expired.modules.php' ,
'/core/modules/mailings/peche.modules.php' ,
'/core/modules/mailings/poire.modules.php' ,
'/core/modules/mailings/kiwi.modules.php' ,
2022-06-03 03:10:31 +02:00
'/core/boxes/box_members.php' ,
2023-09-03 23:06:48 +02:00
2023-09-03 23:06:48 +02:00
'/includes/restler/framework/Luracast/Restler/Data/Object.php' ,
2023-12-16 20:11:30 +01:00
'/includes/nusoap/lib/class.*' ,
2023-09-03 23:06:48 +02:00
'/phenix/inc/triggers/interface_modPhenix_Phenixsynchro.class.php' ,
'/webcalendar/inc/triggers/interface_modWebcalendar_webcalsynchro.class.php' ,
2020-10-28 17:49:52 +01:00
'/api/class/api_generic.class.php' ,
2022-07-27 13:42:32 +02:00
'/asterisk/cidlookup.php' ,
2020-10-28 17:49:52 +01:00
'/categories/class/api_category.class.php' ,
'/categories/class/api_deprecated_category.class.php' ,
'/compta/facture/class/api_invoice.class.php' ,
'/commande/class/api_commande.class.php' ,
2023-10-31 13:31:02 +01:00
'/partnership/class/api_partnership.class.php' ,
2020-10-28 17:49:52 +01:00
'/product/class/api_product.class.php' ,
2023-10-31 13:37:15 +01:00
'/recruitment/class/api_recruitment.class.php' ,
2020-10-28 17:49:52 +01:00
'/societe/class/api_contact.class.php' ,
'/societe/class/api_thirdparty.class.php' ,
'/support/online.php' ,
'/takepos/class/actions_takepos.class.php' ,
2023-12-16 20:11:30 +01:00
'/user/class/api_user.class.php' ,
2020-10-28 17:49:52 +01:00
'/install/mysql/tables/llx_c_ticketsup_category.key.sql' ,
'/install/mysql/tables/llx_c_ticketsup_category.sql' ,
'/install/mysql/tables/llx_c_ticketsup_severity.key.sql' ,
'/install/mysql/tables/llx_c_ticketsup_severity.sql' ,
'/install/mysql/tables/llx_c_ticketsup_type.key.sql' ,
'/install/mysql/tables/llx_c_ticketsup_type.sql'
);
2023-12-16 20:11:30 +01:00
/*
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'DeleteOldFiles' ) . " </b><br> \n " ;
print '</td></tr>' ;
*/
2020-10-28 17:49:52 +01:00
foreach ( $filetodeletearray as $filetodelete ) {
//print '<b>'DOL_DOCUMENT_ROOT.$filetodelete."</b><br>\n";
2024-12-31 11:06:27 +01:00
if ( preg_match ( '/\*/' , $filetodelete ) || file_exists ( DOL_DOCUMENT_ROOT . $filetodelete )) {
2023-12-16 20:11:30 +01:00
//print "Process file ".$filetodelete."\n";
2025-02-04 23:25:24 +01:00
$result = dol_delete_file ( DOL_DOCUMENT_ROOT . $filetodelete , 0 , ( preg_match ( '/\*/' , $filetodelete ) ? 1 : 0 ), 0 , null , true , 0 );
2020-10-28 17:49:52 +01:00
if ( ! $result ) {
$langs -> load ( " errors " );
print '<div class="error">' . $langs -> trans ( " Error " ) . ': ' . $langs -> trans ( " ErrorFailToDeleteFile " , DOL_DOCUMENT_ROOT . $filetodelete );
print ' ' . $langs -> trans ( " RemoveItManuallyAndPressF5ToContinue " ) . '</div>' ;
} else {
//print $langs->trans("FileWasRemoved", $filetodelete).'<br>';
}
}
}
2023-01-04 11:36:46 +01:00
return $ret ;
2010-08-01 23:42:57 +02:00
}
2011-09-29 22:21:57 +02:00
/**
2010-08-01 23:42:57 +02:00
* Remove deprecated directories
2011-09-29 22:21:57 +02:00
*
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
2023-01-04 11:36:46 +01:00
* @ return boolean
2010-08-01 23:42:57 +02:00
*/
2018-11-17 15:21:24 +01:00
function migrate_delete_old_dir ( $db , $langs , $conf )
2010-08-01 23:42:57 +02:00
{
2023-01-04 11:36:46 +01:00
$ret = true ;
2020-10-28 17:49:52 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_delete_old_dir " );
// List of files to delete
$filetodeletearray = array (
DOL_DOCUMENT_ROOT . '/core/modules/facture/terre' ,
DOL_DOCUMENT_ROOT . '/core/modules/facture/mercure' ,
);
2021-04-08 17:35:52 +02:00
// On linux, we can also removed old directory with a different case than new directory.
if ( ! empty ( $_SERVER [ " WINDIR " ])) {
$filetodeletearray [] = DOL_DOCUMENT_ROOT . '/includes/phpoffice/PhpSpreadsheet' ;
}
2020-10-28 17:49:52 +01:00
foreach ( $filetodeletearray as $filetodelete ) {
2023-01-12 18:06:26 +01:00
$result = 1 ;
2020-10-28 17:49:52 +01:00
if ( file_exists ( $filetodelete )) {
$result = dol_delete_dir_recursive ( $filetodelete );
}
if ( ! $result ) {
$langs -> load ( " errors " );
print '<div class="error">' . $langs -> trans ( " Error " ) . ': ' . $langs -> trans ( " ErrorFailToDeleteDir " , $filetodelete );
print ' ' . $langs -> trans ( " RemoveItManuallyAndPressF5ToContinue " ) . '</div>' ;
}
}
2023-01-04 11:36:46 +01:00
return $ret ;
2010-08-01 23:42:57 +02:00
}
2011-09-29 22:21:57 +02:00
/**
2024-01-13 19:48:41 +01:00
* Disable / Re - enable features modules .
2010-08-01 23:42:57 +02:00
* We must do this when internal menu of module or permissions has changed
* or when triggers have moved .
2011-09-29 22:21:57 +02:00
*
2015-01-07 11:11:40 +01:00
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
2024-10-03 19:40:34 +02:00
* @ param array < string , 'noboxes' | 'newboxdefonly' | 'forceactivate' > $listofmodule List of modules , like array ( 'MODULE_KEY_NAME' => $reloadmode , ... )
* @ param int < 0 , 1 > $force 1 = Reload module even if not already loaded
* @ return int Return integer < 0 if KO , > 0 if OK
2010-08-01 23:42:57 +02:00
*/
2019-01-27 15:20:16 +01:00
function migrate_reload_modules ( $db , $langs , $conf , $listofmodule = array (), $force = 0 )
2010-08-01 23:42:57 +02:00
{
2023-05-12 20:41:23 +02:00
global $user ;
2021-02-22 15:18:01 +01:00
if ( count ( $listofmodule ) == 0 ) {
2023-02-21 17:51:24 +01:00
return 0 ;
2021-02-22 15:18:01 +01:00
}
2010-08-01 23:42:57 +02:00
2023-05-12 20:41:23 +02:00
if ( ! is_object ( $user )) {
include_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$user = new User ( $db ); // To avoid error during migration
}
Qual: Apply automatic phan fixes (deprecations, unneeded imports) (#28154)
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
2024-02-13 21:46:12 +01:00
dolibarr_install_syslog ( " upgrade2::migrate_reload_modules force= " . $force . " , listofmodule= " . implode ( ',' , array_keys ( $listofmodule )));
2015-01-07 11:11:40 +01:00
2023-05-26 13:52:53 +02:00
$reloadactionformodules = array (
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_AGENDA' => array ( 'class' => 'modAgenda' , 'remove' => 1 ),
2023-05-26 13:52:53 +02:00
'MAIN_MODULE_API' => array ( 'class' => 'modApi' ),
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_BARCODE' => array ( 'class' => 'modBarcode' , 'remove' => 1 ),
'MAIN_MODULE_BLOCKEDLOG' => array ( 'class' => 'modBlockedLog' , 'deleteinsertmenus' => 1 ),
'MAIN_MODULE_CRON' => array ( 'class' => 'modCron' , 'remove' => 1 ),
'MAIN_MODULE_EXTERNALSITE' => array ( 'class' => 'modExternalSite' , 'remove' => 1 ),
'MAIN_MODULE_SOCIETE' => array ( 'class' => 'modSociete' , 'remove' => 1 ),
2023-05-26 13:52:53 +02:00
'MAIN_MODULE_PRODUIT' => array ( 'class' => 'modProduct' ),
'MAIN_MODULE_SERVICE' => array ( 'class' => 'modService' ),
'MAIN_MODULE_COMMANDE' => array ( 'class' => 'modCommande' ),
2024-08-31 12:24:49 +02:00
'MAIN_MODULE_DON' => array ( 'class' => 'modDon' ),
2023-05-26 13:52:53 +02:00
'MAIN_MODULE_FACTURE' => array ( 'class' => 'modFacture' ),
2024-01-05 09:43:44 +01:00
'MAIN_MODULE_FICHEINTER' => array ( 'class' => 'modFicheinter' ),
2023-05-26 13:52:53 +02:00
'MAIN_MODULE_FOURNISSEUR' => array ( 'class' => 'modFournisseur' ),
2023-11-19 15:05:20 +01:00
'MAIN_MODULE_EXPEDITION' => array ( 'class' => 'modExpedition' ),
2023-05-26 13:52:53 +02:00
'MAIN_MODULE_EXPENSEREPORT' => array ( 'class' => 'modExpenseReport' ),
2024-08-31 12:24:49 +02:00
'MAIN_MODULE_EVENTORGANIZATION' => array ( 'class' => 'modEventOrganization' , 'remove' => 1 ),
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_ECM' => array ( 'class' => 'modECM' , 'remove' => 1 ),
2024-08-31 12:24:49 +02:00
'MAIN_MODULE_HOLIDAY' => array ( 'class' => 'modHoliday' , 'remove' => 1 ),
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_KNOWLEDGEMANAGEMENT' => array ( 'class' => 'modKnowledgeManagement' , 'remove' => 1 ),
2024-08-31 12:24:49 +02:00
'MAIN_MODULE_LOAN' => array ( 'class' => 'modLoan' , 'remove' => 1 ),
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_PAYBOX' => array ( 'class' => 'modPaybox' , 'remove' => 1 ),
2023-11-19 15:05:20 +01:00
'MAIN_MODULE_PROPAL' => array ( 'class' => 'modPropale' ),
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_SUPPLIERPROPOSAL' => array ( 'class' => 'modSupplierProposal' , 'remove' => 1 ),
'MAIN_MODULE_OPENSURVEY' => array ( 'class' => 'modOpenSurvey' , 'remove' => 1 ),
'MAIN_MODULE_PRODUCTBATCH' => array ( 'class' => 'modProductBatch' , 'remove' => 1 ),
'MAIN_MODULE_TAKEPOS' => array ( 'class' => 'modTakePos' , 'remove' => 1 ),
2024-08-31 12:12:59 +02:00
'MAIN_MODULE_VARIANTS' => array ( 'class' => 'modVariants' , 'remove' => 1 ),
2024-03-19 00:46:03 +01:00
'MAIN_MODULE_EMAILCOLLECTOR' => array ( 'class' => 'modEmailCollector' , 'remove' => 1 ),
2023-05-26 13:52:53 +02:00
);
2020-12-16 17:00:14 +01:00
foreach ( $listofmodule as $moduletoreload => $reloadmode ) { // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate'
2021-02-22 15:18:01 +01:00
if ( empty ( $moduletoreload ) || ( empty ( $conf -> global -> $moduletoreload ) && ! $force )) {
continue ; // Discard reload if module not enabled
}
2017-09-09 16:49:26 +02:00
2019-11-14 12:09:15 +01:00
$mod = null ;
2017-09-09 16:49:26 +02:00
2023-05-26 13:52:53 +02:00
if ( ! empty ( $reloadactionformodules [ $moduletoreload ])) {
dolibarr_install_syslog ( " upgrade2::migrate_reload_modules Reactivate module " . $moduletoreload . " with mode " . $reloadmode );
$val = $reloadactionformodules [ $moduletoreload ];
$classformodule = $val [ 'class' ];
$res = @ include_once DOL_DOCUMENT_ROOT . '/core/modules/' . $classformodule . '.class.php' ;
2020-01-27 00:38:28 +01:00
if ( $res ) {
2023-05-26 13:52:53 +02:00
$mod = new $classformodule ( $db );
if ( ! empty ( $val [ 'remove' ])) {
$mod -> remove ( 'noboxes' );
}
if ( ! empty ( $val [ 'deleteinsertmenus' ])) {
// We only reload menus
$mod -> delete_menus ();
$mod -> insert_menus ();
2023-05-26 14:19:20 +02:00
} else {
$mod -> init ( $reloadmode );
2023-05-26 13:52:53 +02:00
}
2020-01-27 00:38:28 +01:00
}
2021-02-15 20:13:38 +01:00
} else { // Other generic cases/modules
2020-01-27 00:38:28 +01:00
$reg = array ();
2018-05-01 11:09:03 +02:00
$tmp = preg_match ( '/MAIN_MODULE_([a-zA-Z0-9]+)/' , $moduletoreload , $reg );
2021-02-22 15:18:01 +01:00
if ( ! empty ( $reg [ 1 ])) {
if ( strtoupper ( $moduletoreload ) == $moduletoreload ) { // If key is un uppercase
2018-07-09 13:02:01 +02:00
$moduletoreloadshort = ucfirst ( strtolower ( $reg [ 1 ]));
2023-12-04 12:36:19 +01:00
} else { // If key is a mix of up and low case
2018-07-09 13:02:01 +02:00
$moduletoreloadshort = $reg [ 1 ];
}
2021-02-15 20:13:38 +01:00
2023-05-26 13:52:53 +02:00
dolibarr_install_syslog ( " upgrade2::migrate_reload_modules Reactivate module " . $moduletoreloadshort . " with mode " . $reloadmode . " (generic code) " );
2019-11-14 12:09:15 +01:00
$res = @ include_once DOL_DOCUMENT_ROOT . '/core/modules/mod' . $moduletoreloadshort . '.class.php' ;
2018-05-01 11:09:03 +02:00
if ( $res ) {
$classname = 'mod' . $moduletoreloadshort ;
2019-11-14 12:09:15 +01:00
$mod = new $classname ( $db );
2024-10-03 19:40:34 +02:00
'@phan-var-force DolibarrModules $mod' ;
2021-02-15 20:13:38 +01:00
2018-05-01 11:09:03 +02:00
//$mod->remove('noboxes');
2021-10-25 22:07:31 +02:00
$mod -> delete_menus (); // We must delete to be sure it is inserted with new values
2018-05-01 11:09:03 +02:00
$mod -> init ( $reloadmode );
2020-05-21 15:05:19 +02:00
} else {
2018-07-09 13:02:01 +02:00
dolibarr_install_syslog ( 'Failed to include ' . DOL_DOCUMENT_ROOT . '/core/modules/mod' . $moduletoreloadshort . '.class.php' );
2019-11-14 12:09:15 +01:00
$res = @ dol_include_once ( strtolower ( $moduletoreloadshort ) . '/core/modules/mod' . $moduletoreloadshort . '.class.php' );
2018-07-09 13:02:01 +02:00
if ( $res ) {
$classname = 'mod' . $moduletoreloadshort ;
2019-11-14 12:09:15 +01:00
$mod = new $classname ( $db );
2024-10-03 19:40:34 +02:00
'@phan-var-force DolibarrModules $mod' ;
2018-07-09 13:02:01 +02:00
$mod -> init ( $reloadmode );
2020-05-21 15:05:19 +02:00
} else {
2020-12-16 15:10:11 +01:00
dolibarr_install_syslog ( 'Failed to include ' . strtolower ( $moduletoreloadshort ) . '/core/modules/mod' . $moduletoreloadshort . '.class.php' , LOG_ERR );
print " Error, can't find module with name " . $moduletoreload . " \n " ;
return - 1 ;
2018-07-09 13:02:01 +02:00
}
}
2020-05-21 15:05:19 +02:00
} else {
2020-12-16 15:10:11 +01:00
dolibarr_install_syslog ( " Error, can't find module with name " . $moduletoreload , LOG_ERR );
print " Error, can't find module with name " . $moduletoreload . " \n " ;
return - 1 ;
2017-09-09 16:49:26 +02:00
}
}
2015-02-18 21:01:17 +01:00
2021-02-22 15:18:01 +01:00
if ( ! empty ( $mod ) && is_object ( $mod )) {
2021-02-27 12:45:07 +01:00
print '<tr class="trforrunsql"><td colspan="4">' ;
2017-09-09 16:49:26 +02:00
print '<b>' . $langs -> trans ( 'Upgrade' ) . '</b>: ' ;
2019-11-14 12:09:15 +01:00
print $langs -> trans ( 'MigrationReloadModule' ) . ' ' . $mod -> getName (); // We keep getName outside of trans because getName is already encoded/translated
2017-09-09 16:49:26 +02:00
print " <!-- ( " . $reloadmode . " ) --> " ;
print " <br> \n " ;
print '</td></tr>' ;
2015-09-11 07:52:06 +02:00
}
2017-09-09 16:49:26 +02:00
}
2020-12-16 15:10:11 +01:00
return 1 ;
2010-08-01 23:42:57 +02:00
}
2010-04-24 19:37:55 +02:00
/**
2021-02-15 20:14:57 +01:00
* Reload SQL menu file ( if dynamic menus , if modified by version )
2011-08-21 15:28:05 +02:00
*
2011-09-29 22:21:57 +02:00
* @ param DoliDB $db Database handler
* @ param Translate $langs Object langs
* @ param Conf $conf Object conf
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2010-04-24 19:37:55 +02:00
*/
2020-04-25 19:13:20 +02:00
function migrate_reload_menu ( $db , $langs , $conf )
2010-04-24 19:37:55 +02:00
{
2020-10-28 17:49:52 +01:00
global $conf ;
dolibarr_install_syslog ( " upgrade2::migrate_reload_menu " );
// Define list of menu handlers to initialize
$listofmenuhandler = array ();
2023-10-08 23:19:49 +02:00
if ( getDolGlobalString ( 'MAIN_MENU_STANDARD' ) == 'auguria_menu' || getDolGlobalString ( 'MAIN_MENU_SMARTPHONE' ) == 'auguria_menu'
|| getDolGlobalString ( 'MAIN_MENUFRONT_STANDARD' ) == 'auguria_menu' || getDolGlobalString ( 'MAIN_MENUFRONT_SMARTPHONE' ) == 'auguria_menu' ) {
2020-10-28 17:49:52 +01:00
$listofmenuhandler [ 'auguria' ] = 1 ; // We set here only dynamic menu handlers
}
2021-02-22 15:18:01 +01:00
foreach ( $listofmenuhandler as $key => $val ) {
2021-02-27 12:45:07 +01:00
print '<tr class="trforrunsql"><td colspan="4">' ;
2020-10-28 17:49:52 +01:00
//print "x".$key;
print '<br>' ;
print '<b>' . $langs -> trans ( 'Upgrade' ) . '</b>: ' . $langs -> trans ( 'MenuHandler' ) . " " . $key . " <br> \n " ;
// Load sql ini_menu_handler.sql file
$dir = DOL_DOCUMENT_ROOT . " /core/menus/ " ;
$file = 'init_menu_' . $key . '.sql' ;
2021-02-22 15:18:01 +01:00
if ( file_exists ( $dir . $file )) {
2024-09-26 22:17:49 +02:00
$result = run_sql ( $dir . $file , 1 , 0 , 1 , $key );
2020-10-28 17:49:52 +01:00
}
print '</td></tr>' ;
}
2022-12-31 14:37:33 +01:00
return 1 ;
2010-04-24 19:37:55 +02:00
}
2024-11-13 23:58:12 +01:00
/**
* Migrate file from old path to new one for lot path
*
* @ return void
*/
function migrate_productlot_path ()
{
global $conf , $db , $langs , $user ;
2024-11-28 11:07:15 +01:00
if ( ! is_object ( $user )) {
include_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$user = new User ( $db ); // To avoid error during migration
}
2024-11-13 23:58:12 +01:00
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'MigrationProductLotPath' ) . " </b><br> \n " ;
$sql = " SELECT rowid , entity, batch, fk_product from " . MAIN_DB_PREFIX . " product_lot " ;
$resql = $db -> query ( $sql );
if ( $resql ) {
$modulepart = " product_batch " ;
while ( $obj = $db -> fetch_object ( $resql )) {
$entity = ( empty ( $obj -> entity ) ? 1 : $obj -> entity );
if ( $entity > 1 ) {
$dir = DOL_DATA_ROOT . '/' . $entity . '/' . $conf -> productbatch -> multidir_output [ $entity ];
} else {
$dir = $conf -> productbatch -> multidir_output [ $entity ];
}
$lot = new Productlot ( $db );
$res = $lot -> fetch ( $obj -> rowid , $obj -> fk_product , $obj -> batch );
if ( $dir && $res > 0 ) {
$lot -> ref = $obj -> batch ;
$origin = $dir . '/' . get_exdir ( 0 , 0 , 0 , 1 , $lot , $modulepart );
$lot -> fetch ( $obj -> rowid , $obj -> fk_product , $obj -> batch );
$destin = $dir . '/' . get_exdir ( 0 , 0 , 0 , 1 , $lot , $modulepart );
if ( dol_is_dir ( $origin ) && ! dol_is_dir ( $destin )) {
dol_move_dir ( $origin , $destin , 0 );
}
}
}
}
print '</td></tr>' ;
}
2018-12-01 23:57:15 +01:00
/**
* Migrate file from old path to new one for users
*
* @ return void
*/
function migrate_user_photospath ()
{
2018-12-07 19:05:24 +01:00
global $conf , $db , $langs , $user ;
2018-12-04 09:12:36 +01:00
2018-12-01 23:57:15 +01:00
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'MigrationUserPhotoPath' ) . " </b><br> \n " ;
2018-12-04 09:12:36 +01:00
2018-12-01 23:57:15 +01:00
include_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$fuser = new User ( $db );
2021-02-22 15:18:01 +01:00
if ( ! is_object ( $user )) {
$user = $fuser ; // To avoid error during migration
}
2018-12-07 19:05:24 +01:00
2023-06-19 16:30:29 +02:00
$sql = " SELECT rowid as uid, entity from " . MAIN_DB_PREFIX . " user " ; // Get list of all users
2018-12-01 23:57:15 +01:00
$resql = $db -> query ( $sql );
2021-02-22 15:18:01 +01:00
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
2023-06-19 16:30:29 +02:00
//$fuser->fetch($obj->uid);
$fuser -> id = $obj -> uid ;
$fuser -> entity = $obj -> entity ;
2018-12-01 23:57:15 +01:00
//echo '<hr>'.$fuser->id.' -> '.$fuser->entity;
2018-12-06 19:29:11 +01:00
$entity = ( empty ( $fuser -> entity ) ? 1 : $fuser -> entity );
2018-12-04 09:12:36 +01:00
if ( $entity > 1 ) {
2019-11-14 12:09:15 +01:00
$dir = DOL_DATA_ROOT . '/' . $entity . '/users' ;
2018-12-04 09:12:36 +01:00
} else {
2019-11-14 12:09:15 +01:00
$dir = $conf -> user -> multidir_output [ $entity ]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module
2018-12-04 09:12:36 +01:00
}
2018-12-07 19:08:53 +01:00
2021-02-22 15:18:01 +01:00
if ( $dir ) {
2018-12-07 19:35:38 +01:00
//print "Process user id ".$fuser->id."<br>\n";
2019-11-14 12:09:15 +01:00
$origin = $dir . '/' . get_exdir ( $fuser -> id , 2 , 0 , 1 , $fuser , 'user' ); // Use old behaviour to get x/y path
$destin = $dir . '/' . $fuser -> id ;
2018-12-04 09:12:36 +01:00
2019-11-14 12:09:15 +01:00
$origin_osencoded = dol_osencode ( $origin );
2018-12-04 09:12:36 +01:00
2018-12-07 19:05:24 +01:00
dol_mkdir ( $destin );
2018-12-07 19:08:53 +01:00
2018-12-07 19:05:24 +01:00
//echo '<hr>'.$origin.' -> '.$destin;
2021-02-22 15:18:01 +01:00
if ( dol_is_dir ( $origin )) {
2019-11-14 12:09:15 +01:00
$handle = opendir ( $origin_osencoded );
2021-02-22 15:18:01 +01:00
if ( is_resource ( $handle )) {
while (( $file = readdir ( $handle )) !== false ) {
if ( $file == '.' || $file == '..' ) {
continue ;
}
2020-10-28 17:49:52 +01:00
2021-02-22 15:18:01 +01:00
if ( dol_is_dir ( $origin . '/' . $file )) { // it is a dir (like 'thumbs')
2020-10-28 17:49:52 +01:00
$thumbs = opendir ( $origin_osencoded . '/' . $file );
2021-02-22 15:18:01 +01:00
if ( is_resource ( $thumbs )) {
dol_mkdir ( $destin . '/' . $file );
while (( $thumb = readdir ( $thumbs )) !== false ) {
if ( ! dol_is_file ( $destin . '/' . $file . '/' . $thumb )) {
if ( $thumb == '.' || $thumb == '..' ) {
continue ;
}
2020-10-28 17:49:52 +01:00
//print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'<br>'."\n";
print '.' ;
2024-09-23 01:59:14 +02:00
dol_copy ( $origin . '/' . $file . '/' . $thumb , $destin . '/' . $file . '/' . $thumb , '0' , 0 );
2020-10-28 17:49:52 +01:00
//var_dump('aaa');exit;
}
}
2018-12-07 19:05:24 +01:00
// dol_delete_dir($origin.'/'.$file);
2020-10-28 17:49:52 +01:00
}
2022-02-22 21:24:34 +01:00
} else { // it is a file
2021-02-22 15:18:01 +01:00
if ( ! dol_is_file ( $destin . '/' . $file )) {
2020-10-28 17:49:52 +01:00
//print $origin.'/'.$file.' -> '.$destin.'/'.$file.'<br>'."\n";
print '.' ;
2024-09-23 01:59:14 +02:00
dol_copy ( $origin . '/' . $file , $destin . '/' . $file , '0' , 0 );
2020-10-28 17:49:52 +01:00
//var_dump('eee');exit;
}
}
}
}
2018-12-07 19:05:24 +01:00
}
2018-12-06 19:29:11 +01:00
}
2018-12-01 23:57:15 +01:00
}
}
print '</td></tr>' ;
}
2010-04-24 19:37:55 +02:00
2022-02-22 21:24:34 +01:00
/**
* Migrate file from old path users / 99 / file . jpg into users / 99 / photos / file . jpg
*
* @ return void
*/
function migrate_user_photospath2 ()
{
2023-06-19 16:30:29 +02:00
global $db , $langs , $user ;
2022-02-22 21:24:34 +01:00
print '<tr><td colspan="4">' ;
print '<b>' . $langs -> trans ( 'MigrationUserPhotoPath' ) . " </b><br> \n " ;
include_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$fuser = new User ( $db );
if ( ! is_object ( $user )) {
$user = $fuser ; // To avoid error during migration
}
2023-06-19 16:42:17 +02:00
$sql = " SELECT rowid as uid, entity, photo from " . MAIN_DB_PREFIX . " user " ; // Get list of all users
2022-02-22 21:24:34 +01:00
$resql = $db -> query ( $sql );
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
2023-06-19 16:42:17 +02:00
//$fuser->fetch($obj->uid);
$fuser -> id = $obj -> uid ;
$fuser -> entity = $obj -> entity ;
$fuser -> photo = $obj -> photo ;
2022-02-22 21:24:34 +01:00
//echo '<hr>'.$fuser->id.' -> '.$fuser->entity;
$entity = ( empty ( $fuser -> entity ) ? 1 : $fuser -> entity );
if ( $entity > 1 ) {
$dir = DOL_DATA_ROOT . '/' . $entity . '/users' ;
} else {
2022-05-10 14:03:09 +02:00
$dir = DOL_DATA_ROOT . '/users' ;
2022-02-22 21:24:34 +01:00
}
if ( $dir ) {
//print "Process user id ".$fuser->id."<br>\n";
$origin = $dir . '/' . $fuser -> id ;
$destin = $dir . '/' . $fuser -> id . '/photos' ;
$origin_osencoded = dol_osencode ( $origin );
dol_mkdir ( $destin );
//echo '<hr>'.$origin.' -> '.$destin;
if ( dol_is_dir ( $origin )) {
$handle = opendir ( $origin_osencoded );
if ( is_resource ( $handle )) {
while (( $file = readdir ( $handle )) !== false ) {
if ( $file == '.' || $file == '..' || $file == 'photos' ) {
continue ;
}
if ( ! empty ( $fuser -> photo ) && ( $file != $fuser -> photo && $file != 'thumbs' )) {
continue ;
}
if ( dol_is_dir ( $origin . '/' . $file )) { // it is a dir (like 'thumbs')
$thumbs = opendir ( $origin_osencoded . '/' . $file );
if ( is_resource ( $thumbs )) {
dol_mkdir ( $destin . '/' . $file );
while (( $thumb = readdir ( $thumbs )) !== false ) {
if ( ! dol_is_file ( $destin . '/' . $file . '/' . $thumb )) {
if ( $thumb == '.' || $thumb == '..' ) {
continue ;
}
//print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'<br>'."\n";
print '.' ;
2024-09-23 01:59:14 +02:00
dol_copy ( $origin . '/' . $file . '/' . $thumb , $destin . '/' . $file . '/' . $thumb , '0' , 0 );
2022-02-22 21:24:34 +01:00
}
}
// dol_delete_dir($origin.'/'.$file);
}
} else { // it is a file
if ( ! dol_is_file ( $destin . '/' . $file )) {
//print $origin.'/'.$file.' -> '.$destin.'/'.$file.'<br>'."\n";
print '.' ;
2024-09-23 01:59:14 +02:00
dol_copy ( $origin . '/' . $file , $destin . '/' . $file , '0' , 0 );
2022-02-22 21:24:34 +01:00
}
}
}
}
}
}
}
}
print '</td></tr>' ;
}
2017-06-06 01:34:25 +02:00
2008-05-21 05:53:52 +02:00
/* A faire egalement : Modif statut paye et fk_facture des factures payes completement
2007-12-11 21:08:53 +01:00
On recherche facture incorrecte :
select f . rowid , f . total_ttc as t1 , sum ( pf . amount ) as t2 from llx_facture as f , llx_paiement_facture as pf where pf . fk_facture = f . rowid and f . fk_statut in ( 2 , 3 ) and paye = 0 and close_code is null group by f . rowid
having f . total_ttc = sum ( pf . amount )
On les corrige :
update llx_facture set paye = 1 , fk_statut = 2 where close_code is null
and rowid in ( ... )
*/
2019-10-01 17:51:44 +02:00
/**
2021-10-27 16:39:34 +02:00
* Migrate users fields facebook and co to socialnetworks .
* Can be called only when version is 10.0 .* or lower . Fields does not exists after .
2019-10-01 17:51:44 +02:00
*
* @ return void
*/
function migrate_users_socialnetworks ()
{
2020-10-28 17:49:52 +01:00
global $db , $langs ;
// skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp
$error = 0 ;
$db -> begin ();
print '<tr><td colspan="4">' ;
$sql = 'SELECT rowid, socialnetworks' ;
$sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM ' . MAIN_DB_PREFIX . 'user WHERE' ;
$sql .= " skype IS NOT NULL OR skype <> '' " ;
$sql .= " OR twitter IS NOT NULL OR twitter <> '' " ;
$sql .= " OR facebook IS NOT NULL OR facebook <> '' " ;
$sql .= " OR linkedin IS NOT NULL OR linkedin <> '' " ;
$sql .= " OR instagram IS NOT NULL OR instagram <> '' " ;
$sql .= " OR snapchat IS NOT NULL OR snapchat <> '' " ;
$sql .= " OR googleplus IS NOT NULL OR googleplus <> '' " ;
$sql .= " OR youtube IS NOT NULL OR youtube <> '' " ;
$sql .= " OR whatsapp IS NOT NULL OR whatsapp <> '' " ;
//print $sql;
$resql = $db -> query ( $sql );
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
$arraysocialnetworks = array ();
if ( ! empty ( $obj -> skype )) {
$arraysocialnetworks [ 'skype' ] = $obj -> skype ;
}
if ( ! empty ( $obj -> twitter )) {
$arraysocialnetworks [ 'twitter' ] = $obj -> twitter ;
}
if ( ! empty ( $obj -> facebook )) {
$arraysocialnetworks [ 'facebook' ] = $obj -> facebook ;
}
if ( ! empty ( $obj -> linkedin )) {
$arraysocialnetworks [ 'linkedin' ] = $obj -> linkedin ;
}
if ( ! empty ( $obj -> instagram )) {
$arraysocialnetworks [ 'instagram' ] = $obj -> instagram ;
}
if ( ! empty ( $obj -> snapchat )) {
$arraysocialnetworks [ 'snapchat' ] = $obj -> snapchat ;
}
if ( ! empty ( $obj -> googleplus )) {
$arraysocialnetworks [ 'googleplus' ] = $obj -> googleplus ;
}
if ( ! empty ( $obj -> youtube )) {
$arraysocialnetworks [ 'youtube' ] = $obj -> youtube ;
}
if ( ! empty ( $obj -> whatsapp )) {
$arraysocialnetworks [ 'whatsapp' ] = $obj -> whatsapp ;
}
if ( $obj -> socialnetworks == '' || is_null ( $obj -> socialnetworks )) {
$obj -> socialnetworks = '[]' ;
}
$socialnetworks = array_merge ( $arraysocialnetworks , json_decode ( $obj -> socialnetworks , true ));
2024-03-19 00:46:03 +01:00
$sqlupd = 'UPDATE ' . MAIN_DB_PREFIX . " user SET socialnetworks=' " . $db -> escape ( json_encode ( $socialnetworks )) . " ' " ;
2020-10-28 17:49:52 +01:00
$sqlupd .= ', skype=null' ;
$sqlupd .= ', twitter=null' ;
$sqlupd .= ', facebook=null' ;
$sqlupd .= ', linkedin=null' ;
$sqlupd .= ', instagram=null' ;
$sqlupd .= ', snapchat=null' ;
$sqlupd .= ', googleplus=null' ;
$sqlupd .= ', youtube=null' ;
$sqlupd .= ', whatsapp=null' ;
2021-08-28 03:09:18 +02:00
$sqlupd .= ' WHERE rowid = ' . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
//print $sqlupd."<br>";
$resqlupd = $db -> query ( $sqlupd );
if ( ! $resqlupd ) {
dol_print_error ( $db );
$error ++ ;
}
}
} else {
$error ++ ;
}
if ( ! $error ) {
$db -> commit ();
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '<b>' . $langs -> trans ( 'MigrationFieldsSocialNetworks' , 'Users' ) . " </b><br> \n " ;
print '</td></tr>' ;
2019-10-01 17:51:44 +02:00
}
/**
* Migrate members fields facebook and co to socialnetworks
2021-10-27 16:39:34 +02:00
* Can be called only when version is 10.0 .* or lower . Fields does not exists after .
2019-10-01 17:51:44 +02:00
*
* @ return void
*/
function migrate_members_socialnetworks ()
{
2020-10-28 17:49:52 +01:00
global $db , $langs ;
print '<tr><td colspan="4">' ;
$error = 0 ;
$db -> begin ();
print '<tr><td colspan="4">' ;
$sql = 'SELECT rowid, socialnetworks' ;
$sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM ' . MAIN_DB_PREFIX . 'adherent WHERE ' ;
$sql .= " skype IS NOT NULL OR skype <> '' " ;
$sql .= " OR twitter IS NOT NULL OR twitter <> '' " ;
$sql .= " OR facebook IS NOT NULL OR facebook <> '' " ;
$sql .= " OR linkedin IS NOT NULL OR linkedin <> '' " ;
$sql .= " OR instagram IS NOT NULL OR instagram <> '' " ;
$sql .= " OR snapchat IS NOT NULL OR snapchat <> '' " ;
$sql .= " OR googleplus IS NOT NULL OR googleplus <> '' " ;
$sql .= " OR youtube IS NOT NULL OR youtube <> '' " ;
$sql .= " OR whatsapp IS NOT NULL OR whatsapp <> '' " ;
//print $sql;
$resql = $db -> query ( $sql );
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
$arraysocialnetworks = array ();
if ( ! empty ( $obj -> skype )) {
$arraysocialnetworks [ 'skype' ] = $obj -> skype ;
}
if ( ! empty ( $obj -> twitter )) {
$arraysocialnetworks [ 'twitter' ] = $obj -> twitter ;
}
if ( ! empty ( $obj -> facebook )) {
$arraysocialnetworks [ 'facebook' ] = $obj -> facebook ;
}
if ( ! empty ( $obj -> linkedin )) {
$arraysocialnetworks [ 'linkedin' ] = $obj -> linkedin ;
}
if ( ! empty ( $obj -> instagram )) {
$arraysocialnetworks [ 'instagram' ] = $obj -> instagram ;
}
if ( ! empty ( $obj -> snapchat )) {
$arraysocialnetworks [ 'snapchat' ] = $obj -> snapchat ;
}
if ( ! empty ( $obj -> googleplus )) {
$arraysocialnetworks [ 'googleplus' ] = $obj -> googleplus ;
}
if ( ! empty ( $obj -> youtube )) {
$arraysocialnetworks [ 'youtube' ] = $obj -> youtube ;
}
if ( ! empty ( $obj -> whatsapp )) {
$arraysocialnetworks [ 'whatsapp' ] = $obj -> whatsapp ;
}
if ( $obj -> socialnetworks == '' || is_null ( $obj -> socialnetworks )) {
$obj -> socialnetworks = '[]' ;
}
$socialnetworks = array_merge ( $arraysocialnetworks , json_decode ( $obj -> socialnetworks , true ));
2024-03-19 00:46:03 +01:00
$sqlupd = 'UPDATE ' . MAIN_DB_PREFIX . " adherent SET socialnetworks=' " . $db -> escape ( json_encode ( $socialnetworks )) . " ' " ;
2020-10-28 17:49:52 +01:00
$sqlupd .= ', skype=null' ;
$sqlupd .= ', twitter=null' ;
$sqlupd .= ', facebook=null' ;
$sqlupd .= ', linkedin=null' ;
$sqlupd .= ', instagram=null' ;
$sqlupd .= ', snapchat=null' ;
$sqlupd .= ', googleplus=null' ;
$sqlupd .= ', youtube=null' ;
$sqlupd .= ', whatsapp=null' ;
2021-08-28 03:09:18 +02:00
$sqlupd .= ' WHERE rowid = ' . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
//print $sqlupd."<br>";
$resqlupd = $db -> query ( $sqlupd );
if ( ! $resqlupd ) {
dol_print_error ( $db );
$error ++ ;
}
}
} else {
$error ++ ;
}
if ( ! $error ) {
$db -> commit ();
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '<b>' . $langs -> trans ( 'MigrationFieldsSocialNetworks' , 'Members' ) . " </b><br> \n " ;
print '</td></tr>' ;
2019-10-01 17:51:44 +02:00
}
/**
* Migrate contacts fields facebook and co to socialnetworks
2021-10-27 16:39:34 +02:00
* Can be called only when version is 10.0 .* or lower . Fields does not exists after .
2019-10-01 17:51:44 +02:00
*
* @ return void
*/
function migrate_contacts_socialnetworks ()
{
2020-10-28 17:49:52 +01:00
global $db , $langs ;
// jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp
$error = 0 ;
$db -> begin ();
print '<tr><td colspan="4">' ;
$sql = 'SELECT rowid, socialnetworks' ;
2021-06-10 00:09:38 +02:00
$sql .= ', jabberid, skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM ' . MAIN_DB_PREFIX . 'socpeople WHERE' ;
2020-10-28 17:49:52 +01:00
$sql .= " jabberid IS NOT NULL OR jabberid <> '' " ;
$sql .= " OR skype IS NOT NULL OR skype <> '' " ;
$sql .= " OR twitter IS NOT NULL OR twitter <> '' " ;
$sql .= " OR facebook IS NOT NULL OR facebook <> '' " ;
$sql .= " OR linkedin IS NOT NULL OR linkedin <> '' " ;
$sql .= " OR instagram IS NOT NULL OR instagram <> '' " ;
$sql .= " OR snapchat IS NOT NULL OR snapchat <> '' " ;
$sql .= " OR googleplus IS NOT NULL OR googleplus <> '' " ;
$sql .= " OR youtube IS NOT NULL OR youtube <> '' " ;
$sql .= " OR whatsapp IS NOT NULL OR whatsapp <> '' " ;
//print $sql;
$resql = $db -> query ( $sql );
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
$arraysocialnetworks = array ();
if ( ! empty ( $obj -> jabberid )) {
$arraysocialnetworks [ 'jabber' ] = $obj -> jabberid ;
}
if ( ! empty ( $obj -> skype )) {
$arraysocialnetworks [ 'skype' ] = $obj -> skype ;
}
if ( ! empty ( $obj -> twitter )) {
$arraysocialnetworks [ 'twitter' ] = $obj -> twitter ;
}
if ( ! empty ( $obj -> facebook )) {
$arraysocialnetworks [ 'facebook' ] = $obj -> facebook ;
}
if ( ! empty ( $obj -> linkedin )) {
$arraysocialnetworks [ 'linkedin' ] = $obj -> linkedin ;
}
if ( ! empty ( $obj -> instagram )) {
$arraysocialnetworks [ 'instagram' ] = $obj -> instagram ;
}
if ( ! empty ( $obj -> snapchat )) {
$arraysocialnetworks [ 'snapchat' ] = $obj -> snapchat ;
}
if ( ! empty ( $obj -> googleplus )) {
$arraysocialnetworks [ 'googleplus' ] = $obj -> googleplus ;
}
if ( ! empty ( $obj -> youtube )) {
$arraysocialnetworks [ 'youtube' ] = $obj -> youtube ;
}
if ( ! empty ( $obj -> whatsapp )) {
$arraysocialnetworks [ 'whatsapp' ] = $obj -> whatsapp ;
}
if ( $obj -> socialnetworks == '' || is_null ( $obj -> socialnetworks )) {
$obj -> socialnetworks = '[]' ;
}
$socialnetworks = array_merge ( $arraysocialnetworks , json_decode ( $obj -> socialnetworks , true ));
2024-03-19 00:46:03 +01:00
$sqlupd = 'UPDATE ' . MAIN_DB_PREFIX . " socpeople SET socialnetworks=' " . $db -> escape ( json_encode ( $socialnetworks )) . " ' " ;
2020-10-28 17:49:52 +01:00
$sqlupd .= ', jabberid=null' ;
$sqlupd .= ', skype=null' ;
$sqlupd .= ', twitter=null' ;
$sqlupd .= ', facebook=null' ;
$sqlupd .= ', linkedin=null' ;
$sqlupd .= ', instagram=null' ;
$sqlupd .= ', snapchat=null' ;
$sqlupd .= ', googleplus=null' ;
$sqlupd .= ', youtube=null' ;
$sqlupd .= ', whatsapp=null' ;
2021-08-28 03:09:18 +02:00
$sqlupd .= ' WHERE rowid = ' . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
//print $sqlupd."<br>";
$resqlupd = $db -> query ( $sqlupd );
if ( ! $resqlupd ) {
dol_print_error ( $db );
$error ++ ;
}
}
} else {
$error ++ ;
}
if ( ! $error ) {
$db -> commit ();
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '<b>' . $langs -> trans ( 'MigrationFieldsSocialNetworks' , 'Contacts' ) . " </b><br> \n " ;
print '</td></tr>' ;
2019-10-01 17:51:44 +02:00
}
/**
2019-10-01 19:59:49 +02:00
* Migrate thirdparties fields facebook and co to socialnetworks
2021-10-27 16:39:34 +02:00
* Can be called only when version is 10.0 .* or lower . Fields does not exists after .
2019-10-01 17:51:44 +02:00
*
* @ return void
*/
function migrate_thirdparties_socialnetworks ()
{
2020-10-28 17:49:52 +01:00
global $db , $langs ;
// skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp
$error = 0 ;
$db -> begin ();
print '<tr><td colspan="4">' ;
$sql = 'SELECT rowid, socialnetworks' ;
$sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM ' . MAIN_DB_PREFIX . 'societe WHERE ' ;
$sql .= " skype IS NOT NULL OR skype <> '' " ;
$sql .= " OR twitter IS NOT NULL OR twitter <> '' " ;
$sql .= " OR facebook IS NOT NULL OR facebook <> '' " ;
$sql .= " OR linkedin IS NOT NULL OR linkedin <> '' " ;
$sql .= " OR instagram IS NOT NULL OR instagram <> '' " ;
$sql .= " OR snapchat IS NOT NULL OR snapchat <> '' " ;
$sql .= " OR googleplus IS NOT NULL OR googleplus <> '' " ;
$sql .= " OR youtube IS NOT NULL OR youtube <> '' " ;
$sql .= " OR whatsapp IS NOT NULL OR whatsapp <> '' " ;
//print $sql;
$resql = $db -> query ( $sql );
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
$arraysocialnetworks = array ();
if ( ! empty ( $obj -> skype )) {
$arraysocialnetworks [ 'skype' ] = $obj -> skype ;
}
if ( ! empty ( $obj -> twitter )) {
$arraysocialnetworks [ 'twitter' ] = $obj -> twitter ;
}
if ( ! empty ( $obj -> facebook )) {
$arraysocialnetworks [ 'facebook' ] = $obj -> facebook ;
}
if ( ! empty ( $obj -> linkedin )) {
$arraysocialnetworks [ 'linkedin' ] = $obj -> linkedin ;
}
if ( ! empty ( $obj -> instagram )) {
$arraysocialnetworks [ 'instagram' ] = $obj -> instagram ;
}
if ( ! empty ( $obj -> snapchat )) {
$arraysocialnetworks [ 'snapchat' ] = $obj -> snapchat ;
}
if ( ! empty ( $obj -> googleplus )) {
$arraysocialnetworks [ 'googleplus' ] = $obj -> googleplus ;
}
if ( ! empty ( $obj -> youtube )) {
$arraysocialnetworks [ 'youtube' ] = $obj -> youtube ;
}
if ( ! empty ( $obj -> whatsapp )) {
$arraysocialnetworks [ 'whatsapp' ] = $obj -> whatsapp ;
}
if ( $obj -> socialnetworks == '' || is_null ( $obj -> socialnetworks )) {
$obj -> socialnetworks = '[]' ;
}
$socialnetworks = array_merge ( $arraysocialnetworks , json_decode ( $obj -> socialnetworks , true ));
2024-03-19 00:46:03 +01:00
$sqlupd = 'UPDATE ' . MAIN_DB_PREFIX . " societe SET socialnetworks=' " . $db -> escape ( json_encode ( $socialnetworks )) . " ' " ;
2020-10-28 17:49:52 +01:00
$sqlupd .= ', skype=null' ;
$sqlupd .= ', twitter=null' ;
$sqlupd .= ', facebook=null' ;
$sqlupd .= ', linkedin=null' ;
$sqlupd .= ', instagram=null' ;
$sqlupd .= ', snapchat=null' ;
$sqlupd .= ', googleplus=null' ;
$sqlupd .= ', youtube=null' ;
$sqlupd .= ', whatsapp=null' ;
2021-08-28 03:09:18 +02:00
$sqlupd .= ' WHERE rowid = ' . (( int ) $obj -> rowid );
2020-10-28 17:49:52 +01:00
//print $sqlupd."<br>";
$resqlupd = $db -> query ( $sqlupd );
if ( ! $resqlupd ) {
dol_print_error ( $db );
$error ++ ;
}
}
} else {
$error ++ ;
}
if ( ! $error ) {
$db -> commit ();
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '<b>' . $langs -> trans ( 'MigrationFieldsSocialNetworks' , 'Thirdparties' ) . " </b><br> \n " ;
print '</td></tr>' ;
2019-10-01 17:51:44 +02:00
}
2021-07-06 11:54:32 +02:00
/**
* Migrate export and import profiles to fix field name that was renamed
*
* @ param string $mode 'export' or 'import'
* @ return void
*/
function migrate_export_import_profiles ( $mode = 'export' )
{
global $db , $langs ;
$error = 0 ;
$resultstring = '' ;
$db -> begin ();
print '<tr class="trforrunsql"><td colspan="4">' ;
$sql = 'SELECT rowid, field' ;
if ( $mode == 'export' ) {
$sql .= ', filter' ;
}
$sql .= ' FROM ' . MAIN_DB_PREFIX . $mode . '_model WHERE' ;
$sql .= " type LIKE 'propale_%' OR type LIKE 'commande_%' OR type LIKE 'facture_%' " ;
//print $sql;
$resql = $db -> query ( $sql );
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
$oldfield = $obj -> field ;
2021-07-06 18:40:54 +02:00
$newfield = str_replace ( array ( ',f.facnumber' , 'f.facnumber,' , 'f.total,' , 'f.tva,' ), array ( ',f.ref' , 'f.ref,' , 'f.total_ht,' , 'f.total_tva,' ), $oldfield );
2021-07-06 11:54:32 +02:00
if ( $mode == 'export' ) {
$oldfilter = $obj -> filter ;
2021-07-06 18:40:54 +02:00
$newfilter = str_replace ( array ( 'f.facnumber=' , 'f.total=' , 'f.tva=' ), array ( 'f.ref=' , 'f.total_ht=' , 'f.total_tva=' ), $oldfilter );
2021-07-06 11:54:32 +02:00
} else {
$oldfilter = '' ;
$newfilter = '' ;
}
if ( $oldfield != $newfield || $oldfilter != $newfilter ) {
$sqlupd = 'UPDATE ' . MAIN_DB_PREFIX . $mode . " _model SET field = ' " . $db -> escape ( $newfield ) . " ' " ;
if ( $mode == 'export' ) {
2021-07-07 01:18:28 +02:00
$sqlupd .= " , filter = ' " . $db -> escape ( $newfilter ) . " ' " ;
2021-07-06 11:54:32 +02:00
}
2021-08-28 03:09:18 +02:00
$sqlupd .= ' WHERE rowid = ' . (( int ) $obj -> rowid );
2021-07-06 11:54:32 +02:00
$resultstring .= '<tr class="trforrunsql" style=""><td class="wordbreak" colspan="4">' . $sqlupd . " </td></tr> \n " ;
$resqlupd = $db -> query ( $sqlupd );
if ( ! $resqlupd ) {
dol_print_error ( $db );
$error ++ ;
}
}
}
} else {
$error ++ ;
}
if ( ! $error ) {
$db -> commit ();
} else {
dol_print_error ( $db );
$db -> rollback ();
}
print '<b>' . $langs -> trans ( 'MigrationImportOrExportProfiles' , $mode ) . " </b><br> \n " ;
print '</td></tr>' ;
if ( $resultstring ) {
print $resultstring ;
} else {
print '<tr class="trforrunsql" style=""><td class="wordbreak" colspan="4">' . $langs -> trans ( " NothingToDo " ) . " </td></tr> \n " ;
}
}
2022-10-07 12:02:53 +02:00
/**
* Migrate Rank into contract line
*
* @ return void
*/
function migrate_contractdet_rank ()
{
global $db , $langs ;
$error = 0 ;
$resultstring = '' ;
$db -> begin ();
print '<tr class="trforrunsql"><td colspan="4">' ;
2022-10-13 20:31:56 +02:00
print '<b>' . $langs -> trans ( 'MigrationContractLineRank' ) . " </b><br> \n " ;
2022-10-07 12:02:53 +02:00
2022-10-13 20:31:56 +02:00
$sql = " SELECT c.rowid as cid ,cd.rowid as cdid,cd.rang FROM " . $db -> prefix () . " contratdet as cd INNER JOIN " . $db -> prefix () . " contrat as c ON c.rowid=cd.fk_contrat AND cd.rang=0 " ;
2024-03-19 00:46:03 +01:00
$sql .= " ORDER BY c.rowid,cd.rowid " ;
2022-10-07 12:02:53 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
2024-03-19 00:46:03 +01:00
$currentRank = 0 ;
$current_contract = 0 ;
2022-10-07 12:02:53 +02:00
while ( $obj = $db -> fetch_object ( $resql )) {
2024-03-19 00:46:03 +01:00
if ( empty ( $current_contract ) || $current_contract == $obj -> cid ) {
2022-10-07 12:02:53 +02:00
$currentRank ++ ;
} else {
2024-03-19 00:46:03 +01:00
$currentRank = 1 ;
2022-10-07 12:02:53 +02:00
}
2022-10-09 14:15:43 +02:00
$sqlUpd = " UPDATE " . $db -> prefix () . " contratdet SET rang= " . ( int ) $currentRank . " WHERE rowid= " . ( int ) $obj -> cdid ;
2022-10-13 20:31:56 +02:00
$resultstring = '.' ;
print $resultstring ;
2022-10-07 12:02:53 +02:00
$resqlUpd = $db -> query ( $sqlUpd );
if ( ! $resqlUpd ) {
dol_print_error ( $db );
$error ++ ;
}
$current_contract = $obj -> cid ;
}
} else {
$error ++ ;
}
if ( ! $error ) {
$db -> commit ();
} else {
$db -> rollback ();
}
print '</td></tr>' ;
2022-10-13 20:31:56 +02:00
if ( ! $resultstring ) {
2022-10-07 12:02:53 +02:00
print '<tr class="trforrunsql" style=""><td class="wordbreak" colspan="4">' . $langs -> trans ( " NothingToDo " ) . " </td></tr> \n " ;
}
}