paypal_payout.html.twig 5.6 KB

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