if (!empty($_SESSION['new_products_id_in_cart']) && $_SESSION['new_products_id_in_cart'] == $productId) {
                 $content .= '<span class="newItemInCart">';
             } else {
                 $content .= '<span class="infoboxcontents">';
             }
             $content .= $product->getTitle() . '</span></a></td></tr>';
             if (!empty($_SESSION['new_products_id_in_cart']) && $_SESSION['new_products_id_in_cart'] == $productId) {
                 $_SESSION['new_products_id_in_cart'] = '';
             }
         }
         $content .= '</table>';
         if ($gvBalance = CommerceVoucher::getGiftAmount()) {
             $content .= '<table style="margin-top:10px;" cellpadding="0" width="100%" cellspacing="0" border="0"><tr><td class="smalltext">' . tra('Gift Certificate Balance') . '</td><td class="smalltext" align="right" valign="bottom">' . $gvBalance . '</td></tr></table>';
             $content .= '<table cellpadding="0" width="100%" cellspacing="0" border="0"><tr><td class="smalltext"><a href="' . zen_href_link(FILENAME_GV_SEND) . '">' . tra('Send Gift Certificate') . '</a></td></tr></table>';
         }
         if ($couponAmount = CommerceVoucher::getCouponAmount()) {
             $content .= '<table style="margin-top:10px;" cellpadding="0" width="100%" cellspacing="0" border="0"><tr><td class="smalltext">' . VOUCHER_REDEEMED . '</td><td class="smalltext" align="right" valign="bottom">' . $couponAmount . '</td></tr></table>';
         }
         if (!empty($_SESSION['cc_id'])) {
             $content .= '<table style="margin-top:10px;" cellpadding="0" width="100%" cellspacing="0" border="0"><tr><td class="smalltext">' . CART_COUPON . '</td><td class="smalltext" align="right" valign="bottom">' . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . CART_COUPON_INFO . '</a>' . '</td></tr></table>';
         }
     } else {
         $content = BOX_SHOPPING_CART_EMPTY;
     }
     if ($gBitCustomer->mCart->count_contents() > 0) {
         $content .= zen_draw_separator();
         $content .= $currencies->format($gBitCustomer->mCart->show_total());
     }
 } else {
     $content = '';
 }
Exemple #2
0
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,			 |
// | that is bundled with this package in the file LICENSE, and is				|
// | available through the world-wide-web at the following url:					 |
// | http://www.zen-cart.com/license/2_0.txt.														 |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to			 |
// | license@zen-cart.com so we can mail you a copy immediately.					|
// +----------------------------------------------------------------------+
//	$Id$
//
require 'includes/application_top.php';
$feedback = array();
if (!empty($_REQUEST['action'])) {
    if ($_REQUEST['action'] == 'delete') {
        //		$gBitUser->verifyTicket();
        $coupon = new CommerceVoucher($_REQUEST['gid']);
        $coupon->expunge();
        bit_redirect($_SERVER['SCRIPT_NAME']);
    }
}
$gBitSmarty->assign('feedback', $feedback);
$sql = "SELECT c.`coupon_id` AS `hash_key`, c.coupon_amount, c.coupon_code, c.coupon_id, c.admin_note, et.sent_firstname, et.sent_lastname, et.customer_id_sent, et.emailed_to, et.date_sent, rt.`customer_id`, rt.`redeem_date`, rt.`redeem_ip`, rt.`order_id`\n\t\tFROM " . TABLE_COUPONS . " c\n\t\t\tINNER JOIN " . TABLE_COUPON_EMAIL_TRACK . " et ON(c.coupon_id=et.coupon_id)\n\t\t\tLEFT JOIN " . TABLE_COUPON_REDEEM_TRACK . " rt ON(c.coupon_id=rt.coupon_id)\n\t\tORDER BY date_sent desc";
$couponList = array();
if ($rs = $gBitDb->query($sql)) {
    while ($row = $rs->fetchRow()) {
        $couponList[$row['hash_key']] = $row;
    }
}
$gBitSmarty->assign_by_ref('couponList', $couponList);
$gBitSystem->display('bitpackage:bitcommerce/admin_gv_sent.tpl', 'Gift Vouchers Sent', array('display_mode' => 'admin'));
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to		|
// | license@zen-cart.com so we can mail you a copy immediately.		|
// +----------------------------------------------------------------------+
//	$Id$
//
define('MAX_DISPLAY_RESTRICT_ENTRIES', 5);
require 'includes/application_top.php';
$restrict_array = array();
$restrict_array[] = array('id' => 'Deny', 'text' => 'Deny');
$restrict_array[] = array('id' => 'Allow', 'text' => 'Allow');
if (!empty($_REQUEST['cid'])) {
    $gCoupon = new CommerceVoucher($_REQUEST['cid']);
    $gCoupon->load(NULL, FALSE);
} else {
    $gCoupon = new CommerceVoucher();
}
if (!empty($_REQUEST['action']) && $gCoupon->isValid()) {
    switch ($_REQUEST['action']) {
        case 'switch_status':
            $status = $gBitDb->getOne("SELECT coupon_restrict FROM " . TABLE_COUPON_RESTRICT . " WHERE restrict_id = ?", array($_GET['info']));
            $new_status = $status == 'N' ? 'Y' : 'N';
            $gBitDb->query("UPDATE " . TABLE_COUPON_RESTRICT . " SET coupon_restrict = ? WHERE restrict_id = ?", array($new_status, $_GET['info']));
            bit_redirect($_SERVER['SCRIPT_NAME'] . '?cid=' . $gCoupon->mCouponId);
            break;
        case 'Add':
            $gCoupon->storeRestriction($_REQUEST);
            bit_redirect($_SERVER['SCRIPT_NAME'] . '?cid=' . $gCoupon->mCouponId);
            break;
        case 'remove':
            if (!empty($_GET['info'])) {
Exemple #4
0
        if ($gv_page->fields['order_id'] == $_GET['order']) {
            break;
        }
        $page_cnt++;
        $gv_page->MoveNext();
    }
    $_GET['page'] = round($page_cnt / MAX_DISPLAY_SEARCH_RESULTS);
    zen_redirect(zen_href_link_admin(FILENAME_GV_QUEUE, 'gid=' . $gv_id . '&page=' . $_GET['page']));
}
// eof: find gv for a particular order and set page
if ($_GET['action'] == 'confirmrelease' && BitBase::verifyId($_GET['gid'])) {
    $gv = $gBitDb->getRow("select release_flag from " . TABLE_COUPON_GV_QUEUE . " where unique_id=?", array($_GET['gid']));
    if ($gv['release_flag'] == 'N' && ($gv = $gBitDb->getRow("select customer_id, amount, order_id from " . TABLE_COUPON_GV_QUEUE . " where unique_id=?", array($_GET['gid'])))) {
        $fromUser = new BitUser($gv['customer_id']);
        $fromUser->load();
        if ($couponCode = CommerceVoucher::customerSendCoupon($fromUser, array('email' => $fromUser->getField('email'), 'to_name' => $fromUser->getDisplayName()), $gv['amount'])) {
            $gBitSmarty->assign('gvAmount', $currencies->format($gv['amount']));
            //send the message
            $textMessage = $gBitSmarty->fetch('bitpackage:bitcommerce/gv_purchase_email_text.tpl');
            $htmlMessage = $gBitSmarty->fetch('bitpackage:bitcommerce/gv_purchase_email_html.tpl');
            zen_mail($fromUser->getDisplayName(), $fromUser->getField('email'), TEXT_REDEEM_GV_SUBJECT . TEXT_REDEEM_GV_SUBJECT_ORDER . $gv['order_id'], $textMessage, STORE_NAME, EMAIL_FROM, $htmlMessage, 'gv_queue');
            $gBitDb->Execute("update " . TABLE_COUPON_GV_QUEUE . "\n\t\t\t\t\t\t  set `release_flag`= 'Y'\n\t\t\t\t\t\t  where `unique_id`='" . $_GET['gid'] . "'");
        }
        bit_redirect(BITCOMMERCE_PKG_URL . 'admin/gv_queue.php');
    }
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php 
echo HTML_PARAMS;
?>
Exemple #5
0
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | license@zen-cart.com so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
// $Id$
//
require_once BITCOMMERCE_PKG_PATH . 'classes/CommerceVoucher.php';
if (!$gBitUser->isRegistered()) {
    $_SESSION['navigation']->set_snapshot();
    zen_redirect(FILENAME_LOGIN);
}
// check for a voucher number in the url
if (isset($_REQUEST['gv_no'])) {
    if (!empty($_REQUEST['gv_no']) && ($couponAmount = CommerceVoucher::redeemCoupon($gBitUser->mUserId, $_REQUEST['gv_no']))) {
        $_SESSION['gv_id'] = '';
        $feedback['success']['valid'] = sprintf(TEXT_VALID_GV, $currencies->format($couponAmount)) . ' ' . tra('If you would like, you can use your balance to <a href="' . BITCOMMERCE_PKG_URL . 'index.php?main_page=gv_send">send a gift certificate to someone else</a>.');
    } else {
        $feedback['error']['invalid'] = TEXT_INVALID_GV;
    }
}
$breadcrumb->add(NAVBAR_TITLE);
$gBitSmarty->assign('feedback', $feedback);
print $gBitSmarty->fetch('bitpackage:bitcommerce/gv_redeem.tpl');
Exemple #6
0
    $requestAmountValue = $currencies->value($requestAmount, true, DEFAULT_CURRENCY);
}
$gvBalance = CommerceVoucher::getGiftAmount(FALSE);
if ($requestAction == 'send') {
    $_SESSION['complete'] = '';
    if (!zen_validate_email(trim($_POST['email']))) {
        $feedback['error']['error_email'] = ERROR_ENTRY_EMAIL_ADDRESS_CHECK;
    }
    if (!is_numeric($requestAmount) || $requestAmountValue > $gvBalance) {
        $feedback['error']['error_amount'] = ERROR_ENTRY_AMOUNT_CHECK;
    }
} elseif ($requestAction == 'process') {
    if ($couponCode = CommerceVoucher::customerSendCoupon($gBitUser, $_POST, $requestAmountValue)) {
        $requestAction = 'complete';
        // do a fresh calculation after sending an email
        $gvBalance = CommerceVoucher::getGiftAmount(FALSE);
    } else {
        $feedback['error']['error_amount'] = ERROR_ENTRY_AMOUNT_CHECK;
        $requestAction = 'send';
    }
}
$gBitSmarty->assign('gvBalance', $currencies->format($gvBalance, true));
if ($requestAction == 'complete') {
    zen_redirect(zen_href_link(FILENAME_GV_SEND, 'action=doneprocess'));
}
$breadcrumb->add(NAVBAR_TITLE);
if ($requestAction == 'doneprocess') {
    $feedback['success'] = tra(TEXT_SUCCESS);
} elseif ($requestAction == 'send' && empty($formfeedback['error'])) {
    // validate entries
    $gvAmount = $currencies->format($requestAmount, false);
Exemple #7
0
<?php

// +--------------------------------------------------------------------+
// | Copyright (c) 2007 bitcommerce.org									|
// | http://www.bitcommerce.org											|
// +--------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license		|
// +--------------------------------------------------------------------+
/**
 * @version	$Header$
 *
 * System class for handling the liberty package
 *
 * @package	bitcommerce
 * @author	 spider <*****@*****.**>
 */
require_once BITCOMMERCE_PKG_PATH . 'classes/CommerceVoucher.php';
global $gBitSmarty;
$gBitSmarty->assign('gvBalance', CommerceVoucher::getGiftAmount());
$gBitSmarty->assign('couponAmount', CommerceVoucher::getCouponAmount());
if (!empty($messageStack) && $messageStack->size('account') > 0) {
    $gBitSmarty->assign('accountMessage', $messageStack->output('account'));
}
$gBitSmarty->display('bitpackage:bitcommerce/page_account.tpl');
 function redeemCoupon($pCustomerId, $pCode)
 {
     global $gBitDb;
     $ret = FALSE;
     if (!empty($pCode)) {
         $error = true;
         $gv_query = "SELECT `coupon_id`, `coupon_amount` FROM " . TABLE_COUPONS . " WHERE `coupon_code` = ? AND `coupon_active`='Y'";
         if ($coupon = $gBitDb->getRow($gv_query, array($pCode))) {
             $redeem_query = "SELECT coupon_id FROM " . TABLE_COUPON_REDEEM_TRACK . " WHERE coupon_id = ?";
             $isRedeemed = $gBitDb->getOne($redeem_query, array($coupon['coupon_id']));
             if (!$isRedeemed) {
                 // check for required session variables
                 $_SESSION['gv_id'] = $coupon['coupon_id'];
                 $error = false;
             }
         }
         if (!$error) {
             // Update redeem status
             $gBitDb->StartTrans();
             $gv_query = "insert into  " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip)\n\t\t\t\t\t\t\tvalues ( ?, ?, now(), ? )";
             $gBitDb->query($gv_query, array($coupon['coupon_id'], $pCustomerId, $_SERVER['REMOTE_ADDR']));
             $gv_update = "update " . TABLE_COUPONS . "\n\t\t\t\t\t\t\tset coupon_active = 'N'\n\t\t\t\t\t\t\twhere coupon_id = ?";
             $gBitDb->query($gv_update, array($coupon['coupon_id']));
             CommerceVoucher::updateCustomerBalance($pCustomerId, $_SESSION['gv_id']);
             $gBitDb->CompleteTrans();
             $ret = $coupon['coupon_amount'];
         }
     }
     return $ret;
 }
Exemple #9
0
// | license@zen-cart.com so we can mail you a copy immediately.
// +----------------------------------------------------------------------+
//	$Id$
//
require 'includes/application_top.php';
$feedback = array();
if (!empty($_REQUEST['selected_box'])) {
    $_REQUEST['action'] = '';
    $_REQUEST['old_action'] = '';
}
$getAction = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
if (!empty($_REQUEST['cid'])) {
    $gCoupon = new CommerceVoucher($_REQUEST['cid']);
    $gCoupon->load(NULL, FALSE);
} else {
    $gCoupon = new CommerceVoucher();
}
switch ($getAction) {
    case 'delete':
        if ($gCoupon->isValid()) {
            // confirm first
            if (isset($_REQUEST["confirm"])) {
                $feedback['success'] = tra('Coupon deleted:') . ' ' . $gCoupon->getField('coupon_code');
                $gCoupon->expunge();
            } else {
                //				$gBitSystem->setBrowserTitle( tra('Confirm removal of') . ' ' . $gContent->getTitle()); // crossposting from Blog \''.'addblognamehere'.'\'' );
                $formHash['action'] = 'delete';
                $formHash['cid'] = $_REQUEST['cid'];
                $msgHash = array('label' => 'Delete Coupon', 'confirm_item' => $gCoupon->getField('coupon_code') . ' - ' . $gCoupon->getField('coupon_description'), 'warning' => tra('This cannot be undone!'));
                $gBitSystem->confirmDialog($formHash, $msgHash);
            }
Exemple #10
0
 function calculate_deductions($order_total)
 {
     global $gBitDb, $gBitCustomer, $order;
     $tax_address = zen_get_tax_locations();
     $od_amount['total'] = 0;
     $od_amount['tax'] = 0;
     if ($_SESSION['cc_id']) {
         $coupon = new CommerceVoucher($_SESSION['cc_id']);
         if ($coupon->load() && $coupon->isRedeemable()) {
             if ($coupon->getField('coupon_minimum_order') <= $order_total) {
                 if ($coupon->getField('coupon_type') == 'S') {
                     if ($coupon->getField('restrict_to_shipping')) {
                         $shippingMethods = explode(',', $coupon->getField('restrict_to_shipping'));
                         if (in_array($order->info['shipping_method_code'], $shippingMethods)) {
                             $od_amount['total'] = $order->info['shipping_cost'];
                         }
                     } else {
                         $od_amount['total'] = $order->info['shipping_cost'];
                     }
                     $od_amount['type'] = 'S';
                 } else {
                     if ($coupon->getField('coupon_type') == 'P') {
                         // Max discount is a sum of percentages of valid products
                         $totalDiscount = 0;
                     } else {
                         $totalDiscount = $coupon->getField('coupon_amount') * ($order_total > 0);
                     }
                     $runningDiscount = 0;
                     $runningDiscountQuantity = 0;
                     foreach (array_keys($gBitCustomer->mCart->contents) as $productKey) {
                         $productHash = $gBitCustomer->mCart->getProductHash($productKey);
                         if ($coupon->getField('quantity_max')) {
                             if ($discountQuantity = $coupon->getField('quantity_max') - $runningDiscountQuantity) {
                                 if ($discountQuantity > $productHash['products_quantity']) {
                                     $discountQuantity = $productHash['products_quantity'];
                                 }
                             }
                         } else {
                             $discountQuantity = $productHash['products_quantity'];
                         }
                         if ($productHash && $discountQuantity && $this->is_product_valid($productHash, $_SESSION['cc_id'])) {
                             // _P_ercentage discount
                             if ($coupon->getField('coupon_type') == 'P') {
                                 $runningDiscountQuantity += $discountQuantity;
                                 $itemDiscount = round($productHash['final_price'] * $discountQuantity * ($coupon->getField('coupon_amount') / 100), 2);
                                 $totalDiscount += $itemDiscount;
                                 if ($runningDiscount < $totalDiscount) {
                                     $runningDiscount += $itemDiscount;
                                 }
                                 if ($runningDiscount > $totalDiscount) {
                                     $runningDiscount = $totalDiscount;
                                     $itemDiscount = 0;
                                 }
                                 switch ($this->calculate_tax) {
                                     case 'Credit Note':
                                         $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $od_amount[$tax_desc] = $runningDiscount / 100 * $tax_rate;
                                         $od_amount['tax'] += $od_amount[$tax_desc];
                                         break;
                                     case 'Standard':
                                         $ratio = $runningDiscount / $this->get_order_total();
                                         $tax_rate = zen_get_tax_rate($productHash['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($productHash['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                         if ($tax_rate > 0) {
                                             if (empty($od_amount[$tax_desc])) {
                                                 $od_amount[$tax_desc] = 0;
                                             }
                                             $od_amount[$tax_desc] += $productHash['final_price'] * $discountQuantity * $tax_rate / 100 * $ratio;
                                             $od_amount['tax'] += $od_amount[$tax_desc];
                                         }
                                         break;
                                 }
                                 // _F_ixed discount
                             } elseif ($coupon->getField('coupon_type') == 'F') {
                                 switch ($this->calculate_tax) {
                                     case 'Credit Note':
                                         $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $od_amount[$tax_desc] = $runningDiscount / 100 * $tax_rate;
                                         $od_amount['tax'] += $od_amount[$tax_desc];
                                         break;
                                     case 'Standard':
                                         $ratio = $runningDiscount / $this->get_order_total();
                                         $t_prid = zen_get_prid($productKey);
                                         $cc_result = $gBitDb->query("select `products_tax_class_id` from " . TABLE_PRODUCTS . " where `products_id` = ?", array($t_prid));
                                         if ($this->is_product_valid($productHash, $_SESSION['cc_id'])) {
                                             if ($runningDiscount < $totalDiscount) {
                                                 $runningDiscount += $productHash['final_price'] * $discountQuantity;
                                             }
                                             if ($runningDiscount > $totalDiscount) {
                                                 $runningDiscount = $totalDiscount;
                                             }
                                             $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                             $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                             if ($tax_rate > 0) {
                                                 if (empty($od_amount[$tax_desc])) {
                                                     $od_amount[$tax_desc] = 0;
                                                 }
                                                 $od_amount[$tax_desc] += $productHash['final_price'] * $discountQuantity * $tax_rate / 100 * $ratio;
                                                 $od_amount['tax'] += $od_amount[$tax_desc];
                                             }
                                         }
                                         break;
                                 }
                             }
                         }
                     }
                     $od_amount['total'] = $runningDiscount;
                     if ($od_amount['total'] > $order_total) {
                         $od_amount['total'] = $order_total;
                     }
                 }
             }
         }
     }
     return $od_amount;
 }
Exemple #11
0
require_once BITCOMMERCE_PKG_PATH . 'classes/CommerceOrder.php';
require_once BITCOMMERCE_PKG_PATH . 'classes/CommerceVoucher.php';
$_REQUEST['amount'] = !empty($_REQUEST['amount']) ? preg_replace('/[^\\d.]/', '', $_REQUEST['amount']) : NULL;
if (!empty($_GET['action'])) {
    if ($_GET['action'] == 'set_editor') {
        if ($_GET['reset_editor'] == '0') {
            $_SESSION['html_editor_preference_status'] = 'NONE';
        } else {
            $_SESSION['html_editor_preference_status'] = 'HTMLAREA';
        }
        $action = '';
        zen_redirect(zen_href_link_admin(FILENAME_GV_MAIL));
    }
    if ($_GET['action'] == 'send_email_to_user' && (!empty($_REQUEST['customers_email_address']) || !empty($_REQUEST['email_to'])) && empty($_REQUEST['back'])) {
        if (!empty($_REQUEST['send_gv'])) {
            $voucher = new CommerceVoucher();
            $voucher->adminSendCoupon($_REQUEST);
            if (!empty($_REQUEST['oID'])) {
                zen_redirect(zen_href_link_admin(FILENAME_ORDERS, 'oID=' . $_REQUEST['oID']));
            } else {
                zen_redirect(zen_href_link_admin(FILENAME_GV_SENT));
            }
        }
    }
    if ($_GET['action'] == 'preview' && empty($_REQUEST['customers_email_address']) && empty($_REQUEST['email_to'])) {
        $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
    }
    if ($_GET['action'] == 'preview' && empty($_REQUEST['subject'])) {
        $messageStack->add(ERROR_NO_SUBJECT, 'error');
    }
    if ($_GET['action'] == 'preview' && $_REQUEST['amount'] <= 0) {