<?php

/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model app\models\Journal */
use yii\helpers\Html;
use app\models\Mood;
$date = date("Y-m-d");
$mood = Mood::percentageMonthly($model->id, date("m"));
if ($model->status != 2 && count($model->moods) > 0) {
    ?>
    <!-- single user -->
    <!-- Widget: user widget style 1 -->
    <div class="col-md-4">
        <div class="box box-widget widget-user">
            <!-- Emoji for widget -->
            <div class="widget-emoji <?php 
    echo $model->todayMood;
    ?>
"></div>
            <!-- Emoji for widget ends -->
            <!-- Add the bg color to the header using any of the bg-* classes -->
            <div class="widget-user-header" style="background-color:<?php 
    echo $model->profile->color;
    ?>
">
                <h3 class="widget-user-username"><?php 
    echo $model->fullname;
    ?>
</h3>
                <h5 class="widget-user-desc">is <?php 
Example #2
0
<?php

use yii\helpers\Html;
use app\models\Mood;
/* @var $this yii\web\View */
/* @var $model app\models\User */
/* @var $moods app\models\Mood */
$this->title = "Mood Summary - " . $model->fullname;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Moods'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$last = Mood::find()->select('date')->where(['user_id' => $model->id])->orderBy(['date' => SORT_DESC])->one();
$mood = Mood::percentageMonthly($model->id, date("m", strtotime($last->date)));
$monthly = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
$yearly = [];
?>
<div class="row">
    <div class="col-md-12 ">
        <label class="control-label">Select a month</label>
        <select id="date-range" name="date-range" class="form-control">
            <option value="<?php 
echo intval(date('m'));
?>
" data-year="<?php 
echo date('Y');
?>
">Please Select</option>
            <?php 
//Find and display available moods in a drop down, by month of selected user
foreach ($moods as $year => $months) {
    foreach ($monthly as $k => $m) {
        $yearly[$year][0][intval($k)] = isset($months[$m]) ? $months[$m]['sad'] : 0;
Example #3
0
 /**
  * get current day mood
  */
 public function getTodayMood($user_id = null)
 {
     $moods_today = Mood::percentageMonthly($this->id, null);
     if ($max = max($moods_today)) {
         return array_search(max($moods_today), $moods_today);
     } else {
         return "not-updated the mood";
     }
 }