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'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = Input::all();
     $restaurant = Restaurant::where('user_id', Auth::user()->id)->first();
     $category = new Category();
     $category->restaurant_id = $restaurant->id;
     $category->category = $input['nombreCategoria'];
     $category->save();
     return redirect('admin/categories');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $menuOption = "analitics";
     $restaurant = Restaurant::where('user_id', Auth::user()->id)->first();
     $dishes = Dish::where('restaurant_id', $restaurant->id)->get();
     $categories = Category::where('restaurant_id', $restaurant->id)->get();
     $dishesIds = Dish::where('restaurant_id', $restaurant->id)->lists('id');
     $categoriesIds = Category::where('restaurant_id', $restaurant->id)->lists('id');
     $dishesAnalytics = Analitic::where('related_table', 'dishes')->whereIn('related_id', $dishesIds)->get();
     $firstDay = Analitic::where('related_table', 'dishes')->whereIn('related_id', $dishesIds)->min('date');
     $categoriesAnalytics = Analitic::where('related_table', 'categories')->whereIn('related_id', $categoriesIds)->get();
     return view('backend.pages.analitics')->with(compact('dishesAnalytics', 'menuOption'));
 }
예제 #4
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;
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('backend.partials.leftPanel', function ($view) {
         $restaurant = Restaurant::where('user_id', Auth::user()->id)->first();
         $view->with(compact('restaurant'));
     });
     view()->composer('backend.partials.headerPanel', function ($view) {
         $restaurant = Restaurant::where('user_id', Auth::user()->id)->first();
         $view->with(compact('restaurant'));
     });
     view()->composer('*', function ($view) {
         $arr = explode('.', $view->getName());
         view()->share('VIEW', $arr[count($arr) - 1]);
     });
 }
 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');
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $restaurant = Restaurant::where('user_id', Auth::user()->id)->first();
     $input = Input::all();
     if (filter_var($input['emailRestaurante'], FILTER_VALIDATE_EMAIL)) {
         if (preg_match("/^[0-9]{3}-[0-9]{4}-[0-9]{4}\$/", $input['telefonoRestaurante'])) {
             $restaurant->name = $input['nombreRestaurante'];
             $restaurant->email = $input['emailRestaurante'];
             $restaurant->telephone = $input['telefonoRestaurante'];
             $restaurant->address = $input['direccionRestaurante'];
             $restaurant->save();
             return redirect('admin/config');
         }
     } else {
         return redirect('admin.config.index');
     }
 }
예제 #8
0
 public function exportRestaurantMenuToCsv($id)
 {
     $restaurantName = Restaurant::findOne(['restaurant_id' => $id])->name;
     Yii::$app->params['uploadPath'] = Yii::$app->basePath . '/web/upload/';
     $string = "name, description, price \n";
     $product = null;
     foreach (Warehouse::find()->where(['restaurant_id' => $id])->batch(1) as $warehouse) {
         try {
             $product = Product::findOne(['product_id' => $warehouse[0]->product_id]);
             $string .= '"' . $product->name . '","' . $product->description . '","' . $warehouse[0]->price . '"';
             $string .= "\n";
         } catch (Exception $e) {
         }
     }
     $path = $this->saveStringToCsvFile($string, $restaurantName);
     $this->giveUserFile($path);
 }
예제 #9
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]);
 }
예제 #10
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;
     }
 }
예제 #11
0
 /**
  * Creating new order
  * User have to give restaurant_id and it should exist in table restaurants
  * Other attributes is optional, gives status value of Order::STATUS_CREATED
  *
  * @throws \yii\db\Exception
  */
 public function actionCreate()
 {
     $role = UserRoleDetector::getUserRole();
     Yii::$app->response->format = Response::FORMAT_JSON;
     if ($role != 3 && $role != 4) {
         echo json_encode(array('error_code' => Codes::$UNAUTHORIZED, 'errors' => StatusCodeMessage::$UNAUTHORIZED), JSON_PRETTY_PRINT);
     } else {
         $params = $_REQUEST;
         //checking restaurant_id
         if (!isset($params['restaurant_id'])) {
             echo json_encode(array('status_code' => CODES::$BAD_REQUEST, 'message' => StatusCodeMessage::$BAD_REQUEST), JSON_PRETTY_PRINT);
             exit;
         } else {
             $restaurant = Restaurant::findOne(['restaurant_id' => $params['restaurant_id']]);
             if ($restaurant == null) {
                 echo json_encode(array('status_code' => CODES::$NOT_FOUND, 'message' => StatusCodeMessage::$NOT_FOUND), JSON_PRETTY_PRINT);
                 exit;
             }
         }
         $query = new Query();
         $result = $query->createCommand()->insert('orders', ["user_id" => isset($params['user_id']) ? User::findOne(['user_id' => $params['user_id']]) != null ? $params['user_id'] : null : null, "user_info" => isset($params['user_info']) ? $params['user_info'] : null, "restaurant_id" => $params['restaurant_id'], "order_info" => isset($params['order_info']) ? $params['order_info'] : '', "status" => Order::STATUS_CREATED, "other_users" => ''])->execute();
         if ($result == null) {
             echo json_encode(array('status_code' => Codes::$INERNAL, 'message' => StatusCodeMessage::$INERNAL), JSON_PRETTY_PRINT);
             exit;
         } else {
             $model = $query->from('orders')->select(['order_id', 'user_id', 'user_info', 'restaurant_id', 'order_info'])->where(['order_id' => $query->max('order_id')])->createCommand()->queryAll();
             echo json_encode(array('status_code' => Codes::$CREATED, 'message' => StatusCodeMessage::$CREATED, 'data' => $model), JSON_PRETTY_PRINT);
         }
     }
 }
 /**
  * @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]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $restaurant = Restaurant::where('user_id', Auth::user()->id)->first();
     $input = Input::all();
     $dish = Dish::find($id);
     $dish->restaurant_id = $restaurant->id;
     $dish->name = $input['nombrePlato'];
     $dish->description = $input['descripcionPlato'];
     $dish->cost = $input['precioPlato'];
     if (isset($input['is_active'])) {
         $dish->is_active = true;
     } else {
         $dish->is_active = false;
     }
     $dish->save();
     $dish->categories()->detach();
     if (isset($input['categoriaPlato'])) {
         for ($i = 0; $i < sizeof($input['categoriaPlato']); $i++) {
             $dish->categories()->attach($input['categoriaPlato'][$i]);
         }
     }
     return redirect('admin/dishes');
 }
예제 #14
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.');
     }
 }
예제 #15
0
    return ['id' => $faker->unique()->randomNumber, 'poste' => 'e', 'prenom' => $faker->firstName, 'nom' => $faker->lastName, 'langue' => 'fr', 'telephone' => $faker->phoneNumber, 'cellulaire' => $faker->phoneNumber, 'est_notifie' => false, 'restaurant_primaire' => $faker->randomElement($restaurants)];
});
/**
 * Fabrique (factory) d'un assistant
 * @retour Array
 */
$factory->defineAs(Employe::class, 'assistant', function () use($factory) {
    $employe = $factory->raw(Employe::class);
    return array_merge($employe, ['poste' => 'a']);
});
/**
 * Fabrique (factory) d'un gérant
 * @retour Array
 */
$factory->defineAs(Employe::class, 'gerant', function ($faker) use($factory) {
    $restaurants = Restaurant::lists('id')->all();
    $employe = $factory->raw(Employe::class);
    return array_merge($employe, ['poste' => 'g', 'restaurant_primaire' => $faker->unique()->randomElement($restaurants)]);
});
/**
 * Fabrique (factory) d'un directeur
 * @retour Array
 */
$factory->defineAs(Employe::class, 'directeur', function () use($factory) {
    $employe = $factory->raw(Employe::class);
    return array_merge($employe, ['poste' => 'd', 'restaurant_primaire' => null]);
});
/**
 * Fabrique (factory) d'un propriétaire
 * @retour Array
 */
예제 #16
0
 public function getRestaurant()
 {
     return $this->hasOne(Restaurant::className(), ['restaurant_id' => 'restaurant_id']);
 }
예제 #17
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>
예제 #18
0
파일: index.php 프로젝트: vodas/praktykigda
                        ' . 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>