You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
3.5 KiB
146 lines
3.5 KiB
<?php
|
|
|
|
class Subflow
|
|
{
|
|
private $form_key;
|
|
private $seq = 0;
|
|
public $current_assigner;
|
|
private $real_id;
|
|
private $receive_date;
|
|
private $pre_finish_date;
|
|
#会签 状态 S0001
|
|
const SUSPEND_STATE = "S0001";
|
|
|
|
public function __construct(Flow $flow)
|
|
{
|
|
if ($flow->getFormKey() == null) {
|
|
$this->form_key = Flow::getNewFormKey();
|
|
} else {
|
|
$this->form_key = $flow->getFormKey();
|
|
}
|
|
}
|
|
|
|
function getFormKey()
|
|
{
|
|
return $this->form_key;
|
|
}
|
|
|
|
public static function delete($formKey = null)
|
|
{
|
|
DB::query("DELETE subflow WHERE Form_Key = '" . $formKey . "'");
|
|
}
|
|
|
|
/**
|
|
* @param $userId
|
|
* @return $this
|
|
*/
|
|
public function setCurrentUser($userId)
|
|
{
|
|
$this->current_assigner = $userId;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
*变更当前签核人员
|
|
* @param $formKey
|
|
* @param $userId
|
|
*/
|
|
public static function updateCurrentUser($formKey, $userId)
|
|
{
|
|
$where = "form_key = '" . $formKey . "'";;
|
|
DB::update_table("subflow", array(
|
|
"current_assigner" => $userId,
|
|
), $where);
|
|
}
|
|
|
|
/**
|
|
* 获取当前签核者
|
|
* @param $formKey
|
|
* @return userId
|
|
*/
|
|
public static function getCurrentUser($formKey)
|
|
{
|
|
list($currentAssigner) = DB::fields("SELECT current_assigner
|
|
FROM subflow where form_key ='$formKey'");
|
|
|
|
return $currentAssigner;
|
|
}
|
|
|
|
/***
|
|
*
|
|
*关闭签核
|
|
* @param null $formKey
|
|
*/
|
|
public static function close($formKey = null)
|
|
{
|
|
$where = "form_key = '" . $formKey . "'";;
|
|
DB::update_table("subflow", array(
|
|
"current_assigner" => '00000'
|
|
), $where);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param null $formKey
|
|
*/
|
|
public static function suspend($formKey = null)
|
|
{
|
|
|
|
self::updateRealId($formKey, self::getCurrentUser($formKey));
|
|
$where = "form_key = '" . $formKey . "'";
|
|
DB::update_table("subflow", array(
|
|
"current_assigner" => self::SUSPEND_STATE,
|
|
|
|
), $where);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param $formKey
|
|
* @param $userId
|
|
*/
|
|
public static function updateRealId($formKey, $userId)
|
|
{
|
|
$where = "form_key = '" . $formKey . "'";;
|
|
DB::update_table("subflow", array(
|
|
"real_id" => $userId,
|
|
), $where);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param $formKey
|
|
* @param $userId
|
|
* @return
|
|
*/
|
|
public static function getRealId($formKey)
|
|
{
|
|
list($real_id) = DB::fields("SELECT real_id
|
|
FROM subflow where form_key ='$formKey'");
|
|
return $real_id;
|
|
}
|
|
|
|
/**
|
|
* 插入记录
|
|
* @return int
|
|
*/
|
|
public function insert()
|
|
{
|
|
list($cnt) = DB::fields("select count(*) from subflow where form_key='" . $this->form_key . "' ");
|
|
if ($cnt == 0) {
|
|
DB::insert_table("subflow", array(
|
|
"form_key" => $this->form_key,
|
|
"seq" => $this->seq + 1,
|
|
"current_assigner" => $this->current_assigner,
|
|
"real_id" => $this->real_id
|
|
));
|
|
return 1;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return json_encode($this);
|
|
}
|
|
}
|
|
|