示例#1
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: partners.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    return;
}
if (!empty($auth['user_id'])) {
    $partner_data = fn_get_partner_data($auth['user_id']);
    if (!empty($partner_data)) {
        $titles = fn_get_static_data_section('T');
        if (!empty($titles) && is_array($titles)) {
            foreach ($titles as $t) {
                if (!empty($t['param']) && $t['param'] == @$partner_data['title']) {
                    $partner_data['title_descr'] = $t['descr'];
                }
            }
        }
        $partner_data['total_payouts'] = db_get_field("SELECT SUM(amount) FROM ?:affiliate_payouts WHERE partner_id = ?i", $auth['user_id']);
        $cnt_period = Registry::if_get('addons.affiliate.number_last_periods', 10);
        $start_date = fn_get_date_of_payment_period($cnt_period);
        if (!empty($start_date)) {
            $last_payouts = array();
            $k = $cnt_period;
示例#2
0
    }
    $payouts_cnt = db_get_field("SELECT COUNT(*) FROM ?:affiliate_payouts LEFT JOIN ?:users ON ?:affiliate_payouts.partner_id = ?:users.user_id WHERE ?p AND user_id = ?i", 'payout_id', $payout_search_condition, $auth['user_id']);
    $limit = fn_paginate(@$_REQUEST['page'], $payouts_cnt, Registry::get('settings.Appearance.admin_elements_per_page'));
    // FIXME: page
    $payouts = db_get_hash_array("SELECT ?:affiliate_payouts.*, ?:users.user_login, ?:users.firstname, ?:users.lastname FROM ?:affiliate_payouts LEFT JOIN ?:users ON ?:affiliate_payouts.partner_id=?:users.user_id WHERE ?p AND ?:users.user_id = ?i ORDER BY {$sorting} {$limit}", 'payout_id', $payout_search_condition, $auth['user_id']);
    $view->assign('payouts', $payouts);
} elseif ($mode == 'update') {
    if (empty($_REQUEST['payout_id'])) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    } else {
        $payout_data = db_get_row("SELECT * FROM ?:affiliate_payouts WHERE payout_id = ?i", $_REQUEST['payout_id']);
        if (empty($payout_data)) {
            return array(CONTROLLER_STATUS_NO_PAGE);
        } else {
            if (!empty($payout_data['partner_id'])) {
                $payout_data['partner'] = fn_get_partner_data($payout_data['partner_id']);
            }
            if (!empty($payout_data['partner']['plan_id'])) {
                $payout_data['plan'] = fn_get_affiliate_plan_data($payout_data['partner']['plan_id']);
            }
            $payout_data['actions'] = fn_get_affiliate_actions($_REQUEST);
            $payout_data['date_range']['min'] = db_get_field("SELECT MIN(date) FROM ?:aff_partner_actions WHERE payout_id = ?i", $_REQUEST['payout_id']);
            $payout_data['date_range']['max'] = db_get_field("SELECT MAX(date) FROM ?:aff_partner_actions WHERE payout_id = ?i", $_REQUEST['payout_id']);
            // [Breadcrumbs]
            fn_add_breadcrumb(fn_get_lang_var('payouts'), "payouts.manage");
            // [/Breadcrumbs]
            $view->assign('affiliate_plan', fn_get_affiliate_plan_data_by_partner_id($auth['user_id']));
            $view->assign('payouts', array($payout_data['partner_id'] => $payout_data));
        }
        $view->assign('sort_order', empty($sort_order) || $sort_order == 'asc' ? 'desc' : 'asc');
        $view->assign('sort_by', empty($sort_by) ? 'date' : $sort_by);
示例#3
0
                    $p_data = array('approved' => 'D');
                    $update_result = fn_update_partner_profile($partner_id, $p_data);
                    if ($update_result) {
                        $user_data = fn_get_user_info($partner_id, false);
                        $view_mail->assign('user_data', $user_data);
                        // Send notification to partners
                        fn_send_mail($user_data['email'], Registry::get('settings.Company.company_users_department'), 'affiliate/declined_subj.tpl', 'affiliate/declined_body.tpl');
                    }
                }
            }
        }
    }
    return array(CONTROLLER_STATUS_REDIRECT, "partners.manage");
}
if ($mode == 'update' && !empty($_REQUEST['user_id'])) {
    $partner_data = fn_get_partner_data($_REQUEST['user_id']);
    if (empty($partner_data)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    // [Breadcrumbs]
    fn_add_breadcrumb(fn_get_lang_var('affiliates'), "partners.manage.reset_view");
    fn_add_breadcrumb(fn_get_lang_var('search_results'), "partners.manage.last_view");
    // [/Breadcrumbs]
    $titles = fn_get_static_data_section('T');
    if (!empty($titles) && is_array($titles)) {
        foreach ($titles as $t) {
            if (!empty($t['param']) && $t['param'] == @$partner_data['title']) {
                $partner_data['title_descr'] = $t['descr'];
            }
        }
    }
示例#4
0
function fn_affiliate_form_cart($order_info, &$cart)
{
    $_partner_data = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'A'", $order_info['order_id']);
    if (!empty($_partner_data)) {
        $_partner_data = unserialize($_partner_data);
        if (!empty($_partner_data['partner_id'])) {
            $cart['affiliate']['partner_id'] = $_partner_data['partner_id'];
            $cart['affiliate']['code'] = fn_dec2any($cart['affiliate']['partner_id']);
            if ($partner_data = fn_get_partner_data($_partner_data['partner_id'])) {
                $cart['affiliate']['firstname'] = $partner_data['firstname'];
                $cart['affiliate']['lastname'] = $partner_data['lastname'];
            }
        }
    }
    $_paid_commissions = fn_get_commissions_4_order($order_info['order_id'], true);
    $cart['affiliate']['is_payouts'] = empty($_paid_commissions) ? 'N' : 'Y';
}
示例#5
0
function fn_add_payouts($params, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = fn_init_view('pay_affiliates', $params);
    // Set default values to input params
    $params['page'] = empty($params['page']) ? 1 : $params['page'];
    // default page is 1
    // Define sort fields
    $sortings = array('action' => "actions.action", 'date' => "actions.date", 'cost' => "actions.amount", 'banner' => "banner");
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'desc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'date';
    }
    $sorting = (is_array($sortings[$params['sort_by']]) ? implode(' ' . $directions[$params['sort_order']] . ', ', $sortings[$params['sort_by']]) : $sortings[$params['sort_by']]) . " " . $directions[$params['sort_order']];
    // Reverse sorting (for usage in view)
    $params['sort_order'] = $params['sort_order'] == 'asc' ? 'desc' : 'asc';
    $new_payouts = array();
    if (!empty($params['partner_ids'])) {
        $date_condition = "";
        if (!empty($params['last_payout']) && !empty($params['time_from'])) {
            $date_condition = db_quote(" AND date < ?i", $params['time_from']);
        }
        foreach ($params['partner_ids'] as $_partner_id) {
            $condition = "1 " . $date_condition . db_quote(" AND approved = 'Y' AND payout_id = 0 AND partner_id = ?i", $_partner_id);
            $new_payouts[$_partner_id]['amount'] = db_get_field("SELECT SUM(amount) FROM ?:aff_partner_actions WHERE {$condition}");
            if (empty($new_payouts[$_partner_id]['amount'])) {
                unset($new_payouts[$_partner_id]);
            } else {
                $new_payouts[$_partner_id]['partner'] = fn_get_partner_data($_partner_id);
                if (!empty($new_payouts[$_partner_id]['partner']['plan_id'])) {
                    $new_payouts[$_partner_id]['plan'] = fn_get_affiliate_plan_data($new_payouts[$_partner_id]['partner']['plan_id'], $lang_code);
                }
                $_params = array('sort_by' => $params['sort_by'], 'sort_order' => $params['sort_order'] == 'asc' ? 'desc' : 'asc');
                $new_payouts[$_partner_id]['actions'] = fn_get_affiliate_actions($condition, $_params, true, @$params['page']);
                $new_payouts[$_partner_id]['date_range']['min'] = db_get_field("SELECT MIN(date) FROM ?:aff_partner_actions WHERE {$condition}");
                $new_payouts[$_partner_id]['date_range']['max'] = db_get_field("SELECT MAX(date) FROM ?:aff_partner_actions WHERE {$condition}");
            }
        }
    }
    return array($new_payouts, $params);
}