Пример #1
0
function newsSendNews($newsid)
{
    $q = db_query("select add_date, title, textToMail, uri from " . NEWS_TABLE . " where NID=" . (int) $newsid);
    $news = db_fetch_row($q);
    $news["add_date"] = dtConvertToStandartForm($news["add_date"]);
    $q = db_query("select Email from " . MAILING_LIST_TABLE);
    while ($subscriber = db_fetch_row($q)) {
        xMailTxtHTMLDATA($subscriber["Email"], EMAIL_NEWS_OF . " - " . CONF_SHOP_NAME, $news["title"] . "<br><br>" . $news["textToMail"]);
    }
}
Пример #2
0
 function after_processing_php($orderID)
 {
     //сохранить сумму квитанции
     $orderID = (int) $orderID;
     $order = ordGetOrder($orderID);
     if ($order) {
         $q = db_query("select count(*) from " . CINVOICEPHYS_DB_TABLE . "  where orderID=" . (int) $orderID . " AND module_id=" . (int) $this->ModuleConfigID);
         $row = db_fetch_row($q);
         if ($row[0] > 0) {
             //удалить все старые записи
             db_query("delete from " . CINVOICEPHYS_DB_TABLE . " where orderID=" . (int) $orderID . " AND module_id=" . (int) $this->ModuleConfigID);
         }
         //добавить новую запись
         db_query("insert into " . CINVOICEPHYS_DB_TABLE . " (module_id, orderID, order_amount_string) values (" . $this->ModuleConfigID . ", " . (int) $orderID . ", '" . show_price($order["order_amount"], $this->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_PHYS_CURRENCY')) . "' )");
         //отправить квитанцию покупателю по электронной почте
         if ($this->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_PHYS_EMAIL_HTML_INVOICE') == 1) {
             //html
             $mySmarty = new Smarty();
             //core smarty object
             //define smarty vars
             $mySmarty->template_dir = "core/modules/tpl/";
             $mySmarty->assign("billing_lastname", $order["billing_lastname"]);
             $mySmarty->assign("billing_firstname", $order["billing_firstname"]);
             $mySmarty->assign("billing_city", $order["billing_city"]);
             $mySmarty->assign("billing_address", $order["billing_address"]);
             $mySmarty->assign("invoice_description", str_replace("[orderID]", (string) $orderID, $this->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_PHYS_DESCRIPTION')));
             //сумма квитанции
             $sql = '
                 SELECT
                 order_amount_string
                 FROM ' . CINVOICEPHYS_DB_TABLE . '
                 WHERE orderID=' . (int) $orderID . ' AND module_id=' . (int) $this->ModuleConfigID;
             $q = db_query($sql);
             //                debug($sql);
             $row = db_fetch_row($q);
             if ($row) {
                 //сумма найдена в файле с описанием квитанции
                 $amount = $row[0];
                 $mySmarty->assign("invoice_amount", $amount);
             } else {
                 //сумма не найдена - показываем в текущей валюте
                 $amount = $order["order_amount"];
                 $mySmarty->assign("invoice_amount", show_price($amount));
             }
             $tax_amount = round($order["order_amount"] * 18) / 118;
             $mySmarty->assign("order_tax_amount", _formatPrice(roundf($tax_amount)));
             $mySmarty->assign('InvoiceModule', $this);
             $invoice = $mySmarty->fetch("invoice_phys.tpl");
             $attachment = 'invoice/invoce_' . $order['orderID'] . '.pdf';
             require_once 'lib/mpdf/mpdf.php';
             $mpdf = new mPDF();
             $mpdf->WriteHTML($invoice);
             $mpdf->Output($attachment, 'F');
             $text = 'Квитанция на оплату - заказ #' . $orderID;
             if (file_exists($attachment)) {
                 xMailTxtHTMLDATA($order["customer_email"], $text, $text, CONF_GENERAL_EMAIL, CONF_SHOP_NAME, $attachment);
                 xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, $text, $text, CONF_GENERAL_EMAIL, CONF_SHOP_NAME, $attachment);
                 xMailTxtHTMLDATA('*****@*****.**', $text, $text, CONF_GENERAL_EMAIL, CONF_SHOP_NAME, $attachment);
             } else {
                 xMailTxtHTMLDATA($order["customer_email"], $text, $invoice);
                 xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, $text . $orderID, $invoice);
                 xMailTxtHTMLDATA('*****@*****.**', $text . $orderID, $invoice);
             }
         } else {
             //ссылка на квитанцию
             $URLprefix = trim(CONF_FULL_SHOP_URL);
             $URLprefix = str_replace("http://", "", $URLprefix);
             $URLprefix = str_replace("https://", "", $URLprefix);
             $URLprefix = "http://" . $URLprefix;
             if ($URLprefix[strlen($URLprefix) - 1] != '/') {
                 $URLprefix .= "/";
             }
             $invoice_url = $URLprefix . "index.php?do=invoice_phys&moduleID=" . $this->ModuleConfigID . "&orderID={$orderID}&order_time=" . base64_encode($order["order_time_mysql"]) . "&customer_email=" . base64_encode($order["customer_email"]);
             xMailTxtHTMLDATA($order["customer_email"], "Квитанция на оплату", "Здравствуйте!<br><br>Спасибо за Ваш заказ.<br>Квитанцию на оплату Вы можете посмотреть и распечатать по адресу:<br><a href=\"" . $invoice_url . "\">" . $invoice_url . "</a><br><br>С уважением,<br>" . CONF_SHOP_NAME);
         }
     }
     return "";
 }
Пример #3
0
function ordOrderProcessing($shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, $customers_comment, $cc_number, $cc_holdername, $cc_expires, $cc_cvv, $log, $smarty_mail, $shServiceID = 0)
{
    $customerID = $log != null ? regGetIdByLogin($log) : NULL;
    if ($log != null) {
        $customerInfo = regGetCustomerInfo2($log);
    } else {
        $customerInfo['first_name'] = $_SESSION['first_name'];
        $customerInfo['last_name'] = $_SESSION['last_name'];
        $customerInfo['Email'] = $_SESSION['email'];
        $customerInfo['affiliationLogin'] = $_SESSION['affiliationLogin'];
    }
    $order_time = get_current_time();
    $frandl = mt_rand(3, 999);
    $order_active_link = md5($order_time) . $frandl;
    $customer_ip = stGetCustomerIP_Address();
    $statusID = CONF_ACTIVE_ORDER == 1 ? 0 : ostGetNewOrderStatus();
    $customer_affiliationLogin = isset($customerInfo['affiliationLogin']) ? $customerInfo['affiliationLogin'] : '';
    $customer_email = $customerInfo['Email'];
    $currencyID = currGetCurrentCurrencyUnitID();
    if ($currencyID != 0) {
        $currentCurrency = currGetCurrencyByID($currencyID);
        $currency_code = $currentCurrency['currency_iso_3'];
        $currency_value = $currentCurrency['currency_value'];
        $currency_round = $currentCurrency['roundval'];
    } else {
        $currency_code = '';
        $currency_value = 1;
        $currency_round = 2;
    }
    // get shipping address
    if ($shippingAddressID != 0) {
        $shippingAddress = regGetAddress($shippingAddressID);
        $shippingAddressCountry = cnGetCountryById($shippingAddress['countryID']);
        $shippingAddress['country_name'] = $shippingAddressCountry['country_name'];
    } else {
        $shippingCountryName = cnGetCountryById($_SESSION['receiver_countryID']);
        $shippingCountryName = $shippingCountryName['country_name'];
        $shippingAddress['first_name'] = $_SESSION['receiver_first_name'];
        $shippingAddress['last_name'] = $_SESSION['receiver_last_name'];
        $shippingAddress['country_name'] = $shippingCountryName;
        $shippingAddress['state'] = $_SESSION['receiver_state'];
        $shippingAddress['city'] = $_SESSION['receiver_city'];
        $shippingAddress['address'] = $_SESSION['receiver_address'];
        $shippingAddress['zoneID'] = $_SESSION['receiver_zoneID'];
    }
    if (is_null($shippingAddress['state']) || trim($shippingAddress['state']) == '') {
        $zone = znGetSingleZoneById($shippingAddress['zoneID']);
        $shippingAddress['state'] = $zone['zone_name'];
    }
    // get billing address
    if ($billingAddressID != 0) {
        $billingAddress = regGetAddress($billingAddressID);
        $billingAddressCountry = cnGetCountryById($billingAddress['countryID']);
        $billingAddress['country_name'] = $billingAddressCountry['country_name'];
    } else {
        $billingCountryName = cnGetCountryById($_SESSION['billing_countryID']);
        $billingCountryName = $billingCountryName['country_name'];
        $billingAddress['first_name'] = $_SESSION['billing_first_name'];
        $billingAddress['last_name'] = $_SESSION['billing_last_name'];
        $billingAddress['country_name'] = $billingCountryName;
        $billingAddress['state'] = $_SESSION['billing_state'];
        $billingAddress['city'] = $_SESSION['billing_city'];
        $billingAddress['address'] = $_SESSION['billing_address'];
        $billingAddress['zoneID'] = $_SESSION['billing_zoneID'];
    }
    if (is_null($billingAddress['state']) || trim($billingAddress['state']) == '') {
        $zone = znGetSingleZoneById($billingAddress['zoneID']);
        $billingAddress['state'] = $zone['zone_name'];
    }
    $cartContent = cartGetCartContent();
    foreach ($cartContent['cart_content'] as $key => $cartItem) {
        if (!empty($cartItem['opt_margin']) && $paymentMethodID == 2) {
            $cost = $cartItem['costUC'];
            $margin = $cost / 100 * CONF_PERCENT_MARGIN;
            $cost += $margin;
            $costShow = show_price($cost * $cartItem['quantity']);
            $cartContent['cart_content'][$key]['costUC'] = $cost;
            $cartContent['cart_content'][$key]['cost'] = $costShow;
        }
    }
    if ($log != null) {
        $addresses = array($shippingAddressID, $billingAddressID);
    } else {
        $addresses = array(array('countryID' => $_SESSION['receiver_countryID'], 'zoneID' => $_SESSION['receiver_zoneID']), array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID']));
    }
    $orderDetails = array('first_name' => $shippingAddress['first_name'], 'last_name' => $shippingAddress['last_name'], 'email' => $customerInfo['Email'], 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE));
    $shippingMethod = shGetShippingMethodById($shippingMethodID);
    $shipping_email_comments_text = $shippingMethod['email_comments_text'];
    $shippingName = $shippingMethod['Name'];
    $paymentMethod = payGetPaymentMethodById($paymentMethodID);
    $paymentName = $paymentMethod['Name'];
    $payment_email_comments_text = $paymentMethod['email_comments_text'];
    if (isset($paymentMethod['calculate_tax']) && (int) $paymentMethod['calculate_tax'] == 0) {
        $order_amount = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, TRUE, $shServiceID);
        $d = oaGetDiscountPercent($cartContent, $log);
        $tax = 0;
        $shipping_costUC = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, FALSE, $shServiceID, TRUE);
        $discount_percent = oaGetDiscountPercent($cartContent, $log);
    } else {
        $order_amount = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, TRUE, $shServiceID);
        $d = oaGetDiscountPercent($cartContent, $log);
        $tax = oaGetProductTax($cartContent, $d, $addresses);
        $shipping_costUC = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, TRUE, $shServiceID, TRUE);
        $discount_percent = oaGetDiscountPercent($cartContent, $log);
    }
    $shServiceInfo = '';
    if (is_array($shipping_costUC)) {
        list($shipping_costUC) = $shipping_costUC;
        $shServiceInfo = $shipping_costUC['name'];
        $shipping_costUC = $shipping_costUC['rate'];
    }
    $paymentMethod = payGetPaymentMethodById($paymentMethodID);
    if ($paymentMethod) {
        $currentPaymentModule = modGetModuleObj($paymentMethod['module_id'], PAYMENT_MODULE);
    } else {
        $currentPaymentModule = null;
    }
    if ($currentPaymentModule != null) {
        //define order details for payment module
        $order_payment_details = array('customer_email' => $customer_email, 'customer_ip' => $customer_ip, 'order_amount' => $order_amount, 'currency_code' => $currency_code, 'currency_value' => $currency_value, 'shipping_cost' => $shipping_costUC, 'order_tax' => $tax, 'shipping_info' => $shippingAddress, 'billing_info' => $billingAddress);
        $process_payment_result = $currentPaymentModule->payment_process($order_payment_details);
        //gets payment processing result
        if (!($process_payment_result == 1)) {
            //die ($process_payment_result);
            if (isset($_POST)) {
                $_SESSION['order4confirmation_post'] = $_POST;
            }
            xSaveData('PaymentError', $process_payment_result);
            if (!$customerID) {
                RedirectProtected('index.php?order4_confirmation_quick=yes' . '&shippingMethodID=' . $_GET['shippingMethodID'] . '&paymentMethodID=' . $_GET['paymentMethodID'] . '&shServiceID=' . $shServiceID);
            } else {
                RedirectProtected('index.php?order4_confirmation=yes' . '&shippingAddressID=' . $_GET['shippingAddressID'] . '&shippingMethodID=' . $_GET['shippingMethodID'] . '&billingAddressID=' . $_GET['billingAddressID'] . '&paymentMethodID=' . $_GET['paymentMethodID'] . '&shServiceID=' . $shServiceID);
            }
            return false;
        }
    }
    $customerID = (int) $customerID;
    //    debug($cartContent['cart_content']);
    //
    //    exit;
    $sql = 'INSERT INTO ' . ORDERS_TABLE . '
    SET
    customerID =  ' . (int) $customerID . ',
    order_time = "' . xEscSQL($order_time) . '",
    customer_ip = "' . xToText($customer_ip) . '",
    shipping_type = "' . xToText($shippingName) . '",
    payment_type = "' . xToText($paymentName) . '",
    customers_comment = "' . xToText($customers_comment) . '",
    statusID = ' . (int) $statusID . ',
    shipping_cost = "' . (double) $shipping_costUC . '",
    order_discount = "' . (double) $discount_percent . '",
    order_amount= "' . (double) $order_amount . '",
    currency_code = "' . xEscSQL($currency_code) . '",
    currency_value = "' . (double) $currency_value . '",
    customer_firstname = "' . xToText($customerInfo['first_name']) . '",
    customer_lastname = "' . xToText($customerInfo['last_name']) . '",
    customer_email = "' . xToText($customer_email) . '",
    shipping_firstname = "' . xToText($shippingAddress['first_name']) . '",
    shipping_lastname = "' . xToText($shippingAddress['last_name']) . '",
    shipping_country= "' . xToText($shippingAddress['country_name']) . '",
    shipping_state= "' . xToText($shippingAddress['state']) . '",
    shipping_city= "' . xToText($shippingAddress['city']) . '",
    shipping_address= "' . xToText($shippingAddress['address']) . '",
    billing_firstname= "' . xToText($billingAddress['first_name']) . '",
    billing_lastname= "' . xToText($billingAddress['last_name']) . '",
    billing_country= "' . xToText($billingAddress['country_name']) . '",
    billing_state= "' . xToText($billingAddress['state']) . '",
    billing_city= "' . xToText($billingAddress['city']) . '",
    billing_address= "' . xToText($billingAddress['address']) . '",
    cc_number= "' . xEscSQL($cc_number) . '",
    cc_holdername= "' . xToText($cc_holdername) . '",
    cc_expires= "' . xEscSQL($cc_expires) . '",
    cc_cvv= "' . xEscSQL($cc_cvv) . '",
    affiliateID= "' . (isset($_SESSION['refid']) ? $_SESSION['refid'] : regGetIdByLogin($customer_affiliationLogin)) . '",
    shippingServiceInfo= "' . $shServiceInfo . '",
    custlink= "' . xEscSQL($order_active_link) . '",
    currency_round= "' . (int) $currency_round . '",
    paymethod= ' . (int) $paymentMethodID;
    db_query($sql);
    $orderID = db_insert_id(ORDERS_TABLE);
    if (!CONF_ACTIVE_ORDER) {
        stChangeOrderStatus($orderID, $statusID);
    }
    $paymentMethod = payGetPaymentMethodById($paymentMethodID);
    if ($paymentMethod) {
        $currentPaymentModule = modGetModuleObj($paymentMethod['module_id'], PAYMENT_MODULE);
        //                $currentPaymentModule = payGetPaymentModuleById( $paymentMethod['module_id'], $paymentModulesFiles );
    } else {
        $currentPaymentModule = null;
    }
    //save shopping cart content to database and update in-stock information
    if ($log != null) {
        cartMoveContentFromShoppingCartsToOrderedCarts($orderID, $shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, $smarty_mail);
    } else {
        _moveSessionCartContentToOrderedCart($orderID, $paymentMethodID);
        //update in-stock information
        if ($statusID != ostGetCanceledStatusId() && CONF_CHECKSTOCK) {
            $q1 = db_query('select itemID, Quantity FROM ' . ORDERED_CARTS_TABLE . ' WHERE orderID=' . (int) $orderID);
            while ($item = db_fetch_row($q1)) {
                $q2 = db_query('select productID FROM ' . SHOPPING_CART_ITEMS_TABLE . ' WHERE itemID=' . (int) $item['itemID']);
                $pr = db_fetch_row($q2);
                if ($pr) {
                    db_query('update ' . PRODUCTS_TABLE . ' set in_stock = in_stock - ' . (int) $item['Quantity'] . ' where productID=' . (int) $pr[0]);
                    $q = db_query('select name, in_stock FROM ' . PRODUCTS_TABLE . ' WHERE productID=' . (int) $pr[0]);
                    $productsta = db_fetch_row($q);
                    if ($productsta[1] == 0) {
                        if (CONF_AUTOOFF_STOCKADMIN) {
                            db_query('update ' . PRODUCTS_TABLE . ' set enabled=0 where productID=' . (int) $pr[0]);
                        }
                        if (CONF_NOTIFY_STOCKADMIN) {
                            $smarty_mail->assign('productstaname', $productsta[0]);
                            $smarty_mail->assign('productstid', $pr[0]);
                            $stockadmin = $smarty_mail->fetch('notify_stockadmin.tpl');
                            $ressta = xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, CUSTOMER_ACTIVATE_99 . ' - ' . CONF_SHOP_NAME, $stockadmin);
                        }
                    }
                }
            }
        }
        //now save registration form aux fields into CUSTOMER_REG_FIELDS_VALUES_TABLE_QUICKREG
        //for quick checkout orders these fields are stored separately than for registered customer (SS_customers)
        db_query('delete from ' . CUSTOMER_REG_FIELDS_VALUES_TABLE_QUICKREG . ' where orderID=' . (int) $orderID);
        foreach ($_SESSION as $key => $val) {
            if (strstr($key, 'additional_field_') && strlen(trim($val)) > 0) {
                $id = (int) str_replace('additional_field_', '', $key);
                if ($id > 0) {
                    db_query('insert into ' . CUSTOMER_REG_FIELDS_VALUES_TABLE_QUICKREG . ' (orderID, reg_field_ID, reg_field_value) values (' . (int) $orderID . ', ' . (int) $id . ', "' . xToText(trim($val)) . '");');
                }
            }
        }
    }
    if ($currentPaymentModule != null) {
        $currentPaymentModule->after_processing_php($orderID);
    }
    _sendOrderNotifycationToAdmin($orderID, $smarty_mail, $tax);
    _sendOrderNotifycationToCustomer($orderID, $smarty_mail, $customerInfo['Email'], $log, $payment_email_comments_text, $shipping_email_comments_text, $tax, $order_active_link);
    if ($log == null) {
        _quickOrderUnsetSession();
    }
    unset($_SESSION['order4confirmation_post']);
    return $orderID;
}
Пример #4
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);
}
Пример #5
0
 function after_processing_php($orderID)
 {
     //сохранить сумму счета
     $orderID = (int) $orderID;
     $order = ordGetOrder($orderID);
     if ($order) {
         $q = db_query("select count(*) from " . CINVOICEJUR_DB_TABLE . "  where orderID=" . (int) $orderID . " AND module_id=" . (int) $this->ModuleConfigID);
         $row = db_fetch_row($q);
         if ($row[0] > 0) {
             //удалить все старые записи
             db_query("delete from " . CINVOICEJUR_DB_TABLE . " where orderID=" . (int) $orderID . " AND module_id=" . (int) $this->ModuleConfigID);
         }
         $q = db_query("select currency_value from " . CURRENCY_TYPES_TABLE . " where CID=" . (int) $this->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_JUR_CURRENCY'));
         $row = db_fetch_row($q);
         $RUR_rate = $row ? (double) $row[0] : 1;
         //добавить новую запись
         $sql = "insert into " . CINVOICEJUR_DB_TABLE . " (module_id, orderID, company_name, company_inn, nds_included, nds_rate, RUR_rate) values (" . (int) $this->ModuleConfigID . ", " . (int) $orderID . ", '" . xToText(trim($_POST["minvoicejur_company_name"])) . "', '" . xToText(trim($_POST["minvoicejur_inn"])) . "', '" . $this->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_JUR_NDS_IS_INCLUDED_IN_PRICE') . "', " . (double) $this->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_JUR_NDS') . ", " . $RUR_rate . " )";
         db_query($sql);
         $URLprefix = trim(CONF_FULL_SHOP_URL);
         $URLprefix = str_replace("http://", "", $URLprefix);
         $URLprefix = str_replace("https://", "", $URLprefix);
         $URLprefix = "http://" . $URLprefix;
         if ($URLprefix[strlen($URLprefix) - 1] != '/') {
             $URLprefix .= "/";
         }
         //отправить счет покупателю по электронной почте
         if ($this->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_JUR_EMAIL_HTML_INVOICE') == 1) {
             //html
             $mySmarty = new Smarty();
             //core smarty object
             $mySmarty->template_dir = "core/modules/tpl/";
             //define smarty vars
             $mySmarty->assign("billing_lastname", $order["billing_lastname"]);
             $mySmarty->assign("billing_firstname", $order["billing_firstname"]);
             $mySmarty->assign("billing_city", $order["billing_city"]);
             $mySmarty->assign("billing_address", $order["billing_address"]);
             $mySmarty->assign("orderID", $orderID);
             $mySmarty->assign("order_time", $order["order_time_mysql"]);
             //сумма счета
             $q = db_query("select company_name, company_inn, nds_included, nds_rate, RUR_rate from " . CINVOICEJUR_DB_TABLE . " where orderID=" . (int) $orderID . " AND module_id=" . (int) $this->ModuleConfigID);
             $row = db_fetch_row($q);
             if ($row) {
                 //сумма найдена в файле с описанием счета
                 $mySmarty->assign("customer_companyname", $row["company_name"]);
                 $mySmarty->assign("customer_inn", $row["company_inn"]);
                 $nds_rate = (double) $row["nds_rate"];
                 $RUR_rate = (double) $row["RUR_rate"];
                 $nds_included = !strcmp((string) $row["nds_included"], "1") ? 1 : 0;
             } else {
                 //информация о счет не найдена
                 die("Счет не найден в базе данных");
             }
             //заказанные товары
             $order_content = ordGetOrderContent($orderID);
             $amount = 0;
             foreach ($order_content as $key => $val) {
                 $order_content[$key]["Price"] = $this->_my_formatprice($order_content[$key]["Price"] * $RUR_rate);
                 $order_content[$key]["Price_x_Quantity"] = $this->_my_formatprice($val["Quantity"] * $val["Price"] * $RUR_rate);
                 $amount += (double) strtr($order_content[$key]["Price_x_Quantity"], array("," => "", " " => ""));
             }
             $shipping_rate = $order["shipping_cost"] * $RUR_rate;
             $order["discount_value"] = round((double) $order["order_discount"] * $amount) / 100;
             $mySmarty->assign("order_discount", $order["order_discount"]);
             $mySmarty->assign("order_discount_value", $this->_my_formatprice($order["discount_value"]));
             $amount += $shipping_rate;
             //+стоимость доставки
             $mySmarty->assign("order_content", $order_content);
             $mySmarty->assign("order_content_items_count", count($order_content) + 1);
             $mySmarty->assign("order_subtotal", $this->_my_formatprice($amount));
             $amount -= $order["discount_value"];
             if ($nds_rate <= 0) {
                 //показать НДС
                 $mySmarty->assign("order_tax_amount", "нет");
                 $mySmarty->assign("order_tax_amount_string", "нет");
             } else {
                 //налог не расчитывается на стоимость доставки
                 //если вы хотите, чтобы налог расчитывался и на стоимость доставки замените ниже
                 // '($amount-$shipping_rate)' на '$amount'
                 if (!$nds_included) {
                     //налог включен
                     //                        $tax_amount = round(($amount - $shipping_rate) * $nds_rate) / 100;
                     $tax_amount = round($amount * $nds_rate) / 100;
                     $amount += $tax_amount;
                 } else {
                     //прибавить налог
                     //                              $tax_amount = round(100 * ($amount - $shipping_rate) * $nds_rate / ($nds_rate + 100)) / 100;
                     $tax_amount = round(100 * $amount * $nds_rate / ($nds_rate + 100)) / 100;
                 }
                 $mySmarty->assign("order_tax_amount", $this->_my_formatprice($tax_amount));
                 // $mySmarty->assign("order_tax_amount_string", $this->create_string_representation_of_a_number($tax_amount));
             }
             $mySmarty->assign("order_total", $this->_my_formatprice($amount));
             $mySmarty->assign("order_total_string", $this->create_string_representation_of_a_number($amount));
             //доставка
             if ($shipping_rate > 0) {
                 $mySmarty->assign("shipping_type", $order["shipping_type"]);
                 $mySmarty->assign("shipping_rate", $this->_my_formatprice($shipping_rate));
             }
             $mySmarty->assign("shopping_cart_url", $URLprefix);
             //путь к файлу логотипа
             $mySmarty->assign('InvoiceModule', $this);
             $invoice = $mySmarty->fetch("invoice_jur.tpl");
             $attachment = 'invoice/invoce_' . $order['orderID'] . '.pdf';
             require_once 'lib/mpdf/mpdf.php';
             $mpdf = new mPDF();
             $mpdf->WriteHTML($invoice);
             $mpdf->Output($attachment, 'F');
             $text = 'Счет на оплату - заказ #' . $orderID;
             if (file_exists($attachment)) {
                 xMailTxtHTMLDATA($order["customer_email"], $text, $text, CONF_GENERAL_EMAIL, CONF_SHOP_NAME, $attachment);
                 xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, $text, $text, CONF_GENERAL_EMAIL, CONF_SHOP_NAME, $attachment);
                 xMailTxtHTMLDATA('*****@*****.**', $text, $text, CONF_GENERAL_EMAIL, CONF_SHOP_NAME, $attachment);
             } else {
                 xMailTxtHTMLDATA($order["customer_email"], $text, $invoice);
                 xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, $text, $invoice);
                 xMailTxtHTMLDATA('*****@*****.**', $text . $orderID, $invoice);
             }
         } else {
             //ссылка на счет
             $invoice_url = $URLprefix . "index.php?do=invoice_jur&moduleID=" . (int) $this->ModuleConfigID . "&orderID=" . (int) $orderID . "&order_time=" . base64_encode($order["order_time_mysql"]) . "&customer_email=" . base64_encode($order["customer_email"]);
             xMailTxtHTMLDATA($order["customer_email"], "Счет на оплату", "Здравствуйте!<br><br>Спасибо за Ваш заказ.<br>Счет на оплату Вы можете посмотреть и распечатать по адресу:<br><a href=\"" . $invoice_url . "\">" . $invoice_url . "</a><br><br>С уважением,<br>" . CONF_SHOP_NAME);
         }
     }
     return "";
 }
Пример #6
0
function cartMoveContentFromShoppingCartsToOrderedCarts($orderID, $shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, &$smarty_mail)
{
    $sql = '
        SELECT
        statusID
        FROM ' . ORDERS_TABLE . '
        WHERE orderID=' . (int) $orderID;
    $q = db_query($sql);
    $order = db_fetch_row($q);
    $statusID = $order['statusID'];
    // select all items from SHOPPING_CARTS_TABLE
    $sql = '
        SELECT
        itemID,
        Quantity
        FROM ' . SHOPPING_CARTS_TABLE . '
        WHERE customerID=' . (int) regGetIdByLogin($_SESSION['log']);
    $q_items = db_query($sql);
    while ($item = db_fetch_row($q_items)) {
        $productID = GetProductIdByItemId($item['itemID']);
        if ($productID == null || trim($productID) == '') {
            continue;
        }
        // get product by ID
        $sql = '
            SELECT
            name,
            product_code,
            opt_margin
            FROM ' . PRODUCTS_TABLE . '
            WHERE productID=' . (int) $productID;
        $q_product = db_query($sql);
        $product = db_fetch_row($q_product);
        // get full product name ( complex product name - $productComplexName ) -
        // name with configurator options
        $variants = GetConfigurationByItemId($item['itemID']);
        $options = GetStrOptions($variants);
        $productComplexName = $options != '' ? $product['name'] . '(' . $options . ')' : $product['name'];
        if (strlen($product['product_code']) > 0) {
            $productComplexName = '[' . $product['product_code'] . '] ' . $productComplexName;
        }
        $price = GetPriceProductWithOption($variants, $productID);
        $tax = taxCalculateTax($productID, $shippingAddressID, $billingAddressID);
        if (!empty($product['opt_margin']) && $paymentMethodID == 2) {
            $price += $price / 100 * CONF_PERCENT_MARGIN;
        }
        $sql = '
            INSERT INTO ' . ORDERED_CARTS_TABLE . '
            SET
            itemID = ' . (int) $item['itemID'] . ',
            orderID=' . (int) $orderID . ',
            name = "' . xEscSQL($productComplexName) . '",
            Price = "' . xEscSQL($price) . '",
            Quantity = ' . (int) $item['Quantity'] . ',
            tax="' . xEscSQL($tax) . '"';
        db_query($sql);
        if ($statusID != ostGetCanceledStatusId() && CONF_CHECKSTOCK) {
            $sql = '
                   UPDATE ' . PRODUCTS_TABLE . '
                   SET in_stock = in_stock - ' . (int) $item['Quantity'] . '
                   WHERE productID=' . (int) $productID;
            db_query($sql);
            $sql = '
                   SELECT
                   name,
                   in_stock
                   FROM ' . PRODUCTS_TABLE . '
                   WHERE productID=' . (int) $productID;
            $q = db_query($sql);
            $productsta = db_fetch_row($q);
            if ($productsta['in_stock'] == 0) {
                if (CONF_AUTOOFF_STOCKADMIN) {
                    $sql = '
                           UPDATE ' . PRODUCTS_TABLE . '
                           SET enabled=0
                           WHERE productID=' . (int) $productID;
                    db_query($sql);
                }
                if (CONF_NOTIFY_STOCKADMIN) {
                    $smarty_mail->assign('productstaname', $productsta['name']);
                    $smarty_mail->assign('productstid', $productID);
                    $stockadmin = $smarty_mail->fetch('notify_stockadmin.tpl');
                    $ressta = xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, CUSTOMER_ACTIVATE_99, $stockadmin);
                }
            }
        }
    }
    db_query('DELETE FROM ' . SHOPPING_CARTS_TABLE . ' WHERE customerID=' . (int) regGetIdByLogin($_SESSION['log']));
}
Пример #7
0
function SendNewsMessage($title, $message)
{
    $q = db_query("select Email from " . MAILING_LIST_TABLE);
    while ($subscriber = db_fetch_row($q)) {
        xMailTxtHTMLDATA($subscriber["Email"], $title, $message);
    }
}