mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix avoid to run import twice by clicking on tab step6
Fix timeout for real import step
This commit is contained in:
parent
4a2f26415e
commit
ac83cea83a
|
|
@ -43,7 +43,11 @@ function import_prepare_head($param, $maxstep = 0)
|
|||
$i = 1;
|
||||
while ($i <= $maxstep)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step='.$i.$param;
|
||||
if ($i < 6) {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step='.$i.$param;
|
||||
} else {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=5'.$param; // For step6, link is to step 5
|
||||
}
|
||||
$head[$h][1] = $langs->trans("Step")." ".$i;
|
||||
$head[$h][2] = 'step'.$i;
|
||||
$h++;
|
||||
|
|
|
|||
|
|
@ -618,6 +618,7 @@ class ImportCsv extends ModeleImports
|
|||
if (!empty($objimport->array_import_regex[0][$val]) && ($newval != ''))
|
||||
{
|
||||
// If test is "Must exist in a field@table or field@table:..."
|
||||
$reg = array();
|
||||
if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg))
|
||||
{
|
||||
$field = $reg[1];
|
||||
|
|
@ -844,7 +845,7 @@ class ImportCsv extends ModeleImports
|
|||
$sqlend .= ', '.$user->id;
|
||||
}
|
||||
$sql = $sqlstart.$sqlend.')';
|
||||
dol_syslog("import_csv.modules", LOG_DEBUG);
|
||||
//dol_syslog("import_csv.modules", LOG_DEBUG);
|
||||
|
||||
// Run insert request
|
||||
if ($sql)
|
||||
|
|
|
|||
|
|
@ -636,6 +636,7 @@ class ImportXlsx extends ModeleImports
|
|||
// Test regexp
|
||||
if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) {
|
||||
// If test is "Must exist in a field@table or field@table:..."
|
||||
$reg = array();
|
||||
if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) {
|
||||
$field = $reg[1];
|
||||
$table = $reg[2];
|
||||
|
|
@ -845,7 +846,7 @@ class ImportXlsx extends ModeleImports
|
|||
$sqlend .= ', ' . $user->id;
|
||||
}
|
||||
$sql = $sqlstart . $sqlend . ')';
|
||||
dol_syslog("import_xlsx.modules", LOG_DEBUG);
|
||||
//dol_syslog("import_xlsx.modules", LOG_DEBUG);
|
||||
|
||||
// Run insert request
|
||||
if ($sql) {
|
||||
|
|
|
|||
|
|
@ -1255,6 +1255,14 @@ if ($step == 4 && $datatoimport)
|
|||
// STEP 5: Summary of choices and launch simulation
|
||||
if ($step == 5 && $datatoimport)
|
||||
{
|
||||
$max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME); // 5mn if not defined
|
||||
$max_time = @ini_get("max_execution_time");
|
||||
if ($max_time && $max_time < $max_execution_time_for_importexport)
|
||||
{
|
||||
dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically.");
|
||||
@ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300
|
||||
}
|
||||
|
||||
$model = $format;
|
||||
$liste = $objmodelimport->liste_modeles($db);
|
||||
|
||||
|
|
@ -1518,14 +1526,6 @@ if ($step == 5 && $datatoimport)
|
|||
}
|
||||
print '</div>';
|
||||
} else {
|
||||
$max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME); // 5mn if not defined
|
||||
$max_time = @ini_get("max_execution_time");
|
||||
if ($max_time && $max_time < $max_execution_time_for_importexport)
|
||||
{
|
||||
dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically.");
|
||||
@ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300
|
||||
}
|
||||
|
||||
// Launch import
|
||||
$arrayoferrors = array();
|
||||
$arrayofwarnings = array();
|
||||
|
|
@ -1603,8 +1603,10 @@ if ($step == 5 && $datatoimport)
|
|||
// Show OK
|
||||
if (!count($arrayoferrors) && !count($arrayofwarnings)) {
|
||||
print '<div class="center">'.img_picto($langs->trans("OK"), 'tick').' <b>'.$langs->trans("NoError").'</b></div><br><br>';
|
||||
print '<div class="ok">';
|
||||
print $langs->trans("NbInsert", $obj->nbinsert).'<br>';
|
||||
print $langs->trans("NbUpdate", $obj->nbupdate).'<br><br>';
|
||||
print '</div>';
|
||||
} else print $langs->trans("NbOfLinesOK", $nbok).'<br><br>';
|
||||
|
||||
// Show Errors
|
||||
|
|
@ -1692,9 +1694,17 @@ if ($step == 5 && $datatoimport)
|
|||
// STEP 6: Real import
|
||||
if ($step == 6 && $datatoimport)
|
||||
{
|
||||
$max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME); // 5mn if not defined
|
||||
$max_time = @ini_get("max_execution_time");
|
||||
if ($max_time && $max_time < $max_execution_time_for_importexport)
|
||||
{
|
||||
dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically.");
|
||||
@ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300
|
||||
}
|
||||
|
||||
$model = $format;
|
||||
$liste = $objmodelimport->liste_modeles($db);
|
||||
$importid = $_REQUEST["importid"];
|
||||
$importid = GETPOST("importid", 'alphanohtml');
|
||||
|
||||
|
||||
// Create classe to use for import
|
||||
|
|
@ -1970,12 +1980,14 @@ if ($step == 6 && $datatoimport)
|
|||
|
||||
// Show result
|
||||
print '<br>';
|
||||
print '<div class="center">';
|
||||
print '<div class="ok">';
|
||||
print $langs->trans("NbOfLinesImported", $nbok).'</b><br>';
|
||||
print $langs->trans("NbInsert", $obj->nbinsert).'<br>';
|
||||
print $langs->trans("NbUpdate", $obj->nbupdate).'<br><br>';
|
||||
print '</div>';
|
||||
print '<div class="center">';
|
||||
print $langs->trans("FileWasImported", $importid).'<br>';
|
||||
print $langs->trans("YouCanUseImportIdToFindRecord", $importid).'<br>';
|
||||
print '<span class="opacitymedium">'.$langs->trans("YouCanUseImportIdToFindRecord", $importid).'</span><br>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user