FIX error message in xls import when stream zip is not availabe.

This commit is contained in:
Laurent Destailleur 2024-10-31 14:35:10 +01:00
parent 26e89a7760
commit d42465ff1f
3 changed files with 18 additions and 0 deletions

View File

@ -125,6 +125,13 @@ class ImportXlsx extends ModeleImports
$this->label_lib = 'PhpSpreadSheet';
$this->version_lib = '1.8.0';
$arrayofstreams = stream_get_wrappers();
if (!in_array('zip', $arrayofstreams)) {
$langs->load("errors");
$this->error = $langs->trans('ErrorStreamMustBeEnabled', 'zip');
return;
}
$this->datatoimport = $datatoimport;
if (preg_match('/^societe_/', $datatoimport)) {
$this->thirdpartyobject = new Societe($this->db);

View File

@ -783,6 +783,16 @@ if ($step == 4 && $datatoimport) {
$classname = "Import".ucfirst($model);
require_once $dir.$file;
$obj = new $classname($db, $datatoimport);
if (!empty($obj->error)) {
$langs->load("errors");
$param = '&datatoimport='.$datatoimport.'&format='.$format;
setEventMessages($obj->error, null, 'errors');
header("Location: ".$_SERVER["PHP_SELF"].'?step=3'.$param.'&filetoimport='.urlencode($relativepath));
exit;
}
if ($model == 'csv') {
$obj->separator = $separator_used;
$obj->enclosure = $enclosure;

View File

@ -342,6 +342,7 @@ ErrorEndHourIsNull=End date field cannot be empty
ErrorStartHourIsNull=Start date field cannot be empty
ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter=Too many lines to process. Please use a more selective filter.
ErrorEmptyValueForQty=Quantity cannot be zero.
ErrorStreamMustBeEnabled=The PHP stream %s is not available. Check your PHP modules and Dolibarr parameter $dolibarr_main_stream_to_disable.
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.