예제 #1
0
파일: Delay.php 프로젝트: pvol/flowmatrix
 /**
  * 保存延时原因
  * @param reason 延时原因
  * @param last_step 上个步骤
  * @param next_processing_time 下次执行时间
  */
 public function saveReason($reason, $last_step, $next_processing_time)
 {
     // 保存位置
     $flow = Model\Flow::find($this->flow->flow_id);
     if (empty($flow)) {
         throw new Exception("流程id不存在");
     }
     $flow_attr = $flow->getAttributes();
     $steps = Config::get('flow.' . $this->flow->tpl_name . '.steps');
     $runing_config = $steps[$flow_attr['current_step']];
     Model\Step::create(array('project_name' => $this->flow->tpl_name, 'flow_id' => $this->flow->flow_id, 'title' => $runing_config['title'], 'real_title' => $runing_config['title'], 'content' => '', 'real_content' => $reason, 'step' => $flow_attr['current_step'], 'status' => Util\Status::DELAY, 'created_user' => $user->name, 'created_role' => $flow->running_role));
     Model\Step::find($last_step)->update(['next_processing_time' => $next_processing_time]);
     return true;
 }
예제 #2
0
파일: Step.php 프로젝트: pvol/flowmatrix
 /** 
  * 流程关闭
  * 
  * @param project_name 项目名称
  * @param flow lib/flow类
  * 
  */
 public static function over($flow)
 {
     $user = User::info();
     $flow_mod = Model\Flow::find($flow->flow_id);
     if (empty($flow_mod)) {
         throw new Exception("流程id不存在");
     }
     $flow_info = $flow_mod->getAttributes();
     $steps = Config::get('flow.' . $flow->tpl_name . '.steps');
     $runing_config = $steps[$flow->running_step];
     // 如果之前已经有执行人
     if (!empty($flow_info['accepted_users'])) {
         $accepted_users = explode(",", $flow_info['accepted_users']);
         // 去除当前执行人
         $accepted_users_reverse = array_flip($accepted_users);
         unset($accepted_users_reverse[$user->name]);
         $accepted_users = array_flip($accepted_users_reverse);
         $accepted_users = implode(',', $accepted_users);
     }
     // 如果之前已经有执行人
     if (!empty($flow_info['accepted_roles'])) {
         $accepted_roles = explode(",", $flow_info['accepted_roles']);
         // 去除当前执行人
         $accepted_roles_reverse = array_flip($accepted_roles);
         unset($accepted_roles_reverse[$flow->running_role]);
         $accepted_roles = array_flip($accepted_roles_reverse);
         $accepted_roles = implode(',', $accepted_roles);
     }
     $content = Arr::get($flow->request, 'content');
     $real_content = Arr::get($flow->request, 'real_content');
     $flow_mod->update(array('accepted_users' => $accepted_users, 'accepted_roles' => $accepted_roles));
     $step = Model\Step::create(array('project_name' => $flow->tpl_name, 'flow_id' => $flow->flow_id, 'title' => $runing_config['title'], 'real_title' => $runing_config['title'], 'content' => $content, 'real_content' => $real_content, 'step' => $flow->running_step, 'status' => Status::OVER, 'created_user' => $user->name, 'created_role' => $flow->running_role));
     // 添加hook
     self::addHooks("after_step", $flow, $step, $flow->running_step, $flow->running_step, Status::OVER);
 }
예제 #3
0
 /**
  * 校验当前是否可以执行打回、跳过、通过、不通过、完成等流转动作
  * 
  * @param flow lib/flow类
  * 
  */
 public static function checkTransitionCondition($flow)
 {
     $user = User::info();
     $flow_mod = Model\Flow::find($flow->flow_id);
     if (empty($flow_mod)) {
         throw new Exception("流程id不存在");
     }
     $flow_info = $flow_mod->getAttributes();
     $accepted_users = explode(",", $flow_info['accepted_users']);
     if (!in_array($user->name, $accepted_users)) {
         throw new Exception("当前用户不在执行列表中!");
     }
     return true;
 }
예제 #4
0
파일: Action.php 프로젝트: pvol/flowmatrix
 /**
  * 流转
  */
 private function turnTo($dest_action, $dest_status)
 {
     $flow_id = $this->flow->flow_id;
     $flow = Model\Flow::find($flow_id);
     if (empty($flow)) {
         throw new Exception("流程id不存在");
     }
     $flow_info = $flow->getAttributes();
     $from = $flow_info['current_step'];
     // 目标步骤获取优先级 页面手动设置>系统配置
     if (isset($this->flow->request['dest'])) {
         $to = $this->flow->request['dest']['dest_step'];
         $dest_status = $this->flow->request['dest']['dest_status'];
     } else {
         $steps = Config::get('flow.' . $this->flow->tpl_name . '.steps');
         $current_config = $steps[$from];
         $to = $current_config[$dest_action];
     }
     // 校验是否可以流转
     Util\Condition::checkTransitionCondition($this->flow);
     // 流转
     Util\Step::turnTo($this->flow, $from, $to, $dest_status);
 }