Your IP : 216.73.216.79


Current Path : /var/www/html/ekursus/backend/models/
Upload File :
Current File : /var/www/html/ekursus/backend/models/ApplicationSearch.php

<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\Application;

/**
 * ApplicationSearch represents the model behind the search form of `backend\models\Application`.
 */
class ApplicationSearch extends Application
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['id', 'kod_jadual', 'no_siri_sijil'], 'integer'],
            [['no_spkk', 'perakuan', 'status_mohon', 'sebab', 'kedatangan_dok', 'tkh_mohon'], 'safe'],
        ];
    }

    /**
     * {@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 = Application::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([
            'id' => $this->id,
            'kod_jadual' => $this->kod_jadual,
            'no_siri_sijil' => $this->no_siri_sijil,
            'tkh_mohon' => $this->tkh_mohon,
        ]);

        $query->andFilterWhere(['like', 'no_spkk', $this->no_spkk])
            ->andFilterWhere(['like', 'perakuan', $this->perakuan])
            ->andFilterWhere(['like', 'status_mohon', $this->status_mohon])
            ->andFilterWhere(['like', 'sebab', $this->sebab])
            ->andFilterWhere(['like', 'kedatangan_dok', $this->kedatangan_dok]);

        return $dataProvider;
    }


    public function search1($params)
    {
        // dd($_GET['kod_jadual']);
        $query = Application::find()->select(['{{application}}.*'])
                    ->joinWith('timetable')
                    ->where(['timetable.id' => $_GET['kod_jadual']])
                    ->distinct();
        // $query = "SELECT a.kod_jadual, a.no_spkk, a.status_mohon, a.tkh_mohon FROM application a JOIN timetable b ON b.id=a.kod_jadual AND b.id=".$_GET['kod_jadual'];

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> ['defaultOrder' => ['status_mohon' => SORT_DESC]],
        ]);

        $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([
            'id' => $this->id,
            'kod_jadual' => $this->kod_jadual,
            'no_siri_sijil' => $this->no_siri_sijil,
            'tkh_mohon' => $this->tkh_mohon,
        ]);

        $query->andFilterWhere(['like', 'no_spkk', $this->no_spkk])
            ->andFilterWhere(['like', 'perakuan', $this->perakuan])
            ->andFilterWhere(['like', 'status_mohon', $this->status_mohon])
            ->andFilterWhere(['like', 'sebab', $this->sebab])
            ->andFilterWhere(['like', 'kedatangan_dok', $this->kedatangan_dok]);

        return $dataProvider;
    }


        public function search2($params)
    {
      //  $query = Application::find();
        // dd($_GET['id']);
        $query = Application::find()->select(['{{application}}.*'])
                    ->joinWith('contractor')
                    ->where(['application.no_spkk' => $_GET['no_spkk']]);

        // 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([
            'id' => $this->id,
            'kod_jadual' => $this->kod_jadual,
            'no_siri_sijil' => $this->no_siri_sijil,
            'tkh_mohon' => $this->tkh_mohon,
            'no_spkk' => $this->no_spkk,
        ]);

        $query->andFilterWhere(['like', 'perakuan', $this->perakuan])
            ->andFilterWhere(['like', 'status_mohon', $this->status_mohon])
            ->andFilterWhere(['like', 'sebab', $this->sebab])
            ->andFilterWhere(['like', 'kedatangan_dok', $this->kedatangan_dok]);

        return $dataProvider;
    }

            public function search3($params)
    {
      //  $query = Application::find();
        // dd($_GET['id']);
        $query = Application::find()->select(['{{application}}.*'])
                    ->innerJoin('contractor', 'contractor.no_spkk=application.no_spkk')
                    ->innerJoin('trainee', 'application.id=trainee.kod_permohonan')
                    ->innerJoin('timetable', 'application.kod_jadual=timetable.id')
                    ->andWhere("application.status_mohon!='P'")
                    ->andWhere("application.status_mohon!='D'")
                    ->andWhere(['application.no_spkk' => $_GET['no_spkk']]);

        // 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([
            'id' => $this->id,
            'kod_jadual' => $this->kod_jadual,
            'no_siri_sijil' => $this->no_siri_sijil,
            'tkh_mohon' => $this->tkh_mohon,
            'no_spkk' => $this->no_spkk,
        ]);

        $query->andFilterWhere(['like', 'perakuan', $this->perakuan])
            ->andFilterWhere(['like', 'status_mohon', $this->status_mohon])
            ->andFilterWhere(['like', 'sebab', $this->sebab])
            ->andFilterWhere(['like', 'kedatangan_dok', $this->kedatangan_dok]);

        return $dataProvider;
    }
}