/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Vendorproducts::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(['Pid' => $this->Pid]);
     $query->andFilterWhere(['like', 'ProductName', $this->ProductName])->andFilterWhere(['like', 'Quatity', $this->Quatity])->andFilterWhere(['like', 'Weight', $this->Weight])->andFilterWhere(['like', 'Price', $this->Price])->andFilterWhere(['like', 'Discount', $this->Discount]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params        	
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if (isset($params['vendorId'])) {
         $vendorId = $params['vendorId'];
         $query = Vendorproducts::find()->where("vendorId = {$vendorId} and \tEndDate >= CURDATE()");
     } else {
         $query = Vendorproducts::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(['Saleid' => $this->Saleid]);
     $query->andFilterWhere(['like', 'productId', $this->productId])->andFilterWhere(['like', 'Brand', $this->Brand])->andFilterWhere(['like', 'Quantity', $this->Quantity])->andFilterWhere(['like', 'uom', $this->uom])->andFilterWhere(['like', 'AltQty', $this->AltQty])->andFilterWhere(['like', 'AltUom', $this->AltUom])->andFilterWhere(['like', 'UnitPrice', $this->UnitPrice])->andFilterWhere(['like', 'SalePrice', $this->SalePrice])->andFilterWhere(['like', 'PriceUnit', $this->PriceUnit])->andFilterWhere(['like', 'StartDate', $this->StartDate])->andFilterWhere(['like', 'EndDate', $this->EndDate])->andFilterWhere(['like', 'ReserveCount', $this->ReserveCount])->andFilterWhere(['like', 'SaleInd', $this->SaleInd])->andFilterWhere(['like', 'categoryName', $this->categoryName]);
     //print_r($dataProvider->getModels());exit();
     return $dataProvider;
 }
Ejemplo n.º 3
0
 public static function getTotalsalleitems($vendorId)
 {
     $totalsaleItems = Vendorproducts::find()->where("(StartDate > '2015-11-07' OR StartDate = '2015-11-07') AND vendorId={$vendorId} ")->count();
     return $totalsaleItems;
 }
Ejemplo n.º 4
0
 /**
  * Finds the Vendorproducts model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Vendorproducts the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Vendorproducts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 5
0
 public function actionUpload()
 {
     $this->layout = "@app/views/layouts/vendor_left";
     $model = new Vendorproducts();
     $model->scenario = 'fileup';
     if ($model->load(Yii::$app->request->post())) {
         $model->FileUpload = UploadedFile::getInstance($model, 'FileUpload');
         if ($model->FileUpload) {
             $time = time();
             $model->FileUpload->saveAs(realpath(Yii::$app->basePath) . '/csv/' . $time . '.' . $model->FileUpload->extension);
             $model->FileUpload = realpath(Yii::$app->basePath) . '/csv/' . $time . '.' . $model->FileUpload->extension;
             $handle = fopen($model->FileUpload, "r");
             $i = 0;
             while (($fileop = fgetcsv($handle, 1000, ",")) !== false) {
                 if ($i >= 1) {
                     $userInfo = Yii::$app->db->createCommand()->insert('saleitems', ['vendorId' => Yii::$app->user->id, 'productId' => $fileop[0], 'Brand' => $fileop[1], 'Quantity' => $fileop[2], 'uom' => $fileop[3], 'AltQty' => $fileop[4], 'AltUom' => $fileop[5], 'UnitPrice' => $fileop[6], 'SalePrice' => $fileop[7], 'PriceUnit' => $fileop[8], 'StartDate' => $fileop[9], 'EndDate' => $fileop[10], 'ReserveCount' => $fileop[11], 'SaleInd' => $fileop[12], 'categoryName' => $fileop[13]])->execute();
                 }
                 $i++;
             }
             $storeMain = new StoresMaster();
             $storeMain->vendorId = Yii::$app->user->id;
             $storeMain->totalSaleItems = $i - 1;
             $storeMain->offerType = $model->offerType;
             $storeMain->offer = $model->offer;
             $storeMain->offerStartDate = $model->offerStartDate;
             $storeMain->offerEndDate = $model->offerEndDate;
             $storeMain->save();
             Yii::$app->getSession()->setFlash('success', ' Your Products are successfully Updated ');
             return $this->redirect(['upload']);
             Yii::$app->getSession()->setFlash('success', ' Only Xlsheets are available ');
         }
     } else {
         return $this->render('vendor_view', ['model' => $model]);
     }
 }