示例#1
0
<br>

<div class="row">

   <div class="panel panel-primary">
     <div class="panel-heading">Tilastot</div>
     <div class="panel-body">

<div class="table-responsive">
<table class="table table-hover table-bordered">
  <tr>
   <th>PVM</th>
  <?php 
$attributes = Mittaus::model()->getAttributes();
$m = new Mittaus();
unset($attributes['id'], $attributes['pvm'], $attributes['user_id']);
foreach ($attributes as $key => $val) {
    echo '<th>' . $m->getAttributeLabel($key) . '</th>';
}
?>

  </tr>
  <?php 
foreach ($data as $model) {
    $return = array();
    $pvm = date("d.m.Y", strtotime($model->pvm));
    $vko = (int) date("YW", strtotime($model->pvm));
    $kk = (int) date("Ym", strtotime($model->pvm));
    //echo $pvm.' '.$vko.'<br>';
    echo '<tr>';
示例#2
0

<?php 
function allZeroes($arr)
{
    foreach ($arr as $v) {
        if ($v != 0) {
            return false;
        }
    }
    return true;
}
$i = 0;
$category = array();
$d = array();
$attributes = Mittaus::model()->getAttributes();
unset($attributes['id'], $attributes['pvm'], $attributes['user_id']);
foreach ($attributes as $ko => $vo) {
    $arr = array();
    foreach ($data as $model) {
        $value = null;
        if ($model->{$ko} > 0 and $model->{$ko} != '') {
            $value = $model->{$ko};
        }
        if ($model->{$ko} == '') {
            $arr[] = null;
        } else {
            $arr[] = (double) str_replace(",", ".", $value);
        }
    }
    if ($ko == 'aamupaino') {
示例#3
0
 protected function yhteensaMittaus($k, $kausi)
 {
     $return = array();
     $criteria = new CDbCriteria();
     //$criteria->select = " YEARWEEK(`pvm`) as gramm,t.* ";
     $criteria->condition = "\n\t\t\tuser_id = '" . Yii::app()->user->id . "' \n\t\t";
     //echo $k.'<br>';
     if ($kausi == 'pvm') {
         $criteria->addCondition(" `pvm`='" . $k . "' ");
     } elseif ($kausi == 'viikko') {
         $criteria->addCondition(" YEARWEEK(pvm, 1) = '" . $k . "' ");
         //YEARWEEK(pvm`, INTERVAL 1 DAY), 3)
     } elseif ($kausi == 'kuukausi') {
         $criteria->addCondition(" EXTRACT(YEAR_MONTH FROM `pvm`)='" . $k . "' ");
     } else {
         $criteria->addCondition(" pvm='" . $k . "' ");
     }
     $m = Mittaus::model()->findAll($criteria);
     $attributes = Mittaus::model()->getAttributes();
     unset($attributes['id'], $attributes['pvm'], $attributes['user_id']);
     if (isset($m[0])) {
         foreach ($attributes as $key => $val) {
             $u = 0;
             $return[$key] = '';
             foreach ($m as $model) {
                 if ($model->{$key} > 0) {
                     $u++;
                     $return[$key] += $model->{$key};
                 }
             }
             if ($return[$key] > 0) {
                 $return[$key] = round($return[$key] / $u, 1);
             }
         }
     }
     return $return;
 }
示例#4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Mittaus the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Mittaus::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#5
0
文件: _form.php 项目: laptopsr/miinus
/* @var $model Mittaus */
/* @var $form CActiveForm */
if (isset($model->id)) {
    $p = $model->pvm;
} else {
    $p = date('Y-m-d', strtotime($_POST['pvm2']));
}
?>

<div class="row well form">

<?php 
$criteria = new CDbCriteria();
$criteria->order = " id ASC ";
$criteria->condition = " user_id='" . Yii::app()->user->id . "' ";
$mit = Mittaus::model()->find($criteria);
if (isset($mit->user_id)) {
    echo '<div class="link alert alert-default bg-primary poistaKaikkiTiedot">Mittaus päiväkirja aloitettu ' . date("d.m.Y", strtotime($mit->pvm)) . '.<br>Jos haluat aloittaa mittaukset alusta, niin paina tästä.</div>';
}
?>


<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'mittaus-form', 'enableAjaxValidation' => false));
?>



	<?php 
echo $form->errorSummary($model);
?>