Merge branch 'ent-12687-sistema-import-export-prd' of https://brutus.artica.es:8081/artica/pandorafms into ent-12687-sistema-import-export-prd
This commit is contained in:
commit
47c6b9c335
|
@ -149,13 +149,8 @@ html_print_table($table);
|
|||
Object.entries(value).forEach(([field, value2]) => {
|
||||
message += "with " + field + ": (";
|
||||
if (typeof value2 === 'object' && Object.keys(value2).length > 0) {
|
||||
let cont = 0;
|
||||
Object.entries(value2).forEach(([key3, value3]) => {
|
||||
message += value3 + " , ";
|
||||
if (cont === 6) {
|
||||
message += "<br>";
|
||||
}
|
||||
cont++;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -222,6 +217,7 @@ html_print_table($table);
|
|||
$.ajax({
|
||||
type: "GET",
|
||||
url: "ajax.php",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
page: 'include/ajax/resources.ajax',
|
||||
exportPrd: 1,
|
||||
|
@ -230,29 +226,34 @@ html_print_table($table);
|
|||
name: $("#select_value option:selected").text(),
|
||||
},
|
||||
success: function(data) {
|
||||
let a = document.createElement('a');
|
||||
const url = '<?php echo $config['homeurl'].'/attachment/'; ?>' + data;
|
||||
a.href = url;
|
||||
a.download = data;
|
||||
a.click();
|
||||
|
||||
setTimeout(() => {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "ajax.php",
|
||||
data: {
|
||||
page: 'include/ajax/resources.ajax',
|
||||
deleteFile: 1,
|
||||
filename: data,
|
||||
},
|
||||
});
|
||||
if (data.error === -1 || data.error === -2) {
|
||||
console.error("Failed to create file");
|
||||
$("#confirm_downloadDialog").dialog("close");
|
||||
}, 3000);
|
||||
} else {
|
||||
let a = document.createElement('a');
|
||||
const url = '<?php echo $config['homeurl'].'/attachment/'; ?>' + data.name;
|
||||
a.href = url;
|
||||
a.download = data.name_download;
|
||||
a.click();
|
||||
|
||||
setTimeout(() => {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "ajax.php",
|
||||
data: {
|
||||
page: 'include/ajax/resources.ajax',
|
||||
deleteFile: 1,
|
||||
filename: data,
|
||||
},
|
||||
});
|
||||
$("#confirm_downloadDialog").dialog("close");
|
||||
}, 3000);
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
console.error("Fatal error in AJAX call to interpreter order", data)
|
||||
console.error("Fatal error in AJAX call to interpreter order", data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -69,10 +69,11 @@ if ((bool) is_ajax() === true) {
|
|||
|
||||
$data = $prd->exportPrd($type, $value, $name);
|
||||
|
||||
$return = '';
|
||||
$return = [];
|
||||
|
||||
if (empty($data) === false) {
|
||||
$filename = $type.'-'.date('Ymd').'-'.date('His').'.prd';
|
||||
$filename = uniqid().'.prd';
|
||||
$filename_download = date('YmdHis').'-'.$type.'-'.$name.'.prd';
|
||||
$file = $config['attachment_store'].'/'.$filename;
|
||||
|
||||
$file_pointer = fopen($file, 'a');
|
||||
|
@ -80,18 +81,19 @@ if ((bool) is_ajax() === true) {
|
|||
$write = fwrite($file_pointer, $data);
|
||||
|
||||
if ($write === false) {
|
||||
$return = -2;
|
||||
$return['error'] = -2;
|
||||
} else {
|
||||
$return = $filename;
|
||||
$return['name'] = $filename;
|
||||
$return['name_download'] = $filename_download;
|
||||
}
|
||||
|
||||
fclose($file_pointer);
|
||||
} else {
|
||||
$return = -1;
|
||||
$return['error'] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
echo $return;
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue