7002 |
daniel |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
7787 |
daniel |
4 |
* User: Daschmi (https://daschmi.de)
|
7002 |
daniel |
5 |
* Date: 02.05.2018
|
|
|
6 |
* Time: 10:47
|
|
|
7 |
*/
|
|
|
8 |
|
|
|
9 |
?>
|
|
|
10 |
|
|
|
11 |
<script>
|
|
|
12 |
|
|
|
13 |
function wpsg_mod_orderupload_upload(product_index, product_id) {
|
8295 |
karl |
14 |
|
7002 |
daniel |
15 |
var files = document.getElementById('wpsg_mod_orderupload_' + product_index + '_file').files;
|
|
|
16 |
var formData = new FormData();
|
|
|
17 |
|
|
|
18 |
for (var i = 0; i < files.length; i++) {
|
|
|
19 |
|
|
|
20 |
var file = files[i];
|
|
|
21 |
|
|
|
22 |
formData.append('file[]', file, file.name);
|
|
|
23 |
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
formData.append('product_index', product_index);
|
|
|
27 |
formData.append('product_id', product_id);
|
|
|
28 |
formData.append('order_id', '<?php echo $_SESSION['wpsg']['order_id']; ?>');
|
|
|
29 |
formData.append('action', 'wpsg_mod_orderupload_upload');
|
|
|
30 |
|
|
|
31 |
var xhr = new XMLHttpRequest();
|
|
|
32 |
|
|
|
33 |
xhr.open('POST', wpsg_ajax.ajaxurl, true);
|
|
|
34 |
|
|
|
35 |
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>');
|
|
|
36 |
|
|
|
37 |
xhr.onload = function () {
|
|
|
38 |
|
|
|
39 |
if (xhr.status === 200) {
|
|
|
40 |
|
|
|
41 |
jQuery('#wpsg_mod_orderupload_' + product_index + '_target').html(xhr.responseText);
|
|
|
42 |
|
|
|
43 |
} else {
|
|
|
44 |
|
|
|
45 |
alert("<?php echo __('Fehler', 'wpsg'); ?>: " + xhr.responseText);
|
|
|
46 |
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
};
|
|
|
50 |
|
|
|
51 |
xhr.send(formData);
|
|
|
52 |
|
|
|
53 |
return false;
|
|
|
54 |
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
function wpsg_mod_orderupload_removefile(file, product_index, product_id) {
|
|
|
58 |
|
|
|
59 |
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>');
|
|
|
60 |
|
|
|
61 |
jQuery.ajax( {
|
|
|
62 |
url: wpsg_ajax.ajaxurl,
|
|
|
63 |
data: {
|
|
|
64 |
action: 'wpsg_mod_orderupload_delete',
|
8295 |
karl |
65 |
order_id: '<?php echo $_SESSION['wpsg']['order_id'] ?>',
|
7002 |
daniel |
66 |
product_index: product_index,
|
|
|
67 |
product_id: product_id,
|
|
|
68 |
file: file
|
|
|
69 |
},
|
|
|
70 |
success: function(data) {
|
|
|
71 |
|
|
|
72 |
jQuery('#wpsg_mod_orderupload_' + product_index + '_target').html(data);
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
} );
|
|
|
76 |
|
|
|
77 |
return false;
|
|
|
78 |
|
|
|
79 |
} // wpsg_mod_orderupload_removefile(aElement)
|
|
|
80 |
|
|
|
81 |
</script>
|