/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AppFormCollateralAccount::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id_app_form_collateral_account' => $this->id_app_form_collateral_account, 'id_application' => $this->id_application, 'id_collateral_account_type' => $this->id_collateral_account_type, 'has_regular_distribution' => $this->has_regular_distribution, 'regular_distribution_amount' => $this->regular_distribution_amount, 'is_trust_account' => $this->is_trust_account, 'is_revocable' => $this->is_revocable, 'tax_id_type' => $this->tax_id_type, 'address_state_where_organized' => $this->address_state_where_organized, 'delete' => $this->delete, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'account_name_title', $this->account_name_title])->andFilterWhere(['like', 'registration', $this->registration])->andFilterWhere(['like', 'custodian', $this->custodian])->andFilterWhere(['like', 'account_number', $this->account_number])->andFilterWhere(['like', 'payee', $this->payee])->andFilterWhere(['like', 'trust_name', $this->trust_name])->andFilterWhere(['like', 'names_of_trustees', $this->names_of_trustees])->andFilterWhere(['like', 'tax_id', $this->tax_id])->andFilterWhere(['like', 'address_street', $this->address_street])->andFilterWhere(['like', 'address_city', $this->address_city])->andFilterWhere(['like', 'trustee_phone_number', $this->trustee_phone_number]);
     return $dataProvider;
 }
예제 #2
0
 public function afterSave($insert, $changeAttributes)
 {
     if ($insert) {
         $applicationModel = $this->application;
         $primaryAppApplicant = $applicationModel->primaryAppApplicant;
         $coAppApplicant = $applicationModel->coAppApplicant;
         $loanBorrowerModel = new LoanBorrower();
         $loanBorrowerModel->id_loan = $this->id_loan;
         $loanBorrowerModel->id_user = $primaryAppApplicant->id_user;
         $loanBorrowerModel->type = 1;
         $loanBorrowerModel->save();
         if ($applicationModel->coAppApplicant) {
             $loanBorrowerModel = new LoanBorrower();
             $loanBorrowerModel->id_loan = $this->id_loan;
             $loanBorrowerModel->id_user = $coAppApplicant->id_user;
             $loanBorrowerModel->type = 0;
             $loanBorrowerModel->save();
         }
         $loanPaymentPreferenceModel = new LoanPaymentPreference();
         $loanPaymentPreferenceModel->id_loan = $this->id_loan;
         $loanPaymentPreferenceModel->type = 2;
         $loanPaymentPreferenceModel->ach_max_debtied_amount = 0;
         $loanPaymentPreferenceModel->ach_id_loan_bank_acount = 0;
         $loanPaymentPreferenceModel->save();
         $loanCollateralAccountModel = new LoanCollateralAccount();
         $loanCollateralAccountModel->id_loan = $this->id_loan;
         $loanCollateralAccountModel->id_institution = Advisor::findOne(['id_user' => $applicationModel->primaryAdvisor->id_user])->id_institution;
         $loanCollateralAccountModel->id_group = $applicationModel->id_group;
         $appFormCollateralAccountModels = AppFormCollateralAccount::find()->andWhere(['id_application' => $this->id_application])->all();
         foreach ($appFormCollateralAccountModels as $appFormCollateralAccountModel) {
             $newLoanCollateralAccountModel = clone $loanCollateralAccountModel;
             $newLoanCollateralAccountModel->load([$newLoanCollateralAccountModel->formName() => $appFormCollateralAccountModel->getAttributes()]);
             $newLoanCollateralAccountModel->save();
         }
     }
 }
예제 #3
0
 public function actionDeleteCollateral($id)
 {
     $model = AppFormCollateralAccount::findOne($id);
     $model->delete = Dict::DELETE_YES;
     $model->save();
     $appFormModel = AppForm::find()->andWhere(['id_application' => $model->id_application])->one();
     $appFormModel->save(false);
     return $this->redirect(['collateral-information', 'id_application' => $model->id_application]);
 }
예제 #4
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (!$insert) {
         if (isset($changedAttributes['delete']) && $changedAttributes['delete'] == 0 && $this->delete == 1) {
             //删除application时,同步删除抵押账户以及line
             AppFormCollateralAccount::updateAll(['delete' => 1], 'id_application = ' . $this->id_application);
             if ($this->loan) {
                 $this->loan->delete = 1;
                 $this->loan->save();
             }
             if ($this->appApplicants) {
                 foreach ($this->appApplicants as $applicant) {
                     $applicant->delete = 1;
                     $applicant->save();
                 }
             }
         }
     }
 }
예제 #5
0
        }
        ?>
                     </li>
                  </ul>
          <?php 
    }
    ?>
        </div>
     </div>
	<?php 
}
?>


    <?php 
$list = AppFormCollateralAccount::find()->andWhere(['id_application' => $model->id_application])->all();
if (!empty($list)) {
    foreach ($list as $value) {
        if ($value->is_trust_account == 1) {
            ?>
	<div class="account-form2 pb20">
          <div class="layout frame">
          <div class="layout-your-list por">
            <h2><?php 
            echo Yii::t('app', 'TRUSTEE CERTIFICATION');
            ?>
</h2>
            <p class="color-ba" style="padding-right: 135px"><?php 
            echo Yii::t('app', 'Please upload your Trustee Certification.');
            ?>
</p>
 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']);
 }
예제 #7
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;
 }
 public function actionUploadWebSigned($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     $UploadModel = new AppDocument();
     if (Yii::$app->request->post()) {
         //upload signed file
         // 			$type = intval(Yii::$app->request->get('type'));
         $type = intval(Yii::$app->request->post()['AppDocument']['id_document_type']);
         //$result = Upload::getFileUpload($id_app_task, $model->id_application, $type);
         $result = Upload::uploadFileByApplication($model->id_application, $_FILES['AppDocument']['tmp_name']['path'], $_FILES['AppDocument']['name']['path'], $type, 1);
         if (!empty($result)) {
             //delete local file(in file outpdf)
             switch ($type) {
                 case 5:
                     $outpdf_file = Yii::getAlias('@frontend') . "/web/outpdf/" . $model->id_application . '_loan_agreements.pdf';
                     if (file_exists($outpdf_file)) {
                         unlink($outpdf_file);
                     }
                     break;
                 case 6:
                     $outpdf_file = Yii::getAlias('@frontend') . "/web/outpdf/" . $model->id_application . '_g3.pdf';
                     if (file_exists($outpdf_file)) {
                         unlink($outpdf_file);
                     }
                     break;
                 case 7:
                     $outpdf_file = Yii::getAlias('@frontend') . "/web/outpdf/" . $model->id_application . '_w9.pdf';
                     if (file_exists($outpdf_file)) {
                         unlink($outpdf_file);
                     }
                     break;
             }
             //delete control file
             $collateral_account = AppFormCollateralAccount::find()->andWhere(['id_application' => $model->id_application])->one();
             $outpdf_file = Yii::getAlias('@frontend') . "/web/outpdf/" . $model->id_application . '_control_agreement_schwab_' . $collateral_account['account_number'] . '.pdf';
             if (file_exists($outpdf_file)) {
                 unlink($outpdf_file);
             }
             //active log (supernova upload line-agreements file)
             foreach (DictDocument::$documentType as $key => $val) {
                 switch ($type) {
                     case $key:
                         Active::operationLog($model->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, DictDocument::$documentType[$type]], DictActive::USER_UPLOADED_WET_SIGNED_FILE, Yii::$app->user->getIdentity()->id);
                         break;
                 }
             }
             //render to index(exit submit)
             return $this->redirect(['task-agreements/index', 'id_app_task' => $id_app_task]);
             //delete the same file before upload a new one
             /*
             				$app_document = AppDocument::find()->andWhere(['id_application' => $model->id_application,'name' => $result['file_name'],'id_document_type' => $type])->one();
             				if (!empty($app_document)) {
             					$app_document->delete = Dict::DELETE_YES;
             					$app_document->save();
             				}
             				$UploadModel->id_application = $model->id_application;
             				$UploadModel->path = $result['url'];
             				$UploadModel->name = $result['file_name'];
             				$UploadModel->id_document_type = $type;
             				$UploadModel->source = 1;
             				$UploadModel->save();
             */
         }
         //关闭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);
     }
     //find the latest one by document type and id_application
     $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();
     // check
     $finished_ctrl = true;
     if ($loanAgreements->source == 1 && $g3->source == 1 && $w9->source == 1) {
         $finished_ctrl = true;
     } else {
         $finished_ctrl = false;
     }
     return $this->render('index', ['model' => $model, 'UploadModel' => $UploadModel, 'loanAgreements' => $loanAgreements, 'g3' => $g3, 'w9' => $w9, 'finished_ctrl' => $finished_ctrl]);
 }