/app/view/member/class-ms-view-member-subscription.php

  1. <?php 
  2.  
  3. /** 
  4. * Dialog: Member Subscription Infos 
  5. * 
  6. * Extends MS_View for rendering methods and magic methods. 
  7. * 
  8. * @since 1.0.0 
  9. * @package Membership2 
  10. * @subpackage View 
  11. */ 
  12. class MS_View_Member_Subscription extends MS_Dialog { 
  13.  
  14. /** 
  15. * Generate/Prepare the dialog attributes. 
  16. * 
  17. * @since 1.0.0 
  18. */ 
  19. public function prepare() { 
  20. $subscription_id = $_POST['subscription_id']; 
  21. $subscription = MS_Factory::load( 'MS_Model_Relationship', $subscription_id ); 
  22.  
  23. if ( ! empty( $_REQUEST['statuscheck'] ) ) { 
  24. $subscription->check_membership_status(); 
  25.  
  26. $data = array( 
  27. 'model' => $subscription,  
  28. ); 
  29.  
  30. $data = apply_filters( 'ms_view_member_subscription_data', $data ); 
  31.  
  32. // Dialog Title 
  33. $this->title = sprintf( 
  34. __( 'Subscription Details: %1$s', 'membership2' ),  
  35. esc_html( $subscription->get_membership()->name ) 
  36. ); 
  37.  
  38. // Dialog Size 
  39. $this->width = 940; 
  40. $this->height = 800; 
  41.  
  42. // Contents 
  43. $this->content = $this->get_contents( $data ); 
  44.  
  45. // Make the dialog modal 
  46. $this->modal = true; 
  47.  
  48. /** 
  49. * Save the dialog details. 
  50. * 
  51. * @since 1.0.0 
  52. * @return string 
  53. */ 
  54. public function submit() { 
  55. // Does nothing... 
  56.  
  57. /** 
  58. * Returns the contens of the dialog 
  59. * 
  60. * @since 1.0.0 
  61. * 
  62. * @return object 
  63. */ 
  64. public function get_contents( $data ) { 
  65. $subscription = $data['model']; 
  66. $gateways = MS_Model_Gateway::get_gateway_names( false, true ); 
  67.  
  68. if ( isset( $gateways[ $subscription->gateway_id ] ) ) { 
  69. $gateway = $gateways[ $subscription->gateway_id ]; 
  70. } elseif ( empty( $subscription->gateway_id ) ) { 
  71. $gateway = __( '- No Gateway -', 'membership2' ); 
  72. } else { 
  73. $gateway = '(' . $subscription->gateway_id . ')'; 
  74.  
  75. $events = MS_Model_Event::get_events( 
  76. array( 
  77. 'topic' => 'membership',  
  78. 'nopaging' => true,  
  79. 'relationship_id' => $subscription->id,  
  80. ); 
  81.  
  82. $sub_details = array( 
  83. 'title' => __( 'Subscription Details', 'membership2' ),  
  84. 'type' => MS_Helper_Html::TYPE_HTML_TABLE,  
  85. 'value' => array( 
  86. array( 'Subscription ID', $subscription->id ),  
  87. array( 'Membership', $subscription->get_membership()->name ),  
  88. array( 'Payment Gateway', $gateway ),  
  89. array( 'Payment Type', $subscription->get_payment_description( null, true ) ),  
  90. array( 'Subscription Start', $subscription->start_date ),  
  91. array( 'Subscription End', $subscription->expire_date ),  
  92. array( 'Status', $subscription->status ),  
  93. ),  
  94. 'field_options' => array( 
  95. 'head_col' => true,  
  96. ),  
  97. ); 
  98.  
  99. $evt_details = array(); 
  100.  
  101. foreach ( $events as $event ) { 
  102. $evt_details[] = array( 
  103. 'title' => __( 'Event Details', 'membership2' ),  
  104. 'type' => MS_Helper_Html::TYPE_HTML_TABLE,  
  105. 'value' => array( 
  106. array( 'Event ID', $event->id ),  
  107. array( 'Date', $event->date ),  
  108. array( 'Description', $event->description ),  
  109. ),  
  110. 'field_options' => array( 
  111. 'head_col' => true,  
  112. ),  
  113. ); 
  114.  
  115. ob_start(); 
  116. ?> 
  117. <div> 
  118. <?php 
  119. MS_Helper_Html::html_element( $sub_details ); 
  120.  
  121. MS_Helper_Html::html_separator(); 
  122.  
  123. foreach ( $evt_details as $detail ) { 
  124. MS_Helper_Html::html_element( $detail ); 
  125. ?> 
  126. </div> 
  127. <?php 
  128. $html = ob_get_clean(); 
  129. return apply_filters( 'ms_view_member_subscription_to_html', $html ); 
  130.  
  131. }; 
.