* Authors: * Justin Kelly, Nicolas Ruflin * * Last edited: * 2007-07-19 * * License: * GPL v2 or above * * Website: * http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_CUSTOMERS = new SimpleInvoices_Db_Table_Customers(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); $billers = $SI_BILLER->fetchAllActive(); $customers = $SI_CUSTOMERS->fetchAllActive(); $taxes = $SI_TAX->fetchAllActive(); $products = $SI_PRODUCTS->findActive(); $preferences = $SI_PREFERENCES->fetchAllActive(); $defaults = $SI_SYSTEM_DEFAULTS->fetchAll(); $defaultBiller = $SI_BILLER->getDefault();
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); # Deal with op and add some basic sanity checking $op = !empty( $_POST['op'] ) ? addslashes( $_POST['op'] ) : NULL; #insert product $saved = false; if ( $op === 'insert_product' ) { $data = array( 'description' => $_POST['description'], 'detail' => $_POST['detail'], 'unit_price' => $_POST['unit_price'], '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' => 1,
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $SI_CUSTOM_FIELDS = new SimpleInvoices_Db_Table_CustomFields(); #get the invoice id $product_id = $_GET['id']; $product = $SI_PRODUCTS->getProductById($product_id); #get custom field labels $customFieldLabel = $SI_CUSTOM_FIELDS->getLabels(); $pageActive = "products"; $smarty->assign('pageActive', $pageActive); $smarty -> assign('product',$product); $smarty -> assign('customFieldLabel',$customFieldLabel); $sql = "select * from ".TB_PREFIX."products_attributes"; $sth = dbQuery($sql); $attributes = $sth->fetchAll(); $smarty -> assign("attributes", $attributes); $sql_matrix = "select * from ".TB_PREFIX."products_matrix where product_id = $product_id order by id"; $sth_matrix = dbQuery($sql_matrix); $matrix = $sth_matrix->fetchAll(); $smarty -> assign("matrix", $matrix);
function updateInvoiceItem($id,$quantity,$product_id,$tax_id,$description,$attr1="",$attr2="",$attr3="", $unit_price="") { $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $attr1 = explode("-",$attr1); $attr1 = $attr1[2]; //echo "Attr1: ".$attr1." "; $attr2 = explode("-",$attr2); $attr2 = $attr2[2]; //echo "Attr2 : ".$attr2." "; $attr3 = explode("-",$attr3); $attr3 = $attr3[2]; //echo "Attr3 : ".$attr3; //echo "<br /><br />"; $product = $SI_PRODUCTS->getProductById($product_id); ($unit_price == "") ? $product_unit_price = $product['unit_price'] : $product_unit_price = $unit_price ; $tax = $SI_TAX->getTaxRateById($tax_id); $total_invoice_item_tax = $product_unit_price * $tax['tax_percentage'] / 100; //:100? $tax_amount = $total_invoice_item_tax * $quantity; $total_invoice_item = $total_invoice_item_tax + $product_unit_price; $total = $total_invoice_item * $quantity; $gross_total = $product_unit_price * $quantity; if ($db_server == 'mysql' && !_invoice_items_check_fk( null, $product_id, $tax_id, 'update')) { return null; } $sql = "UPDATE ".TB_PREFIX."invoice_items SET quantity = :quantity, product_id = :product_id, unit_price = :unit_price, tax_id = :tax_id, tax = :tax, tax_amount = :tax_amount, gross_total = :gross_total, description = :description, total = :total, attribute_1 = :attr1, attribute_2 = :attr2, attribute_3 = :attr3 WHERE id = :id"; //echo $sql; return dbQuery($sql, ':quantity', $quantity, ':product_id', $product_id, ':unit_price', $product_unit_price, ':tax_id', $tax_id, ':tax', $tax[tax_percentage], ':tax_amount', $tax_amount, ':gross_total', $gross_total, ':description', $description, ':total', $total, ':id', $id, ':attr1', $attr1, ':attr2', $attr2, ':attr3', $attr3 ); }
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $number_of_rows = $SI_PRODUCTS->getCount(); $smarty -> assign("number_of_rows",$number_of_rows); $pageActive = "products"; $smarty->assign('pageActive', $pageActive); ?>
/* * Script: save.php * Invoice save file * * License: * GPL v3 or above * * Website: * http://www.simpleinvoices.or */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $SI_INVOICES = new SimpleInvoices_Db_Table_Invoices(); $pageActive = "invoices"; $smarty->assign('pageActive', $pageActive); # Deal with op and add some basic sanity checking if(!isset( $_POST['type']) && !isset($_POST['action'])) { exit("no save action"); } $saved = false; $type = $_POST['type'];
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); $debtor = getTopDebtor(); $customer = getTopCustomer(); $biller = getTopBiller(); $billers = $SI_BILLER->fetchAll(); $customers = customer::get_all(); $taxes = $SI_TAX->fetchAll(); $products = $SI_PRODUCTS->fetchAll(); $preferences = $SI_PREFERENCES->fetchAll(); $defaults = $SI_SYSTEM_DEFAULTS->fetchAll(); if ($billers == null OR $customers == null OR $taxes == null OR $products == null OR $preferences == null) { $first_run_wizard =true; $smarty -> assign("first_run_wizard",$first_run_wizard); } $smarty -> assign("mysql",$mysql); $smarty -> assign("db_server",$db_server); /*