Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comstock::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 10]]);
     if (isset($_GET['ComstockSearch']) && !($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     /*
      $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(['id' => $this->id, 'eqmType' => $this->eqmType, 'status' => $this->status, 'addToSystem' => $this->addToSystem, 'warranty' => $this->warranty, 'dealer' => $this->dealer, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'cat' => $this->cat, 'location' => $this->location]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'serial', $this->serial])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'eqmnum', $this->eqmnum])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'amount', $this->amount])->andFilterWhere(['like', 'budget', $this->budget])->andFilterWhere(['like', 'howtobuy', $this->howtobuy])->andFilterWhere(['like', 'invnum', $this->invnum]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function actionDeletefileAjax()
 {
     $model = Uploads::findOne(Yii::$app->request->post('key'));
     if ($model !== NULL) {
         $filename = Comstock::getUploadPath() . $model->ref . '/' . $model->real_filename;
         $thumbnail = Comstock::getUploadPath() . $model->ref . '/thumbnail/' . $model->real_filename;
         if ($model->delete()) {
             @unlink($filename);
             @unlink($thumbnail);
             echo json_encode(['success' => true]);
         } else {
             echo json_encode(['success' => false]);
         }
     } else {
         echo json_encode(['success' => false]);
     }
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getComstocks()
 {
     return $this->hasMany(Comstock::className(), ['eqmType' => 'id']);
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getComstocks()
 {
     return $this->hasMany(Comstock::className(), ['warranty' => 'id']);
 }
Ejemplo n.º 5
0
 private function removeUploadDir($dir)
 {
     BaseFileHelper::removeDirectory(Comstock::getUploadPath() . $dir);
 }