public function actionSubSchedule() { $op = EnvUtil::getRequest("op"); if ($op == "getsubordinates") { $this->getsubordinates(); } elseif ($op == "list") { $this->getList(); } else { $workTime = Ibos::app()->setting->get("setting/calendarworkingtime"); $workingtime = explode(",", $workTime); $setting = array("worktimestart" => $workingtime[0], "worktimeend" => $workingtime[1], "allowAdd" => CalendarUtil::getIsAllowAdd(), "allowEdit" => CalendarUtil::getIsAllowEdit()); $getUid = EnvUtil::getRequest("uid"); if (!$getUid) { $deptArr = UserUtil::getManagerDeptSubUserByUid($this->uid); if (!empty($deptArr)) { $firstDept = reset($deptArr); $uid = $firstDept["user"][0]["uid"]; } else { $this->error(IBos::lang("You do not subordinate"), $this->createUrl("schedule/index")); } } else { $uid = $getUid; } if (!UserUtil::checkIsSub(Ibos::app()->user->uid, $uid)) { $this->error(Ibos::lang("No permission to view schedule"), $this->createUrl("schedule/index")); } $data = array("setting" => $setting, "user" => User::model()->fetchByUid($uid), "supUid" => UserUtil::getSupUid($this->uid)); $this->setPageTitle(Ibos::lang("Subordinate schedule")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Calendar arrangement"), "url" => $this->createUrl("schedule/index")), array("name" => Ibos::lang("Subordinate schedule")))); $this->render("subschedule", $data); } }
protected function listCalendar($st, $et, $uid) { $curUid = Ibos::app()->user->uid; $list["calendar"] = Calendars::model()->listCalendarByRange($st, $et, $uid); $allowEdit = CalendarUtil::getIsAllowEdit(); $tmpret["events"] = array(); foreach ($list["calendar"]["events"] as $key => $row) { $spanday = date("Y-m-d", $row["starttime"]) < date("Y-m-d", $row["endtime"]) ? 1 : 0; if ($row["lock"]) { $editAble = 0; } else { if ($row["uid"] == $curUid || $allowEdit || $curUid == $row["upuid"]) { $editAble = 1; } else { $editAble = 0; } } $tmpret["events"][] = array("id" => $row["calendarid"], "title" => $row["subject"], "start" => CalendarUtil::php2JsTime($row["starttime"]), "end" => CalendarUtil::php2JsTime($row["endtime"]), "allDay" => $row["isalldayevent"], "acrossDay" => $spanday, "type" => $row["instancetype"], "category" => $row["category"], "editable" => $editAble, "location" => $row["location"], "attends" => "", "status" => $row["status"], "loopId" => $row["masterid"]); } foreach ($tmpret["events"] as $key => $row) { $beginarr[$key] = $row["start"]; } if (!empty($beginarr)) { array_multisort($beginarr, SORT_ASC, $tmpret["events"]); } $ret = $list["calendar"]; $ret["events"] = $tmpret["events"]; return $ret; }