public function insert_item() { $sql = "INSERT INTO " . TB_PREFIX . "invoice_items \n\t\t\t\t(\n\t\t\t\t\tinvoice_id, \n\t\t\t\t\tquantity, \n\t\t\t\t\tproduct_id, \n\t\t\t\t\tunit_price, \n\t\t\t\t\ttax_amount, \n\t\t\t\t\tgross_total, \n\t\t\t\t\tdescription, \n\t\t\t\t\ttotal\n\t\t\t\t) \n\t\t\t\tVALUES \n\t\t\t\t(\n\t\t\t\t\t:invoice_id, \n\t\t\t\t\t:quantity, \n\t\t\t\t\t:product_id, \n\t\t\t\t\t:unit_price, \n\t\t\t\t\t:tax_amount, \n\t\t\t\t\t:gross_total, \n\t\t\t\t\t:description, \n\t\t\t\t\t:total\n\t\t\t\t)"; //echo $sql; dbQuery($sql, ':invoice_id', $this->invoice_id, ':quantity', $this->quantity, ':product_id', $this->product_id, ':unit_price', $this->unit_price, ':tax_amount', $this->tax_amount, ':gross_total', $this->gross_total, ':description', $this->description, ':total', $this->total); invoice_item_tax(lastInsertId(), $this->tax, $this->unit_price, $this->quantity, "insert"); }
public function insert_item() { $sql = "INSERT INTO " . TB_PREFIX . "invoice_items \n\t\t\t\t(\n\t\t\t\t\tinvoice_id, \n\t\t\t\t\tdomain_id, \n\t\t\t\t\tquantity, \n\t\t\t\t\tproduct_id, \n\t\t\t\t\tunit_price, \n\t\t\t\t\ttax_amount, \n\t\t\t\t\tgross_total, \n\t\t\t\t\tdescription, \n\t\t\t\t\ttotal,\n\t\t\t\t\tattribute\n\t\t\t\t) \n\t\t\t\tVALUES \n\t\t\t\t(\n\t\t\t\t\t:invoice_id, \n\t\t\t\t\t:domain_id, \n\t\t\t\t\t:quantity, \n\t\t\t\t\t:product_id, \n\t\t\t\t\t:unit_price, \n\t\t\t\t\t:tax_amount, \n\t\t\t\t\t:gross_total, \n\t\t\t\t\t:description, \n\t\t\t\t\t:total,\n\t\t\t\t\t:attribute\n\t\t\t\t)"; dbQuery($sql, ':invoice_id', $this->invoice_id, ':domain_id', $this->domain_id, ':quantity', $this->quantity, ':product_id', $this->product_id, ':unit_price', $this->unit_price, ':tax_amount', $this->tax_amount, ':gross_total', $this->gross_total, ':description', trim($this->description), ':total', $this->total, ':attribute', $this->attribute); $inv_item_id = lastInsertId(); invoice_item_tax($inv_item_id, $this->tax, $this->unit_price, $this->quantity, 'insert', $this->domain_id); return $inv_item_id; }
} ?> </td> <td align="right" class= "espai"> <?php echo invoice_item_unit_price($item); ?> </td> <td align="right" class= "espai"> <?php echo invoice_item_tax_rate($item); ?> </td> <td align="right" class= "espai"> <?php echo invoice_item_tax($item); ?> </td> <td align="right" class= "espai"> <?php echo invoice_item_total($item); ?> </td> </tr> <?php } } ?> <tr> <td colspan="3"></td> <td colspan="4">
function updateInvoiceItem($id, $quantity, $product_id, $line_number, $line_item_tax_id, $description, $unit_price, $attribute = "", $domain_id = '') { global $logger; global $LANG; global $db_server; $domain_id = domain_id::get($domain_id); //$product = getProduct($product_id); //$tax = getTaxRate($tax_id); $attr = array(); $logger->log('Line item attributes: ' . var_export($attribute, true), Zend_Log::INFO); foreach ($attribute as $k => $v) { if ($attribute[$v] !== '') { $attr[$k] = $v; } } $tax_total = getTaxesPerLineItem($line_item_tax_id, $quantity, $unit_price); $logger->log('Invoice: ' . $invoice_id . ' Tax ' . $line_item_tax_id . ' for line item ' . $line_number . ': ' . $tax_total, Zend_Log::INFO); $logger->log('Description: ' . $description, Zend_Log::INFO); $logger->log(' ', Zend_Log::INFO); //line item gross total $gross_total = $unit_price * $quantity; //line item total $total = $gross_total + $tax_total; //Remove jquery auto-fill description - refer jquery.conf.js.tpl autofill section if ($description == $LANG['description']) { $description = ""; } if ($db_server == 'mysql' && !_invoice_items_check_fk(null, $product_id, $tax_id, 'update')) { return null; } $sql = "UPDATE " . TB_PREFIX . "invoice_items \n\tSET quantity = :quantity,\n\tproduct_id = :product_id,\n\tunit_price = :unit_price,\n\ttax_amount = :tax_amount,\n\tgross_total = :gross_total,\n\tdescription = :description,\n\ttotal = :total,\t\t\t\n\tattribute = :attribute\t\t\t\n\tWHERE id = :id AND domain_id = :domain_id"; dbQuery($sql, ':quantity', $quantity, ':product_id', $product_id, ':unit_price', $unit_price, ':tax_amount', $tax_total, ':gross_total', $gross_total, ':description', $description, ':total', $total, ':attribute', json_encode($attr), ':id', $id, ':domain_id', $domain_id); //if from a new invoice item in the edit page user lastInsertId() $id == null ? $id = lastInsertId() : ($id = $id); invoice_item_tax($id, $line_item_tax_id, $unit_price, $quantity, "update"); return true; }
public function insert_item() { global $LANG; $tax_total = getTaxesPerLineItem($this->line_item_tax_id,$this->quantity, $this->unit_price); //line item gross total $gross_total = $this->unit_price * $this->quantity; //line item total $total = $gross_total + $tax_total; //Remove jquery auto-fill description - refer jquery.conf.js.tpl autofill section if ($this->description == $LANG['description']) { $this->description =""; } if ($db_server == 'mysql' && !_invoice_items_check_fk( $invoice_id, $product_id, $tax['tax_id'])) { return null; } $sql = "INSERT INTO ".TB_PREFIX."invoice_items ( invoice_id, quantity, product_id, unit_price, tax_amount, gross_total, description, total ) VALUES ( :invoice_id, :quantity, :product_id, :unit_price, :tax_amount, :gross_total, :description, :total )"; //echo $sql; dbQuery($sql, ':invoice_id', $this->invoice_id, ':quantity', $this->quantity, ':product_id', $this->product_id, ':unit_price', $this->unit_price, // ':tax_id', $tax[tax_id], // ':tax_percentage', $tax[tax_percentage], ':tax_amount', $tax_total, ':gross_total', $gross_total, ':description', $this->description, ':total', $total ); invoice_item_tax(lastInsertId(),$this->tax,$this->unit_price,$this->quantity,"insert"); return true; }
function updateInvoiceItem($id, $quantity, $product_id, $line_number, $line_item_tax_id, $description, $unit_price) { global $logger; global $LANG; //$product = getProduct($product_id); //$tax = getTaxRate($tax_id); $tax_total = getTaxesPerLineItem($line_item_tax_id, $quantity, $unit_price); $logger->log('Invoice: ' . $invoice_id . ' Tax ' . $line_item_tax_id . ' for line item ' . $line_number . ': ' . $tax_total, Zend_Log::INFO); $logger->log('Description: ' . $description, Zend_Log::INFO); $logger->log(' ', Zend_Log::INFO); //line item gross total $gross_total = $unit_price * $quantity; //line item total $total = $gross_total + $tax_total; //Remove jquery auto-fill description - refer jquery.conf.js.tpl autofill section if ($description == $LANG['description']) { $description = ""; } if ($db_server == 'mysql' && !_invoice_items_check_fk(null, $product_id, $tax_id, 'update')) { return null; } $sql = "UPDATE " . TB_PREFIX . "invoice_items \n\tSET quantity = :quantity,\n\tproduct_id = :product_id,\n\tunit_price = :unit_price,\n\ttax_amount = :tax_amount,\n\tgross_total = :gross_total,\n\tdescription = :description,\n\ttotal = :total\t\t\t\n\tWHERE id = :id"; //echo $sql; dbQuery($sql, ':quantity', $quantity, ':product_id', $product_id, ':unit_price', $unit_price, ':tax_amount', $tax_total, ':gross_total', $gross_total, ':description', $description, ':total', $total, ':id', $id); //if from a new invoice item in the edit page user lastInsertId() $id == null ? $id = lastInsertId() : ($id = $id); invoice_item_tax($id, $line_item_tax_id, $unit_price, $quantity, "update"); return true; }