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; }
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); } }
public function actionForm() { $key = EnvUtil::getRequest("key"); if ($key) { $this->key = $key; $param = WfCommonUtil::param($key, "DECODE"); $this->_extraAttributes = $param; $this->runid = $param["runid"]; $this->flowid = $param["flowid"]; $this->processid = $param["processid"]; $this->flowprocess = $param["flowprocess"]; } else { $this->ajaxReturn("<script>alert('工作流数据错误,可能已转交或被回退')</script>", "EVAL"); } $flow = new ICFlowType(intval($this->flowid)); if ($_SERVER["REQUEST_METHOD"] == "POST") { $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)) { $enablefiledArr = explode(",", $_POST["enablefiled"]); $formData = array(); $structure = $flow->form->parser->structure; foreach ($structure as $index => $item) { if (!in_array("data_" . $item["itemid"], $enablefiledArr)) { 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, 300); $this->ajaxReturn("<script>alert('保存成功')</script>", "EVAL"); break; case "turn": MainUtil::setCookie("turn_flag", 1, 300); 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 = true; } } else { $process = array(); } $run = new ICFlowRun($this->runid); $hasOtherOPUser = FlowRunProcess::model()->getHasOtherOPUser($this->runid, $this->processid, $this->flowprocess, $this->uid); if ($runProcess->flag == self::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 != self::FORCE) { $this->setProcessDone($preProcess); } } if ($flow->isFixed() && $process->timeout != 0) { if ($runProcess->flag == self::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(), "process" => !empty($process) ? $process->toArray() : $process, "checkItem" => $checkitem, "prcscache" => WfCommonUtil::loadProcessCache($this->flowid), "rp" => $runProcess->toArray(), "rpcache" => WfPreviewUtil::getViewFlowData($this->runid, $this->flowid, $this->uid, $remindUid), "fbSigned" => $this->isFeedBackSigned(), "allowBack" => isset($isAllowBack) ? $isAllowBack : false, "timeUsed" => isset($timeUsed) ? $timeUsed : 0, "uploadConfig" => AttachUtil::getUploadConfig()), $viewer->render(true, false, true)); $formdata = array("run" => $data["run"], "flow" => $data["flow"], "enableArr" => "", "valueArr" => "", "emptyArr" => ""); $data["enablefiled"] = array(); if (is_array($data["model"]["itemData"])) { if (isset($data["prcscache"][$data["rp"]["flowprocess"]]["processitem"])) { $enableFiled = explode(",", $data["prcscache"][$data["rp"]["flowprocess"]]["processitem"]); } else { $enableFiled = array(); } foreach ($data["model"]["itemData"] as $k => $v) { if (substr($k, 0, 5) != "data_") { continue; } $data["model"]["structure"][$k]["value"] = $v; if (in_array($data["model"]["structure"][$k]["data-title"], $enableFiled)) { $data["enablefiled"][] = $k; $data["model"]["structure"][$k]["value"] = $data["model"]["eleout"][$k]; $formdata["enableArr"][] = $data["model"]["structure"][$k]; continue; } if ($v != "") { $formdata["valueArr"][] = $data["model"]["structure"][$k]; continue; } $formdata["emptyArr"][] = $data["model"]["structure"][$k]; } } $data["model"] = $this->renderPartial("application.modules.mobile.views.work.form", $formdata, true); $data["model"] .= "<input type=\"hidden\" name=\"key\" value=\"" . $this->key . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"hidden\" value=\"" . $data["hidden"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"readonly\" value=\"" . $data["readonly"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"attachmentid\" id=\"attachmentid\" value=\"" . $data["run"]["attachmentid"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"fbattachmentid\" id=\"fbattachmentid\" value=\"\">"; $data["model"] .= "<input type=\"hidden\" name=\"topflag\" value=\"" . $data["rp"]["opflag"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"saveflag\">"; $data["model"] .= "<input type=\"hidden\" name=\"formhash\" value=\"" . FORMHASH . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"enablefiled\" value=\"" . implode(",", $data["enablefiled"]) . "\">"; 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) { $data["allowFeedback"] = true; $data["feedback"] = WfHandleUtil::loadFeedback($flow->getID(), $run->getID(), $flow->type, $this->uid); } else { $data["allowFeedback"] = false; } 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->ajaxReturn($data, "JSONP"); } }
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); }