Exemplo n.º 1
0
 /**
  * Lists all Goods models.
  * @return mixed
  */
 public function actionIndex($order_id = 0)
 {
     $searchModel = new GoodsSearch();
     if (Yii::$app->user->can('operator')) {
         $tp = 0;
     } else {
         $customers = new Customers();
         $tp = $customers->getTP(Yii::$app->user->id);
     }
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $tp);
     //$dataProvider->setPagination(['defaultPageSize' => 50]);
     //var_dump($dataProvider->pagination);
     //die();
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'order_id' => $order_id]);
 }
Exemplo n.º 2
0
 protected function findModel($id)
 {
     if (($model = Customers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 3
0
 public function getParent($id)
 {
     $usr = User::findOne(['id' => $id]);
     $cust = Customers::findOne(['customer_name' => $usr->fullname]);
     //$usr = User::findOne(['id' => $cust->user_id]);
     //var_dump($cust);
     //die;
     return $cust->typeprices_id;
 }
Exemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customers::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['customer_id' => $this->customer_id]);
     $query->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'province', $this->province]);
     return $dataProvider;
 }
Exemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customers::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(['customer_id' => $this->customer_id]);
     $query->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'province', $this->province]);
     return $dataProvider;
 }
Exemplo n.º 6
0
 /**
  * Creates a new Listofgoods model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($order_id = 0, $amount = 0)
 {
     $model = new Listofgoods();
     $customers = new Customers();
     $typeprice = $customers->getTP(Yii::$app->user->id);
     //получаем тип цены для данного пользователя
     if ($model->load(Yii::$app->request->post())) {
         if ($order_id != 0) {
             $model->orders_order_id = $order_id;
             $price = $model->goodsGoodId->good_price / 100;
             $count = $model->good_count;
             $amount = $amount + $price * $count;
             //увеличим сумму заказа
             $order = Orders::findOne($order_id);
             $order->order_amount = $amount * 100;
             $order->save();
         }
         $model->save();
         return $this->redirect(['orders/view', 'id' => $model->orders_order_id]);
     } else {
         return $this->render('create', ['model' => $model, 'orders_order_id' => $order_id, 'tp' => $typeprice]);
     }
 }
Exemplo n.º 7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     //каждому пользователю соответствуют его контрагенты
     if (Yii::$app->user->can('admin')) {
         $query = Customers::find();
     } else {
         $query = Customers::find()->where(['user_id' => Yii::$app->user->id]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('usersUser');
     $query->joinWith('typePrices');
     $query->andFilterWhere(['customer_id' => $this->customer_id]);
     $query->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'user.fullname', $this->user_id])->andFilterWhere(['like', 'type_price.type_price_name', $this->typeprices_id])->andFilterWhere(['like', 'customer_email', $this->customer_email]);
     return $dataProvider;
 }
Exemplo n.º 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCustomer()
 {
     return $this->hasOne(Customers::className(), ['id' => 'customer_id']);
 }
Exemplo n.º 9
0
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\Orders */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="orders-form">

    <?php 
$form = ActiveForm::begin();
?>
   
    <?php 
echo $form->field($model, 'customers_customer_id')->dropDownList(ArrayHelper::map(Customers::find()->where(['user_id' => Yii::$app->user->id])->all(), 'customer_id', 'customer_name'), ['prompt' => 'Выберите контрагента...']);
?>

    
    <?php 
//$form->field($model, 'order_amount')->textInput(['value' => $model->order_amount / 100])
?>
    <?php 
if (isset($amount)) {
    echo 'Сумма заказа: ' . $amount;
} else {
    echo 'Сумма заказа: ' . $model->order_amount;
}
?>
    
Exemplo n.º 10
0
 public function getCustomer()
 {
     return $this->hasMany(Customers::className(), ['user_id' => 'id']);
 }