<?php if ($isform) { ?> <div class="row"> <a href="#family_id#create#0" class="btn btn-primary"><?php echo at('Add Family'); ?> </a> </div> <?php } ?> <?php $this->widget('DTGridView', array('id' => 'masters-employee-familys-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeFamilys::model()->searchByEmployee($model->id), 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'status_id', 'header' => at('Status'), 'value' => '$data->viewStatus()'), array('name' => 'name', 'header' => at('Name')), array('name' => 'gender', 'header' => at('Gender'), 'value' => 'MyHelper::viewGender($data->gender)'), array('name' => 'education_level', 'header' => at('Education')), array('name' => 'job_position', 'header' => at('Job')), array('class' => 'CButtonColumn', 'htmlOptions' => array('style' => 'width: 80px'), 'buttons' => array('view' => array('url' => '"#family_id#view#".$data->id'), 'update' => array('url' => '"#family_id#update#".$data->id'), 'delete' => array('url' => 'createUrl("employee/familys/delete", array("id"=>$data->id))')))))); ?> <!-- Modal --> <div class="modal fade" id="familysModal" tabindex="-1" role="dialog" aria-labelledby="familysModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="familysModalLabel">Family</h4> </div> <div class="modal-body" id="familysModalBody"> <!-- tampilan dari ajax --> </div> </div> </div>
<?php $urlCreate = Yii::app()->createUrl('employee/familys/create'); ?> <?php $this->widget('DTGridView', array('id' => 'masters-employee-familys-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeFamilys::model()->searchByEmployee($model->id), 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'status_id', 'header' => at('Status'), 'value' => '$data->viewStatus()'), array('name' => 'name', 'header' => at('Name')), array('name' => 'gender', 'header' => at('Gender'), 'value' => 'MyHelper::viewGender($data->gender)'), array('name' => 'education_level', 'header' => at('Education')), array('name' => 'job_position', 'header' => at('Job'))))); ?>
public function actionAjaxcreate($id) { $model = new MastersEmployeeFamilys(); if ($id != '') { $model = MastersEmployeeFamilys::model()->findByPk($id); } $model->employee_id = $_POST['employee_id']; $model->group_id = $_POST['group_id']; $model->status_id = $_POST['status_id']; $model->family_no = $_POST['family_no']; $model->name = $_POST['name']; $model->gender = $_POST['gender']; $model->address_id = $_POST['address_id']; $model->birthplace_country_id = $_POST['birthplace_country_id']; $model->birthplace_state_id = $_POST['birthplace_state_id']; $model->birthplace_city_id = $_POST['birthplace_city_id']; $model->birthplace_district_id = $_POST['birthplace_district_id']; $model->poscode = $_POST['poscode']; $model->birthdate = $_POST['birthdate']; $model->age = $_POST['age']; $model->mobile = $_POST['mobile']; $model->phone = $_POST['phone']; $model->education_level = $_POST['education_level']; $model->job = $_POST['job']; $model->job_position = $_POST['job_position']; if ($model->save()) { $_POST['success'] = 1; } else { $_POST['success'] = 0; } $_POST['id'] = $id; $_POST['error_employee_id'] = ''; $_POST['error_group_id'] = ''; $_POST['error_status_id'] = ''; $_POST['error_family_no'] = ''; $_POST['error_name'] = ''; $_POST['error_gender'] = ''; $_POST['error_address_id'] = ''; $_POST['error_birthplace_country_id'] = ''; $_POST['error_birthplace_state_id'] = ''; $_POST['error_birthplace_city_id'] = ''; $_POST['error_birthplace_district_id'] = ''; $_POST['error_poscode'] = ''; $_POST['error_birthdate'] = ''; $_POST['error_age'] = ''; $_POST['error_mobile'] = ''; $_POST['error_phone'] = ''; $_POST['error_education_level'] = ''; $_POST['error_job'] = ''; $_POST['error_job_position'] = ''; if (isset($model->errors['employee_id'][0])) { $_POST['error_employee_id'] = $model->errors['employee_id'][0]; } if (isset($model->errors['group_id'][0])) { $_POST['error_group_id'] = $model->errors['group_id'][0]; } if (isset($model->errors['status_id'][0])) { $_POST['error_status_id'] = $model->errors['status_id'][0]; } if (isset($model->errors['family_no'][0])) { $_POST['error_family_no'] = $model->errors['family_no'][0]; } if (isset($model->errors['name'][0])) { $_POST['error_name'] = $model->errors['name'][0]; } if (isset($model->errors['gender'][0])) { $_POST['error_gender'] = $model->errors['gender'][0]; } if (isset($model->errors['address_id'][0])) { $_POST['address_id'] = $model->errors['address_id'][0]; } if (isset($model->errors['birthplace_country_id'][0])) { $_POST['error_birthplace_country_id'] = $model->errors['birthplace_country_id'][0]; } if (isset($model->errors['birthplace_state_id'][0])) { $_POST['error_birthplace_state_id'] = $model->errors['birthplace_state_id'][0]; } if (isset($model->errors['birthplace_city_id'][0])) { $_POST['error_birthplace_city_id'] = $model->errors['birthplace_city_id'][0]; } if (isset($model->errors['birthplace_district_id'][0])) { $_POST['error_birthplace_district_id'] = $model->errors['birthplace_district_id'][0]; } if (isset($model->errors['poscode'][0])) { $_POST['error_poscode'] = $model->errors['poscode'][0]; } if (isset($model->errors['birthdate'][0])) { $_POST['error_birthdate'] = $model->errors['birthdate'][0]; } if (isset($model->errors['age'][0])) { $_POST['error_age'] = $model->errors['age'][0]; } if (isset($model->errors['mobile'][0])) { $_POST['error_mobile'] = $model->errors['mobile'][0]; } if (isset($model->errors['phone'][0])) { $_POST['error_phone'] = $model->errors['phone'][0]; } if (isset($model->errors['education_level'][0])) { $_POST['error_education_level'] = $model->errors['education_level'][0]; } if (isset($model->errors['job'][0])) { $_POST['error_job'] = $model->errors['job'][0]; } if (isset($model->errors['job_position'][0])) { $_POST['job_position'] = $model->errors['job_position'][0]; } echo json_encode($_POST); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return MastersEmployeeFamilys the loaded model * @throws CHttpException */ public function loadModel($id) { $c = new CDbCriteria(); $c->compare('id', $id); $c->compare('employee_id', getUser()->id); $model = MastersEmployeeFamilys::model()->find($c); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }