shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

squareup_recurring_buttons.twig (2973B)


      1 <div id="squareup_buttons" class="form-control-static buttons clearfix">
      2   {% if order_recurring_id %}
      3   <div class="pull-right">
      4     <button type="button" id="button-cancel" data-loading-text="{{ text_loading }}" class="btn btn-danger">{{ button_text }}</button>
      5   </div>
      6   {% endif %}
      7 </div>
      8 <script type="text/javascript"><!--
      9 $(document).ready(function() {
     10     var addOrderHistory = function(success_callback) {
     11         $.ajax({
     12             url: '{{ catalog }}index.php?route=api/order/history&api_token={{ api_token }}&order_id={{ order_id }}',
     13             type: 'post',
     14             dataType: 'json',
     15             data: 'order_status_id={{ order_status_id }}&notify={{ notify }}&override=0&append=0&comment=' + encodeURIComponent("{{ comment }}"),
     16             success: function(json) {
     17                 if (json['error']) {
     18                     $('#squareup_buttons').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
     19                 }
     20 
     21                 if (json['success']) {
     22                     success_callback();
     23                 }
     24             },
     25             error: function(xhr, ajaxOptions, thrownError) {
     26                 $('#squareup_buttons').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + thrownError + "<br />" + xhr.statusText + "<br />" + xhr.responseText + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
     27             }
     28         });
     29     }
     30 
     31     $(document).delegate('#button-cancel', 'click', function() {
     32         if (!confirm("{{ text_confirm_cancel }}")) {
     33             return false;
     34         }
     35 
     36         $.ajax({
     37             url: '{{ cancel }}',
     38             dataType: 'json',
     39             beforeSend: function() {
     40                 $('#button-cancel').button('loading');
     41             },
     42             success: function(json) {
     43                 $('.alert').remove();
     44                 
     45                 if (json['success']) {
     46                     addOrderHistory(function() {
     47                         $('#squareup_buttons').before('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
     48 
     49                         $('#button-cancel').hide();
     50                     });
     51                 }
     52                 
     53                 if (json['error']) {
     54                     $('#squareup_buttons').before('<div class="alert alert-danger">' + json['error'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
     55 
     56                     $('#button-cancel').button('reset');
     57                 }
     58             },
     59             error: function(xhr, ajaxOptions, thrownError) {
     60                 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
     61             }
     62         });
     63     });
     64 });
     65 //--></script>