Joywork/ajax/getStatTableList.php

29 lines
776 B
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if (!$_SESSION['id']) {
header("location:index.php");
die("Доступ запрещён!");
}
$currentUserId = $_SESSION['id'];
$user_view = new User;
$user_view->get($currentUserId);
if (!isset($user_view->agencyId)) {
$user_view->agencyId = $currentUserId;
$user_view->agencyName = $user_view->agency_name;
}
$agency_id = (int) $user_view->agencyId;
$statTablesDBO = mysql_query("select * from stat_tables WHERE agency_id = {$agency_id}");
$statTables = array();
while ($row = mysql_fetch_assoc($statTablesDBO)) {
$statTable = array();
$statTable['id'] = $row['id'];
$statTable['name'] = $row['name'];
array_push($statTables, $statTable);
}
echo(json_encode($statTables));