コード例 #1
0
 /**
  * Add Item to Invoice
  *
  * Creates an InvoiceItemDBO and adds it to this Invoice
  *
  * @param integer $quantity Quantity of units
  * @param double $unitamount Cost of each unit
  * @param string $text Description of unit(s)
  * @param boolean $taxflag True if this item is a tax item
  */
 function add_item($quantity, $unitamount, $text, $taxflag)
 {
     // Create a new Invoice Item DBO
     $itemdbo = new InvoiceItemDBO();
     $itemdbo->setInvoiceID($this->getID());
     $itemdbo->setQuantity($quantity);
     $itemdbo->setUnitAmount($unitamount);
     $itemdbo->setText($text);
     $itemdbo->setTaxItem($taxflag ? "Yes" : "No");
     // Add DBO to invoice
     if ($this->getID() != null) {
         // Invoice already exists in database, so go ahead and Insert line-item
         // into database
         add_InvoiceItemDBO($itemdbo);
     }
     $this->invoiceitemdbo_array[] = $itemdbo;
 }
コード例 #2
0
/**
 * Load multiple InvoiceItemDBO's from database
 *
 * @param string $filter A WHERE clause
 * @param string $sortby Field name to sort results by
 * @param string $sortdir Direction to sort in (ASEC or DESC)
 * @param int $limit Limit the number of results
 * @param int $start Record number to start the results at
 * @return array Array of InvoiceItemDBO's
 */
function &load_array_InvoiceItemDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null)
{
    $DB = DBConnection::getDBConnection();
    // Build query
    $sql = $DB->build_select_sql("invoiceitem", "*", $filter, $sortby, $sortdir, $limit, $start);
    // Run query
    if (!($result = @mysql_query($sql, $DB->handle()))) {
        // Query error
        throw new DBException(mysql_error($DB->handle()));
    }
    if (mysql_num_rows($result) == 0) {
        // No services found
        throw new DBNoRowsFoundException();
    }
    // Build an array of DBOs from the result set
    $dbo_array = array();
    while ($data = mysql_fetch_array($result)) {
        // Create and initialize a new DBO with the data from the DB
        $dbo = new InvoiceItemDBO();
        $dbo->load($data);
        // Add HostingServiceDBO to array
        $dbo_array[] = $dbo;
    }
    return $dbo_array;
}
コード例 #3
0
 /**
  * Add Line Item
  *
  * Create a new InvoiceLineItemDBO and attach it to the Invoice
  */
 function add_line_item()
 {
     // Create new Line Item DBO
     $lineitem_dbo = new InvoiceItemDBO();
     $lineitem_dbo->setText($this->post['text']);
     $lineitem_dbo->setUnitAmount($this->post['unitamount']);
     $lineitem_dbo->setQuantity($this->post['quantity']);
     $lineitem_dbo->setInvoiceID($this->get['invoice']->getID());
     // Save Lineitem to database
     add_InvoiceItemDBO($lineitem_dbo);
     // Success
     $this->setMessage(array("type" => "[INVOICE_ITEM_CREATED]"));
 }