$template = '{view}'; if ($isform) { ?> <div class="row"> <a href="#language_id#create#0" class="btn btn-primary"><?php echo at('Add Language'); ?> </a> </div> <?php $template .= '{update}{delete}'; } ?> <?php $this->widget('DTGridView', array('id' => 'masters-employee-languages-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeLanguages::model()->searchByEmployee($model->id), 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'language_id', 'header' => at('Language'), 'value' => '$data->language->short'), array('name' => 'level', 'header' => at('Level')), array('class' => 'CButtonColumn', 'htmlOptions' => array('style' => 'width: 70px'), 'buttons' => array('view' => array('url' => '"#language_id#view#".$data->id'), 'update' => array('url' => '"#language_id#update#".$data->id'), 'delete' => array('url' => 'createUrl("employee/languages/delete", array("id"=>$data->id))')))))); ?> <!-- Modal --> <div class="modal fade" id="languagesModal" tabindex="-1" role="dialog" aria-labelledby="languagesModalLabel" 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="languagesModalLabel">Training</h4> </div> <div class="modal-body" id="languagesModalBody"> <!-- tampilan dari ajax --> </div> </div> </div>
/** * 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 MastersEmployeeLanguages the loaded model * @throws CHttpException */ public function loadModel($id) { $c = new CDbCriteria(); $c->compare('id', $id); $c->compare('employee_id', getUser()->id); $model = MastersEmployeeLanguages::model()->find($c); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionAjaxcreate($id) { $model = new MastersEmployeeLanguages(); if ($id != '') { $model = MastersEmployeeLanguages::model()->findByPk($id); } // print_r($_POST);die(); $model->employee_id = $_POST['employee_id']; $model->language_id = $_POST['language_id']; $model->level = $_POST['level']; if ($model->save()) { $_POST['success'] = 1; } else { $_POST['success'] = 0; } $_POST['id'] = $id; $_POST['error_employee_id'] = ''; $_POST['error_language_id'] = ''; $_POST['error_level'] = ''; if (isset($model->errors['employee_id'][0])) { $_POST['error_employee_id'] = $model->errors['employee_id'][0]; } if (isset($model->errors['language_id'][0])) { $_POST['error_language_id'] = $model->errors['language_id'][0]; } if (isset($model->errors['level'][0])) { $_POST['error_level'] = $model->errors['level'][0]; } echo json_encode($_POST); }
public function checkLang() { if ($this->isNewRecord) { $c = new CDbCriteria(); $c->compare('employee_id', $this->employee_id); $c->compare('language_id', $this->language_id); $model = MastersEmployeeLanguages::model()->findAll($c); if (count($model) > 0) { $this->addError('language_id', at('Sorry, You have added this language.')); } } }
<?php $this->widget('DTGridView', array('id' => 'masters-employee-languages-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeLanguages::model()->searchByEmployee($model->id), 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'language_id', 'header' => at('Language'), 'value' => '$data->language->short'), array('name' => 'level', 'header' => at('Level'))))); ?>