示例#1
0
 public function actionTurnNextPost()
 {
     $runId = $_GET["runid"];
     $flowId = $_GET["flowid"];
     $processId = $_GET["processid"];
     $flowProcess = $_GET["flowprocess"];
     $topflag = isset($_GET["topflag"]) ? $_GET["topflag"] : null;
     $this->nextAccessCheck($topflag, $runId, $processId);
     $plugin = FlowProcess::model()->fetchTurnPlugin($flowId, $flowProcess);
     if ($plugin) {
         $pluginFile = "./system/modules/workflow/plugins/turn/" . $plugin;
         if (file_exists($pluginFile)) {
             include_once $pluginFile;
         }
     }
     $prcsTo = $_GET["processto"];
     $prcsToArr = explode(",", trim($prcsTo, ","));
     $prcsChooseArr = $_GET["prcs_choose"];
     $prcsChoose = implode($prcsChooseArr, ",");
     $message = $_GET["message"];
     $toId = $nextId = $beginUserId = $toallId = "";
     $ext = array("{url}" => Ibos::app()->urlManager->createUrl("workflow/list/index", array("op" => "category")), "{message}" => $message);
     if (isset($_GET["remind"][1])) {
         $nextId = "";
         if (isset($_GET["prcs_user_op"])) {
             $nextId = intval($_GET["prcs_user_op"]);
         } else {
             foreach ($prcsChooseArr as $k => $v) {
                 if (isset($_GET["prcs_user_op" . $k])) {
                     $nextId .= $_GET["prcs_user_op" . $k] . ",";
                 }
             }
             $nextId = trim($nextId, ",");
         }
     }
     if (isset($_GET["remind"][2])) {
         $beginuser = FlowRunProcess::model()->fetchAllOPUid($runId, 1, true);
         if ($beginuser) {
             $beginUserId = StringUtil::wrapId($beginuser[0]["uid"]);
         }
     }
     if (isset($_GET["remind"]["3"])) {
         $toallId = "";
         if (isset($_GET["prcs_user"])) {
             $toallId = filter_input(INPUT_POST, "prcs_user", FILTER_SANITIZE_STRING);
         } else {
             foreach ($prcsChooseArr as $k => $v) {
                 if (isset($_GET["prcs_user" . $k])) {
                     $toallId .= filter_input(INPUT_POST, "prcs_user" . $k, FILTER_SANITIZE_STRING);
                 }
             }
         }
     }
     $idstr = $nextId . "," . $beginUserId . "," . $toallId;
     $toId = StringUtil::filterStr($idstr);
     if ($toId) {
         Notify::model()->sendNotify($toId, "workflow_turn_notice", $ext);
     }
     if ($prcsChoose == "") {
         $prcsUserOp = isset($_GET["prcs_user_op"]) ? intval($_GET["prcs_user_op"]) : "";
         $prcsUser = isset($_GET["prcs_user"]) ? $_GET["prcs_user"] : "";
         $run = FlowRun::model()->fetchByPk($runId);
         if ($run) {
             $pId = $run["parentrun"];
             $runName = $run["name"];
         }
         FlowRunProcess::model()->updateAll(array("flag" => FlowConst::PRCS_DONE), sprintf("runid = %d AND processid = %d AND flowprocess = %d", $runId, $processId, $flowProcess));
         FlowRunProcess::model()->updateAll(array("flag" => FlowConst::PRCS_DONE), sprintf("runid = %d AND flag = 3", $runId));
         FlowRunProcess::model()->updateAll(array("delivertime" => TIMESTAMP), sprintf("runid = %d AND processid = %d AND flowprocess = %d AND uid = %d", $runId, $processId, $flowProcess, $this->uid));
         $isUnique = FlowRunProcess::model()->getIsUnique($runId);
         if (!$isUnique) {
             FlowRun::model()->modify($runId, array("endtime" => TIMESTAMP));
         }
         if ($pId != 0) {
             $parentflowId = FlowRun::model()->fetchFlowIdByRunId($pId);
             $parentFormId = FlowType::model()->fetchFormIDByFlowID($parentflowId);
             $parentPrcs = FlowRunProcess::model()->fetchIDByChild($pId, $runId);
             if ($parentPrcs) {
                 $parentPrcsId = $parentPrcs["processid"];
                 $parentFlowProcess = $parentPrcs["flowprocess"];
             }
             $parentProcess = FlowProcess::model()->fetchProcess($parentflowId, $parentPrcsId);
             if ($parentProcess["relationout"] !== "") {
                 $relationArr = explode(",", trim($parentProcess["relationout"], ","));
                 $src = $des = $set = array();
                 foreach ($relationArr as $field) {
                     $src[] = substr($field, 0, strpos($field, "=>"));
                     $des[] = substr($field, strpos($field, "=>") + strlen("=>"));
                 }
                 $runData = WfHandleUtil::getRunData($runId);
                 $form = new ICFlowForm($parentFormId);
                 $structure = $form->parser->structure;
                 foreach ($structure as $k => $v) {
                     if ($v["data-type"] !== "label" && in_array($v["data-title"], $des)) {
                         $i = array_search($v["data-title"], $des);
                         $ptitle = $src[$i];
                         $itemData = $runData[$ptitle];
                         if (is_array($itemData) && $v["data-type"] == "listview") {
                             $itemDataStr = "";
                             $newDataStr = "";
                             for ($j = 1; $j < count($itemData); ++$j) {
                                 foreach ($itemData[$i] as $val) {
                                     $newDataStr .= $val . "`";
                                 }
                                 $itemDataStr .= $newDataStr . "\r\n";
                                 $newDataStr = "";
                             }
                             $itemData = $itemDataStr;
                         }
                         $field = "data_" . $v["itemid"];
                         $set[$field] = $itemData;
                     }
                 }
                 if (!empty($set)) {
                     FlowDataN::model()->update($parentflowId, $pId, $set);
                 }
             }
             WfHandleUtil::updateParentOver($runId, $pId);
             $prcsBack = $_GET["prcsback"] . "";
             if ($prcsBack != "") {
                 $parentPrcsIdNew = $parentPrcsId + 1;
                 $data = array("runid" => $pId, "processid" => $parentPrcsIdNew, "uid" => $prcsUserOp, "flag" => "1", "flowprocess" => $prcsBack, "opflag" => 1, "topflag" => 0, "parent" => $parentFlowProcess);
                 FlowRunProcess::model()->add($data);
                 foreach (explode(",", trim($prcsUser, ",")) as $k => $v) {
                     if ($v != $prcsUserOp && !empty($v)) {
                         $data = array("runid" => $pId, "processid" => $parentPrcsIdNew, "uid" => $v, "flag" => "1", "flowprocess" => $prcsBack, "opflag" => 0, "topflag" => 0, "parent" => $parentFlowProcess);
                         FlowRunProcess::model()->add($data);
                     }
                 }
                 $parentRunName = FlowRun::model()->fetchNameByRunID($pId);
                 $content = "[{$runName}]" . Ibos::lang("Log return the parent process") . ":[{$parentRunName}]";
                 WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
                 FlowRun::model()->modify($pId, array("endtime" => null));
             }
         }
         $content = Ibos::lang("Form endflow");
         WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
     } else {
         $freeother = FlowType::model()->fetchFreeOtherByFlowID($flowId);
         $prcsChooseArrCount = count($prcsChooseArr);
         for ($i = 0; $i < $prcsChooseArrCount; $i++) {
             $flowPrcsNext = $prcsToArr[$prcsChooseArr[$i]];
             $prcsIdNew = $processId + 1;
             $str = "prcs_user_op" . $prcsChooseArr[$i];
             $prcsUserOp = $_GET[$str];
             if (empty($prcsUserOp)) {
                 $this->ajaxReturn(array("isSuccess" => false, "msg" => "必须选择主办人"), "JSONP");
                 exit;
             }
             if ($freeother == 2) {
                 $prcsUserOp = WfHandleUtil::turnOther($prcsUserOp, $flowId, $runId, $processId, $flowProcess);
             }
             $str = "prcs_user" . $prcsChooseArr[$i];
             $prcsUser = explode(",", $_GET[$str]);
             array_push($prcsUser, $prcsUserOp);
             $prcsUser = implode(",", array_unique($prcsUser));
             if ($freeother == 2) {
                 $prcsUser = WfHandleUtil::turnOther($prcsUser, $flowId, $runId, $processId, $flowProcess, $prcsUserOp);
             }
             $str = "topflag" . $prcsChooseArr[$i];
             $topflag = intval($_GET[$str]);
             $fp = FlowProcess::model()->fetchProcess($flowId, $flowPrcsNext);
             if ($fp["childflow"] == 0) {
                 $_topflag = FlowRunProcess::model()->fetchTopflag($runId, $prcsIdNew, $flowPrcsNext);
                 if ($_topflag) {
                     $topflag = $_topflag;
                 }
                 $isOpHandle = FlowRunProcess::model()->getIsOpOnTurn($runId, $prcsIdNew, $flowPrcsNext);
                 if ($isOpHandle) {
                     $prcsUserOp = "";
                     $t_flag = 1;
                 } else {
                     $t_flag = 0;
                 }
                 foreach (explode(",", trim($prcsUser)) as $k => $v) {
                     if ($v == $prcsUserOp || $topflag == 1) {
                         $opflag = 1;
                     } else {
                         $opflag = 0;
                     }
                     if ($topflag == 2) {
                         $opflag = 0;
                     }
                     $workedId = FlowRunProcess::model()->fetchProcessIDOnTurn($runId, $prcsIdNew, $flowPrcsNext, $v, $fp["gathernode"]);
                     if (!$workedId) {
                         $wrp = FlowRunProcess::model()->fetchRunProcess($runId, $processId, $flowProcess, $this->uid);
                         if ($wrp) {
                             $otherUser = $wrp["otheruser"] != "" ? $wrp["otheruser"] : "";
                         } else {
                             $otherUser = "";
                         }
                         $data = array("runid" => $runId, "processid" => $prcsIdNew, "uid" => $v, "flag" => 1, "flowprocess" => $flowPrcsNext, "opflag" => $opflag, "topflag" => $topflag, "parent" => $flowProcess, "createtime" => TIMESTAMP, "otheruser" => $otherUser);
                         FlowRunProcess::model()->add($data);
                     } else {
                         if ($prcsIdNew < $workedId) {
                             $prcsIdNew = $workedId;
                         }
                         $lastPrcsId = $workedId;
                         FlowRunProcess::model()->updateTurn($flowProcess, $prcsIdNew, $runId, $lastPrcsId, $flowPrcsNext, $v);
                     }
                 }
                 if ($t_flag == 1) {
                     FlowRunProcess::model()->updateToOver($runId, $processId, $flowProcess);
                 } else {
                     FlowRunProcess::model()->updateToTrans($runId, $processId, $flowProcess);
                 }
                 $userNameStr = User::model()->fetchRealnamesByUids($prcsUser);
                 $content = Ibos::lang("To the steps") . $prcsIdNew . "," . Ibos::lang("Transactor") . ":" . $userNameStr;
                 WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
             } else {
                 $runidNew = WfNewUtil::createNewRun($fp["childflow"], $prcsUserOp, $prcsUser, $runId);
                 $data = array("runid" => $runId, "processid" => $prcsIdNew, "uid" => $prcsUserOp, "flag" => 1, "flowprocess" => $flowPrcsNext, "opflag" => 1, "topflag" => 0, "parent" => $flowProcess, "childrun" => $runidNew, "createtime" => TIMESTAMP);
                 FlowRunProcess::model()->add($data);
                 FlowRunProcess::model()->updateToOver($runId, $processId, $flowProcess);
                 $content = Ibos::lang("Log new subflow") . $runidNew;
                 WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
             }
         }
     }
     $this->ajaxReturn(array("isSuccess" => true), "JSONP");
 }
示例#2
0
 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);
 }