Example #1
0
<?php

if (isset($address_book) && isset($_SESSION["log"])) {
    if (isset($_GET["delete"])) {
        $aID = (int) $_GET["delete"];
        if (regGetAddressByLogin($aID, $_SESSION["log"])) {
            redDeleteAddress($aID);
        }
    }
    if (isset($_POST["save"])) {
        $aID = (int) $_POST["DefaultAddress"];
        if (regGetAddressByLogin($aID, $_SESSION["log"])) {
            regSetDefaultAddressIDByLogin($_SESSION["log"], $aID);
        }
    }
    $addresses = regGetAllAddressesByLogin($_SESSION["log"]);
    for ($i = 0; $i < count($addresses); $i++) {
        $addresses[$i]["addressStr"] = regGetAddressStr($addresses[$i]["addressID"]);
    }
    $defaultAddressID = regGetDefaultAddressIDByLogin($_SESSION["log"]);
    $smarty->assign("defaultAddressID", $defaultAddressID);
    $smarty->assign("addresses", $addresses);
    $smarty->assign("main_content_template", "address_book.tpl");
}
Example #2
0
        include $fileName;
    }
    $payment_methods = payGetAllPaymentMethods(true);
    $payment_methodsToShow = array();
    foreach ($payment_methods as $payment_method) {
        if ($_GET["shippingMethodID"] == 0) {
            $shippingMethodsToAllow = true;
        } else {
            $shippingMethodsToAllow = false;
            foreach ($payment_method["ShippingMethodsToAllow"] as $ShippingMethod) {
                if ((int) $_GET["shippingMethodID"] == (int) $ShippingMethod["SID"] && $ShippingMethod["allow"]) {
                    $shippingMethodsToAllow = true;
                    break;
                }
            }
        }
        if ($shippingMethodsToAllow) {
            $payment_methodsToShow[] = $payment_method;
        }
    }
    if (count($payment_methodsToShow) == 0) {
        RedirectProtected("index.php?order4_confirmation=yes&" . "shippingAddressID=" . $_GET["shippingAddressID"] . "&" . "shippingMethodID=" . $_GET["shippingMethodID"] . "&" . "billingAddressID=" . regGetDefaultAddressIDByLogin($_SESSION["log"]) . "&" . "paymentMethodID=0" . (isset($_GET['shServiceID']) ? "&shServiceID=" . $_GET['shServiceID'] : ''));
    }
    $smarty->assign("shippingAddressID", $_GET["shippingAddressID"]);
    $smarty->assign("billingAddressID", $_GET["billingAddressID"]);
    $smarty->assign("shippingMethodID", $_GET["shippingMethodID"]);
    $smarty->assign("strAddress", regGetAddressStr($_GET["billingAddressID"]));
    $smarty->assign("payment_methods", $payment_methodsToShow);
    $smarty->assign("payment_methods_count", count($payment_methodsToShow));
    $smarty->assign("main_content_template", "order3_billing.tpl");
}
Example #3
0
function getOrderSummarize($shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, $shServiceID = 0)
{
    // result this function
    $sumOrderContent = array();
    $q = db_query('select email_comments_text from ' . PAYMENT_TYPES_TABLE . ' where PID=' . (int) $paymentMethodID);
    $payment_email_comments_text = db_fetch_row($q);
    $payment_email_comments_text = $payment_email_comments_text[0];
    $q = db_query('select email_comments_text from ' . SHIPPING_METHODS_TABLE . ' where SID=' . (int) $shippingMethodID);
    $shipping_email_comments_text = db_fetch_row($q);
    $shipping_email_comments_text = $shipping_email_comments_text[0];
    $cartContent = cartGetCartContent();
    $pred_total = oaGetClearPrice($cartContent);
    if (isset($_SESSION['log'])) {
        $log = $_SESSION['log'];
    } else {
        $log = null;
    }
    $d = oaGetDiscountPercent($cartContent, $log);
    $discount = $pred_total / 100 * $d;
    // ordering with registration
    if ($shippingAddressID != 0 || isset($log)) {
        $addresses = array($shippingAddressID, $billingAddressID);
        $shipping_address = regGetAddressStr($shippingAddressID);
        $billing_address = regGetAddressStr($billingAddressID);
        $shaddr = regGetAddress($shippingAddressID);
        $sh_firstname = $shaddr['first_name'];
        $sh_lastname = $shaddr['last_name'];
    } else {
        if (!isset($_SESSION['receiver_countryID']) || !isset($_SESSION['receiver_zoneID'])) {
            return NULL;
        }
        $shippingAddress = array('countryID' => $_SESSION['receiver_countryID'], 'zoneID' => $_SESSION['receiver_zoneID']);
        $billingAddress = array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID']);
        $addresses = array($shippingAddress, $billingAddress);
        $shipping_address = quickOrderGetReceiverAddressStr();
        $billing_address = quickOrderGetBillingAddressStr();
        $sh_firstname = $_SESSION['receiver_first_name'];
        $sh_lastname = $_SESSION['receiver_last_name'];
    }
    foreach ($cartContent['cart_content'] as $key => $cartItem) {
        // if conventional ordering
        if ($shippingAddressID != 0) {
            $productID = GetProductIdByItemId($cartItem['id']);
            $cartItem['tax'] = taxCalculateTax($productID, $addresses[0], $addresses[1]);
        } else {
            $productID = $cartItem['id'];
            $cartItem['tax'] = taxCalculateTax2($productID, $addresses[0], $addresses[1]);
        }
        if (!empty($cartItem['opt_margin']) && $paymentMethodID == 2) {
            $cost = $cartItem['costUC'];
            $margin = $cost / 100 * CONF_PERCENT_MARGIN;
            $cost += $margin;
            $costShow = show_price($cost * $cartItem['quantity']);
            $pred_total += $margin * $cartItem['quantity'];
            $cartContent['cart_content'][$key]['costUC'] = $cost;
            $cartContent['cart_content'][$key]['cost'] = $costShow;
            $cartItem['costUC'] = $cost;
            $cartItem['cost'] = $costShow;
        }
        $sumOrderContent[] = $cartItem;
    }
    $shipping_method = shGetShippingMethodById($shippingMethodID);
    if (!$shipping_method) {
        $shipping_name = '-';
    } else {
        $shipping_name = $shipping_method['Name'];
    }
    $payment_method = payGetPaymentMethodById($paymentMethodID);
    if (!$payment_method) {
        $payment_name = '-';
    } else {
        $payment_name = $payment_method['Name'];
    }
    //do not calculate tax for this payment type!
    if (isset($payment_method['calculate_tax']) && (int) $payment_method['calculate_tax'] == 0) {
        foreach ($sumOrderContent as $key => $val) {
            $sumOrderContent[$key]['tax'] = 0;
        }
        $orderDetails = array('first_name' => $sh_firstname, 'last_name' => $sh_lastname, 'email' => '', 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE, $shServiceID));
        $tax = 0;
        $total = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, FALSE, $shServiceID);
        $shipping_cost = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, FALSE, $shServiceID);
    } else {
        $orderDetails = array('first_name' => $sh_firstname, 'last_name' => $sh_lastname, 'email' => '', 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE));
        $tax = oaGetProductTax($cartContent, $d, $addresses);
        $total = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, TRUE, $shServiceID);
        $shipping_cost = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, TRUE, $shServiceID);
    }
    $tServiceInfo = null;
    if (is_array($shipping_cost)) {
        $_T = array_shift($shipping_cost);
        $tServiceInfo = $_T['name'];
        $shipping_cost = $_T['rate'];
    }
    $payment_form_html = '';
    $paymentModule = modGetModuleObj($payment_method['module_id'], PAYMENT_MODULE);
    if ($paymentModule) {
        $order = array();
        $address = array();
        if ($shippingAddressID != 0) {
            $payment_form_html = $paymentModule->payment_form_html(array('BillingAddressID' => $billingAddressID));
        } else {
            $payment_form_html = $paymentModule->payment_form_html(array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID'], 'first_name' => $_SESSION['billing_first_name'], 'last_name' => $_SESSION['billing_last_name'], 'city' => $_SESSION['billing_city'], 'address' => $_SESSION['billing_address']));
        }
    }
    return array('sumOrderContent' => $sumOrderContent, 'discount' => $discount, 'discount_percent' => $d, 'discount_show' => show_price($discount), 'pred_total_disc' => show_price($pred_total * ((100 - $d) / 100)), 'pred_total' => show_price($pred_total), 'totalTax' => show_price($tax), 'totalTaxUC' => $tax, 'shipping_address' => $shipping_address, 'billing_address' => $billing_address, 'shipping_name' => $shipping_name, 'payment_name' => $payment_name, 'shipping_cost' => show_price($shipping_cost), 'shipping_costUC' => $shipping_cost, 'payment_form_html' => $payment_form_html, 'total' => show_price($total), 'totalUC' => $total, 'payment_email_comments_text' => $payment_email_comments_text, 'shipping_email_comments_text' => $shipping_email_comments_text, 'orderContentCartProductsCount' => count($sumOrderContent), 'shippingServiceInfo' => $tServiceInfo);
}
Example #4
0
     $res = cartGetCartContent();
     $order["orderContent"] = $res["cart_content"];
     $d = oaGetDiscountPercent($res, $_SESSION["log"]);
     $order["order_amount"] = $res["total_price"] - $res["total_price"] / 100 * $d;
     return $order;
 }
 if (isset($_GET["selectedNewAddressID"])) {
     if (!isset($_GET["defaultBillingAddressID"])) {
         RedirectProtected("index.php?order2_shipping=yes" . "&shippingAddressID=" . $_GET["selectedNewAddressID"]);
     } else {
         RedirectProtected("index.php?order2_shipping=yes" . "&shippingAddressID=" . $_GET["selectedNewAddressID"] . "&defaultBillingAddressID=" . $_GET["defaultBillingAddressID"]);
     }
 }
 $shippingAddressID = $_GET["shippingAddressID"];
 $order = _getOrder();
 $strAddress = regGetAddressStr($shippingAddressID);
 $moduleFiles = GetFilesInDirectory("core/modules/shipping", "php");
 foreach ($moduleFiles as $fileName) {
     include $fileName;
 }
 $shipping_methods = shGetAllShippingMethods(true);
 $shipping_costs = array();
 $res = cartGetCartContent();
 $sh_address = regGetAddress($shippingAddressID);
 $addresses = array($sh_address, $sh_address);
 $j = 0;
 foreach ($shipping_methods as $key => $shipping_method) {
     $_ShippingModule = modGetModuleObj($shipping_method["module_id"], SHIPPING_RATE_MODULE);
     if ($_ShippingModule) {
         if ($_ShippingModule->allow_shipping_to_address(regGetAddress($shippingAddressID))) {
             $shipping_costs[$j] = oaGetShippingCostTakingIntoTax($res, $shipping_method["SID"], $addresses, $order);
Example #5
0
function regEmailNotification($smarty_mail, $login, $cust_password, $Email, $first_name, $last_name, $subscribed4news, $additional_field_values, $countryID, $zoneID, $state, $city, $address, $updateOperation)
{
    $user = array();
    $smarty_mail->assign("login", $login);
    $smarty_mail->assign("cust_password", $cust_password);
    $smarty_mail->assign("first_name", $first_name);
    $smarty_mail->assign("last_name", $last_name);
    $smarty_mail->assign("Email", $Email);
    $additional_field_values = GetRegFieldsValues($login);
    $smarty_mail->assign("additional_field_values", $additional_field_values);
    $addresses = regGetAllAddressesByLogin($login);
    for ($i = 0; $i < count($addresses); $i++) {
        $addresses[$i]["addressStr"] = regGetAddressStr((int) $addresses[$i]["addressID"]);
    }
    $smarty_mail->assign("addresses", $addresses);
    if (CONF_ENABLE_REGCONFIRMATION) {
        $sql = 'SELECT ActivationCode FROM ' . CUSTOMERS_TABLE . '
                        WHERE Login="******" AND cust_password="******"';
        @(list($ActivationCode) = db_fetch_row(db_query($sql)));
        $smarty_mail->assign('ActURL', CONF_FULL_SHOP_URL . (substr(CONF_FULL_SHOP_URL, strlen(CONF_FULL_SHOP_URL) - 1, 1) == '/' ? '' : '/') . 'index.php?act_customer=1&act_code=' . $ActivationCode);
        $smarty_mail->assign('ActCode', $ActivationCode);
    }
    $html = $smarty_mail->fetch("register_successful.tpl");
    xMailTxtHTMLDATA($Email, EMAIL_REGISTRATION, $html);
}
Example #6
0
function serExportCustomersToExcel($customers)
{
    $maxCountAddress = 0;
    foreach ($customers as $customer) {
        $q = db_query("select count(*) from " . CUSTOMER_ADDRESSES_TABLE . " where customerID=" . $customer["customerID"]);
        $countAddress = db_fetch_row($q);
        $countAddress = $countAddress[0];
        if ($maxCountAddress < $countAddress) {
            $maxCountAddress = $countAddress;
        }
    }
    // open file to write
    $f = fopen("core/temp/customers.csv", "w");
    // head table generate
    $headLine = "Login;First name;Last name;Email;Group;Registered;Newsletter subscription;";
    $q = db_query("select reg_field_ID, reg_field_name from " . CUSTOMER_REG_FIELDS_TABLE . " order by sort_order ");
    while ($row = db_fetch_row($q)) {
        $headLine .= _filterBadSymbolsToExcel($row["reg_field_name"]) . ";";
    }
    for ($i = 1; $i <= $maxCountAddress; $i++) {
        $headLine .= "Address " . $i . ";";
    }
    fputs($f, $headLine . "\n");
    foreach ($customers as $customer) {
        $q = db_query("select Login, first_name, last_name, Email, custgroupID, reg_datetime, subscribed4news from " . CUSTOMERS_TABLE . " where addressID=" . (int) $customer["addressID"]);
        $row_cust = db_fetch_row($q);
        if ($row_cust["custgroupID"] != null) {
            $q = db_query("select custgroup_name from " . CUSTGROUPS_TABLE . " where custgroupID=" . $row_cust["custgroupID"]);
            $row = db_fetch_row($q);
            $row_cust["custgroup_name"] = $row["custgroup_name"];
        } else {
            $row_cust["custgroup_name"] = "";
        }
        if ($row_cust["subscribed4news"]) {
            $row_cust["subscribed4news"] = "+";
        } else {
            $row_cust["subscribed4news"] = "";
        }
        $line = "";
        $line .= _filterBadSymbolsToExcel($row_cust["Login"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["first_name"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["last_name"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["Email"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["custgroup_name"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["reg_datetime"]) . ";";
        $line .= $row_cust["subscribed4news"] . ";";
        $q_reg_param = db_query("select reg_field_ID, reg_field_name from " . CUSTOMER_REG_FIELDS_TABLE . " order by sort_order ");
        while ($row = db_fetch_row($q_reg_param)) {
            $q_reg_value = db_query("select reg_field_value from " . CUSTOMER_REG_FIELDS_VALUES_TABLE . " where reg_field_ID=" . $row["reg_field_ID"] . " AND customerID=" . $customer["customerID"]);
            $value = db_fetch_row($q_reg_value);
            $value = $value["reg_field_value"];
            $line .= _filterBadSymbolsToExcel($value) . ";";
        }
        $countAddress = 0;
        $addresses = regGetAllAddressesByLogin(regGetLoginById($customer["customerID"]));
        foreach ($addresses as $address) {
            $line .= " " . _filterBadSymbolsToExcel(regGetAddressStr($address["addressID"])) . ";";
            $countAddress++;
        }
        for ($i = 1; $i <= $maxCountAddress - $countAddress; $i++) {
            $line .= ";";
        }
        fputs($f, $line . "\n");
    }
    fclose($f);
}
Example #7
0
    $first_name = null;
    $last_name = null;
    $subscribed4news = null;
    $additional_field_values = null;
    regGetContactInfo($_SESSION["log"], $cust_password, $Email, $first_name, $last_name, $subscribed4news, $additional_field_values);
    $smarty->assign("additional_field_values", $additional_field_values);
    $smarty->assign("first_name", $first_name);
    $smarty->assign("last_name", $last_name);
    $smarty->assign("Email", $Email);
    $smarty->assign("login", $_SESSION["log"]);
    $customerID = regGetIdByLogin($_SESSION["log"]);
    $custgroup = GetCustomerGroupByCustomerId($customerID);
    $smarty->assign("custgroup_name", $custgroup["custgroup_name"]);
    $smarty->assign('affiliate_customers', affp_getCustomersNum($customerID));
    if (CONF_DISCOUNT_TYPE == '2') {
        if ($custgroup["custgroup_discount"] > 0) {
            $smarty->assign("discount", $custgroup["custgroup_discount"]);
        }
    }
    if (CONF_DISCOUNT_TYPE == '4' || CONF_DISCOUNT_TYPE == '5') {
        if ($custgroup["custgroup_discount"] > 0) {
            $smarty->assign("min_discount", $custgroup["custgroup_discount"]);
        }
    }
    $defaultAddressID = regGetDefaultAddressIDByLogin($_SESSION["log"]);
    $addressStr = regGetAddressStr($defaultAddressID);
    $smarty->assign("addressStr", $addressStr);
    $smarty->assign("visits_count", stGetVisitsCount($_SESSION["log"]));
    $smarty->assign("status_distribution", ordGetDistributionByStatuses($_SESSION["log"]));
    $smarty->assign("main_content_template", "user_account.tpl");
}