/** * Execute Domain Order * * Register or Transfer the domain and create a new Domain Service Purchase * for this order item * * @param AccountDBO $accountDBO Account object * @return boolean True for success */ function execute($accountDBO) { switch ($this->getType()) { case "Existing": // Do nothing return true; break; case "New": if (!$this->registerDomain($accountDBO)) { return false; } break; case "Transfer": if (!$this->transferDomain($accountDBO)) { return false; } break; default: fatal_error("OrderDomainDBO::execute()", "Domain order type not supported: " . $this->getType()); } // Create a new domain service purchase record $purchaseDBO = new DomainServicePurchaseDBO(); $purchaseDBO->setAccountID($accountDBO->getID()); $purchaseDBO->setTLD($this->getTLD()); $purchaseDBO->setTerm($this->getTerm()); $purchaseDBO->setDomainName($this->getDomainName()); $purchaseDBO->setDate(DBConnection::format_datetime(time())); $purchaseDBO->setPrevInvoiceID(-1); $purchaseDBO->incrementNextBillingDate(); add_DomainServicePurchaseDBO($purchaseDBO); // Fulfill this order item $this->setStatus("Fulfilled"); update_OrderDomainDBO($this); // Success return true; }
/** * 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())); } }