Beispiel #1
0
 function delete()
 {
     $db = new db_alloc();
     $query = prepare("SELECT * \n                        FROM productSaleItem \n                       WHERE productSaleID = %d", $this->get_id());
     $db->query($query);
     while ($db->next_record()) {
         $productSaleItem = new productSaleItem();
         $productSaleItem->read_db_record($db);
         $productSaleItem->delete();
     }
     $this->delete_transactions();
     return parent::delete();
 }
Beispiel #2
0
    !$productSaleID && $productSale->set_value("status", "edit");
    $productSale->read_globals();
    $productSale->save();
    $productSaleID = $productSale->get_id();
    alloc_redirect($TPL["url_alloc_productSale"] . "productSaleID=" . $productSaleID);
} else {
    if ($_POST["save_items"] && $productSaleID) {
        is_array($_POST["deleteProductSaleItem"]) or $_POST["deleteProductSaleItem"] = array();
        if (is_array($_POST["productSaleItemID"]) && count($_POST["productSaleItemID"])) {
            is_array($_POST["sellPriceIncTax"]) or $_POST["sellPriceIncTax"] = array();
            foreach ($_POST["productSaleItemID"] as $k => $productSaleItemID) {
                // Delete
                if (in_array($productSaleItemID, $_POST["deleteProductSaleItem"])) {
                    $productSaleItem = new productSaleItem();
                    $productSaleItem->set_id($productSaleItemID);
                    $productSaleItem->delete();
                    // Save
                } else {
                    $a = array("productID" => $_POST["productID"][$k], "sellPrice" => $_POST["sellPrice"][$k], "sellPriceCurrencyTypeID" => $_POST["sellPriceCurrencyTypeID"][$k], "quantity" => $_POST["quantity"][$k], "description" => $_POST["description"][$k], "productSaleID" => $productSaleID);
                    if ($productSaleItemID) {
                        $a["sellPriceIncTax"] = sprintf("%d", in_array($productSaleItemID, $_POST["sellPriceIncTax"]));
                    } else {
                        $a["sellPriceIncTax"] = sprintf("%d", isset($_POST["sellPriceIncTax"][$k]));
                    }
                    if (substr($productSaleItemID, 0, 3) == "new") {
                        $productSaleItemID = "";
                    }
                    $a["productSaleItemID"] = $productSaleItemID;
                    $productSaleItem = new productSaleItem();
                    $productSaleItem->read_array($a);
                    if ($productSaleItem->validate() == "") {