/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Betterdebt::find();
     if (!isset($params['sort'])) {
         $query->orderBy(['id_betterdebt' => SORT_DESC]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id_betterdebt' => $this->id_betterdebt, 'id_user' => $this->id_user, 'is_in_service_team' => $this->is_in_service_team, 'is_primary_service_member' => $this->is_primary_service_member, 'delete' => $this->delete, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'betterdebt_id', $this->betterdebt_id])->andFilterWhere(['like', 'phone', $this->phone]);
     return $dataProvider;
 }
Exemple #2
0
}], ['label' => 'Group Name', 'value' => function ($model) {
    if ($model->group) {
        return $model->group->group_id;
    }
}], ['class' => 'common\\widgets\\ActionColumn', 'template' => '{invite}{view}', 'width' => '15%', 'buttons' => ['invite' => function ($url, $model, $key) {
    if ($model->user) {
        if ($model->user->status == 0) {
            $options = ['class' => 'btn btn-light btn-icon', 'title' => Yii::t('yii', 'Invite'), 'aria-label' => Yii::t('yii', 'Invite'), 'data-confirm' => Yii::t('yii', 'Are you sure invite this client to email?'), 'data-pjax' => '0'];
            return Html::a('<span class="glyphicon">&#xe621;</span>', $url, $options);
        }
    }
}, 'cancelinvite' => function ($url, $model, $key) {
    $options = ['class' => 'btn btn-light btn-icon', 'title' => Yii::t('yii', 'Cancel Invition'), 'aria-label' => Yii::t('yii', 'Cancel Invition'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to cancel invition?'), 'data-pjax' => '0'];
    return Html::a('<span class="glyphicon">&#xe621;</span>', $url, $options);
}, 'view' => function ($url, $model, $key) {
    $betterdebt = Betterdebt::find()->andWhere(['id_user' => Yii::$app->user->getId()])->one();
    $options = ['class' => 'btn btn-light btn-icon', 'title' => Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_ADVISOR || Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_BETTERDEBT && $betterdebt->is_in_service_team == Dict::BD_SERVICE_TEAM_NOT ? Yii::t('yii', 'View') : Yii::t('yii', 'Update'), 'aria-label' => Yii::t('yii', 'View'), 'data-pjax' => '0'];
    if (Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_ADVISOR || Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_BETTERDEBT && $betterdebt->is_in_service_team == Dict::BD_SERVICE_TEAM_NOT) {
        return Html::a('<span class="glyphicon">&#xe620;</span>', Url::to(['/client/update', 'id' => $model->id_client]), $options);
    } else {
        if (Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_BETTERDEBT && $betterdebt->is_in_service_team == Dict::BD_SERVICE_TEAM_YES) {
            return Html::a('<span class="glyphicon">&#xe61f;</span>', Url::to(['/client/update', 'id' => $model->id_client]), $options);
        }
    }
}], 'detailViewAttributes' => function ($model, $key) {
    return ['id_client', ['label' => 'Group Name', 'value' => $model->group ? $model->group->group_id : ''], 'client_id'];
}]]]);
?>

               </div>
                 </div>
Exemple #3
0
 public function getUsers()
 {
     $users = [];
     // 找到 advisor
     if (isset($this->advisors)) {
         foreach ($this->advisors as $val) {
             $users[] = $val->user;
         }
     }
     // 找到 applicant
     if (isset($this->appApplicants)) {
         foreach ($this->appApplicants as $val) {
             $users[] = $val->user;
         }
     }
     // 找到 supernova
     $supernovas = Betterdebt::find()->andWhere(['is_in_service_team' => Dict::BD_SERVICE_TEAM_YES])->all();
     if (isset($supernovas)) {
         foreach ($supernovas as $val) {
             $users[] = $val->user;
         }
     }
     return $users;
 }
Exemple #4
0
 public static function createByApplication($application)
 {
     $primaryAppApplicant = $application->primaryAppApplicant;
     $coAppApplicant = $application->coAppApplicant;
     $primaryAdvisor = $application->primaryAdvisor;
     $primarySupernova = $application->primarySupernova;
     $appUserModel = new self();
     $appUserModel->id_application = $application->id_application;
     $primaryClientUserModel = clone $appUserModel;
     $primaryClientUserModel->id_user = $primaryAppApplicant->id_user;
     $primaryClientUserModel->is_primary_contact = 1;
     $primaryClientUserModel->save();
     if ($application->is_joint_application) {
         $coClientUserModel = clone $appUserModel;
         $coClientUserModel->id_user = $coAppApplicant->id_user;
         $coClientUserModel->is_primary_contact = 0;
         $coClientUserModel->save();
     }
     foreach ($application->group->advisors as $advisorModel) {
         $model = clone $appUserModel;
         $model->id_user = $advisorModel->id_user;
         if ($advisorModel->id_user == $primaryAdvisor->id_user) {
             $model->is_primary_contact = 1;
         } else {
             $model->is_primary_contact = 0;
         }
         $model->save();
     }
     $betterdebts = Betterdebt::find()->andWhere(['is_in_service_team' => Dict::BD_SERVICE_TEAM_YES])->all();
     foreach ($betterdebts as $betterdebt) {
         $model = clone $appUserModel;
         $model->id_user = $betterdebt->id_user;
         if ($betterdebt->id_user == $primarySupernova->id_user) {
             $model->is_primary_contact = 1;
         } else {
             $model->is_primary_contact = 0;
         }
         $model->save();
     }
     return true;
 }