Joywork/admin/dischargeTariffsEdit.php
2026-05-22 21:21:54 +03:00

111 lines
3.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
// закрываем доступ на выполнение запросов
if (!isset($_SESSION['superadmin'])) {
header("location:/index.php");
die("Доступ запрещён!");
}
if (isset($_POST['add_tariff'])) {
$err = "";
$post = clearInputData($_POST);
if (isset($post['id'])) {
if (strlen($err) == 0) {
$sqlUpdate = "UPDATE discharge_tariff SET count = '$post[count]', price = '$post[price]' WHERE id = $post[id]";
mysql_query($sqlUpdate);
header("location:/admin/dischargeTariffs.php");
exit();
}
} else {
if (strlen($err) > 0) {
$err = $err . "<br/>";
}
$err .= "Не найден идентификатор тарифа в запросе.";
}
}
$get = clearInputData($_GET);
if (!isset($get['id'])) {
header("location:/admin/dischargeTariffs.php");
}
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/header-admin.php");
if (!isset($post) && $get['id'] > 0) {
$sql = "select * from discharge_tariff where id= $get[id]";
$rez = mysql_query($sql);
$tariff = mysql_fetch_array($rez);
}
?>
<div class="main-title">
<h1>Редактирование тарифа выписок ЕГРН</h1>
</div>
<div class="users fr__users" style="margin-right: 20px;">
<div class="new-object">
<form method="post">
<div class="new-object__form">
<?php if (isset($err) && strlen($err) > 0) { ?>
<div class="block" style="border-bottom: none; color: red;"><?php echo $err; ?></div>
<?php } ?>
<div class="block">
<div class="line">
<div class="label">
<span>Количество:</span>
</div>
<div class="inputs">
<input type="number" class="text" name="count" style="width: 75%;"
value="<? if (isset($post)) echo $post['count'];
if (isset($tariff)) echo $tariff['count']; ?>">
</div>
</div>
<div class="line">
<div class="label">
<span>Цена:</span>
</div>
<div class="inputs">
<input type="number" class="text" name="price" style="width: 75%;"
value="<? if (isset($post)) echo $post['price'];
if (isset($tariff)) echo $tariff['price']; ?>">
</div>
</div>
<div class="line" style="text-align: right">
<button type="submit" class="medium-button">Сохранить</button>
<a href="/admin/dischargeTariffs.php" class="cancel-button medium-button">Закрыть</a>
</div>
<input type="hidden" name="add_tariff" value="1">
<input type="hidden" name="id" value="<?php if (isset($tariff)) {
echo $tariff['id'];
} else {
if (isset($post)) {
echo $post['id'];
}
} ?>">
<div class="clear"></div>
</div>
</div>
</form>
</div>
<div class="clear"></div>
</div>
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/footer-admin.php");
?>