merging
Merge branch 'work_with_reports' into calendarWidget_reports_and_birthdays
This commit is contained in:
commit
cc29bf2e1a
@ -35,10 +35,7 @@ class AjaxController extends \yii\web\Controller
|
||||
$response = Yii::$app->response;
|
||||
$response->format = Response::FORMAT_JSON;
|
||||
$response->getHeaders()->set('Content-Type', 'application/json; charset=utf-8');
|
||||
$response->content = json_encode(array_merge(
|
||||
['reports' => $reports_array],
|
||||
['month' => (array)new Month($year.'-'.$month.'-01')])
|
||||
);
|
||||
$response->content = json_encode($reports_array);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
@ -1,33 +1,89 @@
|
||||
<?php
|
||||
|
||||
use backend\widgets\Calendar;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $fio */
|
||||
/* @var $USER_ID */
|
||||
|
||||
$this->registerJs('let userID = '. $USER_ID);
|
||||
$this->registerJs(file_get_contents(Url::base(true).'/js/calendar.js'));
|
||||
$this->registerCssFile('@web/css/calendar.css');
|
||||
$this->title = 'Календарь пользователя - ' . $fio;
|
||||
?>
|
||||
<?=Html::beginTag('section', ['class' => 'calendar-contain'])?>
|
||||
<?=Html::beginTag('aside', ['class' => 'calendar__sidebar'])?>
|
||||
<?=Html::beginTag('section', ['class' => 'title-bar'])?>
|
||||
<?= Html::a('<i class="fas fa-long-arrow-alt-left"></i> Назад', Yii::$app->request->referrer, ['class' => 'btn btn-primary',]) ?>
|
||||
<?= Html::input('date', null, date('Y-m-d'), ['class' => 'form-control', 'id' => 'date',]) ?>
|
||||
<?=Html::endTag('section')?>
|
||||
|
||||
<?=Html::tag('h2', date('l').'<br>'.date('F d'), ['class' => 'sidebar__heading'])?>
|
||||
<?=Calendar::widget([
|
||||
|
||||
<?=Html::beginTag('ul', ['class' => 'sidebar__list'])?>
|
||||
<?=Html::endTag('ul')?>
|
||||
<?=Html::endTag('aside')?>
|
||||
'button' => Html::a('<i class="fas fa-long-arrow-alt-left"></i> Назад',
|
||||
Yii::$app->request->referrer, ['class' => 'btn btn-primary',]),
|
||||
|
||||
<?=Html::beginTag('section', ['class' => 'calendar__days'])?>
|
||||
<?=Html::endTag('section')?>
|
||||
<?=Html::endTag('section')?>
|
||||
'runBuild' => "function (date, content){
|
||||
contentDays = []
|
||||
for (let item of content){
|
||||
contentDays.push(item['created_at'])
|
||||
}
|
||||
this.build(date, contentDays)
|
||||
}",
|
||||
|
||||
'updateContent' => "function(date){
|
||||
let monthNumber = date.substr(5, 2);
|
||||
let yearNumber = date.substr(0, 4);
|
||||
return fetch('../ajax/get-reports-for-month-by-id-year-month?user_id='+".$USER_ID."+
|
||||
'&month=' + monthNumber +
|
||||
'&year=' + yearNumber)
|
||||
.then((res) => {
|
||||
return res.json()
|
||||
})
|
||||
}",
|
||||
|
||||
'getColor' => "function (date, dates = null) {
|
||||
let d = date;
|
||||
if ([6, 0].includes(d.getDay()))
|
||||
return;
|
||||
for (let i = 0; i < dates.length; i++) {
|
||||
if (dates[i] == DateHelper.dateToString(date)) {
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
return 'danger';
|
||||
}",
|
||||
|
||||
'getHtmlContentForDate' => "function (content, date) {
|
||||
if ([0, 6].includes(new Date(date).getDay())) {
|
||||
return 'Выходной день';
|
||||
}
|
||||
let j = 0;
|
||||
let html = `<ul class='sidebar__list'>
|
||||
<table class='table table-striped table-bordered'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Что было сделано сегодня?</th>
|
||||
<th>Какие сложности возникли?</th>
|
||||
<th>Что планируется сделать завтра?</th>
|
||||
<th class='action-column'> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>`;
|
||||
for (let k = 0, i = 0; i < content.length; i++) {
|
||||
let report = content[i];
|
||||
if (report['created_at'] == date) {
|
||||
k++;
|
||||
html += `<tr data-key='\${report['id']}'>
|
||||
<td>\${k}</td><td>`;
|
||||
|
||||
for (j = 0; j < Object.keys(report['today']).length; j++) {
|
||||
html += `<p>\${j + 1}. (\${report['today'][j]['hours_spent']} ч.)
|
||||
\${report['today'][j]['task']}</p>`
|
||||
}
|
||||
|
||||
html += `</td>
|
||||
<td>\${report['difficulties']}</td>
|
||||
<td>\${report['tomorrow']}</td>
|
||||
\${CalendarHelper._getActionColumn(`/secure/reports/reports`, report['id'])}`;
|
||||
}
|
||||
}
|
||||
if (j == 0) {
|
||||
return 'За этот день не было отчетов';
|
||||
}
|
||||
return html;
|
||||
}"
|
||||
]) ?>
|
||||
|
Loading…
Reference in New Issue
Block a user