예제 #1
0
 /**
  * 邀请邮件发送方法
  * @param $userModel  用户数据对象 
  */
 public function invite($userModel)
 {
     if (!empty($userModel)) {
         if (SendEmail::email(DictEmail::EMAIL_INVITE_USER, [$userModel])) {
             $massage = "Successfully invitation [ " . $userModel->email . " ]";
         } else {
             $massage = "SendEmail Fail, Please Send Again";
         }
     } else {
         $massage = "User not existing";
     }
     return $massage;
 }
예제 #2
0
 public function actionInvite($id)
 {
     // create invite
     $model = $this->findModel($id);
     $userModel = User::find()->andWhere(['id_user_role' => $this->_roleId, 'id_user' => $model->id_user])->one();
     if (!empty($userModel)) {
         // check email existing
         $message = "Invitation sent successfully to " . $userModel->email;
         //send invite email
         SendEmail::email(DictEmail::EMAIL_INVITE_USER, [$userModel]);
     } else {
         $message = "User not existing";
     }
     return $this->render('invite', ['model' => $model, 'message' => $message]);
 }
예제 #3
0
 /**
  * Send forgot email
  *
  * @return bool
  */
 public function sendForgotEmail()
 {
     /** @var Mailer $mailer */
     /** @var Message $message */
     /** @var   $userKey */
     // validate
     if ($this->validate()) {
         $user = $this->getUser();
         // calculate expireTime (converting via strtotime)
         $expireTime = $this->_resetKeyExpiration;
         //send email
         $result = SendEmail::email(DictEmail::EMAIL_FORGOT_PASSWORD, [$user, $expireTime]);
         return $result;
     }
     return false;
 }
 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 actionIndex($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     $UploadModel = new AppDocument();
     if (Yii::$app->request->post()) {
         //active log
         Active::operationLog($model->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, DictTask::$taskType[DictTask::TYPE_LINE_AGREEMENTS]], DictActive::USER_UPLOADED_WET_SIGNED_FILE, Yii::$app->user->getIdentity()->id_user);
         Active::operationLog($model->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'finished', DictTask::$taskType[DictTask::TYPE_LINE_AGREEMENTS]], DictActive::USER_FINISH_TASK, Yii::$app->user->getIdentity()->id_user);
         // Finish Task
         if (AppTask::taskFinish($id_app_task)) {
             //find user
             $user = SendEmail::findUserByApplication($model->id_application);
             //active log. system create a task line setup  to loan officer
             Active::operationLog($model->id_application, [DictTask::$taskType[DictTask::TYPE_LINE_SETUP], $user['supernova']->first_name, $user['supernova']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
             //send email to notification supernova  task Line Setup
             SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_LINE_SETUP, $model->id_application, $id_app_task]);
             //0:表示没有传递id_app_owner_task
         }
         if ($this->user->id_user_role == Dict::USER_ROLE_CLIENT) {
             return $this->redirect(['/loan/application']);
         } else {
             return $this->redirect(['/application/view', 'id' => $model->id_application]);
         }
     }
     //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]);
 }
 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]);
 }
예제 #7
0
 public function actionSubmitEsign($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     $application = $model->application;
     $appFormModel = $application->appForm;
     $appFormModel->load(Yii::$app->request->get());
     $appFormModel->save(false);
     $appFormModel->setScenario('disclosures');
     $status = $appFormModel->validate(true);
     AppFormStatus::changeStatus($application->id_application, 4, $status);
     //检查AppForm所有项是否正确填写
     $result = $application->checkAppForm();
     if (Yii::$app->request->post()) {
         // docusign
         $result_docusign = SendDocuSign::appForm($application->id_application);
         // Finish Task
         AppTask::taskFinish($id_app_task);
         //active log. client submit app-form
         Active::operationLog($application->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'submitted', DictTask::$taskType[DictTask::TYPE_APPLICATION_FORM]], DictActive::USER_FINISH_TASK, Yii::$app->user->getIdentity()->id);
         //find user
         $res = SendEmail::findUserByApplication($application->id_application);
         //active log. system create task sing-app-form and assign to client/advisor
         Active::operationLog($application->id_application, [DictTask::$taskType[DictTask::TYPE_SIGN_APPLICATION_FORM], $res['advisor']->first_name, $res['advisor']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
         //system assign to advisor
         Active::operationLog($application->id_application, [DictTask::$taskType[DictTask::TYPE_SIGN_APPLICATION_FORM], $res['applicant']->first_name, $res['applicant']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
         //system assign to client
         if (!is_null($res['co_applicant'])) {
             Active::operationLog($application->id_application, [DictTask::$taskType[DictTask::TYPE_SIGN_APPLICATION_FORM], $res['co_applicant']->first_name, $res['co_applicant']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
             //system assign to co_client
         }
         //active log. system send docusign task email to user
         Active::operationLog($application->id_application, [DictTask::$taskType[DictTask::TYPE_APPLICATION_FORM], $res['advisor']->first_name, $res['advisor']->last_name], DictActive::SYSTEM_SEND_DOCUSIGN_EMAIL, 0);
         //system send docusign email to advisor
         Active::operationLog($application->id_application, [DictTask::$taskType[DictTask::TYPE_APPLICATION_FORM], $res['applicant']->first_name, $res['applicant']->last_name], DictActive::SYSTEM_SEND_DOCUSIGN_EMAIL, 0);
         //system send docusign email to client
         //active log. system create task supplemental-materials and assign to advisor
         Active::operationLog($application->id_application, [DictTask::$taskType[DictTask::TYPE_SUPPLEMENTAL_MATERIALS], $res['advisor']->first_name, $res['advisor']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
         //System send email new task “Supplemental materials Notification” to client
         SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_SUPPLEMENTAL_MATERIALS, $application->id_application, $id_app_task + 2]);
         //id_app_task_type:1(app-form);0:表示没有传递id_app_task
         if ($this->user->id_user_role == Dict::USER_ROLE_CLIENT) {
             return $this->redirect(['/loan/application']);
         } else {
             return $this->redirect(['/application/view', 'id' => $application->id_application]);
         }
     }
     return $this->renderAjax('submit_esign', ['model' => $model, 'result' => $result]);
 }
 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]);
 }
예제 #9
0
 /**
  * Deletes an existing Application model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionIndex()
 {
     $documents_type = ['app_form.pdf' => DictDocument::TYPE_APPLICATION_FORM, 'loan_agreements.pdf' => DictDocument::TYPE_LINE_AGREEMENT, 'g3.pdf' => DictDocument::TYPE_G3, 'w9.pdf' => DictDocument::TYPE_W9];
     // log
     Yii::getLogger()->log(date("Y-m-d h:i:s", time()) . ' - 开始一次定时任务', Logger::LEVEL_ERROR);
     $dir = Yii::$app->params['outpdfPath'];
     $envelopes_data = DocusignRecipient::find()->andWhere(['status' => 0])->all();
     $envelopes = [];
     foreach ($envelopes_data as $val) {
         $envelopes[] = $val->id_envelope;
     }
     $envelopes = array_unique($envelopes);
     if (count($envelopes) > 0) {
         // DocuSign
         $client = new DocuSign_Client();
         $service = new DocuSign_StatusService($client);
         // Status
         foreach ($envelopes as $id_envelope) {
             $response = $service->status->getRecipientsStatus($id_envelope);
             $signers = $response->signers;
             foreach ($signers as $val) {
                 if ($val->status == 'completed') {
                     // DocusignRecipient
                     $recipient = DocusignRecipient::find()->andWhere(['email' => $val->email, 'id_envelope' => $id_envelope])->one();
                     $user = User::findOne($recipient->id_user);
                     if (isset($recipient) && isset($user) && $recipient->status == 0) {
                         // 获取在线文件
                         $task = AppTask::findOne($recipient->id_app_task);
                         //active log  after E-signed documents
                         switch ($task->id_app_task_type) {
                             case DictTask::TYPE_SIGN_APPLICATION_FORM:
                                 Active::operationLog($recipient->id_application, [$user->first_name, $user->last_name, DictTask::$taskType[DictTask::TYPE_APPLICATION_FORM]], DictActive::USER_DOCSIGNED_TASK, $user->id_user);
                                 break;
                             case DictTask::TYPE_SIGN_AGREEMENTS:
                                 Active::operationLog($recipient->id_application, [$user->first_name, $user->last_name, DictTask::$taskType[DictTask::TYPE_LINE_AGREEMENTS]], DictActive::USER_DOCSIGNED_TASK, $user->id_user);
                                 break;
                         }
                         $service_document = new DocuSign_EnvelopeService($client);
                         $document_all = $service_document->envelope->getEnvelopeDocuments($id_envelope);
                         foreach ($document_all->envelopeDocuments as $document) {
                             if ($document->type == 'content') {
                                 Yii::getLogger()->log(date("Y-m-d h:i:s", time()) . ' - 将' . $user->first_name . '.' . $user->last_name . '(id_user:'******')' . '-的签名改为已完成-' . $id_envelope, Logger::LEVEL_ERROR);
                                 $file = $dir . $recipient->id_application . '_' . $document->name;
                                 // 删除旧文件
                                 if (file_exists($file)) {
                                     unlink($file);
                                 }
                                 // 读取 Docusign 新文件
                                 $content = $service_document->envelope->getEnvelopeDocuments($id_envelope, $document->documentId);
                                 // 写入文件
                                 $fp = @fopen($file, 'a');
                                 fwrite($fp, $content);
                                 fclose($fp);
                                 // 上传 document
                                 $id_document_type = $documents_type[$document->name];
                                 $result = Upload::uploadFileByApplication($recipient->id_application, $file, $document->name, $id_document_type);
                                 if ($result) {
                                     //delete local file
                                     $outpdf_file = $dir . $recipient->id_application . '_' . $document->name;
                                     if (file_exists($outpdf_file)) {
                                         unlink($outpdf_file);
                                     }
                                     //active log (0:present send by System)
                                     foreach (DictDocument::$documentType as $key => $val) {
                                         switch ($id_document_type) {
                                             case $key:
                                                 Active::operationLog($recipient->id_application, [$val], DictActive::SYSTEM_UPDATED_TASK_WITH_SIGNATURE, 0);
                                                 break;
                                         }
                                     }
                                 }
                             }
                         }
                         // 变更 DocusignRecipient Status
                         $recipient->status = 1;
                         $recipient->save(false);
                         // 变更 Task Status
                         Yii::getLogger()->log(date("Y-m-d h:i:s", time()) . ' - 变更 task status (id_app_task:' . $recipient->id_app_task . ')', Logger::LEVEL_ERROR);
                         if (AppTask::taskFinish($recipient->id_app_task)) {
                             //再次查询task (finish之后的appTask,每次子task完成之后会相应的改变父类task的status)
                             $after_task = AppTask::findOne($recipient->id_app_task);
                             $parent_status = $after_task->parent->status;
                             if ($parent_status == DictTask::STATUS_FINISH) {
                                 //find user
                                 $user = SendEmail::findUserByApplication($recipient->id_application);
                                 if ($after_task->parent->id_app_task_type == DictTask::TYPE_SIGN_APPLICATION_FORM_BOX) {
                                     //system created a task 'Review Application' to loan officer
                                     Active::operationLog($recipient->id_application, [DictTask::$taskType[DictTask::TYPE_APPLICATION_REVIEW], $user['supernova']->first_name, $user['supernova']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
                                     //send email to supernova start task Application Review
                                     SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_APPLICATION_REVIEW, $recipient->id_application, $after_task->parent->id_app_task, DictTask::DOCUSIGN_NOTIFICATION]);
                                 } elseif ($after_task->parent->id_app_task_type == DictTask::TYPE_SIGN_AGREEMENTS_BOX) {
                                     //active log.system closed the task 'line Agreement'
                                     Active::operationLog($recipient->id_application, [DictTask::$taskType[DictTask::TYPE_LINE_AGREEMENTS]], DictActive::SYSTEM_CLOSED_TASK, 0);
                                     //active log. system create task line set-up and assign to client/advisor
                                     Active::operationLog($recipient->id_application, [DictTask::$taskType[DictTask::TYPE_LINE_SETUP], $user['supernova']->first_name, $user['supernova']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
                                     //system created task line-setup
                                     //send email to supernova start task Line Setup
                                     SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_LINE_SETUP, $recipient->id_application, $after_task->parent->id_app_task, DictTask::DOCUSIGN_NOTIFICATION]);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     Yii::getLogger()->log(date("Y-m-d h:i:s", time()) . ' - 完成 ---------------------', Logger::LEVEL_ERROR);
 }
예제 #10
0
 /**
  * Creates a new Application model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Application();
     $appModel = new AppApplicant(['scenario' => 'primary-create']);
     $coAppModel = new AppApplicant(['scenario' => 'co-create']);
     $appFormModel = new AppForm();
     //加载数据并验证
     if ($model->load(Yii::$app->request->post()) && $appModel->load(Yii::$app->request->post()) && $coAppModel->load(Yii::$app->request->post()) && $appFormModel->load(Yii::$app->request->post()) && $model->validate() && $appModel->validate() && ($model->is_joint_application == 1 ? $coAppModel->validate() : true) && ($model->is_joint_application == 1 ? $appModel->email_address != $coAppModel->email_address : true)) {
         //开启事务
         $transaction = Yii::$app->db->beginTransaction();
         try {
             if (!$appModel->id_user) {
                 $user = User::createUser(Dict::USER_ROLE_CLIENT, ['User' => ['first_name' => $appModel->first_name, 'last_name' => $appModel->last_name, 'mid_name' => $appModel->mid_name, 'email' => $appModel->email_address], 'Client' => ['id_group' => $model->id_group]]);
                 //设置applicant的id_user
                 $appModel->id_user = $user->id_user;
                 SendEmail::email(DictEmail::EMAIL_INVITE_USER, [$user]);
             }
             if ($model->is_joint_application && !$coAppModel->id_user) {
                 $user = User::createUser(Dict::USER_ROLE_CLIENT, ['User' => ['first_name' => $coAppModel->first_name, 'last_name' => $coAppModel->last_name, 'mid_name' => $coAppModel->mid_name, 'email' => $coAppModel->email_address], 'Client' => ['id_group' => $model->id_group]]);
                 //设置co-applicant的id_user
                 $coAppModel->id_user = $user->id_user;
                 SendEmail::email(DictEmail::EMAIL_INVITE_USER, [$user]);
             }
             $model->application_name = $appModel->first_name . ($model->is_joint_application ? ' and ' . $coAppModel->first_name : '') . "'s application";
             $model->charge_fee = Advisor::findOne(['id_user' => Yii::$app->user->getId()])->will_charge_fee;
             if (!$model->save()) {
                 $transaction->rollBack();
             }
             $user = Yii::$app->user->getIdentity();
             Active::operationLog($model->id_application, [$user->first_name, $user->last_name], DictActive::CREATE_APPLICATION, $user->id);
             $appModel->id_application = $model->id_application;
             $appModel->id_app_applicant_type = 1;
             if (!$appModel->save()) {
                 $transaction->rollBack();
             }
             if ($model->is_joint_application == 1) {
                 $coAppModel->id_application = $model->id_application;
                 $coAppModel->id_app_applicant_type = 2;
                 if (!$coAppModel->save()) {
                     $transaction->rollBack();
                 }
             }
             $appFormModel->id_application = $model->id_application;
             if (!$appFormModel->save()) {
                 $transaction->rollBack();
             }
             //初始化任务
             AppTask::initialize($model->id_application);
             // 将AppTaskCheckpoint中的模板转换为实例
             AppTaskCheckpoint::initialize($model->appTask);
             //创建AppUser记录
             AppUser::createByApplication($model);
             //send email to notificate advisor create application success.method email([$task_type,$id_application,$id_app_owner_task],$notify_type)
             SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_APPLICATION_FORM, $model->id_application, 0]);
             //id_app_owner_task_type:1(app-form);0:表示没有传递id_app_owner_task
             $transaction->commit();
         } catch (Exception $e) {
             $transaction->rollBack();
         }
         return $this->redirect(['/app-form/basic-info', 'id_application' => $model->id_application]);
     }
     return $this->render('create', ['model' => $model, 'appModel' => $appModel, 'coAppModel' => $coAppModel, 'appFormModel' => $appFormModel]);
 }
예제 #11
0
 /**
  * Send email confirmation to user
  *
  * @param UserKey $userKey
  * @return int
  */
 public function sendEmailConfirmation($userKey)
 {
     /** @var Mailer $mailer */
     /** @var Message $message */
     //send email to new_mail user(email($email_type,[$to_user,$userKey]))
     $result = SendEmail::email(DictEmail::EMAIL_RESET_EMAIL, [$this, $userKey]);
     return $result;
 }
예제 #12
0
 public function actionDrawConfirm($id)
 {
     $model = new LoanDrawRequest();
     $model->id_user = Yii::$app->user->getId();
     $model->id_loan = $id;
     $model->status = 1;
     $loanModel = Loan::findOne($id);
     $loanBank = LoanBankAcount::find()->andWhere(['id_loan' => $id])->one();
     if (!$loanModel->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.");
     }
     $request = LoanDrawRequest::find()->where(['id_loan' => $loanModel->id_loan, 'status' => 1])->one();
     $request = is_null($request) ? [] : $request;
     if (count($request) > 0) {
         $model->addError('amount', 'Your draw request was submitted successfully!Better Debt is working on it.');
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //send draw request email to client (and cc to co_applicant).Method email($email_type,[$letter_type,$id_application,$user_type,$drawModel])
         SendEmail::email(DictEmail::EMAIL_LETTER_ABOUT_LINE, [DictEmail::LETTER_DRAW_REQUEST, $loanModel->id_application, DictEmail::DRAW_REQUEST_TYPE_CLIENT, $model]);
         //send draw request email to advisor.Method email($email_type,[$letter_type,$id_application,$user_type,$drawModel,$loanModel])
         SendEmail::email(DictEmail::EMAIL_LETTER_ABOUT_LINE, [DictEmail::LETTER_DRAW_REQUEST, $loanModel->id_application, DictEmail::DRAW_REQUEST_TYPE_ADVISOR, $model, $loanModel]);
         //send draw request email to betterdebt.Method email($email_type,[$letter_type,$id_application,$user_type,$drawModel,$loanModel])
         SendEmail::email(DictEmail::EMAIL_LETTER_ABOUT_LINE, [DictEmail::LETTER_DRAW_REQUEST, $loanModel->id_application, DictEmail::DRAW_REQUEST_TYPE_LOAN_OFFICER, $model, $loanModel]);
         return $this->render('draw_success');
     } else {
         return $this->render('draw_confirm', ['model' => $model, 'loanModel' => $loanModel, 'loanBank' => is_null($loanBank) ? new LoanBankAcount() : $loanBank, 'request' => $request]);
     }
 }
예제 #13
0
 public function actionClose($id_application, $id_app_task_type_close, $id_app_task_type_open)
 {
     if (Yii::$app->request->isPost) {
         $app_tasks = AppTask::getTaskByType($id_application, $id_app_task_type_close);
         foreach ($app_tasks as $task) {
             // 关闭签名信封
             $result = DocusignRecipient::find()->where(['id_app_task' => $task->id_app_task])->one();
             $result->delete = Dict::DELETE_YES;
             $result->save(false);
             //active log .close task
             Active::operationLog($id_application, [DictTask::$taskType[DictTask::TYPE_APPLICATION_FORM]], DictActive::SYSTEM_CLOSED_TASK, 0);
             //delete local file
             $outpdf_file = Yii::$app->params['outpdfPath'] . $id_application . '_app_form.pdf';
             if (file_exists($outpdf_file)) {
                 unlink($outpdf_file);
             }
         }
         $id_app_task_type_close_box = 0;
         if (DictTask::TYPE_SIGN_APPLICATION_FORM == $id_app_task_type_close) {
             $id_app_task_type_close_box = DictTask::TYPE_SIGN_APPLICATION_FORM_BOX;
         } else {
             if (DictTask::TYPE_SIGN_AGREEMENTS == $id_app_task_type_close) {
                 $id_app_task_type_close_box = DictTask::TYPE_SIGN_AGREEMENTS_BOX;
             }
         }
         $task_e_sign_box = AppTask::find(false)->andWhere(['id_application' => $id_application, 'id_app_task_type' => $id_app_task_type_close_box])->one();
         AppTask::close($task_e_sign_box->id_app_task);
         $task_wet_sign = AppTask::find(false)->andWhere(['id_application' => $id_application, 'id_app_task_type' => $id_app_task_type_open])->one();
         $task_wet_sign->active = DictTask::ACTIVE;
         $task_wet_sign->delete = Dict::DELETE_NOT;
         $task_wet_sign->save();
         $task_wet_sign->nextStart($task_wet_sign->id_app_task);
         //id_app_task_type:1(app-form);0:表示没有传递id_app_task
         SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [$id_app_task_type_open, $id_application, 0]);
         return $this->redirect(['application/view', 'id' => $id_application]);
     }
     return $this->renderAjax('close', ['id_application' => $id_application, 'id_app_task_type_close' => $id_app_task_type_close, 'id_app_task_type_open' => $id_app_task_type_open]);
 }
예제 #14
0
 public function AssignTo($id_app_task, $owner_type)
 {
     $model = AppTask::find(false)->andWhere(['id_app_task' => $id_app_task])->one();
     $model->owner_type = $owner_type;
     if ($model->save()) {
         foreach (DictTask::$taskType as $key => $val) {
             switch ($model->id_app_task_type) {
                 case $key:
                     //active log 包含在发送邮件的方法中
                     SendEmail::email(DictEmail::EMAIL_TASK_ASSIGN_TO, [$model->id_application, $id_app_task, $owner_type, $key]);
                     break;
             }
         }
     }
 }