<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_PAYMENT_TYPES = new SimpleInvoices_Db_Table_PaymentTypes(); $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(); #system defaults query $defaults = $SI_SYSTEM_DEFAULTS->fetchAll(); if ($_GET["submit"] == "line_items") { jsBegin(); jsFormValidationBegin("frmpost"); jsValidateifNum("def_num_line_items","Default number of line items"); jsFormValidationEnd(); jsEnd(); $default = "line_items"; $escaped = htmlsafe($defaults[line_items]); $value = <<<EOD <input type="text" size="25" name="value" value="$escaped"> EOD; $description = "{$LANG['default_number_items']}";
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 ); }
* 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(); $defaultCustomerID = (isset($_GET['customer_id'])) ? $_GET['customer_id'] : $SI_CUSTOMERS->getDefault(); $defaultTax = $SI_TAX->getDefault(); $defaultPreference = $SI_PREFERENCES->getDefault();
/** * Get a system default value * * @param mixed $name * @return mixed */ public function findByName($name) { switch ($name) { case 'biller': $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); return $SI_BILLER->getDefault(); break; case 'customer': $SI_CUSTOMERS = new SimpleInvoices_Db_Table_Customers(); return $SI_CUSTOMERS->getDefault(); break; case 'payment_type': $SI_PAYMENT_TYPES = new SimpleInvoices_Db_Table_PaymentTypes(); return $SI_PAYMENT_TYPES->getDefault(); break; case 'preference': $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); return $SI_PREFERENCES->getDefault(); break; case 'tax': $SI_TAX = new SimpleInvoices_Db_Table_Tax(); return $SI_TAX->getDefault(); break; default: $auth_session = Zend_Registry::get('auth_session'); $select = $this->select(); $select->where('name = ?', $name); $select->where('domain_id = ?', $auth_session->domain_id); $result = $this->getAdapter()->fetchRow($select); return $result['value']; break; } }
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); //gets the long language name out of the short name $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_PAYMENT_TYPES = new SimpleInvoices_Db_Table_PaymentTypes(); $SI_CUSTOMERS = new SimpleInvoices_Db_Table_Customers(); $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); $lang = $SI_SYSTEM_DEFAULTS->findByName('language'); $languages = getLanguageList($include_dir . 'sys/lang/'); foreach($languages as $language) { if($language->shortname == $lang) { $lang = $language->name; break; } } // Default delete $defaults['delete'] = $system_defaults->findByName('delete'); $defaults['delete'] = $defaults['delete']==1?$LANG['enabled']:$LANG['disabled']; // Default Logging $defaults['logging'] = $system_defaults->findByName('logging'); $defaults['logging'] = $defaults['logging']==1?$LANG['enabled']:$LANG['disabled']; // Default inventory
function getTaxesPerLineItem($line_item_tax_id,$quantity, $unit_price) { global $logger; $SI_TAX = new SimpleInvoices_Db_Table_Tax(); foreach($line_item_tax_id as $key => $value) { $logger->log("Key: ".$key." Value: ".$value, Zend_Log::INFO); $tax = $SI_TAX->getTaxRateById($value); $logger->log('tax rate: '.$tax['tax_percentage'], Zend_Log::INFO); $tax_amount = lineItemTaxCalc($tax,$unit_price,$quantity); //get Total tax for line item $tax_total = $tax_total + $tax_amount; //$logger->log('Qty: '.$quantity.' Unit price: '.$unit_price, Zend_Log::INFO); //$logger->log('Tax rate: '.$tax[tax_percentage].' Tax type: '.$tax['tax_type'].' Tax $: '.$tax_amount, Zend_Log::INFO); } return $tax_total; }
* * Website: * http://www.simpleinvoices.org */ #table //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); if(!isset($_GET['id'])) { throw new SimpleInvoices_Exception('Invalid invoice identifier'); } $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $SI_CUSTOMERS = new SimpleInvoices_Db_Table_Customers(); $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); #get the invoice id $master_invoice_id = $_GET['id']; $invoice = new SimpleInvoices_Invoice($_GET['id']); //$invoice = getInvoice($master_invoice_id); $invoiceItems = invoice::getInvoiceItems($invoice->getId()); //var_dump($invoiceItems); $customers = $SI_CUSTOMERS->fetchAllActive(); $preference = $invoice->getPreference(); $billers = $SI_BILLER->fetchAllActive();
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); #table jsBegin(); jsFormValidationBegin("frmpost"); jsValidateRequired("tax_description",$LANG['tax_description']); jsValidateifNum("tax_percentage",$LANG['tax_percentage']); jsFormValidationEnd(); jsEnd(); #get the invoice id $tax_rate_id = $_GET['id']; $tax = $SI_TAX->getTaxRateById($tax_rate_id); $types = $types = array( '%' => '%', '$' => '$' ); $smarty -> assign("tax",$tax); $smarty -> assign("types",$types); $smarty -> assign('pageActive', 'tax_rate');
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $smarty -> assign("taxes", $SI_TAX->fetchAll()); $smarty -> assign('pageActive', 'tax_rate'); $smarty -> assign('active_tab', '#setting'); ?>
public static function expense_item_tax($expense_id,$line_item_tax_id,$unit_price,$quantity,$action="") { global $logger; global $db; $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $logger->log("Exp ITEM :: Key: ".$key." Value: ".$value, Zend_Log::INFO); //if editing invoice delete all tax info then insert first then do insert again //probably can be done without delete - someone to look into this if required - TODO if ($action =="update") { $sql_delete = "DELETE from ".TB_PREFIX."expense_item_tax WHERE expense_id = :expense_id"; $logger->log("Expense item: ".$expense_id." tax lines deleted", Zend_Log::INFO); $db->query($sql_delete,':expense_id',$expense_id); } foreach($line_item_tax_id as $key => $value) { if($value !== "") { $tax = $SI_TAX->getTaxRateById($value); $logger->log("Expense - item tax :: Key: ".$key." Value: ".$value, Zend_Log::INFO); $logger->log('Expense - item tax :: tax rate: '.$tax['tax_percentage'], Zend_Log::INFO); $tax_amount = lineItemTaxCalc($tax,$unit_price,$quantity); //get Total tax for line item $tax_total = $tax_total + $tax_amount; $logger->log('Expense - item tax :: Qty: '.$quantity.' Unit price: '.$unit_price, Zend_Log::INFO); $logger->log('Expense - item tax :: Tax rate: '.$tax[tax_percentage].' Tax type: '.$tax['type'].' Tax $: '.$tax_amount, Zend_Log::INFO); $sql = "INSERT INTO ".TB_PREFIX."expense_item_tax ( expense_id, tax_id, tax_type, tax_rate, tax_amount ) VALUES ( :expense_id, :tax_id, :tax_type, :tax_rate, :tax_amount )"; $db->query($sql, ':expense_id', $expense_id, ':tax_id', $tax[tax_id], ':tax_type', $tax[type], ':tax_rate', $tax[tax_percentage], ':tax_amount', $tax_amount ); } } //TODO fix this return true; }
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $display_block = ""; $refresh_total = "<meta http-equiv='refresh' content='2;url=index.php?module=tax_rates&view=manage' />"; # Deal with op and add some basic sanity checking $op = !empty( $_POST['op'] ) ? addslashes( $_POST['op'] ) : NULL; $op = isset($_POST['cancel']) ? "cancel" : $op; switch ($op) { case "insert_tax_rate": { $tax_data = array( 'tax_description' => $_POST['tax_description'], 'tax_percentage' => $_POST['tax_percentage'], 'type' => $_POST['type'], 'tax_enabled' => $_POST['tax_enabled'] ); #insert tax rate if ($SI_TAX->insert($tax_data)) $display_block = $LANG['save_tax_rate_success']; else $display_block = $LANG['save_tax_rate_failure']; break; }
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $product_id = $_GET['id']; $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_PRODUCTS = new SimpleInvoices_Db_Table_Products(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); $SI_CUSTOM_FIELDS = new SimpleInvoices_Db_Table_CustomFields(); $product = $SI_PRODUCTS->getProductById($product_id); #get custom field labels $customFieldLabel = $SI_CUSTOM_FIELDS->getLabels(); $taxes = $SI_TAX->fetchAllActive(); $tax_selected = $SI_TAX->getTaxRateById($product['default_tax_id']); $smarty -> assign("defaults",$SI_SYSTEM_DEFAULTS->fetchAll()); $smarty -> assign('product',$product); $smarty -> assign('taxes',$taxes); $smarty -> assign('tax_selected',$tax_selected); $smarty -> assign('customFieldLabel',$customFieldLabel); $smarty -> assign('pageActive', 'product_manage'); $subPageActive = $_GET['action'] =="view" ? "product_view" : "product_edit" ; $smarty -> assign('subPageActive', $subPageActive); $smarty -> assign('active_tab', '#product'); ?>