Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $pagination = 10)
 {
     $query = Goods::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => $pagination]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['goods_id' => $this->goods_id, 'shop_price' => $this->shop_price, 'promote_price' => $this->promote_price, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'goods_sn', $this->goods_sn])->andFilterWhere(['like', 'goods_name', $this->goods_name]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params 
  * @param integer $firmID 
  *
  * @return ActiveDataProvider
  */
 public function search($params, $firmID)
 {
     /*  if($params != []){
         var_dump($params);die();}*/
     $query = Goods::find()->where(['like', 'firm_id', $firmID]);
     //-> orderBy('id ASC');
     $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->andFilterWhere(['is_active' => $this->is_active]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'price_with_vat', $this->price_with_vat])->andFilterWhere(['like', 'price_without_vat', $this->price_without_vat])->andFilterWhere(['like', 'increment_price', $this->increment_price])->andFilterWhere(['like', 'percentage', $this->percentage])->andFilterWhere(['like', 'expiration_date', $this->expiration_date])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'picture', $this->picture]);
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $tp = 0)
 {
     //if(Yii::$app->user->can('operatorSQL')){
     if ($tp == 0) {
         $query = Goods::find();
     } else {
         $query = Goods::find()->where(['typeprices_id' => $tp]);
     }
     //print_r($query);
     //die();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->pagination = FALSE;
     $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->andFilterWhere(['good_id' => $this->good_id, 'good_price' => $this->good_price, 'typeprices_id' => $this->typeprices_id]);
     $query->andFilterWhere(['like', 'good_name', $this->good_name])->andFilterWhere(['like', 'good_logo', $this->good_logo]);
     return $dataProvider;
 }
Esempio n. 4
0
<div class="listofgoods-form">

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

    <?php 
if ($orders_order_id != 0) {
    echo '<p> Номер текущего заказа ' . $orders_order_id . '</p>';
} else {
    echo $form->field($model, 'orders_order_id')->textInput(['value' => $orders_order_id]);
}
?>

    <?php 
echo $form->field($model, 'goods_good_1c_id')->dropDownList(ArrayHelper::map(Goods::find()->where(['typeprices_id' => $tp])->all(), 'good_id', 'good_name'), ['prompt' => 'Выберите товар...']);
?>

    <?php 
echo $form->field($model, 'good_count')->textInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Готово' : 'Редактировать', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Esempio n. 5
0
 /**
  * create goods
  * @param $result array
  * @param $accountId objectId
  */
 public static function createGoods($result, $accountId)
 {
     $goodsData = [];
     //get max order
     $where = ['accountId' => $accountId, 'isDeleted' => \backend\components\BaseModel::NOT_DELETED];
     $goods = Goods::find()->where($where)->orderBy(['order' => SORT_DESC])->one();
     if (empty($goods)) {
         $order = 1;
     } else {
         $order = $goods['order'] + 1;
     }
     foreach ($result as $key => $info) {
         $data = [];
         $data['productId'] = new MongoId($info['productId']);
         $data['productName'] = $info['productName'];
         $data['sku'] = $info['sku'];
         $data['categoryId'] = !empty($info['categoryId']) ? new \MongoId($info['categoryId']) : '';
         $data['score'] = intval($info['score']);
         $data['total'] = empty($info['total']) ? '' : new \MongoInt32($info['total']);
         $data['accountId'] = $accountId;
         $data['order'] = $order;
         $data['pictures'] = empty($info['pictures']) ? [] : $info['pictures'];
         $data['status'] = Goods::STATUS_OFF;
         $data['usedCount'] = 0;
         $data['offShelfTime'] = new \Mongodate();
         $order++;
         $goodsData[] = $data;
     }
     if (count($goodsData) > 0) {
         Goods::batchInsert($goodsData);
     }
     return ['status' => 'OK', 'message' => 'create successful'];
 }
Esempio n. 6
0
 public static function showGoods()
 {
     return $goods = Goods::find()->joinWith('style')->asArray()->all();
 }