diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 0a3e49c9600..7594ead39a4 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -43,7 +43,9 @@ $langs->load("install"); // Now we load forced/pre-set values from install.forced.php file. $useforcedwizard = false; $forcedfile = "./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") { + $forcedfile = "/etc/dolibarr/install.forced.php"; +} if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -66,36 +68,36 @@ print '
'.$langs->trans("WarningBrowserTooOld")."
'.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
$checksok = 0; // 0=error, 1=warning
-} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) // Minimum supported (warning if lower)
-{
+} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) { // Minimum supported (warning if lower)
print '
'.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
$checksok = 0; // 0=error, 1=warning
} else {
print '
'.$langs->trans("PHPVersion")." ".versiontostring(versionphparray());
}
-if (empty($force_install_nophpinfo)) print ' ('.$langs->trans("MoreInformation").')';
+if (empty($force_install_nophpinfo)) {
+ print ' ('.$langs->trans("MoreInformation").')';
+}
print "
'.$langs->trans("PHPSupportPOSTGETKo");
print ' ('.$langs->trans("Recheck").')';
print "
'.$langs->trans("ErrorPHPDoesNotSupportSessions")."
'.$langs->trans("ErrorPHPDoesNotSupportGD")."
'.$langs->trans("ErrorPHPDoesNotSupportCurl")."
'.$langs->trans("ErrorPHPDoesNotSupportCalendar")."
'.$langs->trans("PHPSupport", "Calendar")."
'.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
'.$langs->trans("ErrorPHPDoesNotSupportIntl")."
'.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")."
'.$langs->trans("PHPMemoryOK", $memmaxorig, $memrequiredorig)."
'.$langs->trans("PHPMemoryTooLow", $memmaxorig, $memrequiredorig)."
'.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
print "
'.$langs->trans("ConfFileMustBeAFileNotADir", $conffiletoshow);
$allowinstall = 0;
- }
- // File exists but cannot be modified
- elseif (!is_writable($conffile))
- {
- if ($confexists)
- {
+ } elseif (!is_writable($conffile)) {
+ // File exists but cannot be modified
+ if ($confexists) {
print '
'.$langs->trans("ConfFileExists", $conffiletoshow);
} else {
print '
'.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
@@ -277,11 +267,9 @@ if (!file_exists($conffile))
print "
'.$langs->trans("ConfFileExists", $conffiletoshow);
} else {
print '
'.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
@@ -295,32 +283,28 @@ if (!file_exists($conffile))
print "



| '; print ' | |
| '; @@ -87,15 +87,13 @@ if ($db->ok) print ' |
| '.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).' | '.$langs->trans('Error').' | |||
| '; print ''.$langs->trans('UpgradeExternalModule').': '; print $hookmanager->error; @@ -544,8 +528,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } } else { //if (! empty($conf->modules)) - if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done - { + 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 ' | ||||
| '; print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); print ' | ||||
| '.$langs->trans('SuppliersInvoices').' | ||||
| fk_paiementfourn | fk_facturefourn | '.$langs->trans('Amount').' | '.$langs->trans("OK").' | '; } else { @@ -1376,10 +1344,8 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $error++; } - if (!$error) - { - if (!$nb) - { + if (!$error) { + if (!$nb) { print '|
| '.$langs->trans("AlreadyDone").' | ||||
| ';
@@ -1640,14 +1599,11 @@ function migrate_price_contrat($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_contrat");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1724,14 +1680,11 @@ function migrate_price_commande($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_commande");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1760,24 +1713,24 @@ function migrate_price_commande($db, $langs, $conf)
$commandeligne->update_total();
/* On touche pas a facture mere
- $commande = new Commande($db);
- $commande->id = $obj->rowid;
- if ( $commande->fetch($commande->id) >= 0 )
- {
- if ( $commande->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$commande->id;
- }
- }
- else
- {
- print "Error #3";
- }
- */
+ $commande = new Commande($db);
+ $commande->id = $obj->rowid;
+ if ( $commande->fetch($commande->id) >= 0 )
+ {
+ if ( $commande->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$commande->id;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ }
+ */
$i++;
}
} else {
@@ -1787,14 +1740,14 @@ function migrate_price_commande($db, $langs, $conf)
$db->free($resql);
/*
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
- $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0";
- $resql=$db->query($sql);
- if (! $resql)
- {
- dol_print_error($db);
- }
- */
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
+ $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0";
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($db);
+ }
+ */
$db->commit();
} else {
@@ -1837,14 +1790,11 @@ function migrate_price_commande_fournisseur($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1873,24 +1823,24 @@ function migrate_price_commande_fournisseur($db, $langs, $conf)
$commandeligne->update_total();
/* On touche pas a facture mere
- $commande = new Commande($db);
- $commande->id = $obj->rowid;
- if ( $commande->fetch($commande->id) >= 0 )
- {
- if ( $commande->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$commande->id;
- }
- }
- else
- {
- print "Error #3";
- }
- */
+ $commande = new Commande($db);
+ $commande->id = $obj->rowid;
+ if ( $commande->fetch($commande->id) >= 0 )
+ {
+ if ( $commande->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$commande->id;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ }
+ */
$i++;
}
} else {
@@ -1900,14 +1850,14 @@ function migrate_price_commande_fournisseur($db, $langs, $conf)
$db->free($resql);
/*
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
- $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
- $resql=$db->query($sql);
- if (! $resql)
- {
- dol_print_error($db);
- }
- */
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
+ $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($db);
+ }
+ */
$db->commit();
} else {
@@ -1936,42 +1886,42 @@ function migrate_modeles($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_modeles");
- if (!empty($conf->facture->enabled))
- {
+ if (!empty($conf->facture->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
$modellist = ModelePDFFactures::liste_modeles($db);
- if (count($modellist) == 0)
- {
+ if (count($modellist) == 0) {
// Aucun model par defaut.
$sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
}
- if (!empty($conf->commande->enabled))
- {
+ if (!empty($conf->commande->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
$modellist = ModelePDFCommandes::liste_modeles($db);
- if (count($modellist) == 0)
- {
+ if (count($modellist) == 0) {
// Aucun model par defaut.
$sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
}
- if (!empty($conf->expedition->enabled))
- {
+ if (!empty($conf->expedition->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
$modellist = ModelePDFExpedition::liste_modeles($db);
- if (count($modellist) == 0)
- {
+ if (count($modellist) == 0) {
// Aucun model par defaut.
$sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
}
@@ -1998,31 +1948,26 @@ function migrate_commande_expedition($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "fk_commande");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$error = 0;
$db->begin();
$sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)";
$sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
@@ -2031,8 +1976,7 @@ function migrate_commande_expedition($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande";
print $langs->trans('FieldRenamed')." \n"; @@ -2069,8 +2013,7 @@ function migrate_commande_livraison($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_commande"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); @@ -2080,23 +2023,19 @@ function migrate_commande_livraison($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; $sql .= " WHERE c.rowid = l.fk_commande"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { $delivery_date = $db->jdate($obj->delivery_date); $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; @@ -2104,8 +2043,7 @@ function migrate_commande_livraison($db, $langs, $conf) $sqlu .= ", date_livraison='".$db->idate($delivery_date)."'"; $sqlu .= " WHERE rowid = ".$obj->rowid; $resql3 = $db->query($sqlu); - if (!$resql3) - { + if (!$resql3) { $error++; dol_print_error($db); } @@ -2118,8 +2056,7 @@ function migrate_commande_livraison($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande"; print $langs->trans('FieldRenamed')." \n"; @@ -2158,8 +2095,7 @@ function migrate_detail_livraison($db, $langs, $conf) // If not this means migration was already done. $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_commande_ligne"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); @@ -2169,15 +2105,12 @@ function migrate_detail_livraison($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; @@ -2188,15 +2121,13 @@ function migrate_detail_livraison($db, $langs, $conf) $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { $sql = "SELECT total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; $sql .= " WHERE rowid = ".$obj->fk_livraison; $resql3 = $db->query($sql); - if ($resql3) - { + if ($resql3) { $obju = $db->fetch_object($resql3); $total_ht = $obju->total_ht + $obj->total_ht; @@ -2204,8 +2135,7 @@ function migrate_detail_livraison($db, $langs, $conf) $sqlu .= " total_ht='".$db->escape($total_ht)."'"; $sqlu .= " WHERE rowid=".$obj->fk_livraison; $resql4 = $db->query($sqlu); - if (!$resql4) - { + if (!$resql4) { $error++; dol_print_error($db); } @@ -2222,8 +2152,7 @@ function migrate_detail_livraison($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer"; print $langs->trans('FieldRenamed')." \n"; @@ -2238,8 +2167,7 @@ function migrate_detail_livraison($db, $langs, $conf) } else { $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_origin_line"); $obj = $db->fetch_object($result); - if (!$obj) - { + if (!$obj) { $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison"; $db->query($sql); } @@ -2273,15 +2201,12 @@ function migrate_stocks($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " GROUP BY fk_product"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; @@ -2289,8 +2214,7 @@ function migrate_stocks($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->fk_product; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { } else { $error++; dol_print_error($db); @@ -2300,8 +2224,7 @@ function migrate_stocks($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2334,8 +2257,7 @@ function migrate_menus($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) { $db->begin(); $sql = "SELECT m.rowid, mc.action"; @@ -2343,14 +2265,11 @@ function migrate_menus($db, $langs, $conf) $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; $sql .= " AND m.enabled = '1'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; @@ -2359,8 +2278,7 @@ function migrate_menus($db, $langs, $conf) $sql .= " AND enabled = '1'"; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { } else { $error++; dol_print_error($db); @@ -2370,8 +2288,7 @@ function migrate_menus($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2407,8 +2324,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) { $db->begin(); $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; @@ -2418,15 +2334,12 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; @@ -2434,8 +2347,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->fk_expedition; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2446,8 +2358,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) print $langs->trans('AlreadyDone')." \n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2476,10 +2387,8 @@ function migrate_restore_missing_links($db, $langs, $conf) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links"); - if (($db->type == 'mysql' || $db->type == 'mysqli')) - { - if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) - { + if (($db->type == 'mysql' || $db->type == 'mysqli')) { + if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); return 0; } @@ -2506,15 +2415,12 @@ function migrate_restore_missing_links($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. '; @@ -2523,18 +2429,18 @@ function migrate_restore_missing_links($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->field; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } //print ". "; $i++; } - } else print $langs->trans('AlreadyDone')." \n"; + } else { + print $langs->trans('AlreadyDone')." \n"; + } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2566,15 +2472,12 @@ function migrate_restore_missing_links($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. '; @@ -2583,8 +2486,7 @@ function migrate_restore_missing_links($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->field; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2595,8 +2497,7 @@ function migrate_restore_missing_links($db, $langs, $conf) print $langs->trans('AlreadyDone')." \n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2628,23 +2529,19 @@ function migrate_project_user_resp($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."projet", "fk_user_resp"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); $sql = "SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX."projet"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; @@ -2661,11 +2558,9 @@ function migrate_project_user_resp($db, $langs, $conf) $sql2 .= ", ".$obj->fk_user_resp; $sql2 .= ")"; - if ($obj->fk_user_resp > 0) - { + if ($obj->fk_user_resp > 0) { $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2676,11 +2571,9 @@ function migrate_project_user_resp($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."projet DROP COLUMN fk_user_resp"; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2715,23 +2608,19 @@ function migrate_project_task_actors($db, $langs, $conf) print ' '; print ''.$langs->trans('MigrationProjectTaskActors')." \n"; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) { $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); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; @@ -2750,8 +2639,7 @@ function migrate_project_task_actors($db, $langs, $conf) $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2760,11 +2648,9 @@ function migrate_project_task_actors($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors"; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2804,8 +2690,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) { dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); $db->begin(); @@ -2814,15 +2699,12 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -2838,8 +2720,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $sqlInsert .= ")"; $result = $db->query($sqlInsert); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -2850,11 +2731,9 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so print $langs->trans('AlreadyDone')." \n"; } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2897,22 +2776,18 @@ function migrate_project_task_time($db, $langs, $conf) $sql = "SELECT rowid, fk_task, task_duration"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $totaltime = array(); $oldtime = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->task_duration > 0) - { + if ($obj->task_duration > 0) { // convert to second // only for int time and float time ex: 1,75 for 1h45 list($hour, $min) = explode('.', $obj->task_duration); @@ -2925,36 +2800,37 @@ function migrate_project_task_time($db, $langs, $conf) $sql2 .= " WHERE rowid = ".$obj->rowid; $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } print ". "; $oldtime++; - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; - else $totaltime[$obj->fk_task] = $newtime; + if (!empty($totaltime[$obj->fk_task])) { + $totaltime[$obj->fk_task] += $newtime; + } else { + $totaltime[$obj->fk_task] = $newtime; + } } else { - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; - else $totaltime[$obj->fk_task] = $obj->task_duration; + if (!empty($totaltime[$obj->fk_task])) { + $totaltime[$obj->fk_task] += $obj->task_duration; + } else { + $totaltime[$obj->fk_task] = $obj->task_duration; + } } $i++; } - if ($error == 0) - { - if ($oldtime > 0) - { - foreach ($totaltime as $taskid => $total_duration) - { + if ($error == 0) { + if ($oldtime > 0) { + foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; $sql .= " duration_effective = ".$total_duration; $sql .= " WHERE rowid = ".$taskid; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; dol_print_error($db); } @@ -2972,8 +2848,7 @@ function migrate_project_task_time($db, $langs, $conf) dol_print_error($db); } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -3003,8 +2878,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "date_delivery"); $obj1 = $db->fetch_object($result1); $obj2 = $db->fetch_object($result2); - if (!$obj1 && !$obj2) - { + if (!$obj1 && !$obj2) { dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping"); $db->begin(); @@ -3012,8 +2886,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity"; $sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition"; - if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) - { + if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) { $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison as delivery_date"; $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; @@ -3022,15 +2895,12 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlSelect .= " AND el.targettype = 'shipping'"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; @@ -3039,8 +2909,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3051,8 +2920,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) print $langs->trans('AlreadyDone')." \n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { dol_print_error($db); @@ -3092,8 +2960,7 @@ function migrate_shipping_delivery($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_expedition"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { dolibarr_install_syslog("upgrade2::migrate_shipping_delivery"); $db->begin(); @@ -3103,15 +2970,12 @@ function migrate_shipping_delivery($db, $langs, $conf) $sqlSelect .= " WHERE fk_expedition is not null"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -3127,14 +2991,12 @@ function migrate_shipping_delivery($db, $langs, $conf) $sqlInsert .= ")"; $result = $db->query($sqlInsert); - if ($result) - { + if ($result) { $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; $sqlUpdate .= " WHERE rowid = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3149,8 +3011,7 @@ function migrate_shipping_delivery($db, $langs, $conf) print $langs->trans('AlreadyDone')." \n"; } - if ($error == 0) - { + if ($error == 0) { $sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'"; $db->query($sqlDelete); @@ -3209,15 +3070,12 @@ function migrate_shipping_delivery2($db, $langs, $conf) $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; @@ -3226,8 +3084,7 @@ function migrate_shipping_delivery2($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3238,8 +3095,7 @@ function migrate_shipping_delivery2($db, $langs, $conf) print $langs->trans('AlreadyDone')." \n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { dol_print_error($db); @@ -3277,12 +3133,10 @@ function migrate_actioncomm_element($db, $langs, $conf) 'invoice_supplier' => 'fk_supplier_invoice' ); - foreach ($elements as $type => $field) - { + foreach ($elements as $type => $field) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm", $field); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); $db->begin(); @@ -3294,8 +3148,7 @@ function migrate_actioncomm_element($db, $langs, $conf) $sql .= " AND elementtype IS NULL"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $db->commit(); // DDL commands must not be inside a transaction @@ -3338,8 +3191,7 @@ function migrate_mode_reglement($db, $langs, $conf) ); $count = 0; - foreach ($elements['old_id'] as $key => $old_id) - { + foreach ($elements['old_id'] as $key => $old_id) { $error = 0; dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]); @@ -3350,11 +3202,9 @@ function migrate_mode_reglement($db, $langs, $conf) $sqlSelect .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $count++; $db->begin(); @@ -3371,25 +3221,21 @@ function migrate_mode_reglement($db, $langs, $conf) $sql .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sql); - if ($resqla && $resql) - { - foreach ($elements['tables'] as $table) - { + if ($resqla && $resql) { + foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; $sql .= " WHERE fk_mode_reglement = ".$old_id; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); $error++; } print ". "; } - if (!$error) - { + if (!$error) { $db->commit(); } else { dol_print_error($db); @@ -3403,7 +3249,9 @@ function migrate_mode_reglement($db, $langs, $conf) } } - if ($count == 0) print $langs->trans('AlreadyDone')." \n"; + if ($count == 0) { + print $langs->trans('AlreadyDone')." \n"; + } print ' | ||||
| '.$langs->trans("MigrationCategorieAssociation").' | '; print ''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).') | |||
| '; print ''.$langs->trans('Upgrade').': '; print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated @@ -4557,13 +4350,11 @@ function migrate_reload_menu($db, $langs, $conf) // Define list of menu handlers to initialize $listofmenuhandler = array(); if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' - || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') - { + || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') { $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } - foreach ($listofmenuhandler as $key => $val) - { + foreach ($listofmenuhandler as $key => $val) { print ' | ||||
| ';
//print "x".$key;
@@ -4573,8 +4364,7 @@ function migrate_reload_menu($db, $langs, $conf)
// Load sql ini_menu_handler.sql file
$dir = DOL_DOCUMENT_ROOT."/core/menus/";
$file = 'init_menu_'.$key.'.sql';
- if (file_exists($dir.$file))
- {
+ if (file_exists($dir.$file)) {
$result = run_sql($dir.$file, 1, '', 1, $key);
}
@@ -4598,14 +4388,14 @@ function migrate_user_photospath()
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
+ if (!is_object($user)) {
+ $user = $fuser; // To avoid error during migration
+ }
$sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users
$resql = $db->query($sql);
- if ($resql)
- {
- while ($obj = $db->fetch_object($resql))
- {
+ if ($resql) {
+ while ($obj = $db->fetch_object($resql)) {
$fuser->fetch($obj->uid);
//echo ' '.$fuser->id.' -> '.$fuser->entity; $entity = (empty($fuser->entity) ? 1 : $fuser->entity); @@ -4615,8 +4405,7 @@ function migrate_user_photospath() $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module } - if ($dir) - { + if ($dir) { //print "Process user id ".$fuser->id." \n"; $origin = $dir.'/'.get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path $destin = $dir.'/'.$fuser->id; @@ -4626,26 +4415,23 @@ function migrate_user_photospath() dol_mkdir($destin); //echo ' '.$origin.' -> '.$destin; - if (dol_is_dir($origin)) - { + if (dol_is_dir($origin)) { $handle = opendir($origin_osencoded); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if ($file == '.' || $file == '..') continue; + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if ($file == '.' || $file == '..') { + continue; + } - if (dol_is_dir($origin.'/'.$file)) // it is a dir (like 'thumbs') - { + 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; + 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.' '."\n"; print '.'; @@ -4657,8 +4443,7 @@ function migrate_user_photospath() } } else // it is a file { - if (!dol_is_file($destin.'/'.$file)) - { + if (!dol_is_file($destin.'/'.$file)) { //print $origin.'/'.$file.' -> '.$destin.'/'.$file.' '."\n"; print '.'; dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0); | ||||