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 handleTplData($flowId) { $data = array(); $lang = Ibos::getLangSources(); $flow = new ICFlowType($flowId); $flowArr = $flow->toArray(); if (!empty($flowArr)) { $data["flow"] = $flowArr; $data["form"] = $flow->form->toArray(); $formStructure = $flow->form->parser->getStructure(); $defTitleArr = array(array("key" => "runid", "title" => $lang["Flow no"]), array("key" => "runname", "title" => $lang["Flow subject/num"]), array("key" => "runstatus", "title" => $lang["Flow status"]), array("key" => "rundate", "title" => $lang["Flow begin date"]), array("key" => "runtime", "title" => $lang["Flow begin time"])); $titleArr = array(); $table = "flow_data_" . $flowId; foreach ($formStructure as $structure) { if ($structure["data-type"] == "sign" || $structure["data-type"] == "label") { continue; } $titleIdentifier = sprintf("%s.%s", $table, "data_" . $structure["itemid"]); $structure["data-title"] = stripslashes(str_replace(array("<", ">"), array("<", ">"), $structure["data-title"])); $titleArr[] = array("key" => $titleIdentifier, "title" => $structure["data-title"]); } $data["deftitle"] = $defTitleArr; $data["title"] = $titleArr; } $data["lang"] = $lang; return $data; }
protected function setGuideProcess(ICFlowType $flow, $curStep) { $guideProcess = $flow->guideprocess; $processPart = explode(",", $guideProcess); if (!in_array($curStep, $processPart)) { $processPart[] = $curStep; sort($processPart); $newProcess = implode(",", $processPart); FlowType::model()->updateByPk($flow->getID(), array("guideprocess" => $newProcess)); } }
public static function checkProcessPermission($flowId, $processId, $uid) { $user = User::model()->fetchByUid(intval($uid)); $flow = new ICFlowType(intval($flowId), false); $criteria = array("select" => "processid,uid,deptid,positionid", "condition" => sprintf("processid > 0 AND flowid = %d%s", $flowId, $processId ? " AND processid = {$processId}" : "")); foreach (FlowProcess::model()->fetchAll($criteria) as $process) { $deptAccess = self::compareIds($user["alldeptid"], $process["deptid"], "d"); $userAccess = self::compareIds($uid, $process["uid"], "u"); $posAccess = self::compareIds($user["allposid"], $process["positionid"], "p"); if ($deptAccess || $userAccess || $posAccess) { return true; } } if (empty($processId)) { $hasPermission = FlowPermission::model()->fetchPermission($uid, $flowId); if ($hasPermission) { return true; } } if ($flow->isFree()) { if ($processId != 1) { return true; } else { $ids = $flow->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) { return true; } else { return false; } } } } unset($flow); return false; }
protected function isEnabledInFreeItem(ICFlowType $flow, ICFlowRunProcess $rp) { return $flow->isFree() && $rp->freeitem == "" || StringUtil::findIn($rp->freeitem, "[A@]"); }
public function actionPrint() { $expWord = EnvUtil::getRequest("word"); $expHtml = EnvUtil::getRequest("html"); $key = EnvUtil::getRequest("key"); if ($key) { $param = WfCommonUtil::param($key, "DECODE"); $flowid = isset($param["flowid"]) ? intval($param["flowid"]) : 0; $runid = isset($param["runid"]) ? intval($param["runid"]) : 0; $flowprocess = isset($param["flowprocess"]) ? intval($param["flowprocess"]) : 0; } $view = EnvUtil::getRequest("view"); if ($view) { MainUtil::setCookie("flowview", $view, TIMESTAMP + 60 * 60 * 24 * 3000); } else { $view = MainUtil::getCookie("flowview"); if (!$view) { $view = "1234"; } } $data = array("formview" => false, "attachview" => false, "signview" => false, "chartview" => false, "flowid" => $flowid, "runid" => $runid, "key" => $key); $this->checkRunAccess($runid); $flow = new ICFlowType(intval($flowid)); $process = new ICFlowProcess($flow->getID(), $flowprocess); $run = new ICFlowRun($runid); if (strstr($view, "1")) { $data["formview"] = true; $viewer = new ICFlowFormViewer(array("flow" => $flow, "form" => $flow->form, "run" => $run, "process" => $process)); $data = array_merge($data, array("runname" => $run->name, "script" => $flow->form->script, "css" => $flow->form->css), $viewer->render(false, true)); } if (strstr($view, "2")) { $data["attachview"] = true; if ($run->attachmentid !== "") { if ($flow->isFixed()) { if (FlowRunProcess::model()->getHasDownper($runid, $flowid, $this->uid)) { $down = 0; } else { $down = 1; } } else { $down = 1; } $data["prcscache"] = WfCommonUtil::loadProcessCache($flowid); $data["attachData"] = AttachUtil::getAttach($run->attachmentid, $down); } } if (strstr($view, "3")) { $data["signview"] = true; $data["feedback"] = WfHandleUtil::loadFeedback($flowid, $runid, $flow->type, $this->uid, true); } if (strstr($view, "4")) { $data["chartview"] = true; } if ($expHtml || $expWord) { $data["chartview"] = false; } $this->layout = ""; $this->setPageTitle(Ibos::lang("Print preview")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow"), "url" => $this->createUrl("list/index")), array("name" => Ibos::lang("Print preview"), "url" => $this->createUrl("preview/print", array("key" => $key))))); $this->render("print", $data); }
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 actionSearch() { $flowId = intval(EnvUtil::getRequest("flowid")); $seqId = intval(EnvUtil::getRequest("id")); if (!$flowId && !$seqId) { $this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("query/advanced")); } $data = array(); if ($seqId) { $edit = true; $tpl = FlowQueryTpl::model()->fetchByPk($seqId); if ($tpl) { $flow = new ICFlowType(intval($tpl["flowid"])); $tpl["flow"] = unserialize($tpl["flowconditions"]); if (!empty($tpl["flow"]["beginuser"])) { $tpl["flow"]["beginuser"] = StringUtil::wrapId($tpl["flow"]["beginuser"]); } $tpl["group"] = unserialize($tpl["groupbyfields"]); $tpl["viewfields"] = !empty($tpl["viewextfields"]) ? explode(",", $tpl["viewextfields"]) : array(); if (!empty($tpl["condformula"])) { $conArr = explode("\\n", $tpl["condformula"]); } else { $conArr = array(); } } else { $this->error(Ibos::lang("Record does not exists", "error"), $this->createUrl("query/advanced")); } } else { $flow = new ICFlowType($flowId); $edit = false; $tpl = $conArr = array(); } $formStructure = $flow->form->parser->getStructure(); $defTitleArr = array(array("key" => "runid", "title" => Ibos::lang("Flow no")), array("key" => "runname", "title" => Ibos::lang("Flow subject/num")), array("key" => "runstatus", "title" => Ibos::lang("Flow status")), array("key" => "rundate", "title" => Ibos::lang("Flow begin date")), array("key" => "runtime", "title" => Ibos::lang("Flow begin time"))); $titleArr = array(); $table = "flow_data_" . $flow->getID(); foreach ($formStructure as $structure) { if ($structure["data-type"] == "sign" || $structure["data-type"] == "label") { continue; } $titleIdentifier = sprintf("%s.%s", $table, "data_" . $structure["itemid"]); $structure["data-title"] = stripslashes(str_replace(array("<", ">"), array("<", ">"), $structure["data-title"])); $titleArr[] = array("key" => $titleIdentifier, "title" => $structure["data-title"]); } $data["deftitle"] = $defTitleArr; $data["title"] = $titleArr; $this->setPageTitle(Ibos::lang("specify query conditions")); $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")))); $tpls = FlowQueryTpl::model()->fetchAllBySearch($flow->getID(), $this->uid); $data["flow"] = $flow->toArray(); $data["tpls"] = $tpls; $data["edit"] = $edit; $data["tpl"] = $tpl; $data["conArr"] = $conArr; $data["id"] = $seqId; $this->render("search", $data); }