예제 #1
0
 function save_invoice_productSaleItems($invoiceID, $productSaleID)
 {
     $productSale = new productSale();
     $productSale->set_id($productSaleID);
     $productSale->select();
     $db = new db_alloc();
     $q = prepare("SELECT * FROM productSaleItem WHERE productSaleID = %d", $productSale->get_id());
     $q1 = $db->query($q);
     while ($row = $db->row($q1)) {
         $q = prepare("SELECT * FROM invoiceItem WHERE productSaleID = %d AND productSaleItemID = %d", $productSaleID, $row["productSaleItemID"]);
         $db = new db_alloc();
         $q2 = $db->query($q);
         $r2 = $db->row($q2);
         $ii = new invoiceItem();
         if ($r2) {
             $ii->set_id($r2["invoiceItemID"]);
         }
         $ii->currency = $row["sellPriceCurrencyTypeID"];
         $ii->set_value("invoiceID", $invoiceID);
         $ii->set_value("productSaleID", $productSale->get_id());
         $ii->set_value("productSaleItemID", $row["productSaleItemID"]);
         $ii->set_value("iiMemo", "Sale (" . $productSale->get_id() . ") item for " . person::get_fullname($productSale->get_value("personID")) . ", " . $row["description"]);
         $ii->set_value("iiQuantity", $row["quantity"]);
         $row["sellPrice"] = page::money($ii->currency, $row["sellPrice"] / $row["quantity"], "%mo");
         $ii->set_value("iiUnitPrice", $row["sellPrice"]);
         $ii->set_value("iiAmount", $row["sellPrice"] * $row["quantity"]);
         $d = $productSale->get_value("productSaleDate") or $d = $productSale->get_value("productSaleModifiedTime") or $d = $productSale->get_value("productSaleCreatedTime");
         $ii->set_value("iiDate", $d);
         //$ii->set_value("iiTax",config::get_config_item("taxPercent")); // product sale items are always excl GST
         $ii->save();
     }
 }
예제 #2
0
    }
}
$productID = $_GET["productID"] or $productID = $_POST["productID"];
$productSaleID = $_GET["productSaleID"] or $productSaleID = $_POST["productSaleID"];
$projectID = $_GET["projectID"] or $projectID = $_POST["projectID"];
$clientID = $_GET["clientID"] or $clientID = $_POST["clientID"];
$TPL["projectID"] = $projectID;
$productSale = new productSale();
$productSale->read_globals();
if ($productSaleID) {
    $productSale->set_id($productSaleID);
    $productSale->select();
    $productSale->set_values();
    $clientID = $productSale->get_value("clientID");
    $projectID = $productSale->get_value("projectID");
    $productSaleID = $productSale->get_id();
} else {
    $TPL["status"] = "create";
}
$db = new db_alloc();
$tf = new tf();
$tflist = $tf->get_assoc_array("tfID", "tfName");
if ($_POST["move_forwards"]) {
    $productSale->move_forwards();
    $_POST["save"] = true;
} else {
    if ($_POST["move_backwards"]) {
        $productSale->move_backwards();
        $_POST["save"] = true;
    }
}