Ejemplo n.º 1
0
 protected function setGuideProcess(ICFlowType $flow, $curStep)
 {
     $guideProcess = $flow->guideprocess;
     $processPart = explode(",", $guideProcess);
     if (!in_array($curStep, $processPart)) {
         $processPart[] = $curStep;
         sort($processPart);
         $newProcess = implode(",", $processPart);
         FlowType::model()->updateByPk($flow->getID(), array("guideprocess" => $newProcess));
     }
 }
Ejemplo n.º 2
0
 public function del($ids)
 {
     $id = is_array($ids) ? implode(",", $ids) : $ids;
     $con = sprintf("FIND_IN_SET(catid,'%s')", $id);
     $flowCount = FlowType::model()->count($con);
     $formCount = FlowFormType::model()->count($con);
     if ($flowCount || $formCount) {
         return false;
     } else {
         return $this->deleteAll($con);
     }
 }
Ejemplo n.º 3
0
 public function actionGetPrcs()
 {
     $flowId = EnvUtil::getRequest("flowid");
     $runId = EnvUtil::getRequest("runid");
     $flow = FlowType::model()->fetchByPk($flowId);
     if ($flow["type"] == 1) {
         $prcs = WfPreviewUtil::getFixedPrcs($flowId, $runId);
     } else {
         $prcs = WfPreviewUtil::getFreePrcs($runId);
     }
     $this->ajaxReturn($prcs);
 }
Ejemplo n.º 4
0
 public function actionAdvanced()
 {
     $flowList = $sort = array();
     $enabledFlowIds = WfNewUtil::getEnabledFlowIdByUid($this->uid);
     foreach (FlowType::model()->fetchAll() as $flow) {
         $catId = $flow["catid"];
         $flowId = $flow["flowid"];
         if (!isset($flowList[$catId])) {
             $sort[$catId] = array();
             $cat = FlowCategory::model()->fetchByPk($catId);
             if ($cat) {
                 $sort[$catId] = $cat;
             }
         }
         if ($flow["usestatus"] == 3) {
             continue;
         }
         $enabled = in_array($flowId, $enabledFlowIds);
         if (!$enabled && $flow["usestatus"] == 2) {
             continue;
         }
         $per = FlowPermission::model()->fetchPermission($this->uid, $flowId);
         if ($flow["type"] == 1 && Ibos::app()->user->isadministrator != "1" && !$per) {
             if (!WfNewUtil::checkProcessPermission($flowId, 0, $this->uid)) {
                 continue;
             }
         }
         $handle = $done = 0;
         foreach (FlowRun::model()->fetchAllEndByFlowID($flowId) as $run) {
             if ($run["endtime"] == 0) {
                 $handle++;
             } else {
                 $done++;
             }
         }
         $flow["handle"] = $handle;
         $flow["done"] = $done;
         $flow["enabled"] = $enabled;
         $flowList[$catId][$flowId] = $flow;
     }
     ksort($flowList, SORT_NUMERIC);
     $this->setPageTitle(Ibos::lang("Select process"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang("Work query"), "url" => $this->createUrl("query/index")), array("name" => Ibos::lang("Advanced query"), "url" => $this->createUrl("query/advanced")), array("name" => Ibos::lang("Select process"))));
     $data = array("flows" => $flowList, "sort" => $sort);
     $this->render("advanced", $data);
 }
Ejemplo n.º 5
0
 private function handleList($runProcess)
 {
     $category = $flows = $list = array();
     foreach ($runProcess as $run) {
         $flowId = $run["flowid"];
         if (isset($flows[$flowId])) {
             $flow = $flows[$flowId];
         } else {
             $flows[$flowId] = $flow = FlowType::model()->fetchByPk($flowId);
         }
         $catId = $flow["catid"];
         if (!isset($list[$catId])) {
             $category[$catId] = array();
             $cat = FlowCategory::model()->fetchByPk($catId);
             if ($cat) {
                 $category[$catId] = $cat;
             }
         }
         if (isset($list[$catId][$flowId])) {
             if ($this->type == "todo") {
                 if ($run["flag"] == FlowConst::PRCS_UN_RECEIVE) {
                     $list[$catId][$flowId]["unreceive"]++;
                 }
             }
             $list[$catId][$flowId]["count"]++;
         } else {
             if ($this->type == "todo") {
                 if ($run["flag"] == FlowConst::PRCS_UN_RECEIVE) {
                     $flow["unreceive"] = 1;
                 } else {
                     $flow["unreceive"] = 0;
                 }
             }
             $flow["count"] = 1;
             $list[$catId][$flowId] = $flow;
         }
     }
     ksort($list, SORT_NUMERIC);
     return array("catSort" => $category, "list" => $list);
 }
Ejemplo n.º 6
0
 public function actionRestore()
 {
     $verID = intval(EnvUtil::getRequest("verid"));
     $ver = FlowFormVersion::model()->fetchByPk($verID);
     $formID = $ver["formid"];
     foreach (FlowType::model()->fetchAllAssociatedFlowIDByFormID($formID) as $flowID) {
         $hasRun = FlowRun::model()->countAllByFlowId($flowID);
         if ($hasRun) {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Formversion Still has run")));
         } else {
             continue;
         }
     }
     unset($ver["formid"]);
     unset($ver["id"]);
     unset($ver["time"]);
     unset($ver["mark"]);
     FlowFormType::model()->modify($formID, $ver);
     $form = new ICFlowForm($formID);
     $form->getParser()->parse(true);
     $this->ajaxReturn(array("isSuccess" => true));
 }
Ejemplo n.º 7
0
 public function actionCategory()
 {
     if (EnvUtil::submitCheck("formhash")) {
         if (isset($_POST["name"])) {
             foreach ($_POST["name"] as $id => $val) {
                 if (!empty($val)) {
                     $data = array("name" => StringUtil::filterCleanHtml($val), "sort" => intval($_POST["sort"][$id]), "deptid" => !empty($_POST["deptid"][$id]) ? implode(",", StringUtil::getId($_POST["deptid"][$id])) : "");
                     FlowCategory::model()->modify(intval($id), $data);
                 }
             }
         }
         if (isset($_POST["newname"])) {
             foreach ($_POST["newname"] as $id => $val) {
                 if (!empty($val)) {
                     $data = array("name" => StringUtil::filterCleanHtml($val), "sort" => intval($_POST["newsort"][$id]), "deptid" => !empty($_POST["newdeptid"][$id]) ? implode(",", StringUtil::getId($_POST["newdeptid"][$id])) : "");
                     FlowCategory::model()->add($data);
                 }
             }
         }
         if (!empty($_POST["delid"])) {
             $id = StringUtil::filterStr($_POST["delid"]);
             if (!FlowCategory::model()->del($id)) {
                 $this->error(Ibos::lang("Category delete require"));
             }
         }
         $this->success(Ibos::lang("Operation succeed", "message"));
     } else {
         $categorys = FlowCategory::model()->fetchAll(array("order" => "sort ASC"));
         foreach ($categorys as $key => &$cat) {
             if ($cat["deptid"] !== "") {
                 $cat["deptid"] = StringUtil::wrapId($cat["deptid"], "d");
             }
             $cat["flownums"] = FlowType::model()->countByAttributes(array("catid" => $cat["catid"]));
             $cat["formnums"] = FlowFormType::model()->countByAttributes(array("catid" => $cat["catid"]));
         }
         $this->render("category", array("list" => $categorys));
     }
 }
Ejemplo n.º 8
0
 public static function import($id, $file, $importUser = false)
 {
     $content = FileUtil::readFile($file);
     $xml = XmlUtil::xmlToArray($content);
     unset($xml["base"]["flowid"]);
     unset($xml["base"]["name"]);
     unset($xml["base"]["formid"]);
     unset($xml["base"]["sort"]);
     $user = array("newuser", "deptid", "uid", "positionid", "autouserop", "autouser", "mailto");
     $data = array();
     foreach ($xml["base"] as $key => $value) {
         $key = strtolower($key);
         if (!$importUser && in_array($key, $user)) {
             continue;
         }
         $data[$key] = $value;
     }
     FlowType::model()->modify($id, $data);
     unset($xml["base"]);
     unset($data);
     FlowProcess::model()->deleteAllByAttributes(array("flowid" => $id));
     if (!empty($xml)) {
         foreach ($xml as $process) {
             unset($process["id"]);
             $data = array();
             $process["flowid"] = $id;
             foreach ($process as $k => $v) {
                 if (!$importUser && in_array($k, $user)) {
                     continue;
                 }
                 $data[$k] = $v;
             }
             FlowProcess::model()->add($data);
         }
     }
     FileUtil::deleteFile($file);
 }
Ejemplo n.º 9
0
 protected function checkEntrustType($flowId)
 {
     $freeOther = FlowType::model()->fetchFreeOtherByFlowID($flowId);
     if ($freeOther == 0) {
         exit(Ibos::lang("No entrust permission"));
     }
 }
Ejemplo n.º 10
0
 protected function handleStartFlowList(&$data)
 {
     $flowList = $commonlyFlowList = $sort = array();
     $enabledFlowIds = WfNewUtil::getEnabledFlowIdByUid($this->uid);
     $commonlyFlowIds = FlowRun::model()->fetchCommonlyUsedFlowId($this->uid);
     foreach (FlowType::model()->fetchAll(array("order" => "sort,flowid")) as $flow) {
         $catId = $flow["catid"];
         $flowId = $flow["flowid"];
         if (!isset($flowList[$catId])) {
             $sort[$catId] = array();
             $cat = FlowCategory::model()->fetchByPk($catId);
             if ($cat) {
                 $sort[$catId] = $cat;
             }
         }
         if ($flow["usestatus"] == 3) {
             continue;
         }
         $enabled = in_array($flowId, $enabledFlowIds);
         if (!$enabled && $flow["usestatus"] == 2) {
             continue;
         }
         $flow["enabled"] = $enabled;
         if (in_array($flowId, $commonlyFlowIds)) {
             $commonlyFlowList[] = $flow;
         }
         $flowList[$catId][$flowId] = $flow;
     }
     ksort($flowList, SORT_NUMERIC);
     $data["flows"] = $flowList;
     $data["sort"] = $sort;
     $data["commonlyFlows"] = $commonlyFlowList;
 }
Ejemplo n.º 11
0
 public static function getEnabledFlowIdByUid($uid)
 {
     $user = User::model()->fetchByUid(intval($uid));
     $flowIds = array();
     $fixedFlowPer = FlowProcess::model()->fetchAllFirstStepPermission();
     foreach ($fixedFlowPer as $fixedFlow) {
         $deptAccess = self::compareIds($user["alldeptid"], $fixedFlow["deptid"], "d");
         $userAccess = self::compareIds($uid, $fixedFlow["uid"], "u");
         $posAccess = self::compareIds($user["allposid"], $fixedFlow["positionid"], "p");
         if ($deptAccess || $userAccess || $posAccess) {
             $flowIds[] = $fixedFlow["flowid"];
         }
     }
     $freeFlowPer = FlowType::model()->fetchAllFreePermission();
     foreach ($freeFlowPer as $freeFlow) {
         $ids = $freeFlow["newuser"];
         if (!empty($ids)) {
             $deptAccess = self::compareMixedIds($user["alldeptid"], $ids, "d");
             $userAccess = self::compareMixedIds($uid, $ids, "u");
             $posAccess = self::compareMixedIds($user["allposid"], $ids, "p");
             if ($deptAccess || $userAccess || $posAccess) {
                 $flowIds[] = $freeFlow["flowid"];
             }
         }
     }
     return array_unique($flowIds);
 }
Ejemplo n.º 12
0
 public static function export($condition, $param, $type = "html")
 {
     $name = FlowType::model()->fetchNameByFlowId($param["flowid"]);
     $list = Ibos::app()->db->createCommand()->select("fr.name as runName,ft.name as typeName,fr.*,ft.*")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->queryAll();
     $edata = self::getExportData($list, $param);
     $title = $edata["title"];
     $data = $edata["data"];
     $sum = $edata["sum"];
     $sum_data = $edata["sum_data"];
     $group = $edata["group"];
     if (empty($data)) {
         EnvUtil::iExit("无符合条件的记录");
     }
     $groupTitle = $title[$group];
     if ($type == "html") {
         $html = "                <html>\r\n                    <head>\r\n                        <title>工作流分组统计报表 - {$name}</title>\r\n                        <style>\r\n                        .TableData {\r\n                            background: none repeat scroll 0 0 #FFFFFF;\r\n                            color: #000000;\r\n                        }\r\n                        .TableContent {\r\n                            background: none repeat scroll 0 0 #F2F8FF;\r\n                        }\r\n                        </style>\r\n                        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n                    </head>\r\n                    <body topmargin=\"5\">\r\n\t\t\t\t\t<table>\r\n\t\t\t\t\t\t<tr>";
     } else {
         ob_end_clean();
         header("Cache-control: private");
         header("Content-type: application/vnd.ms-excel");
         header("Content-Disposition: attachment; filename= " . urlencode($name) . ".xls");
         $html = "                <html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n                xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\r\n                xmlns=\"http://www.w3.org/TR/REC-html40\">\r\n                <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t\t\t<body>\r\n\t\t\t\t\t<table>\r\n\t\t\t\t\t<tr style=\"background: #D3E5FA; color: #000000; font-weight: bold;\">";
     }
     $html .= "             <td class=\"TableControl\" align=\"center\" nowrap><strong>分组:{$groupTitle}&nbsp;</strong></td>\n";
     foreach ($title as $key => $name) {
         if ($key == $group || $name == "") {
             continue;
         }
         $html .= "<td align=\"center\" nowrap><strong>{$name}&nbsp;</strong></td>\n";
     }
     $html .= "</tr>\n";
     $rowCount = count($data);
     $colCount = count($data[0]);
     $data_index = $data_group = $sum_total_data = array();
     for ($i = 0; $i < $rowCount; $i++) {
         $data_index[0][$i] = $data[$i][$group];
         $data_index[1][$i] = $i;
     }
     if ($group == 0) {
         $sort_type = 1;
     } else {
         $sort_type = 2;
     }
     $sort_desc = 3;
     $sort_asc = 4;
     $sort_string = 1;
     if ($param["groupbyfields"]["order"] == "asc") {
         array_multisort($data_index[0], $sort_type, $sort_asc, $data_index[1], $sort_string, $sort_asc);
     } else {
         array_multisort($data_index[0], $sort_type, $sort_desc, $data_index[1], $sort_string, $sort_asc);
     }
     $cur_value_prev = "oa_null_value";
     $group_count = -1;
     for ($i = 0; $i < $rowCount; $i++) {
         if ($data_index[0][$i] != $cur_value_prev) {
             $group_count++;
         }
         $data_group[$group_count][0] = $data_index[0][$i];
         if (!isset($data_group[$group_count][1])) {
             $data_group[$group_count][1] = "";
         }
         $data_group[$group_count][1] .= $data_index[1][$i] . ",";
         $cur_value_prev = $data_index[0][$i];
     }
     for ($i = 0; $i <= $group_count; $i++) {
         $row_array = explode(",", $data_group[$i][1]);
         $array_count = count($row_array) - 1;
         $rowspan = $array_count;
         if (!empty($sum)) {
             $rowspan++;
         }
         for ($j = 0; $j < $array_count; $j++) {
             $html .= "<tr class=\"TableData\">\n";
             if ($j == 0) {
                 $html .= "<td rowspan=\"{$rowspan}\" class=\"TableContent\">\n";
                 $html .= $data_group[$i][0];
                 if ($param["groupbyfields"]["field"] != "runid") {
                     $html .= "<br><strong>共" . $array_count . "项";
                 }
                 $html .= "</td>\n";
             }
             for ($k = 0; $k < $colCount; $k++) {
                 if ($k == $group || $title[$k] == "") {
                     continue;
                 }
                 if (in_array($k, $sum)) {
                     if (!isset($sum_data[$k])) {
                         $sum_data[$k] = "";
                     }
                     if (!isset($sum_total_data[$k])) {
                         $sum_total_data[$k] = "";
                     }
                     $sum_data[$k] += $data[$row_array[$j]][$k];
                     $sum_total_data[$k] += $data[$row_array[$j]][$k];
                 }
                 $html .= "<td";
                 if (in_array($k, $sum)) {
                     $html .= " align=\"right\"";
                 }
                 $html .= ">" . $data[$row_array[$j]][$k] . "</td>\n";
             }
             $html .= "</tr>\n";
         }
         if (!empty($sum)) {
             $html .= "<tr class=\"TableData\">\n";
             $flag = 0;
             for ($k = 0; $k < $colCount; $k++) {
                 if ($k == $group) {
                     continue;
                 }
                 if ($flag == 0) {
                     $flag = 1;
                     $html .= " <td class=\"TableControl\" align=right><b>小计</b></td>\n";
                     continue;
                 }
                 $html .= "<td class=\"TableControl\" align=right>" . (isset($sum_data[$k]) ? $sum_data[$k] : "") . "&nbsp;</td>\n";
             }
             $html .= "</tr>\n";
         }
     }
     if (!empty($sum)) {
         $html .= "                \n<tr class=\"TableControl\">\r\n                    <td align=\"center\"><b>合计</b></td>\n";
         for ($k = 0; $k < $colCount; $k++) {
             if ($k == $group) {
                 continue;
             }
             $html .= "<td align=\"right\">" . (isset($sum_total_data[$k]) ? $sum_total_data[$k] : "") . "&nbsp;</td>\n";
         }
         $html .= "</tr>\n";
     }
     $html .= "</table></body></html>";
     echo $html;
 }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 14
0
 protected function setAllGuideInfo($formID)
 {
     foreach (FlowType::model()->fetchAllFlowIDByFormID($formID) as $flow) {
         $this->setGuideProcess(new ICFlowType(intval($flow["flowid"]), false), 2);
     }
 }
Ejemplo n.º 15
0
 public static function getFlowList($uid, $filterUseStatus = true)
 {
     $temp = array();
     foreach (FlowType::model()->fetchAllFlow() as $flow) {
         if (!WfNewUtil::checkProcessPermission($flow["flowid"], 0, $uid)) {
             continue;
         }
         if ($filterUseStatus && $flow["usestatus"] == 3) {
             continue;
         }
         $data = array("id" => $flow["flowid"], "text" => $flow["name"]);
         if (!isset($temp[$flow["catid"]])) {
             $temp[$flow["catid"]]["text"] = $flow["catname"];
             $temp[$flow["catid"]]["children"] = array();
         }
         $temp[$flow["catid"]]["children"][] = $data;
     }
     $result = array_merge(array(), $temp);
     return $result;
 }
Ejemplo n.º 16
0
 private function beforeSave()
 {
     $data =& $_POST;
     $process = array("processid" => intval($data["processid"]), "type" => intval($data["type"]));
     if (isset($data["attachpriv"]) && is_array($data["attachpriv"])) {
         $process["attachpriv"] = implode(",", $data["attachpriv"]);
     } else {
         $process["attachpriv"] = "";
     }
     if (!empty($data["prcsuser"])) {
         $users = StringUtil::getId($data["prcsuser"], true);
         if (isset($users["c"])) {
             $process["deptid"] = "alldept";
         } else {
             if (isset($users["d"])) {
                 $process["deptid"] = implode(",", $users["d"]);
             } else {
                 $process["deptid"] = "";
             }
             if (isset($users["p"])) {
                 $process["positionid"] = implode(",", $users["p"]);
             } else {
                 $process["positionid"] = "";
             }
             if (isset($users["u"])) {
                 $process["uid"] = implode(",", $users["u"]);
             } else {
                 $process["uid"] = "";
             }
         }
     } else {
         $process["uid"] = $process["deptid"] = $process["positionid"] = "";
     }
     if ($process["type"] == 1) {
         $childFlow = intval($data["childflow"]);
         $typeData = array("name" => FlowType::model()->fetchNameByFlowId($childFlow), "processto" => $data["prcsback"], "autouserop" => !empty($data["backuserop"]) ? implode(",", StringUtil::getId($data["backuserop"])) : "", "autouser" => !empty($data["backuser"]) ? implode(",", StringUtil::getId($data["backuser"])) : "", "childflow" => $childFlow, "relationout" => $data["map"]);
     } else {
         $autoUser = !empty($data["autouser"]) ? implode(",", StringUtil::getId($data["autouser"])) : "";
         $autoType = intval($data["autotype"]);
         if ($autoType == 7) {
             $autoUser = intval($data["itemid"]);
         } elseif ($autoType == 8) {
             $autoUser = intval($data["autoprcsuser"]);
         }
         $typeData = array("name" => StringUtil::filterCleanHtml($data["name"]), "plugin" => $data["plugin"], "pluginsave" => $data["pluginsave"], "feedback" => intval($data["feedback"]), "signlook" => intval($data["signlook"]), "autotype" => $autoType, "autouserop" => !empty($data["autouserop"]) ? implode(",", StringUtil::getId($data["autouserop"])) : "", "autouser" => $autoUser, "userfilter" => intval($data["userfilter"]), "timeout" => $data["timeout"], "syncdeal" => intval($data["syncdeal"]), "userlock" => isset($data["userlock"]) ? 1 : 0, "turnpriv" => isset($data["turnpriv"]) ? 1 : 0, "topdefault" => intval($data["topdefault"]), "gathernode" => intval($data["gathernode"]), "allowback" => $data["allowback"], "childflow" => 0, "autobaseuser" => intval($data["autobaseuser"]));
     }
     $process = array_merge($process, $typeData);
     $write = isset($data["write"]) ? $data["write"] : array();
     $secret = isset($data["secret"]) ? $data["secret"] : array();
     $check = isset($data["check"]) ? $data["check"] : array();
     $micro = isset($data["micro"]) ? $data["micro"] : array();
     $checkSelect = isset($data["check_select"]) ? $data["check_select"] : array();
     if (!empty($write)) {
         $prcsItem = $checkItem = array();
         foreach ($write as $title) {
             $prcsItem[] = $title;
             if (in_array($title, $check)) {
                 $key = array_search($title, $check);
                 if (isset($checkSelect[$key])) {
                     $checkItem[] = sprintf("%s=%s", $title, $checkSelect[$key]);
                 }
             }
         }
         $process["processitem"] = implode(",", $prcsItem);
         $process["checkitem"] = implode(",", $checkItem);
     } else {
         $process["processitem"] = $process["checkitem"] = "";
     }
     if (!empty($secret)) {
         $process["hiddenitem"] = implode(",", $secret);
     } else {
         $process["hiddenitem"] = "";
     }
     if (!empty($micro)) {
         $process["processitemauto"] = implode(",", $micro);
     } else {
         $process["processitemauto"] = "";
     }
     if (isset($data["conresult"])) {
         foreach ($data["conresult"] as $id => $cond) {
             FlowProcessTurn::model()->deleteAll(sprintf("`flowid` = '%d' AND `processid` = '%d' AND `to` = '%d'", $this->flow->getID(), $process["processid"], $id));
             $desc = $data["condesc"][$id];
             FlowProcessTurn::model()->add(array("processout" => $cond, "processid" => $process["processid"], "conditiondesc" => $desc, "flowid" => $this->flow->getID(), "to" => $id));
         }
     }
     return $process;
 }
Ejemplo n.º 17
0
 protected function setFlow($flowId)
 {
     $attr = FlowType::model()->fetchByPk(intval($flowId));
     $this->setAttributes($attr);
 }
Ejemplo n.º 18
0
 public function actionVerify()
 {
     $flowID = intval(EnvUtil::getRequest("flowid"));
     if ($flowID) {
         $result = FlowType::model()->examFlow($flowID, true);
         $data = array("result" => $result, "lang" => Ibos::getLangSources());
         $this->renderPartial("verify", $data);
     }
 }