Esempio n. 1
0
 public function search($params)
 {
     $q = Order::find()->where(['manager_id' => Yii::$app->user->getId()]);
     $dataProvider = new ActiveDataProvider(['query' => $q]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $q->andFilterWhere(['type' => $this->type])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
Esempio n. 2
0
 public function searchMyOrders2($params)
 {
     $q = Order::find()->where(['client_id' => Yii::$app->user->getId(), 'status' => [5]]);
     $dataProvider = new ActiveDataProvider(['query' => $q]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $q->andFilterWhere(['product_id' => $this->product_id])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
Esempio n. 3
0
 public function actionSendToClient($idChat, $message)
 {
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $model = new Messages();
     $model->id_chat = $idChat;
     $model->from_user = Yii::$app->user->getId();
     $model->to_user = \app\modules\main\models\Order::findOne(['id' => $idChat])->client_id;
     $model->message = $message;
     if ($model->save()) {
         return ['status' => true];
     } else {
         return ['status' => false];
     }
 }
Esempio n. 4
0
 public function actionCreateOrder()
 {
     $model = new Order();
     $products = Product::find()->asArray()->all();
     $listProducts = ArrayHelper::map($products, 'id', 'name');
     if (Yii::$app->request->post()) {
         //var_dump($_POST);
         if ($_POST['category']) {
             $categories = $_POST['category'];
             //var_dump($_POST); echo "<br/>";
             foreach ($categories as $category) {
                 if (count($_POST['sub_category_' . $category]) > 1) {
                     foreach ($_POST['sub_category_' . $category] as $subCategory) {
                         $data[$category][] = $subCategory;
                     }
                 } else {
                     $data[$category] = $_POST['sub_category_' . $category];
                 }
             }
             //            var_dump(json_encode($data));
             //            die();
         } else {
             return $this->render('createOrder', ['model' => $model, 'listProducts' => $listProducts]);
         }
     }
     $clientId = Yii::$app->user->getId();
     $model->client_id = $clientId;
     //$model->manager_id = UserClient::findOne(['user_id' => $clientId])->manager_id;
     $model->status = 1;
     if (Yii::$app->request->post() && $model->save()) {
         $model->product_id = $_POST['Order']['product_id'];
         $model->comment = $_POST['Order']['comment'];
         $model->data = json_encode($data);
         $model->save();
         Yii::$app->session->setFlash('success', 'Добавлена');
         return $this->render('showOrder', ['model' => $model]);
     } else {
         return $this->render('createOrder', ['model' => $model, 'listProducts' => $listProducts]);
     }
 }
Esempio n. 5
0
<?php

use yii\widgets\ListView;
use yii\helpers\Html;
use app\modules\main\models\Order;
use yii\helpers\Url;
$status = Order::getStatusesArray();
$this->params['leftMenu'] = 1;
?>

<div class="content-header">
    заказы
</div>
<div class="new-template">
    <select id="filter" name="filter">
        <option value="0">Все заказы</option>
        <?php 
foreach ($status as $key => $value) {
    echo "<option " . ($statusOrder == $key ? 'selected ' : '') . "value='" . $key . "'>" . $value . "</option>";
}
?>
    </select>
</div>
<script>
    $(document).ready(function(){
        $('#filter').change(function() {
            if($( "#filter option:selected" ).val() == 0) {
                window.location.href = "/manager/order";
            }
            else {
                window.location.href = "?status=" + $( "#filter option:selected" ).val();
Esempio n. 6
0
<?php

use yii\helpers\Html;
use app\components\widgets\Header;
\app\assets\BaseAsset::register($this);
$quantityMyOrder = \app\modules\main\models\Order::countMyOrder();
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="ru">
    <head>
        <?php 
echo Html::csrfMetaTags();
?>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title><?php 
echo Html::encode($this->title);
?>
</title>
        <link href="/css/style1.css" rel="stylesheet">
        <link href="/css/custom.css" rel="stylesheet">
        <?php 
$this->head();
?>
    </head>
    <body>		
        <?php 
$this->beginBody();
?>
        <div id="container">