Beispiel #1
0
 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");
     }
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
 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;
 }