public function actionDestroy() { $id = EnvUtil::getRequest("id"); $runId = StringUtil::filterStr(StringUtil::filterCleanHtml($id)); WfHandleUtil::destroy($runId); $this->ajaxReturn(array("isSuccess" => true)); }
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); }
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; }
public static function getExportData($list, $param) { $lang = Ibos::getLangSources(array("workflow.default")); $data = $titles = $sum = array(); $group = ""; $flow = new ICFlowType($param["flowid"]); $structure = $flow->form->parser->structure; foreach ($list as $index => $row) { if (!empty($param["condition"])) { $formData = WfHandleUtil::getFormData($row["flowid"], $row["runid"]); $notPass = WfHandleUtil::checkCondition($formData, $param["condition"], ""); if ($notPass !== "") { continue; } } $queryHidden = Ibos::app()->db->createCommand()->select("hiddenitem")->from("{{flow_process}} fp")->leftJoin("{{flow_run_process}} frp", "fp.processid = frp.flowprocess")->where(sprintf("fp.flowid = %d AND frp.runid = %d AND frp.uid = %d", $param["flowid"], $row["runid"], $param["uid"]))->queryAll(); $hidden = ConvertUtil::getSubByKey($queryHidden, "hiddenitem"); $itemData = FlowDataN::model()->fetch($param["flowid"], $row["runid"]); $processor = new ICPrintViewProcessor(array("itemData" => $itemData)); foreach (explode(",", $param["viewextfields"]) as $key => $field) { if (strpos($field, ".") !== false) { list(, $itemID) = explode(".", $field); $item = isset($structure[$itemID]) ? $structure[$itemID] : array(); if (empty($item)) { continue; } if ($item["data-type"] == "sign" || $item["data-type"] == "label") { continue; } if (in_array($item["data-title"], $hidden)) { $value = ""; } else { $itemValue = $itemData[$itemID]; switch ($item["data-type"]) { case "checkbox": if ($itemValue == "on") { $value = $lang["Yes"]; } else { $value = $lang["No"]; } break; case "user": case "auto": $method = $item["data-type"] . "Processor"; if (method_exists($processor, $method)) { $value = $processor->{$method}($item, true); } break; case "listview": $sumflag = 0; $lv_subject = $item["data-lv-title"]; $lv_sum = $item["data-lv-sum"]; $lv_sum_array = explode("`", $lv_sum); if (strstr($lv_sum, "1")) { $sumflag = 1; } $lv_value = $itemValue; $item_value = "<table class='commonTable2' ><tr>\n"; $my_array = explode("`", $lv_subject); $array_count_title = sizeof($my_array); if ($my_array[$array_count_title - 1] == "") { $array_count_title--; } for ($i = 0; $i < $array_count_title; $i++) { $item_value .= "<td>" . $my_array[$i] . "</td>\n"; } $item_value .= "</tr>\n"; $my_array = explode("\r\n", $lv_value); $array_count = sizeof($my_array); if ($my_array[$array_count - 1] == "") { $array_count--; } $sum_data = array(); for ($i = 0; $i < $array_count; $i++) { $item_value .= "<tr>\n"; $tr_data = $my_array[$i]; $my_array1 = explode("`", $tr_data); for ($j = 0; $j < $array_count_title; $j++) { if ($lv_sum_array[$j] == 1) { $sum_data[$j] += $my_array1[$j]; } $td_data = $my_array1[$j]; if ($td_data == "") { $td_data = " "; } $item_value .= "<td>" . $td_data . "</td>\n"; } $item_value .= "</tr>\n"; } if ($sumflag == 1 && 0 < $array_count) { $item_value .= "<tr style='font-weight:bold;'>\n"; for ($j = 0; $j < $array_count_title; $j++) { if ($sum_data[$j] == "") { $sumvalue = " "; } else { $sumvalue = "合计:" . $sum_data[$j]; } $item_value .= "<td align=right>" . $sumvalue . "</td>\n"; } $item_value .= "</tr>\n"; } $item_value .= "</table>\n"; break; default: $value = isset($itemData[$itemID]) ? $itemData[$itemID] : ""; break; } } $title = $item["data-title"]; } else { switch ($field) { case "runid": $value = $row["runid"]; $title = $lang["Flow no"]; break; case "runname": $value = $row["runName"]; $title = $lang["Flow subject/num"]; break; case "runstatus": if ($param["flowconditions"]["flowstatus"] == "all") { if ($row["endtime"] == 0) { $status = "<span class=\"red\">{$lang["Perform"]}</span>"; } else { $status = $lang["Has ended"]; } } elseif ($param["flowconditions"]["flowstatus"] == "0") { $status = "<span class=\"red\">{$lang["Perform"]}</span>"; } else { $status = $lang["Has ended"]; } $value = $status; $title = $lang["Flow status"]; break; case "rundate": $value = date("Y-m-d", $row["begintime"]); $title = $lang["Flow begin date"]; break; case "runtime": $value = ConvertUtil::formatDate($row["begintime"]); $title = $lang["Flow begin time"]; break; default: break; } } if (StringUtil::findIn($param["sumfields"], $field)) { $sum[] = $key; } $data[$index][$key] = $value; if ($index == 0) { if (strcmp($param["groupbyfields"]["field"], $field) == 0) { $group = $key; } $titles[$key] = $title; } } } return array("title" => $titles, "data" => $data, "sum" => $sum, "group" => $group, "sum_data" => isset($sum_data) ? $sum_data : array()); }
protected function makeUserSelect($runId, $index, $process, $name, $flowId, $processId) { $lang = Ibos::getLangSource("workflow.default"); $tablestr = ""; if ($index) { $display = "none;"; } else { $display = ""; } if ($process["childflow"] != 0) { $flow = FlowType::model()->fetchByPk($process["childflow"]); if ($flow) { $type = $flow["type"]; } if ($type == 2) { $process["prcs_id_next"] = ""; } $subfp = FlowProcess::model()->fetchProcess($process["childflow"], 1); if ($subfp) { $prcsuser = WfHandleUtil::getPrcsUser($process["childflow"], $processId); } else { $prcsuser = ""; } $prcsuser = sprintf("[%s]", !empty($prcsuser) ? StringUtil::iImplode($prcsuser) : ""); if (empty($subfp["uid"]) && empty($subfp["deptid"]) && empty($subfp["positionid"])) { $nopriv = $lang["Not set step permissions"]; } $tablestr = " <div style='display:{$display};' id='user_select_{$index}'>\r\n <div class=\"control-group first-group\">\r\n <label class=\"control-label\">{$lang["Host"]}</label>\r\n <div class=\"controls\">\r\n <strong>{$name} {$nopriv}</strong>\r\n <input type=\"hidden\" name=\"topflag{$index}\" value=\"0\">\r\n <input id=\"prcs_user_op{$index}\" name=\"prcs_user_op{$index}\" type=\"text\" />\r\n </div>\r\n </div>\r\n <div class=\"control-group\">\r\n <label class=\"control-label\">{$lang["Agent"]}</label>\r\n <div class=\"controls\">\r\n <input id=\"prcs_user{$index}\" name=\"prcs_user{$index}\" type=\"text\" />\r\n </div>\r\n </div>\r\n </div>\r\n <script>\r\n\t\t\t\t\$(function(){\r\n\t\t\t\t\tvar prcsData{$index} = {$prcsuser};\r\n\t\t\t\t\t\$('#prcs_user_op{$index}').userSelect({\r\n\t\t\t\t\t\tbox:\$('<div id=\"prcs_user_op_box{$index}\"></div>').appendTo(document.body),\r\n\t\t\t\t\t\tdata:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\t\ttype:'user',\r\n\t\t\t\t\t\tmaximumSelectionSize:'1'\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\$('#prcs_user{$index}').userSelect({\r\n\t\t\t\t\t\tbox:\$('<div id=\"prcs_user_box{$index}\"></div>').appendTo(document.body),\r\n\t\t\t\t\t\tdata:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\t\ttype:'user'\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t</script>"; } else { if (empty($process["uid"]) && empty($process["deptid"]) && empty($process["positionid"])) { $nopriv = $lang["Not set step permissions"]; } $prcsOpUser = $prcsUserAuto = ""; $deptArr = DepartmentUtil::loadDepartment(); if ($process["autotype"] == 1) { $uid = FlowRun::model()->fetchBeginUserByRunID($runId); $prcsuser = User::model()->fetchByUid($uid); if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $prcsuser["uid"]) || StringUtil::findIn($process["deptid"], $prcsuser["alldeptid"]) || StringUtil::findIn($process["positionid"], $prcsuser["allposid"])) { $prcsOpUser = $prcsuser["uid"]; $prcsUserAuto = $prcsuser["uid"] . ","; } } elseif (in_array($process["autotype"], array(2, 4, 5, 6))) { if ($process["autobaseuser"] != 0) { $baseUid = FlowRunProcess::model()->fetchBaseUid($runId, $process["autobaseuser"]); $baseuser = User::model()->fetchByUid($baseUid); $autodept = $baseuser["deptid"]; } else { $autodept = Ibos::app()->user->deptid; } if (0 < intval($autodept)) { if ($process["autotype"] == 2) { $tmpdept = $autodept; } else { if ($process["autotype"] == 4 || $process["autotype"] == 6) { $tmpdept = $deptArr[$autodept]["pid"] == 0 ? $autodept : $deptArr[$autodept]["pid"]; } elseif ($process["autotype"] == 5) { $deptStr = Department::model()->queryDept($autodept, true); $temp = explode(",", $deptStr); $count = count($temp); $dept = isset($temp[$count - 2]) ? $temp[$count - 2] : $autodept; if ($deptArr[$dept]["pid"] != 0) { $tmpdept = $deptArr[$dept]["deptid"]; } else { $tmpdept = $autodept; } } } $manager = $deptArr[$tmpdept]["manager"]; if ($process["autotype"] == 4 || $process["autotype"] == 6) { $leader = $deptArr[$autodept]["leader"]; $subleader = $deptArr[$autodept]["subleader"]; if ($leader != "0" && $process["autotype"] == 4) { $manager = $leader; } if ($subleader != "0" && $process["autotype"] == 6) { $manager = $subleader; } } if (!empty($manager)) { $muser = User::model()->fetchByUid($manager); if (!empty($muser)) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $muser["uid"]) || StringUtil::findIn($process["deptid"], $muser["alldeptid"]) || StringUtil::findIn($process["positionid"], $muser["allposid"])) { $prcsUserAuto = $muser["uid"] . ","; } if ($prcsUserAuto != "") { $prcsOpUser = strtok($prcsUserAuto, ","); } } } else { $userPerMax = ""; foreach (User::model()->fetchAllOtherManager($tmpdept) as $user) { $user = User::model()->fetchByUid($user["uid"]); $uid = $user["uid"]; $position = $user["allposid"]; if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $uid) || StringUtil::findIn($process["deptid"], $user["alldeptid"]) || StringUtil::findIn($process["positionid"], $position)) { if ($userPerMax == "") { $prcsOpUser = $uid; $prcsUserAuto .= $uid . ","; $userPerMax = $position; } elseif ($position == $userPerMax) { $prcsUserAuto .= $uid . ","; } } } } } } elseif ($process["autotype"] == 3) { $autouserop = User::model()->fetchByUid($process["autouserop"]); if (!empty($autouserop)) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $autouserop["uid"]) || StringUtil::findIn($process["deptid"], $autouserop["alldeptid"]) || StringUtil::findIn($process["positionid"], $autouserop["allposid"])) { $prcsOpUser = $autouserop["uid"]; } } if (!empty($process["autouser"])) { foreach (User::model()->fetchAllByUids(explode(",", trim($process["autouser"], ","))) as $user) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $user["uid"]) || StringUtil::findIn($process["deptid"], $user["alldeptid"]) || StringUtil::findIn($process["positionid"], $user["allposid"])) { $prcsUserAuto .= $user["uid"] . ","; } } } } elseif ($process["autotype"] == 7) { if (is_numeric($process["autouser"])) { $itemData = FlowDataN::model()->fetchItem($process["autouser"], $process["flowid"], $runId); $tmp = strtok($itemData, ","); $userarr = array(); while ($tmp) { $userarr[$tmp] = array(); $tmp = strtok(","); } $tempArray = explode(",", trim($itemData, ",")); foreach ($tempArray as $key => $value) { if (is_numeric($value)) { $value = User::model()->fetchRealnameByUid($value, ""); $tempArray[$key] = $value; } } foreach (User::model()->fetchAllByRealnames($tempArray) as $k => $v) { $dept = Department::model()->queryDept($v["alldeptid"]); if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $dept) || StringUtil::findIn($process["positionid"], $v["allposid"])) { $prcsUserAuto .= $v["uid"] . ","; } } if ($prcsUserAuto != "") { $prcsOpUser = strtok($prcsUserAuto, ","); } } } else { if ($process["autotype"] == 8 && is_numeric($process["autouser"])) { $uid = FlowRunProcess::model()->fetchBaseUid($runId, $process["autouser"]); if ($uid) { $temp = User::model()->fetchByUid($uid); if ($temp) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $temp["uid"]) || StringUtil::findIn($process["deptid"], $temp["alldeptid"]) || StringUtil::findIn($process["positionid"], $temp["allposid"])) { $prcsOpUser = $prcsUserAuto = $temp["uid"]; $prcsUserAuto .= ","; } } } } elseif ($process["autotype"] == 9) { $main = Ibos::app()->user->deptid; foreach (User::model()->fetchAllFitDeptUser($main) as $k => $v) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $v["alldeptid"]) || StringUtil::findIn($process["positionid"], $v["allposid"])) { $prcsUserAuto .= $v["uid"] . ","; } } if (!empty($prcsUserAuto)) { $prcsOpUser = strtok($prcsUserAuto, ","); } } elseif ($process["autotype"] == 10) { $main = Ibos::app()->user->deptid; $deptStr = Department::model()->queryDept($main, true); $temp = explode(",", $deptStr); $count = count($temp); $dept = isset($temp[$count - 2]) ? $temp[$count - 2] : $main; if ($deptArr[$dept]["pid"] != 0) { $tmpdept = $deptArr[$dept]["deptid"]; } else { $tmpdept = $main; } foreach (User::model()->fetchAllFitDeptUser($tmpdept) as $k => $v) { if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $v["alldeptid"]) || StringUtil::findIn($process["positionid"], $v["allposid"])) { $prcsUserAuto .= $v["uid"] . ","; } } if (!empty($prcsUserAuto)) { $prcsOpUser = strtok($prcsUserAuto, ","); } } else { if ($process["uid"] != "" && $process["deptid"] == "" && $process["positionid"] == "") { $prcsUserArr = explode(",", $process["uid"]); $prcsUserCount = count($prcsUserArr) - 1; if ($prcsUserCount == 1) { $prcsUserAuto = $process["uid"]; $prcsOpUser = $prcsUserAuto; } } } } $prcsuser = WfHandleUtil::getPrcsUser($flowId, $process["processid"]); $prcsuser = sprintf("[%s]", !empty($prcsuser) ? StringUtil::iImplode($prcsuser) : ""); if ($process["userlock"] != 1) { $attr = 'islock="1"'; } else { $attr = ''; } if (!empty($prcsOpUser)) { $prcsOpUser = StringUtil::wrapId($prcsOpUser); } if (!empty($prcsUserAuto)) { $prcsUserAuto = StringUtil::wrapId(StringUtil::filterStr($prcsUserAuto)); } $tablestr = " <div class=\"control-group\" style=\"display:{$display};\" id='user_select_{$index}'>\r\n <div class=\"control-group first-group\">\r\n <label class=\"control-label\">{$lang["Host"]}</label>\r\n <div class=\"controls\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"topflag{$index}\" value=\"{$process["topdefault"]}\">\r\n\t\t\t\t\t<input id=\"prcs_user_op{$index}\" {$attr} name=\"prcs_user_op{$index}\" value=\"{$prcsOpUser}\" type=\"text\" />\r\n\t\t\t\t</div>\r\n </div>\r\n <div class=\"control-group\">\r\n <label class=\"control-label\">{$lang["Agent"]}</label>\r\n <div class=\"controls\">\r\n\t\t\t\t\t<input id=\"prcs_user{$index}\" {$attr} name=\"prcs_user{$index}\" value=\"{$prcsUserAuto}\" type=\"text\" />\r\n\t\t\t\t</div>\r\n </div>\r\n </div>\r\n <script>\r\n \$(function(){\r\n\t\t\t\tvar prcsData{$index} = {$prcsuser};\r\n var puo = \$('#prcs_user_op{$index}');\r\n var pu = \$('#prcs_user{$index}');\r\n\t\t\t\tvar topdef = '{$process["topdefault"]}';\r\n puo.userSelect({\r\n box:\$('<div id=\"prcs_user_op_box{$index}\"></div>').appendTo(document.body),\r\n data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user',\r\n maximumSelectionSize:'1'\r\n });\r\n if(puo.attr('islock')==1 || topdef != 0){\r\n puo.userSelect('setReadOnly');\r\n } \r\n pu.userSelect({\r\n\t\t\t\t\tbox:\$('<div id=\"prcs_user_box{$index}\"></div>').appendTo(document.body),\r\n data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user'\r\n });\r\n if(pu.attr('islock')==1){\r\n pu.userSelect('setReadOnly');\r\n }\r\n });\r\n </script>"; } return $tablestr; }
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 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); }
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); }
public function clearFlow($flowIds) { $ids = is_array($flowIds) ? $flowIds : explode(",", $flowIds); $count = 0; foreach ($ids as $id) { $flow = $this->fetchByPk($id); if (!empty($flow)) { $runs = FlowRun::model()->fetchAllByFlowId($id); if (!empty($runs)) { $runIds = ConvertUtil::getSubByKey($runs, "runid"); WfHandleUtil::destroy($runIds); $table = sprintf("{{flow_data_%d}}", $id); if (WfCommonUtil::tableExists($table)) { Ibos::app()->db->createCommand()->dropTable($table); } FlowRun::model()->deleteAllByAttributes(array("flowid" => $id)); $content = Ibos::lang("Clear flow", "workflow.default", array("{flowName}" => $flow["name"])); FlowManageLog::model()->log($id, $flow["name"], Ibos::app()->user->uid, 3, $content); $count++; } } } return $count; }