/** * Save Changes * * Write any changes made to the order to the database * * @return boolean True for success */ function saveChanges() { if ($this->get['order']->getAccountType() == "New Account") { if (!isset($this->post['username'])) { throw new FieldMissingException("username"); } try { load_UserDBO($this->post['username']); throw new SWUserException("[DB_USER_EXISTS]"); } catch (DBNoRowsFoundException $e) { } $this->get['order']->setUsername($this->post['username']); if (isset($this->post['password'])) { $this->get['order']->setPassword($this->post['password']); } } // Update OrderDBO $this->get['order']->setContactName($this->post['contactname']); $this->get['order']->setContactEmail($this->post['contactemail']); $this->get['order']->setAddress1($this->post['address1']); $this->get['order']->setAddress2($this->post['address2']); $this->get['order']->setCity($this->post['city']); $this->get['order']->setState($this->post['state']); $this->get['order']->setCountry($this->post['country']); $this->get['order']->setPostalCode($this->post['postalcode']); $this->get['order']->setPhone($this->post['phone']); $this->get['order']->setMobilePhone($this->post['mobilephone']); $this->get['order']->setFax($this->post['fax']); $acceptedItems = is_array($this->post['items']) ? $this->post['items'] : array(); foreach ($this->get['order']->getItems() as $itemDBO) { if (in_array($itemDBO, $acceptedItems)) { $this->get['order']->acceptItem($itemDBO->getOrderItemID()); } else { $this->get['order']->rejectItem($itemDBO->getOrderItemID()); } } // Save changes to database update_OrderDBO($this->get['order']); }
/** * Complete Order * * Set the status to "Pending" and the data completed to now, then update DB */ public function complete() { // Set status to pending and give a timestamp $this->setStatus("Pending"); $this->setDateCompleted(DBConnection::format_datetime(time())); // Update the database record update_OrderDBO($this); // Notification e-mail $body = $this->replaceTokens($conf['order']['notification_email']); $notifyEmail = new Email(); $notifyEmail->addRecipient($conf['company']['notification_email']); $notifyEmail->setFrom($conf['company']['email'], "SolidState"); $notifyEmail->setSubject($conf['order']['notification_subject']); $notifyEmail->setBody($body); if (!$notifyEmail->send()) { log_error("OrderDBO::complete()", "Failed to send notification e-mail."); } // Confirmation e-mail $body = $this->replaceTokens($conf['order']['confirmation_email']); $confirmEmail = new Email(); $confirmEmail->addRecipient($this->getContactEmail()); $confirmEmail->setFrom($conf['company']['email'], $conf['company']['name']); $confirmEmail->setSubject($conf['order']['confirmation_subject']); $confirmEmail->setBody($body); if (!$confirmEmail->send()) { log_error("OrderDBO::complete()", "Failed to send confirmation e-mail."); } }