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 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); }