public function actionGetleavesinfo($id)
 {
     header('Content-type: application/json');
     $employee = MastersEmployees::model()->findByPk($_GET['id']);
     $leave = LeaveRequest::model()->find(array('condition' => 'employee_id = ' . $_GET['id'] . ' and (status = "new" or status = "request")'));
     // $leaves_pending_msg = count($leave);
     if (count($leave) == 0) {
         $leaves_pending_msg = '';
     } else {
         $leaves_pending_msg = at('There is a pending leaves request for this employee.');
     }
     $leaves_quota = $employee->leave_quota;
     echo CJSON::encode(array('leaves_pending' => $leaves_pending_msg, 'leaves_info' => '{ Current Leaves : 2 / 3 ( Max : 1 ) } { Total Leaves : 21 }', 'leaves_quota' => $leaves_quota));
 }
Пример #2
0
 /**
  * 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 LeaveRequest the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = LeaveRequest::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }