Joywork/ajax/createNewStatTable.php

31 lines
832 B
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if (!$_SESSION['id']) {
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;
$post = clearInputData($_POST);
$tableName = $post['name'];
if ($tableName === '') {
$tableName = 'Новая таблица';
}
$tableType = (int) $post['type'];
$funnelsJSON = $post['funnels'];
$addFieldsJSON = $post['addFields'];
mysql_query("INSERT INTO stat_tables (`agency_id`, `name`, `type`, `json_funnel`, `json_add`) "
. "VALUES ($agency_id, '$tableName', $tableType, '$funnelsJSON', '$addFieldsJSON')");