private function loadTodo($num = 4) { $uid = Ibos::app()->user->uid; $fields = array("frp.runid", "frp.processid", "frp.flowprocess", "ft.type", "frp.flag", "ft.flowid", "fr.name as runName", "fr.beginuser", "fr.focususer"); $condition = array("and", "fr.delflag = 0", "frp.childrun = 0", sprintf("frp.uid = %d", $uid)); $condition[] = array("in", "frp.flag", array(1, 2)); $sort = "frp.createtime DESC"; $group = "frp.id"; $runProcess = Ibos::app()->db->createCommand()->select($fields)->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order($sort)->group($group)->offset(0)->limit($num)->queryAll(); $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId(); foreach ($runProcess as &$run) { $run["user"] = User::model()->fetchByUid($run["beginuser"]); 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", "workflow.default"); } } else { $run["stepname"] = Ibos::lang("Step", "", array("{step}" => $run["processid"])); } $run["focus"] = StringUtil::findIn($uid, $run["focususer"]); $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]); $run["key"] = WfCommonUtil::param($param); } return $runProcess; }
protected function handleList($runProcess) { $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId(); foreach ($runProcess as &$run) { $run["user"] = User::model()->fetchByUid($run["beginuser"]); $rp = FlowRunProcess::model()->fetchCurrentNextRun($run["runid"], $this->uid); 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"])); } $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]); $run["key"] = WfCommonUtil::param($param); } return array("list" => $runProcess); }
public function getProcessInfo() { $data = array("name" => $this->name); $preProcessName = FlowProcess::model()->fetchAllPreProcessName($this->flowid, $this->processid); foreach ($preProcessName as $key => $value) { $data["pre"][$key] = $value["name"]; } if (!empty($this->processto)) { foreach (explode(",", $this->processto) as $key => $toId) { $toId = intval($toId); if ($toId == 0) { $data["next"][$key] = Ibos::lang("End"); } else { $next = FlowProcess::model()->fetchProcess($this->flowid, $toId); $data["next"][$key] = $next["name"]; } if (isset($next) && !empty($next["processin"])) { $data["prcsout"][$key]["name"] = $next["name"]; $data["prcsout"][$key]["con"] = $next["processin"]; } } } if (!empty($this->processitem)) { $itemPart = explode(",", $this->processitem); $data["processitem"] = $this->processitem; $data["itemcount"] = count($itemPart); } else { $data["processitem"] = ""; $data["itemcount"] = 0; } if (!empty($this->hiddenitem)) { $itemPart = explode(",", $this->hiddenitem); $data["hiddenitem"] = $this->hiddenitem; $data["hiddencount"] = count($itemPart); } else { $data["hiddenitem"] = ""; $data["hiddencount"] = 0; } if (!empty($this->uid)) { $data["user"] = User::model()->fetchRealnamesByUids($this->uid); } else { $data["user"] = ""; } if (!empty($this->deptid)) { $data["dept"] = Department::model()->fetchDeptNameByDeptId($this->deptid); } else { $data["dept"] = ""; } if (!empty($this->positionid)) { $data["position"] = Position::model()->fetchPosNameByPosId($this->positionid); } else { $data["position"] = ""; } return $data; }
private function handleList($list) { $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId(); foreach ($list as &$run) { $run["user"] = User::model()->fetchByUid($run["beginuser"]); if ($this->getIsOver()) { $this->refreshRun($run); } $this->setStepName($run, $allProcess); $this->setOtherInfo($run); $this->setOpt($run); } return $list; }
public function actionAdd() { if (EnvUtil::submitCheck("typeSubmit")) { $this->beforeSave(); $newId = FlowType::model()->add($_POST, true); FlowProcess::model()->addSpecialNode($newId); $catId = intval($_POST["catid"]); $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("type/index", array("catid" => $catId, "flowid" => $newId))); } else { $data = array("formList" => FlowFormType::model()->fetchAllOnOptListByUid($this->uid, $this->category), "category" => $this->category, "catId" => $this->catid); $this->setPageTitle(Ibos::lang("Workflow manager")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang("Workflow manager"), "url" => $this->createUrl("type/index")), array("name" => Ibos::lang("New flow")))); $this->render("add", $data); } }
public static function import($id, $file, $importUser = false) { $content = FileUtil::readFile($file); $xml = XmlUtil::xmlToArray($content); unset($xml["base"]["flowid"]); unset($xml["base"]["name"]); unset($xml["base"]["formid"]); unset($xml["base"]["sort"]); $user = array("newuser", "deptid", "uid", "positionid", "autouserop", "autouser", "mailto"); $data = array(); foreach ($xml["base"] as $key => $value) { $key = strtolower($key); if (!$importUser && in_array($key, $user)) { continue; } $data[$key] = $value; } FlowType::model()->modify($id, $data); unset($xml["base"]); unset($data); FlowProcess::model()->deleteAllByAttributes(array("flowid" => $id)); if (!empty($xml)) { foreach ($xml as $process) { unset($process["id"]); $data = array(); $process["flowid"] = $id; foreach ($process as $k => $v) { if (!$importUser && in_array($k, $user)) { continue; } $data[$k] = $v; } FlowProcess::model()->add($data); } } FileUtil::deleteFile($file); }
protected function getListData($op) { switch ($op) { case "rule": case "berule": if ($op == "rule") { $where = "fr.uid = {$this->uid}"; } else { $where = "fr.toid = {$this->uid} AND fr.status = 1"; } $sqlText = "SELECT fr.*,ft.name as typeName,fr.toid as userID FROM {{flow_rule}} fr LEFT JOIN {{flow_type}} ft ON ft.flowid = fr.flowid LEFT JOIN {{user}} u ON fr.toid = u.uid WHERE {$where} ORDER BY fr.ruleid DESC"; break; case "record": case "berecord": if ($op == "record") { $idField = "uid"; } else { $idField = "toid"; } $sqlText = "SELECT log.flowid,log.runid,log.runname,log.processid,log.toid as userID,log.time,frp.flag,frp.flowprocess,ft.type,ft.name as typeName,ft.flowid FROM {{flow_run_log}} log INNER JOIN {{flow_type}} ft ON log.flowid = ft.flowid LEFT JOIN {{flow_run_process}} frp ON frp.runid = log.runid WHERE frp.processid = log.processid AND log.{$idField} = {$this->uid} AND log.type = 2 GROUP BY log.processid ORDER BY log.runid DESC"; break; } $query = Ibos::app()->db->createCommand()->setText($sqlText)->query(); $count = $query->count(); $pages = PageUtil::create($count, $this->getListPageSize()); $offset = $pages->getOffset(); $limit = $pages->getLimit(); $list = Ibos::app()->db->createCommand()->setText($sqlText . " LIMIT {$offset},{$limit}")->queryAll(); $now = strtotime(date("Y-m-d", TIMESTAMP)); $proceses = FlowProcess::model()->fetchAllProcessSortByFlowId(); foreach ($list as &$rec) { if ($op == "rule" || $op == "berule") { $condition1 = WfHandleUtil::compareTimestamp($now, $rec["begindate"]); $condition2 = WfHandleUtil::compareTimestamp($now, $rec["enddate"]); $rec["enabled"] = false; $rec["datedesc"] = ""; if ($rec["status"] == 1) { if ($rec["begindate"] != 0 && $rec["enddate"] != 0) { $rec["datedesc"] = date("Y-m-d", $rec["begindate"]) . "--" . date("Y-m-d", $rec["enddate"]); if (0 <= $condition1 && $condition2 <= 0) { $rec["enabled"] = true; } } elseif ($rec["begindate"] != 0) { $rec["datedesc"] = Ibos::lang("Entrust begin with", "", array("{date}" => date("Y-m-d", $rec["begindate"]))); if (0 <= $condition1) { $rec["enabled"] = true; } } elseif ($rec["enddate"] != 0) { $rec["datedesc"] = Ibos::lang("Entrust finish up width", "", array("{date}" => date("Y-m-d", $rec["enddate"]))); if ($condition2 <= 0) { $rec["enabled"] = true; } } else { $rec["datedesc"] = Ibos::lang("Always effective"); $rec["enabled"] = true; } } } else { $rec["key"] = WfCommonUtil::param(array("runid" => $rec["runid"], "processid" => $rec["processid"], "flowprocess" => $rec["flowprocess"], "flowid" => $rec["flowid"])); if ($rec["type"] == 1) { if (isset($proceses[$rec["flowid"]][$rec["flowprocess"]])) { $rec["processname"] = $proceses[$rec["flowid"]][$rec["flowprocess"]]["name"]; } } else { $rec["processname"] = Ibos::lang("Steps", "", array("{step}" => $rec["processid"])); } } $rec["user"] = User::model()->fetchByUid($rec["userID"]); } return array("pages" => $pages, "list" => $list); }
public static function getEnabledFlowIdByUid($uid) { $user = User::model()->fetchByUid(intval($uid)); $flowIds = array(); $fixedFlowPer = FlowProcess::model()->fetchAllFirstStepPermission(); foreach ($fixedFlowPer as $fixedFlow) { $deptAccess = self::compareIds($user["alldeptid"], $fixedFlow["deptid"], "d"); $userAccess = self::compareIds($uid, $fixedFlow["uid"], "u"); $posAccess = self::compareIds($user["allposid"], $fixedFlow["positionid"], "p"); if ($deptAccess || $userAccess || $posAccess) { $flowIds[] = $fixedFlow["flowid"]; } } $freeFlowPer = FlowType::model()->fetchAllFreePermission(); foreach ($freeFlowPer as $freeFlow) { $ids = $freeFlow["newuser"]; if (!empty($ids)) { $deptAccess = self::compareMixedIds($user["alldeptid"], $ids, "d"); $userAccess = self::compareMixedIds($uid, $ids, "u"); $posAccess = self::compareMixedIds($user["allposid"], $ids, "p"); if ($deptAccess || $userAccess || $posAccess) { $flowIds[] = $freeFlow["flowid"]; } } } return array_unique($flowIds); }
public function updateProcessto($flowid, $oldPrcsId, $newPrcsId) { $allProcess = FlowProcess::model()->fetchAll(sprintf("flowid = %d AND FIND_IN_SET(%d, `processto`)", $flowid, $oldPrcsId)); if (!empty($allProcess)) { foreach ($allProcess as $processs) { $oldProcesstoArr = explode(",", $process["processto"]); $key = array_search($oldPrcsId, $oldProcesstoArr); if (isset($oldProcesstoArr[$key])) { $oldProcesstoArr[$key] = $newPrcsId; $newProcessto = implode(",", $oldProcesstoArr); FlowProcess::model()->updateByPk($process["id"], array("processto" => $newProcessto)); } } } }
protected function makeUserSelect($runId, $index, $process, $name, $flowId, $processId) { $lang = Ibos::getLangSource("workflow.default"); $tablestr = ""; if ($index) { $display = "none;"; } else { $display = ""; } if ($process["childflow"] != 0) { $flow = FlowType::model()->fetchByPk($process["childflow"]); if ($flow) { $type = $flow["type"]; } if ($type == 2) { $process["prcs_id_next"] = ""; } $subfp = FlowProcess::model()->fetchProcess($process["childflow"], 1); if ($subfp) { $prcsuser = WfHandleUtil::getPrcsUser($process["childflow"], $processId); } else { $prcsuser = ""; } $prcsuser = sprintf("[%s]", !empty($prcsuser) ? StringUtil::iImplode($prcsuser) : ""); if (empty($subfp["uid"]) && empty($subfp["deptid"]) && empty($subfp["positionid"])) { $nopriv = $lang["Not set step permissions"]; } $tablestr = " <div style='display:{$display};' id='user_select_{$index}'>\r\n <div class=\"control-group first-group\">\r\n <label class=\"control-label\">{$lang["Host"]}</label>\r\n <div class=\"controls\">\r\n <strong>{$name} {$nopriv}</strong>\r\n <input type=\"hidden\" name=\"topflag{$index}\" value=\"0\">\r\n <input id=\"prcs_user_op{$index}\" name=\"prcs_user_op{$index}\" type=\"text\" />\r\n </div>\r\n </div>\r\n <div class=\"control-group\">\r\n <label class=\"control-label\">{$lang["Agent"]}</label>\r\n <div class=\"controls\">\r\n <input id=\"prcs_user{$index}\" name=\"prcs_user{$index}\" type=\"text\" />\r\n </div>\r\n </div>\r\n </div>\r\n <script>\r\n\t\t\t\t\$(function(){\r\n\t\t\t\t\tvar prcsData{$index} = {$prcsuser};\r\n\t\t\t\t\t\$('#prcs_user_op{$index}').userSelect({\r\n\t\t\t\t\t\tbox:\$('<div id=\"prcs_user_op_box{$index}\"></div>').appendTo(document.body),\r\n\t\t\t\t\t\tdata:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\t\ttype:'user',\r\n\t\t\t\t\t\tmaximumSelectionSize:'1'\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\$('#prcs_user{$index}').userSelect({\r\n\t\t\t\t\t\tbox:\$('<div id=\"prcs_user_box{$index}\"></div>').appendTo(document.body),\r\n\t\t\t\t\t\tdata:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\t\ttype:'user'\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t</script>"; } else { if (empty($process["uid"]) && empty($process["deptid"]) && empty($process["positionid"])) { $nopriv = $lang["Not set step permissions"]; } $prcsOpUser = $prcsUserAuto = ""; $deptArr = DepartmentUtil::loadDepartment(); if ($process["autotype"] == 1) { $uid = FlowRun::model()->fetchBeginUserByRunID($runId); $prcsuser = User::model()->fetchByUid($uid); if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $prcsuser["uid"]) || StringUtil::findIn($process["deptid"], $prcsuser["alldeptid"]) || StringUtil::findIn($process["positionid"], $prcsuser["allposid"])) { $prcsOpUser = $prcsuser["uid"]; $prcsUserAuto = $prcsuser["uid"] . ","; } } elseif (in_array($process["autotype"], array(2, 4, 5, 6))) { if ($process["autobaseuser"] != 0) { $baseUid = FlowRunProcess::model()->fetchBaseUid($runId, $process["autobaseuser"]); $baseuser = User::model()->fetchByUid($baseUid); $autodept = $baseuser["deptid"]; } else { $autodept = Ibos::app()->user->deptid; } if (0 < intval($autodept)) { if ($process["autotype"] == 2) { $tmpdept = $autodept; } else { if ($process["autotype"] == 4 || $process["autotype"] == 6) { $tmpdept = $deptArr[$autodept]["pid"] == 0 ? $autodept : $deptArr[$autodept]["pid"]; } elseif ($process["autotype"] == 5) { $deptStr = Department::model()->queryDept($autodept, true); $temp = explode(",", $deptStr); $count = count($temp); $dept = isset($temp[$count - 2]) ? $temp[$count - 2] : $autodept; if ($deptArr[$dept]["pid"] != 0) { $tmpdept = $deptArr[$dept]["deptid"]; } else { $tmpdept = $autodept; } } } $manager = $deptArr[$tmpdept]["manager"]; if ($process["autotype"] == 4 || $process["autotype"] == 6) { $leader = $deptArr[$autodept]["leader"]; $subleader = $deptArr[$autodept]["subleader"]; if ($leader != "0" && $process["autotype"] == 4) { $manager = $leader; } if ($subleader != "0" && $process["autotype"] == 6) { $manager = $subleader; } } if (!empty($manager)) { $muser = User::model()->fetchByUid($manager); if (!empty($muser)) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $muser["uid"]) || StringUtil::findIn($process["deptid"], $muser["alldeptid"]) || StringUtil::findIn($process["positionid"], $muser["allposid"])) { $prcsUserAuto = $muser["uid"] . ","; } if ($prcsUserAuto != "") { $prcsOpUser = strtok($prcsUserAuto, ","); } } } else { $userPerMax = ""; foreach (User::model()->fetchAllOtherManager($tmpdept) as $user) { $user = User::model()->fetchByUid($user["uid"]); $uid = $user["uid"]; $position = $user["allposid"]; if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $uid) || StringUtil::findIn($process["deptid"], $user["alldeptid"]) || StringUtil::findIn($process["positionid"], $position)) { if ($userPerMax == "") { $prcsOpUser = $uid; $prcsUserAuto .= $uid . ","; $userPerMax = $position; } elseif ($position == $userPerMax) { $prcsUserAuto .= $uid . ","; } } } } } } elseif ($process["autotype"] == 3) { $autouserop = User::model()->fetchByUid($process["autouserop"]); if (!empty($autouserop)) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $autouserop["uid"]) || StringUtil::findIn($process["deptid"], $autouserop["alldeptid"]) || StringUtil::findIn($process["positionid"], $autouserop["allposid"])) { $prcsOpUser = $autouserop["uid"]; } } if (!empty($process["autouser"])) { foreach (User::model()->fetchAllByUids(explode(",", trim($process["autouser"], ","))) as $user) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $user["uid"]) || StringUtil::findIn($process["deptid"], $user["alldeptid"]) || StringUtil::findIn($process["positionid"], $user["allposid"])) { $prcsUserAuto .= $user["uid"] . ","; } } } } elseif ($process["autotype"] == 7) { if (is_numeric($process["autouser"])) { $itemData = FlowDataN::model()->fetchItem($process["autouser"], $process["flowid"], $runId); $tmp = strtok($itemData, ","); $userarr = array(); while ($tmp) { $userarr[$tmp] = array(); $tmp = strtok(","); } $tempArray = explode(",", trim($itemData, ",")); foreach ($tempArray as $key => $value) { if (is_numeric($value)) { $value = User::model()->fetchRealnameByUid($value, ""); $tempArray[$key] = $value; } } foreach (User::model()->fetchAllByRealnames($tempArray) as $k => $v) { $dept = Department::model()->queryDept($v["alldeptid"]); if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $dept) || StringUtil::findIn($process["positionid"], $v["allposid"])) { $prcsUserAuto .= $v["uid"] . ","; } } if ($prcsUserAuto != "") { $prcsOpUser = strtok($prcsUserAuto, ","); } } } else { if ($process["autotype"] == 8 && is_numeric($process["autouser"])) { $uid = FlowRunProcess::model()->fetchBaseUid($runId, $process["autouser"]); if ($uid) { $temp = User::model()->fetchByUid($uid); if ($temp) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $temp["uid"]) || StringUtil::findIn($process["deptid"], $temp["alldeptid"]) || StringUtil::findIn($process["positionid"], $temp["allposid"])) { $prcsOpUser = $prcsUserAuto = $temp["uid"]; $prcsUserAuto .= ","; } } } } elseif ($process["autotype"] == 9) { $main = Ibos::app()->user->deptid; foreach (User::model()->fetchAllFitDeptUser($main) as $k => $v) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $v["alldeptid"]) || StringUtil::findIn($process["positionid"], $v["allposid"])) { $prcsUserAuto .= $v["uid"] . ","; } } if (!empty($prcsUserAuto)) { $prcsOpUser = strtok($prcsUserAuto, ","); } } elseif ($process["autotype"] == 10) { $main = Ibos::app()->user->deptid; $deptStr = Department::model()->queryDept($main, true); $temp = explode(",", $deptStr); $count = count($temp); $dept = isset($temp[$count - 2]) ? $temp[$count - 2] : $main; if ($deptArr[$dept]["pid"] != 0) { $tmpdept = $deptArr[$dept]["deptid"]; } else { $tmpdept = $main; } foreach (User::model()->fetchAllFitDeptUser($tmpdept) as $k => $v) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $v["alldeptid"]) || StringUtil::findIn($process["positionid"], $v["allposid"])) { $prcsUserAuto .= $v["uid"] . ","; } } if (!empty($prcsUserAuto)) { $prcsOpUser = strtok($prcsUserAuto, ","); } } else { if ($process["uid"] != "" && $process["deptid"] == "" && $process["positionid"] == "") { $prcsUserArr = explode(",", $process["uid"]); $prcsUserCount = count($prcsUserArr) - 1; if ($prcsUserCount == 1) { $prcsUserAuto = $process["uid"]; $prcsOpUser = $prcsUserAuto; } } } } $prcsuser = WfHandleUtil::getPrcsUser($flowId, $process["processid"]); $prcsuser = sprintf("[%s]", !empty($prcsuser) ? StringUtil::iImplode($prcsuser) : ""); if ($process["userlock"] != 1) { $attr = 'islock="1"'; } else { $attr = ''; } if (!empty($prcsOpUser)) { $prcsOpUser = StringUtil::wrapId($prcsOpUser); } if (!empty($prcsUserAuto)) { $prcsUserAuto = StringUtil::wrapId(StringUtil::filterStr($prcsUserAuto)); } $tablestr = " <div class=\"control-group\" style=\"display:{$display};\" id='user_select_{$index}'>\r\n <div class=\"control-group first-group\">\r\n <label class=\"control-label\">{$lang["Host"]}</label>\r\n <div class=\"controls\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"topflag{$index}\" value=\"{$process["topdefault"]}\">\r\n\t\t\t\t\t<input id=\"prcs_user_op{$index}\" {$attr} name=\"prcs_user_op{$index}\" value=\"{$prcsOpUser}\" type=\"text\" />\r\n\t\t\t\t</div>\r\n </div>\r\n <div class=\"control-group\">\r\n <label class=\"control-label\">{$lang["Agent"]}</label>\r\n <div class=\"controls\">\r\n\t\t\t\t\t<input id=\"prcs_user{$index}\" {$attr} name=\"prcs_user{$index}\" value=\"{$prcsUserAuto}\" type=\"text\" />\r\n\t\t\t\t</div>\r\n </div>\r\n </div>\r\n <script>\r\n \$(function(){\r\n\t\t\t\tvar prcsData{$index} = {$prcsuser};\r\n var puo = \$('#prcs_user_op{$index}');\r\n var pu = \$('#prcs_user{$index}');\r\n\t\t\t\tvar topdef = '{$process["topdefault"]}';\r\n puo.userSelect({\r\n box:\$('<div id=\"prcs_user_op_box{$index}\"></div>').appendTo(document.body),\r\n data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user',\r\n maximumSelectionSize:'1'\r\n });\r\n if(puo.attr('islock')==1 || topdef != 0){\r\n puo.userSelect('setReadOnly');\r\n } \r\n pu.userSelect({\r\n\t\t\t\t\tbox:\$('<div id=\"prcs_user_box{$index}\"></div>').appendTo(document.body),\r\n data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user'\r\n });\r\n if(pu.attr('islock')==1){\r\n pu.userSelect('setReadOnly');\r\n }\r\n });\r\n </script>"; } return $tablestr; }
protected function getBackList($parent) { $flowProcessIds = $this->getParent($parent); $list = array(); foreach ($flowProcessIds as $flowprocess) { $list[] = array("id" => $flowprocess, "name" => FlowProcess::model()->fetchName($this->flowid, $flowprocess)); } return $list; }
protected function getCon($flowId, $processId, $toIds) { $conArr = array(); $idPart = explode(",", trim($toIds, ",")); foreach ($idPart as $toId) { $conArr[$toId] = array(); $con = FlowProcessTurn::model()->fetchByUnique($flowId, $processId, $toId); if (!empty($con)) { if (!empty($con["processout"])) { $part = explode("\n", $con["processout"]); while (list(, $condition) = each($part)) { if (!empty($condition)) { $conArr[$toId]["options"][] = $condition; } } } $conArr[$toId]["desc"] = $con["conditiondesc"]; } else { $conArr[$toId]["desc"] = ""; } if ($toId == "0") { $conArr[$toId]["name"] = Ibos::lang("End step"); } else { $conArr[$toId]["name"] = FlowProcess::model()->fetchName($flowId, $toId); } } return $conArr; }
protected function getProcessUserList($flowID, $processID = 0, $value = "", $single = false) { $autoValue = ""; $ids = array(); if ($single) { $process = FlowProcess::model()->fetchProcess($flowID, $processID); $this->getProcessUser($process, $ids); } else { $allProcess = FlowProcess::model()->fetchAllByFlowId($flowID); foreach ($allProcess as $process) { $this->getProcessUser($process, $ids); } } if (!empty($ids)) { $uids = StringUtil::getUid($ids); foreach (User::model()->fetchAllByUids($uids) as $user) { $selected = $value == $user["uid"] ? "selected" : ""; $autoValue .= "<option {$selected} value='" . $user["uid"] . "'>" . $user["realname"] . "</option>"; } } return $autoValue; }
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); } } } }
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 function delFlow($flowIds) { $ids = is_array($flowIds) ? $flowIds : explode(",", $flowIds); $sqlCondition = sprintf("FIND_IN_SET(flowid,'%s')", implode(",", $ids)); $this->clearFlow($ids); $uid = Ibos::app()->user->uid; foreach ($ids as $id) { $flow = $this->fetchByPk($id); $content = Ibos::lang("Del flow", "workflow.default", array("{flowName}" => $flow["name"])); FlowManageLog::model()->log($id, $flow["name"], $uid, 3, $content); } $delFlow = $this->deleteByPk($ids); FlowProcess::model()->deleteAll($sqlCondition); FlowRule::model()->deleteAll($sqlCondition); FlowPermission::model()->deleteAll($sqlCondition); if ($delFlow) { return true; } else { return false; } }