/**
  * Initialize the Table
  *
  * @param array $params Parameters from the {form_table} tag
  */
 public function init($params)
 {
     parent::init($params);
     // Build an ProductPurchase filter
     $where = isset($this->accountID) ? sprintf("accountid='%d'", $this->accountID) : null;
     // Load the ProductPurchase Table
     try {
         // Build the table
         $purchases = load_array_ProductPurchaseDBO($where);
         foreach ($purchases as $dbo) {
             // Put the row into the table
             $this->data[] = array("id" => $dbo->getID(), "productname" => $dbo->getProductName(), "note" => $dbo->getNote(), "date" => $dbo->getDate(), "term" => $dbo->getTerm(), "nextbillingdate" => $dbo->getNextBillingDate());
         }
     } catch (DBNoRowsFoundException $e) {
     }
 }
Example #2
0
/**
 * Delete ProductDBO
 *
 * @param ProductDBO &$dbo ProductDBO to be deleted
 * @return boolean True on success
 */
function delete_ProductDBO(&$dbo)
{
    $DB = DBConnection::getDBConnection();
    try {
        load_array_ProductPurchaseDBO("productid=" . $dbo->getID());
        // Can not delete product if any purchases exist
        throw new DBException("[PURCHASES_EXIST]");
    } catch (DBNoRowsFoundException $e) {
    }
    // Build SQL
    $sql = $DB->build_delete_sql("product", "id = " . intval($dbo->getID()));
    // Run query
    if (!mysql_query($sql, $DB->handle())) {
        throw new DBException(mysql_error($DB->handle()));
    }
}
Example #3
0
 /**
  * Get Product Purchases for this Account
  *
  * return array Array of ProductPurchaseDBO's for this account
  */
 function getProducts()
 {
     try {
         return load_array_ProductPurchaseDBO("accountid=" . intval($this->getID()));
     } catch (DBNoRowsFoundException $e) {
         return array();
     }
 }