public function view_addAppointPerson() { $searchDepId = $_GET['searchDepId'] ? post_check(trim($_GET['searchDepId'])) : 0; $searchUserId = $_GET['searchUserId'] ? post_check(trim($_GET['searchUserId'])) : 0; $addDepId = $_GET['addDepId'] ? post_check(trim($_GET['addDepId'])) : 0; $addUserId = $_GET['addUserId'] ? post_check(trim($_GET['addUserId'])) : 0; $addDepId = intval($addDepId); $addUserId = intval($addUserId); $status = ''; if ($addDepId <= 0 || $addUserId <= 0) { $status = "部门或指派工程师为空,添加失败"; } else { $addDepName = getDepNameByDepId($addDepId); $addUserName = getPersonNameById($addUserId); if (empty($addDepName) || empty($addUserName)) { $status = "部门或指派工程师不存在,添加失败"; } else { $tName = 'pc_products_appoint_person'; $where = "WHERE is_delete=0 AND depId='{$addDepId}' AND appointPersonId='{$addUserId}'"; $isExistDU = OmAvailableModel::getTNameCount($tName, $where); if ($isExistDU) { $status = "记录已经存在,添加失败"; } else { $dataArr = array(); $dataArr['depId'] = $addDepId; $dataArr['appointPersonId'] = $addUserId; $dataArr['addUserId'] = $_SESSION['userId']; $dataArr['addTime'] = time(); OmAvailableModel::addTNameRow2arr($tName, $dataArr); $status = "部门:{$addDepName} 指派工程师:{$addUserName} 添加成功"; } } } header("Location:index.php?mod=products&act=getAppointPersonList&status={$status}&addDepId={$addDepId}&addUserId={$addUserId}&searchDepId={$searchDepId}&searchUserId={$searchUserId}"); }
function act_getAppointPersonList() { $searchDepId = $_GET['searchDepId'] ? post_check(trim($_GET['searchDepId'])) : 0; $searchUserId = $_GET['searchUserId'] ? post_check(trim($_GET['searchUserId'])) : 0; $tName = 'pc_products_appoint_person'; $select = '*'; $where = "WHERE is_delete=0 "; if (intval($searchDepId) > 0) { $where .= "AND depId='{$searchDepId}' "; } if (intval($searchUserId) > 0) { $where .= "AND appointPersonId='{$searchUserId}' "; } $total = OmAvailableModel::getTNameCount($tName, $where); $num = 50; //每页显示的个数 $page = new Page($total, $num, '', 'CN'); $where .= "order by id desc " . $page->limit; $appointPersonList = OmAvailableModel::getTNameList($tName, $select, $where); if (!empty($appointPersonList)) { $countAppointPersonList = count($appointPersonList); for ($i = 0; $i < $countAppointPersonList; $i++) { $appointPersonList[$i]['depName'] = getDepNameByDepId($appointPersonList[$i]['depId']); $appointPersonList[$i]['userName'] = getPersonNameById($appointPersonList[$i]['appointPersonId']); $appointPersonList[$i]['addUserName'] = getPersonNameById($appointPersonList[$i]['addUserId']); } } if (!empty($_GET['page'])) { if (intval($_GET['page']) <= 1 || intval($_GET['page']) > ceil($total / $num)) { $n = 1; } else { $n = (intval($_GET['page']) - 1) * $num + 1; } } else { $n = 1; } if ($total > $num) { //输出分页显示 $show_page = $page->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $show_page = $page->fpage(array(0, 2, 3)); } return array('appointPersonList' => $appointPersonList, 'show_page' => $show_page); }