public function actionAdd() { $flowId = intval(EnvUtil::getRequest("flowid")); $flow = new ICFlowType($flowId); if (EnvUtil::submitCheck("formhash")) { $this->checkFlowAccess($flowId, 1, $this->createUrl("new/add")); $this->beforeAdd($_POST, $flow); $run = array("name" => $_POST["name"], "flowid" => $flowId, "beginuser" => $this->uid, "begintime" => TIMESTAMP); $runId = FlowRun::model()->add($run, true); $runProcess = array("runid" => $runId, "processid" => 1, "uid" => $this->uid, "flag" => FlowConst::PRCS_UN_RECEIVE, "flowprocess" => 1, "createtime" => TIMESTAMP); FlowRunProcess::model()->add($runProcess); if (strstr($flow->autoname, "{N}")) { FlowType::model()->updateCounters(array("autonum" => 1), sprintf("flowid = %d", $flowId)); CacheUtil::rm("flowtype_" . $flowId); } $runData = array("runid" => $runId, "name" => $_POST["name"], "beginuser" => $this->uid, "begin" => TIMESTAMP); $this->handleRunData($flow, $runData); $param = array("flowid" => $flowId, "runid" => $runId, "processid" => 1, "flowprocess" => 1, "fromnew" => 1); $jumpUrl = $this->createUrl("form/index", array("key" => WfCommonUtil::param($param))); $this->ajaxReturn(array("isSuccess" => true, "jumpUrl" => $jumpUrl)); } else { $this->checkFlowAccess($flowId, 1); if (!empty($flow->autoname)) { $runName = WfNewUtil::replaceAutoName($flow, $this->uid); } else { $runName = sprintf("%s (%s)", $flow->name, date("Y-m-d H:i:s")); } $data = array("flow" => $flow->toArray(), "runName" => $runName, "lang" => Ibos::getLangSources()); $this->renderPartial("add", $data); } }
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 static function createNewRun($flowId, $uid, $uidstr, $pid = 0, $remind = 0, $startTime = "") { if (!$startTime) { $startTime = TIMESTAMP; } $flow = new ICFlowType(intval($flowId)); $runName = self::replaceAutoName($flow, $uid, !!$pid); $maxRunId = FlowRun::model()->getMaxRunId(); if ($maxRunId) { $runId = $maxRunId + 1; } $data = array("runid" => $runId, "name" => $runName, "flowid" => $flowId, "beginuser" => $uid, "begintime" => $startTime, "parentrun" => $pid); FlowRun::model()->add($data); if (strstr($runName, "{RUN}") !== false) { $runName = str_replace("{RUN}", $runId, $runName); FlowRun::model()->modify($runId, array("name" => $runName)); } foreach (explode(",", trim($uidstr, ",")) as $k => $v) { if ($v == $uid) { $opflag = 1; } else { $opflag = 0; } $wrpdata = array("runid" => $runId, "processid" => 1, "uid" => $v, "flag" => 1, "flowprocess" => 1, "opflag" => $opflag, "createtime" => $startTime); FlowRunProcess::model()->add($wrpdata); } if ($remind) { $remindUrl = Ibos::app()->urlManager->createUrl("workflow/form/index", array("key" => WfCommonUtil::param(array("runid" => $runId, "flowid" => $flowId, "processid" => 1, "flowprocess" => 1)))); $config = array("{url}" => $remindUrl, "{runname}" => $runName, "{runid}" => $runId); Notify::model()->sendNotify($uid, "workflow_new_notice", $config); } if ($pid != 0) { $pflowId = FlowRun::model()->fetchFlowIdByRunId($pid); $pRundata = WfHandleUtil::getRunData($pid); $pfield = $subFlow = array(); $relation = FlowProcess::model()->fetchRelationOut($pflowId, $flowId); if ($relation) { $relationArr = explode(",", trim($relation, ",")); foreach ($relationArr as $field) { $pfield[] = substr($field, 0, strpos($field, "=>")); $subFlow[] = substr($field, strpos($field, "=>") + strlen("=>")); } } $runData = array("runid" => $runId, "name" => $runName, "begin" => $startTime, "beginuser" => $uid); } $structure = $flow->form->parser->structure; if (is_array($structure) && 0 < count($structure)) { foreach ($structure as $k => $v) { if ($v["data-type"] !== "label") { if ($v["data-type"] == "checkbox") { if (stristr($v["content"], "checked") || stristr($v["content"], " checked=\"checked\"")) { $itemData = "on"; } else { $itemData = ""; } } if ($v["data-type"] != "select" && $v["data-type"] != "listview") { $itemData = isset($v["data-value"]) ? $v["data-value"] : ""; $itemData = str_replace("\"", "", $itemData); if ($v["data-type"] == "auto") { $itemData = ""; } } if ($pid != 0 && in_array($v["data-title"], $subFlow)) { $i = array_search($v["data-title"], $subFlow); $ptitle = $pfield[$i]; $itemData = $pRundata["{$ptitle}"]; if (is_array($itemData) && $v["data-type"] == "listview") { $itemDataStr = ""; $newDataStr = ""; for ($j = 1; $j < count($itemData); ++$j) { foreach ($itemData[$j] as $val) { $newDataStr .= $val . "`"; } $itemDataStr .= $newDataStr . "\r\n"; $newDataStr = ""; } $itemData = $itemDataStr; } } $runData[$k] = $itemData; } } } WfCommonUtil::addRunData($flowId, $runData, $structure); return $runId; }
protected function countUnReceive() { return FlowRunProcess::model()->countByAttributes(array("uid" => $this->uid, "flag" => 1)); }
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; }
public function actionTrans() { if (EnvUtil::submitCheck("formhash")) { $data =& $_POST; $conArr = array("begin" => !empty($data["begin"]) ? strtotime($data["begin"]) : "", "end" => !empty($data["end"]) ? strtotime($data["end"]) : "", "runbegin" => !empty($data["runbegin"]) ? intval($data["runbegin"]) : "", "runend" => !empty($data["runend"]) ? intval($data["runend"]) : ""); $flowStr = StringUtil::filterStr($data["flowid"]); $uid = implode(",", StringUtil::getId($data["uid"])); $toid = implode(",", StringUtil::getId($data["toid"])); $fitRunIds = FlowRun::model()->fetchAllRunIdByFlowIdFeatCondition($flowStr, $conArr); if (!empty($fitRunIds)) { FlowRunProcess::model()->updateTransRun($uid, $toid, $fitRunIds); } $this->ajaxReturn(array("isSuccess" => true)); } else { $data = array("flows" => FlowType::model()->fetchAllOnOptlist($this->uid), "lang" => Ibos::getLangSources()); $this->renderPartial("trans", $data); } }
public static function getRunPermission($runId, $uid, $processId = 0) { $user = User::model()->fetchByUid($uid); $per = array(); $flowId = FlowRun::model()->fetchFlowIdByRunId($runId); if (!$flowId) { return ""; } if ($user["isadministrator"]) { $per[] = 1; } if (FlowRunProcess::model()->getIsOp($uid, $runId, $processId)) { $per[] = 2; } $permissions = FlowPermission::model()->fetchPermission($uid, $flowId); if (in_array($permissions, array(0, 1, 2), true)) { $per[] = 3; } elseif ($permissions == 3) { $per[] = 5; } if (FlowRunProcess::model()->getIsAgent($uid, $runId, $processId)) { $per[] = 4; } return implode(",", $per); }
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); }
protected function checkIllegal() { $illegal = FlowRunProcess::model()->getIsIllegal($this->runid, $this->processid, $this->flowprocess, $this->uid); if ($illegal) { $this->error(Ibos::lang("Form run has been processed"), $this->createUrl("list/index")); } }
protected function redo($runId, $processId, $uid, $flowProcess) { if (FlowRunProcess::model()->updateRedo($runId, $processId, $uid, $flowProcess)) { $name = User::model()->fetchRealnameByUid($uid); $message = Ibos::lang("Agent redo", "", array("{user}" => $name)); WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 7, $message); return true; } return false; }
protected function setByAllID($runId, $processId, $flowProcess, $uid) { $attr = FlowRunProcess::model()->fetchRunProcess($runId, $processId, $flowProcess, $uid); $this->setAttributes($attr); }
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; }
private function getAllItemName($var) { $flow = $var["flow"]; if ($var["processid"] == 1) { $allItemName = WfFormUtil::getAllItemName($flow->form->structure, array(), ($flow->allowattachment == "1" ? "" : "[A@]") . "[B@]"); unset($flow); } else { $allItemName = FlowRunProcess::model()->fetchFreeitem($var["runid"], $var["processid"]); } return $allItemName; }
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 function del($id, $uid) { $ids = is_array($id) ? $id : explode(",", $id); $count = 0; $logContent = Ibos::lang("Del run", "workflow.default"); foreach ($ids as $runID) { $per = WfCommonUtil::getRunPermission($runID, $uid, 1); $isOnly = FlowRunProcess::model()->getIsOnlyOne($runID); if (!StringUtil::findIn($per, 2) && $isOnly && !StringUtil::findIn($per, 1) && !StringUtil::findIn($per, 3)) { continue; } if ($this->modify($runID, array("delflag" => 1))) { $count++; WfCommonUtil::runlog($runID, 0, 0, $uid, 3, $logContent); } } return $count; }
private function refreshRun(&$run) { $rp = FlowRunProcess::model()->fetchCurrentNextRun($run["runid"], $this->uid, $this->flag); if (!empty($rp)) { $run["processid"] = $rp["processid"]; $run["flowprocess"] = $rp["flowprocess"]; $run["opflag"] = $rp["opflag"]; $run["flag"] = $rp["flag"]; } }
public function loadNew() { return intval(FlowRunProcess::model()->countByAttributes(array("uid" => Ibos::app()->user->uid, "flag" => 1))); }
protected function handleList($flowId, $runId, $processId) { $processNameArr = $list = array(); for ($pId = 1; $pId <= $processId; $pId++) { $process = array("count" => 0); $processes = FlowRunProcess::model()->fetchAllProcessByProcessID($runId, $pId); foreach ($processes as $value) { $process["count"]++; $process["flowprocess"] = $flowProcess = $value["flowprocess"]; $uids = FlowRunProcess::model()->fetchAllUidByRealProcess($runId, $pId, $flowProcess); $process["userName"] = User::model()->fetchRealnamesByUids($uids); if (!isset($processNameArr[$flowProcess])) { $name = FlowProcess::model()->fetchName($flowId, $flowProcess); $name && ($processNameArr[$flowProcess] = $name); } } $list[$pId] = $process; } return array("list" => $list, "prcsName" => $processNameArr); }
public function actionSearchResult() { if (EnvUtil::submitCheck("formhash")) { $data = $this->getPostData(); $param = array_merge((array) $data["flowconditions"], array("condition" => $data["condformula"]), array("flowid" => $data["flowid"])); } else { $searchParam = EnvUtil::getRequest("key"); if (!$searchParam) { $this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("query/advanced")); } $param = WfCommonUtil::param($searchParam, "DECODE"); } $isManager = FlowPermission::model()->fetchPermission($this->uid, $param["flowid"], array(0, 1)); $condition = $this->getSearchCondition($param); if (!empty($param["condition"])) { $count = Ibos::app()->db->createCommand()->select("count(*)")->from("{{flow_type}} ft")->leftJoin("{{flow_run}} fr", "ft.flowid = fr.flowid")->leftJoin(sprintf("{{flow_data_%d}} fd", $param["flowid"]), "fd.runid = fr.runid")->where($condition)->queryScalar(); $pages = PageUtil::create($count, $this->getListPageSize()); $list = Ibos::app()->db->createCommand()->select("fr.name as runName,ft.name as typeName,fr.*,ft.*")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin(sprintf("{{flow_data_%d}} fd", $param["flowid"]), "fd.runid = fr.runid")->where($condition)->order("fr.runid")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll(); } else { $count = Ibos::app()->db->createCommand()->select("count(*)")->from("{{flow_type}} ft")->leftJoin("{{flow_run}} fr", "ft.flowid = fr.flowid")->where($condition)->queryScalar(); $pages = PageUtil::create($count, $this->getListPageSize()); $list = Ibos::app()->db->createCommand()->select("fr.name as runName,ft.name as typeName,fr.*,ft.*")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order("fr.runid")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll(); } $pages->params = array("key" => WfCommonUtil::param($param)); foreach ($list as &$rec) { $rp = FlowRunProcess::model()->fetch(array("select" => "processid,flag,flowprocess,opflag", "condition" => "runid = :runid AND uid = :uid AND flag<>'4'", "params" => array(":runid" => $rec["runid"], ":uid" => $this->uid), "order" => "flag", "limit" => 1)); $keyParam = array("flowid" => $rec["flowid"], "runid" => $rec["runid"]); if ($rp) { $rec["flag"] = $rp["flag"]; $rec["opflag"] = $rp["opflag"]; $keyParam["processid"] = $rp["processid"]; $keyParam["flowprocess"] = $rp["flowprocess"]; } else { $rec["flag"] = ""; } $rec["key"] = WfCommonUtil::param($keyParam); $editper = FlowPermission::model()->fetchPermission($this->uid, $rec["flowid"], array(4)); if ($editper || Ibos::app()->user->isadministrator == 1) { $rec["editper"] = true; } else { $rec["editper"] = false; } $rec["isend"] = false; if ($param["flowstatus"] == "all") { if ($rec["endtime"] != 0) { $rec["isend"] = true; } } elseif ($param["flowstatus"] == 0) { $rec["isend"] = true; } 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["begin"] = ConvertUtil::formatDate($rec["begintime"], "n月j日 H:i"); } $this->setPageTitle(Ibos::lang("Query results")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang("Work query"), "url" => $this->createUrl("query/index")), array("name" => Ibos::lang("Advanced query"), "url" => $this->createUrl("query/advanced")), array("name" => Ibos::lang("specify query conditions"), "url" => $this->createUrl("query/search", array("flowid" => $param["flowid"]))), array("name" => Ibos::lang("Query results")))); $data = array("pages" => $pages, "list" => $list, "flowid" => $param["flowid"], "advanceOpt" => $isManager || Ibos::app()->user->isadministrator == 1); $this->render("result", $data); }