Example #1
0
 public static function uploadFileByApplication($id_application, $sourcePath, $fileName, $id_document_type, $source = 0)
 {
     $FileName = $id_application . '_' . $fileName;
     $key = DictDocument::$documentPath[$id_document_type];
     if (Yii::$app->params['s3_upload']) {
         try {
             $s3 = Yii::$app->aws->createS3();
             $result = $s3->putObject(['SourceFile' => $sourcePath, 'Key' => $key . $FileName, 'ACL' => 'private', 'ServerSideEncryption' => 'AES256']);
         } catch (HttpException $e) {
             throw new BadRequestHttpException("RequestTimesout,please try again.");
         }
     }
     if (in_array($id_document_type, [1, 5, 6, 7])) {
         $appDocument = AppDocument::find()->andWhere(['id_application' => $id_application, 'id_document_type' => $id_document_type])->one();
     } else {
         $appDocument = AppDocument::find()->andWhere(['id_application' => $id_application, 'name' => $fileName, 'id_document_type' => $id_document_type])->one();
     }
     if (!$appDocument) {
         $appDocument = new AppDocument();
     }
     $appDocument->id_application = $id_application;
     $appDocument->name = $fileName;
     $appDocument->path = isset($result['ObjectURL']) ? $result['ObjectURL'] : 'outpdf/';
     $appDocument->id_document_type = $id_document_type;
     $appDocument->source = $source;
     $appDocument->save();
     return ['url' => isset($result['ObjectURL']) ? $result['ObjectURL'] : 'outpdf/', 'file_name' => str_replace(' ', '', $fileName)];
 }
 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()) {
         // 如果选择 wet­signed
         $post = Yii::$app->request->post();
         if ($post['type'] == 'wet­signed') {
             //关闭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'] != 'wet­signed') {
             // 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]);
 }
Example #3
0
    echo $w9['name'];
    ?>
</a></span>
						<a href="<?php 
    echo Url::to(['application/down-load', 'id_application' => $w9['id_application'], 'file_name' => $w9['name'], 'type' => $w9['id_document_type']]);
    ?>
" target="_blank"><span class="ico-01 pl10 ico-download">&#xe60c;</span></a>
					</dd>
				<?php 
}
?>
				</dl>

				<dl>
				<?php 
$control_agreement = AppDocument::find()->andWhere(['id_application' => $id_application, 'id_document_type' => DictDocument::TYPE_CONTROL_AGREEMENT])->orderBy(['id_app_document' => SORT_DESC])->all();
?>
					<dt style="margin-bottom:20px;display: <?php 
echo empty($control_agreement) ? 'none' : 'block';
?>
"><?php 
echo DictDocument::$documentType[DictDocument::TYPE_CONTROL_AGREEMENT];
?>
<button  type="button" class="btn btn-default fr ico-download" style="display:<?php 
echo Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_BETTERDEBT ? 'inline' : 'none';
?>
" data-toggle="modal" data-target="#myModal1" data-whatever="8">Add  Document</button></dt>
				<?php 
if (!empty($control_agreement)) {
    foreach ($control_agreement as $val) {
        ?>
 public function actionCheck($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     //find by document type
     $loanStatements = AppDocument::find()->andWhere(['id_document_type' => DictDocument::TYPE_LOAN_STATEMENT, 'id_application' => $model->id_application])->orderBy(['id_app_document' => SORT_DESC])->all();
     //display loan statement?
     $application = Application::find()->andWhere(['id_application' => $model->id_application])->one();
     if ($application->have_existing_loan == 1) {
         $loanStatements_display = 'list-item';
         //method of display
     }
     $accountStatements = AppDocument::find()->andWhere(['id_document_type' => DictDocument::TYPE_ACCOUNT_STATEMENT, 'id_application' => $model->id_application])->orderBy(['id_app_document' => SORT_DESC])->all();
     $photos = AppDocument::find()->andWhere(['id_document_type' => DictDocument::TYPE_PHOTO_ID, 'id_application' => $model->id_application])->orderBy(['id_app_document' => SORT_DESC])->all();
     $certification = AppDocument::find()->andWhere(['id_document_type' => DictDocument::TYPE_TRUSTEE_CERTIFICATION, 'id_application' => $model->id_application])->orderBy(['id_app_document' => SORT_DESC])->all();
     $account = AppFormCollateralAccount::find()->andWhere(['id_application' => $model->id_application])->one();
     if ($account->is_trust_account == 1) {
         $certification_display = 'list-item';
         //method of display
     }
     return $this->renderAjax('check', ['model' => $model, 'loanStatements' => $loanStatements, 'accountStatements' => $accountStatements, 'photos' => $photos, 'certification' => $certification, 'loanStatements_display' => isset($loanStatements_display) ? $loanStatements_display : 'none', 'certification_display' => isset($certification_display) ? $certification_display : 'none']);
 }
Example #5
0
 public function afterSave($insert, $changedAttributes)
 {
     //如果为新建,则同时创建AppFormStatus
     if ($insert) {
         AppFormStatus::createSections($this->id_application);
     }
     //生成app_form.pdf
     AppDocument::createPdfByApplication($this->application, DictDocument::TYPE_APPLICATION_FORM);
 }
 public function actionCheck($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     //find by document type
     $loanAgreements = AppDocument::find()->andWhere(['id_document_type' => DictDocument::TYPE_LINE_AGREEMENT, 'id_application' => $model->id_application])->orderBy(['id_app_document' => SORT_DESC])->one();
     $g3 = AppDocument::find()->andWhere(['id_document_type' => DictDocument::TYPE_G3, 'id_application' => $model->id_application])->orderBy(['id_app_document' => SORT_DESC])->one();
     $w9 = AppDocument::find()->andWhere(['id_document_type' => DictDocument::TYPE_W9, 'id_application' => $model->id_application])->orderBy(['id_app_document' => SORT_DESC])->one();
     return $this->renderAjax('check', ['model' => $model, 'loanAgreements' => $loanAgreements, 'g3' => $g3, 'w9' => $w9]);
 }