public function showInfoRestaurant($id)
 {
     $analytic = Restaurant::find($id);
     if ($analytic) {
         $analytic->counter = $analytic->counter++;
         $analytic->save();
     }
     $restaurant = Restaurant::find($id);
     return view('frontend.pages.info-restaurant', compact('restaurant'));
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Restaurant::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(['restaurant_id' => $this->restaurant_id, 'name' => $this->name, 'street' => $this->street, 'house_nr' => $this->house_nr, 'flat_nr' => $this->flat_nr, 'zip_code' => $this->zip_code, 'city' => $this->city]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'street', $this->street])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'city', $this->city]);
     return $dataProvider;
 }
 function userRestaurantAnalytic()
 {
     $input = Input::all();
     $analytic = Restaurant::find($input['restaurant_id']);
     $analytic->counter = $analytic->counter++;
     if (!$analytic) {
         return Json::error('error');
     } else {
         $analytic->counter = $analytic->counter++;
         if ($analytic->save()) {
             return Json::success();
         } else {
             return Json::error('error');
         }
     }
 }
Ejemplo n.º 4
0
 public function actionChart()
 {
     $customers = User::find()->select(['city', 'COUNT(*) AS street'])->groupBy('city')->all();
     $restaurants = Restaurant::find()->select(['city', 'COUNT(*) AS street'])->groupBy('city')->all();
     // $restaurantsOrders = Restaurant::find()
     //    ->select(['{{restaurants}}.name', 'COUNT({{orders}}.order_id) AS restaurant_id'])
     //    ->joinWith('order')
     //    ->groupBy('{{restaurants}}.name')
     //   ->all();
     $connection = \Yii::$app->db;
     $restaurantsOrders = $connection->createCommand('SELECT restaurants.name, Count(orders.order_id) FROM restaurants LEFT JOIN orders ON restaurants.restaurant_id = orders.restaurant_id GROUP BY restaurants.name')->queryAll();
     $chart = new Charts();
     $LabChartsPie = new LabChartsPie();
     $LabChartsPie->setData($chart->getUsersAmountArray($customers));
     $LabChartsPie->setTitle('');
     $LabChartsPie->setSize('400x200');
     $LabChartsPie->setColors('D9351C');
     $LabChartsPie->setLabels($chart->getCities($customers));
     $LabChartsBar = new LabChartsBar();
     $LabChartsBar->setData($chart->getAmountArray($restaurants));
     $LabChartsBar->setSize('400x200');
     $LabChartsBar->setTitle('');
     //$LabChartsBar->setColors('D9351C|FAAC02|79D81C|2A9DF0|02AA9D');
     $LabChartsBar->setLabels($chart->getCities($restaurants));
     $LabChartsBar->setBarStyles(40);
     $LabChartsBar->setAxis(10);
     $LabChartsBar->setGrids(10);
     $LabChartsPie2 = new LabChartsPie();
     $LabChartsPie2->setData($chart->getAmountOrderArray($restaurantsOrders));
     //$LabChartsPie->setType('p3');
     $LabChartsPie2->setTitle('');
     $LabChartsPie2->setSize('400x200');
     $LabChartsPie2->setColors('D9351C');
     $LabChartsPie2->setLabels($chart->getRestaurantNames($restaurantsOrders));
     return $this->render('chart', ['LabChartsPie' => $LabChartsPie, 'LabChartsPie2' => $LabChartsPie2, 'LabChartsBar' => $LabChartsBar]);
 }
Ejemplo n.º 5
0
 public function upload()
 {
     if ($this->validate()) {
         $this->xmlFile->saveAs('uploads/' . $this->xmlFile->baseName . '.' . $this->xmlFile->extension);
         $xml = simplexml_load_file('uploads/' . $this->xmlFile->baseName . '.' . $this->xmlFile->extension);
         foreach ($xml->product as $product) {
             $warehouse = new Warehouse();
             $warehouse->warehouse_id = null;
             $restaurant = Restaurant::find()->where(['name' => $product->restaurant_name])->one();
             $products = Product::find()->where(['name' => $product->product_name])->one();
             if (isset($products) && isset($restaurant)) {
                 $warehouse->restaurant_id = $restaurant->restaurant_id;
                 $warehouse->product_id = $products->product_id;
                 $warehouse->description = $product->description;
                 $warehouse->price = $product->price;
                 $warehouse->save();
             }
         }
         unlink('uploads/' . $this->xmlFile->baseName . '.' . $this->xmlFile->extension);
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 6
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Restaurant;
$this->title = Yii::t('app', 'Pdf menu creator');
$this->params['breadcrumbs'][] = Yii::t('app', $this->title);
?>

<div class="order-form">

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

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



    <div class="form-group">
        <?php 
echo Html::submitButton(Yii::t('app', 'Create'), ['class' => 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Ejemplo n.º 7
0
                        ' . Yii::t('app', 'You are logged in') . '
                </div>';
    echo '<h1>' . Yii::t('app', 'Welcome') . ' ' . $model->login . '</h1>';
    echo '<img src= "/upload/' . $model->filename . '" onError="this.src=\'\';"/>';
    echo '<h1>' . Yii::t('app', 'Find restaurant') . '</h1>';
}
?>
        <div style="width:100%">
        <div class="col-lg-5" style="left: 30%;">
            <?php 
$form = ActiveForm::begin(['id' => 'contact-form']);
?>


            <?php 
echo $form->field($modelform, 'city')->dropDownList(ArrayHelper::map(Restaurant::find()->all(), 'city', 'city'));
?>

            <?php 
echo $form->field($modelform, 'street')->label(Yii::t('app', "Street name:"));
?>

            <div class="form-group">
                <?php 
echo Html::submitButton(Yii::t('app', 'Find'), ['class' => 'btn btn-primary', 'name' => 'contact-button']);
?>
            </div>
            <?php 
ActiveForm::end();
?>
        </div>
 /**
  * @return string
  */
 public function actionCreatepdf()
 {
     if (Yii::$app->user->isGuest || Yii::$app->user->identity->user_role != 4 && Yii::$app->user->identity->user_role != 3) {
         return $this->goHome();
     }
     $model = new Restaurant();
     if ($model->load(Yii::$app->request->post())) {
         $mpdf = new mPDF();
         $connection = \Yii::$app->db;
         $warehouses = $connection->createCommand('SELECT warehouse.description, warehouse.price, products.name FROM warehouse LEFT JOIN products ON warehouse.product_id=products.product_id WHERE warehouse.restaurant_id=' . $model->restaurant_id)->queryAll();
         $restaurant = Restaurant::find()->where(['restaurant_id' => $model->restaurant_id])->one();
         $mpdf->WriteHTML('<h1>Menu restauracji ' . $restaurant->name . ' ' . $restaurant->city . '</h1>');
         foreach ($warehouses as $warehouse) {
             $mpdf->WriteHTML($warehouse['name'] . '<br> Opis: ' . $warehouse['description'] . '<br>Cena: ' . $warehouse['price'] . '<br><br><br>');
         }
         $mpdf->Output();
         exit;
     }
     return $this->render('createpdf', ['model' => $model]);
 }
Ejemplo n.º 9
0
 protected function findModel($id)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     if (($model = Restaurant::find()->where(['restaurant_id' => $id])->one()) !== null) {
         return $model;
     } else {
         echo json_encode(array('status' => 0, 'error_code' => Codes::$BAD_REQUEST, 'message' => StatusCodeMessage::$BAD_REQUEST), JSON_PRETTY_PRINT);
         exit;
         // throw new NotFoundHttpException('The requested page does not exist.');
     }
 }