/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Receipt::find(); $query->joinWith(['estimate']); $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(['receipt.id' => $this->id, 'receipt.estimate_id' => $this->estimate_id, 'receipt.status' => $this->status, 'receipt.created_date' => $this->created_date, 'receipt.type' => $this->type, 'receipt.iva' => $this->iva, 'estimate.client_id' => $this->client_id]); $query->andFilterWhere(['like', 'number', $this->number]); /** * Convert the to dates to mysql format. * Leave them as null so they are not used * by ActiveQuery::andFilterWhere(). */ $fromDate = null; $toDate = null; if ($this->from_date) { $this->from_date = DateConverter::convert($this->from_date); } if ($this->to_date) { $this->to_date = DateConverter::convert($this->to_date); } $query->andFilterWhere(['>=', 'created_date', $this->from_date]); $query->andFilterWhere(['<=', 'created_date', $this->to_date]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EstimateEntry::find(); $query->innerJoinWith(['product']); $query->innerJoinWith(['estimate.receipt']); $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(['product_id' => $this->product_id, 'estimate.client_id' => $this->client_id]); $query->andFilterWhere(['like', 'product.bukmark_code', $this->bukmark_code]); /** * Convert the to dates to mysql format. * Leave them as null so they are not used * by ActiveQuery::andFilterWhere(). */ $fromDate = null; $toDate = null; if ($this->from_date) { $this->from_date = DateConverter::convert($this->from_date); } if ($this->to_date) { $this->to_date = DateConverter::convert($this->to_date); } $query->andFilterWhere(['>=', 'receipt.created_date', $this->from_date]); $query->andFilterWhere(['<=', 'receipt.created_date', $this->to_date]); // Only checked entries are used $query->andFilterWhere(['checked' => true]); return $dataProvider; }
/** * Format birthdate * @inheritdoc */ public function beforeSave($insert) { $this->birthdate = DateConverter::convert($this->birthdate); return parent::beforeSave($insert); }
/** * @inheritdoc */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->isNewRecord) { $this->us = Currency::getUsToArsWithMargin(); $this->user_id = Yii::$app->user->id; } $this->request_date = DateConverter::convert($this->request_date); $this->sent_date = DateConverter::convert($this->sent_date); if (!$this->sent_date && $this->status == self::STATUS_SENT) { $this->sent_date = date('Y-m-d'); } return true; } else { return false; } }