'month' => $model->month,
'storeId' => $model->store_id,
'status' => 'pending',
- 'info' => 'auto',
'startTime' => date('Y-m-d H:i:s'),
'progress' => 0,
'error' => null
$log->context = json_encode($cacheValue, JSON_UNESCAPED_UNICODE);
$log->year = (int)$cacheValue['year'];
$log->month = (int)$cacheValue['month'];
- $log->info = $cacheValue['info'];
$log->active = 1;
$log->progress = 0;
$log->status = 1;
$year = (int)Yii::$app->request->get('year');
$month = (int)Yii::$app->request->get('month');
$store = (int)Yii::$app->request->get('store_id');
- $changes = Yii::$app->request->get('changes');
$taskName = "taskApRecalculate";
$scriptLauncherLog = ScriptLauncherLog::find()
'status' => 'pending',
'startTime' => date('Y-m-d H:i:s'),
'progress' => 0,
- 'error' => null
+ 'error' => null,
];
$log = new ScriptLauncherLog();
$log->source = 'CronController';
$log->category = 'autoplannogramma';
$log->prefix = 'actionAutoplannogrammaRecalculate';
$log->name = $taskName;
- $log->info = $cacheValue['info'];
$log->context = json_encode($cacheValue, JSON_UNESCAPED_UNICODE);
$log->year = (int)$cacheValue['year'];
$log->month = (int)$cacheValue['month'];
->limit(1)
->one();
$task = json_decode($scriptLauncherLog->context, true );
- if (!$task || $scriptLauncherLog->active == 0) {
+ if (!$task) {
return $this->asJson(['status' => 'not_found']);
}
$('#rebuild').prop('disabled', true).text('Пересчёт запущен...');
$('#delete').prop('disabled', true);
$('#filter-btn').prop('disabled', true);
+
$.ajax({
url: '/category-plan/rebuild',
type: 'GET',
year: $('#dynamicmodel-year').val(),
month: $('#dynamicmodel-month').val(),
store_id: store_id,
- changes: localStorage.getItem('planChanges'),
[param26]: token26
},
success: function (data) {
}
if (data.status == 'started') {
startTaskPolling();
-
console.log(data.data);
}
}
});
});
- startTaskPolling();
+ $.ajax({
+ url: '/category-plan/check-task',
+ type: 'GET',
+ dataType: 'json',
+ success: function (data) {
+ console.log(data.status);
+ console.log(data.start);
+ if (data.status === 'running' || data.status === 'pending') {
+ startTaskPolling();
+ $('#rebuild').prop('disabled', true).text('Пересчёт запущен...');
+ $('#delete').prop('disabled', true);
+ $('#filter-btn').prop('disabled', true);
+ $('#changes-hint').hide();
+ $('#changes').hide();
+ $('#changes-count').hide();
+ $('#categoryPlan').addClass('block_table');
+ }
+ }
+ });
+
});
let taskPollInterval = null;
}
}
});
- }, 3000);
+ }, 5000);
}
\ No newline at end of file