Esempio n. 1
0
function show_productSale_new($template)
{
    global $TPL;
    global $productSaleItemsDoExist;
    global $productSaleID;
    $taxName = config::get_config_item("taxName");
    $productSaleItem = new productSaleItem();
    $productSaleItem->set_values();
    // wipe clean
    $product = new product();
    $ops = $product->get_assoc_array("productID", "productName");
    $TPL["productList_dropdown"] = page::select_options($ops, $productSaleItem->get_value("productID"));
    $productSaleItemsDoExist and $TPL["display"] = "display:none";
    if ($taxName) {
        $TPL["sellPriceTax_check"] = sprintf(" <input type='checkbox' name='sellPriceIncTax[]' value='1'%s> inc %s", $productSaleItem->get_value("sellPriceIncTax") ? ' checked' : '', $taxName);
    }
    $TPL["psid"] = $productSaleID;
    // poorly named template variable to prevent clobbering
    include_template($template);
}
Esempio n. 2
0
 function get_amounts()
 {
     $rows = $this->get_productSaleItems();
     $rows or $rows = array();
     $rtn = array();
     foreach ($rows as $row) {
         $productSaleItem = new productSaleItem();
         $productSaleItem->read_row_record($row);
         //$rtn["total_spent"] += $productSaleItem->get_amount_spent();
         //$rtn["total_earnt"] += $productSaleItem->get_amount_earnt();
         //$rtn["total_other"] += $productSaleItem->get_amount_other();
         list($sp, $spcur) = array($productSaleItem->get_value("sellPrice"), $productSaleItem->get_value("sellPriceCurrencyTypeID"));
         $sellPriceCurr[$spcur] += page::money($spcur, $sp, "%m");
         $total_sellPrice += exchangeRate::convert($spcur, $sp);
         $total_margin += $productSaleItem->get_amount_margin();
         $total_unallocated += $productSaleItem->get_amount_unallocated();
     }
     unset($sep, $label, $show);
     foreach ((array) $sellPriceCurr as $code => $amount) {
         $label .= $sep . page::money($code, $amount, "%s%mo %c");
         $sep = " + ";
         $code != config::get_config_item("currency") and $show = true;
     }
     $show && $label and $sellPrice_label = " (" . $label . ")";
     $total_sellPrice_plus_gst = add_tax($total_sellPrice);
     $rtn["total_sellPrice"] = page::money(config::get_config_item("currency"), $total_sellPrice, "%s%mo %c") . $sellPrice_label;
     $rtn["total_sellPrice_plus_gst"] = page::money(config::get_config_item("currency"), $total_sellPrice_plus_gst, "%s%mo %c") . $sellPrice_label;
     $rtn["total_margin"] = page::money(config::get_config_item("currency"), $total_margin, "%s%mo %c");
     $rtn["total_unallocated"] = page::money(config::get_config_item("currency"), $total_unallocated, "%s%mo %c");
     $rtn["total_unallocated_number"] = page::money(config::get_config_item("currency"), $total_unallocated, "%mo");
     $rtn["total_sellPrice_value"] = page::money(config::get_config_item("currency"), $total_sellPrice, "%mo");
     return $rtn;
 }