Aggiunti esempio csv anagrafiche per modulo import

This commit is contained in:
Luca 2018-05-23 11:54:49 +02:00
parent eb65c39fa8
commit dc5ea2dfe9
2 changed files with 51 additions and 1 deletions

View File

@ -3,7 +3,28 @@
include_once __DIR__.'/../../core.php';
switch (post('op')) {
case 'import':
case 'example':
$module = filter('module');
$list = array (
array('Codice','Ragione sociale','Partita IVA','Nazione','Indirizzo','CAP','Città','Provincia','Telefono','Fax','Cellulare','Email','IBAN','Note','Tipologia'),
array('00001','Cliente','12345678910','ITALIA','Via Giuseppe Mazzini, 123','12345','Este','PD','786 543 21','123 456 78','321 123 456 78','email@cliente.it','IT60 X054 2811 1010 0000 0123 456','Anagrafica di esempio','Cliente'),
);
$fp = fopen('../../files/'.$module.'/'.$module.'.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields, ';');
}
fclose($fp);
exit;
break;
case 'import':
foreach ($data as $key => $value) {
if (!empty($value)) {

View File

@ -28,7 +28,36 @@ foreach ($imports as $key => $value) {
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button id="example" type="button" class="btn btn-info hide" ><i class="fa fa-file"></i> <?php echo tr('Scarica esempio CSV'); ?></button>
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
</div>
</div>
</form>
<script>
$('#id_record').change( function(){
if ($(this).val()>0){
$( "#example" ).removeClass('hide');
}else{
$( "#example" ).addClass('hide');
}
});
$( "#example" ).click(function(event) {
var module = $('#id_record').find(':selected').data('text').toLowerCase();
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').hide();
return false;
}
});
});
</script>