public static function addOrderStatusesToDatabase(Package $package) { $table = OrderStatus::getTableName(); $db = Database::get(); $statuses = array(array('osHandle' => 'incomplete', 'osName' => t('Incomplete'), 'osInformSite' => 1, 'osInformCustomer' => 0, 'osIsStartingStatus' => 0), array('osHandle' => 'pending', 'osName' => t('Pending'), 'osInformSite' => 1, 'osInformCustomer' => 1, 'osIsStartingStatus' => 1), array('osHandle' => 'processing', 'osName' => t('Processing'), 'osInformSite' => 1, 'osInformCustomer' => 1, 'osIsStartingStatus' => 0), array('osHandle' => 'shipped', 'osName' => t('Shipped'), 'osInformSite' => 1, 'osInformCustomer' => 1, 'osIsStartingStatus' => 0), array('osHandle' => 'complete', 'osName' => t('Complete'), 'osInformSite' => 1, 'osInformCustomer' => 1, 'osIsStartingStatus' => 0)); foreach ($statuses as $status) { $row = $db->GetRow("SELECT * FROM " . $table . " WHERE osHandle=?", array($status['osHandle'])); if (!isset($row['osHandle'])) { OrderStatus::add($status['osHandle'], $status['osName'], $status['osInformSite'], $status['osInformCustomer'], $status['osIsStartingStatus']); } else { $orderStatus = OrderStatus::getByID($row['osID']); $orderStatus->update($status, true); } } }
private function saveOrderStatuses($data) { if (isset($data['osID'])) { foreach ($data['osID'] as $key => $id) { $orderStatus = OrderStatus::getByID($id); $orderStatusSettings = array('osName' => isset($data['osName'][$key]) && $data['osName'][$key] != '' ? $data['osName'][$key] : $orderStatus->getReadableHandle(), 'osInformSite' => isset($data['osInformSite'][$key]) ? 1 : 0, 'osInformCustomer' => isset($data['osInformCustomer'][$key]) ? 1 : 0, 'osSortOrder' => $key); $orderStatus->update($orderStatusSettings); } if (isset($data['osIsStartingStatus'])) { OrderStatus::setNewStartingStatus(OrderStatus::getByID($data['osIsStartingStatus'])->getHandle()); } else { $orderStatuses = OrderStatus::getAll(); OrderStatus::setNewStartingStatus($orderStatuses[0]->getHandle()); } } }
public static function getByHandle($osHandle) { $db = Database::get(); $data = $db->GetRow("SELECT osID FROM " . self::getTableName() . " WHERE osHandle=?", $osHandle); return OrderStatus::getByID($data['osID']); }