не работает ооп

This commit is contained in:
maxim 2021-09-06 10:29:50 +03:00
parent cb504e25bc
commit 56d7afe055
14 changed files with 3059 additions and 603 deletions

View File

@ -85,7 +85,7 @@ class UserCardSearch extends UserCard
$query->orderBy('user_card.updated_at DESC'); $query->orderBy('user_card.updated_at DESC');
$query->groupBy('card_skill.card_id'); // $query->groupBy('card_skill.card_id');
$sumQuery = clone $query; $sumQuery = clone $query;

View File

@ -0,0 +1,42 @@
<?php
namespace backend\modules\reports\controllers;
use backend\modules\reports\models\Month;
use common\classes\Debug;
use Yii;
use backend\modules\reports\models\ReportsSearch;
use yii\web\JsonResponseFormatter;
use yii\web\Response;
class AjaxController extends \yii\web\Controller
{
public function actionGetReportsForMonthByIdYearMonth($id, $year=null, $month=null){
if (!($year and $month)){
$searchModel->month = date('m');
$searchModel->year = date('Y');
Debug::prn('Неверный год или месяц');
}
$searchModel = new ReportsSearch();
$searchModel->id = $id;
$searchModel->month = $month;
$searchModel->year = $year;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$reports = ['reports'=>array_column($dataProvider->getModels(), 'attributes')];
$month = new Month($year.'-'.$month.'-01');
$response = Yii::$app->response;
$response->format = Response::FORMAT_JSON;
$response->content = json_encode(array_merge($reports,
['month'=>(array)$month]));
$response->getHeaders()->set('Content-Type', 'application/json; charset=utf-8');
return $response;
}
}

View File

@ -3,14 +3,17 @@
namespace backend\modules\reports\controllers; namespace backend\modules\reports\controllers;
use backend\modules\card\models\UserCardSearch; use backend\modules\card\models\UserCardSearch;
use backend\modules\reports\models\Month;
use common\classes\Debug; use common\classes\Debug;
use Yii; use Yii;
use common\models\Reports; use common\models\Reports;
use backend\modules\reports\models\ReportsSearch; use backend\modules\reports\models\ReportsSearch;
use yii\base\Model;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\web\Response;
/** /**
* ReportsController implements the CRUD actions for Reports model. * ReportsController implements the CRUD actions for Reports model.
@ -56,6 +59,34 @@ class ReportsController extends Controller
]); ]);
} }
public function actionUser($id, $date = null)
{
if (!(isset($date) and preg_match("/^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/", $date))) {
// Debug::dd('неверный формат даты');
$date = date('Y-m-01');
}
$date = date('Y-m-01', strtotime($date));
$searchModel = new ReportsSearch();
$searchModel->id = $id;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$reports = $dataProvider->getModels();
// Debug::dd($dataProvider);
$month = new Month($date);
if (!Yii::$app->request->isAjax) {
return $this->render('user', [
'ID' => $reports[0]->id,
'reports' => $reports,
'reports_month' => json_encode(array_merge(['reports'=>array_column($reports, 'attributes')],
['month'=>(array)$month])),
'date' => $date
]);
}
}
public function actionGroup() public function actionGroup()
{ {
$searchModel = new UserCardSearch(); $searchModel = new UserCardSearch();
@ -65,6 +96,7 @@ class ReportsController extends Controller
return $this->render('group', [ return $this->render('group', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
]); ]);
} }

View File

@ -0,0 +1,101 @@
<?php
namespace backend\modules\reports\models;
use common\classes\Debug;
use yii\base\Model;
use function GuzzleHttp\Psr7\str;
class Month
{
public $inactive_begin;
public $inactive_end;
public $active;
public $days;
public function __construct($date = null)
{
// $date = '2021-08-10';
$this->inactive_begin = [];
$this->inactive_end = [];
// Debug::prn($date);
if (!$date and !self::is_date($date)) {
$date = date('Y-m-d');
Debug::dd($date);
}
// Debug::dd($date);
$first_day_of_week = self::get_day_week(self::get_first_day($date));
$quantity_days = self::get_days_month($date);
$day = 1;
for (
$index = $first_day_of_week;
$index < $first_day_of_week + $quantity_days;
$index++, $day++
) {
$this->active[$index] = $day;
}
$prev_month = date('Y-m-d', strtotime(self::get_first_day($date)) - 3600 * 37);
$day = self::get_days_month($prev_month);
for ($index = $first_day_of_week - 1; $index >= 1; $index--, $day--) {
$this->inactive_begin[$index] = $day;
}
$day = 1;
$index_end = ($first_day_of_week==7?42:35);
for ($index = $quantity_days + $first_day_of_week; $index <=$index_end; $index++, $day++) {
$this->inactive_end[$index] = $day;
}
$this->days = array_merge($this->inactive_end, $this->inactive_begin, $this->active);
// Debug::dd($this);
}
public static function next_day($date, $number)
{
return date('Y-m-d', strtotime($date) + 3600 * 24 * $number);
}
public static function get_first_day($date)
{
return date('Y-m-01', strtotime($date));
}
public static function get_day_week($date)
{
$day = date('w', strtotime(date($date)));
if($day==0)
return 7;
return $day;
}
public static function is_date($date)
{
$date = date_parse($date);
if ($date or checkdate($date['month'], $date['day'], $date['year']))
return true;
return false;
}
public static function get_days_month($date)
{
return date("t", strtotime($date));
}
public function a()
{
// $a = date('w', strtotime(date('')))
}
}

View File

@ -2,16 +2,21 @@
namespace backend\modules\reports\models; namespace backend\modules\reports\models;
use common\classes\Debug;
use yii\base\Model; use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use common\models\Reports; use common\models\Reports;
/** /**
* ReportsSearch represents the model behind the search form of `common\models\Reports`. * ReportsSearch represents the model behind the search form of `common\models\Reports`.
*/ */
class ReportsSearch extends Reports class ReportsSearch extends Reports
{ {
public $fio; public $fio;
public $month;
public $year;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -57,23 +62,36 @@ class ReportsSearch extends Reports
$this->load($params); $this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails if (isset($params['date']) and preg_match("/^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/", $params['date']) and !isset($params['id'])) {
// $query->where('0=1'); $this->created_at = $params['date'];
return $dataProvider;
} }
// if (!$this->validate()) {
// // uncomment the following line if you do not want to return any records when validation fails
// // $query->where('0=1');
//
// return $dataProvider;
// }
// grid filtering conditions // grid filtering conditions
// Debug::dd($params['date']);
$query->andFilterWhere([ $query->andFilterWhere([
'id' => $this->id, 'user_card.id' => $this->id,
'created_at' => $this->created_at, 'reports.created_at' => $this->created_at,
'user_card_id' => $this->user_card_id, 'user_card_id' => $this->user_card_id,
]); ]);
$query->andFilterWhere(['like', 'today', $this->today]) $query->andFilterWhere(['like', 'today', $this->today])
->andFilterWhere(['like', 'difficulties', $this->difficulties]) ->andFilterWhere(['like', 'difficulties', $this->difficulties])
->andFilterWhere(['like', 'tomorrow', $this->tomorrow]) ->andFilterWhere(['like', 'tomorrow', $this->tomorrow])
->andFilterWhere(['like', 'user_card.fio', $this->fio]); ->andFilterWhere(['like', 'user_card.fio', $this->fio])
->andFilterWhere(['=', 'YEAR(reports.created_at)', $this->year])
->andFilterWhere(['=', 'MONTH(reports.created_at)', $this->month]);
return $dataProvider; return $dataProvider;
} }

View File

@ -9,48 +9,108 @@ use yii\grid\GridView;
$this->title = 'Отчеты'; $this->title = 'Отчеты';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
define('TODAY', date('Y-m-d'));
define('WEEK_AGO', date('Y-m-d', time() - 3600 * 24 * 7));
function next_day($date, $number)
{
return date('Y-m-d', strtotime($date) + 3600 * 24 * $number);
}
?> ?>
<div class="reports-index"> <div class="reports-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p> <p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Сгрупированный по пользователям вид', ['group'], ['class' => 'btn btn-success']) ?> <?= Html::a('Сгрупированный по пользователям вид', ['group'], ['class' => 'btn btn-success']) ?>
</p> </p>
<p>
<?php for ($date = TODAY; $date != WEEK_AGO; $date = next_day($date, -1)): ?>
<?= Html::a($date, ['reports/?date=' . $date], ['class' => 'btn btn-primary']) ?>
<?php endfor; ?></div>
<div class="row">
<div class="col-xs-6">
<?= GridView::widget([ <form method="get" style="display: inline-flex;">
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'created_at', <?= Html::input('date', 'date', isset($_GET['date']) ? $_GET['date'] : date('Y-m-d'), [
[ 'class' => 'form-control',
'attribute' => 'today', 'style' => 'display:',
'format' => 'raw', 'id' => 'date'
'value' => function ($model) {
$text = ''; ]) ?>
if ($model->task) {
$i = 1; <?= Html::button('Сортировка по дате', ['class' => 'btn btn-danger sort_by_date', 'type' => 'submit']) ?>
foreach ($model->task as $task) {
$text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>"; <?= Html::a('Все дни', ['index'], ['class' => 'btn btn-dark']) ?>
$i++;
}
} </form>
return $text; </div>
}
],
'difficulties',
'tomorrow',
[
'format' => 'raw',
'attribute' => 'ФИО',
'filter' => Html::activeTextInput($searchModel, 'fio', ['class' => 'form-control']),
'value' => function ($data) { return \common\models\Reports::getFio($data); },
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div> </div>
<!-- <div class="row" style="margin: 10px 0px 0 5px">-->
</p>
<?php
//echo '<pre>';
//var_dump($dataProvider);
//echo '</pre>';?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'created_at',
[
'attribute' => 'today',
'format' => 'raw',
'value' => function ($model) {
$text = '';
if ($model->task) {
$i = 1;
foreach ($model->task as $task) {
$text .= "<p>$i. ($task->hours_spent ч.) $task->task</p>";
$i++;
}
}
return $text;
}
],
'difficulties',
'tomorrow',
[
'format' => 'raw',
'attribute' => 'ФИО',
'filter' => Html::activeTextInput($searchModel, 'fio', ['class' => 'form-control']),
'value' => function ($data) {
return '<a href="./reports/user?id='.$data['user_card_id'].'">' . \common\models\Reports::getFio($data) . '</a>';
},
],
['class' => 'yii\grid\ActionColumn'],
],
]);
$this->registerCssFile('../../css/site.css');
?>
</div>
<script>
// let date = document.querySelector('#date')
// date.onchange = function (){
// window.location.replace(`./?date=${date.value}`);
// }
</script>
<style>
.row * {
margin-right: 10px;
}
.row {
margin-left: 1px;
}
</style>

View File

@ -0,0 +1,877 @@
<?php
use backend\modules\reports\models\ReportsSearch;
use kartik\grid\GridView;
use yii\data\Pagination;
use yii\helpers\Html;
use common\models\Reports;
use \common\classes\Debug;
use backend\modules\reports\models\Month;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\reports\models\ReportsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $reports common\models\Reports */
/* @var $ID */
$month = new Month($date);
$index_raw = 0;
function next_day($date, $number)
{
return date('Y-m-d', strtotime($date) + 3600 * 24 * $number);
}
function get_dates_created_at(Reports $report)
{
return $report->created_at;
}
function get_color($date, $dates_created_at)
{
if (in_array(Month::get_day_week($date), array(6, 7)))
return;
if (in_array($date, $dates_created_at)) {
return 'success';
} else
return 'danger';
}
$this->title = 'Календарь пользователя - ' . Reports::getFio($reports[0]);
$dates_created_at = array_unique(array_map('get_dates_created_at', $reports));
//for ($date = '2021-08-01', $i = 0; $date != '2021-09-01'; $date = next_day($date, 1), $i++) {
// if ($i == 7) {
// echo '<div>';
// $i = 0;
// }
// if (in_array($date, $dates_created_at)) {
// $color = 'primary';
// } else
// $color = 'danger';
// echo Html::a($date, ['reports/?date=' . $date], ['class' => 'btn btn-' . $color . '',
// 'style' => 'margin: 10px;']);
//
//}
//
//
//?>
<?= Html::csrfMetaTags() ?>
<section class="calendar-contain">
<aside class="calendar__sidebar">
<section class="title-bar">
<?= Html::input('date', 'date', isset($_GET['date']) ? $_GET['date'] : date('Y-m-d'), [
'class' => 'form-control',
'style' => 'display:',
'id' => 'date',
]) ?>
</section>
<h2 class="sidebar__heading"><?= date('l') ?><br><?= date('F d') ?></h2>
<ul class="sidebar__list">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th><a href="/secure/reports/reports/index?date=2021-08-31&amp;sort=today" data-sort="today">Что
было сделано
сегодня?</a></th>
<th><a href="/secure/reports/reports/index?date=2021-08-31&amp;sort=difficulties"
data-sort="difficulties">Какие
сложности возникли?</a></th>
<th><a href="/secure/reports/reports/index?date=2021-08-31&amp;sort=tomorrow" data-sort="tomorrow">Что
планируется сделать завтра?</a></th>
<th class="action-column">&nbsp;</th>
</tr>
</thead>
<tbody>
<tr data-key="4">
<td>1</td>
<td><p>1. (1 ч.) asd</p></td>
<td></td>
<td></td>
<td><a href="/secure/reports/reports/view?id=4" title="Просмотр" aria-label="Просмотр"
data-pjax="0">
<svg aria-hidden="true"
style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1.125em"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
<path fill="currentColor"
d="M573 241C518 136 411 64 288 64S58 136 3 241a32 32 0 000 30c55 105 162 177 285 177s230-72 285-177a32 32 0 000-30zM288 400a144 144 0 11144-144 144 144 0 01-144 144zm0-240a95 95 0 00-25 4 48 48 0 01-67 67 96 96 0 1092-71z"></path>
</svg>
</a> <a href="/secure/reports/reports/update?id=4" title="Редактировать"
aria-label="Редактировать"
data-pjax="0">
<svg aria-hidden="true"
style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1em"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path fill="currentColor"
d="M498 142l-46 46c-5 5-13 5-17 0L324 77c-5-5-5-12 0-17l46-46c19-19 49-19 68 0l60 60c19 19 19 49 0 68zm-214-42L22 362 0 484c-3 16 12 30 28 28l122-22 262-262c5-5 5-13 0-17L301 100c-4-5-12-5-17 0zM124 340c-5-6-5-14 0-20l154-154c6-5 14-5 20 0s5 14 0 20L144 340c-6 5-14 5-20 0zm-36 84h48v36l-64 12-32-31 12-65h36v48z"></path>
</svg>
</a> <a href="/secure/reports/reports/delete?id=4" title="Удалить" aria-label="Удалить"
data-pjax="0"
data-confirm="Вы уверены, что хотите удалить этот элемент?" data-method="post">
<svg aria-hidden="true"
style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:.875em"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<path fill="currentColor"
d="M32 464a48 48 0 0048 48h288a48 48 0 0048-48V128H32zm272-256a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zM432 32H312l-9-19a24 24 0 00-22-13H167a24 24 0 00-22 13l-9 19H16A16 16 0 000 48v32a16 16 0 0016 16h416a16 16 0 0016-16V48a16 16 0 00-16-16z"></path>
</svg>
</a></td>
</tr>
<tr data-key="9">
<td>2</td>
<td><p>1. (23 ч.) asdasd</p></td>
<td></td>
<td></td>
<td><a href="/secure/reports/reports/view?id=9" title="Просмотр" aria-label="Просмотр"
data-pjax="0">
<svg aria-hidden="true"
style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1.125em"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
</svg>
</a> <a href="/secure/reports/reports/update?id=9" title="Редактировать"
aria-label="Редактировать"
data-pjax="0">
<svg aria-hidden="true"
style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1em"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
</svg>
</a> <a href="/secure/reports/reports/delete?id=9" title="Удалить" aria-label="Удалить"
data-pjax="0"
data-confirm="Вы уверены, что хотите удалить этот элемент?" data-method="post">
<svg aria-hidden="true"
style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:.875em"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
</svg>
</a></td>
</tr>
</tbody>
</table>
</ul>
</aside>
<section class="calendar__days">
<!-- <section class="calendar__top-bar">-->
<!-- <span class="top-bar__days">Mon</span>-->
<!-- <span class="top-bar__days">Tue</span>-->
<!-- <span class="top-bar__days">Wed</span>-->
<!-- <span class="top-bar__days">Thu</span>-->
<!-- <span class="top-bar__days">Fri</span>-->
<!-- <span class="top-bar__days">Sat</span>-->
<!-- <span class="top-bar__days">Sun</span>-->
<!-- </section>-->
<!---->
<!-- --><?php
// $index = 1;
// if (count($month->inactive_begin)) {
// echo '<section class="calendar__week">';
//
// for ($index = 1; $index <= count($month->inactive_begin); $index++, $index_raw++)
// echo ' <div class="calendar__day inactive">
//
// <span class="calendar__date">' . $month->inactive_begin[$index] . '</span>
// </div>';
// }
// for (; $index <= array_key_last($month->active); $index++, $index_raw++) {
//
// if ($index_raw % 7 == 0) {
// if ($index != 1) echo '</section>';
// echo '<section class="calendar__week">
// ';
// }
// echo '
// <div class="calendar__day">
// <span class="calendar__date ' . get_color(date('Y-m-' . $month->active[$index], strtotime($date)), $dates_created_at) . '">
// ' . $month->active[$index] . '
// </span>
// </div>
// ';
// }
// ?>
<!-- --><?php //for (; $index <= array_key_last($month->inactive_end); $index++, $index_raw++): ?>
<!-- --><?php //if ($index_raw % 7 == 0)
// echo '
// </section>
// <section class="calendar__week ">
// ';
// ?>
<!-- <div class="calendar__day inactive">-->
<!-- <span class="calendar__date "><? //= $month->inactive_end[$index] ?><!--</span>-->
<!-- </div>-->
<!-- --><?php //endfor; ?>
</section>
</section>
<script>
class CalendarBuilder {
constructor(month, reports, innerElem, datePicker, before = '') {
this.month = month;
this.Elem = innerElem;
this.reports = reports;
this.before = before;
this.datePicker = datePicker;
this.nameDate = document.querySelector('.sidebar__heading');
this.initBefore();
}
build() {
this.getInactiveBegin();
this.getActive();
this.getInactiveEnd();
this.loadInElem();
this.initAfter();
let rep = this.loadMonthReports();
console.log(rep)
console.log(123)
// this.activeButtonsDays();
}
update(month, reports = null) {
this.month = month;
this.reports = reports;
this.initBefore();
this.build();
}
initBefore() {
this.html = '';
this.index = 1;
this.indexRaw = 0;
this.classDay = 'calendar__day';
this.date = document.querySelector('#date').value.substr(0, 7);
}
initAfter() {
this.days = document.querySelectorAll('.calendar__day');
}
loadInElem() {
this.Elem.innerHTML = this.before + this.html;
}
activeButtonsDays() {
// console.log(this.days);
for (let i = 0; i < Object.keys(this.days).length; i++) {
// if (this.days[i].querySelector('.calendar__date.inactive')) {
// this.clickInactive(this.days[i])''
// } else
console.log(this.days[i])
console.log(i)
this.days[i].dayOnClick = this.dayOnClick;
this.days[i].changeDateFutureOrPast = this.changeDateFutureOrPast;
this.days[i].nameDate = this.nameDate;
this.days[i].datePicker = this.datePicker;
this.days[i].IntToDate = this.IntToDate;
this.days[i].loadMonthReports = this.loadMonthReports;
this.days[i].update = this.update;
this.days[i].onclick = function () {
this.dayOnClick(this)
};
}
}
dayOnClick(day) {
// console.log(day)
// alert(parseInt(days[i].textContent))
let number_date = parseInt(day.textContent);
number_date = this.IntToDate(number_date);
if (day.classList.contains('inactive')) {
this.changeDateFutureOrPast(number_date);
} else {
this.datePicker.value = this.datePicker.value.substr(0, 8) + number_date;
let date = new Date(this.datePicker.value);
let monthName = date.toLocaleString('default', {month: 'long'});
let dayWeekName = date.toLocaleString('default', {weekday: 'long'});
console.log(this.nameDate)
this.nameDate.innerHTML = dayWeekName + '<br>' + monthName + ' ' + date.toString().split(' ')[2];
}
}
changeDateFutureOrPast(number_date) {
let date = new Date(this.datePicker.value);
if (parseInt(this.textContent) <= 7) {
if (date.getMonth() == 11) {
date = new Date(date.getFullYear() + 1, 0, 1);
} else {
date = new Date(date.getFullYear(), date.getMonth() + 1, number_date);
}
// console.log(date.getFullYear() + '-' + (parseInt(date.getMonth())+1) + '-' + number_date)
// datePicker.value = date.toISOString().substring(0, 10);
} else {
if (date.getMonth() == 0) {
date = new Date(date.getFullYear() - 1, 11, 1);
} else {
date = new Date(date.getFullYear(), date.getMonth() - 1, 1);
}
// console.log(date.getFullYear() + '-' + (parseInt(date.getMonth())+1) + '-' + number_date)
// datePicker.value = date.getFullYear() + '-' + date.getMonth() + '-' + number_date
}
console.log(this)
this.loadMonthReports()
.then(function (reports_month) {
console.log(reports_month)
let reports = (JSON.parse(reports_month))[0]['reports']
let month = (JSON.parse(reports_month))[0]['month']
reports_month[1](month, reports);
})
this.datePicker.value = date.getFullYear() + '-' + this.IntToDate(parseInt(date.getMonth()) + 1) + '-' + number_date
}
IntToDate(number_date) {
if (Math.floor(number_date / 10) === 0)
number_date = '0' + number_date;
return number_date
}
getInactiveBegin() {
if (Object.keys(this.month['inactive_begin']).length > 0) {
this.html += '<section class="calendar__week">';
for (; this.index <= Object.keys(this.month['inactive_begin']).length; this.index++, this.indexRaw++) {
this.html += this.getCalendarDay('inactive_begin', 'inactive');
}
}
}
getActive() {
for (; this.index <= this.getLastKey(this.month['active']); this.index++, this.indexRaw++) {
if (this.indexRaw % 7 == 0) {
if (this.index != 1) {
this.html += '</section>';
}
this.html += '<section class="calendar__week">';
}
this.html += this.getCalendarDay('active')
}
}
getInactiveEnd() {
for (; this.index <= this.getLastKey(this.month['inactive_end']); this.index++, this.indexRaw++) {
if (this.indexRaw % 7 == 0) {
this.html += `</section>
<section class="calendar__week ">`;
}
this.html += this.getCalendarDay('inactive_end', 'inactive');
}
}
getCalendarDay(type, className = '') {
return `<div class="${this.classDay} ${className}">
<span class="calendar__date ${this.getColor(this.date + '-' + this.month[type][this.index])}">${this.month[type][this.index]}</span>
</div>`;
}
getColor(date) {
let d = new Date(date)
if ([6, 0].includes(d.getDay()))
return;
for (let i in this.reports) {
if (this.reports[i]['created_at'] == date) {
return 'success';
}
}
return 'danger';
}
getLastKey(obj) {
return Object.keys(obj)[Object.keys(obj).length - 1];
}
async loadMonthReports() {
let datePicker = this.datePicker;
let makeRequest = function () {
return new Promise(function (resolve, reject) {
let monthNumber = datePicker.value.substr(5, 2);
let yearNumber = datePicker.value.substr(0, 4);
let req = new XMLHttpRequest();
req.open('get', '../ajax/get-reports-for-month-by-id-year-month?id=<?=$ID?>' +
'&month=' + monthNumber +
'&year=' + yearNumber
)
;
req.setRequestHeader('Content-type', 'application/json');
req.onload = function () {
if (this.status >= 200 && this.status < 300) {
let response = [req.response, this.update]
resolve(response);
}
};
req.send();
})
}
return await makeRequest();
}
}
const CALENDAR_BAR = `<section class="calendar__top-bar">
<span class="top-bar__days">Mon</span>
<span class="top-bar__days">Tue</span>
<span class="top-bar__days">Wed</span>
<span class="top-bar__days">Thu</span>
<span class="top-bar__days">Fri</span>
<span class="top-bar__days">Sat</span>
<span class="top-bar__days">Sun</span>
</section>`;
let reports = (JSON.parse('<?=$reports_month?>'))['reports']
let month = (JSON.parse('<?=$reports_month?>'))['month']
let datePicker = document.querySelector('#date');
let calendarBuilder = new CalendarBuilder(
month, reports, document.querySelector('.calendar__days'), datePicker, CALENDAR_BAR);
calendarBuilder.build()
let days = document.querySelectorAll('.calendar__day');
let oldDate = datePicker.value.substr(0, 7);
datePicker.onchange = function () {
console.log(this.value)
if (!isOldDatePicker(datePicker, oldDate)) {
oldDate = datePicker.value.substr(0, 7);
get_reports_ajax(datePicker)
.then(function (reports_month) {
let reports = (JSON.parse(reports_month))['reports']
let month = (JSON.parse(reports_month))['month']
calendarBuilder.update(month, reports);
})
}
}
let nameDate = document.querySelector('.sidebar__heading');
function isOldDatePicker(datePicker, oldDate) {
if (datePicker.value.substr(0, 7) == oldDate)
return true;
return false
}
function get_reports_ajax(datePicker) {
return new Promise(function (resolve, reject) {
let monthNumber = datePicker.value.substr(5, 2);
let yearNumber = datePicker.value.substr(0, 4);
let req = new XMLHttpRequest();
req.open('get', '../ajax/get-reports-for-month-by-id-year-month?id=<?=$ID?>' +
'&month=' + monthNumber +
'&year=' + yearNumber
);
req.setRequestHeader('Content-type', 'application/json');
req.onload = function () {
if (this.status >= 200 && this.status < 300) {
resolve(req.response);
}
};
req.send();
})
}
</script>
<style>
.calendar-contain {
position: relative;
left: 0;
right: 0;
border-radius: 0;
width: 100%;
overflow: hidden;
max-width: 1920px;
min-width: 450px;
margin: 1rem auto;
background-color: #f5f7f6;
box-shadow: 5px 5px 72px rgba(30, 46, 50, 0.5);
color: #040605;
}
@media screen and (min-width: 55em) {
.calendar-contain {
margin: auto;
top: 5%;
}
}
.title-bar {
position: relative;
width: 100%;
display: table;
text-align: right;
background: #f5f7f6;
padding: 0.5rem;
margin-bottom: 0;
}
.title-bar:after {
display: table;
clear: both;
}
.title-bar__burger {
display: block;
position: relative;
float: left;
overflow: hidden;
margin: 0;
padding: 0;
width: 38px;
height: 30px;
font-size: 0;
text-indent: -9999px;
appearance: none;
box-shadow: none;
border: none;
cursor: pointer;
background: none;
}
.title-bar__burger:focus {
outline: none;
}
.burger__lines {
display: block;
position: absolute;
width: 18px;
top: 15px;
left: 0;
right: 0;
margin: auto;
height: 1px;
background: #040605;
}
.burger__lines:before, .burger__lines:after {
position: absolute;
display: block;
left: 0;
width: 100%;
height: 1px;
background-color: #040605;
content: "";
}
.burger__lines:before {
top: -5px;
}
.burger__lines:after {
bottom: -5px;
}
.title-bar__year {
display: block;
position: relative;
float: left;
font-size: 1rem;
line-height: 30px;
width: 43%;
padding: 0 0.5rem;
text-align: left;
}
@media screen and (min-width: 55em) {
.title-bar__year {
width: 27%;
}
}
.title-bar__month {
position: relative;
/*float: center;*/
font-size: 1rem;
line-height: 30px;
width: 22%;
padding: 0 0.5rem;
text-align: center;
margin-right: 67px;
word-spacing: 30px;
}
@media screen and (min-width: 55em) {
.title-bar__month {
width: 12%;
}
}
.title-bar__minimize, .title-bar__maximize, .title-bar__close {
position: relative;
float: left;
width: 34px;
height: 34px;
}
.title-bar__minimize:before, .title-bar__maximize:before, .title-bar__close:before, .title-bar__minimize:after, .title-bar__maximize:after, .title-bar__close:after {
top: 30%;
right: 30%;
bottom: 30%;
left: 30%;
content: " ";
position: absolute;
border-color: #8e8e8e;
border-style: solid;
border-width: 0 0 2px 0;
}
.title-bar .title-bar__controls {
display: inline-block;
vertical-align: top;
position: relative;
float: right;
width: auto;
}
.title-bar .title-bar__controls:before, .title-bar .title-bar__controls:after {
content: none;
}
.title-bar .title-bar__minimize:before {
border-bottom-width: 2px;
}
.title-bar .title-bar__maximize:before {
border-width: 1px 1px 2px 1px;
}
.title-bar .title-bar__close:before, .title-bar .title-bar__close:after {
bottom: 50%;
top: 49.9%;
}
.title-bar .title-bar__close:before {
transform: rotate(45deg);
}
.title-bar .title-bar__close:after {
transform: rotate(-45deg);
}
.calendar__sidebar {
width: 100%;
margin: 0 auto;
float: none;
background: linear-gradient(120deg, #eff3f3, #e1e7e8);
padding-bottom: 0.7rem;
}
@media screen and (min-width: 55em) {
.calendar__sidebar {
position: absolute;
height: 100%;
width: 50%;
float: left;
margin-bottom: 0;
}
}
.calendar__sidebar .content {
padding: 2rem 1.5rem 2rem 4rem;
color: #040605;
}
.sidebar__nav {
display: flex;
align-items: center;
justify-content: flex-start;
margin-bottom: 0.9rem;
padding: 0.7rem 1rem;
background-color: #f5f7f6;
}
.sidebar__nav-item {
display: inline-block;
width: 22px;
margin-right: 23px;
padding: 0;
opacity: 0.8;
}
.sidebar__list {
list-style: none;
margin: 0;
padding-left: 1rem;
padding-right: 1rem;
}
.sidebar__list-item {
margin: 1.2rem 0;
color: #2d4338;
font-weight: 100;
font-size: 1rem;
}
.list-item__time {
display: inline-block;
width: 60px;
}
@media screen and (min-width: 55em) {
.list-item__time {
margin-right: 2rem;
}
}
.sidebar__list-item--complete {
color: rgba(4, 6, 5, 0.3);
}
.sidebar__list-item--complete .list-item__time {
color: rgba(4, 6, 5, 0.3);
}
.sidebar__heading {
font-size: 2.2rem;
font-weight: bold;
padding-left: 1rem;
padding-right: 1rem;
margin-bottom: 3rem;
margin-top: 1rem;
}
.sidebar__heading span {
float: right;
font-weight: 300;
}
.calendar__heading-highlight {
color: #2d444a;
font-weight: 900;
}
.calendar__days {
display: flex;
flex-flow: column wrap;
align-items: stretch;
width: 100%;
float: none;
min-height: 580px;
height: 100%;
font-size: 12px;
/*padding: 0.8rem 0 1rem 1rem;*/
#b8cad6 background: #f5f7f6;
}
@media screen and (min-width: 55em) {
.calendar__days {
width: 50%;
float: right;
}
}
.calendar__top-bar {
background: #b8cad6;
text-align: center;
display: flex;
flex: 56px 0 0;
}
.top-bar__days {
width: 100%;
padding: 0 5px;
color: #2d4338;
font-weight: 100;
-webkit-font-smoothing: subpixel-antialiased;
font-size: 1rem;
}
.calendar__week {
display: flex;
flex: 1 1 0;
}
.calendar__day {
text-align: center;
display: flex;
flex-flow: column wrap;
justify-content: space-between;
width: 100%;
padding: 1.9rem 0.2rem 0.2rem;
}
.calendar__date {
color: #040605;
font-size: 1.7rem;
font-weight: 600;
line-height: 0.7;
}
@media screen and (min-width: 55em) {
.calendar__date {
font-size: 2.3rem;
}
}
.calendar__week .inactive .calendar__date, .calendar__week .inactive .task-count {
color: #c6c6c6;
}
.calendar__week .today .calendar__date {
color: #fd588a;
}
.calendar__task {
color: #040605;
display: flex;
font-size: 0.8rem;
}
@media screen and (min-width: 55em) {
.calendar__task {
font-size: 1rem;
}
}
.calendar__task.calendar__task--today {
color: #fd588a;
}
.danger {
color: red;
}
.success {
color: green;
}
.calendar__day:hover {
color: #0a0a0a;
background: #a6a6a6;
cursor: pointer;
}
</style>

View File

@ -49,7 +49,7 @@ $this->params['breadcrumbs'][] = $this->title;
// 'user_card_id', // 'user_card_id',
[ [
'format' => 'raw', 'format' => 'raw',
'attribute' => 'ФИО', 'attribute' => 'asdФИО',
'value' => function ($data) { 'value' => function ($data) {
return \common\models\Reports::getFio($data); return \common\models\Reports::getFio($data);
}, },

View File

@ -35,6 +35,8 @@ if (Yii::$app->controller->action->id === 'login') {
<?= Html::csrfMetaTags() ?> <?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title> <title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?> <?php $this->head() ?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head> </head>
<body class="hold-transition skin-blue sidebar-mini"> <body class="hold-transition skin-blue sidebar-mini">
<?php $this->beginBody() ?> <?php $this->beginBody() ?>

View File

@ -1,3 +1,6 @@
.body{
display: none;
}
.media__upload_img{ .media__upload_img{
margin-bottom: 10px; margin-bottom: 10px;
float: left; float: left;

View File

@ -1,3 +1,5 @@
alert(123);
$(function(){ $(function(){
$('#options').change(function(){ $('#options').change(function(){
month = $('#options :selected').val(); month = $('#options :selected').val();

2434
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -45,8 +45,9 @@ class UserCardController extends Controller
public function actionIndex() public function actionIndex()
{ {
$id_user = Yii::$app->user->id; $id_user = Yii::$app->user->id;
echo $id_user;
// die();
$result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all();
if($result) { if($result) {
$id = $result[0]['id']; $id = $result[0]['id'];
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([