Beispiel #1
0
function show_productSale_list($productSaleID, $template)
{
    global $TPL;
    global $productSaleItemsDoExist;
    $productSale = new productSale();
    $productSale->set_id($productSaleID);
    $productSale->select();
    $productSale->set_tpl_values();
    $taxName = config::get_config_item("taxName");
    $product = new product();
    $ops = $product->get_assoc_array("productID", "productName");
    $query = prepare("SELECT *\n                      FROM productSaleItem \n                     WHERE productSaleID = %d", $productSaleID);
    $db = new db_alloc();
    $db->query($query);
    while ($db->next_record()) {
        $productSaleItemsDoExist = true;
        $productSaleItem = new productSaleItem();
        $productSaleItem->read_db_record($db);
        $productSaleItem->set_tpl_values();
        $TPL["itemSellPrice"] = $productSaleItem->get_value("sellPrice");
        $TPL["itemMargin"] = $productSaleItem->get_amount_margin();
        $TPL["itemSpent"] = $productSaleItem->get_amount_spent();
        $TPL["itemEarnt"] = $productSaleItem->get_amount_earnt();
        $TPL["itemOther"] = $productSaleItem->get_amount_other();
        $TPL["itemCosts"] = page::money(config::get_config_item("currency"), product::get_buy_cost($productSaleItem->get_value("productID")) * $productSaleItem->get_value("quantity"), "%s%mo %c");
        $TPL["itemTotalUnallocated"] = $productSaleItem->get_amount_unallocated();
        $TPL["productList_dropdown"] = page::select_options($ops, $productSaleItem->get_value("productID"));
        $TPL["productLink"] = "<a href=\"" . $TPL["url_alloc_product"] . "productID=" . $productSaleItem->get_value("productID") . "\">" . page::htmlentities($ops[$productSaleItem->get_value("productID")]) . "</a>";
        $TPL["transactions"] = $productSale->get_transactions($productSaleItem->get_id());
        if ($taxName) {
            $TPL["sellPriceTax_check"] = sprintf(" <input type='checkbox' name='sellPriceIncTax[]' value='%d'%s> inc %s", $productSaleItem->get_id(), $productSaleItem->get_value("sellPriceIncTax") ? ' checked' : '', $taxName);
            $TPL["sellPriceTax_label"] = $productSaleItem->get_value("sellPriceIncTax") ? " inc " . $taxName : " ex " . $taxName;
        }
        include_template($template);
    }
}