public function actionGetVisibleStores()
{
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- $f = Yii::$app->request->get();
+ $filters = Yii::$app->request->get();
- $q = CityStoreParams::find()
+ $query = CityStoreParams::find()
->alias('p')
->joinWith(['store s'])
->select('p.store_id')
->where(['s.visible' => CityStore::IS_VISIBLE]);
- foreach ([
- 'city' => 'p.address_city',
- 'storeType' => 'p.store_type',
- 'region' => 'p.address_region',
- 'district' => 'p.address_district'
- ] as $param => $col) {
- if (!empty($f[$param])) $q->andWhere([$col => $f[$param]]);
+ $query->andFilterWhere(['=', 'p.address_city', $filters['city']]);
+ $query->andFilterWhere(['=', 'p.store_type', $filters['store_type']]);
+ $query->andFilterWhere(['=', 'p.address_region', $filters['region']]);
+ $query->andFilterWhere(['=', 'p.address_district', $filters['district']]);
+
+ if (!empty($filters['territorial_manager'])) {
+ $territorialManagerStoreIds = StoreDynamic::find()
+ ->select('store_id')
+ ->where(['category' => 3, 'active' => 1, 'value_int' => $filters['territorial_manager']])
+ ->column();
+ $query->andWhere(['in', 'a.store_id', $territorialManagerStoreIds ?: [-1]]);
}
- foreach ([
- 'territorialManager' => 3,
- 'bushChefFlorist' => 2
- ] as $param => $cat) {
- if (!empty($f[$param])) {
- $ids = StoreDynamic::find()
- ->select('store_id')
- ->where(['category' => $cat, 'active' => 1, 'value_int' => $f[$param]])
- ->column();
- $q->andWhere(['p.store_id' => $ids ?: [-1]]);
- }
+ if (!empty($filters['bush_chef_florist'])) {
+ $bushChefFloristStoreIds = StoreDynamic::find()
+ ->select('store_id')
+ ->where(['category' => 2, 'active' => 1, 'value_int' => $filters['bush_chef_florist']])
+ ->column();
+ $query->andWhere(['in', 'a.store_id', $bushChefFloristStoreIds ?: [-1]]);
}
- return array_values($q->column());
+ return array_values($query->column());
}
public function action1()
</div>
<div class="row">
<div class="col-md d-flex">
- <?= Html::label('Месяц: ', [], ['class' => 'month-label']) ?>
+ <?= Html::label('Месяц: ', [], ['class' => 'month-label ms-4']) ?>
</div>
<div class="col-md d-flex">
<?= Select2::widget([
</div>
</div>
</div>
- <div class="table-wrapper">
+ <div class="div alert">
+ <div class="alert text-center flash-message alert-info mb-1 py-1 m-5">Для редактирования планограммы необходимо выбрать неделю и год!</div>
+ </div>
+ <div class="table-wrapper" style=" pointer-events: none; opacity: 0.5;">
<table class="table">
<thead>
<tr class="head">
$('.btn-apply').on('click', function () {
applyStoreFilter();
- console.log($('#week').val(),$('#year').val(), getMonthByWeek($('#week').val(), $('#year').val()))
+ if ($('#week').val() && $('#year').val()) {
+ $('.table-wrapper').css({
+ 'pointer-events': 'auto',
+ 'opacity': '1'
+ });
+ $('.flash-message').css({
+ 'display': 'none'
+ });
+ }
$('tr.inserted-row').remove();
});
$('.btn-reset').on('click', resetStoreFilter);
return startMonth === endMonth ? startMonth : `${startMonth} - ${endMonth}`;
}
+
+$(document).ready(function () {
+ if ($('#week').val().length > 0) {
+ $('#edit-button').click();
+ }
+
+ const flashMessage = $('.flash-message');
+
+ if (flashMessage.length) {
+ const delayTime = flashMessage.hasClass('alert-success') ? 5000 : 15000;
+ setTimeout(() => flashMessage.fadeOut(2000, () => flashMessage.remove()), delayTime);
+ }
+});
\ No newline at end of file