예제 #1
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (isset($_GET['id_application'])) {
             $appTaskModel = AppTask::find()->andWhere(['id_application' => $_GET['id_application'], 'id_app_task_type' => 1])->one();
             $this->appTaskModel = $appTaskModel;
         }
         return true;
     }
 }
예제 #2
0
 public function getAllTasksInProgress()
 {
     $_user = Yii::$app->user->getIdentity();
     // 查找用户所有正在活动的任务,不包括节点
     $app_tasks = AppTask::find()->andWhere(['id_application' => $this->id_application, 'child_relation_type' => DictTask::CHILD_RELATION_NULL, 'finish_type' => DictTask::FINISH_NULL, 'active' => DictTask::ACTIVE, 'status' => DictTask::STATUS_ACTIVE])->andWhere(['!=', 'owner_type', DictTask::$userRoleToOwner[$_user->id_user_role]])->andWhere(['!=', 'id_user', $_user->id_user])->all();
     return $app_tasks;
 }
예제 #3
0
 public static function recipient($id_application, $response, $id_app_task_type)
 {
     if (isset($response->envelopeId)) {
         $eSignTasks = AppTask::find()->where(['id_application' => $id_application, 'active' => DictTask::ACTIVE, 'id_app_task_type' => $id_app_task_type])->all();
         foreach ($eSignTasks as $task) {
             $docusign = new DocusignRecipient();
             $docusign->id_application = $id_application;
             $docusign->id_envelope = $response->envelopeId;
             $docusign->id_app_task = $task->id_app_task;
             $docusign->id_user = $task->id_user;
             $docusign->email = $task->user->email;
             $docusign->status = 0;
             $docusign->save(false);
         }
     }
     return true;
 }
예제 #4
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]);
 }
예제 #5
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;
             }
         }
     }
 }
 public function safeUp()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     // 读取 application
     $application_list = Application::find()->all();
     // application添加的2个字段primaty_advisor和primary_supernova补充完整
     foreach ($application_list as $application) {
         $id_application = $application->id_application;
         // 读取advisor
         $user_advisor = AppUser::find()->andWhere(['id_application' => $id_application, 'is_primary_contact' => 1])->joinWith('user')->andWhere(['id_user_role' => Dict::USER_ROLE_ADVISOR])->one();
         // 读取 supernova
         $user_supernova = AppUser::find()->andWhere(['id_application' => $id_application, 'is_primary_contact' => 1])->joinWith('user')->andWhere(['id_user_role' => Dict::USER_ROLE_BETTERDEBT])->one();
         $application->primary_advisor = $user_advisor->id_user;
         $application->primary_supernova = $user_supernova->id_user;
         $application->save();
         // 读取application初始化新的app_task和app_task_checkpoint
         AppTask::initialize($id_application);
         $app_task_list = AppTask::find()->andWhere(['id_application' => $id_application])->all();
         AppTaskCheckpoint::initialize($app_task_list);
         //读取app_owner_task_back和app_owner_task_checkpoint_back
         $app_owner_task_list = Yii::$app->db->createCommand("SELECT O.* FROM app_task_back AS T, app_owner_task_back as O where T.id_app_task = O.id_app_task and T.id_application = {$id_application}")->queryAll();
         $app_owner_task_checkpoint_list = Yii::$app->db->createCommand("SELECT B.* FROM app_task_back AS T, app_owner_task_checkpoint_back as B, app_owner_task_back as O where B.id_app_owner_task = O.id_app_owner_task and T.id_app_task = O.id_app_task and T.id_application = {$id_application}")->queryAll();
         // app_owner_task_back
         foreach ($app_owner_task_list as $app_owner_task_key => $app_owner_task) {
             $back_to_now = ['1' => DictTask::TYPE_APPLICATION_FORM, '2' => DictTask::TYPE_SIGN_APPLICATION_FORM, '3' => DictTask::TYPE_UPLOAD_WET­SIGNED_FORM, '4' => DictTask::TYPE_SUPPLEMENTAL_MATERIALS, '5' => DictTask::TYPE_APPLICATION_REVIEW, '6' => DictTask::TYPE_LINE_AGREEMENTS, '7' => DictTask::TYPE_SIGN_AGREEMENTS, '8' => DictTask::TYPE_LINE_SETUP];
             // 读取对应的 app_task
             $app_task_where = ['id_application' => $id_application, 'id_app_task_type' => $back_to_now[$app_owner_task['id_app_owner_task_type']]];
             if (in_array($app_owner_task['id_app_owner_task_type'], array('2', '7'))) {
                 $app_task_where['id_user'] = $app_owner_task['id_user'];
             }
             $app_task = AppTask::findOne($app_task_where);
             // 逻辑修正
             if ($app_owner_task['id_app_owner_task_type'] == 6 && $app_owner_task_list[$app_owner_task_key + 1]['delete'] == Dict::DELETE_NOT && $app_owner_task_list[$app_owner_task_key + 1]['id_app_owner_task_status'] != DictTask::STATUS_NOT_ACTIVE) {
                 AppTask::close($app_task->id_app_task);
             } else {
                 // 变更完成状态
                 switch ($app_owner_task['id_app_owner_task_status']) {
                     case DictTask::STATUS_ACTIVE:
                         $app_task->nextStart($app_task->id_app_task);
                         break;
                     case DictTask::STATUS_FINISH:
                         if ($app_task->active == DictTask::INACTIVE) {
                             $app_task->active = DictTask::ACTIVE;
                             $app_task->save();
                         }
                         $app_task->taskFinish($app_task->id_app_task);
                         break;
                 }
             }
             // 变更结束状态
             if ($app_owner_task['delete'] == Dict::DELETE_YES) {
                 AppTask::close($app_task->id_app_task);
             }
             // 变更任务所属人角色
             if ($app_task['id_app_task_type'] != DictTask::TYPE_SIGN_APPLICATION_FORM) {
                 if ($app_task['id_app_task_type'] != DictTask::TYPE_SIGN_AGREEMENTS) {
                     $id_user = $app_owner_task['id_user'];
                     $user = User::findOne(['id_user' => $id_user]);
                     $app_task->owner_type = DictTask::$userRoleToOwner[$user->id_user_role];
                     $app_task->save();
                 }
             }
             // 判断是否是签名任务
             if (in_array($app_owner_task['id_app_owner_task_type'], array('2', '7'))) {
                 // 找到对应的签名记录
                 $docusign_recipient = DocusignRecipient::find(false)->andWhere(['id_application' => $id_application, 'id_app_task' => $app_owner_task['id_app_owner_task']])->one();
                 if (isset($docusign_recipient)) {
                     // 找到新的 id_app_task
                     $app_task_new = AppTask::findOne(['id_application' => $id_application, 'id_user' => $app_owner_task['id_user'], 'id_app_task_type' => $back_to_now[$app_owner_task['id_app_owner_task_type']]]);
                     // 变更 id_app_task
                     $docusign_recipient->id_app_task = $app_task_new->id_app_task;
                     $docusign_recipient->save();
                 }
             }
         }
         // 变更app_task_checkpoint里面的status
         foreach ($app_owner_task_checkpoint_list as $app_owner_task_checkpoint) {
             $app_task_checkpoint = AppTaskCheckpoint::findOne(['id_application' => $id_application, 'id_app_task_checkpoint_type' => $app_owner_task_checkpoint['id_app_owner_task_checkpoint_type']]);
             $app_task_checkpoint->status = $app_owner_task_checkpoint['status'];
             $app_task_checkpoint->save();
         }
     }
 }