예제 #1
0
 public static function installOrderStatuses(Package $package)
 {
     $table = StoreOrderStatus::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'])) {
             StoreOrderStatus::add($status['osHandle'], $status['osName'], $status['osInformSite'], $status['osInformCustomer'], $status['osIsStartingStatus']);
         } else {
             $orderStatus = StoreOrderStatus::getByID($row['osID']);
             $orderStatus->update($status, true);
         }
     }
 }
예제 #2
0
 public static function getByHandle($osHandle)
 {
     $db = Database::get();
     $data = $db->GetRow("SELECT osID FROM " . self::getTableName() . " WHERE osHandle=?", $osHandle);
     return OrderStatus::getByID($data['osID']);
 }
예제 #3
0
 private function saveOrderStatuses($data)
 {
     if (isset($data['osID'])) {
         foreach ($data['osID'] as $key => $id) {
             $orderStatus = StoreOrderStatus::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'])) {
             StoreOrderStatus::setNewStartingStatus(StoreOrderStatus::getByID($data['osIsStartingStatus'])->getHandle());
         } else {
             $orderStatuses = StoreOrderStatus::getAll();
             StoreOrderStatus::setNewStartingStatus($orderStatuses[0]->getHandle());
         }
     }
 }
예제 #4
0
 private function saveOrderStatuses($data)
 {
     if (isset($data['osID'])) {
         if ($data['osIsStartingStatus']) {
             $existingStartingStatus = StoreOrderStatus::getStartingStatus();
             if (is_object($existingStartingStatus)) {
                 $existingStartingStatus->setIsStartingStatus(false);
                 $existingStartingStatus->save();
             }
         }
         foreach ($data['osID'] as $key => $id) {
             $orderStatus = StoreOrderStatus::getByID($id);
             if (isset($data['osName'][$key]) && $data['osName'][$key] != '') {
                 $orderStatus->setName($data['osName'][$key]);
             } else {
                 $orderStatus->setName($orderStatus->getReadableHandle());
             }
             $orderStatus->setInformSite(isset($data['osInformSite'][$key]) ? 1 : 0);
             $orderStatus->setInformCustomer(isset($data['osInformCustomer'][$key]) ? 1 : 0);
             $orderStatus->setSortOrder($key);
             if ($data['osIsStartingStatus'] == $id) {
                 $orderStatus->setIsStartingStatus(true);
             }
             $orderStatus->save();
         }
     }
 }