Example #1
0
        'default_tax_id'    => $_POST['default_tax_id'],
        /*'default_tax_id_2'  => NULL,*/
        'cost'              => $_POST['cost'],
        'reorder_level'     => $_POST['reoder_level'],
        'custom_field1'     => $_POST['custom_field1'],
        'custom_field2'     => $_POST['custom_field2'],
        'custom_field3'     => $_POST['custom_field3'],
        'custom_field4'     => $_POST['custom_field4'],
        'notes'             => $_POST['notes'],
        'enabled'           => $_POST['enabled']
        /*'visible'           => $visible*/
    );
    
	if (isset($_POST['save_product']) && $SI_PRODUCTS->update($product_data,$_GET['id'])) {
		$saved = true;
		updateCustomFieldValues($_POST['categorie'],$_GET['id']);
	}
	
 	$i = 1;
 	while ($i <= 3 )
 	{
		/* 1 - check if attribue exists for that product in the matrix - 2 if not INSERT 3 if is UPDATE*/

/*		$sql1 = "select attribute_id from ".TB_PREFIX."products_matrix where product_id = ".$_GET['id'];
		$result1 = dbQuery($sql1);
		$attributes = $result1->fetch(PDO::FETCH_ASSOC);		
		foreach ($attributes as $key=>$value)
		{
			if ($value == $_POST['attribute_'.$i])
			{
			echo "<br /><br /><b>".$_POST['attribute_'.$i]."in db</b><br />";
Example #2
0
                $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";
        dbQuery($sql, ':price', $_POST['unit_price'], ':description', $_POST['description0'], ':id', $_POST['products0']);
    }
    for ($i = 0; !empty($_POST["quantity{$i}"]) && $i < $_POST['max_items']; $i++) {
        if (matrix_invoice::updateInvoiceItem($_POST["id{$i}"], $_POST["quantity{$i}"], $_POST["products{$i}"], $_POST['tax_id'], $_POST["description{$i}"], $_POST["attr1-{$i}"], $_POST["attr2-{$i}"], $_POST["attr3-{$i}"], $_POST["unit_price{$i}"]) && $saved) {
            //$saved =  true;
        } else {
            die(end($dbh->errorInfo()));
        }
    }
}
//Get type id - so do add into redirector header