function aff_config() { global $config; config_set_notebook_comment('Affiliates', 'affiliate program configuration'); add_config_field('aff.payout_methods', 'Accepted Payout methods', 'multi_select', "affiliate can choose a method for payout comissions.<br />\n If nothing will be selected, comissions will not be included to automated<br />\n payout report.\n ", "Affiliates", '', '', '', array('store_type' => 1, 'options' => aff_get_payout_methods())); add_config_field('aff.aff_commission', 'Affiliate commission for first payment', 'integer', "affiliate comissions for first payment, ex.: 1.5 or 2.5%", "Affiliates", '', '', ''); add_config_field('aff.aff_commission_rec', 'Affiliate commission for the following payments', 'integer', "affiliate comissions for the following payments, ex.: 1.5 or 2.5%", "Affiliates", '', '', ''); add_config_field('aff.aff_commission2', '2 Tier - Affiliate commission for the first payment', 'integer', 'affiliate comissions for referrer of the affiliate, can be set to<br /> percentage of commission received by immediate affiliate only, ex.: 1.5 or 15%<br /> in first case 2 tier affiliate will get USD 1.5 for each sale,<br /> in second case 2 tier affiliate will receive 15% of all related<br /> affiliate commissions', "Affiliates", '', '', ''); add_config_field('aff.aff_commission_rec2', '2 Tier - Affiliate commission for the following payments', 'integer', 'affiliate comissions for referrer of the affiliate, can be set to<br /> percentage of commission received by immediate affiliate only, ex.: 1.5 or 15%<br /> in first case 2 tier affiliate will get USD 1.5 for each sale,<br /> in second case 2 tier affiliate will receive 15% of all related<br /> affiliate commissions', "Affiliates", '', '', ''); add_config_field('aff.cookie_lifetime', 'Affiliate cookie lifetime', 'integer', "how long (in days) store cookies about referrer.<br />\n So if customer will return to the site later, comission will be<br />\n paid to referring affiliate.\n ", "Affiliates", '', '', '', array('default' => 365)); add_config_field('aff.only_first', 'Pay only first commission', 'checkbox', "affiliate will get commision only for first purchase.<br />\n In case of recurring payments, only one (first) commission will<br />\n be generated.\n ", "Affiliates", '', '', '', array('store_type' => 1)); add_config_field('aff.do_not_pay_for_free_subscriptions', 'Do not give commision for free subscriptions', 'select', "sale commission will not be credited to affiliate account<br />\n if user subscribed to free subscription. Of course, it only affects<br />\n 'fixed' affiliate commissions.\n ", "Affiliates", '', '', '', array('store_type' => 1, 'options' => array('' => 'Give Commission even for free subscriptions', 1 => 'Do not give commissions for free subscriptions'))); add_config_field('aff.signup_type', 'Affiliates Signup Type', 'select', "affiliate will get commision only for first purchase.<br />\n In case of recurring payments, only one (first) commission will<br />\n be generated.\n ", "Affiliates", '', '', '', array('store_type' => 1, 'options' => array('' => 'Default - user have to click link to become affiliate', 1 => 'All new members automatically become affiliates', 2 => 'Only admin can enable user as an affiliate'))); add_config_field('aff.mail_sale_admin', 'E-Mail commission to admin', 'checkbox', "when new sale commission credited to affiliate account<br />\n send an e-mail message to admin\n ", "Affiliates", '', 'email_checkbox_get', '', array('store_type' => 1)); add_config_field('aff.mail_sale_user', 'E-Mail commission to customer', 'checkbox', "when new sale commission credited to affiliate account<br />\n send an e-mail message to affiliate\n ", "Affiliates", '', 'email_checkbox_get', '', array('store_type' => 1)); add_config_field('aff.mail_signup_user', 'Send Signup E-Mail to Affiliate', 'checkbox', "send email when affiliate will signup\n ", "Affiliates", '', 'email_checkbox_get', '', array('store_type' => 1)); }
function display_payout_info($member_id, $u, $err = array()) { global $t, $config, $db; $t->assign('u', $u); $t->assign('error', $err); $t->assign('aff_payout_types', $m = aff_get_payout_methods(1)); $t->display("aff_payout_info.html"); }
function show_form() { global $t; global $error; global $db, $config, $vars; $t->assign('error', $error); plugin_fill_in_signup_form($_REQUEST); $t->assign('additional_fields_html', get_additional_fields_html($vars, 'affiliate_signup')); $t->assign('aff_payout_types', aff_get_payout_methods(1)); $is_affiliate = '2'; $newsletter_threads = $db->get_signup_threads_c($is_affiliate); $t->assign('newsletter_threads', $newsletter_threads); $t->display('aff_signup.html'); }
function display_edit_form($vars = array()) { global $member_id; global $db, $t; $u =& $db->get_user(intval($member_id)); global $member_additional_fields; if ($u['aff_id']) { $a = $db->get_user($u['aff_id']); $t->assign('aff', $a); } foreach ((array) $vars['data'] as $k => $v) { $u['data'][$k] = $v; } foreach ($vars as $k => $v) { if ($k != 'data') { $u[$k] = $v; } } $threads = $db->get_member_threads($member_id); $threads = array_keys($threads); $t->assign('u', $u); $t->assign('threads', $threads); $t->assign('threads_list', $db->get_newsletter_threads()); $t->assign('member_additional_fields', $member_additional_fields); $t->assign('additional_fields_html', get_additional_fields_html($u, 'admin', 1)); $t->assign('aff_payout_types', aff_get_payout_methods()); $t->display('admin/user_form.html'); }
} function get_default_ym() { $y = date('Y'); $m = date('m'); $m -= 2; if ($m <= 0) { $y--; $m = 12 - $m; } return "{$y}_{$m}"; } /*******************************************/ $t->assign('year_month_options', get_ym_options()); $t->assign('default_month', get_default_ym()); $t->assign('payout_methods', aff_get_payout_methods() + array('' => 'Not selected', 'ALL' => 'All payouts (for reporting)')); if ($vars['action'] == 'aff_payout_export') { $rand = $vars['payout_sess_id']; $rows = array(); foreach ($_SESSION['_amember_aff_commission'][$rand]['rows'] as $member_id => $to_pay) { $r = $db->get_user($member_id); $r['to_pay'] = $to_pay; $rows[] = $r; } $dat1 = $_SESSION['_amember_aff_commission'][$rand]['dat1']; $dat2 = $_SESSION['_amember_aff_commission'][$rand]['dat2']; $payout_method = $_SESSION['_amember_aff_commission'][$rand]['payout_method']; $func_name = 'aff_pay_commission_' . $payout_method; $func_name($dat1, $dat2, $payout_method, $rows); exit; }