public function peopleAction() { $schoolid = $this->getInput('schoolid', 'get'); if (!isset($schoolid) || $schoolid <= 0) { $this->showError("无效的学校"); } $type = $this->getInput('type', 'get'); if (!isset($type) || $type == '') { $this->showError("无效的类型参数,例如delivery,master"); } switch ($type) { case "master": $typename = "学校管理员"; break; case "orderdispatch": $typename = "订单分配"; break; case "delivery": $typename = "订单配送"; break; case "areaorderget": $typename = "区域下订单人"; break; case "shopaccount": $typename = "商家帐号列表"; break; default: break; } //get order area from school $areaList = $this->_getSchoolAreaDS()->getBySchoolid($schoolid); $this->setOutput($areaList, "areaList"); if ("checkAndAdd" == $this->getInput("checkAndAdd")) { //get user name $username = $this->getInput("peoplename"); if (empty($username)) { $this->showError("请输入有效的帐号全名"); } //check if it is valid user name $user = $this->_getUserDs()->getUserByName($username); if (empty($user) || count($user) == 0) { $this->showError("未找到此帐号"); } //add into table //if already added, then ignore $userid = $user['uid']; $exists = $this->_getSchoolPeopleDS()->checkIfExists($schoolid, $userid, $type, 0); $message = "不能添加重复项"; if (!$exists) { Wind::import('EXT:4tschool.service.schoolpeople.dm.App_SchoolPeople_Dm'); $dm = new App_SchoolPeople_Dm(); $dm->setSchool($schoolid)->setUserid($userid)->setAreaId($areaid)->setType($type); $this->_getSchoolPeopleDS()->addSchoolUser($dm); } else { $this->showError($message); } } if ("deleteSelected" == $this->getInput("deleteSelected")) { $checkedItems = $this->getInput("checkItem"); $itemArray = $this->getInput("eachItem"); foreach ($checkedItems as $checkKey => $checkValue) { if ($checkValue) { $id = $checkValue; //delete based on id $this->_getSchoolPeopleDS()->delete($id); } } } $this->setOutput($schoolid, "schoolid"); $this->setOutput($type, "type"); $this->setOutput($typename, "typename"); //get school information $schoolInfo = $this->_getSchoolDs()->getSchool($schoolid); $this->setOutput($schoolInfo, "schoolInfo"); $ppls = $this->_getSchoolPeopleDS()->getSchoolPeople($schoolid, $type); $this->setOutput($ppls, "ppls"); }
public function addSchoolUser(App_SchoolPeople_Dm $dm) { return $this->_loadDao()->add($dm->getData()); }