| Current Path : /var/www/html/ekursus/frontend/models/ |
| Current File : /var/www/html/ekursus/frontend/models/TraineeSearch.php |
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\Trainee;
use backend\models\contractor\Contractor;
use backend\models\timetable\Timetable;
use backend\models\Application;
use mPDF;
/**
* TraineeSearch represents the model behind the search form of `backend\models\Trainee`.
*/
class TraineeSearch extends Trainee
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'kod_permohonan', 'kod_jadual'], 'integer'],
[['no_kp', 'nama_peserta', 'kod_kehadiran', 'borang_penilaian', 'surat_rujukan', 'surat_amaran', 'tkh_surat', 'no_tel', 'jantina', 'jawatan', '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 = Trainee::find()->where(['kod_jadual' => $_GET['kod_jadual']]);
// 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_permohonan' => $this->kod_permohonan,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function search1($params)
{
// dd($_GET['kod_jadual']);
$query = Trainee::find()->select(['{{trainee}}.*'])
->innerJoin('application', 'application.id=trainee.kod_permohonan')
->innerJoin('timetable', 'timetable.id=application.kod_jadual')
->andWhere(['timetable.id' => $_GET['kod_jadual']]);
// $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,
]);
$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_permohonan' => $this->kod_permohonan,
'kod_jadual' => $this->kod_jadual,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function searchExcel($params)
{
$query = 'SELECT t.nama_peserta, t.no_kp, t.kod_kehadiran, c.nama_sykt, c.no_spkk
FROM trainee t LEFT JOIN application a ON a.id=t.kod_permohonan
AND a.kod_jadual=t.kod_jadual
LEFT JOIN contractor c ON c.no_spkk=a.no_spkk
WHERE t.kod_jadual='.$_GET['kod_jadual'];
// $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,
]);
$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([
't.nama_peserta' => $this->nama_peserta,
// 'kod_permohonan' => $this->kod_permohonan,
// 'kod_jadual' => $this->kod_jadual,
// 'tkh_surat' => $this->tkh_surat,
// 'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function search2($params)
{
// dd($_GET['kod_jadual']);
$query = Trainee::find()->select(['{{trainee}}.*'])
->innerJoin('application', 'application.id=trainee.kod_permohonan')
->innerJoin('timetable', 'timetable.id=application.kod_jadual')
->andWhere(['timetable.id' => $_GET['kod_jadual']]);
// $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,
'pagination' => [ 'pageSize' => 500 ],
]);
$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_permohonan' => $this->kod_permohonan,
'kod_jadual' => $this->kod_jadual,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function search3($params)
{
// dd($_GET['kod_jadual']);
// $query = Trainee::find()->select(['{{trainee}}.*'])
// ->innerJoin('application', 'application.id=trainee.kod_permohonan')
// // ->innerJoin('timetable', 'timetable.id=application.kod_jadual')
// ->andWhere(['application.no_spkk' => Yii::$app->user->identity->username]);
$query = Trainee::find()->select(['trainee.*'])
->innerJoin('application', 'application.id=trainee.kod_permohonan')
->andWhere(['application.no_spkk' => Yii::$app->user->identity->username]);
// 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_permohonan' => $this->kod_permohonan,
'kod_jadual' => $this->kod_jadual,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function search4($params)
{
// dd($_GET['kod_jadual']);
$query = Trainee::find()->select(['{{trainee}}.*'])
->innerJoin('application', 'application.id=trainee.kod_permohonan')
->innerJoin('timetable', 'timetable.id=application.kod_jadual')
->innerJoin('dmg_user', 'dmg_user.username=application.no_spkk')
->andWhere("application.status_mohon!='P'")
->andWhere("application.status_mohon!='D'")
->andWhere(['application.no_spkk' => Yii::$app->user->identity->username]);
// 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_permohonan' => $this->kod_permohonan,
'kod_jadual' => $this->kod_jadual,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function search5($params)
{
// dd($_GET['kod_jadual']);
$query = Trainee::find()->select(['{{trainee}}.*'])
->innerJoin('application', 'application.id=trainee.kod_permohonan')
->innerJoin('timetable', 'timetable.id=application.kod_jadual')
->innerJoin('dmg_user', 'dmg_user.username=application.no_spkk')
->andWhere("application.status_mohon!='L'")
->andWhere("application.status_mohon!='G'")
->andWhere(['application.no_spkk' => Yii::$app->user->identity->username]);
// 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_permohonan' => $this->kod_permohonan,
'kod_jadual' => $this->kod_jadual,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function search6($params)
{
// dd($_GET['kod_jadual']);
$query = Trainee::find()->select(['{{trainee}}.*'])
->innerJoin('application', 'application.id=trainee.kod_permohonan')
->innerJoin('timetable', 'timetable.id=application.kod_jadual')
->innerJoin('dmg_user', 'dmg_user.username=application.no_spkk')
->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_permohonan' => $this->kod_permohonan,
'kod_jadual' => $this->kod_jadual,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
public function search7($params)
{
// dd($_GET['kod_jadual']);
$query = Trainee::find()->select(['{{trainee}}.*'])
->innerJoin('application', 'application.id=trainee.kod_permohonan')
->innerJoin('timetable', 'timetable.id=application.kod_jadual')
->innerJoin('dmg_user', 'dmg_user.username=application.no_spkk')
->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_permohonan' => $this->kod_permohonan,
'kod_jadual' => $this->kod_jadual,
'tkh_surat' => $this->tkh_surat,
'tkh_mohon' => $this->tkh_mohon,
]);
$query->andFilterWhere(['like', 'no_kp', $this->no_kp])
->andFilterWhere(['like', 'nama_peserta', $this->nama_peserta])
->andFilterWhere(['like', 'kod_kehadiran', $this->kod_kehadiran])
->andFilterWhere(['like', 'borang_penilaian', $this->borang_penilaian])
->andFilterWhere(['like', 'surat_rujukan', $this->surat_rujukan])
->andFilterWhere(['like', 'surat_amaran', $this->surat_amaran])
->andFilterWhere(['like', 'no_tel', $this->no_tel])
->andFilterWhere(['like', 'jantina', $this->jantina])
->andFilterWhere(['like', 'jawatan', $this->jawatan]);
return $dataProvider;
}
}