Example #1
0
 protected function getDataByDept()
 {
     $deptid = intval(EnvUtil::getRequest("deptid"));
     $allDepts = DepartmentUtil::loadDepartment();
     if (!empty($deptid)) {
         $childDepts = Department::model()->fetchChildDeptByDeptid($deptid, $allDepts);
         $selfDept = Department::model()->fetchByPk($deptid);
         $depts = array_merge(array($selfDept), $childDepts);
         $deptsTmp = ContactUtil::handleDeptData($depts, $deptid);
         $depts = array_merge(array($selfDept), $deptsTmp);
     } else {
         $depts = ContactUtil::handleDeptData($allDepts, 0);
     }
     if (!empty($depts)) {
         foreach ($depts as $k => $childDept) {
             $pDeptids = Department::model()->queryDept($childDept["deptid"]);
             $depts[$k]["pDeptids"] = !empty($pDeptids) ? array_reverse(explode(",", trim($pDeptids))) : array();
             $deptUids = User::model()->fetchAllUidByDeptid($childDept["deptid"], false);
             $deptRelatedUids = DepartmentRelated::model()->fetchAllUidByDeptId($childDept["deptid"]);
             $uids = array_unique(array_merge($deptUids, $deptRelatedUids));
             $uids = $this->removeDisabledUid($uids);
             $depts[$k]["users"] = User::model()->fetchAllByUids($uids);
         }
     }
     return $depts;
 }
Example #2
0
 public static function getShowData($data)
 {
     $data["subject"] = stripslashes($data["subject"]);
     if (!empty($data["author"])) {
         $data["authorDeptName"] = Department::model()->fetchDeptNameByUid($data["author"]);
     }
     if ($data["approver"] != 0) {
         $data["approver"] = User::model()->fetchRealNameByUid($data["approver"]);
     } else {
         $data["approver"] = Ibos::lang("None");
     }
     $data["addtime"] = ConvertUtil::formatDate($data["addtime"], "u");
     $data["uptime"] = empty($data["uptime"]) ? "" : ConvertUtil::formatDate($data["uptime"], "u");
     $data["categoryName"] = ArticleCategory::model()->fetchCateNameByCatid($data["catid"]);
     if (empty($data["deptid"]) && empty($data["positionid"]) && empty($data["uid"])) {
         $data["departmentNames"] = Ibos::lang("All");
         $data["positionNames"] = $data["uidNames"] = "";
     } elseif ($data["deptid"] == "alldept") {
         $data["departmentNames"] = Ibos::lang("All");
         $data["positionNames"] = $data["uidNames"] = "";
     } else {
         $department = DepartmentUtil::loadDepartment();
         $data["departmentNames"] = ArticleUtil::joinStringByArray($data["deptid"], $department, "deptname", "、");
         $position = PositionUtil::loadPosition();
         $data["positionNames"] = ArticleUtil::joinStringByArray($data["positionid"], $position, "posname", "、");
         if (!empty($data["uid"])) {
             $users = User::model()->fetchAllByUids(explode(",", $data["uid"]));
             $data["uidNames"] = ArticleUtil::joinStringByArray($data["uid"], $users, "realname", "、");
         } else {
             $data["uidNames"] = "";
         }
     }
     return $data;
 }
Example #3
0
 public static function getMyFlowIDs($uid)
 {
     $flowIDs = $orgIDs = array();
     $user = User::model()->fetchByUid($uid);
     $allDeptStr = Department::model()->queryDept($user["alldeptid"], true);
     $deptArr = DepartmentUtil::loadDepartment();
     foreach ($deptArr as $id => $dept) {
         if ($dept["pid"] == 0) {
             $orgIDs[] = $id;
         }
     }
     $orgIDs = implode(",", $orgIDs);
     foreach (FlowPermission::model()->fetchAllByPer() as $val) {
         switch ($val["scope"]) {
             case "selfdeptall":
             case "selfdept":
                 $deptid = FlowType::model()->fetchDeptIDByFlowID($val["flowid"]);
                 if ($deptid !== 0 && $user["isadministrator"] != 1) {
                     if ($val["scope"] == "selfdept") {
                         $deptAccess = StringUtil::findIn($user["alldeptid"], $val["deptid"]);
                         $userAccess = WfNewUtil::compareIds($user["uid"], $val["uid"], "u");
                         $posAccess = WfNewUtil::compareIds($user["allposid"], $val["positionid"], "p");
                         if ($deptAccess || $userAccess || $posAccess) {
                             $flowIDs[] = $val["flowid"];
                         }
                     } elseif (self::hasAccess($user, $val)) {
                         $flowIDs[] = $val["flowid"];
                     }
                 } else {
                     $flowIDs[] = $val["flowid"];
                 }
                 break;
             case "selforg":
                 if (StringUtil::findIn($allDeptStr, $orgIDs)) {
                     if (self::hasAccess($user, $val)) {
                         $flowIDs[] = $val["flowid"];
                     }
                 }
                 break;
             case "alldept":
                 if (self::hasAccess($user, $val)) {
                     $flowIDs[] = $val["flowid"];
                 }
                 break;
             default:
                 if (StringUtil::findIn($allDeptStr, $val["scope"])) {
                     if (self::hasAccess($user, $val)) {
                         $flowIDs[] = $val["flowid"];
                     }
                 }
                 break;
         }
     }
     return $flowIDs;
 }
Example #4
0
 public function actionIndex()
 {
     $op = EnvUtil::getRequest("op");
     if (!empty($op) && in_array($op, array("get"))) {
         return $this->{$op}();
     }
     $dept = DepartmentUtil::loadDepartment();
     $data = array("dept" => $dept, "tree" => StringUtil::getTree($dept, $this->selectFormat), "unit" => Ibos::app()->setting->get("setting/unit"), "license" => Ibos::app()->setting->get("setting/license"), "perAdd" => Ibos::app()->user->checkAccess("organization/department/add"), "perEdit" => Ibos::app()->user->checkAccess("organization/department/edit"), "perDel" => Ibos::app()->user->checkAccess("organization/department/del"));
     $this->setPageTitle(Ibos::lang("Department manage"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("Department manage"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("Department list"))));
     $this->render("index", $data);
 }
Example #5
0
 private static function createStaticJs()
 {
     CacheUtil::load(array("department", "position"), true);
     $unit = Ibos::app()->setting->get("setting/unit");
     $department = DepartmentUtil::loadDepartment();
     $users = UserUtil::loadUser();
     $position = PositionUtil::loadPosition();
     $positionCategory = PositionUtil::loadPositionCategory();
     $companyData = self::initCompany($unit);
     $deptData = self::initDept($department);
     $userData = self::initUser($users);
     $posData = self::initPosition($position);
     $posCatData = self::initPositionCategory($positionCategory);
     $default = file_get_contents(PATH_ROOT . "/static/js/src/org.default.js");
     if ($default) {
         $patterns = array("/\\{\\{(company)\\}\\}/", "/\\{\\{(department)\\}\\}/", "/\\{\\{(position)\\}\\}/", "/\\{\\{(users)\\}\\}/", "/\\{\\{(positioncategory)\\}\\}/");
         $replacements = array($companyData, $deptData, $posData, $userData, $posCatData);
         $new = preg_replace($patterns, $replacements, $default);
         FileUtil::createFile("data/org.js", $new);
         CacheUtil::update("setting");
     }
 }
Example #6
0
 public function getBranchParent($deptid)
 {
     static $depts = array();
     if (empty($depts)) {
         $depts = DepartmentUtil::loadDepartment();
     }
     if (isset($depts[$deptid]) && $depts[$deptid]["isbranch"] == 1) {
         return $depts[$deptid];
     }
     $pid = isset($depts[$deptid]) ? $depts[$deptid]["pid"] : 0;
     if (0 < $pid) {
         return $this->getBranchParent($pid);
     } else {
         return array();
     }
 }
Example #7
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;
 }
Example #8
0
 public static function checkDeptPurv($uid, $deptId = 0, $catId = 0)
 {
     $user = User::model()->fetchByUid($uid);
     if ($user["isadministrator"] == 1) {
         return true;
     }
     if ($deptId == "") {
         if (0 < $catId) {
             $cat = FlowCategory::model()->fetchByPk($catId);
             if ($cat) {
                 return self::checkDeptPurv($uid, $cat["deptid"], 0);
             }
         }
         return true;
     }
     $purv = false;
     if (!empty($user["alldeptid"])) {
         foreach (explode(",", $user["alldeptid"]) as $userDept) {
             foreach (explode(",", $deptId) as $dept) {
                 if ($userDept == $dept || DepartmentUtil::isDeptParent($userDept, $dept)) {
                     $purv = true;
                     break;
                 }
             }
         }
     }
     return $purv;
 }
Example #9
0
    echo $lang['Department'];
    ?>
</th>
								<th><?php 
    echo $lang['Position'];
    ?>
</th>
								<th width="60"><?php 
    echo $lang['Operation'];
    ?>
</th>
							</tr>
						</thead>
						<tbody>
							<?php 
    $dept = DepartmentUtil::loadDepartment();
    ?>
							<?php 
    $position = PositionUtil::loadPosition();
    ?>
							<?php 
    foreach ($list as $key => $value) {
        ?>
								<tr>
									<td>
										<?php 
        if ($value['uid'] !== '1' && $value['perManager']) {
            ?>
											<label class="checkbox">
												<input type="checkbox" name="user" value="<?php 
            echo $value['uid'];
Example #10
0
 private function makeOrgstructXml()
 {
     $deptArr = DepartmentUtil::loadDepartment();
     $unit = Ibos::app()->setting->get("setting/unit");
     $str = "<?xml version=\"1.0\" encoding=\"gb2312\" ?>";
     $str .= "<enterprise name=\"" . $unit["fullname"] . "\" postcode=\"" . $unit["zipcode"] . "\" address=\"" . $unit["address"] . "\" phone=\"" . $unit["phone"] . "\" email=\"" . $unit["adminemail"] . "\">";
     $str .= "<departments>";
     $str .= $this->getDeptree($deptArr);
     $str .= "</departments>";
     $str .= "</enterprise>";
     $file = "userdata.xml";
     $fp = @fopen($file, "wb");
     if ($fp) {
         $str = ConvertUtil::iIconv($str, CHARSET, "gbk");
         file_put_contents($file, $str);
         if (0 < filesize($file)) {
             return true;
         }
     }
     return false;
 }
Example #11
0
 public static function handleUserGroupByDept($users)
 {
     if (empty($users)) {
         return array();
     }
     $ret = array();
     $deptIdsTemp = ConvertUtil::getSubByKey($users, "deptid");
     $deptIds = array_unique($deptIdsTemp);
     $departments = DepartmentUtil::loadDepartment();
     foreach ($deptIds as $deptId) {
         $ret[$deptId]["deptname"] = isset($departments[$deptId]) ? $departments[$deptId]["deptname"] : "未定义部门";
         foreach ($users as $k => $user) {
             if ($user["deptid"] == $deptId) {
                 $ret[$deptId]["users"][$user["uid"]] = $user;
                 unset($user[$k]);
             }
         }
     }
     return $ret;
 }
Example #12
0
 private function getReader()
 {
     if (Ibos::app()->request->isAjaxRequest) {
         $articleid = EnvUtil::getRequest("articleid");
         $readerData = ArticleReader::model()->fetchAll("articleid=:articleid", array(":articleid" => $articleid));
         $departments = DepartmentUtil::loadDepartment();
         $res = $tempDeptids = $users = array();
         foreach ($readerData as $reader) {
             $user = User::model()->fetchByUid($reader["uid"]);
             $users[] = $user;
             $deptid = $user["deptid"];
             $tempDeptids[] = $user["deptid"];
         }
         $deptids = array_unique($tempDeptids);
         foreach ($deptids as $deptid) {
             $deptName = isset($departments[$deptid]["deptname"]) ? $departments[$deptid]["deptname"] : "--";
             foreach ($users as $k => $user) {
                 if ($user["deptid"] == $deptid) {
                     $res[$deptName][] = $user;
                     unset($users[$k]);
                 }
             }
         }
         $this->ajaxReturn($res);
     }
 }
Example #13
0
 public function autoProcessor($item, $readOnly)
 {
     $field = $item["data-field"];
     $width = isset($item["data-width"]) ? $item["data-width"] : "200";
     $autoValue = "";
     $value = $this->getValue($item);
     $hourTime = date("H:i:s", TIMESTAMP);
     $date = date("Y-m-d");
     $time = $date . " " . $hourTime;
     $isTextAuto = substr($field, 0, 8) !== "sys_list";
     $lang = Ibos::getLangSource("workflow.default");
     if ($isTextAuto) {
         switch ($field) {
             case "sys_date":
                 $autoValue = $date;
                 break;
             case "sys_date_cn":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["Month"] . "d" . $lang["Chinese day"]);
                 break;
             case "sys_date_cn_short1":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["month"]);
                 break;
             case "sys_date_cn_short2":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "m" . $lang["Month"] . "d" . $lang["Chinese day"]);
                 break;
             case "sys_date_cn_short3":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"]);
                 break;
             case "sys_date_cn_short4":
                 $autoValue = date("Y", TIMESTAMP);
                 break;
             case "sys_time":
                 $autoValue = $hourTime;
                 break;
             case "sys_datetime":
                 $autoValue = $time;
                 break;
             case "sys_week":
                 $autoValue = WfCommonUtil::getWeek();
                 break;
             case "sys_userid":
                 $autoValue = Ibos::app()->user->uid;
                 break;
             case "sys_realname":
                 $autoValue = Ibos::app()->user->realname;
                 break;
             case "sys_userpos":
                 $autoValue = Ibos::app()->user->posname;
                 break;
             case "sys_realname_date":
                 $autoValue = Ibos::app()->user->realname . " " . $date;
                 break;
             case "sys_realname_datetime":
                 $autoValue = Ibos::app()->user->realname . " " . $time;
                 break;
             case "sys_deptname":
                 $autoValue = Department::model()->fetchDeptNameByDeptId(Ibos::app()->user->alldeptid);
                 break;
             case "sys_deptname_short":
                 $autoValue = Ibos::app()->user->deptname;
                 break;
             case "sys_formname":
                 $autoValue = $this->form->formname;
                 break;
             case "sys_runname":
                 $autoValue = $this->inDebug ? "" : $this->run->name;
                 break;
             case "sys_rundate":
                 $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime, "d");
                 break;
             case "sys_rundatetime":
                 $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime);
                 break;
             case "sys_runid":
                 $autoValue = $this->inDebug ? "" : $this->run->runid;
                 break;
             case "sys_autonum":
                 $autoValue = $this->inApp ? $this->flow->autonum : "";
                 break;
             case "sys_ip":
                 $autoValue = EnvUtil::getClientIp();
                 break;
             case "sys_sql":
                 $sql = $item["data-src"];
                 $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid);
                 $autoValue = $this->execSysSql($sql, $tempopt, false);
                 break;
             case "sys_manager1":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $managerID = $deptCache[$main]["manager"];
                 if ($managerID != 0) {
                     $autoValue = User::model()->fetchRealnameByUid($managerID);
                 }
                 break;
             case "sys_manager2":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $upid = $deptCache[$main]["upid"];
                 if ($upid != 0) {
                     if ($deptCache[$upid]["manager"] != 0) {
                         $autoValue = User::model()->fetchRealnameByUid($deptCache[$upid]["manager"]);
                     }
                 }
                 break;
             case "sys_manager3":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $dept_str = Department::model()->queryDept($main);
                 $temp = explode(",", $dept_str);
                 $count = count($temp);
                 $dept = $temp[$count - 2];
                 if ($deptCache[$dept]["manager"] != 0) {
                     $autoValue = User::model()->fetchRealnameByUid($deptCache[$dept]["manager"]);
                 }
                 break;
             default:
                 break;
         }
         if ($value == "" && !$readOnly || $this->flow->isFixed() && $readOnly && StringUtil::findIn($this->process->processitemauto, $item["data-title"]) && $this->rp->opflag) {
             $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$autoValue}\" title=\"{$item["data-title"]}\" />";
         } else {
             $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$value}\" title=\"{$item["data-title"]}\" />";
         }
         $hidden = isset($item["data-hide"]) ? $item["data-hide"] : "0";
         if ($hidden == "1") {
             $eleout = str_ireplace("type=\"text\"", "type=\"hidden\"", $eleout);
         }
         if (!$readOnly) {
             if ($this->inApp && $this->flow->isFixed() && StringUtil::findIn($this->process->processitemauto, $item["data-title"])) {
                 $readOnly = true;
             } else {
                 $eleout = str_ireplace("<input", "<input data-orig-value=\"{$autoValue}\" data-focus=\"restore\"", $eleout);
             }
         }
         if ($readOnly) {
             $this->setCommonReadOnly($item, $eleout, "input");
         }
     } else {
         $autoValue = "<option value=\"\"";
         if ($value == "") {
             $autoValue .= " selected";
         }
         $autoValue .= "></option>\n";
         switch ($field) {
             case "sys_list_dept":
                 $cache = DepartmentUtil::loadDepartment();
                 $str = StringUtil::getTree($cache, "<option value='\$deptid' \$selected>\$spacer\$deptname</option>", $value);
                 $autoValue .= $str;
                 break;
             case "sys_list_user":
                 foreach (UserUtil::loadUser() as $user) {
                     $selected = $value == $user["uid"] ? "selected" : "";
                     $autoValue .= "<option {$selected} value='" . $user["uid"] . "'>" . $user["realname"] . "</option>";
                 }
                 break;
             case "sys_list_pos":
                 foreach (PositionUtil::loadPosition() as $pos) {
                     $selected = $value == $pos["positionid"] ? "selected" : "";
                     $autoValue .= "<option {$selected} value='" . $pos["positionid"] . "'>" . $pos["posname"] . "</option>";
                 }
                 break;
             case "sys_list_prcsuser1":
                 $autoValue .= $this->getProcessUserList($this->flow->flowid, 0, $value);
                 break;
             case "sys_list_prcsuser2":
                 $autoValue .= $this->getProcessUserList($this->flow->flowid, $this->process->processid, $value, true);
                 break;
             case "sys_list_sql":
                 $sql = $item["data-src"];
                 $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid);
                 $autoValue = $this->execSysSql($sql, $tempopt);
                 $autoValue .= $this->arrayTolist($autoValue, $value);
                 break;
             case "sys_list_manager1":
                 $main = Ibos::app()->user->deptid;
                 $autoValue .= $this->getManagerList($main, $value);
                 break;
             case "sys_list_manager2":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $upid = $deptCache[$main]["upid"];
                 if ($upid != 0) {
                     $autoValue .= $this->getManagerList($main, $value);
                 }
                 break;
             case "sys_list_manager3":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $dept_str = Department::model()->queryDept($main);
                 $temp = explode(",", $dept_str);
                 $count = count($temp);
                 $dept = $temp[$count - 2];
                 $autoValue .= $this->getManagerList($dept, $value);
                 break;
         }
         $eleout = "\t\t\t\t\t<select title=\"{$item["data-title"]}\" name=\"data_{$item["itemid"]}\">\r\n\t\t\t\t\t{$autoValue}\r\n\t\t\t\t\t</select>";
         if ($readOnly) {
             $this->setCommonReadOnly($item, $eleout, "select");
         }
     }
     return $eleout;
 }
Example #14
0
 protected function handleFormData($list)
 {
     $return = array();
     if (!empty($list)) {
         $depts = DepartmentUtil::loadDepartment();
         $undefined = Ibos::lang("Undefined");
         $sysdept = Ibos::lang("Form sys dept");
         foreach ($list as $form) {
             if (!empty($form["formid"]) && WfCommonUtil::checkDeptPurv($this->uid, $form["deptid"])) {
                 $form["id"] = $form["formid"];
                 $form["name"] = $form["formname"];
                 $form["catelog"] = $form["catid"];
                 if (!isset($form["flow"]) || empty($form["flow"])) {
                     $form["flow"] = $undefined;
                 }
                 $form["department"] = isset($depts[$form["deptid"]]) ? $depts[$form["deptid"]]["deptname"] : $sysdept;
                 $form["departmentId"] = !empty($form["deptid"]) ? StringUtil::wrapId($form["deptid"], "d") : "";
                 $return[] = $form;
             }
         }
     }
     return $return;
 }