コード例 #1
0
ファイル: DashboardController.php プロジェクト: sabih3/hotpot
 public function actionResturantmenu()
 {
     $from = strtotime(date('2015-07-25'));
     //$from = strtotime(date('Y-m-d'));
     $today = strtotime('+7 days');
     $difference = $today - $from;
     $daysDiff = floor($difference / (60 * 60 * 24));
     $sEndDate = date('Y-m-d', strtotime('+' . $daysDiff . ' days'));
     //$datestr = date('Y-m-d', strtotime('-6 days'));
     $sStartDate = date("Y-m-d", strtotime(date('2015-07-25')));
     $sEndDate = date("Y-m-d", strtotime($sEndDate));
     // Start the variable off with the start date
     $aDays[] = $sStartDate;
     // Set a 'temp' variable, sCurrentDate, with
     // the start date - before beginning the loop
     $sCurrentDate = $sStartDate;
     // While the current date is less than the end date
     while ($sCurrentDate < $sEndDate) {
         // Add a day to the current date
         $sCurrentDate = date("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate)));
         // Add this new day to the aDays array
         $aDays[] = $sCurrentDate;
     }
     $meals = Meal::getMeal();
     $count = 0;
     $newArrayMealsByDays = [];
     if (!empty($meals)) {
         foreach ($meals as $key => $value) {
             //echo $count++;
             //foreach ($aDays as $dateKey => $dateValue) {
             //$dayOfDeal = date('Y-m-d', $value['day']);
             //if($dayOfDeal == $dateValue){
             $newArrayMealsByDays[$value['day']][$count]['id'] = $value['id'];
             $newArrayMealsByDays[$value['day']][$count]['name'] = $value['name'];
             $newArrayMealsByDays[$value['day']][$count]['mealImageUrl'] = $value['image_new_url'];
             $newArrayMealsByDays[$value['day']][$count]['mealPrice'] = $value['meal_price'];
             $getMealItems = MealItemsManage::find()->select(['item_id'])->where(['meal_id' => $value['id']])->asArray()->all();
             if (!empty($getMealItems)) {
                 foreach ($getMealItems as $key2 => $value2) {
                     $query = new Query();
                     $query->select(['meal_item.*', 'meal_item_image.image_new_url', 'meal_item_image.image_org_url'])->from('meal_item')->join('LEFT JOIN', 'meal_item_image', 'meal_item_image.itemID = meal_item.id')->where(['meal_item.id' => $value2['item_id']]);
                     $command = $query->createCommand();
                     $data[] = $command->queryAll()[0];
                 }
                 $newArrayMealsByDays[$value['day']][$count]['items'] = $data;
                 //array_values($newArrayMealsByDays[$dayOfDeal]);
                 unset($data);
                 $count++;
             }
             //}
             //}
         }
     }
     // echo '<pre>';
     // print_r($newArrayMealsByDays);die;
     // die;
     return $this->render('_resturant_menu', ['data' => $newArrayMealsByDays]);
 }
コード例 #2
0
ファイル: MealSearch.php プロジェクト: gearger/imagenizer
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Meal::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['meal_id' => SORT_ASC], 'enableMultiSort' => true]]);
     $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(['meal_id' => $this->meal_id]);
     $query->andFilterWhere(['like', 'meal_text', $this->meal_text])->andFilterWhere(['like', 'meal_img', $this->meal_img])->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: MealController.php プロジェクト: sabih3/hotpot
 /**
  * Finds the Meal model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Meal the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Meal::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
ファイル: MainController.php プロジェクト: gearger/imagenizer
 private function generator($scenario)
 {
     $model = new Main();
     if (!empty(Yii::$app->request->post())) {
         $main_id = Yii::$app->request->post()['Main']['main_id'];
         if (empty($main_id)) {
             // New record
             $model->load(Yii::$app->request->post());
             // Load time_array manually, since it's not part of Main Table
             $model->time_array = Yii::$app->request->post()['Main']['time_array'];
             // Add Owner
             $model->user_id = Yii::$app->user->identity->id;
             $model->created = date('Y-m-d H:i:s');
             $model->updated = date('Y-m-d H:i:s');
         } else {
             // Update exist record
             $model = $this->findModel($main_id);
             $model->load(Yii::$app->request->post());
             // Load time_array manually, since it's not part of Main Table
             $model->time_array = Yii::$app->request->post()['Main']['time_array'];
             // Update Timestamp
             $model->updated = date('Y-m-d H:i:s');
         }
         if (!empty($model->time_array)) {
             // Convert array to bit
             $model->time_bit = $model->encodeBit($model->time_array);
         }
         // Force null
         $model->drug_name = empty($model->drug_name) ? null : $model->drug_name;
     }
     if (isset(Yii::$app->request->post()['save']) && $model->validate()) {
         if ($model->save()) {
             Yii::$app->getSession()->setFlash('main_create_success', ['type' => Growl::TYPE_SUCCESS, 'title' => '<b>' . Yii::t('backend', 'Success') . '</b>', 'icon' => 'glyphicon glyphicon-ok-sign', 'body' => '<strong>' . $model->profile_name . '</strong> ' . Yii::t('backend', 'has been saved.')]);
         }
         $model = new Main();
     } elseif (isset(Yii::$app->request->post()['generate'])) {
         $model->scenario = $scenario;
         if ($model->validate()) {
             if ($model->scenario == 'generate-original') {
                 // Load patient_name manually, since it's not part of Main Table
                 $model->patient_name = Yii::$app->request->post()['Main']['patient_name'];
             }
             /* Get amount_img */
             $amount_data = \backend\models\Amount::find()->select(['amount_img'])->andWhere('amount_id = :amount_id', [':amount_id' => $model->amount_id])->one();
             $model->amount_id = $amount_data->amount_img;
             /* Get time_img */
             $time_data = \backend\models\Time::find()->select(['time_id', 'time_img'])->orderBy('time_id')->asArray()->all();
             foreach ($time_data as $time_all_key => $time_all_value) {
                 foreach ($model->time_array as $time_select_key => $time_select_value) {
                     if ($time_all_value['time_id'] == $time_select_value) {
                         $time_img[] = $time_all_value['time_img'];
                     }
                 }
             }
             $model->time_array = $time_img;
             /* Get meal_img */
             $meal_data = \backend\models\Meal::find()->select(['meal_img'])->andWhere('meal_id = :meal_id', [':meal_id' => $model->meal_id])->one();
             $model->meal_id = $meal_data->meal_img;
             /* Build PDF */
             $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => [48, 80], 'orientation' => Pdf::ORIENT_LANDSCAPE, 'marginLeft' => 2, 'marginRight' => 2, 'marginTop' => 10, 'marginBottom' => 0, 'cssInline' => '
                     body{font-family:garuda; color: #000;}
                     hr{margin-top: 4px; margin-bottom: 4px; color: #000;}
                     .text-ctl{font-size: 10px;}
                     .table-ctl{text-align: center; width:80px;}
                     .table-vr{border-left: solid #000;}
                 ', 'content' => $this->renderPartial('_label', ['model' => $model]), 'filename' => 'label_' . date('YmdHi') . '.pdf', 'destination' => Pdf::DEST_BROWSER]);
             return $pdf->render();
         }
     }
     return $this->render('generator', ['model' => $model, 'scenario' => $scenario]);
 }
コード例 #5
0
ファイル: Main.php プロジェクト: gearger/imagenizer
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMeal()
 {
     return $this->hasOne(Meal::className(), ['meal_id' => 'meal_id']);
 }