Example #1
0
 public function actionIndex()
 {
     // header('Location: http://www.supernovacompanies.com/lending/');
     //return $this->render('index');
     if (Yii::$app->user->getIsGuest()) {
         return $this->redirect(Yii::$app->user->loginUrl);
     }
     $id_user_role = Yii::$app->user->getIdentity()->id_user_role;
     $id_user = Yii::$app->user->getIdentity()->id_user;
     $agree = Yii::$app->user->getIdentity()->agree;
     $url = '/user/login';
     if ($id_user_role == Dict::USER_ROLE_BETTERDEBT) {
         $url = '/official/index';
     } else {
         if ($id_user_role == Dict::USER_ROLE_INSTITUTION) {
             $url = '/institution/index';
         } else {
             if ($id_user_role == Dict::USER_ROLE_ADVISOR) {
                 //新增判断是否已读协议
                 if ($agree == Dict::USER_AGREE_NOT) {
                     $url = '/user/login';
                 } else {
                     $url = '/advisor/index';
                 }
             } else {
                 if ($id_user_role == Dict::USER_ROLE_CLIENT) {
                     if ($agree == Dict::USER_AGREE_NOT) {
                         $url = '/user/login';
                     }
                     //根据用户id_user查出是否有无数据
                     $applicant = AppApplicant::find()->where(['id_user' => Yii::$app->user->getIdentity()->id_user])->orderBy(['id_app_applicant' => SORT_DESC])->one();
                     if (is_null($applicant)) {
                         $url = '/loan/application';
                     } else {
                         $loan = Loan::find()->where(['id_application' => $applicant->id_application]);
                         if (is_null($loan) && $loan->status == Dict::LOAN_STATUS_ACTIVE) {
                             $url = '/loan/index';
                         } else {
                             $url = '/loan/application';
                         }
                     }
                 } else {
                     if ($id_user_role == Dict::USER_ROLE_BANK) {
                         $url = '/bank/index';
                     }
                 }
             }
         }
     }
     return $this->redirect([$url]);
 }
 public function actionUpdate($id)
 {
     $model = LoanDrawRequest::findOne($id);
     $model->status = 2;
     $model->save();
     //根据id_loan字段更新loan表中的balance字段
     $id_loan = $model->id_loan;
     $loanModel = Loan::findOne($id_loan);
     if (Yii::$app->params['should_update_balance']) {
         $loanModel->balance = $loanModel->balance + $model->amount;
         $loanModel->save();
     }
     //send draw request approval email to client()
     SendEmail::email(DictEmail::EMAIL_LETTER_ABOUT_LINE, [DictEmail::LETTER_DRAW_REQUEST_APPROVAL, $loanModel->id_application, DictEmail::DRAW_REQUEST_TYPE_CLIENT, $model]);
     //send draw request approval email to advisor
     SendEmail::email(DictEmail::EMAIL_LETTER_ABOUT_LINE, [DictEmail::LETTER_DRAW_REQUEST_APPROVAL, $loanModel->id_application, DictEmail::DRAW_REQUEST_TYPE_ADVISOR, $model, $loanModel]);
     return $this->redirect('index');
 }
 public function actionCheck($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     //  判断是否可以 approve
     $loanModel = Loan::find()->where(['id_application' => $model->id_application])->one();
     $loanModel->setScenario('review');
     $loan_ctrl = $loanModel->validate();
     // check points
     $checkPoints = AppTaskCheckpoint::find()->where(['id_app_task' => $id_app_task])->all();
     return $this->renderAjax('check', ['model' => $model, 'loan_ctrl' => $loan_ctrl, 'checkPoints' => $checkPoints]);
 }
 public function actionIndex($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     // loan
     $loan = Loan::find()->where(['id_application' => $model->id_application])->one();
     // application
     $application = Application::findOne($model->id_application);
     // applicants
     $app_applicants = $application->appApplicants;
     $applicants = [];
     foreach ($app_applicants as $val) {
         $applicants[] = $val->first_name;
     }
     // advisors
     $advisors = [];
     foreach ($model->application->advisors as $advisor) {
         if (isset($advisor->user)) {
             $advisors[] = $advisor->user->first_name;
         }
     }
     // 读取所以检查项
     $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) {
         $check_ctrl = $checkPoints[4]->status && $checkPoints[5]->status ? true : false;
     } else {
         $check_ctrl = $checkPoints[4]->status ? true : false;
     }
     if (Yii::$app->request->post()) {
         $loanModel = Loan::find()->andWhere(['id_application' => $model->id_application])->one();
         $loanModel->status = 1;
         $loanModel->save();
         if (AppTask::taskFinish($id_app_task)) {
             //active log.loan officer finished the task line set-up
             Active::operationLog($model->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'finished', DictTask::$taskType[DictTask::TYPE_LINE_SETUP]], DictActive::USER_FINISH_TASK, Yii::$app->user->getIdentity()->id);
         }
         // 拷贝 form/financial info/LOC Disbursement
         $app_form = AppForm::find()->andWhere(['id_application' => $model->id_application])->one();
         $LoanBankAcount = new LoanBankAcount();
         $LoanBankAcount->account_type = 1;
         $LoanBankAcount->id_loan = $loanModel->id_loan;
         $LoanBankAcount->bank_name = $app_form->bank_name;
         $LoanBankAcount->routing_number = $app_form->routing_number;
         $LoanBankAcount->account_name = $app_form->account_name;
         $LoanBankAcount->account_number = $app_form->account_number;
         $LoanBankAcount->save();
         // 拷贝 collateral_data 数据
         LineAccount::copyData($model->id_application, $loanModel->id_loan);
         CollateralAccount::copyData($model->id_application, $loanModel->id_loan);
         //send loan approval email to client and cc to advisor(email($email_type,[$task_type,$id_app_task,$loan]))
         $res = SendEmail::email(DictEmail::EMAIL_LETTER_ABOUT_LINE, [DictEmail::LETTER_TASK_LOAN_APPROVAL, $id_app_task, $loan]);
         if ($res) {
             //active log.system sent an email 'Your Line is Live' to client and advisor
             //判断是否有两个client参与
             $user = SendEmail::findUserByApplication($model->id_application);
             if (is_null($user['co_applicant'])) {
                 Active::operationLog($model->id_application, [$user['applicant']->first_name, $user['applicant']->last_name, '', $user['advisor']->first_name, $user['advisor']->last_name], DictActive::SYSTEM_SEND_LINE_ALIVE_LETTER, 0);
             } else {
                 Active::operationLog($model->id_application, [$user['applicant']->first_name, $user['applicant']->last_name, ',' . $user['co_applicant']->first_name . ' ' . $user['co_applicant']->last_name, $user['advisor']->first_name, $user['advisor']->last_name], DictActive::SYSTEM_SEND_LINE_ALIVE_LETTER, 0);
             }
         }
         //active log.system closed the application
         Active::operationLog($model->id_application, [], DictActive::SYSTEM_CLOSED_THE_APPLICATION, 0);
         // collateral_data 拷贝 Line
         $application = Application::findOne($model->id_application);
         $application->id_application_status = DictApplication::STATUS_CLOSED;
         $application->save(false);
         return $this->redirect(['/application/view', 'id' => $model->id_application]);
     }
     return $this->render('index', ['model' => $model, 'application' => $application, 'loan' => $loan, 'applicants' => $applicants, 'advisors' => $advisors, 'checkPoints' => $checkPoints, 'check_ctrl' => $check_ctrl]);
 }
Example #5
0
<?php

use yii\helpers\Html;
use common\models\Application;
use common\models\AppOwnerTask;
use common\models\Loan;
$identity = Yii::$app->user->getIdentity();
$loan = Loan::find()->andWhere(['id_application' => $model->id_application])->one();
$percent = $model->percent;
$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) : '---,---,---');
?>

<div class="row pt60  ovh clearfix">
	<div class="col-md-4 por">
		<i class="ico-01 ico-bell"></i>
		<div class="pl70 Notic_text_auto_font_size" style="height:68px;display: table-cell;vertical-align: middle;">
		<?php 
if ($identity->id_user_role == Dict::USER_ROLE_BETTERDEBT) {
    ?>
			<p class="fs14 mb0" style="font-weight: 100;">Welcome to Supernova Lending, <?php 
    echo $identity->first_name;
    ?>
!</p>
		<?php 
} else {
    if ($identity->id_user_role == Dict::USER_ROLE_ADVISOR) {
        ?>
			<p class="fs14 mb0" style="font-weight: 100;">Welcome to Supernova Lending, <?php 
        echo $identity->first_name;
Example #6
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']);
Example #7
0
 public function getLoan()
 {
     return $this->hasOne(Loan::className(), ['id_application' => 'id_application']);
 }
Example #8
0
 public function actionLogin($email = '', $come = '')
 {
     $this->enableCsrfValidation = false;
     $this->layout = '//home/yii';
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && !$model->login($this->loginDuration)) {
         $a = ['errors' => $model['errors'], 'code' => 0];
         exit(json_encode($a));
     }
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && $model->login($this->loginDuration)) {
         $id_user_role = Yii::$app->user->getIdentity()->id_user_role;
         $id_user = Yii::$app->user->getIdentity()->id_user;
         $agree = Yii::$app->user->getIdentity()->agree;
         $url = '';
         if ($id_user_role == Dict::USER_ROLE_BETTERDEBT) {
             $url = '/official/index';
         } else {
             if ($id_user_role == Dict::USER_ROLE_INSTITUTION) {
                 $url = '/institution/index';
             } else {
                 if ($id_user_role == Dict::USER_ROLE_ADVISOR) {
                     //新增判断是否已读协议
                     if ($agree == Dict::USER_AGREE_NOT) {
                         exit($this->_agree($id_user, $id_user_role));
                     } else {
                         $url = '/advisor/index';
                     }
                 } else {
                     if ($id_user_role == Dict::USER_ROLE_CLIENT) {
                         if ($agree == Dict::USER_AGREE_NOT) {
                             exit($this->_agree($id_user, $id_user_role));
                         }
                         //根据用户id_user查出是否有无数据
                         $applicant = AppApplicant::find()->where(['id_user' => $id_user])->orderBy(['id_app_applicant' => SORT_DESC])->one();
                         if (is_null($applicant)) {
                             $url = '/loan/application';
                         } else {
                             $loan = Loan::find()->where(['id_application' => $applicant->id_application])->one();
                             if (isset($loan) && $loan->status == Dict::LOAN_STATUS_ACTIVE) {
                                 $url = '/loan/index';
                             } else {
                                 $url = '/loan/application';
                             }
                         }
                     } else {
                         if ($id_user_role == Dict::USER_ROLE_BANK) {
                             $url = '/bank/index';
                         }
                     }
                 }
             }
         }
         if ($come) {
             $return = ['code' => 2, 'url' => $come];
             exit(json_encode($return));
             //return $this->redirect([$come]);
         } else {
             $return = ['code' => 2, 'url' => $url];
             exit(json_encode($return));
             //return $this->redirect([$url]);
         }
     }
     return $this->render('login', ['model' => $model, 'email' => $email]);
 }
Example #9
0
 public function actionList()
 {
     $searchModel = new LoanSearch();
     if ($this->user->id_user_role == Dict::USER_ROLE_ADVISOR) {
         $advisor = Advisor::find()->andWhere(['id_user' => $this->user->id])->one();
         //find related groups
         $id_groups = AdvisorGroup::find()->andWhere(['id_advisor' => $advisor['id_advisor']])->all();
         $ids = [];
         foreach ($id_groups as $value) {
             $ids[] = $value['id_group'];
         }
         $applications = Application::find()->andWhere(['in', 'id_group', $ids])->all();
         $id_applications = [];
         foreach ($applications as $value) {
             $id_applications[] = $value['id_application'];
         }
         $query = Loan::find()->andWhere(['in', 'id_application', $id_applications])->andWhere(['status' => 1]);
         //->orderBy(['id_loan' => SORT_DESC]);
         $dataProvider = $searchModel->search(Yii::$app->request->get(), $query);
     } else {
         if ($this->user->id_user_role == Dict::USER_ROLE_BETTERDEBT) {
             $query = Loan::find()->andWhere(['status' => 1]);
             //->orderBy(['id_loan' => SORT_DESC]);
             $dataProvider = $searchModel->search(Yii::$app->request->get(), $query);
             // 			$query->orderBy(['id_loan' => SORT_DESC]);
             // 			$dataProvider = new ActiveDataProvider([
             // 				'query' => $query,
             // 			]);
         }
     }
     return $this->render('list', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #10
0
 public function getLoan()
 {
     return $this->hasOne(Loan::classname(), ['id_loan' => 'id_loan']);
 }
 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;
 }