示例#1
0
	public static function getInvoiceItems($id) {

		global $logger;
		global $dbh;

		$sql = "SELECT * FROM ".TB_PREFIX."invoice_items WHERE invoice_id = :id order by id";
		$sth = dbQuery($sql, ':id', $id);

		$invoiceItems = null;

		for($i=0;$invoiceItem = $sth->fetch();$i++) {

			$invoiceItem['quantity'] = $invoiceItem['quantity'];
			$invoiceItem['unit_price'] = $invoiceItem['unit_price'];
			$invoiceItem['tax_amount'] = $invoiceItem['tax_amount'];
			$invoiceItem['gross_total'] = $invoiceItem['gross_total'];
			$invoiceItem['total'] = $invoiceItem['total'];

			$sql = "SELECT * FROM ".TB_PREFIX."products WHERE id = :id";
			$tth = dbQuery($sql, ':id', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
			$invoiceItem['product'] = $tth->fetch();

			$tax = taxesGroupedForInvoiceItem($invoiceItem['id']);

			foreach ($tax as $key => $value)
			{
				$invoiceItem['tax'][$key] = $value['tax_id'];
				$logger->log('Invoice: '.$invoiceItem['invoice_id'].' Item id: '.$invoiceItem['id'].' Tax '.$key.' Tax ID: '.$value['tax_id'], Zend_Log::INFO);
			}
			$invoiceItems[$i] = $invoiceItem;
		}

		return $invoiceItems;
	}
示例#2
0
 public function getInvoiceItems($id, $domain_id = '')
 {
     global $logger;
     if (!empty($domain_id)) {
         $this->domain_id = $domain_id;
     }
     $sql = "SELECT * FROM " . TB_PREFIX . "invoice_items WHERE invoice_id = :id AND domain_id = :domain_id ORDER BY id";
     $sth = dbQuery($sql, ':id', $id, ':domain_id', $this->domain_id);
     $invoiceItems = null;
     for ($i = 0; $invoiceItem = $sth->fetch(); $i++) {
         //			$invoiceItem['quantity'] = $invoiceItem['quantity'];
         //			$invoiceItem['unit_price'] = $invoiceItem['unit_price'];
         //			$invoiceItem['tax_amount'] = $invoiceItem['tax_amount'];
         //			$invoiceItem['gross_total'] = $invoiceItem['gross_total'];
         //			$invoiceItem['total'] = $invoiceItem['total'];
         $invoiceItem['attribute_decode'] = json_decode($invoiceItem['attribute'], true);
         foreach ($invoiceItem['attribute_decode'] as $key => $value) {
             $invoiceItem['attribute_json'][$key]['name'] = product_attributes::getName($key);
             $invoiceItem['attribute_json'][$key]['value'] = product_attributes::getValue($key, $value);
             $invoiceItem['attribute_json'][$key]['type'] = product_attributes::getType($key);
             $invoiceItem['attribute_json'][$key]['visible'] = product_attributes::getVisible($key);
         }
         $sql = "SELECT * FROM " . TB_PREFIX . "products WHERE id = :id AND domain_id = :domain_id";
         $tth = dbQuery($sql, ':id', $invoiceItem['product_id'], ':domain_id', $this->domain_id);
         $invoiceItem['product'] = $tth->fetch();
         $tax = taxesGroupedForInvoiceItem($invoiceItem['id']);
         foreach ($tax as $key => $value) {
             $invoiceItem['tax'][$key] = $value['tax_id'];
             $logger->log('Invoice: ' . $invoiceItem['invoice_id'] . ' Item id: ' . $invoiceItem['id'] . ' Tax ' . $key . ' Tax ID: ' . $value['tax_id'], Zend_Log::INFO);
         }
         $invoiceItems[$i] = $invoiceItem;
     }
     return $invoiceItems;
 }