MS_View_Billing_Link

Render Link-Transaction View.

Defined (1)

The class is defined in the following location(s).

/app/view/billing/class-ms-view-billing-link.php  
  1. class MS_View_Billing_Link extends MS_View { 
  2.  
  3. /** 
  4. * Create view output. 
  5. * @since 1.0.1.0 
  6. * @return string 
  7. */ 
  8. public function to_html() { 
  9. $groups = $this->prepare_fields(); 
  10.  
  11. ob_start(); 
  12. // Render tabbed interface. 
  13. ?> 
  14. <div> 
  15. <div class="wpmui-grid-8 ms-transaction-window"> 
  16. <div class="the-details col-3"> 
  17. <?php 
  18. foreach ( $groups['info'] as $field ) { 
  19. MS_Helper_Html::html_element( $field ); 
  20. unset( $groups['info'] ); 
  21. ?> 
  22. </div> 
  23. <div class="the-form col-5"> 
  24. <?php foreach ( $groups as $key => $fields ) : ?> 
  25. <div class="link-block link-<?php echo esc_attr( $key . ' ' . $key ); ?>"> 
  26. <?php 
  27. foreach ( $fields as $field ) { 
  28. MS_Helper_Html::html_element( $field ); 
  29. ?> 
  30. </div> 
  31. <?php endforeach; ?> 
  32. </div> 
  33. </div> 
  34. </div> 
  35. <?php 
  36. $html = ob_get_clean(); 
  37.  
  38. return apply_filters( 'ms_view_billing_link_to_html', $html, $this ); 
  39.  
  40. /** 
  41. * Prepare html fields. 
  42. * @since 1.0.1.0 
  43. * @return array 
  44. */ 
  45. function prepare_fields() { 
  46. $member = $this->data['member']; 
  47. $userlist = MS_Model_Member::get_usernames( null, MS_Model_Member::SEARCH_ALL_USERS ); 
  48. $log = $this->data['log']; 
  49. $data_action = MS_Controller_Billing::AJAX_ACTION_TRANSACTION_LINK_DATA; 
  50. $update_action = MS_Controller_Billing::AJAX_ACTION_TRANSACTION_UPDATE; 
  51. $fields = array(); 
  52.  
  53. $member_id = 0; 
  54. if ( $member && $member->id ) { 
  55. $member_id = $member->id; 
  56.  
  57. $fields['info'] = array( 
  58. 'id' => array( 
  59. 'type' => MS_Helper_Html::TYPE_HTML_TEXT,  
  60. 'title' => __( 'Transaction ID', 'membership2' ),  
  61. 'value' => $log->id,  
  62. ),  
  63. 'gateway' => array( 
  64. 'type' => MS_Helper_Html::TYPE_HTML_TEXT,  
  65. 'title' => __( 'Payment Gateway', 'membership2' ),  
  66. 'value' => MS_Model_Gateway::get_name( $log->gateway_id, true ),  
  67. ),  
  68. 'amount' => array( 
  69. 'type' => MS_Helper_Html::TYPE_HTML_TEXT,  
  70. 'title' => __( 'Transaction Amount', 'membership2' ),  
  71. 'value' => MS_Helper_Billing::format_price( $log->amount ),  
  72. ),  
  73. 'details' => array( 
  74. 'type' => MS_Helper_Html::TYPE_HTML_TEXT,  
  75. 'title' => __( 'Transaction Details', 'membership2' ),  
  76. 'value' => $log->description,  
  77. ),  
  78. 'sep' => array( 
  79. 'type' => MS_Helper_Html::TYPE_HTML_SEPARATOR,  
  80. 'value' => 'vertical',  
  81. ),  
  82. ); 
  83.  
  84. $fields['member'] = array( 
  85. 'user_id' => array( 
  86. 'id' => 'user_id',  
  87. 'title' => __( '1. Payment by user', 'membership2' ),  
  88. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  89. 'value' => $member_id,  
  90. 'field_options' => $userlist,  
  91. ); 
  92.  
  93. $fields['subscription'] = array( 
  94. 'subscription_id' => array( 
  95. 'id' => 'subscription_id',  
  96. 'title' => __( '2. Payment for subscription', 'membership2' ),  
  97. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  98. 'value' => 0,  
  99. 'field_options' => array(),  
  100. ); 
  101.  
  102. $fields['invoice'] = array( 
  103. 'invoice_id' => array( 
  104. 'id' => 'invoice_id',  
  105. 'title' => __( '3. Link payment with invoice', 'membership2' ),  
  106. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  107. 'value' => 0,  
  108. 'field_options' => array(),  
  109. 'after' => __( 'The selected Invoice will be marked as "paid"', 'membership2' ),  
  110. ); 
  111.  
  112. $fields['buttons'] = array( 
  113. 'nonce_link_data' => array( 
  114. 'id' => 'nonce_link_data',  
  115. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  116. 'value' => wp_create_nonce( $data_action ),  
  117. ),  
  118. 'nonce_update' => array( 
  119. 'id' => 'nonce_update',  
  120. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  121. 'value' => wp_create_nonce( $update_action ),  
  122. ),  
  123. 'log_id' => array( 
  124. 'id' => 'log_id',  
  125. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  126. 'value' => $log->id,  
  127. ),  
  128. 'cancel' => array( 
  129. 'id' => 'cancel',  
  130. 'type' => MS_Helper_Html::INPUT_TYPE_BUTTON,  
  131. 'value' => __( 'Cancel', 'membership2' ),  
  132. 'class' => 'wpmui-field-button button close',  
  133. ),  
  134. 'submit' => array( 
  135. 'id' => 'submit',  
  136. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  137. 'value' => __( 'Save Transaction', 'membership2' ),  
  138. ),  
  139. ); 
  140.  
  141. return apply_filters( 
  142. 'ms_view_billing_link_prepare_fields',  
  143. $fields,  
  144. $this 
  145. );