protected function handleList($runProcess, $flag) { $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId(); foreach ($runProcess as &$run) { if ($this->getIsOver()) { $rp = FlowRunProcess::model()->fetchCurrentNextRun($run["runid"], $this->uid, $flag); if (!empty($rp)) { $run["processid"] = $rp["processid"]; $run["flowprocess"] = $rp["flowprocess"]; $run["opflag"] = $rp["opflag"]; $run["flag"] = $rp["flag"]; } } if ($run["type"] == 1) { if (isset($allProcess[$run["flowid"]][$run["flowprocess"]]["name"])) { $run["stepname"] = $allProcess[$run["flowid"]][$run["flowprocess"]]["name"]; } else { $run["stepname"] = Ibos::lang("Process steps already deleted"); } } else { $run["stepname"] = Ibos::lang("Step", "", array("{step}" => $run["processid"])); } if ($this->type !== "done") { $run["focus"] = StringUtil::findIn($this->uid, $run["focususer"]); } elseif (!empty($run["endtime"])) { $usedTime = $run["endtime"] - $run["begintime"]; $run["usedtime"] = WfCommonUtil::getTime($usedTime); } $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]); $run["key"] = WfCommonUtil::param($param); } return array("datas" => $runProcess); }
private function setOtherInfo(&$run) { if ($this->type !== "done") { $run["focus"] = StringUtil::findIn($this->uid, $run["focususer"]); } elseif (!empty($run["endtime"])) { $usedTime = $run["endtime"] - $run["begintime"]; $run["usedtime"] = WfCommonUtil::getTime($usedTime); } $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]); $run["key"] = WfCommonUtil::param($param); }
protected function handleTimeOut($model) { $lang = Ibos::getLangSources("workflow.default"); $label = "macro_timeout"; $exp = "/#\\[" . $label . "(\\d*)(\\*?)\\]/i"; preg_match_all($exp, $model, $matches); foreach ($matches[1] as $k => $v) { if (!empty($v)) { $data = FlowRunProcess::model()->fetchTimeoutRecord($this->run->runid, $v); if ($data) { $flowPrcs = $data["flowprocess"]; $processTime = $data["processtime"]; $createTime = $data["createtime"]; $deliverTime = $data["delivertime"]; } else { $flowPrcs = ""; } if ($flowPrcs) { $info = FlowProcess::model()->fetchTimeoutInfo($this->run->flowid, $flowPrcs); if ($info) { $processName = $lang["The"] . $v . $lang["Steps"] . ":" . $info["name"]; if (!isset($timeout) && $timeout == "") { $timeout = $info["timeout"]; } $timeOutType = $info["timeouttype"]; } if (isset($timeOutType) && $timeOutType == 0) { $prcsBeginTime = $processTime; if (!$processTime) { $prcsBeginTime = $createTime; } } else { $prcsBeginTime = $createTime; } $prcsEndTime = $deliverTime; $prcsBeginTime = strtotime($prcsBeginTime); $prcsEndTime = strtotime($prcsEndTime); if (!$prcsBeginTime) { $prcsBeginTime = TIMESTAMP; } if (!$prcsEndTime) { $prcsEndTime = TIMESTAMP; } $timeUsedDesc = WfCommonUtil::getTime($prcsEndTime - $prcsBeginTime); $str = $processName . $lang["Timeout"] . ":" . $timeUsedDesc; $model = str_replace($matches[0][$k], $str, $model); } else { $model = str_replace($matches[0][$k], "", $model); } } } }
public static function getViewFlowData($runId, $flowId, $uid, &$remindUid) { $fl = array(); $flow = new ICFlowType(intval($flowId)); $pMaxId = FlowRunProcess::model()->fetchMaxIDByRunID($runId); $process = WfCommonUtil::loadProcessCache($flowId); for ($processId = 1; $processId <= $pMaxId; $processId++) { foreach (FlowRunProcess::model()->fetchAllProcessByProcessID($runId, $processId) as $rp) { $temp = array("flowprocess" => $rp["flowprocess"], "parent" => $rp["parent"], "runid" => $rp["runid"], "processid" => $rp["processid"]); if (FlowRunProcess::model()->getIsAgent($runId, $processId, $uid, $rp["flowprocess"])) { $temp["isprocuser"] = 1; } else { $temp["isprocuser"] = 0; } $op = FlowRunProcess::model()->fetchOpUserByUniqueID($runId, $processId, $rp["flowprocess"]); if (!empty($op)) { $temp["opuser"] = !empty($op["uid"]) ? User::model()->fetchRealnameByUid($op["uid"]) : ""; $temp["opprocessflag"] = $op["flag"]; } else { $temp["opuser"] = User::model()->fetchRealnameByUid($rp["uid"]); $temp["opprocessflag"] = $rp["flag"]; } if ($flow->isFixed()) { if (isset($process[$rp["flowprocess"]])) { $temp["name"] = $process[$rp["flowprocess"]]["name"]; $temp["timeout"] = $process[$rp["flowprocess"]]["timeout"]; $temp["signlook"] = $process[$rp["flowprocess"]]["signlook"]; } else { $temp["name"] = Ibos::lang("Process steps already deleted", "workflow.default"); } } else { $temp["timeout"] = 0; } foreach (FlowRunProcess::model()->fetchAllProcessByFlowProcess($runId, $processId, $rp["flowprocess"]) as $arp) { $temp["prcsuid"] = $arp["uid"]; $temp["opflag"] = $arp["opflag"]; $temp["flag"] = $arp["flag"]; $temp["processtime"] = ConvertUtil::formatDate($arp["processtime"], "u"); $temp["delivertime"] = $arp["delivertime"] != 0 ? ConvertUtil::formatDate($arp["delivertime"], "u") : $arp["delivertime"]; if ($arp["flag"] == "1") { $temp["timeused"] = 0; } elseif ($arp["flag"] == "2") { $temp["timeused"] = TIMESTAMP - $arp["processtime"]; } elseif ($arp["delivertime"] == 0) { $temp["timeused"] = 0; } else { $temp["timeused"] = $arp["delivertime"] - $arp["processtime"]; } if ($arp["processtime"] == "") { $temp["timeused"] = 0; } $temp["timestr"] = WfCommonUtil::getTime($temp["timeused"]); $temp["timeoutflag"] = 0; if ($arp["flag"] == "2" && $arp["processtime"] != "" && $temp["timeout"] != 0) { if ($temp["timeout"] * 3600 < $temp["timeused"]) { $temp["timeoutflag"] = 1; $temp["timeused"] = WfCommonUtil::getTime($temp["timeused"] - $temp["timeout"] * 3600); } } if ($arp["flag"] == 1 || $temp["timeoutflag"] == 1) { $remindUid[] = $arp["uid"]; } $temp["redo"] = false; if ($temp["opuser"] == $uid && $arp["uid"] != $uid && ($temp["opprocessflag"] == 1 || $temp["opprocessflag"] == 2) && ($arp["flag"] == 3 || $arp["flag"] == 4)) { $temp["redo"] = true; } $temp["log"] = FlowRunLog::model()->fetchLog($temp["runid"], $temp["processid"], $temp["flowprocess"], 8); } $fl[count($fl) + 1] = $temp; } } return $fl; }
protected function getListData() { if (EnvUtil::submitCheck("formhash")) { $runid = intval(EnvUtil::getRequest("runid")); $flowid = intval(EnvUtil::getRequest("flowid")); $userType = EnvUtil::getRequest("usertype"); $runName = StringUtil::filterCleanHtml(EnvUtil::getRequest("runname")); $toid = !empty($_POST["toid"]) ? implode(",", StringUtil::getId($_POST["toid"])) : ""; } else { $runid = 0; $userType = $runName = $toid = ""; $flowid = "all"; } $flowIds = WfQueryUtil::getMyFlowIDs($this->uid); if (empty($flowIds)) { $flowIds = array(0); } $condition = array("and", "fr.delflag = 0", array("in", "fr.flowid", $flowIds), array("in", "frp.flag", array(1, 2)), "(frp.opflag = 1 OR frp.topflag = 2)"); $field = "frp.runid,frp.processid,frp.uid,frp.flag,frp.processtime,frp.flowprocess,fr.attachmentid,fr.focususer,ft.freeother"; if ($flowid !== "all") { $condition[] = "ft.flowid = " . $flowid; } if (!empty($runid)) { $condition[] = "fr.runid = " . $runid; } if (!empty($runName)) { $condition[] = " fr.name LIKE '%{$runName}%'"; } if ($toid != "") { if ($userType == "opuser") { $condition[] = "frp.uid = {$toid}"; } else { $condition[] = "fr.beginuser = {$toid}"; } } $lang = Ibos::getLangSource("workflow.default"); $count = Ibos::app()->db->createCommand()->select("count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->where($condition)->queryScalar(); $pages = PageUtil::create($count, $this->getListPageSize()); $list = Ibos::app()->db->createCommand()->select($field)->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->where($condition)->group("frp.runid")->order("frp.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll(); foreach ($list as $k => &$rec) { $temp = Ibos::app()->db->createCommand()->select("ft.flowid,ft.freeother,fr.name as runName,ft.name as typeName,ft.type,ft.sort")->from("{{flow_type}} ft")->leftJoin("{{flow_run}} fr", "fr.flowid = ft.flowid")->where("fr.runid = " . $rec["runid"])->queryRow(); if ($temp) { $rec = array_merge($rec, $temp); } else { continue; } if ($temp["type"] == 1) { $fp = FlowProcess::model()->fetchProcess($temp["flowid"], $rec["flowprocess"]); if ($fp) { $rec["stepname"] = $fp["name"]; } else { $rec["stepname"] = $lang["Process steps already deleted"]; } } else { $rec["stepname"] = Ibos::lang("Step", "", array("{step}" => $rec["processid"])); } if ($rec["flag"] == FlowConst::PRCS_UN_RECEIVE) { $deliverTime = FlowRunProcess::model()->fetchDeliverTime($rec["runid"], $rec["flowprocess"]); if ($deliverTime) { $prcsBeginTime = $deliverTime; } } else { $prcsBeginTime = $rec["processtime"]; } if (!isset($prcsBeginTime) || $prcsBeginTime == 0) { $prcsBeginTime = TIMESTAMP; } $usedTime = TIMESTAMP - $prcsBeginTime; $rec["timestr"] = WfCommonUtil::getTime($usedTime, "dhi"); if (!empty($rec["attachmentid"])) { $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]); } $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]); $rec["user"] = User::model()->fetchByUid($rec["uid"]); $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"], "processid" => $rec["processid"], "flowprocess" => $rec["flowprocess"])); if (empty($rec["user"])) { unset($list[$k]); } } return array("list" => $list, "pages" => $pages); }