コード例 #1
0
function PAYPAL_getSubscriptionForm($subscription = array())
{
    global $_CONF, $_PAY_CONF, $LANG_PAYPAL_1, $_TABLES;
    //PHP 5.4 set all $subscription[key]
    PAYPAL_setAllKeys($subscription, array('id', 'product_id', 'user_id', 'txn_id', 'purchase_date', 'expiration', 'price', 'status', 'add_to_group', 'notification'));
    //Display form
    $retval = '';
    $subscription['id'] == '' ? $retval .= COM_startBlock($LANG_PAYPAL_1['create_new_subscription']) : ($retval .= COM_startBlock($LANG_PAYPAL_1['edit_subscription'] . ' ' . $subscription['id']));
    $template = new Template($_CONF['path'] . 'plugins/paypal/templates');
    $template->set_file(array('subscription' => 'subscription_form.thtml'));
    $template->set_var('site_url', $_CONF['site_url']);
    $template->set_var('xhtml', XHTML);
    $template->set_var('id', '<input type="hidden" name="id" value="' . $subscription['id'] . '" />');
    //Subscrition infos
    $template->set_var('informations', $LANG_PAYPAL_1['subscription_informations']);
    //Membership
    $template->set_var('product_id_label', $LANG_PAYPAL_1['product_id']);
    $result = DB_query("SELECT * FROM {$_TABLES['paypal_products']} WHERE type='subscription'");
    $nRows = DB_numRows($result);
    if ($nRows == 0) {
        return $LANG_PAYPAL_1['create_membership_first'];
    }
    $product_id_select = '<select name="product_id">';
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        $product_id_select .= '<option value="' . $row['id'] . '"' . ($subscription['product_id'] == $row['id'] ? 'selected="selected"' : '') . '>' . $row['id'] . '. ' . $row['name'] . ' | ' . $row['price'] . ' ' . $_PAY_CONF['currency'] . '</option>';
    }
    $product_id_select .= '</select>';
    $template->set_var('product_id_select', $product_id_select);
    //user
    $template->set_var('user_id_label', $LANG_PAYPAL_1['user_id']);
    $result = DB_query("SELECT * FROM {$_TABLES['users']} ORDER BY uid");
    $nRows = DB_numRows($result);
    $user_select = '<select name="user_id">';
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        if ($row['uid'] == 1) {
            continue;
        }
        $user_select .= '<option value="' . $row['uid'] . '"' . ($subscription['user_id'] == $row['uid'] ? 'selected="selected"' : '') . '>' . $row['uid'] . '. ' . COM_getDisplayName($row['uid']) . '</option>';
    }
    $user_select .= '</select>';
    $template->set_var('user_select', $user_select);
    $template->set_var('txn_id_label', $LANG_PAYPAL_1['txn_id']);
    $template->set_var('txn_id', $subscription['txn_id']);
    $template->set_var('purchase_date_label', $LANG_PAYPAL_1['purchase_date']);
    if ($subscription['purchase_date'] != '') {
        $date = date("Y/m/d", strtotime($subscription['purchase_date']));
        $template->set_var('purchase_date', $date);
    } else {
        $date = date("Y/m/d");
        $template->set_var('purchase_date', $date);
    }
    $template->set_var('expiration_label', $LANG_PAYPAL_1['expiration']);
    $template->set_var('expiration', $subscription['expiration']);
    if ($subscription['expiration'] != '') {
        $date = date("Y/m/d", strtotime($subscription['expiration']));
        $template->set_var('expiration', $date);
    } else {
        $date = date("Y/m/d");
        $template->set_var('expiration', $date);
    }
    $template->set_var('price_label', $LANG_PAYPAL_1['price_label']);
    $template->set_var('price', $subscription['price']);
    $template->set_var('status_label', $LANG_PAYPAL_1['status']);
    $template->set_var('status', $subscription['status']);
    $template->set_var('add_to_group_label', $LANG_PAYPAL_1['add_to_group_label']);
    $template->set_var('add_to_group_options', COM_optionList($_TABLES['groups'], 'grp_id,grp_name', $subscription['add_to_group'], 1));
    $template->set_var('notification_label', $LANG_PAYPAL_1['notification']);
    $notification_select = '<select name="notification">';
    for ($i = 0; $i < 4; $i++) {
        $notification_select .= '<option value="' . $i . '"' . ($subscription['notification'] == $i ? 'selected="selected"' : '') . '>' . $i . '</option>';
    }
    $notification_select .= '</select>';
    $template->set_var('notification_select', $notification_select);
    $template->set_var('currency', $_PAY_CONF['currency']);
    //validation button
    $template->set_var('save_button', $LANG_PAYPAL_1['save_button']);
    $template->set_var('delete_button', $LANG_PAYPAL_1['delete_button']);
    $template->set_var('ok_button', $LANG_PAYPAL_1['ok_button']);
    $template->set_var('required_field', $LANG_PAYPAL_1['required_field']);
    $retval .= $template->parse('', 'subscription');
    $retval .= COM_endBlock();
    return $retval;
}
コード例 #2
0
/**
 * This function creates a product Form
 *
 * Creates a Form for a product using the supplied defaults (if specified).
 *
 * @param array $product array of values describing a proudct
 * @return string HTML string of product form
 */
function PAYPAL_getProductForm($product = array(), $type = 'product')
{
    global $_CONF, $_PAY_CONF, $LANG_PAYPAL_1, $LANG_PAYPAL_ADMIN, $LANG_PAYPAL_PRO, $_TABLES, $LANG24, $LANG_ADMIN, $LANG_ACCESS, $_USER, $_GROUPS, $_SCRIPTS;
    //PHP 5.4 set all $product[key]
    PAYPAL_setAllKeys($product, array('type', 'name', 'id', 'category', 'cat_id', 'short_description', 'description', 'item_id', 'price', 'price_ref', 'discount_a', 'discount_p', 'logged', 'hidden', 'active', 'show_in_blocks', 'customisable', 'product_type', 'file', 'weight', 'shipping_type', 'expiration', 'duration', 'duration_type', 'duration_recurrent', 'duration_type_recurrent', 'add_to_group', 'add_to_group_recurrent', 'perm_owner', 'owner_id', 'group_id', 'perm_group', 'perm_members', 'perm_anon'));
    //Validate product type
    if ($_REQUEST['type'] == '' && $product['type'] == '') {
        $type = 'product';
    }
    foreach ($_PAY_CONF['types'] as $item => $value) {
        $types[$item] = $item;
    }
    if (!in_array($type, $types)) {
        return $LANG_PAYPAL_1['wrong_type'];
    }
    //Display form
    $product['name'] == '' ? $display = COM_startBlock($LANG_PAYPAL_1['create_new_product']) : ($display = COM_startBlock($LANG_PAYPAL_1['edit_label'] . ' ' . $product['name']));
    $template = new Template($_CONF['path'] . 'plugins/paypal/templates');
    $template->set_file(array('product' => 'product_form.thtml'));
    $template->set_var('site_url', $_CONF['site_url']);
    $template->set_var('xhtml', XHTML);
    if ($_CONF['advanced_editor'] == 1) {
        $_SCRIPTS->setJavaScriptLibrary('jquery');
        $_SCRIPTS->setJavaScriptFile('ckeditor', '/editors/ckeditor/ckeditor.js');
        $ckeditor = '        var geeklogEditorName = "ckeditor";
        var geeklogAllowedHtml = [];
        jQuery(function() {
            CKEDITOR.replace( \'description\', {
             customConfig: \'' . $_CONF['site_url'] . '/editors/ckeditor/config.js\',
             toolbar: \'toolbar0\',
             height:500
            });
        });';
        $_SCRIPTS->setJavaScript($ckeditor, true);
    } else {
        $template->set_var('adveditor', '');
    }
    $product['product_type'] == '' ? $prod_type_ini = 2 : ($prod_type_ini = $product['product_type']);
    $js = 'jQuery(function () {
        var tabContainers = jQuery(\'div.tabs > div\');
        
        jQuery(\'div.tabs ul.tabNavigation a\').click(function () {
            tabContainers.hide().filter(this.hash).show();
            
            jQuery(\'div.tabs ul.tabNavigation a\').removeClass(\'selected\');
            jQuery(this).addClass(\'selected\');
            
            return false;
        }).filter(\':first\').click();
		
    });' . LB;
    $js .= "jQuery(document).ready(function() {\n\t\tjQuery('#load').hide();\n\t\t});\n\n\t\tjQuery(function() {\n\t\t\tjQuery(\".delete\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar pid = jQuery(this).attr(\"pid\");\n\t\t\t\tvar aid = jQuery(this).attr(\"aid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&pid=' + pid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#attributes_actions\").replaceWith(result);\n\t\t\t\t\t}   \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\tjQuery(\".add\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar pid = jQuery(this).attr(\"pid\");\n\t\t\t\tvar aid = jQuery(this).attr(\"aid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&pid=' + pid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#attributes_actions\").replaceWith(result);\n\t\t\t\t\t}   \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t});\n\t" . LB;
    //Hide #attributes if product not customisable
    if ($product['customisable'] == '0' || $product['customisable'] == '') {
        $js .= LB . "jQuery(document).ready(function() {\n\t\t    jQuery('#attributes_actions').hide();\n\t\t});" . LB;
    }
    if ($prod_type_ini == 2) {
        $js .= LB . "jQuery(document).ready(function() {\n\t\t    jQuery('#type_download').hide();\n\t\t});" . LB;
    }
    $js .= "\n\tfunction PP_changeCustomisable(value)\n\t{\n\t  switch(value) {\n\t  case '0':\n\t\tdocument.getElementById('attributes_actions').style.display = 'none';\n\t\tbreak;\n\t  case '1':\n\t\tdocument.getElementById('attributes_actions').style.display = '';\n\t\tbreak;\n\t  }\n\t}\n\n\t" . LB;
    $js .= "\n\tfunction PP_changeProdType(value)\n\t{\n\t  switch(value) {\n\t  case '0':\n\t\tdocument.getElementById('type_download').style.display = 'none';\n\t\tdocument.getElementById('type_physical').style.display = '';\n\t\tbreak;\n\t  case '1':\n\t\tdocument.getElementById('type_download').style.display = '';\n\t\tdocument.getElementById('type_physical').style.display = 'none';\n\t\tbreak;\n\t  case '2':\n\t\tdocument.getElementById('type_download').style.display = 'none';\n\t\tdocument.getElementById('type_physical').style.display = 'none';\n\t\tbreak;\n\t  }\n\t}\n\n\t" . LB;
    $_SCRIPTS->setJavaScriptLibrary('jquery');
    $_SCRIPTS->setJavaScript($js, true);
    //Product type
    if ($product['type'] != '') {
        $template->set_var('product_type', '<input type="hidden" name="type" value="' . $product['type'] . '" />');
    } else {
        $template->set_var('product_type', '<input type="hidden" name="type" value="' . $type . '" />');
    }
    //Product infos
    $template->set_var('informations', $LANG_PAYPAL_1['product_informations']);
    if ($_REQUEST['type'] == 'subscription' || $product['type'] == 'subscription') {
        $template->set_var('informations', $LANG_PAYPAL_1['membership_informations']);
    }
    $template->set_var('name_label', $LANG_PAYPAL_1['name_label']);
    $template->set_var('category_label', $LANG_PAYPAL_1['category_label']);
    $template->set_var('currency', $_PAY_CONF['currency']);
    if (is_numeric($product['id'])) {
        $template->set_var('id', '<input type="hidden" name="id" value="' . $product['id'] . '" />');
    } else {
        $template->set_var('id', '');
    }
    $template->set_var('name', $product['name']);
    //catogory
    $template->set_var('category', $product['category']);
    //categorie
    $categories = '';
    $categories .= '<option value="0">' . $LANG_PAYPAL_ADMIN['choose_category'] . '</option>';
    $categories .= PAYPAL_adOptionList($_TABLES['paypal_categories'], 'cat_id,cat_name', $product['cat_id'], 'cat_name', 'enabled=1');
    $template->set_var('categories', $categories);
    //Descriptions
    $template->set_var('short_description_label', $LANG_PAYPAL_1['short_description_label']);
    $template->set_var('short_description', strip_tags($product['short_description']));
    $template->set_var('description_label', $LANG_PAYPAL_1['description_label']);
    $template->set_var('description', $product['description']);
    //item_id
    $template->set_var('item_id_label', $LANG_PAYPAL_1['item_id_label']);
    $template->set_var('item_id', $product['item_id']);
    //Price
    $template->set_var('price_label', $LANG_PAYPAL_1['price_label']);
    if (empty($product['price']) || !is_numeric($product['price'])) {
        $template->set_var('price', 0);
    } else {
        $template->set_var('price', number_format($product['price'], $_CONF['decimal_count']));
    }
    $template->set_var('price_edit', $LANG_PAYPAL_1['price_edit']);
    //Price_ref
    $template->set_var('price_ref_label', $LANG_PAYPAL_1['price_ref_label']);
    if (empty($product['price_ref'])) {
        $template->set_var('price_ref', 0);
    } else {
        $template->set_var('price_ref', number_format($product['price_ref'], $_CONF['decimal_count']));
    }
    $template->set_var('price_ref_edit', $LANG_PAYPAL_1['price_ref_edit']);
    //Discount
    $template->set_var('discount_legend', $LANG_PAYPAL_1['discount_legend']);
    $template->set_var('discount_label', $LANG_PAYPAL_1['discount_label']);
    $template->set_var('discount_a_label', $LANG_PAYPAL_1['discount_a_label']);
    $template->set_var('discount_p_label', $LANG_PAYPAL_1['discount_p_label']);
    if (empty($product['discount_a'])) {
        $template->set_var('discount_a', 0);
    } else {
        $template->set_var('discount_a', number_format($product['discount_a'], $_CONF['decimal_count']));
    }
    if (empty($product['discount_p'])) {
        $template->set_var('discount_p', 0);
    } else {
        $template->set_var('discount_p', number_format($product['discount_p'], $_CONF['decimal_count']));
    }
    //access & display
    $template->set_var('access_display', $LANG_PAYPAL_1['access_display']);
    //logged
    $template->set_var('logged_to_purchase', $LANG_PAYPAL_1['logged_to_purchase']);
    if ($type == 'subscription' || $product['type'] == 'subscription') {
        $template->set_var('logged_yes', ' selected');
        $template->set_var('logged_no', ' disabled="disabled"');
    } else {
        if ($product['logged'] == 1) {
            $template->set_var('logged_yes', ' selected');
            $template->set_var('logged_no', '');
        } else {
            $template->set_var('logged_yes', '');
            $template->set_var('logged_no', ' selected');
        }
    }
    //hidden
    $template->set_var('hidden', $LANG_PAYPAL_1['hidden_product']);
    if ($product['hidden'] == 1) {
        $template->set_var('hidden_yes', ' selected');
        $template->set_var('hidden_no', '');
    } else {
        $template->set_var('hidden_yes', '');
        $template->set_var('hidden_no', ' selected');
    }
    //active
    $template->set_var('active', $LANG_PAYPAL_1['active_product']);
    !isset($product['active']) ? $product['active'] = 1 : NULL;
    if ($product['active'] == 1) {
        $template->set_var('active_yes', ' selected');
        $template->set_var('active_no', '');
    } else {
        $template->set_var('active_yes', '');
        $template->set_var('active_no', ' selected');
    }
    //Show in blocks
    $template->set_var('show_in_blocks', $LANG_PAYPAL_1['show_in_blocks']);
    !isset($product['show_in_blocks']) ? $product['show_in_blocks'] = 1 : NULL;
    if ($product['show_in_blocks'] == 1) {
        $template->set_var('show_in_blocks_yes', ' selected');
        $template->set_var('show_in_blocks_no', '');
    } else {
        $template->set_var('show_in_blocks_yes', '');
        $template->set_var('show_in_blocks_no', ' selected');
    }
    //customisable
    $template->set_var('customisation', $LANG_PAYPAL_ADMIN['customisation']);
    $template->set_var('customisable', $LANG_PAYPAL_ADMIN['customisable']);
    if (isset($product['customisable']) && $product['customisable'] == 1) {
        $template->set_var('customisable_yes', ' selected');
        $template->set_var('customisable_no', '');
    } else {
        $template->set_var('customisable_yes', '');
        $template->set_var('customisable_no', ' selected');
    }
    if (function_exists('PAYPALPRO_displayAttributes') && $product['id'] != '') {
        $template->set_var('attributes', PAYPALPRO_displayAttributes($product['id']));
        $template->set_var('add_attributes', PAYPALPRO_displayAttributesToAdd($product['id']));
    } else {
        if (function_exists('PAYPALPRO_displayAttributes')) {
            $template->set_var('attributes', '');
            $template->set_var('add_attributes', $LANG_PAYPAL_PRO['add_attributes']);
        } else {
            $template->set_var('attributes', '<p>' . $LANG_PAYPAL_PRO['pro_feature'] . '</p>');
            $template->set_var('add_attributes', '');
        }
    }
    //images
    $template->set_var('lang_images', $LANG_PAYPAL_1['product_images']);
    $fileinputs = '';
    $saved_images = '';
    if ($_PAY_CONF['max_images_per_products'] > 0) {
        if ($product['id'] != '') {
            $icount = DB_count($_TABLES['paypal_images'], 'pi_pid', $product['id']);
            if ($icount > 0) {
                $result_products = DB_query("SELECT * FROM {$_TABLES['paypal_images']} WHERE pi_pid = '" . $product['id'] . "'");
                for ($z = 1; $z <= $icount; $z++) {
                    $I = DB_fetchArray($result_products);
                    $saved_images .= '<div><p>' . $z . ') ' . '<a class="lightbox" href="' . $_PAY_CONF['images_url'] . $I['pi_filename'] . '"><img align="top" class="lightbox" src="' . $_PAY_CONF['site_url'] . '/timthumb.php?src=' . $_PAY_CONF['images_url'] . $I['pi_filename'] . '&amp;w=75&amp;h=75&amp;zc=1&amp;q=100" alt="' . $I['pi_filename'] . '" /></a>' . '&nbsp;&nbsp;&nbsp;' . $LANG_ADMIN['delete'] . ': <input type="checkbox" name="delete[' . $I['pi_img_num'] . ']"' . XHTML . '><br' . XHTML . '></p></div>';
                }
            }
        }
        $newallowed = $_PAY_CONF['max_images_per_products'] - $icount;
        for ($z = $icount + 1; $z <= $_PAY_CONF['max_images_per_products']; $z++) {
            $fileinputs .= $z . ') <input type="file" dir="ltr" name="file' . $z . '"' . XHTML . '> ';
            if ($z < $_PAY_CONF['max_images_per_products']) {
                $fileinputs .= '<br' . XHTML . '>';
            }
        }
    }
    $template->set_var('saved_images', $saved_images);
    $template->set_var('image_form_elements', $fileinputs);
    //delivery info
    $type != 'product' ? $template->set_var('display_product', 'display:none;') : $template->set_var('display_product', '');
    $template->set_var('delivery_info_label', $LANG_PAYPAL_ADMIN['delivery_info_label']);
    $template->set_var('prod_type', $LANG_PAYPAL_ADMIN['prod_type']);
    $template->set_var('prod_type_ini', $product['product_type']);
    $template->set_var('customisable_ini', $product['customisable']);
    $template->set_block('product', 'ProdTypeRadio', 'ProdType');
    foreach ($LANG_PAYPAL_ADMIN['prod_types'] as $value => $text) {
        $template->set_var(array('type_val' => $value, 'type_txt' => $text, 'type_sel' => $product['product_type'] == $value ? 'checked="checked"' : ''));
        $template->parse('ProdType', 'ProdTypeRadio', true);
    }
    //files
    $template->set_var('filename_label', $LANG_PAYPAL_1['filename_label']);
    $files = '';
    $files_folder = @opendir($_PAY_CONF['download_path']);
    if (!$files_folder) {
        $template->set_var('select_file', $LANG_PAYPAL_1['no_download_folder']);
        $template->set_var('file_selection', '');
    } else {
        while ($file = readdir($files_folder)) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $sel = $file == $product['file'] ? ' selected="selected" ' : '';
            $files .= "<option value=\"{$file}\" {$sel}>{$file}</option>\n";
        }
        closedir($files_folder);
        $template->set_var('select_file', $LANG_PAYPAL_1['select_file']);
        $template->set_var('file_selection', $files);
    }
    $template->set_var('upload_new', $LANG_PAYPAL_1['upload_new']);
    $template->set_var('expiration_label', $LANG_PAYPAL_1['expiration_label']);
    //weight
    $template->set_var('weight_label', $LANG_PAYPAL_ADMIN['weight']);
    if ($product['weight'] == '') {
        $product['weight'] = '0.000';
    }
    $template->set_var('weight', $product['weight']);
    $template->set_var('per_item', $LANG_PAYPAL_ADMIN['per_item']);
    //shipping
    $template->set_var('shipping_type', $LANG_PAYPAL_ADMIN['shipping_type']);
    $template->set_var('shipping_type_ini', $product['shipping_type']);
    $shipping_options = '';
    if ($product['shipping_type'] == 0) {
        $selected0 = ' selected="selected"';
        $selected1 = '';
    } else {
        $selected1 = ' selected="selected"';
        $selected0 = '';
    }
    $shipping_options .= '<option value="0"' . $selected0 . '>' . $LANG_PAYPAL_ADMIN['shipping_options'][0] . '</option>';
    $shipping_options .= '<option value="1"' . $selected1 . '>' . $LANG_PAYPAL_ADMIN['shipping_options'][1] . '</option>';
    $template->set_var('shipping_options', $shipping_options);
    $template->set_var('yes', $LANG_PAYPAL_1['yes']);
    $template->set_var('no', $LANG_PAYPAL_1['no']);
    $template->set_var('save_button', $LANG_PAYPAL_1['save_button']);
    $template->set_var('delete_button', $LANG_PAYPAL_1['delete_button']);
    $template->set_var('ok_button', $LANG_PAYPAL_1['ok_button']);
    $template->set_var('required_field', $LANG_PAYPAL_1['required_field']);
    if ($product['product_type'] == 1) {
        $template->set_var('download_yes', ' selected');
        $template->set_var('download_no', '');
    } else {
        $template->set_var('download_yes', '');
        $template->set_var('download_no', ' selected');
    }
    $template->set_var('file', $product['file']);
    $template->set_var('expiration', $product['expiration']);
    //Subscription
    $type != 'subscription' ? $template->set_var('display_subscription', 'display:none;') : $template->set_var('display_subscription', '');
    $template->set_var('subscription_product_label', $LANG_PAYPAL_1['subscription_label']);
    $template->set_var('duration_label', $LANG_PAYPAL_1['duration_label']);
    $template->set_var('duration', $product['duration']);
    $product['duration_type'] == 'day' ? $template->set_var('sel_day', ' selected="selected"') : '';
    $template->set_var('day', $LANG_PAYPAL_1['day']);
    $product['duration_type'] == 'week' ? $template->set_var('sel_week', ' selected="selected"') : '';
    $template->set_var('week', $LANG_PAYPAL_1['week']);
    $product['duration_type'] == 'month' ? $template->set_var('sel_month', ' selected="selected"') : '';
    $template->set_var('month', $LANG_PAYPAL_1['month']);
    $product['duration_type'] == 'year' ? $template->set_var('sel_year', ' selected="selected"') : '';
    $template->set_var('year', $LANG_PAYPAL_1['year']);
    //Recurrent
    if ($type != 'recurrent') {
        $template->set_var('display_recurrent', 'display:none;');
        $template->set_var('add_to_group_label', $LANG_PAYPAL_1['recurrent_add_to_group']);
    } else {
        $template->set_var('display_recurrent', '');
    }
    $template->set_var('recurrent_product_label', $LANG_PAYPAL_1['recurrent_product_label']);
    $template->set_var('add_to_group_label', $LANG_PAYPAL_1['recurrent_add_to_group']);
    $template->set_var('period_label', $LANG_PAYPAL_1['period_label']);
    $template->set_var('billing_label', $LANG_PAYPAL_1['billing_label']);
    $template->set_var('billingamt', $product['billingamt']);
    $template->set_var('frequency_label', $LANG_PAYPAL_1['frequency_label']);
    $template->set_var('frequency_help', $LANG_PAYPAL_1['frequency_help']);
    $template->set_var('duration_recurrent', $product['duration']);
    $product['duration_type'] == 'Day' ? $template->set_var('sel_recurrent_day', ' selected="selected"') : '';
    $template->set_var('recurrent_day', $LANG_PAYPAL_1['recurrent_day']);
    $product['duration_type'] == 'Week' ? $template->set_var('sel_recurrent_week', ' selected="selected"') : '';
    $template->set_var('recurrent_week', $LANG_PAYPAL_1['recurrent_week']);
    $product['duration_type'] == 'SemiMonth' ? $template->set_var('sel_recurrent_semimonth', ' selected="selected"') : '';
    $template->set_var('recurrent_semimonth', $LANG_PAYPAL_1['recurrent_semimonth']);
    $product['duration_type'] == 'Month' ? $template->set_var('sel_recurrent_month', ' selected="selected"') : '';
    $template->set_var('recurrent_month', $LANG_PAYPAL_1['recurrent_month']);
    $product['duration_type'] == 'Year' ? $template->set_var('sel_recurrent_year', ' selected="selected"') : '';
    $template->set_var('recurrent_year', $LANG_PAYPAL_1['recurrent_year']);
    //Group select list
    $template->set_var('add_to_group_options', COM_optionList($_TABLES['groups'], 'grp_id,grp_name', $product['add_to_group'], 1));
    // Permissions
    if ($product['perm_owner'] == '') {
        SEC_setDefaultPermissions($product, $_PAY_CONF['default_permissions']);
    }
    $template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $template->set_var('lang_owner', $LANG_ACCESS['owner']);
    if ($product['owner_id'] == '') {
        $product['owner_id'] = $_USER['uid'];
    }
    $ownername = COM_getDisplayName($product['owner_id']);
    $template->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$product['owner_id']}"));
    $template->set_var('owner_name', $ownername);
    $template->set_var('owner', $ownername);
    $template->set_var('owner_id', $product['owner_id']);
    if ($product['group_id'] == '') {
        $product['group_id'] = $_GROUPS['Paypal Admin'];
    }
    $template->set_var('lang_group', $LANG_ACCESS['group']);
    //Todo make group = paypal.admin
    $access = 3;
    $template->set_var('group_dropdown', SEC_getGroupDropdown($product['group_id'], $access));
    $template->set_var('permissions_editor', SEC_getPermissionsHTML($product['perm_owner'], $product['perm_group'], $product['perm_members'], $product['perm_anon']));
    $template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $display .= $template->parse('output', 'product');
    $display .= COM_endBlock();
    return $display;
}
コード例 #3
0
ファイル: index.php プロジェクト: Geeklog-Plugins/paypal
function PAYPAL_getShippingCostForm($shipping_cost = array())
{
    global $_CONF, $_PAY_CONF, $LANG_PAYPAL_1, $LANG_PAYPAL_ADMIN, $LANG_ACCESS, $_TABLES;
    //PHP 5.4 set all $shipping_cost[key]
    PAYPAL_setAllKeys($shipping_cost, array('shipping_id', 'shipping_shipper_id', 'shipping_cost_name', 'shipping_max', 'shipping_min', 'shipping_amt', 'shipping_destination_id'));
    //Display form
    $shipping_cost['shipping_cost_name'] == '' ? $retval = COM_startBlock($LANG_PAYPAL_ADMIN['create_shipping_cost']) : ($retval = COM_startBlock($LANG_PAYPAL_1['edit_label'] . ' ' . $shipping_cost['shipping_cost_name']));
    $template = COM_newTemplate($_CONF['path'] . 'plugins/paypal/templates');
    $template->set_file(array('shipping_cost' => 'shipping_cost_form.thtml'));
    if (is_numeric($shipping_cost['shipping_id'])) {
        $template->set_var(array('shipping_id' => '<input type="hidden" name="shipping_id" value="' . $shipping_cost['shipping_id'] . '" />', 'delete_button' => '<option value="delete_shipping_cost">' . $LANG_PAYPAL_1['delete_button'] . '</option>'));
        $creation = false;
    } else {
        $template->set_var(array('shipping_id' => '', 'delete_button' => ''));
        $creation = true;
    }
    if ($shipping_cost['shipping_max'] == '') {
        $shipping_cost['shipping_max'] = '0.000';
    }
    if ($shipping_cost['shipping_min'] == '') {
        $shipping_cost['shipping_min'] = '0.000';
    }
    if ($shipping_cost['shipping_amt'] == '') {
        $shipping_cost['shipping_amt'] = '0.00';
    }
    $template->set_var(array('shipping_amt' => $shipping_cost['shipping_amt'], 'shipping_max' => $shipping_cost['shipping_max'], 'shipping_min' => $shipping_cost['shipping_min'], 'shipping_max_label' => $LANG_PAYPAL_ADMIN['shipping_max'], 'shipping_min_label' => $LANG_PAYPAL_ADMIN['shipping_min'], 'shipping_amt_label' => $LANG_PAYPAL_ADMIN['shipping_amt'], 'shipper_label' => $LANG_PAYPAL_ADMIN['shipper_label'], 'destination_label' => $LANG_PAYPAL_ADMIN['shipping_to_label'], 'required_field' => $LANG_PAYPAL_1['required_field'], 'ok_button' => $LANG_PAYPAL_1['ok_button'], 'save_button' => $LANG_PAYPAL_1['save_button'], 'admin_url' => $_CONF['site_admin_url'], 'yes' => $LANG_PAYPAL_1['yes'], 'no' => $LANG_PAYPAL_1['no'], 'main_settings' => $LANG_PAYPAL_ADMIN['main_settings']));
    //shipper
    $shipper = '';
    $shipper .= '<option value="0">' . $LANG_PAYPAL_ADMIN['choose_shipper'] . '</option>';
    $shipper .= PAYPAL_adOptionList($_TABLES['paypal_shipper_service'], 'shipper_service_id, shipper_service_name, shipper_service_service', $shipping_cost['shipping_shipper_id'], 'shipper_service_name');
    $template->set_var('shipper', $shipper);
    //destination
    $destination = '';
    $destination .= '<option value="0">' . $LANG_PAYPAL_ADMIN['choose_destination'] . '</option>';
    $destination .= PAYPAL_adOptionList($_TABLES['paypal_shipping_to'], 'shipping_to_id, shipping_to_name', $shipping_cost['shipping_destination_id'], 'shipping_to_name');
    $template->set_var('destination', $destination);
    $retval .= $template->parse('output', 'shipping_cost');
    $retval .= COM_endBlock();
    return $retval;
}