public function searchKPI($params, $pageSize = 20) { $query = DeliveryNote::find()->where(['delivery_note.state' => 'done']); /*$dataProvider->sort->attributes['saleOrder.date_order'] = [ 'asc' => ['saleOrder.date_order' => SORT_ASC], 'desc' => ['saleOrder.date_order' => SORT_DESC], ];*/ $query->joinWith(['partner', 'saleOrder']); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } if ($this->year_tanggal != null) { $query->andWhere(['and', 'EXTRACT(YEAR FROM delivery_note.tanggal) = ' . $this->year_tanggal]); } if ($this->month_tanggal != null) { $query->andWhere(['and', 'EXTRACT(MONTH FROM delivery_note.tanggal) = ' . $this->month_tanggal]); } if ($this->year_po != null) { $query->andWhere(['and', 'EXTRACT(YEAR FROM sale_order.date_order) = ' . $this->year_po]); } if ($this->month_po != null) { $query->andWhere(['and', 'EXTRACT(MONTH FROM sale_order.date_order) = ' . $this->month_po]); } if ($this->partner_id != null) { $query->andFilterWhere(['ilike', 'res_partner.display_name', $this->partner_id]); } /*if($this->name != null) { $query->andFilterWhere(['ilike', 'delivery_note.name', $this->name]); }*/ return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getNote() { return $this->hasOne(DeliveryNote::className(), ['id' => 'note_id']); }
/** * Finds the DeliveryNote model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return DeliveryNote the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DeliveryNote::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getDeliveryNotes() { return $this->hasMany(DeliveryNote::className(), ['work_order_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getDeliveryNotes() { return $this->hasMany(DeliveryNote::className(), ['prepare_id' => 'id']); }
/** * @return Delivery Note */ public function getDeliveryNotes() { return $this->hasMany(DeliveryNote::className(), ['prepare_id' => 'id'])->via('orderPreparations'); }