diff --git a/backend/modules/calendar/controllers/CalendarController.php b/backend/modules/calendar/controllers/CalendarController.php
index c6760bd..78ed1ec 100644
--- a/backend/modules/calendar/controllers/CalendarController.php
+++ b/backend/modules/calendar/controllers/CalendarController.php
@@ -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()
diff --git a/backend/modules/calendar/views/calendar/calendar.php b/backend/modules/calendar/views/calendar/calendar.php
new file mode 100644
index 0000000..ca050c5
--- /dev/null
+++ b/backend/modules/calendar/views/calendar/calendar.php
@@ -0,0 +1,59 @@
+title = 'Календарь ДР';
+?>
+= \backend\widgets\Calendar::widget([
+
+ 'css' => '.success{color: orange;}',
+
+ 'button' => Html::a(' Назад',
+ 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 = `
+
+
+
#
+
ФИО
+
Дата рождения
+
+
+ `;
+ 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 += `
`
+ html += `
${i}
`
+ html += `
${model["fio"]}
`
+ html += `
${model["dob"]}
`
+ html += CalendarHelper._getActionColumn(`secure/calendar/calendar`,model[`id`])
+ html += `
`
+ }
+ }
+ html += `
`
+ if (flag) return html;
+ return "empty"
+ }'
+]) ?>
+
+
diff --git a/backend/modules/calendar/views/calendar/index.php b/backend/modules/calendar/views/calendar/index.php
index 18a1223..1783f5f 100644
--- a/backend/modules/calendar/views/calendar/index.php
+++ b/backend/modules/calendar/views/calendar/index.php
@@ -27,7 +27,7 @@ use yii\widgets\Pjax;
=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'])?>
'reload']);
diff --git a/backend/widgets/Calendar.php b/backend/widgets/Calendar.php
index 59ac6c8..3c922dd 100644
--- a/backend/widgets/Calendar.php
+++ b/backend/widgets/Calendar.php
@@ -5,158 +5,40 @@ namespace backend\widgets;
use yii\base\Widget;
use yii\helpers\Html;
-use yii\helpers\Url;
class Calendar extends Widget
{
public $button;
+
+ public $css;
+
public $runBuild = 'function (date, content){
this.build(date, content)
}';
+
public $updateContent = "function(){
+ return [];
+ /*
+ Example, return [model1, model2, model3 , ...] :
+
let monthNumber = date.substr(5, 2);
return fetch('../ajax/get-birthday-by-month?' +
'month=' + monthNumber)
.then((res) => {
return res.json()
- })
+ })*/
}";
+
public $getColor = "function (date, dates = null) {
- for (let contentDate of dates) {
- if (contentDate['dob'].substr(8, 2) == DateHelper.intToDate(date.getDate())) {
- return 'success';
- }
- }
- }";
+ return `className`;
+ }";
+
public $getHtmlContentForDate = 'function (content, date) {
- console.log(content)
- let flag = false
- let html = `
-
-
-
#
-
ФИО
-
Дата рождения
-
-
- `;
- 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 += `
- `;
- 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 += `