コード例 #1
0
ファイル: OrdersModel.php プロジェクト: sov-20-07/billing
 public function getOrderById($id)
 {
     $sql = 'SELECT * FROM {{orders}} WHERE id=' . $id;
     $data = DB::getRow($sql);
     if ($data['address']) {
         $data['address'] = unserialize($data['address']);
     }
     if (strpos($data['saletype'], '(') !== false) {
         $data['saleperc'] = explode('(', $data['saletype']);
         $data['saleperc'] = explode(')', $data['saleperc'][count($data['saleperc']) - 1]);
         $data['saleperc'] = str_replace('%', '', $data['saleperc'][0]);
     } else {
         $data['saleperc'] = 0;
     }
     $sql = 'SELECT * FROM {{iusers_bonuses}} WHERE orderid=' . $id . '';
     $list = DB::getAll($sql);
     foreach ($list as $item) {
         if (strpos($item['reason'], '(') !== false) {
             $item['perc'] = explode('(', $item['reason']);
             $item['perc'] = explode(')', $item['perc'][count($item['perc']) - 1]);
             $item['perc'] = str_replace('%', '', $item['perc'][0]);
         } else {
             $item['perc'] = 0;
         }
         if ($item['amount'] > 0) {
             $data['bonusesinfo']['in'] = $item;
         } else {
             $data['bonusesinfo']['out'] = $item;
         }
     }
     $data['city'] = $data['address']['city'];
     $sql = 'SELECT * FROM {{orders_items}} WHERE orders=' . $data['id'] . '';
     $items = DB::getAll($sql);
     $sum = 0;
     $count = 0;
     $sale = 0;
     $weight = 0;
     $data['goods'] = array();
     foreach ($items as $item) {
         $item['info'] = Goods::getOne($item['tree']);
         $item['art'] = Goods::getSizeByName($item['tree'], $item['size']);
         $data['goods'][] = $item;
         $sum += $item['price'] * $item['num'];
         $weight += $item['info']['weight'];
         $count++;
     }
     if ($data['iuser']) {
         $data['client'] = Iuser::getIuser($data['iuser']);
         $data['fio'] = $data['client']['lastname'] . ' ' . $data['client']['firstname'] . ' ' . $data['client']['secondname'];
     }
     $data['sum'] = $sum;
     $data['count'] = $count;
     $data['weight'] = $weight;
     //$data['postal']=unserialize($data['postal']);
     $data['authoradd'] = User::getUser($data['authoradd']);
     $data['authoredit'] = User::getUser($data['authoredit']);
     return $data;
 }
コード例 #2
0
ファイル: DeliveryModel.php プロジェクト: sov-20-07/billing
 public static function getParcel($what, $orderid = 0)
 {
     $data = array('volume' => 0, 'weight' => 0, 'height' => 0, 'width' => 0, 'length' => 0);
     if ($what == 'site') {
         $order = Basket::getOrder();
         $arrField = 'goods';
         $data = array('volume' => 0, 'weight' => 0);
         foreach ($order[$arrField] as $item) {
             if ($item['set'] == true) {
                 foreach ($item['goods'] as $goods) {
                     $temp = Catalog::getArticle($goods['sizeId']);
                     $data['volume'] += $temp['height'] * $temp['width'] * $temp['length'];
                     $data['weight'] += $temp['weight'];
                     if ($temp['width'] > $data['width']) {
                         $data['width'] = $temp['width'];
                     }
                     if ($temp['length'] > $data['length']) {
                         $data['length'] = $temp['length'];
                     }
                     $data['height'] += $temp['height'];
                 }
             } else {
                 $temp = Catalog::getArticle($item['sizeId']);
                 $data['volume'] += $temp['height'] * $temp['width'] * $temp['length'];
                 $data['weight'] += $temp['weight'];
                 if ($temp['width'] > $data['width']) {
                     $data['width'] = $temp['width'];
                 }
                 if ($temp['length'] > $data['length']) {
                     $data['length'] = $temp['length'];
                 }
                 $data['height'] += $temp['height'];
             }
         }
         $data['volume'] = $data['volume'] / 1000000;
         $data['weight'] = $data['weight'] / 1000;
         $address = Region::getCity($_SESSION['iuser']['address'][0]['city']);
     } else {
         $order = Orders::getOrderById($orderid);
         foreach ($order['goods'] as $item) {
             $temp = Goods::getSizeByName($item['tree'], $item['size']);
             $data['volume'] += $temp['height'] * $temp['width'] * $temp['length'];
             $data['weight'] += $temp['weight'];
             if ($temp['width'] > $data['width']) {
                 $data['width'] = $temp['width'];
             }
             if ($temp['length'] > $data['length']) {
                 $data['length'] = $temp['length'];
             }
             $data['height'] += $temp['height'];
         }
         $data['volume'] = $data['volume'] / 1000000;
         $data['weight'] = $data['weight'] / 1000;
         $address = IuserAddress::getCity($order['address']['city']);
     }
     return array('data' => $data, 'address' => $address);
 }