예제 #1
0
<?php

/*
* Script: add_invoice_item.php
* 	add new invoice item in edit page
*
* License:
*	 GPL v3 or above
*
* Website:
* 	http://www.simpleinvoices.org
*/
if (isset($_POST['submit'])) {
    matrix_invoice::insertInvoiceItem($_POST['invoice_id'], $_POST['quantity1'], $_POST['product1'], $_POST['tax_id'], $_POST['description'], $_POST["attr1"], $_POST["attr2"], $_POST["attr3"], $_POST["unit_price1"]);
} else {
    $products = getActiveProducts();
    $smarty->assign("products", $products);
}
$type = $_GET[type];
$pageActive = "invoices";
$smarty->assign('pageActive', $pageActive);
$smarty->assign("type", $type);
$sql_prod = "select product_id as PID, (select count(product_id) from " . TB_PREFIX . "products_matrix where product_id = PID ) as count from " . TB_PREFIX . "products_matrix ORDER BY count desc LIMIT 1;";
$sth_prod = dbQuery($sql_prod);
$number_of_products = $sth_prod->fetchAll();
$smarty->assign("number_of_attributes", $number_of_products['0']['count']);
$js = <<<EOD
<script type="text/javascript" charset="utf-8">


\$(function()
예제 #2
0
        insertProduct(0, 0);
        $product_id = lastInsertId();
        if (matrix_invoice::insertInvoiceItem($invoice_id, 1, $product_id, $_POST['tax_id'], $_POST['description'])) {
            //$saved = true;
        } else {
            die(end($dbh->errorInfo()));
        }
    } elseif ($saved) {
        for ($i = 0; !empty($_POST["quantity{$i}"]) && $i < $_POST['max_items']; $i++) {
            if ($type == 4) {
                insertProductComplete(0, 0, $_POST["description{$i}"], $_POST["price{$i}"], NULL, NULL, NULL, NULL, $_POST["notes{$i}"]);
                $product = lastInsertId();
            } else {
                $product = $_POST["products{$i}"];
            }
            if (matrix_invoice::insertInvoiceItem($invoice_id, $_POST["quantity{$i}"], $product, $_POST['tax_id'], $_POST["description{$i}"], $_POST["attr1-{$i}"], $_POST["attr2-{$i}"], $_POST["attr3-{$i}"], $_POST["unit_price{$i}"])) {
                //$saved = true;
            } else {
                die(end($dbh->errorInfo()));
            }
        }
    }
} elseif ($_POST['action'] == "edit") {
    //Get type id - so do add into redirector header
    $invoice_id = $_POST['invoice_id'];
    if (updateInvoice($_POST['invoice_id'])) {
        updateCustomFieldValues($_POST['categorie'], $_POST['invoice_id']);
        $saved = true;
    }
    if ($type == 1 && $saved) {
        $sql = "UPDATE " . TB_PREFIX . "products SET unit_price = :price, description = :description WHERE id = :id";