/**
     * Create view output.
     *
     * @since  1.0.1.0
     * @return string
     */
    public function to_html()
    {
        $this->check_simulation();
        // Setup navigation tabs.
        $tabs = $this->data['tabs'];
        $membership = $this->data['membership'];
        $desc = array();
        ob_start();
        // Render tabbed interface.
        ?>
		<div class="ms-wrap wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $membership->get_name_tag(), 'title_icon_class' => '', 'desc' => __('Edit Memberhip details and define Membership specific settings.', MS_TEXT_DOMAIN)));
        $active_tab = MS_Helper_Html::html_admin_vertical_tabs($tabs);
        // Call the appropriate form to render.
        $tab_name = str_replace('-', '_', $active_tab);
        $callback_name = 'render_tab_' . $tab_name;
        $render_callback = apply_filters('ms_view_membership_edit_render_callback', array($this, $callback_name), $active_tab, $this->data);
        ?>
			<div class="ms-settings ms-settings-<?php 
        echo esc_attr($tab_name);
        ?>
">
				<?php 
        $html = call_user_func($render_callback);
        $html = apply_filters('ms_view_settings_' . $callback_name, $html);
        echo $html;
        ?>
			</div>
		</div>
		<?php 
        $html = ob_get_clean();
        return $html;
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $this->check_simulation();
        $membership = $this->data['membership'];
        $admin_message = MS_Helper_Membership::get_admin_message(array($membership->name), $membership);
        $title = MS_Helper_Membership::get_admin_title();
        $membership_list = MS_Factory::create('MS_Helper_ListTable_Membership');
        $membership_list->prepare_items();
        $create_new_button = array('id' => 'create_new_ms_button', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => $this->data['create_new_url'], 'value' => __('Create New Membership', MS_TEXT_DOMAIN), 'class' => 'button');
        ob_start();
        ?>

		<div class="wrap ms-wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'desc' => array(__('Here you can view and edit all the Memberships you have created.', MS_TEXT_DOMAIN), $admin_message)));
        ?>
			<form action="" method="post">
				<div class="ms-list-table-wrapper ms-membership-list">
					<?php 
        MS_Helper_Html::html_element($create_new_button);
        $membership_list->display();
        MS_Helper_Html::html_element($create_new_button);
        ?>
				</div>
			</form>
		</div>

		<?php 
        $html = ob_get_clean();
        echo $html;
    }
Exemplo n.º 3
0
    /**
     * Create view output.
     *
     * @since  1.0.0
     *
     * @return string
     */
    public function to_html()
    {
        $this->check_simulation();
        $fields = $this->prepare_fields();
        $form_url = esc_url_raw(remove_query_arg(array('action', 'invoice_id')));
        if ($this->data['invoice']->is_valid()) {
            $title = __('Edit Billing', MS_TEXT_DOMAIN);
        } else {
            $title = __('Add Billing', MS_TEXT_DOMAIN);
        }
        ob_start();
        // Render tabbed interface.
        ?>
			<div class="ms-wrap ms-billing">
				<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'title_icon_class' => 'wpmui-fa wpmui-fa-pencil-square'));
        ?>
				<form action="<?php 
        echo $form_url;
        ?>
" method="post" class="ms-form">
					<?php 
        MS_Helper_Html::settings_box($fields, '', '', 'static', 'ms-small-form');
        ?>
				</form>
				<div class="clear"></div>
			</div>
		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_view_billing_edit_to_html', $html, $this);
    }
    public function to_html()
    {
        $this->check_simulation();
        // Search for orphaned relationships and delete them.
        MS_Model_Member::clean_db();
        $listview = MS_Factory::create('MS_Helper_ListTable_Member');
        $listview->prepare_items();
        ob_start();
        ?>

		<div class="wrap ms-wrap ms-member-list">
			<?php 
        MS_Helper_Html::settings_header(array('title' => __('Members', MS_TEXT_DOMAIN), 'title_icon_class' => 'wpmui-fa wpmui-fa-users', 'desc' => __('Here you can manage the Memberships of existing Users.', MS_TEXT_DOMAIN)));
        // Display a filter to switch between individual memberships.
        $this->membership_filter();
        $listview->views();
        $listview->search_box();
        ?>
			<form method="post">
				<?php 
        $listview->display();
        ?>
			</form>
		</div>

		<?php 
        $html = ob_get_clean();
        return $html;
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $list_table = MS_Factory::create('MS_Helper_ListTable_Event');
        $list_table->prepare_items();
        if (isset($_REQUEST['membership_id'])) {
            $membership = MS_Factory::load('MS_Model_Membership', $_REQUEST['membership_id']);
            $title = sprintf(__('%s News', 'membership2'), $membership->get_name_tag());
            $url = esc_url_raw(add_query_arg(array('step' => MS_Controller_Membership::STEP_OVERVIEW), remove_query_arg(array('paged', 'order', 'post_mime_type', 'detached', 'orderby', 's'))));
            $back_link = array('id' => 'back', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => __('&raquo; Back to Overview', 'membership2'), 'url' => $url, 'class' => 'wpmui-field-button button');
        } else {
            $title = __('Membership News', 'membership2');
            $back_link = '';
        }
        ob_start();
        ?>

		<div class="wrap ms-wrap ms-membership-news">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title));
        MS_Helper_Html::html_element($back_link);
        $list_table->search_box();
        $list_table->views();
        ?>
			<form action="" method="post">
				<?php 
        $list_table->display();
        ?>
			</form>
		</div>

		<?php 
        $html = ob_get_clean();
        echo '' . $html;
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     *
     * @return string
     */
    public function to_html()
    {
        $coupon_list = MS_Factory::create('MS_Addon_Coupon_Helper_Listtable');
        $coupon_list->prepare_items();
        $title = __('Coupons', MS_TEXT_DOMAIN);
        $add_new_button = array('id' => 'add_new', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('coupons', array('action' => 'edit', 'coupon_id' => 0)), 'value' => __('Add New Coupon', MS_TEXT_DOMAIN), 'class' => 'button');
        ob_start();
        ?>
		<div class="wrap ms-wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'title_icon_class' => 'wpmui-fa wpmui-fa-credit-card'));
        ?>
			<div>
				<?php 
        MS_Helper_Html::html_element($add_new_button);
        ?>
			</div>

			<form action="" method="post">
				<?php 
        $coupon_list->display();
        ?>
			</form>
		</div>

		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_addon_coupon_view_list_to_html', $html, $this);
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     *
     * @return string
     */
    public function to_html()
    {
        $code_list = MS_Factory::create('MS_Addon_Invitation_Helper_Listtable');
        $code_list->prepare_items();
        $title = __('Invitations', 'membership2');
        $add_new_button = array('id' => 'add_new', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url(MS_Addon_Invitation::SLUG, array('action' => 'edit', 'invitation_id' => 0)), 'value' => __('Add New Code', 'membership2'), 'class' => 'button');
        ob_start();
        ?>
		<div class="wrap ms-wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'title_icon_class' => 'wpmui-fa wpmui-fa-ticket'));
        ?>
			<div>
				<?php 
        MS_Helper_Html::html_element($add_new_button);
        ?>
			</div>

			<form action="" method="post">
				<?php 
        $code_list->display();
        ?>
			</form>
			<p><em>
				<?php 
        _e('By default all Memberships are protected and require an invitation code to register.<br>You can manually change this for individual memberships via a new setting in the "Payment Options" settings of each membership.', 'membership2');
        ?>
			</em></p>
		</div>

		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_addon_invitation_view_list_to_html', $html, $this);
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $fields = $this->prepare_fields();
        $cols = count($fields['type']['field_options']);
        if ($cols < 2) {
            $cols = 2;
        }
        if ($cols > 3) {
            $cols = 2;
        }
        ob_start();
        ?>
		<div class="ms-wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => __('Create New Membership', MS_TEXT_DOMAIN), 'desc' => __('First up, choose a name and a type for your membership site.', MS_TEXT_DOMAIN)));
        ?>
			<div class="ms-settings ms-membership-add ms-cols-<?php 
        echo esc_attr($cols);
        ?>
">
				<form method="post" id="ms-choose-type-form">
					<div class="ms-settings-row cf">
						<h3><?php 
        _e('Choose a membership type:', MS_TEXT_DOMAIN);
        ?>
</h3>
						<?php 
        MS_Helper_Html::html_element($fields['type']);
        ?>
					</div>
					<div class="ms-settings-row cf">
						<?php 
        MS_Helper_Html::html_element($fields['name']);
        ?>
					</div>
					<div class="ms-settings-row cf">
						<div class="ms-options-wrapper">
							<?php 
        foreach ($fields['config_fields'] as $field) {
            echo '<span class="opt">';
            MS_Helper_Html::html_element($field);
            echo '</span>';
        }
        ?>
						</div>
					</div>
					<div class="ms-control-fields-wrapper">
						<?php 
        foreach ($fields['control_fields'] as $field) {
            MS_Helper_Html::html_element($field);
        }
        ?>
					</div>
				</form>
			</div>
		</div>
		<?php 
        $html = ob_get_clean();
        return $html;
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     *
     * @return string
     */
    public function to_html()
    {
        $fields = $this->prepare_fields();
        $form_url = esc_url_raw(remove_query_arg(array('action', 'coupon_id')));
        if ($this->data['coupon']->is_valid()) {
            $title = __('Edit Coupon', 'membership2');
        } else {
            $title = __('Add Coupon', 'membership2');
        }
        ob_start();
        // Render tabbed interface.
        ?>
		<div class="ms-wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'title_icon_class' => 'wpmui-fa wpmui-fa-pencil-square'));
        ?>
			<form action="<?php 
        echo esc_url($form_url);
        ?>
" method="post" class="ms-form">
				<?php 
        MS_Helper_Html::settings_box($fields, '', '', 'static', 'ms-small-form');
        ?>
			</form>
			<div class="clear"></div>
		</div>
		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_addon_coupon_view_edit_to_html', $html, $this);
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $this->check_simulation();
        $this->check_network();
        $desc = array(__('Choose Pages, Categories etc. that you want to make <strong>unavailable</strong> to visitors, and non-members.', 'membership2'));
        ob_start();
        // Render tabbed interface.
        ?>
		<div class="ms-wrap wrap ms-wrap-membership2">
			<?php 
        MS_Helper_Html::settings_header(array('title' => __('Set-up Protection Rules', 'membership2'), 'desc' => $desc));
        // Display a filter to switch between individual memberships.
        $this->membership_filter();
        // In network-wide protection mode allow user to select a site.
        $this->site_filter();
        $active_tab = $this->data['active_tab'];
        MS_Helper_Html::html_admin_vertical_tabs($this->data['tabs'], $active_tab);
        // Call the appropriate form to render.
        $callback_name = 'render_tab_' . str_replace('-', '_', $active_tab);
        $render_callback = array($this, $callback_name);
        $render_callback = apply_filters('ms_view_protectedcontent_define-' . $active_tab, $render_callback, $this->data);
        if (is_callable($render_callback)) {
            $html = call_user_func($render_callback);
        } else {
            // This is to notify devs that a file/hook is missing or wrong.
            $html = '<div class="ms-settings">' . '<div class="error below-h2"><p>' . '<em>No View defined by hook "ms_view_protectedcontent_define-' . $active_tab . '"</em>' . '</p></div>' . '</div>';
        }
        $html = apply_filters('ms_view_membership_protected_' . $active_tab, $html);
        echo $html;
        ?>
		</div>
		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_view_membership_protectedcontent_to_html', $html, $this);
    }
Exemplo n.º 11
0
    /**
     * Overrides parent's to_html() method.
     *
     * Creates an output buffer, outputs the HTML and grabs the buffer content before releasing it.
     * Creates a wrapper 'ms-wrap' HTML element to contain content and navigation. The content inside
     * the navigation gets loaded with dynamic method calls.
     * e.g. if key is 'settings' then render_settings() gets called, if 'bob' then render_bob().
     *
     * @since  1.0.0
     *
     * @return object
     */
    public function to_html()
    {
        $this->check_simulation();
        // Setup navigation tabs.
        $tabs = $this->data['tabs'];
        ob_start();
        // Render tabbed interface.
        ?>
		<div class="ms-wrap wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => __('Help and documentation', MS_TEXT_DOMAIN), 'title_icon_class' => 'wpmui-fa wpmui-fa-info-circle'));
        $active_tab = MS_Helper_Html::html_admin_vertical_tabs($tabs);
        // Call the appropriate form to render.
        $callback_name = 'render_tab_' . str_replace('-', '_', $active_tab);
        $render_callback = apply_filters('ms_view_help_render_callback', array($this, $callback_name), $active_tab, $this->data);
        ?>
			<div class="ms-settings ms-help-content">
				<?php 
        $html = call_user_func($render_callback);
        $html = apply_filters('ms_view_help_' . $callback_name, $html);
        echo $html;
        ?>
			</div>
		</div>
		<?php 
        return ob_get_clean();
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $fields = $this->get_fields();
        $wrapper_class = $this->data['is_global_payments_set'] ? '' : 'wide';
        ob_start();
        ?>

		<div class="wrap ms-wrap">
			<?php 
        MS_Helper_Html::settings_header(array('title' => __('Payment', MS_TEXT_DOMAIN), 'title_icon_class' => 'wpmui-fa wpmui-fa-money', 'desc' => __('Set up your payment gateways and Membership Price')));
        ?>
			<div class="ms-settings ms-wrapper-center ms-membership-payment cf <?php 
        echo esc_attr($wrapper_class);
        ?>
">
				<?php 
        $this->global_payment_settings();
        $this->specific_payment_settings();
        MS_Helper_Html::settings_footer($this->fields['control_fields'], $this->data['show_next_button']);
        ?>
			</div>
		</div>

		<?php 
        $html = ob_get_clean();
        echo $html;
    }
    /**
     * Overrides parent's to_html() method.
     *
     * Creates an output buffer, outputs the HTML and grabs the buffer content before releasing it.
     * Creates a wrapper 'ms-wrap' HTML element to contain content and navigation. The content inside
     * the navigation gets loaded with dynamic method calls.
     * e.g. if key is 'settings' then render_settings() gets called, if 'bob' then render_bob().
     *
     * @todo Could use callback functions to call dynamic methods from within the helper, thus
     * creating the navigation with a single method call and passing method pointers in the $tabs array.
     *
     * @since  1.0.0
     *
     * @return object
     */
    public function to_html()
    {
        $this->check_simulation();
        // Setup navigation tabs.
        $tabs = $this->data['tabs'];
        $desc = array();
        ob_start();
        // Render tabbed interface.
        ?>
		<div class="ms-wrap wrap">
			<?php 
        $desc = $this->advanced_forms($desc);
        MS_Helper_Html::settings_header(array('title' => __('Membership 2 Settings', 'membership2'), 'title_icon_class' => 'wpmui-fa wpmui-fa-cog', 'desc' => $desc));
        $active_tab = MS_Helper_Html::html_admin_vertical_tabs($tabs);
        // Call the appropriate form to render.
        $tab_name = str_replace('-', '_', $active_tab);
        $callback_name = 'render_tab_' . $tab_name;
        $render_callback = apply_filters('ms_view_settings_edit_render_callback', array($this, $callback_name), $active_tab, $this->data);
        ?>
			<div class="ms-settings ms-settings-<?php 
        echo esc_attr($tab_name);
        ?>
">
				<?php 
        $html = call_user_func($render_callback);
        $html = apply_filters('ms_view_settings_' . $callback_name, $html);
        echo $html;
        ?>
			</div>
		</div>
		<?php 
        $this->render_settings_footer($tab_name);
        $html = ob_get_clean();
        return $html;
    }
    public function to_html()
    {
        $this->check_simulation();
        $membership = $this->data['membership'];
        $toggle = array('id' => 'ms-toggle-' . $membership->id, 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'value' => $membership->active, 'class' => '', 'data_ms' => array('action' => MS_Controller_Membership::AJAX_ACTION_TOGGLE_MEMBERSHIP, 'field' => 'active', 'membership_id' => $membership->id));
        $status_class = '';
        if ($membership->active) {
            $status_class = 'ms-active';
        }
        $edit_args = array('membership_id' => $membership->id);
        $edit_button = sprintf('<a href="?page=%1$s&step=%2$s&tab=%3$s&membership_id=%4$s" class="button">%5$s</a>', esc_attr($_REQUEST['page']), MS_Controller_Membership::STEP_EDIT, MS_Controller_Membership::TAB_DETAILS, esc_attr($membership->id), '<i class="wpmui-fa wpmui-fa-pencil"></i> ' . __('Edit', 'membership2'));
        ob_start();
        ?>
		<div class="wrap ms-wrap ms-membership-overview">
			<div class="ms-wrap-top ms-group">
				<div class="ms-membership-status-wrapper">
					<?php 
        MS_Helper_Html::html_element($toggle);
        ?>
					<div id="ms-membership-status" class="ms-membership-status <?php 
        echo esc_attr($status_class);
        ?>
">
						<?php 
        printf('<div class="ms-active">%s</div>', sprintf(__('Membership is %s', 'membership2'), '<span id="ms-membership-status-text" class="ms-ok">' . __('Active', 'membership2') . '</span>'));
        printf('<div>%s</div>', sprintf(__('Membership is %s', 'membership2'), '<span id="ms-membership-status-text" class="ms-nok">' . __('Inactive', 'membership2') . '</span>'));
        ?>
					</div>
				</div>
				<div class="ms-membership-edit-wrapper">
					<?php 
        echo $edit_button;
        ?>
				</div>
				<?php 
        $title = sprintf(__('%s Overview', 'membership2'), $membership->get_name_tag());
        $desc = array(__('Here you find a summary of this membership, and alter any of its details.', 'membership2'), sprintf(__('This is a %s', 'membership2'), $membership->get_type_description()));
        MS_Helper_Html::settings_header(array('title' => $title, 'desc' => $desc, 'title_icon_class' => 'wpmui-fa wpmui-fa-dashboard'));
        ?>
				<div class="clear"></div>
			</div>
			<?php 
        $this->available_content_panel();
        ?>
			<div class="clear"></div>
		</div>

		<?php 
        $html = ob_get_clean();
        return $html;
    }
    /**
     * Create view output.
     *
     * @since 1.0.1.0
     * @return string
     */
    public function to_html()
    {
        if ('add' == $this->data['action']) {
            $title = __('Add or Select Member', MS_TEXT_DOMAIN);
            $groups = $this->prepare_fields_add();
        } else {
            $title = __('Edit Member', MS_TEXT_DOMAIN);
            $groups = $this->prepare_fields_edit();
        }
        ob_start();
        ?>
		<div class="ms-wrap ms-add-member">
			<?php 
        MS_Helper_Html::settings_header(array('title_icon_class' => 'wpmui-fa wpmui-fa-user', 'title' => $title, 'desc' => ''));
        ?>
			<div class="ms-settings ms-add-member">
			<?php 
        foreach ($groups as $class => $fields) {
            ?>
				<div class="ms-field-group ms-group-<?php 
            echo esc_attr($class);
            ?>
">
				<div class="ms-field-group-inner">
				<form method="post">
				<?php 
            foreach ($fields as $field) {
                MS_Helper_Html::html_element($field);
            }
            ?>
				</div></div>
				</form>
			<?php 
        }
        ?>
			</div>
		</div>
		<?php 
        $html = ob_get_clean();
        return $html;
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     *
     * @return string
     */
    public function to_html()
    {
        $this->check_simulation();
        $buttons = array();
        // Count invalid transactions.
        $args = array('state' => 'err');
        $error_count = MS_Model_Transactionlog::get_item_count($args);
        if ($error_count && (empty($_GET['state']) || 'err' != $_GET['state'])) {
            if (1 == $error_count) {
                $message = __('One transaction failed. Please %2$sreview the logs%3$s and decide if you want to ignore the transaction or manually assign it to an invoice.', MS_TEXT_DOMAIN);
            } else {
                $message = __('%1$s transactions failed. Please %2$sreview the logs%3$s and decide if you want to ignore the transaction or manually assign it to an invoice.', MS_TEXT_DOMAIN);
            }
            $review_url = MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs', 'state' => 'err'));
            lib2()->ui->admin_message(sprintf($message, $error_count, '<a href="' . $review_url . '">', '</a>'), 'err');
        }
        if (isset($_GET['show']) && 'logs' == $_GET['show']) {
            $title = __('Transaction Logs', MS_TEXT_DOMAIN);
            $listview = MS_Factory::create('MS_Helper_ListTable_TransactionLog');
            $listview->prepare_items();
            $buttons[] = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing'), 'value' => __('Show Invoices', MS_TEXT_DOMAIN), 'class' => 'button');
        } else {
            $title = __('Billing', MS_TEXT_DOMAIN);
            $listview = MS_Factory::create('MS_Helper_ListTable_Billing');
            $listview->prepare_items();
            $buttons[] = array('id' => 'add_new', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing', array('action' => MS_Controller_Billing::ACTION_EDIT, 'invoice_id' => 0)), 'value' => __('Create new Invoice', MS_TEXT_DOMAIN), 'class' => 'button');
            $buttons[] = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs')), 'value' => __('Show Transaction Logs', MS_TEXT_DOMAIN), 'class' => 'button');
            if (!empty($_GET['gateway_id'])) {
                $gateway = MS_Model_Gateway::factory($_GET['gateway_id']);
                if ($gateway->name) {
                    $title .= ' - ' . $gateway->name;
                }
            }
        }
        ob_start();
        ?>

		<div class="wrap ms-wrap ms-billing">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'title_icon_class' => 'wpmui-fa wpmui-fa-credit-card'));
        ?>
			<div>
				<?php 
        foreach ($buttons as $button) {
            MS_Helper_Html::html_element($button);
        }
        ?>
			</div>
			<?php 
        $listview->views();
        $listview->search_box(__('User', MS_TEXT_DOMAIN), 'search');
        ?>
			<form action="" method="post">
				<?php 
        $listview->display();
        ?>
			</form>
		</div>

		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_view_billing_list', $html, $this);
    }
    /**
     * Create view output.
     *
     * @since  1.0.0
     *
     * @return string
     */
    public function to_html()
    {
        $this->check_simulation();
        $buttons = array();
        $module = 'billing';
        if (isset($_GET['show'])) {
            $module = $_GET['show'];
        }
        if (!$module) {
            // Show a message if there are error-state transactions.
            $args = array('state' => 'err');
            $error_count = MS_Model_Transactionlog::get_item_count($args);
            if ($error_count) {
                if (1 == $error_count) {
                    $message = __('One transaction failed. Please %2$sreview the logs%3$s and decide if you want to ignore the transaction or manually assign it to an invoice.', 'membership2');
                } else {
                    $message = __('%1$s transactions failed. Please %2$sreview the logs%3$s and decide if you want to ignore the transaction or manually assign it to an invoice.', 'membership2');
                }
                $review_url = MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs', 'state' => 'err'));
                lib3()->ui->admin_message(sprintf($message, $error_count, '<a href="' . $review_url . '">', '</a>'), 'err');
            }
        }
        // Decide which list to display in the Billings page.
        switch ($module) {
            // Transaction logs.
            case 'logs':
                $title = __('Transaction Logs', 'membership2');
                $listview = MS_Factory::create('MS_Helper_ListTable_TransactionLog');
                $listview->prepare_items();
                $buttons[] = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing'), 'value' => __('Show Invoices', 'membership2'), 'class' => 'button');
                break;
                // M1 Migration matching.
            // M1 Migration matching.
            case 'matching':
                $title = __('Automatic Transaction Matching', 'membership2');
                $listview = MS_Factory::create('MS_Helper_ListTable_TransactionMatching');
                $listview->prepare_items();
                $buttons[] = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing'), 'value' => __('Show Invoices', 'membership2'), 'class' => 'button');
                $buttons[] = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs')), 'value' => __('Show Transaction Logs', 'membership2'), 'class' => 'button');
                break;
                // Default billings list.
            // Default billings list.
            case 'billing':
            default:
                $title = __('Billing', 'membership2');
                $listview = MS_Factory::create('MS_Helper_ListTable_Billing');
                $listview->prepare_items();
                $buttons[] = array('id' => 'add_new', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing', array('action' => MS_Controller_Billing::ACTION_EDIT, 'invoice_id' => 0)), 'value' => __('Create new Invoice', 'membership2'), 'class' => 'button');
                $buttons[] = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs')), 'value' => __('Show Transaction Logs', 'membership2'), 'class' => 'button');
                if (!empty($_GET['gateway_id'])) {
                    $gateway = MS_Model_Gateway::factory($_GET['gateway_id']);
                    if ($gateway->name) {
                        $title .= ' - ' . $gateway->name;
                    }
                }
                break;
        }
        if ('matching' != $module) {
            if (MS_Model_Import::can_match()) {
                $btn_label = __('Setup automatic matching', 'membership2');
                $btn_class = 'button';
            } else {
                $btn_label = '(' . __('Setup automatic matching', 'membership2') . ')';
                $btn_class = 'button button-link';
            }
            $buttons[] = array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'url' => MS_Controller_Plugin::get_admin_url('billing', array('show' => 'matching')), 'value' => $btn_label, 'class' => $btn_class);
        }
        // Default list view part - dislay prepared values from above.
        ob_start();
        ?>

		<div class="wrap ms-wrap ms-billing">
			<?php 
        MS_Helper_Html::settings_header(array('title' => $title, 'title_icon_class' => 'wpmui-fa wpmui-fa-credit-card'));
        ?>
			<div>
				<?php 
        foreach ($buttons as $button) {
            MS_Helper_Html::html_element($button);
        }
        ?>
			</div>
			<?php 
        $listview->views();
        $listview->search_box(__('User', 'membership2'), 'search');
        ?>
			<form action="" method="post">
				<?php 
        $listview->display();
        ?>
			</form>
		</div>

		<?php 
        $html = ob_get_clean();
        return apply_filters('ms_view_billing_list', $html, $this);
    }