/**
  * Execute Hosting Service Order
  *
  * Create a new Hosting Service Purchase for this order item
  *
  * @param AccountDBO $accountDBO Account object
  * @return boolean True for success
  */
 public function execute($accountDBO)
 {
     // Create a hosting service purchase record
     $purchaseDBO = new HostingServicePurchaseDBO();
     $purchaseDBO->setAccountID($accountDBO->getID());
     $purchaseDBO->setHostingServiceID($this->getServiceID());
     $purchaseDBO->setTerm($this->getTerm());
     $purchaseDBO->setDate(DBConnection::format_datetime(time()));
     $purchaseDBO->setDomainName($this->getDomainName());
     $purchaseDBO->setPrevInvoiceID(-1);
     $purchaseDBO->incrementNextBillingDate();
     add_HostingServicePurchaseDBO($purchaseDBO);
     // Fulfill the order and return
     $this->setStatus("Fulfilled");
     update_OrderHostingDBO($this);
     // Success
     return true;
 }
Beispiel #2
0
/**
 * Update OrderDBO in database
 *
 * @param OrderDBO &$dbo OrderDBO to update
 */
function update_OrderDBO(&$dbo)
{
    $DB = DBConnection::getDBConnection();
    // Update all OrderItemDBO's
    foreach ($dbo->getItems() as $orderItemDBO) {
        if (is_a($orderItemDBO, "OrderHostingDBO")) {
            update_OrderHostingDBO($orderItemDBO);
        } elseif (is_a($orderItemDBO, "OrderDomainDBO")) {
            update_OrderDomainDBO($orderItemDBO);
        }
    }
    // Build SQL
    $sql = $DB->build_update_sql("order", "id = " . intval($dbo->getID()), array("businessname" => $dbo->getBusinessName(), "datecreated" => $dbo->getDateCreated(), "datecompleted" => $dbo->getDateCompleted(), "datefulfilled" => $dbo->getDateFulfilled(), "remoteip" => $dbo->getRemoteIP(), "contactname" => $dbo->getContactName(), "contactemail" => $dbo->getContactEmail(), "address1" => $dbo->getAddress1(), "address2" => $dbo->getAddress2(), "city" => $dbo->getCity(), "state" => $dbo->getState(), "country" => $dbo->getCountry(), "postalcode" => $dbo->getPostalCode(), "phone" => $dbo->getPhone(), "mobilephone" => $dbo->getMobilePhone(), "fax" => $dbo->getFax(), "username" => $dbo->getUsername(), "password" => $dbo->getPassword(), "accountid" => $dbo->getAccountID(), "status" => $dbo->getStatus(), "note" => $dbo->getNote(), "accepted_tos" => $dbo->getAcceptedTOS()));
    // Run query
    if (!mysql_query($sql, $DB->handle())) {
        throw new DBException(mysql_error($DB->handle()));
    }
}