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 beforeAction($action) { parent::beforeAction($action); if ($action->id == 'index' && Yii::$app->user->getIdentity()->id_user_role != Dict::USER_ROLE_CLIENT) { throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page."); } if ($action->id == 'view' && Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_CLIENT) { throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page."); } if ($action->id == 'view' && Yii::$app->user->getIdentity()->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']; } $result = Loan::find()->andWhere(['in', 'id_application', $id_applications])->all(); if (count($result) == 0) { //没有与该advisor在同一个group中的line throw new UnauthorizedHttpException("Sorry, you don't have permission to access this page."); } } $id_application = 0; //根据用户id查出是否有无数据 $applicant = AppApplicant::find()->where(['id_user' => $this->user->id])->orderBy(['id_app_applicant' => SORT_DESC])->one(); if (!is_null($applicant)) { $this->application = Application::findOne($applicant->id_application); $this->loan = Loan::find()->where(['id_application' => $applicant->id_application])->one(); } return true; }
public function actionIndex($id_app_task) { $model = AppTask::findOne($id_app_task); $loanModel = Loan::find()->where(['id_application' => $model->id_application])->one(); // 如果 loan 不存在,则新建 if (is_null($loanModel)) { $loanModel = new Loan(); $loanModel->loan_number = ''; $loanModel->id_application = $model->id_application; $loanModel->status = 0; $loanModel->loc = $model->application->loc; $loanModel->balance = 0; $loanModel->advance_rate = 50; $loanModel->maintainance_rate = 70; $loanModel->collateral_value = $model->application->collateral_value; $loanModel->save(false); } // 读取所以检查项 $checkPointsData = AppTaskCheckpoint::find()->where(['id_app_task' => $id_app_task])->all(); $checkPoints = []; $check_points_ctrl = true; foreach ($checkPointsData as $val) { $checkPoints[$val['id_app_task_checkpoint_type']] = $val; if (!$val->status) { $check_points_ctrl = false; } } // 判断是否可以 approve $loanModel->setScenario('review'); $loanCheck = clone $loanModel; $loan_ctrl = $loanCheck->validate(); if (Yii::$app->request->post()) { // 如果选择 wetsigned $post = Yii::$app->request->post(); if ($post['type'] == 'wetsigned') { //关闭sign agreements $task_e_sign_box = AppTask::findOne(['id_application' => $model->id_application, 'id_app_task_type' => DictTask::TYPE_SIGN_AGREEMENTS_BOX]); AppTask::close($task_e_sign_box->id_app_task); } // 确认 Application Review and Check 结束 $applicationModel = $model->application; //g3 AppDocument::createPdfByApplication($applicationModel, DictDocument::TYPE_G3); //control_agreement AppDocument::createPdfByApplication($applicationModel, DictDocument::TYPE_CONTROL_AGREEMENT); //line_agreements AppDocument::createPdfByApplication($applicationModel, DictDocument::TYPE_LINE_AGREEMENT); //w9 AppDocument::createPdfByApplication($applicationModel, DictDocument::TYPE_W9); $loanModel->id_application = $applicationModel->id_application; $id_application = $loanModel->id_application; //active log.loan officer approved the application. Active::operationLog($id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name], DictActive::APPROVED_APPLICATION, Yii::$app->user->getIdentity()->id); AppTask::taskFinish($id_app_task); //find Control Agreement--type--schwab(control agreement->id_application->id_group->Coustidian) $application = Application::find()->andWhere(['id_application' => $id_application])->one(); $group = Group::find()->andWhere(['id_group' => $application->id_group])->one(); //judge for id_custodian //send application approval email to client and cc to advisor(email($email_type,[$task_type,$id_app_task,$loan,$group])) $res = SendEmail::email(DictEmail::EMAIL_LETTER_ABOUT_LINE, [DictEmail::LETTER_APPLICATION_APPROVAL, $id_app_task, $loanModel, $group]); if ($res) { //判断是否有两个client参与 $user = SendEmail::findUserByApplication($id_application); if (is_null($user['co_applicant'])) { Active::operationLog($id_application, [$user['applicant']->first_name, $user['applicant']->last_name, '', $user['advisor']->first_name, $user['advisor']->last_name], DictActive::SYSTEM_SEND_APPROVAL_LETTER, 0); } else { Active::operationLog($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_APPROVAL_LETTER, 0); } } //active.system geneerated all the line agreements Active::operationLog($id_application, [], DictActive::SYSTEM_GENERATED_LINE_AGREEMENTS, 0); //find user $user = SendEmail::findUserByApplication($id_application); //create a task line-agreement to loan officer Active::operationLog($model->id_application, [DictTask::$taskType[DictTask::TYPE_LINE_AGREEMENTS], $user['supernova']->first_name, $user['supernova']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0); //system created task line-agreements //System send email new task "Line Agrrements Notification" to betterdebt($email_type,[$task_type,$id_application,$id_app_task]) SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_LINE_AGREEMENTS, $id_application, $id_app_task + 2]); if ($post['type'] != 'wetsigned') { // docusign $result_docusign = SendDocuSign::appReview($id_application); } //crate a task sign-line-agreement to client Active::operationLog($model->id_application, [DictTask::$taskType[DictTask::TYPE_SIGN_AGREEMENTS], $user['applicant']->first_name, $user['applicant']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0); //system created task line-agreements Active::operationLog($model->id_application, [DictTask::$taskType[DictTask::TYPE_LINE_AGREEMENTS], $user['applicant']->first_name, $user['applicant']->last_name], DictActive::SYSTEM_SEND_DOCUSIGN_EMAIL, 0); //system send sign agreement docusign email to client return $this->redirect(['/application/view', 'id' => $model->id_application]); } $data = CollateralAccount::find()->andWhere(['line_type' => 1, 'id_line' => $model->id_application])->orderBy(['data_date' => SORT_DESC])->one(); if ($data) { $account = CollateralAccount::find()->andWhere(['line_type' => 1, 'id_line' => $model->id_application, 'data_date' => $data['data_date']])->orderBy(['data_date' => SORT_DESC])->all(); $line_account = LineAccount::find()->andWhere(['line_type' => 1, 'id_line' => $model->id_application, 'data_date' => $data['data_date']])->orderBy(['data_date' => SORT_DESC])->one(); } else { $account = ''; $line_account = ''; } //credit score $applicant = AppApplicant::find()->andWhere(['id_application' => $model->id_application])->all(); return $this->render('index', ['model' => $model, 'loanModel' => $loanModel, 'checkPoints' => $checkPoints, 'approve_ctrl' => $check_points_ctrl && $loan_ctrl, 'collateral_account' => $account, 'line_account' => $line_account, 'date' => empty($data) ? '' : $data['data_date'], 'applicant' => empty($applicant) ? '' : $applicant]); }
public function getPrimaryAdvisor() { $a = AppApplicant::find()->andWhere(['id_user' => Yii::$app->user->getId()])->one(); return AppUser::find()->joinwith('appApplicant')->joinwith('user')->andWhere(['app_applicant.id_user' => Yii::$app->user->getId(), 'app_applicant.id_application' => $a['id_application'], 'is_primary_contact' => 1, 'id_user_role' => Dict::USER_ROLE_ADVISOR]); }
<?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 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]); }
public function actionGetClientByIdGroup($selected = null) { if (isset($_POST['depdrop_all_params'])) { $id = $_POST['depdrop_all_params']['application-id_group']; $models = Client::find()->andWhere(['id_group' => $id])->all(); foreach ($models as $model) { //验证client是否无active application与loan $canAdd = true; if (Yii::$app->params['uniqueSelectClient']) { $applicants = AppApplicant::find()->andWhere(['id_user' => $model->id_user])->all(); foreach ($applicants as $applicant) { if (isset($applicant->application) && $applicant->application->id_application_status == 1 || isset($applicant->application->loan) && $applicant->application->loan->status == 1) { $canAdd = false; } } } if ($canAdd) { $output[] = ['id' => $model->id_user, 'name' => $model->user->first_name . ' ' . $model->user->last_name]; } } if (isset($output)) { echo json_encode(['output' => $output, 'selected' => $selected]); } else { echo json_encode(['output' => '', 'selected' => '']); } } }
use kartik\widgets\DatePicker; use common\models\AppFormStatus; use common\models\Application; use common\models\AppTask; use common\models\AppApplicant; use common\models\AppFormCollateralAccount; use yii\base\Object; $application = Application::findOne($model->id_application); $identity = Yii::$app->user->getIdentity(); // 获取与application有关的client用户id_users $id_users = $model->ownerUser; foreach ($id_users as $val) { $id_client[] = $val; } // 读取申请人身份信息 $applicants = AppApplicant::find()->andWhere(['id_application' => $model->id_application])->all(); // 生成 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 */ $this->title = Yii::t('app', 'Supplemental Materials');