コード例 #1
0
function ym_render_subscription_form($predata)
{
    global $ym_formgen, $duration_str, $link, $ym_res, $ym_package_types;
    $data = $predata;
    $data['id'] = isset($data['id']) ? $data['id'] : 0;
    if ($data['id']) {
        echo '<input type="hidden" name="id" value="' . $data['id'] . '" />';
    }
    echo '
	<table class="form-table">';
    $ym_formgen->render_form_table_text_row(__('Admin Name', 'ym'), 'admin_name', $data['admin_name'], __('A Handy Name for the Admin Interface', 'ym'));
    $ym_formgen->render_form_table_text_row(__('Price', 'ym'), 'cost', $data['cost'], __('The Price in digits, no currency symbol needed', 'ym'));
    $types = array();
    if ($ym_package_types) {
        foreach ($ym_package_types->types as $k => $v) {
            $types[$k] = $v;
        }
    }
    $types['new'] = __('Create a New Type', 'ym');
    echo '<tr><th>' . __('Package Type', 'ym') . '</th><td><select name="account_type" class="account_type_selector">';
    foreach ($types as $k => $v) {
        echo '<option value="' . $k . '" ';
        if ($data['account_type'] && strtolower($v) == strtolower($data['account_type'])) {
            echo ' selected="selected" ';
        }
        echo ' >';
        echo $v;
        echo '</option>';
    }
    echo '</select></td></tr>';
    echo '<tr class="new_account_type_entry"><th>' . __('New Package Type', 'ym');
    echo '<div style="color: gray; margin-top: 5px; font-size: 11px;">';
    echo __('Create a new Package Type', 'ym');
    echo '</th><td><input type="text" name="new_account_type" value="" /></td></tr>';
    echo '
<tr>
	<th>' . __('Duration', 'ym') . ':
	<div style="color: gray; margin-top: 5px; font-size: 11px;">' . __('The Length of the Subscription', 'ym') . '</div>
	</th>
	<td>
		<table><tr>
			<td>
				<input class="ym_input" style="width: 50px; font-family:\'Lucida Grande\',Verdana; font-size: 11px; text-align: right;" name="duration" value="' . $data['duration'] . '">
			</td>
			<td>
				<select name="duration_type">
				';
    foreach ($duration_str as $str => $val) {
        echo '<option value="' . $str . '"';
        if ($str == $data['duration_type']) {
            echo ' selected="selected"';
        }
        echo '>' . $val . '</option>';
    }
    echo '
				</select>
			</td>
		</tr></table>
	</td>
</tr>
';
    /**
    Basic with trial
    */
    $trial = ym_packs_gateways_trial_on();
    if ($trial) {
        echo '<tr class="basic_with_trial table_divider"><td></td><th><h4>' . __('Trial Options', 'ym') . '</h4></th></tr>';
        echo '<tr class="basic_with_trial"><th>' . __('Enable Trial Period', 'ym');
        echo '</th><td><input type="checkbox" name="trial_on" value="1" ';
        if (isset($data['trial_on'])) {
            if ($data['trial_on'] == 1) {
                echo 'checked="checked"';
            }
        }
        echo ' /></td></tr>';
        echo '<tr class="basic_with_trial"><th>' . __('Trial Price', 'ym');
        echo '</th><td><input tpye="text" name="trial_cost" value="' . $data['trial_cost'] . '" /></td></tr>';
        echo '
<tr class="basic_with_trial">
	<th>' . __('Trial Duration', 'ym') . ':
	<div style="color: gray; margin-top: 5px; font-size: 11px;">' . __('The Length of the Trial Subscription', 'ym') . '</div>
	</th>
	
	<td>
		<table><tr>
			<td>
				<input class="ym_input" style="width: 50px; font-family:\'Lucida Grande\',Verdana; font-size: 11px; text-align: right;" name="trial_duration" value="' . $data['trial_duration'] . '">
			</td>
			<td>
				<select name="trial_duration_type">
				';
        foreach ($duration_str as $str => $val) {
            echo '<option value="' . $str . '"';
            if (isset($data['trial_duration_type'])) {
                if ($str == $data['trial_duration_type']) {
                    echo ' selected="selected"';
                }
            }
            echo '>' . $val . '</option>';
        }
        echo '
				</select>
			</td>
		</tr></table>
	</td>
</tr>
';
    }
    /**
    Advanced
    */
    echo '<tr class="advanced table_divider"><td></td><th><h4>' . __('Additional Package Options', 'ym') . '</h4></th></tr>';
    $cycles = array(0 => 'Ongoing');
    for ($x = 1; $x <= 59; $x++) {
        $cycles[$x] = $x;
    }
    $ym_formgen->tr_class = 'advanced';
    $ym_formgen->style = 'display: none;';
    $ym_formgen->render_combo_from_array_row(__('Package Reoccurance', 'ym'), 'num_cycles', $cycles, $data['num_cycles'], __('How many times the subscription repeats', 'ym'), $data['num_cycles']);
    $currencies = ym_get_currencies();
    if (!$data['currency']) {
        $data['currency'] = ym_get_currency();
    }
    $ym_formgen->render_combo_from_array_row(__('Payment Currency', 'ym'), 'currency', $currencies, $data['currency'], __('Currency for Package', 'ym'));
    $roles = new WP_Roles();
    $roles_array = array_reverse($roles->role_names);
    $ym_formgen->render_combo_from_array_row(__('WordPress Role', 'ym'), 'role', $roles_array, $data['role'], __('Grant these Role set to the User', 'ym'));
    $ym_formgen->render_form_table_textarea_row(__('Package Description', 'ym'), 'description', $data['description'], __('Only used with the [description] Package Template Argument. Check Advanced -> Messages -> Templates', 'ym'));
    $ym_formgen->render_form_table_checkbox_row(__('Hide Old Content', 'ym'), 'hide_old_content', $data['hide_old_content'], __('Hide content created and protected prior to the member&#39;s current subscription start date', 'ym'));
    $ym_formgen->render_form_table_checkbox_row(__('Hide from Standard Subscription page', 'ym'), 'hide_subscription', $data['hide_subscription'], __('When enabled, this package would only be available directly from ym_register shortcode or from a coupon', 'ym'));
    $ym_formgen->render_form_table_checkbox_row(__('Hide Admin Bar', 'ym'), 'hide_admin_bar', $data['hide_admin_bar']);
    echo '<tr class="advanced table_divider"><td></td><th><h4>' . __('Expire Options', 'ym') . '</h4></th></tr>';
    echo '<tr class="advanced"><th>' . __('Set Subscription Expiry Date', 'ym');
    echo '<div style="color: gray; margin-top: 5px; font-size: 11px;">' . __('Users will expire at the start of this date', 'ym') . '</div></th>';
    $value = $data['force_end_date'] ? $data['force_end_date'] : '';
    if ($value) {
        $value = date('d/m/Y', $value);
    }
    echo '<td>
					<input type="text" name="force_end_date" id="dateclear" value="' . $value . '" class="ym_yearpicker" /> <a href="#nowhere" onclick="ym_clear_target(\'dateclear\');">' . __('Clear Date', 'ym') . '
				</td></tr>';
    echo '<tr class="advanced"><th>' . __('On Expire Drop User to:', 'ym') . '</th>';
    echo '<td>';
    echo '<select name="on_expire_drop_to">';
    echo '<option value="">' . __('Inactive', 'ym') . '</option>';
    foreach (ym_get_packs() as $pack) {
        if ($data['id'] == $pack['id']) {
            continue;
        }
        echo '<option value="' . $pack['id'] . '" ';
        if ($data['on_expire_drop_to'] == $pack['id']) {
            echo 'selected="selected"';
        }
        echo '>';
        echo '(' . $pack['id'] . ') ' . ym_get_pack_label($pack['id']);
        echo '</option>';
    }
    echo '</select>';
    echo '</td></tr>';
    // gateway disable
    echo '<tr class="advanced table_divider"><td></td><th><h4>' . __('Payment Gateway Options', 'ym') . '</h4></th></tr>';
    echo '
	<tr class="advanced">
		<td colspan="2"><p>' . __('This filtering is also subject to Payment Gateway filters, for example, the Free Gateway can never be used to buy a non Free Package (so you do not have to deselect it here if this package is not free)', 'ym') . '</p></td>
	</tr>
	<tr class="advanced"><th>' . __('Allow Gateways', 'ym');
    echo '<div style="color: gray; margin-top: 5px; font-size: 11px;">' . __('You can select gateways to use with this Pack', 'ym') . '</div></th>';
    echo '<td>';
    echo '<ul>';
    global $ym_active_modules;
    foreach ((array) $ym_active_modules as $key => $module) {
        echo '<li>';
        echo '<label for="disable_module_' . $key . '">';
        echo '<input type="checkbox" id="disable_module_' . $key . '" name="gateway_disable[]" value="' . $module . '" ';
        // checked?
        if (FALSE !== array_search($module, $data['gateway_disable'])) {
            echo 'checked="checked"';
        }
        echo ' /> ';
        $way = new $module();
        echo $way->name;
        echo '</label>';
        echo '</li>';
    }
    echo '</ul>';
    echo '</td>';
    echo '</tr>';
    // URLS
    echo '<tr class="advanced table_divider"><td></td><th><h4>' . __('Package Speicifc Redirects', 'ym') . '</h4></th></tr>';
    $ym_formgen->render_form_table_url_row(__('Success URL', 'ym'), 'success_redirect', $data['success_redirect'], __('Where to redirect the user to on Successful Transaction, aka Thank You Page', 'ym'));
    echo '
	<tr class="advanced">
		<td colspan="2"><p>' . __('If you need Pack Specific redirects you can configure these here, you can leave these blank and the default redirects configured under Advanced->Security will be used', 'ym') . '</p></td>
	</tr>
	';
    $ym_formgen->render_form_table_url_row(__('Login Redirect URL', 'ym'), 'login_redirect_url', $data['login_redirect_url'], __('Where to redirect the user to on Login', 'ym'));
    $ym_formgen->render_form_table_url_row(__('WP Admin Block URL', 'ym'), 'wpadmin_disable_redirect_url', $data['wpadmin_disable_redirect_url'], __('Where to redirect the user to on WP Admin Access', 'ym'));
    $ym_formgen->render_form_table_url_row(__('Logout Redirect URL', 'ym'), 'logout_redirect_url', $data['logout_redirect_url'], __('Where to redirect the user to on Logout', 'ym'));
    $ym_formgen->render_form_table_url_row(__('First Login URL', 'ym'), 'first_login', $data['first_login'], __('Where to redirect on the user first login with this package', 'ym'));
    // Group Membership
    echo '<tr class="advanced table_divider"><td></td><th><h4>' . __('Group Membership', 'ym') . '</h4></th></tr>';
    $ym_formgen->render_form_table_text_row(__('Total Allowed Child Accounts', 'ym'), 'child_accounts_allowed', $data['child_accounts_allowed']);
    echo '<tr class="advanced"><td colspan="2"><p>' . __('A Group Leader can create child accounts, these child accounts normally inherit the parents package type, optionally you can allow the group admin to choose which Package Type the child account uses from a subset of the available Package Types (this will exclude the parent package type from being selectable unless you select it below). Further more you can allow Packages to be available, allowing you a Group Leader, to create a child account, which itself can have children. If packages are allowed they are applied to a child account at zero cost', 'ym') . '</p></td></tr>';
    echo '<tr class="advanced"><td>' . __('Use Inherit Mode', 'ym') . '</td><td><input type="checkbox" name="inherit_mode" id="ym_inherit_mode" ';
    $score = 0;
    foreach ($data['child_accounts_package_types'] as $v => $count) {
        $score += $count;
    }
    global $ym_packs;
    foreach ($ym_packs->packs as $pack) {
        if (in_array($pack['id'], $data['child_accounts_packages'])) {
            $score++;
        }
    }
    if (!$score) {
        echo 'checked="checked"';
    }
    echo ' /></td></tr>';
    echo '<tr class="ym_inherit_mode_off"><td>' . __('Available Package Types', 'ym') . '</td><td><table>';
    foreach ($ym_package_types->types as $v) {
        if (strtolower($v) == 'guest') {
            continue;
        }
        echo '<tr><td>';
        echo $v;
        echo '</td><td>';
        echo '<input type="text" name="child_accounts_package_types[' . $v . ']" value="' . (isset($data['child_accounts_package_types'][$v]) ? $data['child_accounts_package_types'][$v] : 0) . '" /> ';
        echo '</td></tr>';
    }
    echo '</table></td></tr>';
    echo '<tr class="ym_inherit_mode_off"><td>' . __('Available Packages', 'ym') . '</td><td><table>';
    foreach ($ym_packs->packs as $pack) {
        echo '<tr><td>';
        echo ym_get_pack_label($pack['id']);
        echo '</td><td>';
        echo '<input type="checkbox" name="child_accounts_packages[]" value="' . $pack['id'] . '" ' . (in_array($pack['id'], $data['child_accounts_packages']) ? 'checked="checked"' : '') . ' /> ';
        echo '</td></tr>';
    }
    echo '</table></td></tr>';
    /**
    ALL
    */
    echo '<tr class="basic table_divider"><td></td><th><h4>' . __('Payment Gateway Specific Fields', 'ym') . '</h4></th></tr>';
    // gateway fields
    ym_packs_gateways_extra_fields_display($data);
    echo '</table>';
}
コード例 #2
0
</table>

<?php 
echo ym_end_box();
echo ym_start_box(__('Global Payment Settings', 'ym'));
global $ym_sys, $ym_res, $ym_formgen;
if (isset($_POST['settings_update']) && !empty($_POST['settings_update'])) {
    // currency is in here
    $ym_res->update_from_post();
    // sys
    $ym_sys->update_from_post();
    update_option('ym_sys', $ym_sys);
    ym_display_message(__('System Updated', 'ym'));
}
$sel_currency = ym_get_currency();
$currencies = ym_get_currencies();
echo '
<form action="" method="post">
<table class="form-table">
';
$ym_formgen->render_form_table_text_row(__('The Name that Appears on Customer Reciepts', 'ym'), 'item_name', $ym_sys->item_name, __('The name of the membership to display on the order form', 'ym'));
$ym_formgen->render_combo_from_array_row(__('Payment Currency', 'ym'), 'currency', $currencies, $sel_currency, __('The Currency used for all payments', 'ym'));
$ym_formgen->render_form_table_radio_row(__('Apply sales Tax?', 'ym'), 'global_vat_applicable', $ym_sys->global_vat_applicable);
$ym_formgen->render_form_table_text_row(__('Sales Tax', 'ym'), 'vat_rate', (int) $ym_sys->vat_rate);
$ym_formgen->render_form_table_radio_row(__('Enable Members to Extend Subscription prior to expiry date?', 'ym'), 'allow_upgrade_to_same', (int) $ym_sys->allow_upgrade_to_same, __('Valid only for non-reoccuring package subscriptions', 'ym'));
$ym_formgen->render_form_table_radio_row(__('Enable end of Subscription Grace Period', 'ym'), 'grace_enable', (int) $ym_sys->grace_enable, __('Tip: Useful for pending payments, does not trigger on cancelled/failed payments', 'ym'));
$ym_formgen->render_form_table_text_row(__('Grace Limit (Days)', 'ym'), 'grace_limit', (int) $ym_sys->grace_limit);
echo '<tr>';
echo '<td><label for="tod">' . __('What time of Day should a User Expire?', 'ym') . '</label></td>';
echo '<td>';
$hours = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);