コード例 #1
0
ファイル: gift_certificates.php プロジェクト: askzap/ultimate
function fn_update_gift_certificate($gift_cert_data, $gift_cert_id = 0, $params = array())
{
    fn_correct_gift_certificate($gift_cert_data);
    $gift_cert_data['products'] = !empty($gift_cert_data['products']) ? serialize($gift_cert_data['products']) : '';
    if (empty($gift_cert_id)) {
        do {
            $code = fn_generate_gift_certificate_code();
        } while (true == fn_check_gift_certificate_code($code));
        $gift_cert_data = fn_array_merge($gift_cert_data, array('gift_cert_code' => $code, 'timestamp' => TIME));
        if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
            $gift_cert_data['company_id'] = Registry::get('runtime.company_id');
        }
        $gift_cert_id = db_query("INSERT INTO ?:gift_certificates ?e", $gift_cert_data);
    } else {
        // Change certfificate status
        fn_change_gift_certificate_status($gift_cert_id, $gift_cert_data['status'], '', fn_get_notification_rules(array(), false));
        //if difference then add line in log
        $debit_info = db_get_row("SELECT debit AS amount, debit_products AS products FROM ?:gift_certificates_log WHERE gift_cert_id = ?i ORDER BY timestamp DESC", $gift_cert_id);
        if (empty($debit_info)) {
            $debit_info = db_get_row("SELECT amount, products FROM ?:gift_certificates WHERE gift_cert_id = ?i", $gift_cert_id);
        }
        $is_diff = $gift_cert_data['amount'] - $debit_info['amount'] != 0 || md5($gift_cert_data['products']) != md5($debit_info['products']);
        if ($is_diff == true) {
            $_info = array('amount' => $gift_cert_data['amount'], 'products' => $gift_cert_data['products']);
            fn_add_gift_certificate_log_record($gift_cert_id, $debit_info, $_info);
        }
        //Update certificate data
        $_data = $gift_cert_data;
        db_query("UPDATE ?:gift_certificates SET ?u WHERE gift_cert_id = ?i", $gift_cert_data, $gift_cert_id);
    }
    $gc_data = fn_get_gift_certificate_info($gift_cert_id);
    fn_gift_certificate_notification($gc_data, fn_get_notification_rules($params));
    return $gift_cert_id;
}
コード例 #2
0
ファイル: func.php プロジェクト: arpad9/bygmarket
function fn_create_return_gift_certificate($order_id, $amount)
{
    $min = Registry::get('addons.gift_certificates.min_amount') * 1;
    $max = Registry::get('addons.gift_certificates.max_amount') * 1;
    $order_info = fn_get_order_info($order_id);
    $templates = fn_get_gift_certificate_templates();
    $_data = array('send_via' => 'E', 'recipient' => "{$order_info['firstname']} {$order_info['lastname']}", 'sender' => Registry::get('settings.Company.company_name'), 'amount' => $amount, 'email' => $order_info['email'], 'address' => $order_info['s_address'], 'address_2' => $order_info['s_address_2'], 'city' => $order_info['s_city'], 'country' => $order_info['s_country'], 'state' => $order_info['s_state'], 'zipcode' => $order_info['s_zipcode'], 'phone' => $order_info['phone'], 'template' => key($templates));
    if (fn_allowed_for('ULTIMATE')) {
        $_data['company_id'] = Registry::ifGet('runtime.company_id', $order_info['company_id']);
    }
    do {
        $code = fn_generate_gift_certificate_code();
    } while (true == fn_check_gift_certificate_code($code));
    if ($amount < $min || $amount > $max) {
        fn_set_notification('E', __('error'), __('gift_cert_error_amount', array('[min]' => $min, '[max]' => $max)));
        $result = array();
    } else {
        $_data = fn_array_merge($_data, array('gift_cert_code' => $code, 'timestamp' => TIME));
        $gift_cert_id = db_query('INSERT INTO ?:gift_certificates ?e', $_data);
        $result = array($gift_cert_id => array('code' => $code, 'amount' => $amount));
    }
    return $result;
}
コード例 #3
0
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: gift_certificates.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Define trusted variables that shouldn't be stripped
    fn_trusted_vars('gift_cert_data');
    if ($mode == 'add') {
        if (!empty($_REQUEST['gift_cert_data'])) {
            do {
                $code = fn_generate_gift_certificate_code();
            } while (true == fn_check_gift_certificate_code($code));
            $gift_cert_data = $_REQUEST['gift_cert_data'];
            fn_correct_gift_certificate($gift_cert_data);
            $_data = fn_check_table_fields($gift_cert_data, 'gift_certificates');
            $_data = fn_array_merge($_data, array('gift_cert_code' => $code, 'timestamp' => TIME));
            if (!empty($_data['products'])) {
                $_data['products'] = serialize($_data['products']);
            }
            $gift_cert_id = db_query("INSERT INTO ?:gift_certificates ?e", $_data);
            $gift_cert_data = fn_get_gift_certificate_info($gift_cert_id);
            fn_gift_certificate_notification($gift_cert_data, fn_get_notification_rules($_REQUEST));
            $suffix = ".update?gift_cert_id={$gift_cert_id}";
        }
    }
    if ($mode == 'update') {
コード例 #4
0
ファイル: func.php プロジェクト: diedsmiling/busenika
function fn_create_return_gift_certificate($order_id, $amount)
{
    $order_info = fn_get_order_info($order_id);
    $templates = fn_get_gift_certificate_templates();
    $_data = array('send_via' => 'E', 'amount_type' => 'I', 'recipient' => "{$order_info['firstname']} {$order_info['lastname']}", 'sender' => Registry::get('settings.Company.company_name'), 'amount' => $amount, 'email' => $order_info['email'], 'address' => $order_info['s_address'], 'address_2' => $order_info['s_address_2'], 'city' => $order_info['s_city'], 'country' => $order_info['s_country'], 'state' => $order_info['s_state'], 'zipcode' => $order_info['s_zipcode'], 'phone' => $order_info['phone'], 'template' => key($templates));
    do {
        $code = fn_generate_gift_certificate_code();
    } while (true == fn_check_gift_certificate_code($code));
    $_data = fn_array_merge($_data, array('gift_cert_code' => $code, 'timestamp' => TIME));
    $gift_cert_id = db_query('INSERT INTO ?:gift_certificates ?e', $_data);
    return array($gift_cert_id => array('code' => $code, 'amount' => $amount));
}