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);
     $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]);
 }
 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]);
 }
 /**
  * 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);
 }
 public function actionWetSign($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     $result = $model->application->checkAppForm();
     if ($result['errorCount']) {
         return $this->renderAjax('wet_sign_errors', ['model' => $model, 'result' => $result]);
     }
     $UploadModel = new AppDocument();
     $WetSignForm = new WetSignForm();
     if (Yii::$app->request->isPost) {
         $type = intval(Yii::$app->request->get('type'));
         $id = $this->user->id;
         //$result = Upload::getFileUpload($id_app_task,$model->id_application,$type);
         $result = Upload::uploadFileByApplication($model->id_application, $_FILES['WetSignForm']['tmp_name']['wet_sign_path'], $_FILES['WetSignForm']['name']['wet_sign_path'], $type);
         if (!empty($result['url'])) {
             //upload success
             /*
                     		$UploadModel->id_application = $model->id_application;
                     		$UploadModel->path = $result['url'];
                     		$UploadModel->name = $result['file_name'];
                     		$UploadModel->id_document_type = $type;
                     		$UploadModel->save();
             */
             //关闭sign application form
             //完成app form 任务
             AppTask::taskFinish($model->id_app_task);
             $task_wet_sign = AppTask::findOne(['id_application' => $model->id_application, 'id_app_task_type' => DictTask::TYPE_UPLOAD_WET­SIGNED_FORM]);
             $task_wet_sign->active = DictTask::ACTIVE;
             $task_wet_sign->save();
             $task_wet_sign->nextStart($task_wet_sign->id_app_task);
             $task_e_sign_box = AppTask::findOne(['id_application' => $model->id_application, 'id_app_task_type' => DictTask::TYPE_SIGN_APPLICATION_FORM_BOX]);
             AppTask::close($task_e_sign_box->id_app_task);
             AppTask::taskFinish($task_wet_sign->id_app_task);
             //active log. client upload wet-signed app-form
             $user = SendEmail::findUserByApplication($model->id_application);
             //log.client uploaded wetsigned app-form
             Active::operationLog($model->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, DictTask::$taskType[DictTask::TYPE_APPLICATION_FORM]], DictActive::USER_UPLOADED_WET_SIGNED_FILE, Yii::$app->user->getIdentity()->id_user);
             /*
                     		$eSignTasks = AppTask::getTaskByType($model->id_application, 2);
                     		foreach ($eSignTasks as $task) {
                     			$task->delete = Dict::DELETE_YES;
                     			$task->save(false);
                     		}
             */
             //将 Upload Wet­Signed Form任务状态改为正常
             /*
                     		$wet_task = AppTask::getTaskByType($model->id_application, 3);
             	        	$wet_task[0]['delete'] = Dict::DELETE_NOT;
             	        	$wet_task[0]->save(false);
             */
             //结束Application Form 任务
             //AppTask::taskFinish($id_app_task);
             //结束 Upload Wet­Signed Form任务
             //AppTask::taskFinish($id_app_task);
             //active log. system create task supplemental-materials and assign to advisor
             Active::operationLog($model->id_application, [DictTask::$taskType[DictTask::TYPE_SUPPLEMENTAL_MATERIALS], $user['advisor']->first_name, $user['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, $model->id_application, $id_app_task + 2]);
             //id_app_task_type:1(app-form);0:表示没有传递id_app_task
             //active log (create task Application Review to loan officer)
             Active::operationLog($model->id_application, [DictTask::$taskType[DictTask::TYPE_APPLICATION_REVIEW], $user['supernova']->first_name, $user['supernova']->last_name], DictActive::SYSTEM_CREATE_TASK_TO_USER, 0);
             //System send email new task "Application Review Notification" to betterdebt
             SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_APPLICATION_REVIEW, $model->id_application, $id_app_task]);
             //id_app_task_type:1(app-form);0:表示没有传递id_app_task
         }
         if (Yii::$app->user->getIdentity()->id_user_role == Dict::USER_ROLE_CLIENT) {
             return $this->redirect(['loan/application']);
         } else {
             return $this->redirect(['application/view', 'id' => $model->id_application]);
         }
     }
     return $this->renderAjax('upload_websigned_form', ['WetSignForm' => $WetSignForm, 'id_app_task' => $id_app_task]);
 }
 public function actionFinished($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     if (Yii::$app->request->post()) {
         if (AppTask::taskFinish($id_app_task)) {
             Active::operationLog($model->id_application, [Yii::$app->user->getIdentity()->first_name, Yii::$app->user->getIdentity()->last_name, 'finished', DictTask::$taskType[DictTask::TYPE_SUPPLEMENTAL_MATERIALS]], DictActive::USER_FINISH_TASK, Yii::$app->user->getIdentity()->id);
         }
         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]);
         }
     }
 }
 public function actionSign($id_app_task)
 {
     $model = AppTask::findOne($id_app_task);
     if (Yii::$app->request->post()) {
         AppTask::taskFinish($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' => $model->id_application]);
         }
     }
     return $this->render('sign', ['model' => $model]);
 }