2018-02-23 19:04:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
$list = [];
|
|
|
|
foreach ($imports as $key => $value) {
|
|
|
|
$list[] = [
|
|
|
|
'id' => $key,
|
|
|
|
'text' => $value['title'],
|
2018-12-12 10:10:07 +01:00
|
|
|
'directory' => $value['directory'],
|
2018-02-23 19:04:05 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Utilizzo le funzionalità di filelist_and_upload
|
|
|
|
?><form action="" method="post" id="add-form" enctype="multipart/form-data">
|
|
|
|
<input type="hidden" name="op" value="link_file">
|
|
|
|
<input type="hidden" name="backto" value="record-edit">
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
2019-03-01 15:52:30 +01:00
|
|
|
{[ "type": "file", "label": "<?php echo tr('File'); ?>", "name": "blob", "required": 1, "extra": "accept=\".csv\"" ]}
|
2018-02-23 19:04:05 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-6">
|
2018-02-26 18:06:52 +01:00
|
|
|
{[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "id_record", "required": 1, "values": <?php echo json_encode($list); ?> ]}
|
2018-02-23 19:04:05 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- PULSANTI -->
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12 text-right">
|
2018-05-23 11:54:49 +02:00
|
|
|
<button id="example" type="button" class="btn btn-info hide" ><i class="fa fa-file"></i> <?php echo tr('Scarica esempio CSV'); ?></button>
|
2018-02-23 19:04:05 +01:00
|
|
|
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2018-05-23 11:54:49 +02:00
|
|
|
|
|
|
|
<script>
|
2018-11-09 11:34:27 +01:00
|
|
|
$('#id_record').change( function(){
|
2018-05-23 11:54:49 +02:00
|
|
|
if ($(this).val()>0){
|
2018-11-09 11:34:27 +01:00
|
|
|
$( "#example" ).removeClass('hide');
|
2018-05-23 11:54:49 +02:00
|
|
|
}else{
|
2018-11-09 11:34:27 +01:00
|
|
|
$( "#example" ).addClass('hide');
|
2018-05-23 11:54:49 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-11-09 11:34:27 +01:00
|
|
|
$( "#example" ).click(function(event) {
|
2018-12-12 10:10:07 +01:00
|
|
|
var module = $('#id_record').find(':selected').data('directory').toLowerCase();
|
2018-09-19 09:51:36 +02:00
|
|
|
var dir = "<?php echo ROOTDIR; ?>/modules/"+module+"/import.php";
|
|
|
|
var file = "<?php echo ROOTDIR; ?>/files/"+module+"/"+module+".csv";
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: dir,
|
|
|
|
type: 'post',
|
|
|
|
data: {
|
|
|
|
op: 'example', module: module
|
|
|
|
},
|
|
|
|
success: function(data){
|
|
|
|
window.location = file;
|
|
|
|
$('#main_loading').fadeOut();
|
|
|
|
return false;
|
|
|
|
}
|
2018-05-23 11:54:49 +02:00
|
|
|
});
|
|
|
|
});
|
2018-09-19 09:51:36 +02:00
|
|
|
</script>
|