-version: '2'
services:
nginx-yii_erp24:
build: ./docker/nginx
use yii\base\DynamicModel;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
+use yii\web\Response;
use yii_app\records\CityStore;
use yii_app\records\ExportImportTable;
use yii_app\records\Sales;
return $this->render('index', compact('model', 'years', 'stores', 'table', 'tableOnline',
'tableWriteOffs', 'types', 'salesWriteOffsPlan'));
}
+
+ public function actionGetStores() {
+ Yii::$app->response->format = Response::FORMAT_JSON;
+ $cityId = Yii::$app->request->post('city_id');
+ $regionId = Yii::$app->request->post('region_id');
+ $raionId = Yii::$app->request->post('raion_id');
+ $storeTypeId = Yii::$app->request->post('store_type_id');
+// $territoryManagerId = Yii::$app->request->post('territory_manager_id');
+// $kshfId = Yii::$app->request->post('kshf_id');
+
+ $stores = CityStore::find()
+ ->andFilterWhere([
+ 'visible' => 1,
+ 'city' => $cityId,
+ 'region' => $regionId,
+ 'district' => $raionId,
+ 'type' => $storeTypeId,
+ ])
+// ->andFilterWhere(['in', 'id', $bushChefFloristStoreIds])
+// ->andFilterWhere(['in', 'id', $territorialManagerStoreIds])
+ ->orderBy('id')
+ ->all();
+
+
+ return ArrayHelper::map($stores, 'id', 'name');
+ }
}
use yii\helpers\Html;
use yii\base\DynamicModel;
use yii\widgets\ActiveForm;
+use yii\helpers\ArrayHelper;
use kartik\select2\Select2;
use yii_app\helpers\HtmlHelper;
use yii_app\records\SalesWriteOffsPlan;
+use yii_app\records\StoreCityList;
/* @var $model DynamicModel */
/* @var $years array */
</div>
<div class="col-4">
<?= $form->field($model, 'city_id')->widget(Select2::class, [
- 'data' => [0 => 'Москва', 1 => 'Нижний Новгород'],
+ 'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'),
'language' => 'ru',
'options' => ['placeholder' => 'Города...'],
'pluginOptions' => [
</div>
<div class="col-4">
<?= $form->field($model, 'region_id')->widget(Select2::class, [
- 'data' => [0 => 'Московская обл.', 1 => 'Нижегородская обл.'],
+ 'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_REGION]), 'id', 'name'),
'language' => 'ru',
'options' => ['placeholder' => 'Регион...'],
'pluginOptions' => [
</div>
<div class="col-4">
<?= $form->field($model, 'raion_id')->widget(Select2::class, [
- 'data' => [0 => 'Автозаводский', 1 => 'Канавинский'],
+ 'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_DISTRICT]), 'id', 'name'),
'language' => 'ru',
'options' => ['placeholder' => 'Район...'],
'pluginOptions' => [
<div class="col-1">
<div class="row" style="min-height: 150px; align-items: center;">
<div class="col-12">
- <button>
+ <button onclick="updateStores(); return false;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play-fill" viewBox="0 0 16 16">
<path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393"/>
</svg>
const param26 = $('meta[name=csrf-param]').attr('content');
const token26 = $('meta[name=csrf-token]').attr('content');
+function updateStores() {
+ const city_id = $('#dynamicmodel-city_id').val();
+ const region_id = $('#dynamicmodel-region_id').val();
+ const raion_id = $('#dynamicmodel-raion_id').val();
+ const store_type_id = $('#dynamicmodel-store_type_id').val();
+ const territory_manager_id = $('#dynamicmodel-territory_manager_id').val();
+ const kshf_id = $('#dynamicmodel-kshf_id').val();
+ $.ajax({
+ method: "POST",
+ url: '/category-plan/get-stores',
+ data: { city_id, region_id, raion_id, store_type_id, territory_manager_id, kshf_id, [param26] : token26 },
+ dataType: 'json',
+ success: function (data) {
+ $('#selected-store').empty();
+ $.each(data, (key, value) => {
+ const option = document.createElement('OPTION');
+ option.value = key;
+ option.text = value;
+ $('#selected-store').append(option);
+ });
+ }
+ });
+}
+
$(document).ready(() => {
$('#categoryPlan').DataTable({
sorting: false,