('.datetime').datetimepicker({ language: 'en-gb', pickDate: true, pickTime: true }); $('.time').datetimepicker({ language: 'en-gb', pickDate: false }); $('button[id^=\'button-upload\']').on('click', function() { var node = this; $('#form-upload').remove(); $('body').prepend(''); $('#form-upload input[name=\'file\']').trigger('click'); if (typeof timer != 'undefined') { clearInterval(timer); } timer = setInterval(function() { if ($('#form-upload input[name=\'file\']').val() != '') { clearInterval(timer); $.ajax({ url: 'index.php?route=tool/upload', type: 'post', dataType: 'json', data: new FormData($('#form-upload')[0]), cache: false, contentType: false, processData: false, beforeSend: function() { $(node).button('loading'); }, complete: function() { $(node).button('reset'); }, success: function(json) { $('.text-danger').remove(); if (json['error']) { $(node).parent().find('input').after('
' + json['error'] + '
'); } if (json['success']) { alert(json['success']); $(node).parent().find('input').val(json['code']); } }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } }, 500); }); //-->