MS_View_Member_Subscription

Dialog: Member Subscription Infos.

Defined (1)

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

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