Rev 7787 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
/**
* User: Daschmi (https://daschmi.de)
* Date: 02.05.2018
* Time: 10:47
*/
?>
<script>
function wpsg_mod_orderupload_upload(product_index, product_id) {
var files = document.getElementById('wpsg_mod_orderupload_' + product_index + '_file').files;
var formData = new FormData();
for (var i = 0; i < files.length; i++) {
var file = files[i];
formData.append('file[]', file, file.name);
}
formData.append('product_index', product_index);
formData.append('product_id', product_id);
formData.append('order_id', '<?php echo $_SESSION['wpsg']['order_id']; ?>');
formData.append('action', 'wpsg_mod_orderupload_upload');
var xhr = new XMLHttpRequest();
xhr.open('POST', wpsg_ajax.ajaxurl, true);
jQuery('#wpsg_mod_orderupload_' + product_index + '_target').html('<?php echo __('Bitte warten ', 'wpsg'); ?><img src="' + wpsg_ajax.img_ajaxloading + '" alt="' + wpsg_ajax.label_pleasewait + '" /></div>');
xhr.onload = function () {
if (xhr.status === 200) {
jQuery('#wpsg_mod_orderupload_' + product_index + '_target').html(xhr.responseText);
} else {
alert("<?php echo __('Fehler', 'wpsg'); ?>: " + xhr.responseText);
}
};
xhr.send(formData);
return false;
}
function wpsg_mod_orderupload_removefile(file, product_index, product_id) {
jQuery('#wpsg_mod_orderupload_' + product_index + '_target').html('<?php echo __('Bitte warten ', 'wpsg'); ?><img src="' + wpsg_ajax.img_ajaxloading + '" alt="' + wpsg_ajax.label_pleasewait + '" /></div>');
jQuery.ajax( {
url: wpsg_ajax.ajaxurl,
data: {
action: 'wpsg_mod_orderupload_delete',
order_id: '<?php echo $_SESSION['wpsg']['order_id'] ?>',
product_index: product_index,
product_id: product_id,
file: file
},
success: function(data) {
jQuery('#wpsg_mod_orderupload_' + product_index + '_target').html(data);
}
} );
return false;
} // wpsg_mod_orderupload_removefile(aElement)
</script>