/**
  * 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 LiikuntaSuosikit the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = LiikuntaSuosikit::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #2
0
     <div class="panel-body">

  <div class="table-responsive">
   <table class="table table-hover tabTuotteet">
    <tr>
	<th>Laji</th>
	<th></th>
    </tr>
    <?php 
    foreach ($data as $model) {
        echo '
	<tr class="link viivat" id="' . $model->id . '" laji="' . $model->laji . '" value="' . $model->value . '">
		<td>' . $model->laji . '</td>';
        $criteria = new CDbCriteria();
        $criteria->condition = " liikunta_paivakirja_id='" . $model->id . "' AND user_id='" . Yii::app()->user->id . "' ";
        $s = LiikuntaSuosikit::model()->find($criteria);
        if (isset($s->id)) {
            echo '<td><b class="onSuosiki fa fa-star" title="Poista suosikeista" style="font-size:150%;color:#FF9900" suID="' . $s->id . '" forID="' . $model->id . '"></b></td>';
        } else {
            echo '<td><b class="tahti fa fa-star-o" title="Lisää suosikkeihin" style="font-size:150%" forID="' . $model->id . '"></b></td>';
        }
        echo '</tr>';
    }
    ?>
   </table>
  </div>

     </div>
   </div>
<?php 
}
Пример #3
0
 public function actionUusi_suosiki()
 {
     if (isset($_POST['sivu']) and $_POST['sivu'] == 'ruoka') {
         $model = new RuokaSuosikit();
     } elseif (isset($_POST['sivu']) and $_POST['sivu'] == 'liikunta') {
         $model = new LiikuntaSuosikit();
     }
     if (isset($_POST)) {
         $model->attributes = $_POST;
         $model->user_id = Yii::app()->user->id;
         if ($model->save()) {
             echo 'uusiFavOK//' . $model->id;
         } else {
             var_dump($model->getErrors());
         }
     }
 }