<?php

namespace backend\modules\administrator\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\RiaLabD;

/**
 * RiaLabDSearch represents the model behind the search form of `common\models\RiaLabD`.
 */
class RiaLabDSearch extends RiaLabD
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['RiaHDocDate', 'RiaHDocID', 'LabID', 'LabName', 'SpecID', 'SpecName', 'SpecGrpName', 'LabID_Set', 'LabName_Set', 'SpecID_Set', 'SpecName_Set', 'SpecGrpName_Set', 'LabTID', 'LabTName', 'LabGrpID', 'LabGrpName', 'LabSubID', 'LabSubName', 'MetAbbr', 'LabUnit', 'LabNormal1', 'LabNormal2', 'RiaLDRsltAnal', 'RiaLDUserIDEntry', 'RiaLDUserDateEntry', 'RiaLDUserNameEntry', 'RiaLDUserIDReEntry', 'RiaLDUserNameReEntry', 'RiaLDUserDateReEntry', 'RiaLDUserIDAppr', 'RiaLDUserNameAppr', 'RiaLDUserDateAppr', 'RiaLHFinDocID', 'LabResultSts', 'LabAbbr', 'LabAbbr_Set', 'RiaLDRsltPre1Exp', 'RiaLDRsltPre2Exp', 'RiaLDGenFileFlag', 'RiaLDGenFileDate', 'MLABLabNo', 'VSLabSend', 'MessageCode', 'LabComment'], 'safe'],
            [['RiaLDSeq', 'RiaDSeq', 'LabSetFlag', 'RiaDTubNbr', 'RiaDInOut', 'RiaLDSelectFlag', 'RiaLDGetRiaFrmDFlag', 'RiaLDTestFlag', 'RiaLDReEntryFlag', 'RiaLDApprvFlag', 'LabResultFlag', 'LabSecretFlag', 'CustLabSpPriceFlag', 'LabDescFlag', 'LabAddResultFlag', 'RiaLDRsltSecretFlag', 'RiaLDRslt1Exp', 'RiaLDRslt2Exp', 'RiaHOnlineFlag'], 'integer'],
            [['RiaDUPrice', 'RiaDUPrice_Set', 'LabUprice'], 'number'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = RiaLabD::find();

        // add conditions that should always apply here

        $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;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'RiaHDocDate' => $this->RiaHDocDate,
            'RiaLDSeq' => $this->RiaLDSeq,
            'RiaDSeq' => $this->RiaDSeq,
            'LabSetFlag' => $this->LabSetFlag,
            'RiaDUPrice' => $this->RiaDUPrice,
            'RiaDUPrice_Set' => $this->RiaDUPrice_Set,
            'RiaDTubNbr' => $this->RiaDTubNbr,
            'RiaDInOut' => $this->RiaDInOut,
            'RiaLDSelectFlag' => $this->RiaLDSelectFlag,
            'RiaLDGetRiaFrmDFlag' => $this->RiaLDGetRiaFrmDFlag,
            'RiaLDTestFlag' => $this->RiaLDTestFlag,
            'RiaLDUserDateEntry' => $this->RiaLDUserDateEntry,
            'RiaLDReEntryFlag' => $this->RiaLDReEntryFlag,
            'RiaLDUserDateReEntry' => $this->RiaLDUserDateReEntry,
            'RiaLDApprvFlag' => $this->RiaLDApprvFlag,
            'RiaLDUserDateAppr' => $this->RiaLDUserDateAppr,
            'LabResultFlag' => $this->LabResultFlag,
            'LabSecretFlag' => $this->LabSecretFlag,
            'CustLabSpPriceFlag' => $this->CustLabSpPriceFlag,
            'LabUprice' => $this->LabUprice,
            'LabDescFlag' => $this->LabDescFlag,
            'LabAddResultFlag' => $this->LabAddResultFlag,
            'RiaLDRsltSecretFlag' => $this->RiaLDRsltSecretFlag,
            'RiaLDRslt1Exp' => $this->RiaLDRslt1Exp,
            'RiaLDRslt2Exp' => $this->RiaLDRslt2Exp,
            'RiaHOnlineFlag' => $this->RiaHOnlineFlag,
            'RiaLDGenFileDate' => $this->RiaLDGenFileDate,
        ]);

        $query->andFilterWhere(['like', 'RiaHDocID', $this->RiaHDocID])
            ->andFilterWhere(['like', 'LabID', $this->LabID])
            ->andFilterWhere(['like', 'LabName', $this->LabName])
            ->andFilterWhere(['like', 'SpecID', $this->SpecID])
            ->andFilterWhere(['like', 'SpecName', $this->SpecName])
            ->andFilterWhere(['like', 'SpecGrpName', $this->SpecGrpName])
            ->andFilterWhere(['like', 'LabID_Set', $this->LabID_Set])
            ->andFilterWhere(['like', 'LabName_Set', $this->LabName_Set])
            ->andFilterWhere(['like', 'SpecID_Set', $this->SpecID_Set])
            ->andFilterWhere(['like', 'SpecName_Set', $this->SpecName_Set])
            ->andFilterWhere(['like', 'SpecGrpName_Set', $this->SpecGrpName_Set])
            ->andFilterWhere(['like', 'LabTID', $this->LabTID])
            ->andFilterWhere(['like', 'LabTName', $this->LabTName])
            ->andFilterWhere(['like', 'LabGrpID', $this->LabGrpID])
            ->andFilterWhere(['like', 'LabGrpName', $this->LabGrpName])
            ->andFilterWhere(['like', 'LabSubID', $this->LabSubID])
            ->andFilterWhere(['like', 'LabSubName', $this->LabSubName])
            ->andFilterWhere(['like', 'MetAbbr', $this->MetAbbr])
            ->andFilterWhere(['like', 'LabUnit', $this->LabUnit])
            ->andFilterWhere(['like', 'LabNormal1', $this->LabNormal1])
            ->andFilterWhere(['like', 'LabNormal2', $this->LabNormal2])
            ->andFilterWhere(['like', 'RiaLDRsltAnal', $this->RiaLDRsltAnal])
            ->andFilterWhere(['like', 'RiaLDUserIDEntry', $this->RiaLDUserIDEntry])
            ->andFilterWhere(['like', 'RiaLDUserNameEntry', $this->RiaLDUserNameEntry])
            ->andFilterWhere(['like', 'RiaLDUserIDReEntry', $this->RiaLDUserIDReEntry])
            ->andFilterWhere(['like', 'RiaLDUserNameReEntry', $this->RiaLDUserNameReEntry])
            ->andFilterWhere(['like', 'RiaLDUserIDAppr', $this->RiaLDUserIDAppr])
            ->andFilterWhere(['like', 'RiaLDUserNameAppr', $this->RiaLDUserNameAppr])
            ->andFilterWhere(['like', 'RiaLHFinDocID', $this->RiaLHFinDocID])
            ->andFilterWhere(['like', 'LabResultSts', $this->LabResultSts])
            ->andFilterWhere(['like', 'LabAbbr', $this->LabAbbr])
            ->andFilterWhere(['like', 'LabAbbr_Set', $this->LabAbbr_Set])
            ->andFilterWhere(['like', 'RiaLDRsltPre1Exp', $this->RiaLDRsltPre1Exp])
            ->andFilterWhere(['like', 'RiaLDRsltPre2Exp', $this->RiaLDRsltPre2Exp])
            ->andFilterWhere(['like', 'RiaLDGenFileFlag', $this->RiaLDGenFileFlag])
            ->andFilterWhere(['like', 'MLABLabNo', $this->MLABLabNo])
            ->andFilterWhere(['like', 'VSLabSend', $this->VSLabSend])
            ->andFilterWhere(['like', 'MessageCode', $this->MessageCode])
            ->andFilterWhere(['like', 'LabComment', $this->LabComment]);

        return $dataProvider;
    }
}
