예제 #1
0
 protected function handleList($runProcess)
 {
     $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId();
     foreach ($runProcess as &$run) {
         $run["user"] = User::model()->fetchByUid($run["beginuser"]);
         $rp = FlowRunProcess::model()->fetchCurrentNextRun($run["runid"], $this->uid);
         if (!empty($rp)) {
             $run["processid"] = $rp["processid"];
             $run["flowprocess"] = $rp["flowprocess"];
             $run["opflag"] = $rp["opflag"];
             $run["flag"] = $rp["flag"];
         }
         if ($run["type"] == 1) {
             if (isset($allProcess[$run["flowid"]][$run["flowprocess"]]["name"])) {
                 $run["stepname"] = $allProcess[$run["flowid"]][$run["flowprocess"]]["name"];
             } else {
                 $run["stepname"] = Ibos::lang("Process steps already deleted");
             }
         } else {
             $run["stepname"] = Ibos::lang("Step", "", array("{step}" => $run["processid"]));
         }
         $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]);
         $run["key"] = WfCommonUtil::param($param);
     }
     return array("list" => $runProcess);
 }
예제 #2
0
 private function loadTodo($num = 4)
 {
     $uid = Ibos::app()->user->uid;
     $fields = array("frp.runid", "frp.processid", "frp.flowprocess", "ft.type", "frp.flag", "ft.flowid", "fr.name as runName", "fr.beginuser", "fr.focususer");
     $condition = array("and", "fr.delflag = 0", "frp.childrun = 0", sprintf("frp.uid = %d", $uid));
     $condition[] = array("in", "frp.flag", array(1, 2));
     $sort = "frp.createtime DESC";
     $group = "frp.id";
     $runProcess = Ibos::app()->db->createCommand()->select($fields)->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order($sort)->group($group)->offset(0)->limit($num)->queryAll();
     $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId();
     foreach ($runProcess as &$run) {
         $run["user"] = User::model()->fetchByUid($run["beginuser"]);
         if ($run["type"] == 1) {
             if (isset($allProcess[$run["flowid"]][$run["flowprocess"]]["name"])) {
                 $run["stepname"] = $allProcess[$run["flowid"]][$run["flowprocess"]]["name"];
             } else {
                 $run["stepname"] = Ibos::lang("Process steps already deleted", "workflow.default");
             }
         } else {
             $run["stepname"] = Ibos::lang("Step", "", array("{step}" => $run["processid"]));
         }
         $run["focus"] = StringUtil::findIn($uid, $run["focususer"]);
         $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]);
         $run["key"] = WfCommonUtil::param($param);
     }
     return $runProcess;
 }
예제 #3
0
 public function actionAdd()
 {
     $flowId = intval(EnvUtil::getRequest("flowid"));
     $flow = new ICFlowType($flowId);
     if (EnvUtil::submitCheck("formhash")) {
         $this->checkFlowAccess($flowId, 1, $this->createUrl("new/add"));
         $this->beforeAdd($_POST, $flow);
         $run = array("name" => $_POST["name"], "flowid" => $flowId, "beginuser" => $this->uid, "begintime" => TIMESTAMP);
         $runId = FlowRun::model()->add($run, true);
         $runProcess = array("runid" => $runId, "processid" => 1, "uid" => $this->uid, "flag" => FlowConst::PRCS_UN_RECEIVE, "flowprocess" => 1, "createtime" => TIMESTAMP);
         FlowRunProcess::model()->add($runProcess);
         if (strstr($flow->autoname, "{N}")) {
             FlowType::model()->updateCounters(array("autonum" => 1), sprintf("flowid = %d", $flowId));
             CacheUtil::rm("flowtype_" . $flowId);
         }
         $runData = array("runid" => $runId, "name" => $_POST["name"], "beginuser" => $this->uid, "begin" => TIMESTAMP);
         $this->handleRunData($flow, $runData);
         $param = array("flowid" => $flowId, "runid" => $runId, "processid" => 1, "flowprocess" => 1, "fromnew" => 1);
         $jumpUrl = $this->createUrl("form/index", array("key" => WfCommonUtil::param($param)));
         $this->ajaxReturn(array("isSuccess" => true, "jumpUrl" => $jumpUrl));
     } else {
         $this->checkFlowAccess($flowId, 1);
         if (!empty($flow->autoname)) {
             $runName = WfNewUtil::replaceAutoName($flow, $this->uid);
         } else {
             $runName = sprintf("%s (%s)", $flow->name, date("Y-m-d H:i:s"));
         }
         $data = array("flow" => $flow->toArray(), "runName" => $runName, "lang" => Ibos::getLangSources());
         $this->renderPartial("add", $data);
     }
 }
예제 #4
0
 protected function handleList($runProcess)
 {
     foreach ($runProcess as &$run) {
         $run["user"] = User::model()->fetchByUid($run["beginuser"]);
         $run["begintime"] = ConvertUtil::formatDate($run["begintime"], "u");
         $param = array("runid" => $run["runid"], "flowid" => $run["flowid"]);
         $run["key"] = WfCommonUtil::param($param);
     }
     return array("list" => $runProcess);
 }
예제 #5
0
 public function init()
 {
     $key = EnvUtil::getRequest("key");
     if ($key) {
         $this->key = $key;
         $param = WfCommonUtil::param($key, "DECODE");
         $this->runid = $param["runid"];
         $this->flowid = $param["flowid"];
         $this->processid = $param["processid"];
         $this->flowprocess = $param["flowprocess"];
     } else {
         $this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("list/index"));
     }
     parent::init();
 }
예제 #6
0
 protected function getListData($op)
 {
     switch ($op) {
         case "rule":
         case "berule":
             if ($op == "rule") {
                 $where = "fr.uid = {$this->uid}";
             } else {
                 $where = "fr.toid = {$this->uid} AND fr.status = 1";
             }
             $sqlText = "SELECT fr.*,ft.name as typeName,fr.toid as userID FROM {{flow_rule}} fr LEFT JOIN {{flow_type}} ft ON ft.flowid = fr.flowid LEFT JOIN {{user}} u ON fr.toid = u.uid WHERE {$where} ORDER BY fr.ruleid DESC";
             break;
         case "record":
         case "berecord":
             if ($op == "record") {
                 $idField = "uid";
             } else {
                 $idField = "toid";
             }
             $sqlText = "SELECT log.flowid,log.runid,log.runname,log.processid,log.toid as userID,log.time,frp.flag,frp.flowprocess,ft.type,ft.name as typeName,ft.flowid FROM {{flow_run_log}} log INNER JOIN {{flow_type}} ft ON log.flowid = ft.flowid LEFT JOIN {{flow_run_process}} frp ON frp.runid = log.runid WHERE frp.processid = log.processid AND log.{$idField} = {$this->uid} AND log.type = 2 GROUP BY log.processid ORDER BY log.runid DESC";
             break;
     }
     $query = Ibos::app()->db->createCommand()->setText($sqlText)->query();
     $count = $query->count();
     $pages = PageUtil::create($count, $this->getListPageSize());
     $offset = $pages->getOffset();
     $limit = $pages->getLimit();
     $list = Ibos::app()->db->createCommand()->setText($sqlText . " LIMIT {$offset},{$limit}")->queryAll();
     $now = strtotime(date("Y-m-d", TIMESTAMP));
     $proceses = FlowProcess::model()->fetchAllProcessSortByFlowId();
     foreach ($list as &$rec) {
         if ($op == "rule" || $op == "berule") {
             $condition1 = WfHandleUtil::compareTimestamp($now, $rec["begindate"]);
             $condition2 = WfHandleUtil::compareTimestamp($now, $rec["enddate"]);
             $rec["enabled"] = false;
             $rec["datedesc"] = "";
             if ($rec["status"] == 1) {
                 if ($rec["begindate"] != 0 && $rec["enddate"] != 0) {
                     $rec["datedesc"] = date("Y-m-d", $rec["begindate"]) . "--" . date("Y-m-d", $rec["enddate"]);
                     if (0 <= $condition1 && $condition2 <= 0) {
                         $rec["enabled"] = true;
                     }
                 } elseif ($rec["begindate"] != 0) {
                     $rec["datedesc"] = Ibos::lang("Entrust begin with", "", array("{date}" => date("Y-m-d", $rec["begindate"])));
                     if (0 <= $condition1) {
                         $rec["enabled"] = true;
                     }
                 } elseif ($rec["enddate"] != 0) {
                     $rec["datedesc"] = Ibos::lang("Entrust finish up width", "", array("{date}" => date("Y-m-d", $rec["enddate"])));
                     if ($condition2 <= 0) {
                         $rec["enabled"] = true;
                     }
                 } else {
                     $rec["datedesc"] = Ibos::lang("Always effective");
                     $rec["enabled"] = true;
                 }
             }
         } else {
             $rec["key"] = WfCommonUtil::param(array("runid" => $rec["runid"], "processid" => $rec["processid"], "flowprocess" => $rec["flowprocess"], "flowid" => $rec["flowid"]));
             if ($rec["type"] == 1) {
                 if (isset($proceses[$rec["flowid"]][$rec["flowprocess"]])) {
                     $rec["processname"] = $proceses[$rec["flowid"]][$rec["flowprocess"]]["name"];
                 }
             } else {
                 $rec["processname"] = Ibos::lang("Steps", "", array("{step}" => $rec["processid"]));
             }
         }
         $rec["user"] = User::model()->fetchByUid($rec["userID"]);
     }
     return array("pages" => $pages, "list" => $list);
 }
예제 #7
0
 public static function createNewRun($flowId, $uid, $uidstr, $pid = 0, $remind = 0, $startTime = "")
 {
     if (!$startTime) {
         $startTime = TIMESTAMP;
     }
     $flow = new ICFlowType(intval($flowId));
     $runName = self::replaceAutoName($flow, $uid, !!$pid);
     $maxRunId = FlowRun::model()->getMaxRunId();
     if ($maxRunId) {
         $runId = $maxRunId + 1;
     }
     $data = array("runid" => $runId, "name" => $runName, "flowid" => $flowId, "beginuser" => $uid, "begintime" => $startTime, "parentrun" => $pid);
     FlowRun::model()->add($data);
     if (strstr($runName, "{RUN}") !== false) {
         $runName = str_replace("{RUN}", $runId, $runName);
         FlowRun::model()->modify($runId, array("name" => $runName));
     }
     foreach (explode(",", trim($uidstr, ",")) as $k => $v) {
         if ($v == $uid) {
             $opflag = 1;
         } else {
             $opflag = 0;
         }
         $wrpdata = array("runid" => $runId, "processid" => 1, "uid" => $v, "flag" => 1, "flowprocess" => 1, "opflag" => $opflag, "createtime" => $startTime);
         FlowRunProcess::model()->add($wrpdata);
     }
     if ($remind) {
         $remindUrl = Ibos::app()->urlManager->createUrl("workflow/form/index", array("key" => WfCommonUtil::param(array("runid" => $runId, "flowid" => $flowId, "processid" => 1, "flowprocess" => 1))));
         $config = array("{url}" => $remindUrl, "{runname}" => $runName, "{runid}" => $runId);
         Notify::model()->sendNotify($uid, "workflow_new_notice", $config);
     }
     if ($pid != 0) {
         $pflowId = FlowRun::model()->fetchFlowIdByRunId($pid);
         $pRundata = WfHandleUtil::getRunData($pid);
         $pfield = $subFlow = array();
         $relation = FlowProcess::model()->fetchRelationOut($pflowId, $flowId);
         if ($relation) {
             $relationArr = explode(",", trim($relation, ","));
             foreach ($relationArr as $field) {
                 $pfield[] = substr($field, 0, strpos($field, "=>"));
                 $subFlow[] = substr($field, strpos($field, "=>") + strlen("=>"));
             }
         }
         $runData = array("runid" => $runId, "name" => $runName, "begin" => $startTime, "beginuser" => $uid);
     }
     $structure = $flow->form->parser->structure;
     if (is_array($structure) && 0 < count($structure)) {
         foreach ($structure as $k => $v) {
             if ($v["data-type"] !== "label") {
                 if ($v["data-type"] == "checkbox") {
                     if (stristr($v["content"], "checked") || stristr($v["content"], " checked=\"checked\"")) {
                         $itemData = "on";
                     } else {
                         $itemData = "";
                     }
                 }
                 if ($v["data-type"] != "select" && $v["data-type"] != "listview") {
                     $itemData = isset($v["data-value"]) ? $v["data-value"] : "";
                     $itemData = str_replace("\"", "", $itemData);
                     if ($v["data-type"] == "auto") {
                         $itemData = "";
                     }
                 }
                 if ($pid != 0 && in_array($v["data-title"], $subFlow)) {
                     $i = array_search($v["data-title"], $subFlow);
                     $ptitle = $pfield[$i];
                     $itemData = $pRundata["{$ptitle}"];
                     if (is_array($itemData) && $v["data-type"] == "listview") {
                         $itemDataStr = "";
                         $newDataStr = "";
                         for ($j = 1; $j < count($itemData); ++$j) {
                             foreach ($itemData[$j] as $val) {
                                 $newDataStr .= $val . "`";
                             }
                             $itemDataStr .= $newDataStr . "\r\n";
                             $newDataStr = "";
                         }
                         $itemData = $itemDataStr;
                     }
                 }
                 $runData[$k] = $itemData;
             }
         }
     }
     WfCommonUtil::addRunData($flowId, $runData, $structure);
     return $runId;
 }
예제 #8
0
 public function actionShowNext()
 {
     $key = EnvUtil::getRequest("key");
     if ($key) {
         $param = WfCommonUtil::param($key, "DECODE");
         $flowId = $param["flowid"];
         $runId = $param["runid"];
         $processId = $param["processid"];
         $flowProcess = $param["flowprocess"];
         $op = isset($param["op"]) ? $param["op"] : "";
         $topflag = EnvUtil::getRequest("topflag");
         $lang = Ibos::getLangSources();
         $this->nextAccessCheck($topflag, $runId, $processId);
         $run = new ICFlowRun($runId);
         $process = new ICFlowProcess($flowId, $flowProcess);
         $notAllFinished = array();
         $parent = "";
         foreach (FlowRunProcess::model()->fetchAllByRunIDProcessID($runId, $processId) as $rp) {
             if ($rp["flowprocess"] == $flowProcess) {
                 $parent .= $rp["parent"] . ",";
                 if (($rp["flag"] == self::TRANS || $rp["flag"] == self::DONE) && $rp["uid"] == $this->uid) {
                     $turnForbidden = true;
                 } else {
                     $turnForbidden = false;
                 }
                 if ($rp["flag"] != self::DONE && $rp["uid"] != $this->uid) {
                     $notAllFinished[] = $rp["uid"];
                 }
             }
         }
         if ($turnForbidden) {
             EnvUtil::iExit(Ibos::lang("Already trans"));
         }
         if (!empty($notAllFinished)) {
             $notAllFinished = User::model()->fetchRealnamesbyUids($notAllFinished);
         } else {
             $notAllFinished = "";
         }
         if ($process->gathernode == self::FORCE) {
             foreach (FlowProcess::model()->fetchAllGatherNode($flowId, $flowProcess) as $fp) {
                 $isUntrans = FlowRunProcess::model()->getIsUntrans($runId, $fp["processid"]);
                 if (!StringUtil::findIn($fp["processid"], $parent)) {
                     if ($isUntrans) {
                         EnvUtil::iExit(Ibos::lang("Gathernode trans error"));
                     }
                 }
             }
         }
         if ($process->processto == "") {
             $prcsMax = FlowProcess::model()->fetchMaxProcessIDByFlowID($flowId);
             if ($flowProcess !== $prcsMax) {
                 $process->processto = $flowProcess + 1;
             } else {
                 $process->processto = "0";
             }
         }
         $prcsArr = explode(",", trim($process->processto, ","));
         $prcsArrCount = count($prcsArr);
         $prcsEnableCount = 0;
         $prcsStop = "S";
         $prcsback = "";
         $prcsEnableFirst = null;
         $list = array();
         $formData = WfHandleUtil::getFormData($flowId, $runId);
         foreach ($prcsArr as $key => $to) {
             $param = array("checked" => "false");
             if ($to == "0") {
                 $param["isover"] = true;
                 $param["prcsname"] = $run->parentrun !== "0" ? Ibos::lang("End subflow") : Ibos::lang("Form endflow");
                 $prcsStop = $key;
                 $prcsEnableCount++;
                 if ($prcsEnableCount == 1) {
                     $param["checked"] = "true";
                     $prcsEnableFirst = $key;
                 }
                 if ($run->parentrun !== "0") {
                     $parentFlowId = FlowRun::model()->fetchFlowIdByRunId($run->parentrun);
                     $parentProcess = FlowRun::model()->fetchIDByChild($run->parentrun, $runId);
                     $parentFlowProcess = $parentProcess["flowprocess"];
                     if ($parentFlowId && $parentFlowProcess) {
                         $temp = FlowProcess::model()->fetchProcess($parentFlowId, $parentFlowProcess);
                         if ($temp) {
                             $prcsback = $temp["processto"];
                             $backUserOP = $temp["autouserop"];
                             $param["backuser"] = $temp["autouser"];
                         }
                     }
                     if ($prcsback != "") {
                         $param["prcsusers"] = WfHandleUtil::getPrcsUser($flowId, $prcsback);
                         $param["display"] = $prcsEnableFirst !== $prcsStop ? false : true;
                         if (isset($backUserOP)) {
                             $param["prcsopuser"] = $backUserOP;
                         }
                     }
                 }
             } else {
                 $param["isover"] = false;
                 $curProcess = FlowProcess::model()->fetchProcess($flowId, $to);
                 $param["prcsname"] = $curProcess["name"];
                 $processOut = FlowProcessTurn::model()->fetchByUnique($flowId, $processId, $to);
                 if (!$processOut) {
                     $processOut = array("processout" => "", "conditiondesc" => "");
                 }
                 $notpass = WfHandleUtil::checkCondition($formData, $processOut["processout"], $processOut["conditiondesc"]);
                 if ($curProcess["childflow"] !== "0") {
                     $param["prcsname"] .= "(" . $lang["Subflow"] . ")";
                 }
                 if (substr($notpass, 0, 5) == "setok") {
                     $notpass = "";
                 }
                 if ($notpass == "") {
                     $prcsEnableCount++;
                     if ($prcsEnableCount == 1 || 0 < $process->syncdeal && !is_numeric($prcsStop)) {
                         $param["checked"] = "true";
                         if ($prcsEnableCount == 1) {
                             $prcsEnableFirst = $key;
                         }
                     }
                     unset($param["notpass"]);
                     $param["selectstr"] = $this->makeUserSelect($runId, $key, $curProcess, $param["prcsname"], $flowId, $processId);
                 } else {
                     $param["notpass"] = $notpass;
                 }
             }
             $list[$key] = $param;
         }
         if ($prcsEnableCount == 0) {
             if ($notpass == "") {
                 EnvUtil::iExit($lang["Process define error"]);
             } else {
                 EnvUtil::iExit($notpass);
             }
         }
         $data = array("lang" => $lang, "notAllFinished" => $notAllFinished, "enableCount" => $prcsEnableCount, "prcsto" => $prcsArr, "prcsback" => $prcsback, "notpass" => isset($notpass) ? $notpass : "", "process" => $process->toArray(), "run" => $run->toArray(), "runid" => $runId, "flowid" => $flowId, "processid" => $processId, "flowprocess" => $flowProcess, "count" => $prcsArrCount, "prcsStop" => $prcsStop, "topflag" => $topflag, "list" => $list, "op" => $op);
         $this->ajaxReturn($data, "JSONP");
     }
 }
예제 #9
0
 private function setOtherInfo(&$run)
 {
     if ($this->type !== "done") {
         $run["focus"] = StringUtil::findIn($this->uid, $run["focususer"]);
     } elseif (!empty($run["endtime"])) {
         $usedTime = $run["endtime"] - $run["begintime"];
         $run["usedtime"] = WfCommonUtil::getTime($usedTime);
     }
     $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]);
     $run["key"] = WfCommonUtil::param($param);
 }
예제 #10
0
파일: IWWfBase.php 프로젝트: AxelPanda/ibos
 public function makeKey($param = array())
 {
     if (!empty($param)) {
         return WfCommonUtil::param($param);
     }
 }
예제 #11
0
 public function actionRedo()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $key = EnvUtil::getRequest("key");
         if ($key) {
             $param = WfCommonUtil::param($key, "DECODE");
             $uid = intval(EnvUtil::getRequest("uid"));
             $per = WfCommonUtil::getRunPermission($param["runid"], $this->uid, $param["processid"]);
             if (!StringUtil::findIn($per, 2)) {
                 exit(Ibos::lang("Permission denied"));
             }
             if ($this->redo($param["runid"], $param["processid"], $uid, $param["flowprocess"])) {
                 $this->ajaxReturn(array("isSuccess" => true));
             } else {
                 $this->ajaxReturn(array("isSuccess" => false));
             }
         }
     }
 }
예제 #12
0
 public function actionRestoreDelay()
 {
     $key = EnvUtil::getRequest("key");
     $param = WfCommonUtil::param($key, "DECODE");
     $this->checkRunAccess($param["runid"], $param["processid"]);
     if (FlowRunProcess::model()->restoreDelay($param["runid"], $param["processid"], $param["flowprocess"])) {
         $this->ajaxReturn(array("isSuccess" => true));
     } else {
         $this->ajaxReturn(array("isSuccess" => false));
     }
 }
예제 #13
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);
 }
예제 #14
0
 protected function getListData()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $runid = intval(EnvUtil::getRequest("runid"));
         $flowid = intval(EnvUtil::getRequest("flowid"));
         $userType = EnvUtil::getRequest("usertype");
         $runName = StringUtil::filterCleanHtml(EnvUtil::getRequest("runname"));
         $toid = !empty($_POST["toid"]) ? implode(",", StringUtil::getId($_POST["toid"])) : "";
     } else {
         $runid = 0;
         $userType = $runName = $toid = "";
         $flowid = "all";
     }
     $flowIds = WfQueryUtil::getMyFlowIDs($this->uid);
     if (empty($flowIds)) {
         $flowIds = array(0);
     }
     $condition = array("and", "fr.delflag = 0", array("in", "fr.flowid", $flowIds), array("in", "frp.flag", array(1, 2)), "(frp.opflag = 1 OR frp.topflag = 2)");
     $field = "frp.runid,frp.processid,frp.uid,frp.flag,frp.processtime,frp.flowprocess,fr.attachmentid,fr.focususer,ft.freeother";
     if ($flowid !== "all") {
         $condition[] = "ft.flowid = " . $flowid;
     }
     if (!empty($runid)) {
         $condition[] = "fr.runid = " . $runid;
     }
     if (!empty($runName)) {
         $condition[] = " fr.name LIKE '%{$runName}%'";
     }
     if ($toid != "") {
         if ($userType == "opuser") {
             $condition[] = "frp.uid = {$toid}";
         } else {
             $condition[] = "fr.beginuser = {$toid}";
         }
     }
     $lang = Ibos::getLangSource("workflow.default");
     $count = Ibos::app()->db->createCommand()->select("count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->where($condition)->queryScalar();
     $pages = PageUtil::create($count, $this->getListPageSize());
     $list = Ibos::app()->db->createCommand()->select($field)->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->where($condition)->group("frp.runid")->order("frp.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll();
     foreach ($list as $k => &$rec) {
         $temp = Ibos::app()->db->createCommand()->select("ft.flowid,ft.freeother,fr.name as runName,ft.name as typeName,ft.type,ft.sort")->from("{{flow_type}} ft")->leftJoin("{{flow_run}} fr", "fr.flowid = ft.flowid")->where("fr.runid = " . $rec["runid"])->queryRow();
         if ($temp) {
             $rec = array_merge($rec, $temp);
         } else {
             continue;
         }
         if ($temp["type"] == 1) {
             $fp = FlowProcess::model()->fetchProcess($temp["flowid"], $rec["flowprocess"]);
             if ($fp) {
                 $rec["stepname"] = $fp["name"];
             } else {
                 $rec["stepname"] = $lang["Process steps already deleted"];
             }
         } else {
             $rec["stepname"] = Ibos::lang("Step", "", array("{step}" => $rec["processid"]));
         }
         if ($rec["flag"] == FlowConst::PRCS_UN_RECEIVE) {
             $deliverTime = FlowRunProcess::model()->fetchDeliverTime($rec["runid"], $rec["flowprocess"]);
             if ($deliverTime) {
                 $prcsBeginTime = $deliverTime;
             }
         } else {
             $prcsBeginTime = $rec["processtime"];
         }
         if (!isset($prcsBeginTime) || $prcsBeginTime == 0) {
             $prcsBeginTime = TIMESTAMP;
         }
         $usedTime = TIMESTAMP - $prcsBeginTime;
         $rec["timestr"] = WfCommonUtil::getTime($usedTime, "dhi");
         if (!empty($rec["attachmentid"])) {
             $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]);
         }
         $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]);
         $rec["user"] = User::model()->fetchByUid($rec["uid"]);
         $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"], "processid" => $rec["processid"], "flowprocess" => $rec["flowprocess"]));
         if (empty($rec["user"])) {
             unset($list[$k]);
         }
     }
     return array("list" => $list, "pages" => $pages);
 }
예제 #15
0
 protected function getListData()
 {
     $param = $this->getListFilterParam();
     $field = "fr.runid,fr.name as runName,fr.begintime,fr.endtime,ft.name as typeName,fr.attachmentid,fr.focususer,fr.beginuser,ft.flowid,ft.type,ft.freeother";
     $condition = array("and", "fr.delflag = 0");
     if ($param["flowid"]) {
         $condition[] = "ft.flowid = " . $param["flowid"];
         $isManager = FlowPermission::model()->fetchPermission($this->uid, $param["flowid"], array(0, 1));
     } else {
         $isManager = false;
     }
     if ($param["start"]) {
         $condition[] = "fr.begintime >= " . $param["start"];
     }
     if ($param["end"]) {
         $condition[] = "fr.endtime <= " . $param["end"];
     }
     $flowIds = WfQueryUtil::getMyFlowIDs($this->uid);
     $myRuns = FlowRun::model()->fetchAllMyRunID($this->uid, $param["flowid"]);
     if ($param["scope"] == "none" && Ibos::app()->user->isadministrator != 1) {
         $condition[] = sprintf("(FIND_IN_SET(fr.runid,'%s') OR FIND_IN_SET(ft.flowid,'%s'))", implode(",", $myRuns), implode(",", $flowIds));
     } elseif ($param["scope"] == "start") {
         $beginUser = $this->uid;
     } elseif ($param["scope"] == "handle") {
         $condition[] = array("in", "fr.runid", $myRuns);
     } else {
         if ($param["scope"] == "manage" && Ibos::app()->user->isadministrator != 1) {
             $condition[] = sprintf("FIND_IN_SET('%s',ft.flowid)", implode(",", $flowIds));
         } elseif ($param["scope"] == "focus") {
             $implodeStr = WfCommonUtil::implodeSql($this->uid, "fr.focususer");
             $condition[] = sprintf("fr.focususer = %d%s", $this->uid, $implodeStr);
         } elseif ($param["scope"] == "custom") {
             if (Ibos::app()->user->isadministrator != 1) {
                 $condition[] = sprintf("FIND_IN_SET(ft.flowid,'%s')", implode(",", $flowIds));
             }
             $beginUser = implode(",", StringUtil::getId($param["beginuser"]));
         } elseif (Ibos::app()->user->isadministrator != 1) {
             $this->error(Ibos::lang("Parameters error", "error"));
         }
     }
     if ($param["type"] !== "all") {
         if ($param["type"] == "perform") {
             $condition[] = "fr.endtime = 0";
         } else {
             $condition[] = "fr.endtime != 0";
         }
     }
     if (isset($beginUser)) {
         $condition[] = "fr.beginuser = "******"count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->queryScalar();
     $pages = PageUtil::create($count, $this->getListPageSize());
     $list = Ibos::app()->db->createCommand()->select($field)->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order("fr.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll();
     foreach ($list as &$rec) {
         if (!empty($rec["attachmentid"])) {
             $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]);
         }
         $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]);
         $rec["user"] = User::model()->fetchByUid($rec["beginuser"]);
         $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"]));
         $rec["begin"] = ConvertUtil::formatDate($rec["begintime"], "n月j日 H:i");
     }
     return array("list" => $list, "pages" => $pages, "advanceOpt" => $isManager || Ibos::app()->user->isadministrator == 1);
 }