Улучшил виджет, доделал календарь дней рождений
This commit is contained in:
@ -42,12 +42,10 @@ class CalendarController extends Controller
|
||||
* Renders the index view for the module
|
||||
* @return string
|
||||
*/
|
||||
public function actionAlternative(){
|
||||
public function actionCalendar(){
|
||||
$searchModel = new UserCardSearch();
|
||||
$dataProvider = $searchModel->search(['month'=>date('m', strtotime('2019-07-03'))]);
|
||||
return $this->render('alternative', [
|
||||
'dataProvider' => $dataProvider
|
||||
]);
|
||||
return $this->render('calendar');
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
|
59
backend/modules/calendar/views/calendar/calendar.php
Normal file
59
backend/modules/calendar/views/calendar/calendar.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
|
||||
$this->title = 'Календарь ДР';
|
||||
?>
|
||||
<?= \backend\widgets\Calendar::widget([
|
||||
|
||||
'css' => '.success{color: orange;}',
|
||||
|
||||
'button' => Html::a('<i class="fas fa-long-arrow-alt-left"></i> Назад',
|
||||
Yii::$app->request->referrer, ['class' => 'btn btn-primary',]),
|
||||
'runBuild' => "function (date, content){
|
||||
this.build(date, content)
|
||||
}",
|
||||
'updateContent' => "function(date){
|
||||
let monthNumber = date.substr(5, 2);
|
||||
return fetch('../ajax/get-birthday-by-month?' +
|
||||
'month=' + monthNumber)
|
||||
.then((res) => {
|
||||
return res.json()
|
||||
})
|
||||
}",
|
||||
'getColor' => "function (date, dates = null) {
|
||||
for (let contentDate of dates) {
|
||||
if (contentDate['dob'].substr(8, 2) == DateHelper.intToDate(date.getDate())) {
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
}",
|
||||
'getHtmlContentForDate' => 'function (content, date) {
|
||||
let flag = false
|
||||
let html = `<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>ФИО</th>
|
||||
<th>Дата рождения</th>
|
||||
<th class="action-column"> </th>
|
||||
</tr>
|
||||
</thead><tbody>`;
|
||||
for (let i = 1; i <= content.length; i++) {
|
||||
let model = content[i - 1];
|
||||
if (model["dob"].substr(8, 2) == date.substr(8, 2)) {
|
||||
flag = true;
|
||||
html += `<tr data-key="${model["id"]}">`
|
||||
html += `<td>${i}</td>`
|
||||
html += `<td>${model["fio"]}</td>`
|
||||
html += `<td>${model["dob"]}</td>`
|
||||
html += CalendarHelper._getActionColumn(`secure/calendar/calendar`,model[`id`])
|
||||
html += `</tr>`
|
||||
}
|
||||
}
|
||||
html += `</tbody></table>`
|
||||
if (flag) return html;
|
||||
return "empty"
|
||||
}'
|
||||
]) ?>
|
||||
|
||||
|
@ -27,7 +27,7 @@ use yii\widgets\Pjax;
|
||||
</select>
|
||||
</p>
|
||||
<?=Html::a('Календарь дней рождений '.Html::tag('i', null, ['class' => 'far fa-calendar-alt']),
|
||||
['alternative'], ['class' => 'btn btn-success', 'style' => 'margin-left: 10px'])?>
|
||||
['calendar'], ['class' => 'btn btn-success', 'style' => 'margin-left: 10px'])?>
|
||||
</div>
|
||||
<?php
|
||||
Pjax::begin(['id' => 'reload']);
|
||||
|
Reference in New Issue
Block a user