-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathempinfosearch.php
137 lines (120 loc) · 5.76 KB
/
empinfosearch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
namespace common\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\EmpInfo;
/**
* EmpInfoSearch represents the model behind the search form about `common\models\EmpInfo`.
*/
class EmpInfoSearch extends EmpInfo
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['emp_id', 'emp_designation_id', 'emp_type_id', 'emp_branch_id', 'emp_passing_year', 'created_by', 'updated_by'], 'integer'],
[['emp_name', 'emp_father_name', 'emp_cnic', 'emp_contact_no', 'emp_perm_address', 'emp_temp_address', 'emp_marital_status', 'emp_gender', 'emp_photo', 'group_by', 'emp_email', 'emp_qualification', 'emp_institute_name', 'degree_scan_copy','emp_cv', 'created_at', 'updated_at'], 'safe'],
[['emp_salary'], '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)
{
if(Yii::$app->user->identity->user_type == 'Superadmin'){
$query = EmpInfo::find();
$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([
'emp_id' => $this->emp_id,
'emp_designation_id' => $this->emp_designation_id,
'emp_type_id' => $this->emp_type_id,
'emp_branch_id' => $this->emp_branch_id,
'emp_passing_year' => $this->emp_passing_year,
'emp_salary' => $this->emp_salary,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'created_by' => $this->created_by,
'updated_by' => $this->updated_by,
]);
$query->andFilterWhere(['like', 'emp_name', $this->emp_name])
->andFilterWhere(['like', 'emp_father_name', $this->emp_father_name])
->andFilterWhere(['like', 'emp_cnic', $this->emp_cnic])
->andFilterWhere(['like', 'emp_contact_no', $this->emp_contact_no])
->andFilterWhere(['like', 'emp_perm_address', $this->emp_perm_address])
->andFilterWhere(['like', 'emp_temp_address', $this->emp_temp_address])
->andFilterWhere(['like', 'emp_marital_status', $this->emp_marital_status])
->andFilterWhere(['like', 'emp_gender', $this->emp_gender])
->andFilterWhere(['like', 'emp_photo', $this->emp_photo])
->andFilterWhere(['like', 'group_by', $this->group_by])
->andFilterWhere(['like', 'emp_email', $this->emp_email])
->andFilterWhere(['like', 'emp_qualification', $this->emp_qualification])
->andFilterWhere(['like', 'emp_institute_name', $this->emp_institute_name])
->andFilterWhere(['like', 'degree_scan_copy', $this->degree_scan_copy])
->andFilterWhere(['like', 'emp_cv', $this->emp_cv]);
return $dataProvider;
} else {
$branch_id = Yii::$app->user->identity->branch_id;
$query = EmpInfo::find()->where(['delete_status' => 1 , 'emp_branch_id'=> $branch_id]);
$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([
'emp_id' => $this->emp_id,
'emp_designation_id' => $this->emp_designation_id,
'emp_type_id' => $this->emp_type_id,
'emp_branch_id' => $this->emp_branch_id,
'emp_passing_year' => $this->emp_passing_year,
'emp_salary' => $this->emp_salary,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'created_by' => $this->created_by,
'updated_by' => $this->updated_by,
]);
$query->andFilterWhere(['like', 'emp_name', $this->emp_name])
->andFilterWhere(['like', 'emp_father_name', $this->emp_father_name])
->andFilterWhere(['like', 'emp_cnic', $this->emp_cnic])
->andFilterWhere(['like', 'emp_contact_no', $this->emp_contact_no])
->andFilterWhere(['like', 'emp_perm_address', $this->emp_perm_address])
->andFilterWhere(['like', 'emp_temp_address', $this->emp_temp_address])
->andFilterWhere(['like', 'emp_marital_status', $this->emp_marital_status])
->andFilterWhere(['like', 'emp_gender', $this->emp_gender])
->andFilterWhere(['like', 'emp_photo', $this->emp_photo])
->andFilterWhere(['like', 'group_by', $this->group_by])
->andFilterWhere(['like', 'emp_email', $this->emp_email])
->andFilterWhere(['like', 'emp_qualification', $this->emp_qualification])
->andFilterWhere(['like', 'emp_institute_name', $this->emp_institute_name])
->andFilterWhere(['like', 'emp_cv', $this->emp_cv]);
return $dataProvider;
}
}
}