示例#1
0
 /**
  * This custom validator is used to prevent the deletion of a cellar location
  * where that location is the curren default for a cellar
  */
 public function validateDefLoc()
 {
     $currentCellar = Cellars::model()->findByPk($this->cellar_id);
     if ($this->cellar_loc_id == $currentCellar->default_cellar_loc_id) {
         return false;
     } else {
         return true;
     }
 }
示例#2
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 Cellars the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Cellars::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#3
0
 public function actionPicker($cellar_id)
 {
     $currentCellar = Cellars::model()->findByPk($cellar_id);
     $cellarName = $currentCellar->cellar_name;
     $criteria = new CDbCriteria();
     $criteria->with = array('winery', 'wineVarietal', 'appellation');
     $sort = new CSort();
     $sort->defaultOrder = 'winery.winery_name, wineVarietal.name, wine_year';
     $sort->attributes = array('id' => array('asc' => 't.id', 'desc' => 't.id desc'), 'winery' => array('asc' => 'winery.winery_name', 'desc' => 'winery.winery_name desc'), 'wine_name' => array('asc' => 't.wine_name', 'desc' => 't.wine_name desc'), 'varietal' => array('asc' => 'wineVarietal.name', 'desc' => 'wineVarietal.name desc'), 'wine_year' => array('asc' => 't.wine_year', 'desc' => 't.wine_year desc'), 'appellation' => array('asc' => 'appellation.appellation', 'desc' => 'appellation.appellation desc'), 'overall_rating' => array('asc' => 'overall_rating', 'desc' => 'overall_rating desc'));
     $dataProvider = new CActiveDataProvider('Wines', array('criteria' => $criteria, 'sort' => $sort, 'pagination' => array('pageSize' => 20)));
     $this->render('picker', array('dataProvider' => $dataProvider, 'cellarName' => $cellarName, 'cellar_id' => $cellar_id));
 }
 /**
  * Lists all models.
  */
 public function actionIndex($cellar_id)
 {
     $currentCellar = Cellars::model()->findByPk($cellar_id);
     $cellarName = $currentCellar->cellar_name;
     $criteria = new CDbCriteria();
     $criteria->compare('cellar_id', $cellar_id, true);
     $dataProvider = new CActiveDataProvider('CellarLocation', array('criteria' => $criteria));
     $this->render('index', array('dataProvider' => $dataProvider, 'cellarName' => $cellarName, 'cellar_id' => $cellar_id));
 }
 /**
  * Lists wines for the given cellar.
  * @param integer $id is the cellar_id to be listed.
  */
 public function actionIndex($cellar_id)
 {
     $currentCellar = Cellars::model()->findByPk($cellar_id);
     $cellarName = $currentCellar->cellar_name;
     $criteria = new CDbCriteria();
     $criteria->compare('t.cellar_id', $cellar_id, true);
     $criteria->with = array('wine.winery', 'wine.wineVarietal', 'cellarLoc');
     $sort = new CSort();
     $sort->defaultOrder = 'winery.winery_name, wineVarietal.name, wine.wine_year';
     $sort->attributes = array('wine_id' => array('asc' => 'wine_id', 'desc' => 'wine_id desc'), 'winery' => array('asc' => 'winery.winery_name', 'desc' => 'winery.winery_name desc'), 'varietal' => array('asc' => 'wineVarietal.name', 'desc' => 'wineVarietal.name desc'), 'vintage' => array('asc' => 'wine.wine_year', 'desc' => 'wine.wine_year desc'), 'wine_name' => array('asc' => 'wine.wine_name', 'desc' => 'wine.wine_name desc'), 'quantity' => array('asc' => 'quantity', 'desc' => 'quantity desc'), 'rating' => array('asc' => 'rating', 'desc' => 'rating desc'), 'location' => array('asc' => 'cellarLoc.location', 'desc' => 'cellarLoc.location desc'));
     if (!isset($_REQUEST['CellarWines_page'])) {
         if (isset(Yii::app()->session['cw_return'])) {
             $gridpage = Yii::app()->session['cw_gridpage'];
             unset(Yii::app()->session['cw_return']);
         } else {
             $gridpage = 0;
         }
     } else {
         $gridpage = $_REQUEST['CellarWines_page'] - 1;
     }
     Yii::app()->session['cw_gridpage'] = $gridpage;
     $dataProvider = new CActiveDataProvider('CellarWines', array('criteria' => $criteria, 'sort' => $sort, 'pagination' => array('pageSize' => 18, 'currentPage' => $gridpage)));
     $model = new CellarWines('search');
     $model->unsetAttributes();
     // clear any default values
     $this->render('index', array('dataProvider' => $dataProvider, 'cellarName' => $cellarName, 'cellar_id' => $cellar_id));
 }