Exemple #1
0
 /**
  * 发布
  */
 public function publish()
 {
     $user = Util\User::info();
     // 如果没有保存过,需要先保存
     $flow = false;
     if (empty($this->flow->flow_id)) {
         $flow = $this->storage();
     }
     $steps = Config::get('flow.' . $this->flow->tpl_name . '.steps');
     $current = current($steps);
     $current_key = key($steps);
     $next_key = $current['createto'];
     // 校验是否可以流转
     Util\Condition::checkFlowOwner($this->flow);
     $now = date('Y-m-d H:i:s');
     $yzt_fileno = Config::get('yzt.config.file_num_start') . date("Ymd", strtotime($now)) . str_pad($this->flow->flow_id, 3, 0, STR_PAD_LEFT);
     Model\Flow::where('id', $this->flow->flow_id)->update(array('current_status' => Util\Status::ARRIVED, 'current_step' => $next_key, 'created_at' => $now, 'yzt_fileno' => $yzt_fileno));
     $step = Model\Step::create(array('project_name' => $this->flow->tpl_name, 'flow_id' => $this->flow->flow_id, 'title' => $current['title'], 'real_title' => $current['title'], 'content' => '新申请', 'real_content' => '新申请', 'step' => $current_key, 'status' => Util\Status::CREATE, 'created_user' => $user->name, 'created_role' => $this->flow->running_role));
     // 添加hook
     Util\Step::addHooks("after_step", $this->flow, $step, ZYD_STEP_APPLY, ZYD_STEP_APPLY, Util\Status::CREATE);
     return $flow;
 }
Exemple #2
0
 /** 
  * 流程关闭
  * 
  * @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);
 }
Exemple #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;
 }