| @@ -12,8 +12,12 @@ | |||||
| jQuery.noConflict(); | jQuery.noConflict(); | ||||
| </script> | </script> | ||||
| <style> | |||||
| #xls-message {font-weight: bold;padding: 10px 0;} | |||||
| .tl_submit {height: 40px;} | |||||
| </style> | |||||
| <div class="tl_listing_container list_view"> | <div class="tl_listing_container list_view"> | ||||
| <div id="xls-message"></div> | |||||
| <div><p id="xls-message"></p></div> | |||||
| <form id="xls-import" method="post" action="{{ path('import_xls') }}" enctype="multipart/form-data"> | <form id="xls-import" method="post" action="{{ path('import_xls') }}" enctype="multipart/form-data"> | ||||
| <input type="hidden" name="REQUEST_TOKEN" value="{{ token }}"/> | <input type="hidden" name="REQUEST_TOKEN" value="{{ token }}"/> | ||||
| <table class="tl_listing"> | <table class="tl_listing"> | ||||
| @@ -23,13 +27,13 @@ | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td class="tl_file_list"> | <td class="tl_file_list"> | ||||
| <label for="result-xls">Excel-Datei:</label> | |||||
| <p><label for="result-xls">Excel-Datei:</label></p> | |||||
| </td> | </td> | ||||
| <td class="tl_file_list"> | <td class="tl_file_list"> | ||||
| <input id="xls" type="file" name="xls" accept=".xls,.xlsx,.XLS,.XLSX" class="tl_submit" required> | |||||
| <p><input id="xls" type="file" name="xls" accept=".xls,.xlsx,.XLS,.XLSX" class="tl_submit" required></p> | |||||
| </td> | </td> | ||||
| <td class="tl_file_list" colspan="2"> | <td class="tl_file_list" colspan="2"> | ||||
| <input type="submit" value="Datei importieren" class="tl_submit"> | |||||
| <p><input type="submit" value="Datei importieren" class="tl_submit"></p> | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| </tbody> | </tbody> | ||||
| @@ -41,23 +45,26 @@ | |||||
| <script> | <script> | ||||
| jQuery("#xls-import").on("submit", function(e) { | jQuery("#xls-import").on("submit", function(e) { | ||||
| e.preventDefault(); | e.preventDefault(); | ||||
| let form = jQuery(this)[0]; // You need to use standard javascript object here | |||||
| let formData = new FormData(form); | |||||
| jQuery("#xls-message").html(""); | |||||
| jQuery.ajax({ | |||||
| url: "{{ path('import_xls') }}", | |||||
| method: "post", | |||||
| data: formData, | |||||
| processData: false, | |||||
| contentType: false, | |||||
| success: function(data) { | |||||
| jQuery("#xls-message").html("Excel-Datei wurde erfolgreich importiert!"); | |||||
| }, | |||||
| error: function(requestObject, error, errorThrown) { | |||||
| jQuery("#xls-message").html('Fehler:' + requestObject.responseText); | |||||
| }, | |||||
| dataType: "html" | |||||
| }); | |||||
| var confirmAction = confirm("Möchten Sie wirklich fortfahren?\nAlle Brands-Daten werden direkt überschrieben!"); | |||||
| if (confirmAction === true) { | |||||
| let form = jQuery(this)[0]; // You need to use standard javascript object here | |||||
| let formData = new FormData(form); | |||||
| jQuery("#xls-message").html(""); | |||||
| jQuery.ajax({ | |||||
| url: "{{ path('import_xls') }}", | |||||
| method: "post", | |||||
| data: formData, | |||||
| processData: false, | |||||
| contentType: false, | |||||
| success: function (data) { | |||||
| jQuery("#xls-message").html("Excel-Datei wurde erfolgreich importiert!"); | |||||
| }, | |||||
| error: function (requestObject, error, errorThrown) { | |||||
| jQuery("#xls-message").html('Fehler:' + requestObject.responseText); | |||||
| }, | |||||
| dataType: "html" | |||||
| }); | |||||
| } | |||||
| }); | }); | ||||
| </script> | </script> | ||||