<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use dektrium\user\models\Profile;

/** @var yii\web\View $this */
/** @var manager\models\CommentsFilter $model */
	$user = $id;
	$cache = Yii::$app->memcache;
	$profile_name = Profile::findOne($id)->name;
	$this->title = 'Мониторинг сна: '.$profile_name."";
	$this->params['breadcrumbs'][] = ['label' => $this->title, 'url' => ['index']];


		$mduser = $id;
		$uactive = $cache->get($obj::keylist);
		if( $uactive ){
			$uactive = unserialize($uactive);
		}
		$ukey ='userlog_'.$id;
		$ulog = $cache->get( $ukey );
		if( $ulog ){
			$ulog = unserialize($ulog);
		}else{
			$ulog = [];
		}

		$tstats = ['start' => 'Начало работы', 'good' => 'Работа<br>...', 'sleep' => 'Лёгий сон', 'dead' => 'Глубокий сон', 'norm' => 'Работа<br>...'];
		$mstats = ['start' => 'bg-soft-primary text-primary', 'good' => 'bg-soft-success text-success', 'sleep' => 'bg-soft-warning text-warning', 'dead' => 'bg-soft-danger text-danger', 'norm' => 'bg-soft-success text-success'];
?>
<style>


.hori-timeline .events {
    border-top: 3px solid #e9ecef;
}
.hori-timeline .events .event-list {
    display: block;
    position: relative;
    text-align: center;
    padding-top: 70px;
    margin-right: 0;
}
.hori-timeline .events .event-list:before {
    content: "";
    position: absolute;
    height: 36px;
    border-right: 2px dashed #dee2e6;
    top: 0;
}
.hori-timeline .events .event-list .event-date {
    position: absolute;
    top: 38px;
    left: 0;
    right: 0;
    width: 75px;
    margin: 0 auto;
    border-radius: 4px;
    padding: 2px 4px;
}
@media (min-width: 1140px) {
    .hori-timeline .events .event-list {
        display: inline-block;
        min-width: 7%;
		max-width:100px;
        padding-top: 45px;
    }
    .hori-timeline .events .event-list .event-date {
        top: -12px;
    }
}
.bg-soft-primary {
    background-color: rgba(64,144,203,.3)!important;
}
.bg-soft-success {
    background-color: rgba(71,189,154,.3)!important;
}
.bg-soft-danger {
    background-color: rgba(231,76,94,.3)!important;
}
.bg-soft-warning {
    background-color: rgba(249,213,112,.3)!important;
}

</style>

<div class="row">

    <div class="col-lg-12">
                <div class="hori-timeline" dir="ltr">
                    <ul class="list-inline events">
<?
	$dt = strtotime( date('Y-m-d 00:00:00') );
	foreach( $ulog as $time => $data ){
		if( $time < $dt ) continue;
?>
                        <li class="list-inline-item event-list">
                            <div class="px-4 align-top">
                                <div class="event-date <?=$mstats[$data['stat']]?> align-top"><?=date("H:i", $time)?></div>
                                <h5 class="font-size-16"><?=$tstats[$data['stat']]?></h5>
                            </div>
                        </li>
<?
}
?>
                    </ul>
                </div>

        <!-- end card -->
    </div>

</div>
