/
EmployeesController.php
79 lines (68 loc) · 1.86 KB
/
EmployeesController.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
<?php
class EmployeesController extends BackEndController
{
public $icon_class = 'glyphicon glyphicon-user';
public function actionTes()
{
$model = $this->loadModel(1);
$this->renderPartial('/employees/_formAjax',array('employee'=>$model));
}
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['MastersEmployees']))
{
$model->attributes=$_POST['MastersEmployees'];
if($model->save())
$this->redirect(array('index'));
}
$this->render('update',array(
'model'=>$model,
));
}
public function actionIndex()
{
$this->render('view',array('model'=>$this->loadModel(getUser()->employee_id)));
}
public function loadModel($id)
{
$model = MastersEmployees::model()->findByPk($id);
if($model===null) throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param MastersEmployees $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='masters-employees-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
public function actionDynamicStatuses($id)
{
$c = new CDbCriteria();
$c->compare('family_group_id', $id);
$model = ReferenceFamilyStatuses::model()->findAll($c);
echo CHtml::tag('option', array('value'=>''), '', true);
foreach($model as $status)
{
echo CHtml::tag('option', array('value'=>$status->id), CHtml::encode($status->name), true);
}
}
public function actionAjaxgetdata(){
$model = $this->loadModel($_POST['id']);
$this->renderPartial('/employees/_formAjax',array('employee'=>$model));
}
public function actionAjaxupdate($id)
{
echo "<pre>";
print_r($_POST);
echo "</pre>";
}
}