Exemplo n.º 1
0
 /**
  * Displays weight tracker page.
  *
  * @return mixed
  */
 public function actionMealPlan()
 {
     Yii::$app->MealPlanComponent->updateMealPlanId();
     $mealplanCurrentIdModel = GeneralSettings::findOne(['name' => 'mealplan_current_id']);
     $mealplanCurrentModel = CmsMealPlan::findOne($mealplanCurrentIdModel->value);
     return $this->render('mealplan/index', ['mealplanModel' => $mealplanCurrentModel]);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CmsMealPlan::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'is_active' => $this->is_active, 'sort_order' => $this->sort_order]);
     $query->andFilterWhere(['like', 'cms_pages_lang.title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'identifier', $this->identifier])->andFilterWhere(['like', 'code_id', $this->code_id]);
     $query->joinWith(['cmsMealplanLangs' => function ($query) {
         $query->where(['language' => Yii::$app->language]);
     }]);
     return $dataProvider;
 }
Exemplo n.º 3
0
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Meal Plans');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="cms-meal-plan-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Yii::t('backend', 'Create Meal Plan'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model) {
    if ($model->is_active == 0) {
        return ['class' => 'danger'];
    }
}, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'title', array('attribute' => 'is_active', 'filter' => Html::activeDropDownList($searchModel, 'is_active', \backend\models\CmsMealPlan::dropdownActive(), ['class' => 'form-control', 'prompt' => Yii::t('backend', 'All')]), 'format' => 'boolean'), 'sort_order', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>
Exemplo n.º 4
0
 private function getMealPlansList()
 {
     return CmsMealPlan::find()->orderBy('sort_order, created_at ASC')->asArray()->all();
 }
Exemplo n.º 5
0
 /**
  * Finds the CmsMealPlan model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CmsMealPlan the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CmsMealPlan::find()->where(['id' => $id])->multilingual()->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 6
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\GeneralSettings */
/* @var $form yii\widgets\ActiveForm */
$plan_items = ArrayHelper::map(\backend\models\CmsMealPlan::find()->all(), 'id', 'title');
$update_freq_items = [];
for ($week = 0; $week < 7; $week++) {
    $update_freq_items[$week] = date('D', time('Mon') + $week * 24 * 3600);
}
?>

<div class="general-settings-form">

    <?php 
$form = ActiveForm::begin();
?>

    
    <?php 
echo $form->field($modelPlanId, 'value')->dropDownList($plan_items, ['name' => 'values[mealplan_current_id]'])->label('Current Meal Plan');
?>
    
    <?php 
echo $form->field($modelPlanFreq, 'value')->dropDownList($update_freq_items, ['name' => 'values[mealplan_update_freq]'])->label('Meal Plan Update Frequency');
?>