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); }
protected function handleRunData(ICFlowType $type, &$runData) { $structure = $type->form->structure; foreach ($structure as $k => $v) { if ($v["data-type"] == "checkbox" && stristr($v["content"], "checkbox")) { if (stristr($v["content"], "checked") || stristr($v["content"], " checked=\"checked\"")) { $itemData = "on"; } else { $itemData = ""; } } elseif (!in_array($v["data-type"], array("select", "listview"))) { if (isset($v["data-value"])) { $itemData = str_replace("\"", "", $v["data-value"]); if ($itemData == "{macro}") { $itemData = ""; } } else { $itemData = ""; } } else { $itemData = ""; } $runData[strtolower($k)] = $itemData; } WfCommonUtil::addRunData($type->getID(), $runData, $structure); }
protected function handleList($runProcess) { foreach ($runProcess as &$run) { $run["user"] = User::model()->fetchByUid($run["beginuser"]); $run["begintime"] = ConvertUtil::formatDate($run["begintime"], "u"); $param = array("runid" => $run["runid"], "flowid" => $run["flowid"]); $run["key"] = WfCommonUtil::param($param); } return array("list" => $runProcess); }
public function fetchAllByUserPurv($uid) { $list = $this->fetchAllSortByPk("catid", array("order" => "sort ASC")); foreach ($list as $index => &$category) { if (WfCommonUtil::checkDeptPurv($uid, $category["deptid"])) { continue; } else { unset($list[$index]); } } return $list; }
public function checkRunAccess($runId, $processId = 0, $jump = "") { $per = WfCommonUtil::getRunPermission($runId, $this->getUid(), $processId); if (empty($per)) { $errMsg = Ibos::lang("Permission denied"); if (!empty($jump)) { $this->error($errMsg, $jump); } else { exit($errMsg); } } }
public function fetchAllOnOptListByUid($uid, $filter = true) { $temp = array(); $list = $this->fetchAllForm(); if (!empty($list)) { while (list(, $form) = each($list)) { if (!$filter || WfCommonUtil::checkDeptPurv($uid, $form["deptid"])) { $data = array("id" => $form["formid"], "text" => $form["formname"]); if (!$form["catid"]) { $form["catid"] = 0; $form["catname"] = "未分类"; } if (!isset($temp[$form["catid"]])) { $temp[$form["catid"]]["text"] = $form["catname"]; $temp[$form["catid"]]["children"] = array(); } $temp[$form["catid"]]["children"][] = $data; } } } $result = array_merge(array(), $temp); return $result; }
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 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 nextAccessCheck($topflag, $runId, $processId) { $per = WfCommonUtil::getRunPermission($runId, $this->uid, $processId); if ($topflag != 2) { if (!StringUtil::findIn($per, 1) && !StringUtil::findIn($per, 2) && !StringUtil::findIn($per, 3)) { EnvUtil::iExit("必须是系统管理员,主办人,管理或监控人才能进行操作"); } } elseif (!StringUtil::findIn($per, 4)) { EnvUtil::iExit("您不是经办人,没有权限进行操作。"); } }
public function actionExport() { if ($this->flowid) { $flow = FlowType::model()->fetchByPk($this->flowid); $checkPurv = WfCommonUtil::checkDeptPurv($this->uid, $flow["deptid"]); if ($checkPurv) { WfTypeUtil::export($this->flowid); } } exit("Access Denied"); }
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 autoProcessor($item, $readOnly) { $field = $item["data-field"]; $width = isset($item["data-width"]) ? $item["data-width"] : "200"; $autoValue = ""; $value = $this->getValue($item); $hourTime = date("H:i:s", TIMESTAMP); $date = date("Y-m-d"); $time = $date . " " . $hourTime; $isTextAuto = substr($field, 0, 8) !== "sys_list"; $lang = Ibos::getLangSource("workflow.default"); if ($isTextAuto) { switch ($field) { case "sys_date": $autoValue = $date; break; case "sys_date_cn": $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["Month"] . "d" . $lang["Chinese day"]); break; case "sys_date_cn_short1": $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["month"]); break; case "sys_date_cn_short2": $autoValue = ConvertUtil::formatDate(TIMESTAMP, "m" . $lang["Month"] . "d" . $lang["Chinese day"]); break; case "sys_date_cn_short3": $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"]); break; case "sys_date_cn_short4": $autoValue = date("Y", TIMESTAMP); break; case "sys_time": $autoValue = $hourTime; break; case "sys_datetime": $autoValue = $time; break; case "sys_week": $autoValue = WfCommonUtil::getWeek(); break; case "sys_userid": $autoValue = Ibos::app()->user->uid; break; case "sys_realname": $autoValue = Ibos::app()->user->realname; break; case "sys_userpos": $autoValue = Ibos::app()->user->posname; break; case "sys_realname_date": $autoValue = Ibos::app()->user->realname . " " . $date; break; case "sys_realname_datetime": $autoValue = Ibos::app()->user->realname . " " . $time; break; case "sys_deptname": $autoValue = Department::model()->fetchDeptNameByDeptId(Ibos::app()->user->alldeptid); break; case "sys_deptname_short": $autoValue = Ibos::app()->user->deptname; break; case "sys_formname": $autoValue = $this->form->formname; break; case "sys_runname": $autoValue = $this->inDebug ? "" : $this->run->name; break; case "sys_rundate": $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime, "d"); break; case "sys_rundatetime": $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime); break; case "sys_runid": $autoValue = $this->inDebug ? "" : $this->run->runid; break; case "sys_autonum": $autoValue = $this->inApp ? $this->flow->autonum : ""; break; case "sys_ip": $autoValue = EnvUtil::getClientIp(); break; case "sys_sql": $sql = $item["data-src"]; $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid); $autoValue = $this->execSysSql($sql, $tempopt, false); break; case "sys_manager1": $main = Ibos::app()->user->deptid; $deptCache = DepartmentUtil::loadDepartment(); $managerID = $deptCache[$main]["manager"]; if ($managerID != 0) { $autoValue = User::model()->fetchRealnameByUid($managerID); } break; case "sys_manager2": $main = Ibos::app()->user->deptid; $deptCache = DepartmentUtil::loadDepartment(); $upid = $deptCache[$main]["upid"]; if ($upid != 0) { if ($deptCache[$upid]["manager"] != 0) { $autoValue = User::model()->fetchRealnameByUid($deptCache[$upid]["manager"]); } } break; case "sys_manager3": $main = Ibos::app()->user->deptid; $deptCache = DepartmentUtil::loadDepartment(); $dept_str = Department::model()->queryDept($main); $temp = explode(",", $dept_str); $count = count($temp); $dept = $temp[$count - 2]; if ($deptCache[$dept]["manager"] != 0) { $autoValue = User::model()->fetchRealnameByUid($deptCache[$dept]["manager"]); } break; default: break; } if ($value == "" && !$readOnly || $this->flow->isFixed() && $readOnly && StringUtil::findIn($this->process->processitemauto, $item["data-title"]) && $this->rp->opflag) { $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$autoValue}\" title=\"{$item["data-title"]}\" />"; } else { $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$value}\" title=\"{$item["data-title"]}\" />"; } $hidden = isset($item["data-hide"]) ? $item["data-hide"] : "0"; if ($hidden == "1") { $eleout = str_ireplace("type=\"text\"", "type=\"hidden\"", $eleout); } if (!$readOnly) { if ($this->inApp && $this->flow->isFixed() && StringUtil::findIn($this->process->processitemauto, $item["data-title"])) { $readOnly = true; } else { $eleout = str_ireplace("<input", "<input data-orig-value=\"{$autoValue}\" data-focus=\"restore\"", $eleout); } } if ($readOnly) { $this->setCommonReadOnly($item, $eleout, "input"); } } else { $autoValue = "<option value=\"\""; if ($value == "") { $autoValue .= " selected"; } $autoValue .= "></option>\n"; switch ($field) { case "sys_list_dept": $cache = DepartmentUtil::loadDepartment(); $str = StringUtil::getTree($cache, "<option value='\$deptid' \$selected>\$spacer\$deptname</option>", $value); $autoValue .= $str; break; case "sys_list_user": foreach (UserUtil::loadUser() as $user) { $selected = $value == $user["uid"] ? "selected" : ""; $autoValue .= "<option {$selected} value='" . $user["uid"] . "'>" . $user["realname"] . "</option>"; } break; case "sys_list_pos": foreach (PositionUtil::loadPosition() as $pos) { $selected = $value == $pos["positionid"] ? "selected" : ""; $autoValue .= "<option {$selected} value='" . $pos["positionid"] . "'>" . $pos["posname"] . "</option>"; } break; case "sys_list_prcsuser1": $autoValue .= $this->getProcessUserList($this->flow->flowid, 0, $value); break; case "sys_list_prcsuser2": $autoValue .= $this->getProcessUserList($this->flow->flowid, $this->process->processid, $value, true); break; case "sys_list_sql": $sql = $item["data-src"]; $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid); $autoValue = $this->execSysSql($sql, $tempopt); $autoValue .= $this->arrayTolist($autoValue, $value); break; case "sys_list_manager1": $main = Ibos::app()->user->deptid; $autoValue .= $this->getManagerList($main, $value); break; case "sys_list_manager2": $main = Ibos::app()->user->deptid; $deptCache = DepartmentUtil::loadDepartment(); $upid = $deptCache[$main]["upid"]; if ($upid != 0) { $autoValue .= $this->getManagerList($main, $value); } break; case "sys_list_manager3": $main = Ibos::app()->user->deptid; $deptCache = DepartmentUtil::loadDepartment(); $dept_str = Department::model()->queryDept($main); $temp = explode(",", $dept_str); $count = count($temp); $dept = $temp[$count - 2]; $autoValue .= $this->getManagerList($dept, $value); break; } $eleout = "\t\t\t\t\t<select title=\"{$item["data-title"]}\" name=\"data_{$item["itemid"]}\">\r\n\t\t\t\t\t{$autoValue}\r\n\t\t\t\t\t</select>"; if ($readOnly) { $this->setCommonReadOnly($item, $eleout, "select"); } } return $eleout; }
public function clearFlow($flowIds) { $ids = is_array($flowIds) ? $flowIds : explode(",", $flowIds); $count = 0; foreach ($ids as $id) { $flow = $this->fetchByPk($id); if (!empty($flow)) { $runs = FlowRun::model()->fetchAllByFlowId($id); if (!empty($runs)) { $runIds = ConvertUtil::getSubByKey($runs, "runid"); WfHandleUtil::destroy($runIds); $table = sprintf("{{flow_data_%d}}", $id); if (WfCommonUtil::tableExists($table)) { Ibos::app()->db->createCommand()->dropTable($table); } FlowRun::model()->deleteAllByAttributes(array("flowid" => $id)); $content = Ibos::lang("Clear flow", "workflow.default", array("{flowName}" => $flow["name"])); FlowManageLog::model()->log($id, $flow["name"], Ibos::app()->user->uid, 3, $content); $count++; } } } return $count; }
public function nextPost() { $var = $this->_var; $topflag = $this->getTopflag(); $topflagOld = filter_input(INPUT_POST, "topflagOld", FILTER_SANITIZE_NUMBER_INT); $prcsUserOpNext = implode(",", StringUtil::getId(filter_input(INPUT_POST, "prcsUserOp", FILTER_SANITIZE_STRING))); $op = $this->getOp(); $prcsUserNext = StringUtil::getId(filter_input(INPUT_POST, "prcsUser", FILTER_SANITIZE_STRING)); array_push($prcsUserNext, $prcsUserOpNext); $prcsUserNext = implode(",", array_unique($prcsUserNext)); $freeOther = $var["flow"]->freeother; $processIdNext = $var["processid"] + 1; $preset = filter_input(INPUT_POST, "preset", FILTER_SANITIZE_NUMBER_INT); if (is_null($preset)) { $lineCount = filter_input(INPUT_POST, "lineCount", FILTER_SANITIZE_NUMBER_INT); for ($i = 0; $i <= $lineCount; $i++) { $prcsIdSet = $processIdNext + $i; $tmp = $i == 0 ? "" : $i; $str = "prcsUserOp" . $tmp; $prcsUserOp = implode(",", StringUtil::getId(filter_input(INPUT_POST, $str, FILTER_SANITIZE_STRING))); $prcsUserOpOld = $prcsUserOp; if ($freeOther == 2) { $prcsUserOp = WfHandleUtil::turnOther($prcsUserOp, $var["flowid"], $var["runid"], $var["processid"], $var["flowprocess"]); } $str = "prcsUser" . $tmp; $prcsUser = StringUtil::getId(filter_input(INPUT_POST, $str, FILTER_SANITIZE_STRING)); array_push($prcsUser, $prcsUserOp); $prcsUser = implode(",", array_unique($prcsUser)); if ($freeOther == 2) { $prcsUser = WfHandleUtil::turnOther($prcsUser, $var["flowid"], $var["runid"], $var["processid"], $var["flowprocess"], $prcsUserOpOld); } $str = "topflag" . $tmp; $topflag = filter_input(INPUT_POST, $str, FILTER_SANITIZE_NUMBER_INT); $prcsFlag = $i == 0 ? 1 : 5; $str = "freeItem" . $tmp; $freeItem = filter_input(INPUT_POST, $str, FILTER_SANITIZE_STRING); if (is_null($freeItem) || empty($freeItem)) { $freeItem = filter_input(INPUT_POST, "freeItemOld", FILTER_SANITIZE_STRING); } $tok = strtok($prcsUser, ","); while ($tok != "") { if ($tok == $prcsUserOp || $topflag == 1) { $opflag = 1; } else { $opflag = 0; } if ($topflag == 2) { $opflag = 0; } if ($opflag == 0) { $freeItem = ""; } $data = array("runid" => $var["runid"], "processid" => $prcsIdSet, "flowprocess" => $prcsIdSet, "uid" => $tok, "flag" => $prcsFlag, "opflag" => $opflag, "topflag" => $topflag, "freeitem" => $freeItem); FlowRunProcess::model()->add($data); $tok = strtok(","); } } } else { FlowRunProcess::model()->updateAll(array("flag" => 1), sprintf("runid = %d AND processid = %d", $var["runid"], $processIdNext)); } $presetDesc = !is_null($preset) ? $var["lang"]["Default step"] : ""; $userNameStr = User::model()->fetchRealnamesByUids($prcsUserNext); $content = $var["lang"]["To the steps"] . $processIdNext . $presetDesc . "," . $var["lang"]["Transactor"] . ":" . $userNameStr; WfCommonUtil::runlog($var["runid"], $var["processid"], 0, Ibos::app()->user->uid, 1, $content); FlowRunProcess::model()->updateAll(array("flag" => 3), sprintf("runid = %d AND processid = %d", $var["runid"], $var["processid"])); FlowRunProcess::model()->updateAll(array("delivertime" => TIMESTAMP), sprintf("runid = %d AND processid = %d AND uid = %d", $var["runid"], $var["processid"], Ibos::app()->user->uid)); $content = filter_input(INPUT_POST, "message", FILTER_SANITIZE_STRING); if (!is_null($content)) { $key = array("runid" => $var["runid"], "flowid" => $var["flowid"], "processid" => $processIdNext, "flowprocess" => $var["flowprocess"]); $ext = array("{url}" => Ibos::app()->createUrl("workflow/form/index", array("key" => WfCommonUtil::param($key))), "{message}" => $content); Notify::model()->sendNotify($prcsUserNext, "workflow_turn_notice", $ext); } if ($op == "manage") { $prcsFirst = $var["processid"] - 1; $prcsNext = $var["processid"] - 2; FlowRunProcess::model()->updateAll(array("flag" => 4), sprintf("runid = %d AND (processid = %d OR processid = %d)", $var["runid"], $prcsFirst, $prcsNext)); } MainUtil::setCookie("flow_turn_flag", 1, 30); $url = Ibos::app()->createUrl("workflow/list/index", array("op" => "list", "type" => "trans", "sort" => "all")); $this->getController()->redirect($url); }
public function makeKey($param = array()) { if (!empty($param)) { return WfCommonUtil::param($param); } }
public function actionIndex() { $flow = new ICFlowType(intval($this->flowid)); if (EnvUtil::submitCheck("formhash")) { $data = array(); $readOnly = $_POST["readonly"]; $hidden = $_POST["hidden"]; $saveflag = $_POST["saveflag"]; $fbAttachmentId = $_POST["fbattachmentid"]; $attachmentId = $_POST["attachmentid"]; $content = isset($_POST["content"]) ? StringUtil::filterCleanHtml($_POST["content"]) : ""; $topflag = $_POST["topflag"]; $this->checkRunAccess($this->runid, $this->processid, $this->createUrl("list/index")); if (FlowRunProcess::model()->getIsOp($this->uid, $this->runid, $this->processid)) { $formData = array(); $structure = $flow->form->parser->structure; foreach ($structure as $index => $item) { if (StringUtil::findIn($hidden, $item["itemid"]) || StringUtil::findIn($readOnly, $item["itemid"])) { continue; } $value = isset($_POST[$index]) ? $_POST[$index] : ""; $formData[$index] = $value; } $formData && $this->handleImgComponent($formData); $formData && FlowDataN::model()->update($this->flowid, $this->runid, $formData); } if (!empty($content) || !empty($fbAttachmentId)) { $fbData = array("runid" => $this->runid, "processid" => $this->processid, "flowprocess" => $this->flowprocess, "uid" => $this->uid, "content" => $content, "attachmentid" => $fbAttachmentId, "edittime" => TIMESTAMP); FlowRunfeedback::model()->add($fbData); AttachUtil::updateAttach($fbAttachmentId, $this->runid); } FlowRun::model()->modify($this->runid, array("attachmentid" => $attachmentId)); AttachUtil::updateAttach($attachmentId, $this->runid); $plugin = FlowProcess::model()->fetchSavePlugin($this->flowid, $this->flowprocess); if (!empty($plugin)) { $pluginFile = "./system/modules/workflow/plugins/save/" . $plugin; if (file_exists($pluginFile)) { include_once $pluginFile; } } switch ($saveflag) { case "save": MainUtil::setCookie("save_flag", 1); $this->redirect($this->createUrl("form/index", array("key" => $this->key))); break; case "turn": MainUtil::setCookie("turn_flag", 1); $this->redirect($this->createUrl("form/index", array("key" => $this->key))); break; case "end": case "finish": if ($saveflag == "end") { $param = array("opflag" => 1); } else { $param = array("topflag" => $topflag); } $this->redirect($this->createUrl("handle/complete", array_merge($param, array("key" => $this->key)))); break; default: break; } } else { $this->checkRunDel(); $this->checkIllegal(); $len = strlen($flow->autonum); for ($i = 0; $i < $flow->autolen - $len; $i++) { $flow->autonum = "0" . $flow->autonum; } $runProcess = new ICFlowRunProcess($this->runid, $this->processid, $this->flowprocess, $this->uid); $checkitem = ""; if ($flow->isFixed()) { $process = new ICFlowProcess($this->flowid, $this->flowprocess); if ($runProcess->opflag != 0) { $checkitem = $process->checkitem; } if (0 < $process->allowback) { $isAllowBack = $this->isAllowBack($runProcess->parent); } } else { $process = array(); } $run = new ICFlowRun($this->runid); $hasOtherOPUser = FlowRunProcess::model()->getHasOtherOPUser($this->runid, $this->processid, $this->flowprocess, $this->uid); if ($runProcess->flag == FlowConst::PRCS_UN_RECEIVE) { $this->setSelfToHandle($runProcess->id); } if ($runProcess->topflag == 1 && $runProcess->opflag == 1) { FlowRunProcess::model()->updateTop($this->uid, $this->runid, $this->processid, $this->flowprocess); } if ($runProcess->topflag == 2) { if (!$hasOtherOPUser) { $runProcess->opflag = 1; } } if ($this->processid == 1) { FlowRun::model()->modify($this->runid, array("beginuser" => $this->uid, "begintime" => TIMESTAMP)); if (!empty($run->parentrun)) { $this->setParentToHandle($run->parentrun, $this->runid); } } $preProcess = $this->processid - 1; if ($preProcess) { if ($flow->isFree() || $flow->isFixed() && $process->gathernode != 1) { $this->setProcessDone($preProcess); } } if ($flow->isFixed() && $process->timeout != 0) { if ($runProcess->flag == FlowConst::PRCS_UN_RECEIVE && $this->processid != 1) { $processBegin = FlowRunProcess::model()->fetchDeliverTime($this->runid, $preProcess); } else { $processBegin = $runProcess->processtime ? $runProcess->processtime : TIMESTAMP; } $timeUsed = TIMESTAMP - $processBegin; } $viewer = new ICFlowFormViewer(array("flow" => $flow, "form" => $flow->getForm(), "run" => $run, "process" => $process, "rp" => $runProcess)); $data = array_merge(array("flow" => $flow->toArray(), "run" => $run->toArray(), "processid" => $this->processid, "process" => !empty($process) ? $process->toArray() : $process, "checkItem" => $checkitem, "prcscache" => WfCommonUtil::loadProcessCache($this->flowid), "rp" => $runProcess->toArray(), "fbSigned" => $this->isFeedBackSigned(), "allowBack" => isset($isAllowBack) ? $isAllowBack : false, "timeUsed" => isset($timeUsed) ? $timeUsed : 0, "uploadConfig" => AttachUtil::getUploadConfig()), $viewer->render()); if ($this->isEnabledAttachment($flow, $run, $process, $runProcess)) { $data["allowAttach"] = true; if (!empty($run->attachmentid)) { $attachPurv = $this->getAttachPriv($flow, $process, $runProcess); $down = $attachPurv["down"]; $edit = $attachPurv["edit"]; $del = $attachPurv["del"]; $data["attachData"] = AttachUtil::getAttach($run->attachmentid, $down, $down, $edit, $del); } } else { $data["allowAttach"] = false; } if ($flow->isFixed() && $process->feedback != 1 || $flow->isFree()) { $data["allowFeedback"] = true; } else { $data["allowFeedback"] = false; } if ($data["allowBack"]) { $data["backlist"] = $this->getBackList($runProcess->flowprocess); } $data["feedback"] = WfHandleUtil::loadFeedback($flow->getID(), $run->getID(), $flow->type, $this->uid); if ($flow->isFree() && $runProcess->opflag == "1") { $hasDefault = FlowRunProcess::model()->getHasDefaultStep($this->runid, $this->processid); if (!$hasDefault) { $data["defaultEnd"] = true; } } if ($flow->isFree() && $runProcess->topflag == "2") { if (!$hasOtherOPUser) { $data["otherEnd"] = true; } } $this->setPageTitle(Ibos::lang("Handle work")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang("My work"), "url" => $this->createUrl("list/index")), array("name" => Ibos::lang("Handle work")))); $this->render("index", $data); } }
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; }
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; }
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 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 handleFormData($list) { $return = array(); if (!empty($list)) { $depts = DepartmentUtil::loadDepartment(); $undefined = Ibos::lang("Undefined"); $sysdept = Ibos::lang("Form sys dept"); foreach ($list as $form) { if (!empty($form["formid"]) && WfCommonUtil::checkDeptPurv($this->uid, $form["deptid"])) { $form["id"] = $form["formid"]; $form["name"] = $form["formname"]; $form["catelog"] = $form["catid"]; if (!isset($form["flow"]) || empty($form["flow"])) { $form["flow"] = $undefined; } $form["department"] = isset($depts[$form["deptid"]]) ? $depts[$form["deptid"]]["deptname"] : $sysdept; $form["departmentId"] = !empty($form["deptid"]) ? StringUtil::wrapId($form["deptid"], "d") : ""; $return[] = $form; } } } return $return; }
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); }
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); }