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); }
public static function getFlowSearch($flowId, $searchType, $uid, $toId = "") { $condition = array(); $flowIds = WfQueryUtil::getMyFlowIDs($uid); $myRuns = FlowRun::model()->fetchAllMyRunID($uid, $flowId); if ($searchType == "all" && Ibos::app()->user->isadministrator != 1) { $condition[] = sprintf("(fr.runid IN (%s) OR FIND_IN_SET('%s',ft.flowid))", implode(",", $myRuns), implode(",", $flowIds)); } elseif ($searchType == "1") { $beginUser = $uid; } elseif ($searchType == "2") { $condition[] = sprintf("fr.runid IN (%s)", implode(",", $myRuns)); } else { if ($searchType == "3" && Ibos::app()->user->isadministrator != 1) { $condition[] = sprintf("(FIND_IN_SET('%s',ft.flowid)", implode(",", $flowIds)); } elseif (Ibos::app()->user->isadministrator != 1) { EnvUtil::iExit(Ibos::lang("Parameters error", "error")); } } if (!empty($toId) && $searchType !== "1") { $beginUser = $toId; } if (isset($beginUser)) { $condition[] = "fr.beginuser = {$beginUser}"; } return $condition; }
protected function getListData() { $param = $this->getListFilterParam(); $field = "fr.runid,fr.name as runName,fr.begintime,fr.endtime,ft.name as typeName,fr.attachmentid,fr.focususer,fr.beginuser,ft.flowid,ft.type,ft.freeother"; $condition = array("and", "fr.delflag = 0"); if ($param["flowid"]) { $condition[] = "ft.flowid = " . $param["flowid"]; $isManager = FlowPermission::model()->fetchPermission($this->uid, $param["flowid"], array(0, 1)); } else { $isManager = false; } if ($param["start"]) { $condition[] = "fr.begintime >= " . $param["start"]; } if ($param["end"]) { $condition[] = "fr.endtime <= " . $param["end"]; } $flowIds = WfQueryUtil::getMyFlowIDs($this->uid); $myRuns = FlowRun::model()->fetchAllMyRunID($this->uid, $param["flowid"]); if ($param["scope"] == "none" && Ibos::app()->user->isadministrator != 1) { $condition[] = sprintf("(FIND_IN_SET(fr.runid,'%s') OR FIND_IN_SET(ft.flowid,'%s'))", implode(",", $myRuns), implode(",", $flowIds)); } elseif ($param["scope"] == "start") { $beginUser = $this->uid; } elseif ($param["scope"] == "handle") { $condition[] = array("in", "fr.runid", $myRuns); } else { if ($param["scope"] == "manage" && Ibos::app()->user->isadministrator != 1) { $condition[] = sprintf("FIND_IN_SET('%s',ft.flowid)", implode(",", $flowIds)); } elseif ($param["scope"] == "focus") { $implodeStr = WfCommonUtil::implodeSql($this->uid, "fr.focususer"); $condition[] = sprintf("fr.focususer = %d%s", $this->uid, $implodeStr); } elseif ($param["scope"] == "custom") { if (Ibos::app()->user->isadministrator != 1) { $condition[] = sprintf("FIND_IN_SET(ft.flowid,'%s')", implode(",", $flowIds)); } $beginUser = implode(",", StringUtil::getId($param["beginuser"])); } elseif (Ibos::app()->user->isadministrator != 1) { $this->error(Ibos::lang("Parameters error", "error")); } } if ($param["type"] !== "all") { if ($param["type"] == "perform") { $condition[] = "fr.endtime = 0"; } else { $condition[] = "fr.endtime != 0"; } } if (isset($beginUser)) { $condition[] = "fr.beginuser = "******"count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->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")->where($condition)->order("fr.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll(); foreach ($list as &$rec) { if (!empty($rec["attachmentid"])) { $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]); } $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]); $rec["user"] = User::model()->fetchByUid($rec["beginuser"]); $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"])); $rec["begin"] = ConvertUtil::formatDate($rec["begintime"], "n月j日 H:i"); } return array("list" => $list, "pages" => $pages, "advanceOpt" => $isManager || Ibos::app()->user->isadministrator == 1); }