Esempio n. 1
0
 public function actionView()
 {
     $this->layout = 'main.php';
     $models = Collection::find()->all();
     $this->view->params['controlNavItems'] = [['label' => 'Редактировать', 'url' => ['/collection/admin']]];
     return $this->render('view', ['models' => $models]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Collection::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;
     }
     if (isset($this->time) && $this->time != '') {
         $date_explode = explode(" to ", $this->time);
         $date1 = trim($date_explode[0]);
         $date2 = trim($date_explode[1]);
         $date2 = date("Y-m-d", strtotime("+1 day", strtotime($date2)));
         $query->andFilterWhere(['between', 'collection.time', $date1, $date2]);
     }
     $query->joinwith('customer');
     $query->joinwith('account');
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'customer.name', $this->customer_id]);
     $query->andFilterWhere(['like', 'account.name', $this->account_id]);
     $query->andFilterWhere(['like', 'money', $this->money]);
     return $dataProvider;
 }
Esempio n. 3
0
 public static function calculateSum()
 {
     /** @var Collection $lastSuccessCollection */
     $lastSuccessCollection = Collection::find()->where(['is_fulfilled' => true])->orderBy(['date' => SORT_DESC])->limit(1)->one();
     if (is_null($lastSuccessCollection)) {
         return Log::calculateSum();
     }
     return Log::calculateSum($lastSuccessCollection->date);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Collection::find()->orderBy(['id' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 200]]);
     $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(['id' => $this->id, 'is_fulfilled' => $this->is_fulfilled, 'sum' => $this->sum, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'login', $this->login]);
     return $dataProvider;
 }