Exemplo n.º 1
0
    }
    if ($mode == 'add' || $mode == 'update') {
        if (isset($_REQUEST['reward_points'])) {
            foreach ($_REQUEST['reward_points'] as $k => $v) {
                if (fn_allowed_for('ULTIMATE')) {
                    if (!Registry::get('runtime.company_id')) {
                        if (!empty($v['update_all_vendors'])) {
                            $companies = fn_get_short_companies();
                            foreach ($companies as $company_id => $name) {
                                fn_add_reward_points($v, 0, GLOBAL_REWARD_POINTS, $company_id);
                            }
                        }
                        continue;
                    }
                }
                fn_add_reward_points($v, 0, GLOBAL_REWARD_POINTS);
            }
        }
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['change_id'])) {
            db_query("DELETE FROM ?:reward_point_changes WHERE change_id = ?i", $_REQUEST['change_id']);
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'reward_points.userlog?user_id=' . $_REQUEST['user_id']);
    }
    return array(CONTROLLER_STATUS_OK, 'reward_points.manage');
}
if ($mode == 'manage') {
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    Registry::get('view')->assign('reward_points', fn_get_reward_points(0, GLOBAL_REWARD_POINTS));
Exemplo n.º 2
0
function fn_reward_points_update_category_post(&$category_data, &$category_id)
{
    if (isset($category_data['reward_points']) && $category_data['is_op'] == 'Y') {
        foreach ($category_data['reward_points'] as $v) {
            fn_add_reward_points($v, $category_id, CATEGORY_REWARD_POINTS);
        }
    }
}
Exemplo n.º 3
0
                }
            }
        }
        //
        // Override multiple products with the one value
        //
    } elseif ($mode == 'do_m_override') {
        if (!empty($_REQUEST['product_ids'])) {
            foreach ($_REQUEST['product_ids'] as $product_id => $value) {
                if (isset($_REQUEST['override_products_points']['point_price'])) {
                    fn_add_price_in_points(array('point_price' => $_REQUEST['override_products_points']['point_price']), $product_id);
                }
                if (isset($_REQUEST['override_reward_points'])) {
                    foreach ((array) $_REQUEST['override_reward_points'] as $usergroup_id => $amount) {
                        $data = array('amount' => $amount, 'usergroup_id' => $usergroup_id);
                        fn_add_reward_points($data, $product_id, PRODUCT_REWARD_POINTS);
                    }
                }
            }
        }
    }
    return;
}
//
// 'Management' page
//
if ($mode == 'manage') {
    $selected_fields = Registry::get('view')->getTemplateVars('selected_fields');
    $selected_fields[] = array('name' => '[data][is_pbp]', 'text' => __('pay_by_points'));
    if (Registry::get('addons.reward_points.auto_price_in_points') == 'Y') {
        $selected_fields[] = array('name' => '[data][is_oper]', 'text' => __('override_per'));