public function getStorelist() { $stores = new TStore(); $astores = $stores->find()->asArray()->all(); $res = []; foreach ($astores as $a) { $res[$a['id']] = $a['name']; } return $res; }
private function getStores() { if (!empty($city = $this->getCityId())) { $store = TStore::find()->select('id')->asArray()->where('city_id = :city_id', [':city_id' => $city])->all(); } return !empty($store) ? $store : false; }
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; }
private function getCityId($options) { if (!empty($options['city_id'])) { $this->cityId = $options['city_id']; unset($options['city_id']); } else { if (!empty($options['store_id'])) { $this->cityId = TStore::find()->select('city_id')->where('id = :id', [':id' => $options['store_id']])->one()->city_id; } else { if (!empty($cookie = Yii::$app->request->cookies['city'])) { $this->cityId = (int) $cookie->value; } } } return $this->cityId; }
public function getStore() { return $this->hasOne(TStore::className(), ['id' => 'store_id']); }
public function searchCity() { $query = TStore::find()->groupBy('city_id'); $dataProvider = new ActiveDataProvider(['query' => $query]); return $dataProvider; }
/** * Функция определения city_id по StoreID - id магазина * @param $store_id * @return int|mixed */ public function getCityid($store_id) { $store = \app\modules\autoparts\models\TStore::find()->where(['id' => $store_id])->one(); return !empty($store) ? $store->city_id : ''; }