Joywork/ajax/datasource/getRequest.php

24 lines
635 B
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
$idAgent = (int)$_SESSION['id'];
// Search text, need check
$clients = isset($_POST['clients']) ? array_map('intval', $_POST['clients']) : [];
$sql = "SELECT id, name, client_id FROM requisitions WHERE client_id IN (" . implode(',', $clients) .") AND who_work = $idAgent AND deleted <> 1 AND cancel = 0";
$rez = mysql_query($sql);
$response = [];
$response['requests'] = [];
while ($request = mysql_fetch_assoc($rez)) {
$response['requests'][] = [
"id" => $request['id'],
"text" => $request['name'],
];
}
echo json_encode($response);
exit();