Пример #1
0
 private function loadItems($reload = false)
 {
     if ($this->items_total == 0 || $reload == true) {
         $this->items = array();
         $this->items_canceled = array();
         $this->items_notcanceled = array();
         $this->items_total_qty = 0;
         $this->items_canceled_total_qty = 0;
         $this->items_notcanceled_total_qty = 0;
         $this->items_returned = array();
         $this->items_returned_total_qty = 0;
         if ($this->isOrderFromSalesPartner()) {
             $table = OrderItem::TABLENAME_SP;
             $colname_order_id = self::COLNAME_ID_SP;
             $colname_item_id = OrderItem::COLNAME_ID_SP;
         } elseif ($this->isOrderFromJulieGrace()) {
             $table = OrderItem::TABLENAME_JG;
             $colname_order_id = self::COLNAME_ID_JG;
             $colname_item_id = OrderItem::COLNAME_ID_JG;
         }
         $q = "SELECT {$colname_item_id} FROM {$table} WHERE {$colname_order_id}" . " = '" . $this->order_id . "'";
         $r = tep_db_query($q);
         while ($row = tep_db_fetch_array($r)) {
             $item_id = $row[$colname_item_id];
             $i = new OrderItem($this, $item_id);
             $this->items[$item_id] = $i;
             $this->items_total_qty += $i->ordered_quantity;
             if (statusIsCancelled($i->status)) {
                 $this->items_canceled[$item_id] = $i;
                 $this->items_canceled_total_qty += $i->ordered_quantity;
             } else {
                 $this->items_notcanceled[$item_id] = $i;
                 $this->items_notcanceled_total_qty += $i->ordered_quantity;
             }
             $return_qty = $i->getReturnQuantity();
             if ($return_qty > 0) {
                 $this->items_returned[$item_id] = $i;
                 $this->items_returned_total_qty += $return_qty;
             }
         }
         $this->items_total = count($this->items);
         $this->items_canceled_total = count($this->items_canceled);
         $this->items_notcanceled_total = count($this->items_notcanceled);
         $this->items_returned_total = count($this->items_returned);
     }
 }