Ejemplo n.º 1
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 actionCheckPoint($id_app_task_checkpoint)
 {
     $model = AppTaskCheckpoint::findOne($id_app_task_checkpoint);
     if (Yii::$app->request->post()) {
         $model->status = true;
         $model->save(false);
         if ($model->save(false)) {
             if ($model->id_app_task_checkpoint_type == DictTask::LINE_IS_SET_UP) {
                 //对line-setup的checkout操作
                 //active log.checkout line-setup
                 Active::operationLog($model->appTask->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, DictTask::$taskType[DictTask::TYPE_LINE_SETUP], ''], DictActive::USER_UPDATE_TASK, Yii::$app->user->getIdentity()->id);
             } else {
                 //其余三个都是application-review的checkout
                 foreach (DictTask::$checkPointType as $key => $val) {
                     switch ($model->id_app_task_checkpoint_type) {
                         //active log.checkout application-review
                         case $key:
                             Active::operationLog($model->appTask->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, DictTask::$checkPointType[$model->id_app_task_checkpoint_type], DictTask::$taskType[DictTask::TYPE_APPLICATION_REVIEW]], DictActive::USER_REVIEWD_CHECK_POINT, Yii::$app->user->getIdentity()->id);
                     }
                 }
             }
         }
         return $this->redirect(AppTask::getSectionsUrl($model->appTask));
     }
     return $this->renderAjax('check_point', ['model' => $model]);
 }
Ejemplo n.º 2
0
 function actionIndex($id_application)
 {
     //$id_app_owner_task  actually is $id_application
     //$model = AppOwnerTask::findOne($id_app_owner_task);
     $UploadModel = new AppDocument();
     if (Yii::$app->request->isPost) {
         $type = intval(Yii::$app->request->post()['AppDocument']['id_document_type']);
         //$result = Upload::getFileUpload($id_application, $id_application, $type);
         $result = Upload::uploadFileByApplication($id_application, $_FILES['AppDocument']['tmp_name']['path'], $_FILES['AppDocument']['name']['path'], $type);
         //$model->appTask->id_application
         if (!empty($result)) {
             //delete the same file before upload a new one
             /*
             				$app_document = AppDocument::find()->andWhere(['id_application' => $id_application,'name' => $result['file_name'],'id_document_type' => $type])->one();
             				if (!empty($app_document)) {
             					$app_document->delete = 1;
             					$app_document->save();
             				}
             				$UploadModel->id_application = $id_application;
             				$UploadModel->path = $result['url'];
             				$UploadModel->name = $result['file_name'];
             				$UploadModel->id_document_type = $type;
             				$UploadModel->save();
             */
             //if ($UploadModel->save()) {
             //$id_app_owner_task  actually is $id_application
             //active log (betterdebt upload documents file)
             foreach (DictDocument::$documentType as $key => $val) {
                 switch ($type) {
                     case $key:
                         Active::operationLog($id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, DictDocument::$documentType[$type]], DictActive::USER_UPLOAD_FILE, Yii::$app->user->getIdentity()->id);
                         break;
                 }
             }
             echo "<script text='javascript'>alert('Upload Success!');history.go(-1) </script>";
         } else {
             echo "<script text='javascript'>alert('Failed,Please try again!');history.go(-1) </script>";
         }
         //}
     }
 }
 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]);
 }
Ejemplo n.º 4
0
 public static function taskAssignTo($type, $id_application, $id_app_task, $owner_type, $app_task_type)
 {
     $user = static::findUserByApplication($id_application);
     switch ($owner_type) {
         case DictTask::OWNER_CLIENT:
             $to_user = $user['applicant'];
             break;
         case DictTask::OWNER_ADVISOR:
             $to_user = $user['advisor'];
             break;
         case DictTask::OWNER_SUPERNOVA:
             $to_user = $user['supernova'];
             break;
     }
     $template = 'taskNotification';
     $subject = DictEmail::$emailType[$type];
     //active before send email
     $old_user = Yii::$app->user->getIdentity();
     Active::operationLog($id_application, [$old_user->first_name, $old_user->last_name, DictTask::$taskType[$app_task_type], $to_user->first_name, $to_user->last_name], DictActive::USER_ASIGN_TASK_TO, $old_user->id);
     return ['user' => $to_user, 'subject' => $subject, 'template' => $template, 'id_application' => $id_application, 'id_app_task' => $id_app_task, 'app_task_type' => $app_task_type];
 }
Ejemplo n.º 5
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]);
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 public function getActives()
 {
     return $this->hasMany(Active::className(), ['id_application' => 'id_application']);
 }
Ejemplo n.º 9
0
 public function actionChange($id_application, $id_user, $id_user_role)
 {
     $model = Application::findOne($id_application);
     $users = $model->users;
     $roles = [Dict::USER_ROLE_BETTERDEBT => 'Loan Officer', Dict::USER_ROLE_ADVISOR => 'Advisor', Dict::USER_ROLE_CLIENT => 'Client'];
     $user = User::find()->where(['id_user' => $id_user])->one();
     $userName = $user['first_name'] . " " . $user['last_name'];
     $userRole = $roles[$user->id_user_role];
     if (Yii::$app->request->post()) {
         $oldPrimaryAdvisor = $model->primaryAdvisor;
         $id_oldAdvisor = $oldPrimaryAdvisor['id_user'];
         $oldPrimarySupernova = $model->primarySupernova;
         $id_oldSupernova = $oldPrimarySupernova['id_user'];
         if ($id_user_role == Dict::USER_ROLE_ADVISOR) {
             $id_newAdvisor = $id_user;
             $id_newSupernova = $id_oldSupernova;
             //active.
             Active::operationLog($id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'advisor', $oldPrimaryAdvisor['first_name'], $oldPrimaryAdvisor['last_name'], $user['first_name'], $user['last_name']], DictActive::CHANGE_PRIMARY_USER, Yii::$app->user->getIdentity()->id_user);
         } elseif ($id_user_role == Dict::USER_ROLE_BETTERDEBT) {
             $id_newAdvisor = $id_oldAdvisor;
             $id_newSupernova = $id_user;
             Active::operationLog($id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'loan officer', $oldPrimarySupernova['first_name'], $oldPrimarySupernova['last_name'], $user['first_name'], $user['last_name']], DictActive::CHANGE_PRIMARY_USER, Yii::$app->user->getIdentity()->id_user);
         }
         $model->changePrimaryAdvisor($id_oldAdvisor, $id_newAdvisor, $id_application);
         $model->changePrimarySupernova($id_oldSupernova, $id_newSupernova, $id_application);
         return $this->redirect(['application/view', 'id' => $id_application]);
     }
     return $this->renderAjax('change_primary', ['id_application' => $id_application, 'id_user' => $id_user, 'id_user_role' => $id_user_role, 'model' => $model, 'userName' => $userName, 'userRole' => $userRole]);
 }
Ejemplo n.º 10
0
 public static function operationLog($id_application, $params = [], $type, $id_user)
 {
     $model = new Active();
     $model->id_application = $id_application;
     $model->id_user = $id_user;
     switch ($type) {
         case DictActive::CREATE_APPLICATION:
             $str = "%s %s created an application";
             //user created an application(%s %s firstname lastname)
             break;
         case DictActive::SYSTEM_CREATE_TASK_TO_USER:
             $str = "System created a task '%s' to %s %s";
             break;
         case DictActive::SYSTEM_ASIGN_TO:
             $str = "System assigned the task '%s' to %s %s";
             break;
         case DictActive::SYSTEM_SEND_DOCUSIGN_EMAIL:
             //system sent a docusign 'Application Form' email to advisor
             $str = "System sent a Docusign '%s' email to %s %s";
             break;
         case DictActive::USER_ASIGN_TASK_TO:
             $str = "%s %s assigned the task '%s' to %s %s";
             break;
         case DictActive::USER_UPDATE_TASK:
             $str = "%s %s updated the task '%s' %s";
             //user updated task taskname %s(on Basic Info)
             break;
         case DictActive::USER_FINISH_TASK:
             $str = "%s %s %s the task '%s'";
             //user finished/submitted the task name
             break;
         case DictActive::SYSTEM_SEND_NOTIFICATION_EMAIL:
             $str = "System send a new task '%s' notification email to %s %s";
             break;
         case DictActive::USER_DOCSIGNED_TASK:
             //user docusigned Application Form
             $str = "%s %s Docusigned the '%s'";
             break;
         case DictActive::USER_UPLOAD_FILE:
             $str = "%s %s uploaded 1 file under '%s'";
             break;
         case DictActive::USER_REMOVE_UPLOAD_FILE:
             $str = "%s %s removed 1 file %s from document '%s'";
             break;
         case DictActive::USER_REVIEWD_CHECK_POINT:
             //loan officer reviewed Documents in the task 'Application Review'
             $str = "%s %s reviewed %s in the task '%s'";
             break;
         case DictActive::APPROVED_APPLICATION:
             $str = "%s %s approved the application";
             break;
         case DictActive::SYSTEM_SEND_APPROVAL_LETTER:
             $str = "System sent an email 'Application Approval Letter' to %s %s %s and %s %s";
             //(%s(applicant_firstname), %s(applicant_lastname), %s (,co_applicant_firstname.co_applicant_firstname))
             break;
         case DictActive::SYSTEM_GENERATED_LINE_AGREEMENTS:
             $str = "System generated all the Line Agreements";
             break;
         case DictActive::SYSTEM_UPDATED_TASK_WITH_SIGNATURE:
             //about docusign
             $str = "System updated the %s with signature";
             break;
         case DictActive::SYSTEM_CLOSED_TASK:
             $str = "System closed the task '%s'";
             break;
         case DictActive::USER_UPLOADED_WET_SIGNED_FILE:
             //client uploaded wetsigned app-form
             $str = "%s %s uploaded wetsigned %s";
             break;
         case DictActive::SYSTEM_SEND_LINE_ALIVE_LETTER:
             $str = "System sent an email 'Your BriteLine is Live' to  %s %s %s and %s %s";
             break;
         case DictActive::SYSTEM_CLOSED_THE_APPLICATION:
             $str = "System closed the application";
             break;
         case DictActive::CHANGE_PRIMARY_USER:
             //advisor1 changed the primary supernova/advisor from advisor1 to advisor2
             $str = "%s %s changed the primary %s from %s %s to %s %s";
             break;
     }
     eval('$str = sprintf($str,\'' . implode('\',\'', $params) . '\');');
     $model->description = $str;
     return $model->save(false);
 }
Ejemplo n.º 11
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]);
 }
 public function actionRemove($id, $id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     $UploadModel = AppDocument::findOne($id);
     $UploadModel->delete = 1;
     if ($UploadModel->save()) {
         //active log6 (client remove file from supplementalinformation)
         $type = $UploadModel->id_document_type;
         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, $UploadModel->name, DictDocument::$documentType[$type]], DictActive::USER_REMOVE_UPLOAD_FILE, Yii::$app->user->getIdentity()->id);
                     break;
             }
         }
     }
     //delete from s3
     // 		Upload::removeFile($UploadModel->name,$this->user->id,$UploadModel->id_document_type);
     //delete form local
     $type = $UploadModel->id_document_type;
     foreach (DictDocument::$documentPath as $key => $value) {
         switch ($type) {
             case $key:
                 $fileName = $value;
                 break;
         }
     }
     $file = Yii::getAlias('@frontend') . '/web/uploads/' . $fileName . $this->user->id . '/' . $UploadModel->name;
     if (file_exists($file)) {
         unlink($file);
     }
     return $this->redirect(['task-supplemental-information/index', 'id_app_task' => $id_app_task]);
 }
 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]);
 }