Пример #1
0
<?php
$templateData = \CPFCMembers\TemplateData::getInstance();
$form = \CPFCMembers\ReportingFilter::getInstance(); ?>

<h3>Filters</h3>

<form method="POST" action="<?php echo home_url(CPFC_MEMBERS_REPORTING_ADMIN_URL, CPFC_MEMBERS_HTTP_MODE); ?>">
    <div id="tabs">
        <ul>
            <li><a href="#fragment-1"><span>Members by Date/Country</span></a></li>
            <li><a href="#fragment-2" class="active"><span>Members by SEE Tickets No.</span></a></li>
            <li><a href="#fragment-3"><span>Member Logins by Date</span></a></li>
        </ul>
        <div id="fragment-1">
            <p>
                <label for="registered-after">Registered After</label>
                <input type="text" name="registered_after" class="cpfc-datepicker" id="registered-after" value="<?php echo $form->getValue('registered_after'); ?>" autocomplete="off">

                <label for="registered-before">Registered Before</label>
                <input type="text" name="registered_before" class="cpfc-datepicker" id="registered-before" value="<?php echo $form->getValue('registered_before'); ?>"autocomplete="off">
            </p>

            <?php
            if ($form->getError('registration_date')) { ?>
            <p style="color:red;"><?php echo $form->getError('registration_date'); ?></p>
            <?php
            } ?>

            <p>
                <label for="country">Country</label>
                <select name="country" id="country">
    /**
     * Build where conditions
     * @return array
     */
    public function buildWhereConditions()
    {
        $form = \CPFCMembers\ReportingFilter::getInstance();
        $whereConditions = array();
        $whereConditionsFriendly = array();

        switch (true) {
            case Input::request('cpfc_filter_member_submit'):
            case Input::request('cpfc_filter_member_export'):

                if (Input::request('registered_after')) {
                    $whereConditions['registered_date >='] = date('Y-m-d H:i:s', strtotime(Input::request('registered_after')));
                    $whereConditionsFriendly[] = 'Members were registered at or after ' . date('H:i \o\n jS F Y', strtotime(Input::request('registered_after')));
                }

                if (Input::request('registered_before')) {
                    $whereConditions['registered_date <'] = date('Y-m-d H:i:s', strtotime(Input::request('registered_before')));
                    $whereConditionsFriendly[] = 'Members were registered before ' . date('H:i \o\n jS F Y', strtotime(Input::request('registered_before')));
                }

                if (Input::request('country')) {
                    $whereConditions['country ='] = Input::request('country');

                    $countries = $form->getCountryOptions();
                    $whereConditionsFriendly[] = 'Members\' country is "' . $countries[Input::request('country')] . '"';
                }

                if (Input::request('membership_level')) {
                    $whereConditions['membership_level ='] = Input::request('membership_level');
                    $membershipLevels = $form->getMembershipLevelOptions();
                    $whereConditionsFriendly[] = 'Members\' membership level is "' . $membershipLevels[Input::request('membership_level')] . '"';
                }
                break;
            case Input::request('cpfc_filter_see_tickets_account_holder_submit'):
            case Input::request('cpfc_filter_see_tickets_account_holder_export'):

                if (Input::request('see_tickets_account_number')) {
                    $whereConditions['see_tickets_account_number ='] = Input::request('see_tickets_account_number');
                    $whereConditionsFriendly[] = 'Member\'s SEE Tickets Account Number is "' . Input::request('see_tickets_account_number') .'"';
                }
                break;
            case Input::post('cpfc_logged_in_filter_submit'):
            case Input::post('cpfc_logged_in_filter_export'):

                if (Input::request('logged_in_after')) {
                    $whereConditions['login_date >='] = date('Y-m-d H:i:s', strtotime(Input::request('logged_in_after')));
                    $whereConditionsFriendly[] = 'Members logged-in at or after ' . date('H:i \o\n jS F Y', strtotime(Input::request('logged_in_after')));
                }

                if (Input::request('logged_in_before')) {
                    $whereConditions['login_date <'] = date('Y-m-d H:i:s', strtotime(Input::request('logged_in_before')));
                    $whereConditionsFriendly[] = 'Members logged-in before ' . date('H:i \o\n jS F Y', strtotime(Input::request('logged_in_before')));
                }

            break;
        }

        return array($whereConditions, $whereConditionsFriendly);
    }