} else {
             $content .= '<span class="infoboxcontents">';
         }
         $content .= $gBitCustomer->mCart->contents[$productKey]['products_quantity'] . '&nbsp;x&nbsp;</span></td><td valign="top" class="infoboxcontents"><a href="' . CommerceProduct::getDisplayUrlFromId(zen_get_prid($productId)) . '">';
         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());
Exemple #2
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');
Exemple #3
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);
 function customerSendCoupon($pFromUser, $pRecipient, $pAmount)
 {
     global $gBitDb, $gBitSmarty, $gCommerceSystem, $currencies;
     $ret = NULL;
     $gBitDb->StartTrans();
     $code = CommerceVoucher::generateCouponCode();
     $gvBalance = CommerceVoucher::getGiftAmount(FALSE);
     $newBalance = $gvBalance - $pAmount;
     if ($new_amount < 0) {
         $error = ERROR_ENTRY_AMOUNT_CHECK;
     } else {
         $gv_query = "UPDATE " . TABLE_COUPON_GV_CUSTOMER . "\n\t\t\t\t\t\t SET `amount` = ?\n\t\t\t\t\t\t WHERE `customer_id` = ?";
         $gBitDb->query($gv_query, array($newBalance, $pFromUser->mUserId));
         $gv_query = "INSERT INTO " . TABLE_COUPONS . " (`coupon_type`, `coupon_code`, `date_created`, `coupon_amount`) values ('G', ?, NOW(), ?)";
         $gv = $gBitDb->query($gv_query, array($code, $pAmount));
         $gvId = zen_db_insert_id(TABLE_COUPONS, 'coupon_id');
         $gv_query = "insert into " . TABLE_COUPON_EMAIL_TRACK . "\t(`coupon_id`, `customer_id_sent`, `emailed_to`, `date_sent`)\n\t\t\t\t\t\tvalues ( ?, ?, ?, now())";
         $gBitDb->query($gv_query, array($gvId, $pFromUser->mUserId, $pRecipient['email']));
         $ret = $code;
         $gv_email_subject = tra('A gift from') . ' ' . $pFromUser->getDisplayName() . ' ' . tra('to') . ' ' . $gCommerceSystem->getConfig('STORE_NAME');
         $gBitSmarty->assign('gvCode', $code);
         $gBitSmarty->assign('gvSender', $pFromUser->getDisplayName());
         $gBitSmarty->assign('gvAmount', $currencies->format($pAmount, false));
         $gBitSmarty->assign('gvRedeemUrl', BITCOMMERCE_PKG_URI . 'index.php?main_page=gv_redeem&gv_no=' . $code);
         if (!empty($pRecipient['message'])) {
             $gBitSmarty->assign('gvMessage', $pRecipient['message']);
         }
         $textMessage = $gBitSmarty->fetch('bitpackage:bitcommerce/gv_send_email_text.tpl');
         $htmlMessage = $gBitSmarty->fetch('bitpackage:bitcommerce/gv_send_email_html.tpl');
         // send the email
         zen_mail('', $pRecipient['email'], $gv_email_subject, $textMessage, STORE_NAME, EMAIL_FROM, $htmlMessage, 'gv_send');
         // send additional emails
         if (SEND_EXTRA_GV_CUSTOMER_EMAILS_TO_STATUS == '1' and SEND_EXTRA_GV_CUSTOMER_EMAILS_TO != '') {
             zen_mail('', SEND_EXTRA_GV_CUSTOMER_EMAILS_TO, $gv_email_subject, $textMessage, STORE_NAME, EMAIL_FROM, $htmlMessage, 'gv_send');
             if ($_SESSION['customer_id']) {
                 $account_query = "select `customers_firstname`, `customers_lastname`, `customers_email_address`\n\t\t\t\t\t\t\t\t\t\tfrom " . TABLE_CUSTOMERS . "\n\t\t\t\t\t\t\t\t\t\twhere `customers_id` = '" . (int) $_SESSION['customer_id'] . "'";
                 $account = $gBitDb->Execute($account_query);
             }
             $extra_info = email_collect_extra_info($pRecipient['to_name'], $pRecipient['email'], $pFromUser->getDisplayName(), $pFromUser->getField('email'));
             $html_msg['EXTRA_INFO'] = $gCommerceSystem->getConfig('TEXT_GV_NAME') . ' Code: ' . $code . '<br/>' . $extra_info['HTML'];
             zen_mail('', SEND_EXTRA_GV_CUSTOMER_EMAILS_TO, tra('[GV CUSTOMER SENT]') . ' ' . $gv_email_subject, $gCommerceSystem->getConfig('TEXT_GV_NAME') . ' Code: ' . $code . "\n" . $gv_email . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'gv_send_extra');
         }
     }
     $gBitDb->CompleteTrans();
     return $ret;
 }