示例#1
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");
     }
 }
示例#2
0
 public function getData($condition = "")
 {
     return PositionUtil::loadPositionCategory();
 }
示例#3
0
 public function actionEdit()
 {
     $id = EnvUtil::getRequest("id");
     if (EnvUtil::submitCheck("posSubmit")) {
         if (isset($_POST["posname"])) {
             $data["posname"] = $_POST["posname"];
             $data["sort"] = $_POST["sort"];
             $data["catid"] = intval(EnvUtil::getRequest("catid"));
             $data["goal"] = $_POST["goal"];
             $data["minrequirement"] = $_POST["minrequirement"];
             Position::model()->modify($id, $data);
         }
         if (isset($_POST["responsibility"])) {
             foreach ($_POST["responsibility"] as $rId => $value) {
                 $data = array("positionid" => $id, "responsibility" => $value, "criteria" => $_POST["criteria"][$rId]);
                 PositionResponsibility::model()->modify($rId, $data);
             }
         }
         if (isset($_POST["newResponsibility"])) {
             $this->addResponsibility($id, $_POST["newResponsibility"], $_POST["newCriteria"]);
         }
         if (!empty($_POST["resDelId"])) {
             $delId = trim($_POST["resDelId"], ",");
             PositionResponsibility::model()->deleteByPk(explode(",", $delId));
         }
         if (isset($_POST["nodes"])) {
             $this->updateAuthItem($id, $_POST["nodes"], $_POST["data-privilege"]);
         }
         if (isset($_POST["member"])) {
             UserUtil::setPosition($id, $_POST["member"]);
         } else {
             OrgUtil::update();
         }
         PositionUtil::cleanPurvCache($id);
         $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("position/index"));
     } else {
         $pos = Position::model()->fetchByPk($id);
         $related = NodeRelated::model()->fetchAllByPosId($id);
         $relateCombine = PositionUtil::combineRelated($related);
         $responsibility = PositionResponsibility::model()->fetchAllByPosId($id);
         $data["id"] = $id;
         $data["pos"] = $pos;
         $catData = PositionUtil::loadPositionCategory();
         $data["category"] = StringUtil::getTree($catData, $this->selectFormat, $pos["catid"]);
         $data["related"] = $relateCombine;
         $data["responsibility"] = $responsibility;
         $authItem = AuthUtil::loadAuthItem();
         $data["authItem"] = $authItem;
         $uids = User::model()->fetchUidByPosId($id, false);
         if (!empty($uids)) {
             $data["uids"] = $uids;
             $data["uidString"] = "";
             foreach ($uids as $uid) {
                 $data["uidString"] .= "'u_" . $uid . "',";
             }
             $data["uidString"] = trim($data["uidString"], ",");
         }
         $this->setPageTitle(Ibos::lang("Edit position"));
         $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("Position manager"), "url" => $this->createUrl("position/index")), array("name" => Ibos::lang("Edit position"))));
         $this->render("edit", $data);
     }
 }