Example #1
0
$template = '{view}';
if ($isform) {
    ?>
	<div class="row">		
		<a href="#employment_id#create#0" class="btn btn-primary"><?php 
    echo at('Add Employment');
    ?>
</a>
	</div>
	<?php 
    $template .= '{update}{delete}';
}
?>

<?php 
$this->widget('DTGridView', array('id' => 'masters-employee-employments-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeHistoryEmployments::model()->searchByEmployee($model->id), 'enableSorting' => false, 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'company_name', 'header' => at('Company')), array('name' => 'position', 'header' => at('Position')), array('name' => 'last_position', 'header' => at('Last Position')), array('name' => 'resign_reason', 'header' => at('Reason')), array('class' => 'CButtonColumn', 'htmlOptions' => array('style' => 'width: 80px'), 'template' => $template, 'buttons' => array('view' => array('url' => '"#employment_id#view#".$data->id'), 'update' => array('url' => '"#employment_id#update#".$data->id'), 'delete' => array('url' => 'createUrl("employee/employments/delete", array("id"=>$data->id))'))))));
?>

<!-- Modal -->
<div class="modal fade" id="employmentsModal" tabindex="-1" role="dialog" aria-labelledby="employmentsModalLabel" 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">&times;</span></button>
        <h4 class="modal-title" id="employmentsModalLabel">Education</h4>
      </div>
      <div class="modal-body" id="employmentsModalBody">
      <!-- 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 MastersEmployeeHistoryEmployments the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $c = new CDbCriteria();
     $c->compare('id', $id);
     $c->compare('employee_id', getUser()->id);
     $model = MastersEmployeeHistoryEmployments::model()->find($c);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionAjaxcreate($id)
 {
     $model = new MastersEmployeeHistoryEmployments();
     if ($id != '') {
         $model = MastersEmployeeHistoryEmployments::model()->findByPk($id);
     }
     $model->employee_id = $_POST['employee_id'];
     $model->company_name = $_POST['company_name'];
     $model->company_address_street1 = $_POST['company_address_street1'];
     $model->company_address_street2 = $_POST['company_address_street2'];
     $model->company_address_country_id = $_POST['company_address_country_id'];
     $model->company_address_state_id = $_POST['company_address_state_id'];
     $model->company_address_city_id = $_POST['company_address_city_id'];
     $model->company_address_poscode = $_POST['company_address_poscode'];
     $model->position = $_POST['position'];
     $model->last_position = $_POST['last_position'];
     $model->work_date = $_POST['work_date'];
     $model->resign_date = $_POST['resign_date'];
     $model->resign_reason = $_POST['resign_reason'];
     // print_r($model);die();
     if ($model->save()) {
         $_POST['success'] = 1;
     } else {
         $_POST['success'] = 0;
     }
     $_POST['id'] = $id;
     $_POST['error_employee_id'] = '';
     $_POST['erorr_company_name'] = '';
     $_POST['erorr_company_address_street1'] = '';
     $_POST['erorr_company_address_street2'] = '';
     $_POST['erorr_company_address_country_id'] = '';
     $_POST['erorr_company_address_state_id'] = '';
     $_POST['erorr_company_address_city_id'] = '';
     $_POST['erorr_company_address_poscode'] = '';
     $_POST['erorr_position'] = '';
     $_POST['erorr_last_position'] = '';
     $_POST['erorr_work_date'] = '';
     $_POST['erorr_resign_date'] = '';
     $_POST['erorr_resign_reason'] = '';
     if (isset($model->errors['employee_id'][0])) {
         $_POST['error_employee_id'] = $model->errors['employee_id'][0];
     }
     if (isset($model->errors['company_name'][0])) {
         $_POST['error_company_name'] = $model->errors['company_name'][0];
     }
     if (isset($model->errors['company_address_street1'][0])) {
         $_POST['error_company_address_street1'] = $model->errors['company_address_street1'][0];
     }
     if (isset($model->errors['company_address_street2'][0])) {
         $_POST['error_company_address_street2'] = $model->errors['company_address_street2'][0];
     }
     if (isset($model->errors['company_address_country_id'][0])) {
         $_POST['erorr_company_address_country_id'] = $model->errors['company_address_country_id'][0];
     }
     if (isset($model->errors['company_address_state_id'][0])) {
         $_POST['erorr_company_address_state_id'] = $model->errors['company_address_state_id'][0];
     }
     if (isset($model->errors['company_address_city_id'][0])) {
         $_POST['erorr_company_address_city_id'] = $model->errors['company_address_city_id'][0];
     }
     if (isset($model->errors['company_address_poscode'][0])) {
         $_POST['erorr_company_address_poscode'] = $model->errors['company_address_poscode'][0];
     }
     if (isset($model->errors['position'][0])) {
         $_POST['error_position'] = $model->errors['position'][0];
     }
     if (isset($model->errors['last_position'][0])) {
         $_POST['erorr_last_position'] = $model->errors['last_position'][0];
     }
     if (isset($model->errors['work_date'][0])) {
         $_POST['erorr_work_date'] = $model->errors['work_date'][0];
     }
     if (isset($model->errors['resign_date'][0])) {
         $_POST['erorr_resign_date'] = $model->errors['resign_date'][0];
     }
     if (isset($model->errors['resign_reason'][0])) {
         $_POST['erorr_resign_reason'] = $model->errors['resign_reason'][0];
     }
     echo json_encode($_POST);
 }
Example #4
0

<?php 
$this->widget('DTGridView', array('id' => 'masters-employee-employments-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => MastersEmployeeHistoryEmployments::model()->searchByEmployee($model->id), 'enableSorting' => false, 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'company_name', 'header' => at('Company')), array('name' => 'position', 'header' => at('Position')), array('name' => 'last_position', 'header' => at('Last Position')), array('name' => 'resign_reason', 'header' => at('Reason')))));