Ejemplo n.º 1
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 Tuotteet the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Tuotteet::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 2
0
    $criteria->condition = " id='" . Yii::app()->user->id . "' AND myyjaID!=0 ";
    $u = User::model()->find($criteria);
    if (isset($u->id)) {
        $criteria = new CDbCriteria();
        $criteria->condition = " \n\t\t\t\tuser_id='" . $u->myyjaID . "' \n\t\t\t\tAND DATE_FORMAT(STR_TO_DATE(alennus_loppu_pvm, '%d.%m.%Y'), '%Y-%m-%d') > CURDATE() \n\t\t\t\tAND alennus_prosentti > 0\n\t\t\t";
        $m = Profile::model()->find($criteria);
        if (isset($m->alennus_prosentti)) {
            $alennus_prosentti = (int) $m->alennus_prosentti;
        }
    }
}
$criteria = new CDbCriteria();
$criteria->order = " id DESC ";
$criteria->condition = " user_id='" . Yii::app()->user->id . "' AND koodi='ilmainen' ";
$order = Orders::model()->find($criteria);
$t = Tuotteet::model()->findAll();
foreach ($t as $data) {
    if (!empty($data->item_id)) {
        if (!Yii::app()->user->isGuest) {
            if ($alennus_prosentti > 0) {
                $data->hinta = $data->hinta - $data->hinta * ($alennus_prosentti / 100);
            }
            $tb = '<td>
	<input type="radio" name="valiko" value="' . $data->nimike . '///' . $data->id . '///' . $data->hinta . '///' . $data->pvm_maara . '">
	' . $data->nimike . '
	</td>
    	<td class="hinta">' . $data->hinta . '&euro;</td>';
        } else {
            $tb = '<td>' . $data->nimike . '</td>
    	<td class="hinta">' . $data->hinta . '&euro;</td>';
        }