Example #1
0
function ordDeleteOrder($orderID)
{
    $q = db_query('select statusID from ' . ORDERS_TABLE . ' where orderID=' . (int) $orderID);
    $row = db_fetch_row($q);
    if ($row['statusID'] != ostGetCanceledStatusId()) {
        return;
    }
    db_query('delete from ' . ORDERED_CARTS_TABLE . ' where orderID=' . (int) $orderID);
    db_query('delete from ' . ORDERS_TABLE . ' where orderID=' . (int) $orderID);
    db_query('delete from ' . ORDER_STATUS_CHANGE_LOG_TABLE . ' where orderID=' . (int) $orderID);
}
Example #2
0
function ostSetOrderStatusToOrder($orderID, $statusID, $comment = '', $notify = 0)
{
    $q1 = db_query("select statusID from " . ORDERS_TABLE . " where orderID=" . (int) $orderID);
    $row = db_fetch_row($q1);
    $pred_statusID = $row["statusID"];
    if ((int) $pred_statusID == (int) $statusID) {
        return;
    }
    db_query("update " . ORDERS_TABLE . " set statusID=" . (int) $statusID . " where orderID=" . (int) $orderID);
    if ($statusID == CONF_COMPLETED_ORDER_STATUS) {
        affp_addCommissionFromOrder($orderID);
    }
    //update product 'in stock' quantity
    if ($pred_statusID != ostGetCanceledStatusId() && $statusID == ostGetCanceledStatusId()) {
        _changeIn_stock($orderID, true);
    } else {
        if ($pred_statusID == ostGetCanceledStatusId() && $statusID != ostGetCanceledStatusId()) {
            _changeIn_stock($orderID, false);
        }
    }
    //update sold counter
    if ($pred_statusID != CONF_COMPLETED_ORDER_STATUS && $statusID == CONF_COMPLETED_ORDER_STATUS) {
        _changeSOLD_counter($orderID, true);
    } else {
        if ($pred_statusID == CONF_COMPLETED_ORDER_STATUS && $statusID != CONF_COMPLETED_ORDER_STATUS) {
            _changeSOLD_counter($orderID, false);
        }
    }
    stChangeOrderStatus($orderID, $statusID, $comment, $notify);
}
Example #3
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']));
}
Example #4
0
     if ((int) $_POST["status"] != -1) {
         ostSetOrderStatusToOrder((int) $_GET["orderID"], $_POST["status"], isset($_POST['status_comment']) ? $_POST['status_comment'] : '', isset($_POST['notify_customer']) ? $_POST['notify_customer'] : '');
     }
     Redirect(ADMIN_FILE . "?dpt=custord&sub=new_orders&orders_detailed=yes&orderID=" . (int) $_GET["orderID"] . "&urlToReturn=" . $_GET["urlToReturn"]);
 }
 if (isset($_GET["urlToReturn"])) {
     $smarty->assign("encodedUrlToReturn", $_GET["urlToReturn"]);
 }
 if (isset($_GET["urlToReturn"])) {
     $smarty->hassign("urlToReturn", base64_decode($_GET["urlToReturn"]));
 }
 $order = ordGetOrder((int) $_GET["orderID"]);
 $orderContent = ordGetOrderContent((int) $_GET["orderID"]);
 $order_status_report = xNl2Br(stGetOrderStatusReport((int) $_GET["orderID"]));
 $order_statuses = ostGetOrderStatues();
 $smarty->assign("cancledOrderStatus", ostGetCanceledStatusId());
 $smarty->assign("orderContent", $orderContent);
 $smarty->assign("order", $order);
 //            $paymentModuleFiles = GetFilesInDirectory("core/modules/payment", "php");
 //
 //
 //            foreach ($paymentModuleFiles as $fileName)
 //                include ( $fileName );
 $paymentMethod = payGetPayModuleID($order['payment_type']);
 $currentPaymentModule = modGetModuleObj($paymentMethod["module_id"], PAYMENT_MODULE);
 if ($currentPaymentModule != null && method_exists($currentPaymentModule, 'admin_print_html')) {
     $admin_print_html = $currentPaymentModule->admin_print_html($order["orderID"]);
     if (!empty($admin_print_html)) {
         $smarty->assign("print_href", $admin_print_html);
     }
 }
    /**
     * @param int $orderID
     * @param array $shipping_info - ('countryID','zoneID', 'zip')
     * @param array $billing_info - ('countryID','zoneID', 'zip')
     */
    function saveToOrderedCarts($orderID, $shipping_info, $billing_info, $calculate_tax = true)
    {
        $sql = "DELETE FROM ?#ORDERED_CARTS_TABLE WHERE orderID=?";
        db_phquery($sql, $orderID);
        $r_aItem = $this->Items->getChildNodes('item');
        $tc = count($r_aItem);
        for ($i = 0; $i < $tc; $i++) {
            $aItem =& $r_aItem[$i];
            /* @var $aItem xmlNodeX */
            $aProduct =& $aItem->getFirstChildByName('product');
            $productID = $aProduct->attribute('id');
            db_phquery('INSERT ?#SHOPPING_CART_ITEMS_TABLE (productID) VALUES(?)', $productID);
            $aItem->attribute('id', db_insert_id(SHOPPING_CART_ITEMS_TABLE));
            //if(strpos($aItem->attribute('id'), '_') !== false){
            //	db_phquery('INSERT ?#SHOPPING_CART_ITEMS_TABLE (productID) VALUES(?)',$productID);
            //	$aItem->attribute('id', db_insert_id(SHOPPING_CART_ITEMS_TABLE));
            $aVariants =& $aItem->getFirstChildByName('variants');
            $r_aVariant = $aVariants->getChildrenByName('variant');
            foreach ($r_aVariant as $aVariant) {
                /* @var $aVariant xmlNodeX */
                db_phquery('INSERT ?#SHOPPING_CART_ITEMS_CONTENT_TABLE (itemID, variantID) 
							VALUES(?,?)', $aItem->attribute('id'), $aVariant->attribute('id'));
            }
            //}
            $dbq = '
					SELECT ' . LanguagesManager::sql_prepareField('name') . ' AS name, product_code, categoryID FROM ?#PRODUCTS_TABLE WHERE productID=?
				';
            $q_product = db_phquery($dbq, $productID);
            $product = db_fetch_row($q_product);
            $productComplexName = '';
            $aVariants =& $aItem->getFirstChildByName('variants');
            $r_aVariant = $aVariants->getChildrenByName('variant');
            $variants = array();
            foreach ($r_aVariant as $aVariant) {
                /* @var $aVariant xmlNodeX */
                $variants[] = $aVariant->attribute('id');
            }
            $options = GetStrOptions($variants);
            if ($options != "") {
                $productComplexName = $product["name"] . " (" . $options . ")";
            } else {
                $productComplexName = $product["name"];
            }
            if ($product["product_code"]) {
                $productComplexName = "[" . $product["product_code"] . "] " . $productComplexName;
            }
            $price = GetPriceProductWithOption($variants, $productID);
            if ($aItem->getChildData('sample')) {
                $productComplexName .= " [SAMPLE]";
                $q_sample_price = db_phquery('SELECT sample_price FROM SC_categories WHERE categoryID=(SELECT categoryID FROM SC_products WHERE productID=?)', $productID);
                $sample_price = db_fetch_assoc($q_sample_price);
                $price = $sample_price["sample_price"];
                $quantity = 1;
            } else {
                $quantity = $aItem->getChildData('quantity');
            }
            $tax = $calculate_tax ? taxCalculateTax2($productID, $shipping_info, $billing_info) : 0;
            $dbq = '
					INSERT ?#ORDERED_CARTS_TABLE (itemID, orderID, name, Price, Quantity, tax )
					VALUES (?, ?, ?, ?, ?, ?)
				';
            db_phquery($dbq, $aItem->attribute('id'), $orderID, $productComplexName, $price, $quantity, $tax);
            $q = db_phquery('SELECT statusID FROM ?#ORDERS_TABLE WHERE orderID=?', $orderID);
            $order = db_fetch_row($q);
            if ($order["statusID"] != ostGetCanceledStatusId() && CONF_CHECKSTOCK) {
                $dbq = '
						UPDATE ?#PRODUCTS_TABLE SET in_stock=in_stock-' . xEscapeSQLstring($quantity) . '
						WHERE productID=? 
					';
                db_phquery($dbq, $productID);
            }
        }
    }