<?
use yii\web\View;
$assetDir = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist');

foreach($users as $userid => $data){
	$op = ( $userid == $id )?0.5:1;
	$mark = (  time()-$data['time'] < $obj::sleep )?'fas fa-user-check':'fas fa-mug-hot';
	$mark = (  time()-$data['time'] < $obj::dead )?$mark:'fas fa-bed';
	$markd = (  time()-$data['time'] < $obj::sleep )?'text-success':'text-warning';
	$markd = (  time()-$data['time'] < $obj::dead )?$markd:'text-danger';
	if(  time()-$data['time'] < $obj::kill ) {
		$photo = "/images/users/".$userid."_norm.jpg";
		if( !file_exists( Yii::getAlias('@webroot').$photo ) ){
			$photo = $assetDir."/img/user1-128x128.jpg";
		}
		$authorname = $data['name'];
		$authornews = [];
		$bb_date = date("Y-m-d 00:00:00", time());
		$eb_date = date("Y-m-d 23:59:59", time());
		$sql = "select * from `news` WHERE `dt_pub` BETWEEN '".$bb_date."' AND '".$eb_date."' and editors like '$authorname%'  order by dt_pub";
		$authornews = Yii::$app->db->createCommand( $sql )->queryAll();

		$authornewsp = [];
		$ebn_date = date("Y-m-d H:i:00", time());
		$sql = "select * from `news` WHERE `dt_pub` BETWEEN '".$bb_date."' AND '".$ebn_date."' and `news`.active = 'Y' and editors like '$authorname%'  order by dt_pub";
		$authornewsn = Yii::$app->db->createCommand( $sql )->queryAll();


?>
<div class="col-md-3">
<div class="card card-primary card-outline">
   <div class="card-body box-profile">
      <div class="text-center">
         <img class="profile-user-img img-fluid img-circle" src="<?=$photo?>" alt="User profile picture">
      </div>
      <h3 class="profile-username text-center"><?=$data['name']?></h3>
      <p class="text-muted text-center"><?=$data['name']?></p>
      <ul class="list-group list-group-unbordered mb-3">
         <li class="list-group-item">
            <b>Неактивен: </b> <i class="far fa-clock mr-1"></i> <?=date("i:s", time()-$data['time'])?><span class="float-right text-sm <?=$markd?>"><i class="<?=$mark?>"></i></span>
         </li>
         <li class="list-group-item">
            <b>Публикаций</b> <a class="float-right"><?=count( $authornews )?></a>
         </li>
         <li class="list-group-item">
            <b>Выпущено</b> <a class="float-right"><?=count( $authornewsn )?></a>
         </li>
      </ul>
   </div>
</div>
</div>

                <div class="dropdown-divider"></div>
<?
	}
}
