Ejemplo n.º 1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getEmployee()
 {
     if ($this->_employee === null) {
         $this->_employee = Employee::findByUsername($this->username);
     }
     return $this->_employee;
 }
 /**
  * Creates a new Employee model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Employee();
     if ($model->load(Yii::$app->request->post())) {
         $model->virtualImage = UploadedFile::getInstance($model, 'virtualImage');
         if ($model->validate()) {
             $filename = $model->virtualImage->baseName . rand(1001, 9009) . '.' . $model->virtualImage->extension;
             $savePathServer = Yii::getAlias('@app') . '/../uploads/' . $filename;
             $model->virtualImage->saveAs($savePathServer);
             $model->image = $filename;
             if ($model->save(false)) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Employee::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created' => $this->created, 'updated' => $this->updated]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Employee::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['employee_id' => $this->employee_id, 'position_id' => $this->position_id, 'user_id' => $this->user_id]);
     $query->orFilterWhere(['like', 'id_number', $this->globalSearch])->orFilterWhere(['like', 'firstname', $this->globalSearch])->orFilterWhere(['like', 'lastname', $this->globalSearch])->orFilterWhere(['like', 'middlename', $this->globalSearch])->orFilterWhere(['like', 'sex', $this->globalSearch])->orFilterWhere(['like', 'employee_status', $this->globalSearch]);
     $query->andFilterWhere(['like', 'id_number', $this->id_number])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'middlename', $this->middlename])->andFilterWhere(['like', 'sex', $this->sex])->andFilterWhere(['like', 'employee_status', $this->employee_status]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Employee::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['fullName'] = ['asc' => ['name' => SORT_ASC, 'surname' => SORT_ASC], 'desc' => ['name' => SORT_DESC, 'surname' => SORT_DESC], 'label' => 'ชื่อ - นามสกุล', 'default' => SORT_ASC];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['emp_id' => $this->emp_id, 'sex' => $this->sex, 'birthday' => $this->birthday, 'modify_date' => $this->modify_date, 'create_date' => $this->create_date, 'salary' => $this->salary, 'expire_date' => $this->expire_date, 'age' => $this->age, 'marital' => $this->marital, 'count_download_resume' => $this->count_download_resume]);
     $query->orFilterWhere(['like', 'employee.name', $this->fullName])->orFilterWhere(['like', 'employee.surname', $this->fullName]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'mobile_phone', $this->mobile_phone])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'skill', $this->skill])->andFilterWhere(['like', 'countries', $this->countries])->andFilterWhere(['like', 'experience', $this->experience])->andFilterWhere(['like', 'personal_id', $this->personal_id])->andFilterWhere(['like', 'province', $this->province])->andFilterWhere(['like', 'amphur', $this->amphur])->andFilterWhere(['like', 'district', $this->district])->andFilterWhere(['like', 'office', $this->office])->andFilterWhere(['like', 'social', $this->social])->andFilterWhere(['like', 'resume', $this->resume])->andFilterWhere(['like', 'token_forupload', $this->token_forupload]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEmployee()
 {
     return $this->hasOne(Employee::className(), ['employee_id' => 'employee_id']);
 }
Ejemplo n.º 7
0
use common\models\Employee;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\EmployeeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Employees');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="employee-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Employee'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'sex', 'filter' => Employee::itemAlias('sex'), 'value' => function ($model) {
    return $model->sexName;
}], 'fullName', 'countryName', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
 public function actionEmployee()
 {
     $this->layout = false;
     header('Content-type: application/json');
     $tmpDataEmployees = Employee::find(['department', 'employee'])->select(['employee.id', 'employee.firstname', 'employee.lastname', 'employee.profile_image_path', 'department.name', 'employee.email'])->asArray()->innerJoin('department', 'department.id = employee.department_id')->all();
     $employees = [];
     if (!empty($tmpDataEmployees)) {
         foreach ($tmpDataEmployees as $tmpDataEmployee) {
             $employees[] = ['id' => $tmpDataEmployee['id'], 'fullname' => $tmpDataEmployee['firstname'] . ' ' . $tmpDataEmployee['lastname'], 'department' => $tmpDataEmployee['name'], 'urlImage' => $tmpDataEmployee['profile_image_path'], 'email' => $tmpDataEmployee['email']];
         }
     }
     echo json_encode($employees);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEmployees()
 {
     return $this->hasMany(Employee::className(), ['position_id' => 'position_id']);
 }
 /**
  * Finds the Employee model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Employee the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Employee::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
$ticket = Ticket::find()->all();
$listData = ArrayHelper::map($ticket, 'ticket_id', 'ticketnumber');
echo $form->field($model, 'ticket_id')->dropDownList($listData, ['prompt' => 'Select Ticket Number']);
?>

    

    <?php 
$ticket_status = TicketStatus::find()->all();
$listData = ArrayHelper::map($ticket_status, 'ticket_status_id', 'status_name');
echo $form->field($model, 'ticket_status_id')->dropDownList($listData, ['prompt' => 'Select Ticket Status']);
?>

    
   <?php 
$employee = Employee::find()->all();
$listData = ArrayHelper::map($employee, 'employee_id', 'firstname', 'lastname');
echo $form->field($model, 'employee_id')->dropDownList($listData, ['prompt' => 'Select Case Number']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Ejemplo n.º 12
0
 public function getEmployees()
 {
     return $this->hasMany(Employee::className(), ['department_id' => 'id']);
 }