public function actionAjaxcreate($id) { $model = new MastersEmployeeHistoryEducations(); if ($id != '') { $model = MastersEmployeeHistoryEducations::model()->findByPk($id); } $model->employee_id = $_POST['employee_id']; $model->education_id = $_POST['education_id']; $model->school = $_POST['school']; $model->department = $_POST['department']; $model->major = $_POST['major']; $model->certificate_year = $_POST['certificate_year']; $model->notes = $_POST['notes']; $model->address_street1 = $_POST['address_street1']; $model->address_street2 = $_POST['address_street2']; $model->address_country_id = $_POST['address_country_id']; $model->address_state_id = $_POST['address_state_id']; $model->address_city_id = $_POST['address_city_id']; $model->address_poscode = $_POST['address_poscode']; if ($model->save()) { $_POST['success'] = 1; } else { $_POST['success'] = 0; } $_POST['id'] = $id; $_POST['error_employee_id'] = ''; $_POST['error_education_id'] = ''; $_POST['error_school'] = ''; $_POST['error_department'] = ''; $_POST['error_major'] = ''; $_POST['error_certificate_year'] = ''; $_POST['error_notes'] = ''; $_POST['error_address_street1'] = ''; $_POST['error_address_street2'] = ''; $_POST['error_address_country_id'] = ''; $_POST['error_address_state_id'] = ''; $_POST['error_address_city_id'] = ''; $_POST['error_address_poscode'] = ''; if (isset($model->errors['employee_id'][0])) { $_POST['error_employee_id'] = $model->errors['employee_id'][0]; } if (isset($model->errors['education_id'][0])) { $_POST['error_education_id'] = $model->errors['education_id'][0]; } if (isset($model->errors['school'][0])) { $_POST['error_school'] = $model->errors['school'][0]; } if (isset($model->errors['department'][0])) { $_POST['error_department'] = $model->errors['department'][0]; } if (isset($model->errors['major'][0])) { $_POST['error_major'] = $model->errors['major'][0]; } if (isset($model->errors['certificate_year'][0])) { $_POST['error_certificate_year'] = $model->errors['certificate_year'][0]; } if (isset($model->errors['notes'][0])) { $_POST['error_notes'] = $model->errors['notes'][0]; } if (isset($model->errors['address_street1'][0])) { $_POST['error_address_street1'] = $model->errors['address_street1'][0]; } if (isset($model->errors['address_street2'][0])) { $_POST['error_address_street2'] = $model->errors['address_street2'][0]; } if (isset($model->errors['address_country_id'][0])) { $_POST['error_address_country_id'] = $model->errors['address_country_id'][0]; } if (isset($model->errors['address_state_id'][0])) { $_POST['error_address_state_id'] = $model->errors['address_state_id'][0]; } if (isset($model->errors['address_city_id'][0])) { $_POST['error_address_city_id'] = $model->errors['address_city_id'][0]; } if (isset($model->errors['address_poscode'][0])) { $_POST['error_address_poscode'] = $model->errors['address_poscode'][0]; } echo json_encode($_POST); }
<?php $this->widget('CGridView', array('id' => 'masters-employee-educations-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeHistoryEducations::model()->searchByEmployee($model->id), 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'education_id', 'header' => at('Level'), 'value' => '$data->education->short'), array('name' => 'school', 'header' => at('School')), array('name' => 'department', 'header' => at('Department')), array('name' => 'certificate_year', 'header' => at('Cert Year')))));
/** * 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 MastersEmployeeHistoryEducations the loaded model * @throws CHttpException */ public function loadModel($id) { $c = new CDbCriteria(); $c->compare('id', $id); $c->compare('employee_id', getUser()->id); $model = MastersEmployeeHistoryEducations::model()->find($c); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php echo CHtml::activeTextField($model, 'major', array('size' => 60, 'maxlength' => 100, 'class' => 'validate[required] form-control')); ?> <?php echo CHtml::error($model, 'major'); ?> </div> </div> <div class="form-group"> <?php echo CHtml::activeLabelEx($model, 'certificate_year', array('class' => $label_class)); ?> <div class="col-md-6 col-xs-12"> <?php echo CHtml::activeDropDownList($model, 'certificate_year', MastersEmployeeHistoryEducations::model()->getCertYears(), array('data-placeholder' => at('Please select one...'), 'prompt' => '', 'class' => 'validate[required] form-control select')); ?> <?php echo CHtml::error($model, 'certificate_year'); ?> </div> </div> <div class="form-group"> <?php echo CHtml::activeLabelEx($model, 'notes', array('class' => $label_class)); ?> <div class="col-md-6 col-xs-12"> <?php echo CHtml::activeTextField($model, 'notes', array('size' => 60, 'maxlength' => 100, 'class' => 'validate[required] form-control')); ?>
<?php if ($isform) { ?> <div class="row"> <a href="#education_id#create#0" class="btn btn-primary"><?php echo at('Add Education'); ?> </a> </div> <?php } ?> <?php $this->widget('CGridView', array('id' => 'masters-employee-educations-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeHistoryEducations::model()->searchByEmployee($model->id), 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'education_id', 'header' => at('Level'), 'value' => '$data->education->short'), array('name' => 'school', 'header' => at('School')), array('name' => 'department', 'header' => at('Department')), array('name' => 'certificate_year', 'header' => at('Cert Year')), array('class' => 'CButtonColumn', 'htmlOptions' => array('style' => 'width: 80px'), 'buttons' => array('view' => array('url' => '"#education_id#view#".$data->id'), 'update' => array('url' => '"#education_id#update#".$data->id'), 'delete' => array('url' => 'createUrl("employee/educations/delete", array("id"=>$data->id))')))))); ?> <!-- Modal --> <div class="modal fade" id="educationsModal" tabindex="-1" role="dialog" aria-labelledby="educationsModalLabel" 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="educationsModalLabel">Education</h4> </div> <div class="modal-body" id="educationsModalBody"> <!-- tampilan dari ajax --> </div> </div> </div>