Exemplo n.º 1
0
 /**
  * Finds the Application model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Application the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Application::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 2
0
 public static function findUserByApplication($id_application)
 {
     // 获取 application
     $application = Application::findOne($id_application);
     // 获取 Primary AppApplicant
     $applicant = $application->primaryAppApplicant->user;
     // 获取 coAppApplicant
     $co_applicant = null;
     if (isset($application->coAppApplicant)) {
         $co_applicant = $application->coAppApplicant->user;
     }
     // 获取 Primary Advisor
     $primary_advisor = $application->primaryAdvisor;
     // 获取 Primary Supernova
     $primary_supernova = $application->primarySupernova;
     return ['supernova' => $primary_supernova, 'advisor' => $primary_advisor, 'applicant' => $applicant, 'co_applicant' => $co_applicant];
 }
Exemplo n.º 3
0
 public function run()
 {
     if ($this->id_application) {
         $model = Application::findOne($this->id_application);
         $result = $model->checkAppForm();
         $rate = round(($result['totalCount'] - $result['errorCount']) * 100.0 / $result['totalCount'], 2);
         $rate = (int) ($rate / 5) * 5;
         $view = $this->getView();
         $view->registerJs($this->circlyJs);
         $locIsMaximum = $model->loc_max == 1 && ($model->loc == null || $model->loc == 0);
         $locToolTip = $locIsMaximum ? 'Maximum amount based on collateral value' : '';
         $locValueLabel = $locIsMaximum ? 'Maximum' : ($model->loc != null && $model->loc != 0 ? number_format($model->loc) : '---,---,---');
         return strtr($this->template, ['{rate}' => $rate, '{locToolTip}' => $locToolTip, '{loc}' => $locValueLabel]);
     } else {
         return 'this widget need id_application!';
     }
 }
Exemplo n.º 4
0
 public function actionCollateralInformation($id_application)
 {
     $application = Application::findOne($id_application);
     $searchModel = new AppFormCollateralAccountSearch();
     $_GET[$searchModel->formName()]['id_application'] = $id_application;
     $dataProvider = $searchModel->search(Yii::$app->request->get());
     //初始化,写入默认数据
     $model = new AppFormCollateralAccount();
     $model->load([$model->formName() => $application->primaryAppApplicant->getAttributes()]);
     $model->trustee_phone_number = $application->primaryAppApplicant->cell_phone;
     $model->has_regular_distribution = 0;
     $model->is_trust_account = 0;
     $model->custodian = $model->application->group->custodian->name;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $appFormModel = AppForm::find()->andWhere(['id_application' => $id_application])->one();
         $appFormModel->save(false);
         //active
         Active::operationLog($id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, DictTask::$taskType[DictTask::TYPE_APPLICATION_FORM], DictActive::$form_type[DictActive::APP_FORM_COLLATERAL_INFO]], DictActive::USER_UPDATE_TASK, Yii::$app->user->getIdentity()->id);
         return $this->redirect(['collateral-information', 'id_application' => $model->id_application]);
     }
     if ($dataProvider->query->all()) {
         AppFormStatus::changeStatus($id_application, 3, 1);
     } else {
         AppFormStatus::changeStatus($id_application, 3, 0);
     }
     return $this->render('collateral_information', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]);
 }
 public function actionCheck($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     // application
     $application = Application::findOne($model->id_application);
     // check points
     $checkPointsData = AppTaskCheckpoint::find()->where(['id_app_task' => $id_app_task])->all();
     $checkPoints = [];
     $check_ctrl = true;
     foreach ($checkPointsData as $val) {
         $checkPoints[$val['id_app_task_checkpoint_type']] = $val;
     }
     if (!$application->have_existing_loan) {
         unset($checkPoints[5]);
     }
     return $this->renderAjax('check', ['model' => $model, 'checkPoints' => $checkPoints]);
 }
use common\widgets\AppFormStatusBar;
use common\models\AppFormCollateralAccount;
use common\models\AppFormStatus;
use common\models\State;
/* @var $this yii\web\View */
/* @var $searchModel common\models\search\ApplicationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $this yii\web\View */
/* @var $model common\models\AppFormCollateralAccount */
$this->title = Yii::t('app', 'Application Form');
if (Yii::$app->user->getIdentity()->id_user_role == 4) {
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'My Application'), 'url' => ['/loan/application']];
    $this->params['breadcrumbs'][] = $this->title;
} else {
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Applications'), 'url' => ['/application/index']];
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', Application::findOne($this->context->actionParams['id_application'])->application_name), 'url' => ['/application/view', 'id' => $this->context->actionParams['id_application']]];
    $this->params['breadcrumbs'][] = $this->title;
}
$isRead = $this->context->AUTH == Dict::AUTH_READ;
?>

<section class="content-wrap">
             <div class="container">
                 <?php 
echo $this->render('_header_tab', ['id_application' => $this->context->actionParams['id_application']]);
?>
<div class="row pt50">
                     <main class="col-md-9 main-content">
                           <div class="frame">
                                <div>
                                  <!-- Tab panes -->
Exemplo n.º 7
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use common\models\Application;
use common\models\AppUser;
use common\models\AppDocument;
use common\models\user\UserRole;
use yii\widgets\ActiveForm;
$model = Application::findOne($id_application);
$users = $model->users;
$user = Yii::$app->user->getIdentity()->id;
$user_role = Yii::$app->user->getIdentity()->id_user_role;
$UploadModel = new AppDocument();
// $documents = AppDocument::find()->andWhere(['id_application' => $id_application])->groupBy(['id_document_type'])->all();
$roles = [Dict::USER_ROLE_BETTERDEBT => 'Loan Officer', Dict::USER_ROLE_ADVISOR => 'Advisor', Dict::USER_ROLE_CLIENT => 'Client'];
$actives = $model->actives;
rsort($actives);
$form = ActiveForm::Begin(['options' => ['enctype' => 'multipart/form-data'], 'method' => 'post', 'action' => ['/documents/index', 'id_application' => $model->id_application], 'id' => 'asd_111']);
?>
<div class="layout mb20">
	<div class="" id="myCollapsible" role="tablist" aria-multiselectable="true">
		<div class="panel panel-default">
		<div class="panel-heading layout-your-list pl30 por" role="tab" id="headingNo1">
			<h4 class="panel-title">
			<a class="collapsed fwb panel-text fs18" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseNo1" aria-expanded="false" aria-controls="collapseNo1"> Documents </a>
			</h4>
			<i class="caret add-subtract-ico"></i>
		</div>

Exemplo n.º 8
0
 public static function insertTask($id_application, $task_type, $parent_id_app_task)
 {
     if ($task_type->owner_type == DictTask::OWNER_NULL && $task_type->id_user != DictTask::OWNER_USER_NULL) {
         // 非组身份
         $application = Application::findOne($id_application);
         $users = [];
         switch ($task_type->id_user) {
             case DictTask::OWNER_USER_ADVISOR_PRIMARY_AND_CLIENT_ALL:
                 // 查找到 Primary Advisor
                 $users[] = $application->primaryAdvisor->id_user;
                 // 查找到 applicants
                 $application->appApplicants;
                 foreach ($application->appApplicants as $applicant) {
                     $users[] = $applicant->id_user;
                 }
                 break;
             case DictTask::OWNER_USER_CLIENT_ALL:
                 // 查找到 applicants
                 foreach ($application->appApplicants as $applicant) {
                     $users[] = $applicant->id_user;
                 }
                 break;
         }
         // 逐个写入
         foreach ($users as $val) {
             $model = new static();
             $model->id_application = $id_application;
             $model->id_app_task_type = $task_type->id_app_task_type;
             $model->parent_id_app_task = $parent_id_app_task;
             $model->child_relation_type = $task_type->child_relation_type;
             $model->finish_type = $task_type->finish_type;
             $model->name = $task_type->name;
             $model->status = $task_type->status;
             $model->owner_type = $task_type->owner_type;
             $model->id_user = $val;
             $model->active = $task_type->active;
             $model->created_at = time();
             $model->updated_at = time();
             $model->save();
         }
         return 0;
     } else {
         // 组身份
         $model = new static();
         $model->id_application = $id_application;
         $model->id_app_task_type = $task_type->id_app_task_type;
         $model->parent_id_app_task = $parent_id_app_task;
         $model->child_relation_type = $task_type->child_relation_type;
         $model->finish_type = $task_type->finish_type;
         $model->name = $task_type->name;
         $model->status = $task_type->status;
         $model->owner_type = $task_type->owner_type;
         $model->id_user = 0;
         $model->active = $task_type->active;
         $model->created_at = time();
         $model->updated_at = time();
         $model->save();
         return $model->id_app_task;
     }
 }
Exemplo n.º 9
0
 public static function changePrimaryAdvisor($id_advisor_old, $id_advisor_new, $id_application)
 {
     $model = Application::findOne(['primary_advisor' => $id_advisor_old, 'id_application' => $id_application]);
     if (isset($model)) {
         $model->primary_advisor = $id_advisor_new;
         $model->save();
     }
     return true;
 }
Exemplo n.º 10
0
// 生成 label 样式
$label_css = '';
switch ($model->status) {
    case 1:
        $label_css = 'label-default';
        break;
    case 2:
        $label_css = 'label-warning';
        break;
    case 3:
        $label_css = 'label-success';
        break;
}
/* @var $this yii\web\View */
/* @var $model common\models\Application */
$application = Application::findOne($model->id_application);
$identity = Yii::$app->user->getIdentity();
$this->title = Yii::t('app', 'Line Agreements');
if ($identity->id_user_role == Dict::USER_ROLE_CLIENT) {
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'My Application'), 'url' => ['/loan/application']];
} else {
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Applications'), 'url' => ['/application/index']];
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', $application->application_name), 'url' => ['application/view', 'id' => $application->id_application]];
}
$this->params['breadcrumbs'][] = $this->title;
?>
<section class="content-wrap">
	<div class="container">
		<?php 
echo $this->render('../application/_status', ['model' => $model->application]);
?>
Exemplo n.º 11
0
 public function actionChange($id_application, $id_user, $id_user_role)
 {
     $model = Application::findOne($id_application);
     $users = $model->users;
     $roles = [Dict::USER_ROLE_BETTERDEBT => 'Loan Officer', Dict::USER_ROLE_ADVISOR => 'Advisor', Dict::USER_ROLE_CLIENT => 'Client'];
     $user = User::find()->where(['id_user' => $id_user])->one();
     $userName = $user['first_name'] . " " . $user['last_name'];
     $userRole = $roles[$user->id_user_role];
     if (Yii::$app->request->post()) {
         $oldPrimaryAdvisor = $model->primaryAdvisor;
         $id_oldAdvisor = $oldPrimaryAdvisor['id_user'];
         $oldPrimarySupernova = $model->primarySupernova;
         $id_oldSupernova = $oldPrimarySupernova['id_user'];
         if ($id_user_role == Dict::USER_ROLE_ADVISOR) {
             $id_newAdvisor = $id_user;
             $id_newSupernova = $id_oldSupernova;
             //active.
             Active::operationLog($id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'advisor', $oldPrimaryAdvisor['first_name'], $oldPrimaryAdvisor['last_name'], $user['first_name'], $user['last_name']], DictActive::CHANGE_PRIMARY_USER, Yii::$app->user->getIdentity()->id_user);
         } elseif ($id_user_role == Dict::USER_ROLE_BETTERDEBT) {
             $id_newAdvisor = $id_oldAdvisor;
             $id_newSupernova = $id_user;
             Active::operationLog($id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'loan officer', $oldPrimarySupernova['first_name'], $oldPrimarySupernova['last_name'], $user['first_name'], $user['last_name']], DictActive::CHANGE_PRIMARY_USER, Yii::$app->user->getIdentity()->id_user);
         }
         $model->changePrimaryAdvisor($id_oldAdvisor, $id_newAdvisor, $id_application);
         $model->changePrimarySupernova($id_oldSupernova, $id_newSupernova, $id_application);
         return $this->redirect(['application/view', 'id' => $id_application]);
     }
     return $this->renderAjax('change_primary', ['id_application' => $id_application, 'id_user' => $id_user, 'id_user_role' => $id_user_role, 'model' => $model, 'userName' => $userName, 'userRole' => $userRole]);
 }
Exemplo n.º 12
0
 public static function appReview($id_application)
 {
     if (Yii::$app->params['DocuSign']['run']) {
         // 文件路径
         $dir = Yii::$app->params['outpdfPath'];
         // 获取 application
         $application = Application::findOne($id_application);
         // 获取 Primary AppApplicant
         $applicant = $application->primaryAppApplicant->user;
         // 获取 coAppApplicant
         $co_applicant = null;
         if (isset($application->coAppApplicant)) {
             $co_applicant = $application->coAppApplicant->user;
         }
         // 获取 Primary Advisor
         $primary_advisor = $application->primaryAdvisor;
         // 获取 Primary Supernova
         $primary_supernova = $application->primarySupernova;
         //
         $users = [];
         $users['applicant'] = $applicant;
         $users['coapplicant'] = $co_applicant;
         $users['advisor'] = $primary_advisor;
         $users['betterdebt'] = $primary_supernova;
         // 读取 loan_agreements josn
         $positions_agreements = file_get_contents($dir . $id_application . "_signaure_spec_loan_agreements.json");
         $positions_agreements = json_decode($positions_agreements, true);
         // 读取 g3 josn
         $positions_g3 = file_get_contents($dir . $id_application . "_signaure_spec_app_g3.json");
         $positions_g3 = json_decode($positions_g3, true);
         // 读取 w9 josn
         $positions_w9 = file_get_contents($dir . $id_application . "_signaure_spec_app_w9.json");
         $positions_w9 = json_decode($positions_w9, true);
         // // 读取 Schwab josn
         // $positions_schwab = file_get_contents($dir.$id_application."_signaure_spec_app_control_schwab.json");
         // $positions_schwab = json_decode($positions_schwab, true);
         // clients
         $clients = [];
         $clients[] = $applicant->first_name . ' ' . $applicant->last_name;
         if (isset($co_applicant)) {
             $clients[] = $co_applicant->first_name . ' ' . $co_applicant->last_name;
         }
         $clients = implode(', ', $clients);
         // betterdebt
         $betterdebt = $primary_supernova->first_name . ' ' . $primary_supernova->last_name;
         $client = new DocuSign_Client();
         $service = new DocuSign_RequestSignatureService($client);
         $emailSubject = "BriteLine Agreements – Signature Required";
         // $emailBlurb = "Hi, {$clients}/{$betterdebt},
         // $emailBlurb = "Hi, {$clients}
         $emailBlurb = "Your BriteLine Application has been approved. Please review and sign line agreements to activate your BriteLine.\n                Sincerely,\n                The Supernova Lending Team";
         $status = "sent";
         $documents = [new DocuSign_Document("loan_agreements.pdf", "1", file_get_contents($dir . $id_application . "_loan_agreements.pdf", FILE_USE_INCLUDE_PATH)), new DocuSign_Document("g3.pdf", "2", file_get_contents($dir . $id_application . "_g3.pdf", FILE_USE_INCLUDE_PATH)), new DocuSign_Document("w9.pdf", "3", file_get_contents($dir . $id_application . "_w9.pdf", FILE_USE_INCLUDE_PATH))];
         // 定位签名位置
         $esigns = [];
         $esigns = DocusignRecipient::signPositions($positions_agreements, $users, '1', $esigns);
         $esigns = DocusignRecipient::signPositions($positions_g3, $users, '2', $esigns);
         $esigns = DocusignRecipient::signPositions($positions_w9, $users, '3', $esigns);
         // $esigns = DocusignRecipient::signPositions($positions_schwab, $users, '4', $esigns);
         // echo '<pre>';print_r($esigns);exit();
         $signers = [];
         $signer_number = 1;
         foreach ($esigns as $val) {
             $signers[] = new DocuSign_Recipient(1, $signer_number, $val['name'], $val['email'], NULL, 'signers', $val['tabs']);
             $signer_number++;
         }
         $eventNotifications = [];
         $response = $service->signature->createEnvelopeFromDocument($emailSubject, $emailBlurb, $status, $documents, $signers, $eventNotifications);
         // 增加 Docusign 记录
         $result_recipient = static::recipient($id_application, $response, DictTask::TYPE_SIGN_AGREEMENTS);
         // echo '<pre>';print_r($response);exit();
     }
     return false;
 }
Exemplo n.º 13
0
 public function actionView($id)
 {
     // 读取是否有正在申请状态的request,如果有则不能申请新的
     $model = Loan::findOne($id);
     $application = Application::findOne($model->id_application);
     if (!$application->checkOnwerAccess(Yii::$app->user->getId()) && $this->user->id_user_role != Dict::USER_ROLE_BETTERDEBT) {
         throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page.");
     }
     $users = [];
     $accounts = [];
     $request = '';
     $payment = '';
     $request = LoanDrawRequest::find()->where(['id_loan' => $model->id_loan, 'status' => 1])->one();
     // 读取 payment
     $payment = LoanPaymentPreference::find()->where(['id_loan' => $model->id_loan])->one();
     $users = [];
     // 获取 申请人
     $id_user = array();
     foreach ($model->loanBorrowers as $loanBorrower) {
         $id_user[] = $loanBorrower->id_user;
     }
     $user_list = Client::find()->where(['in', 'id_user', $id_user])->all();
     foreach ($user_list as $val) {
         $users[] = $val->user->first_name;
     }
     // 读取 抵押账户 Loan Collateral Account
     $accounts = LoanCollateralAccount::find()->where(['id_loan' => $model->id_loan])->asArray()->all();
     return $this->render('view', ['accounts' => $accounts, 'model' => $model, 'application' => $application, 'request' => $request, 'payment' => $payment, 'users' => implode(',', $users)]);
 }
Exemplo n.º 14
0
<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\helpers\Url;
use common\models\Application;
use kartik\grid\GridView;
$line_id = 0;
$line_type_show = '';
$name = '';
$master_account = '';
if ($line_type == 1) {
    $application = Application::findOne($id_line);
    $this->title = $account_number == '' ? Yii::t('app', 'Collateral Accounts') : Yii::t('app', 'Collateral Accounts - Historical Data');
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Applications'), 'url' => ['/application/index']];
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', $application->application_name), 'url' => ['/application/view', 'id' => $application->id_application]];
    $this->params['breadcrumbs'][] = $this->title;
    $line_id = $id_line;
    $line_type_show = 'Application';
    $name = $application->application_name;
    $master_account = $application->group->group_id;
} else {
}
?>

<section class="content-wrap">
	<div class="container">
		<div class="row pt50">
			<main class="main-content">
				<div class="layout frame">
					<div class="layout-your-list">
Exemplo n.º 15
0
<?php

use yii\helpers\Url;
use yii\widgets\Breadcrumbs;
use common\models\Loan;
use common\models\AppApplicant;
use common\models\Application;
use common\models\Client;
$id_application = 0;
//根据用户id查出是否有无数据
$applicant = AppApplicant::find()->where(['id_user' => Yii::$app->user->getIdentity()->id])->orderBy(['id_app_applicant' => SORT_DESC])->one();
$application = null;
$loan = null;
if (!is_null($applicant)) {
    $application = Application::findOne($applicant->id_application);
    $loan = Loan::find()->where(['id_application' => $applicant->id_application])->one();
}
//根据id_user查找出client(用于profile方法的传值)$id_client
$client = Client::find()->andWhere(['id_user' => Yii::$app->user->getIdentity()->id_user])->one();
?>
<nav class="navbar navbar-default navbar-fixed-top nav-ma">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand h60" href="#"><img src="<?php 
echo Url::to(['@web/images/BetterDebt_logo.svg']);
 public function actionSave($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     if (Yii::$app->request->post()) {
         // save loan
         $loan = Loan::find()->where(['id_application' => $model->id_application])->one();
         $loan->setScenario('review');
         if (Yii::$app->request->isAjax && $loan->load(Yii::$app->request->post())) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($loan);
         }
         if ($loan->load(Yii::$app->request->post()) && $loan->validate()) {
             if ((int) $loan->total_capacity == 0 && Yii::$app->params['capacity_test_initialize']) {
                 $loan->total_capacity = $loan->loc;
             }
             $loan->save();
         }
         // save application
         $app = Application::findOne($model->id_application);
         $app->loc = $loan->loc;
         $app->interest_rate = $loan->interest_rate;
         $app->advance_rate = $loan->advance_rate;
         $app->maintainance_rate = $loan->maintainance_rate;
         $app->margin_rate = $loan->margin_rate;
         $app->total_capacity = $loan->total_capacity;
         $app->save(false);
         //send email to client(s)---application approval letter
         $data = AppUser::find()->andWhere(['id_application' => $model->id_application, 'is_primary_contact' => 1])->all();
         $users_id = [];
         foreach ($data as $val) {
             if ($val->user->id_user_role == Dict::USER_ROLE_BETTERDEBT) {
                 $users_id[] = $val->id_user;
             }
         }
     }
     return $this->redirect(['/task-app-review/index', 'id_app_task' => $id_app_task]);
 }
Exemplo n.º 17
0
 public function beforeAction($action)
 {
     // ID
     $ctrl_id = $action->controller->id;
     $action_id = $action->id;
     $behaviour = $ctrl_id . '/' . $action_id;
     if (parent::beforeAction($action)) {
         // 判断 id_application 权限
         if (isset($_GET['id_application']) && !isset($_GET['id_app_task'])) {
             $application = Application::findOne($_GET['id_application']);
             if (!$application->checkOnwerAccess($this->user->id_user)) {
                 if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT) {
                     $this->AUTH = Dict::AUTH_READ;
                     $app_task = AppTask::findOne(['id_application' => $application->id_application, 'id_app_task_type' => DictTask::TYPE_APPLICATION_FORM]);
                     if (($app_task->status != DictTask::STATUS_ACTIVE || $app_task->application->id_application_status != DictApplication::STATUS_ACTIVE) && !in_array($behaviour, ['task-sign/close', 'task-supplemental-information/view-file'])) {
                         if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT || $this->user->id_user_role == Dict::USER_ROLE_ADVISOR) {
                             $this->redirect(['/application/view', 'id' => $app_task->id_application]);
                         } else {
                             if ($this->user->id_user_role == Dict::USER_ROLE_CLIENT) {
                                 $this->redirect(['/loan/application']);
                             }
                         }
                         return false;
                     }
                 } else {
                     throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page.");
                 }
             } else {
                 // app-form 特殊判断
                 if ($ctrl_id == 'app-form') {
                     $app_task = AppTask::findOne(['id_application' => $application->id_application, 'id_app_task_type' => DictTask::TYPE_APPLICATION_FORM]);
                     if ($app_task->status != DictTask::STATUS_ACTIVE || $app_task->application->id_application_status != DictApplication::STATUS_ACTIVE) {
                         if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT || $this->user->id_user_role == Dict::USER_ROLE_ADVISOR) {
                             $this->redirect(['/application/view', 'id' => $app_task->id_application]);
                         } else {
                             if ($this->user->id_user_role == Dict::USER_ROLE_CLIENT) {
                                 $this->redirect(['/loan/application']);
                             }
                         }
                         return false;
                     }
                     if ($app_task->owner_type == DictTask::$userRoleToOwner[$this->user->id_user_role]) {
                         $this->AUTH = Dict::AUTH_OPERATE;
                     } else {
                         $this->AUTH = Dict::AUTH_READ;
                     }
                 } else {
                     if ($behaviour == 'task-sign/close') {
                         $betterdebt = Betterdebt::findOne(['id_user' => $this->user->id_user]);
                         if ($betterdebt->is_in_service_team == Dict::BD_SERVICE_TEAM_YES) {
                             $this->AUTH = Dict::AUTH_OPERATE;
                         } else {
                             $this->AUTH = Dict::AUTH_READ;
                         }
                     } else {
                         $this->AUTH = Dict::AUTH_READ;
                     }
                 }
             }
         }
         // 判断 id_app_task 权限
         if (isset($_GET['id_app_task'])) {
             $app_task = AppTask::findOne($_GET['id_app_task']);
             if ($app_task->application->checkOnwerAccess($this->user->id_user)) {
                 if (!AppTask::checkOnwerAccess($app_task, $behaviour)) {
                     throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page.");
                 } else {
                     if (in_array($behaviour, ['task-sign/close', 'task/assign-to', 'task-sign/remind'])) {
                         $this->AUTH = Dict::AUTH_OPERATE;
                     } else {
                         if (DictTask::$ownerToUserRole[$app_task->owner_type] == $this->user->id_user_role) {
                             $this->AUTH = Dict::AUTH_OPERATE;
                         } else {
                             $this->AUTH = Dict::AUTH_READ;
                         }
                     }
                 }
             } else {
                 if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT) {
                     $this->AUTH = Dict::AUTH_READ;
                 } else {
                     throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page.");
                 }
             }
             $loan = Loan::findOne(['id_application' => $app_task->id_application]);
             // 如果任务不是正在进行中,则跳转
             if ($app_task->status != DictTask::STATUS_ACTIVE || $app_task->application->id_application_status != DictApplication::STATUS_ACTIVE || isset($loan) && $loan->status == Dict::LOAN_STATUS_CLOSED) {
                 if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT || $this->user->id_user_role == Dict::USER_ROLE_ADVISOR) {
                     $this->redirect(['/application/view', 'id' => $app_task->id_application]);
                 } else {
                     if ($this->user->id_user_role == Dict::USER_ROLE_CLIENT) {
                         $this->redirect(['/loan/application']);
                     }
                 }
                 return false;
             }
         }
         // 判断 id_app_form_collateral_account 权限
         if (isset($_GET['id_app_form_collateral_account'])) {
             $collateral_account = AppFormCollateralAccount::findOne($_GET['id_app_form_collateral_account']);
             if (!$collateral_account->application->checkOnwerAccess($this->user->id_user)) {
                 if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT) {
                     $this->AUTH = Dict::AUTH_READ;
                 } else {
                     throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page.");
                 }
             } else {
                 $this->AUTH = Dict::AUTH_OPERATE;
             }
         }
         // 判断 id_app_task_checkpoint 权限
         if (isset($_GET['id_app_task_checkpoint'])) {
             $checkpoint = AppTaskCheckpoint::findOne($_GET['id_app_task_checkpoint']);
             if (!$checkpoint->appTask->application->checkOnwerAccess($this->user->id_user) || !AppTask::checkOnwerAccess($checkpoint->appTask, $behaviour)) {
                 if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT) {
                     $this->AUTH = Dict::AUTH_READ;
                 } else {
                     throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page.");
                 }
             } else {
                 $this->AUTH = Dict::AUTH_OPERATE;
             }
         }
     }
     return true;
 }