public static function finddetails($params) { $p = array_merge(Yii::$app->request->post(), Yii::$app->request->get()); $params['store_id'] = !empty($p['store_id']) ? $p['store_id'] : 109; $tstore = new TStore(); $store = $tstore->findOne(['id' => $params['store_id']]); $params['city_id'] = $store->city_id; // var_dump($params);die; $details = Tovar::findDetails($params); $xml = '<?xml version="1.0" encoding="utf-8"?> <ArrayOfDetailInfo>'; foreach ($details as $d) { $xml .= '<DetailInfo> <detailnumber>' . $d['code'] . '</detailnumber> <detailname>' . htmlspecialchars($d['name'], ENT_XML1) . '</detailname> <dname>' . htmlspecialchars($d['name'], ENT_XML1) . '</dname> <maker> <id>-</id> <name>' . htmlspecialchars($d['manufacture'], ENT_XML1) . '</name> </maker> <quantity>' . $d['quantity'] . '</quantity> <lotquantity>' . $d['lotquantity'] . '</lotquantity> <price>' . $d['price'] . '</price> <pricedestination>' . $d['pricedestination'] . '</pricedestination> <days>' . $d['srokmin'] . '</days> <dayswarranty>' . $d['srokmax'] . '</dayswarranty> <regionname>' . htmlspecialchars($d['sklad'], ENT_XML1) . '</regionname> <estimation>' . $d['estimation'] . '</estimation> <orderrefernce>' . $d['reference'] . '</orderrefernce> <pricedate>' . $d['pricedate'] . '</pricedate> <groupid>' . $d['groupid'] . '</groupid> <provider>' . $d['provider'] . '</provider> <pid>' . $d['pid'] . '</pid> <storeid>' . $d['storeid'] . '</storeid> <FlagPostav>' . $d['flagpostav'] . '</FlagPostav> <srok>' . $d['srok'] . '</srok> <ball>' . $d['ball'] . '</ball> </DetailInfo>'; } $xml .= ' </ArrayOfDetailInfo>'; return $xml; }
public function actionFinddetails() { $params = \Yii::$app->request->queryParams; $parts = Yii::$app->params['Parts']; $details = isset($params['article']) ? Tovar::findDetails($params) : []; $provider = new ArrayDataProvider(['allModels' => $details, 'sort' => $parts['sort'], 'pagination' => $parts['pagination']]); $catalog = Yii::$app->getModule('autocatalog')->getModel(); return $this->render('finddetails_tabs', ['provider' => $provider, 'columns' => $parts['columns'], 'params' => $params, 'catalog' => $catalog]); }
public function actionPricing() { $id = (int) Yii::$app->request->post('order'); $code = Yii::$app->request->post('code'); $city = (int) Yii::$app->request->post('city_id'); if (empty($id) && empty($code)) { return false; } $allDetails = []; if (!empty($id)) { $details = OrdersSearch::find()->where('order_id = :order_id', [':order_id' => $id])->andWhere('status = :status', [':status' => [Orders::ORDER_ADOPTED, Orders::ORDER_CANCELED, Orders::ORDER_CANCELED_BY_PROVIDER]])->andWhere('provider_id <> 5 OR provider_id IS NULL')->andWhere('related_detail IS NULL')->all(); // var_dump($details);die; foreach ($details as $detail) { $article = !empty($detail->product_article) ? $detail->product_article : (!empty($detail->product_id) ? $detail->product_id : null); $compareDetails = Tovar::findDetails(['article' => $article, 'city_id' => $detail->order->store->city_id]); $allDetails[$article]['manufacture'] = $detail->manufacture; $allDetails[$article]['offers'] = $compareDetails; } } else { $allDetails[$code]['offers'] = Tovar::findDetails(['article' => $code, 'city_id' => $city]); } $offers = []; foreach ($allDetails as $key => $detail_offers) { if (is_array($detail_offers) && !empty($detail_offers)) { foreach ($detail_offers['offers'] as $offer) { if (strtoupper($offer['code']) == strtoupper($key)) { $offers[$key]['offers'][] = $offer; } } } } if (!empty($id)) { $firstOffers = $this->firstOffers($details, $offers); $data = $this->buildArray($firstOffers, $offers, $details); $orderdetails = $details; } else { $data = $offers[key($offers)]['offers']; $orderdetails['order_id'] = Yii::$app->request->post('order_id'); $orderdetails['detail_id'] = 0; } $dataProvider = new ArrayDataProvider(['allModels' => $data, 'pagination' => false]); $offersData = $this->toDataProvider($offers); $params = ['model' => $dataProvider, 'offersData' => $offersData, 'orderedDetails' => $orderdetails]; return Json::encode(['output' => '', 'table' => $this->renderAjax('_pricing', $params)]); }