/** * 編集対象アカウントを検索 * * * @param */ function searchEditAccount($query_staff_cd, $query_name, $query_department_cd, $query_division_cd, $query_section_cd, $query_target_year) { $sql = 'SELECT id, staff_cd, name, retire_flg from m_staff'; $sql .= ' WHERE delete_flg = 0 and target_year = :target_year'; $searchParam = array("target_year" => $query_target_year); if (!emp($query_staff_cd)) { $sql .= ' and staff_cd = :staff_cd'; $searchParam["staff_cd"] = $query_staff_cd; } if (!emp($query_name)) { $sql .= ' and name like :name'; $searchParam["name"] = $query_name; } if (!emp($query_department_cd)) { $sql .= ' and department_cd = :department_cd'; $searchParam["department_cd"] = $query_department_cd; } if (!emp($query_division_cd)) { $sql .= ' and division_cd = :division_cd'; $searchParam["division_cd"] = $query_division_cd; } if (!emp($query_section_cd)) { $sql .= ' and section_cd = :section_cd'; $searchParam["section_cd"] = $query_section_cd; } $sql .= ' ORDER BY staff_cd asc'; $sql .= ' LIMIT ' . SEARCH_LIMIT; // データベースに接続する $conn = DbControl::getInstance(); $conn->dbConnect(DbControl::SLAVE_DB); // クエリを実行する $res = $conn->dbExecFetchAll(DbControl::SLAVE_DB, $sql, $searchParam); // データベースを切断する $conn->dbClose(DbControl::SLAVE_DB); //検索結果のIDを用いて権限取得 $temp = $res; for ($i = 0; $i < count($res); $i++) { $staff_id = $res[$i]["id"]; $authority_result = getStaffAuth($staff_id); $authority = array(); foreach ($authority_result as $num => $data) { $authority[] = $data["group_cd"]; } $temp[$i]["group_cd"] = $authority; } $res = $temp; return $res; }
/** * ログインAdminユーザー情報を取得する * * @param $admin_userId Adminユーザー * @param $password パスワード * @return Adminユーザー情報 */ public function getAdminUserInfo($admin_user, $password = null) { $result = array(); $searchParam = array(); if (!$admin_user || is_null($admin_user)) { return -1; } $sql = "select " . " id, staff_cd, name, passwd, mail, department_cd, division_cd, section_cd, target_year, retire_flg, delete_flg from m_staff " . " where " . " staff_cd = :user " . " and target_year = :year "; if ($password && strlen($password)) { $sql .= " AND passwd = :pass "; $searchParam['pass'] = $password; } $searchParam['user'] = $admin_user; $searchParam['year'] = date('Y'); DbControl::getInstance()->dbConnect(DbControl::SLAVE_DB); $result = DbControl::getInstance()->dbExecFetch(DbControl::SLAVE_DB, $sql, $searchParam); if (!is_array($result) || !isset($result['staff_cd'])) { return -1; } $tmp = $result; $authority_result = getStaffAuth($result['id']); $authority = array(); foreach ($authority_result as $num => $data) { $authority[] = $data['group_cd']; } $tmp['group_cd'] = $authority; $result = $tmp; return $result; }
/** * 編集対象アカウント情報を取得 * * * @param */ function editAccountData($query_id) { $sql = "SELECT " . "id, " . "staff_cd, " . "name, " . "name_kana, " . "sex, " . "mail, " . "post_cd, " . "department_cd, " . "division_cd, " . "section_cd, " . "occupation_cd, " . "occupation, " . "target_year, " . "retire_flg, " . "update_date "; $sql .= "FROM m_staff "; $sql .= "WHERE id = :id "; $searchParam = array("id" => $query_id); //$sql .= ' ORDER BY staff_cd asc'; // データベースに接続する $conn = DbControl::getInstance(); $conn->dbConnect(DbControl::SLAVE_DB); // クエリを実行する $res = $conn->dbExecFetch(DbControl::SLAVE_DB, $sql, $searchParam); // 取得したデータをDUMP //var_dump($res); // データベースを切断する $conn->dbClose(DbControl::SLAVE_DB); //検索結果のIDを用いて権限取得 $temp = $res; $authority_result = getStaffAuth($query_id); $authority = array(); foreach ($authority_result as $num => $data) { $authority[] = $data["group_cd"]; } $temp["group_cd"] = $authority; $res = $temp; return $res; }