You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
<?php
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
require_once('../conn.php');
|
|
header("Content-Type: application/json");
|
|
$department_id = isset($_POST['department_id']) ? $_POST['department_id'] : null;
|
|
$u = new User();
|
|
echo $u->getUser($department_id);
|
|
}
|
|
|
|
|
|
class User
|
|
{
|
|
public function getUser($department_id)
|
|
{
|
|
global $conn;
|
|
|
|
$sql_str = "
|
|
SELECT
|
|
*
|
|
FROM(
|
|
SELECT
|
|
'' AS value,
|
|
'全部' AS text
|
|
FROM account
|
|
|
|
UNION
|
|
|
|
SELECT
|
|
DISTINCT
|
|
accountid AS value,
|
|
name AS text
|
|
FROM account
|
|
WHERE accounttype IN ('B','M','W','E')
|
|
";
|
|
$sql_str .= !empty($department_id) ? " AND department_id = :department_id" : '';
|
|
$sql_str .= "
|
|
)AS tmp
|
|
ORDER BY tmp.value
|
|
";
|
|
$stmt = $conn->prepare($sql_str);
|
|
if (!empty($department_id)) {
|
|
$stmt->bindParam(':department_id', $department_id);
|
|
}
|
|
$stmt->execute();
|
|
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
return json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|
|
|