if ($filter->date_from || $filter->date_to) {
$query->innerJoin(
- Products1cNomenclatureActuality::tableName() . ' a',
+ Products1cNomenclatureActuality::tableName().' a',
'a.guid = n.id AND a.active = 1'
);
- if ($filter->date_from) {
+
+ if ($filter->date_from && $filter->date_to) {
+ $dfObj = \DateTime::createFromFormat('Y-m', $filter->date_from);
+ $dtObj = \DateTime::createFromFormat('Y-m', $filter->date_to);
+ $dfObj->setTime(0,0,0);
+ $dtObj->modify('last day of this month')->setTime(23,59,59);
+
+ $query->andWhere(['<=', 'a.date_from', $dtObj->format('Y-m-d H:i:s')])
+ ->andWhere(['>=', 'a.date_end', $dfObj->format('Y-m-d H:i:s')]);
+ }
+
+ elseif ($filter->date_from) {
$df = \DateTime::createFromFormat('Y-m', $filter->date_from)
->format('Y-m-01 00:00:00');
- $query->andWhere(['>=', 'a.date_from', $df]);
+ $query->andWhere(['>=', 'a.date_end', $df]);
}
- if ($filter->date_to) {
+
+ elseif ($filter->date_to) {
$dt = \DateTime::createFromFormat('Y-m', $filter->date_to);
$dt->modify('last day of this month')->setTime(23,59,59);
- $query->andWhere(['<=', 'a.date_end', $dt->format('Y-m-d H:i:s')]);
+ $query->andWhere(['<=', 'a.date_from', $dt->format('Y-m-d H:i:s')]);
}
}
+
$attrMap = [
'type' => ['type','тип'],
'color' => ['цвет','color'],
use kartik\form\ActiveForm;
use kartik\grid\GridView;
use yii\helpers\Html;
+use yii\web\View;
/* @var $this yii\web\View */
$this->title = 'Актуализация номенклатуры';
$this->params['breadcrumbs'][] = $this->title;
-
+$this->registerJsFile('/js/products1cNomenclatureActuality/index.js', ['position' => View::POS_END]);
// Список месяцев-годов для выпадающих списков
function monthList()
{
</div>
-<?php
-$js = <<<JS
-$('.from-month').on('change', function(){
- var from = $(this).val(),
- to = $(this).closest('td').find('.to-month');
- to.find('option').each(function(){
- $(this).toggle($(this).val() >= from);
- });
- if (to.val() < from) {
- to.val(from);
- }
-});
-
- $('#filter-date-from').on('change', function(){
- var from = $(this).val();
- var to = $('#filter-date-to');
- to.find('option').each(function(){
- var val = $(this).val();
- if (val === '' || val >= from) {
- $(this).show();
- } else {
- $(this).hide();
- }
- });
- if (to.val() && to.val() < from) {
- to.val(from);
- }
- });
-$('.clear-btn').on('click', function(){
- var target = $(this).data('target');
- $('#' + target).val(null).trigger('change');
-});
-JS;
-$this->registerJs($js);
-?>
--- /dev/null
+document.addEventListener("DOMContentLoaded", () => {
+$('.from-month').on('change', function(){
+ var from = $(this).val(),
+ to = $(this).closest('td').find('.to-month');
+ to.find('option').each(function(){
+ $(this).toggle($(this).val() >= from);
+ });
+ if (to.val() < from) {
+ to.val(from);
+ }
+});
+
+$('#filter-date-from').on('change', function(){
+ var from = $(this).val();
+ var to = $('#filter-date-to');
+ to.find('option').each(function(){
+ var val = $(this).val();
+ if (val === '' || val >= from) {
+ $(this).show();
+ } else {
+ $(this).hide();
+ }
+ });
+ if (to.val() && to.val() < from) {
+ to.val(from);
+ }
+});
+$('.clear-btn').on('click', function(){
+ var target = $(this).data('target');
+ $('#' + target).val(null).trigger('change');
+});
+
+});
\ No newline at end of file