예제 #1
0
 protected function getManagerList($deptid, $value = "")
 {
     $deptCache = DepartmentUtil::loadDepartment();
     $uid = Ibos::app()->user->uid;
     $autoValue = "";
     $manager = array();
     $myarr = explode(",", $deptid);
     foreach ($myarr as $k => $v) {
         if (!empty($v)) {
             if (isset($deptCache[$v]) && $deptCache[$v]["manager"] != 0) {
                 $manager[] = $deptCache[$v]["manager"];
             }
         }
     }
     if (!empty($manager)) {
         foreach (User::model()->fetchAllByUids($manager) as $v) {
             $selected = $v["uid"] == $value ? " selected" : "";
             $autoValue .= "<option value=\"" . $v["uid"] . "\"{$selected}>" . $v["realname"] . "</option>\n";
         }
     } else {
         $criteria = array("select" => "uid,realname", "condition" => "uid!={$uid} AND FIND_IN_SET(deptid,'{$deptid}')" . WfCommonUtil::implodeSql($deptid), "order" => "groupid,uid,username");
         foreach (User::model()->fetchAll($criteria) as $user) {
             $selected = $user["uid"] == $value ? " selected" : "";
             $autoValue .= "<option value=\"" . $user["uid"] . "\"{$selected}>" . $user["realname"] . "</option>\n";
         }
     }
     return $autoValue;
 }
예제 #2
0
 protected function getListData()
 {
     $param = $this->getListFilterParam();
     $field = "fr.runid,fr.name as runName,fr.begintime,fr.endtime,ft.name as typeName,fr.attachmentid,fr.focususer,fr.beginuser,ft.flowid,ft.type,ft.freeother";
     $condition = array("and", "fr.delflag = 0");
     if ($param["flowid"]) {
         $condition[] = "ft.flowid = " . $param["flowid"];
         $isManager = FlowPermission::model()->fetchPermission($this->uid, $param["flowid"], array(0, 1));
     } else {
         $isManager = false;
     }
     if ($param["start"]) {
         $condition[] = "fr.begintime >= " . $param["start"];
     }
     if ($param["end"]) {
         $condition[] = "fr.endtime <= " . $param["end"];
     }
     $flowIds = WfQueryUtil::getMyFlowIDs($this->uid);
     $myRuns = FlowRun::model()->fetchAllMyRunID($this->uid, $param["flowid"]);
     if ($param["scope"] == "none" && Ibos::app()->user->isadministrator != 1) {
         $condition[] = sprintf("(FIND_IN_SET(fr.runid,'%s') OR FIND_IN_SET(ft.flowid,'%s'))", implode(",", $myRuns), implode(",", $flowIds));
     } elseif ($param["scope"] == "start") {
         $beginUser = $this->uid;
     } elseif ($param["scope"] == "handle") {
         $condition[] = array("in", "fr.runid", $myRuns);
     } else {
         if ($param["scope"] == "manage" && Ibos::app()->user->isadministrator != 1) {
             $condition[] = sprintf("FIND_IN_SET('%s',ft.flowid)", implode(",", $flowIds));
         } elseif ($param["scope"] == "focus") {
             $implodeStr = WfCommonUtil::implodeSql($this->uid, "fr.focususer");
             $condition[] = sprintf("fr.focususer = %d%s", $this->uid, $implodeStr);
         } elseif ($param["scope"] == "custom") {
             if (Ibos::app()->user->isadministrator != 1) {
                 $condition[] = sprintf("FIND_IN_SET(ft.flowid,'%s')", implode(",", $flowIds));
             }
             $beginUser = implode(",", StringUtil::getId($param["beginuser"]));
         } elseif (Ibos::app()->user->isadministrator != 1) {
             $this->error(Ibos::lang("Parameters error", "error"));
         }
     }
     if ($param["type"] !== "all") {
         if ($param["type"] == "perform") {
             $condition[] = "fr.endtime = 0";
         } else {
             $condition[] = "fr.endtime != 0";
         }
     }
     if (isset($beginUser)) {
         $condition[] = "fr.beginuser = "******"count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->queryScalar();
     $pages = PageUtil::create($count, $this->getListPageSize());
     $list = Ibos::app()->db->createCommand()->select($field)->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order("fr.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll();
     foreach ($list as &$rec) {
         if (!empty($rec["attachmentid"])) {
             $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]);
         }
         $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]);
         $rec["user"] = User::model()->fetchByUid($rec["beginuser"]);
         $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"]));
         $rec["begin"] = ConvertUtil::formatDate($rec["begintime"], "n月j日 H:i");
     }
     return array("list" => $list, "pages" => $pages, "advanceOpt" => $isManager || Ibos::app()->user->isadministrator == 1);
 }