コード例 #1
0
 public function search($params)
 {
     $query = Appellations::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['country' => SORT_DESC, 'region_id' => SORT_ASC, 'app_name' => SORT_ASC]], 'pagination' => ['pageSize' => 100]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'region_id' => $this->region_id]);
     $query->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'app_name', $this->app_name])->andFilterWhere(['like', 'common_flg', $this->common_flg]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Appellations::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['common_flg' => SORT_ASC, 'country' => SORT_ASC, 'appellation' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'region_id' => $this->region_id]);
     $query->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'appellation', $this->appellation])->andFilterWhere(['like', 'common_flg', $this->common_flg]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: _form.php プロジェクト: nncrypted/mysommelier
<?php

use app\models\Wineries;
use app\models\Appellations;
use app\models\Varietals;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use kartik\widgets\ActiveForm;
use kartik\widgets\Select2;
use kartik\builder\Form;
use kartik\datecontrol\DateControl;
/**
 * @var yii\web\View $this
 * @var app\models\Wines $model
 * @var yii\widgets\ActiveForm $form
 */
?>

<div class="wines-form">
    <?php 
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_HORIZONTAL]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['upc_barcode' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Upc Barcode...', 'maxlength' => 30]], 'wine_name' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Wine Name...', 'maxlength' => 45]], 'winery_id' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Wineries::find()->orderBy('winery_name')->asArray()->all(), 'id', 'winery_name')], 'appellation_id' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Appellations::find()->orderBy('app_name')->asArray()->all(), 'id', 'app_name')], 'wine_year' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Wine Year...', 'maxlength' => 4]], 'wine_varietal_id' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Varietals::find()->orderBy('varietal_name')->asArray()->all(), 'id', 'varietal_name')], 'bottle_size' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Bottle Size...', 'maxlength' => 15]], 'bottle_size' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Yii::$app->params['bottle_sizes']], 'overall_rating' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Overall Rating...']], 'created_at' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Created At...']], 'updated_at' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Updated At...']], 'description' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Description...', 'maxlength' => 255]]]]);
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
ActiveForm::end();
?>
</div>
コード例 #4
0
ファイル: Wineries.php プロジェクト: nncrypted/mysommelier
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDefaultAppellation()
 {
     return $this->hasOne(Appellations::className(), ['id' => 'default_appellation_id']);
 }
コード例 #5
0
ファイル: Regions.php プロジェクト: aekkapun/mysommelier
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAppellations()
 {
     return $this->hasMany(Appellations::className(), ['region_id' => 'id']);
 }
コード例 #6
0
ファイル: picklist.php プロジェクト: nncrypted/mysommelier
 * @var app\models\WinesSearch $searchModel
 */
$this->title = 'Wines';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wines-index">
    <div class="page-header">
            <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </div>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
/* echo Html::a('Create Wines', ['create'], ['class' => 'btn btn-success'])*/
?>
    </p>

    <?php 
Pjax::begin();
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'columns' => [['attribute' => 'winery_id', 'header' => 'Winery', 'value' => 'winery.winery_name', 'width' => '170px', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Wineries::find()->orderBy('winery_name')->asArray()->all(), 'id', 'winery_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Any Winery']], ['attribute' => 'wine_year', 'value' => 'wine_year', 'hAlign' => GridView::ALIGN_CENTER, 'width' => '90px'], ['attribute' => 'varietal_name', 'value' => 'wineVarietal.varietal_name', 'width' => '175px'], 'wine_name', ['attribute' => 'appellation_id', 'header' => 'Appellation', 'value' => 'appellation.app_name', 'width' => '200px', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Appellations::find()->orderBy('app_name')->asArray()->all(), 'id', 'app_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Any appellation']], ['attribute' => 'bottle_size', 'value' => 'bottle_size', 'hAlign' => GridView::ALIGN_CENTER, 'width' => '90px'], ['attribute' => 'overall_rating', 'value' => 'overall_rating', 'hAlign' => GridView::ALIGN_CENTER, 'width' => '100px'], ['class' => 'kartik\\grid\\ActionColumn', 'width' => '70px', 'buttons' => ['update' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Yii::$app->urlManager->createUrl(['wines/view', 'id' => $model->id, 'edit' => 't']), ['title' => Yii::t('yii', 'Edit')]);
}]]], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . ' </h3>', 'type' => 'info', 'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> Add', ['create'], ['class' => 'btn btn-success']), 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset List', ['index'], ['class' => 'btn btn-info']), 'showFooter' => false]]);
Pjax::end();
?>
</div>
コード例 #7
0
ファイル: _form.php プロジェクト: aekkapun/mysommelier
?>

    <?php 
echo $form->field($model, 'upc_barcode')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'wine_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'winery_id')->dropDownList(ArrayHelper::map(Wineries::find()->all(), 'id', 'winery_name'));
?>

    <?php 
echo $form->field($model, 'appellation_id')->dropDownList(ArrayHelper::map(Appellations::find()->all(), 'id', 'appellation'));
?>

    <?php 
echo $form->field($model, 'wine_year')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'wine_varietal_id')->dropDownList(ArrayHelper::map(Varietals::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'bottle_size')->dropDownList(Yii::$app->params['bottle_sizes']);
?>

    <?php 
コード例 #8
0
 /**
  * Finds the Appellations model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Appellations the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Appellations::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }