paypal_payout.tpl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <div class="table-responsive">
  2. <table class="table table-striped table-hover">
  3. <thead>
  4. <tr>
  5. <th class="text-center"><input type="checkbox" id="checkAll"></th>
  6. <th class="text-center">{{ 'OrderReference'| get_plugin_lang('BuyCoursesPlugin') }}</th>
  7. <th class="text-center">{{ 'OrderDate'| get_plugin_lang('BuyCoursesPlugin') }}</th>
  8. <th class="text-right">{{ 'Commission'| get_plugin_lang('BuyCoursesPlugin') }}</th>
  9. <th class="text-right">{{ 'PayPalAccount'| get_plugin_lang('BuyCoursesPlugin') }}</th>
  10. <th class="text-right">{{ 'Options'| get_lang }}</th>
  11. </tr>
  12. </thead>
  13. <tbody>
  14. {% for payout in payout_list %}
  15. <tr style="{{ payout.paypal_account ? '' : 'color: red;' }}">
  16. <td class="text-center" style="vertical-align:middle">{% if payout.paypal_account %} <input id="{{ payout.id }}" type="checkbox" name="data[]" value="{{ payout.commission }}"> {% endif %}</td>
  17. <td class="text-center" style="vertical-align:middle">{{ payout.reference }}</td>
  18. <td class="text-center" style="vertical-align:middle">{{ payout.date }}</td>
  19. <td class="text-right" style="vertical-align:middle">{{ payout.currency ~ ' ' ~ payout.commission }}</td>
  20. {% if payout.paypal_account %}
  21. <td class="text-right" style="vertical-align:middle">{{ payout.paypal_account }}</td>
  22. {% else %}
  23. <td class="text-right" style="vertical-align:middle">{{ 'NoPayPalAccountDetected'| get_plugin_lang('BuyCoursesPlugin') }}</td>
  24. {% endif %}
  25. <td class="text-right" style="vertical-align:middle"><button id="{{ payout.id }}" type="button" class="btn btn-danger fa fa-ban cancelPayout"> {{ 'CancelPayout'| get_plugin_lang('BuyCoursesPlugin') }}</button></td>
  26. </tr>
  27. {% endfor %}
  28. </tbody>
  29. </table>
  30. <div id="startPayout" class="modal fade" role="dialog">
  31. <div class="modal-dialog modal-lg">
  32. <div class="modal-content">
  33. <div class="modal-header">
  34. <h4 class="modal-title">{{ 'PaypalPayoutCommissions'|get_plugin_lang('BuyCoursesPlugin') }}</h4>
  35. </div>
  36. <div class="modal-body" id="content">
  37. </div>
  38. <div class="modal-footer">
  39. <button id="proceedPayout" type="button" class="btn btn-success fa fa-paypal"> {{ 'ProceedPayout' | get_plugin_lang('BuyCoursesPlugin') }}</button>
  40. <button id="cancelPayout" type="button" class="btn btn-danger" data-dismiss="modal">{{ 'Cancel' | get_lang }}</button>
  41. <button id="responseButton" type="button" class="btn btn-primary">{{ 'Confirm' | get_lang }}</button>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div>
  48. <button id="continuePayout" type="button" class="btn btn-primary fa fa-caret-square-o-right" data-toggle="modal" data-target="#startPayout" data-backdrop="static" data-keyboard="false"> {{ 'ContinuePayout'|get_plugin_lang('BuyCoursesPlugin') }}</button>
  49. </div>
  50. <script>
  51. $(document).ready(function() {
  52. $("#responseButton").hide();
  53. $("#checkAll").click(function() {
  54. $(':checkbox').prop('checked', this.checked);
  55. });
  56. $('#continuePayout').click(function() {
  57. var val = [];
  58. $(':checkbox:checked').not('#checkAll').each(function(i) {
  59. val[i] = $(this).attr("id");
  60. });
  61. $.ajax({
  62. data: { payouts : val },
  63. url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'processPayout' } | url_encode() }}',
  64. type: 'POST',
  65. success: function(response) {
  66. $("#content").html(response);
  67. (jQuery.isEmptyObject(val)) ? $('#proceedPayout').prop( "disabled", true ) : $('#proceedPayout').prop( "disabled", false );
  68. }
  69. });
  70. });
  71. $('#proceedPayout').click(function() {
  72. var val = [];
  73. $(':checkbox:checked').not('#checkAll').each(function(i) {
  74. val[i] = $(this).attr("id");
  75. });
  76. $.ajax({
  77. data: { payouts : val },
  78. url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'proceedPayout' } | url_encode() }}',
  79. type: 'POST',
  80. beforeSend: function() {
  81. $("#proceedPayout").hide();
  82. $("#cancelPayout").hide();
  83. $("#spinner").html('<br /><br /><div class="wobblebar-loader"></div><p> {{ 'ProcessingPayoutsDontCloseThisWindow' | get_plugin_lang('BuyCoursesPlugin') }} </p>');
  84. },
  85. success: function(response) {
  86. $("#content").html(response);
  87. $("#responseButton").show();
  88. }
  89. });
  90. });
  91. $(".cancelPayout").click(function() {
  92. var id = this.id;
  93. $.ajax({
  94. data: 'id='+id,
  95. url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'cancelPayout' } | url_encode() }}',
  96. type: 'POST',
  97. success: function() {
  98. window.location.reload();
  99. }
  100. });
  101. });
  102. $('#responseButton').click(function() {
  103. window.location.reload();
  104. });
  105. });
  106. </script>