<?php
include($_SERVER['DOCUMENT_ROOT']."/includes/header.php");
if (isset($_SESSION["AUTH_USER"])) {
$session = $_SESSION["AUTH_USER"];
$today = date("Y-m-d H:i:s");
$services_list = DB::query_fetch_all("
SELECT cs.price_condition, client_id, s.`name`, s.`options`, s.price, s.price_type, s.id
FROM Services as s JOIN ClientServices as cs ON s.id = cs.service_id WHERE client_id = '%d'
",$session);
if (isset($_POST['save_but']))
{
$on_off = 1;
$service_id = 2;
/* foreach ($_POST as $key=>$value) {
echo "<p>".$key." = " . $value . "</p>";
}*/
/*$name = $_POST["keyName"];
$phone = $_POST["keyPhone"];*/
$res = DB::query("UPDATE ClientServices SET client_id = '%d', service_id = '%d', price_condition = '%d'",$session,$service_id,$on_off);
if ($res) return "все получилось";
}
}
?>
<!DOCTYPE html>
<html lang="ru">
<?php include (ABSOLUTE_PATH."/layouts/shared/head.php"); ?>
<?php if ($conf->is_auth()) { ?>
<body>
<!-- Page container -->
<div class="page-container page-container sidebar-fixed can-resize">
<?php include (ABSOLUTE_PATH."/layouts/shared/sidebar.php"); ?>
<!-- Main container -->
<div class="main-container gray-bg">
<?php include (ABSOLUTE_PATH."/layouts/shared/mheader.php"); ?>
<?php include (ABSOLUTE_PATH."/layouts/shared/breadcrumbs.php"); ?>
<?php if (isset($_GET["err"])) $err = "<h1>Ошибка</h1>";?>
<style>
.services_check button {margin-right:19px;}
.services_check {font-size:20px;}
</style>
<!-- Main content -->
<div class="main-content">
<div class="row">
<div class="col-md-10">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h3 class="panel-title">Услуги</h3>
</div>
<!-- panel body -->
<div class="panel-body">
<ul class="list-group services_check">
<form method="post" action="edit_services.php">
<?php
// btn btn-default btn btn-primary// icon-list-add icon-check
foreach ($services_list as $row)
{
if ($row['price_type'] == 0) {$row['price_type'] = 'Руб./месяц';}
else {$row['price_type'] = 'Руб./единоразово';}
echo '<li class="list-group-item">
<button class="changeCondition '.(!empty($row['price_condition'] == '1') ? "btn btn-primary" : "btn btn-default").'" type="submit">
<i class="'.(!empty($row['price_condition'] == '1') ? "icon-check" : "icon-list-add").'"></i>
</button>'.$row['options'].' '.$row['price'].' '.$row['price_type'].' '.$row['price_condition'].'</li>
';
}
/*<i class="'.(empty($row['pole']) ? "icon-list-add" : "icon-check").'">*/
?>
</ul>
<input type="hidden" name="save_but">
<button class="btn btn-success save_services" type="submit">Сохранить</button>
</form>
<p>
<div class="alert alert-success alert-dismissible saved" style="display:none;" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Изменения сохранены!</strong>
<br>Уважаемый абонент, сформирована заявка №137484 на активацию дополнительных услуг. В ближайшее время с вами свяжется менеджер по работе с клиентами.
</div>
</p>
</div>
</div>
</div>
</div>
<?php include (ABSOLUTE_PATH."/layouts/shared/footer.php"); ?>
</div>
<!-- /main content -->
</div>
<!-- /main container -->
</div>
<!-- /page container -->
<?php
}
else {
if (isset($auth) && $auth != "true") {
$auth_err = '<div class="alert alert-danger alert-login" role="alert">'.$auth.'</div>';
}
include (ABSOLUTE_PATH."/layouts/shared/login_page.php");
}
?>
<script asyncsrc="/assets/js/services.js"></script>
<?php include (ABSOLUTE_PATH."/layouts/shared/loadjs.php"); ?>
</body>
</html>
$condition = $_POST['condition'];
foreach($condition as $item) {
//мне нужны для записи 3 переменные
$item['client_id'], $item['service_id'], $condition = $_POST['condition'];
//а дальше запрос к базе на изменение добавление редактирование
$res = DB::query("UPDATE ClientServices SET client_id = '%d', service_id = '%d', price_condition = '%d'",$session,$service_id,$on_off);
}
if (isset($_POST['save_but']))
{
$condition = $_POST['condition'];
дальше массив
{
arrey =[как тут написать переменные или что ? ]
}
и дальше что идет ?
$res = DB::query("UPDATE ClientServices SET client_id = '%d', service_id = '%d', price_condition = '%d'",$session,$service_id,$on_off);
if ($res) return "все получилось";
}
<form method="post" action="edit_services.php">
<?php
foreach ($services_list as $row)
{
if ($row['price_type'] == 0) {$row['price_type'] = 'Руб./месяц';}
else {$row['price_type'] = 'Руб./единоразово';}
echo '<li class="list-group-item">
<input type="hidden" name="condition" value="1">
<button class="changeCondition '.(!empty($row['price_condition'] == '1') ? "btn btn-primary" : "btn btn-default").'" type="submit">
<i class="'.(!empty($row['price_condition'] == '1') ? "icon-check" : "icon-list-add").'"></i>
</button>'.$row['options'].' '.$row['price'].' '.$row['price_type'].' '.$row['price_condition'].'</li>
';
}
?>
</ul>
<input type="hidden" name="save_but" value="1">
<button class="btn btn-success save_services" type="submit">Сохранить</button>
</form>
if (isset($_POST['save_but']))
{
$on_off = 1;
$service_id = 2;
/*$on_off = $_POST["где взять пост"];
$service_id = $_POST["где взять пост"];*/
$res = DB::query("UPDATE ClientServices SET client_id = '%d', service_id = '%d', price_condition = '%d'",$session,$service_id,$on_off);
if ($res) return "все получилось";
}
CREATE TABLE `ClientServices` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`client_id` INT(11) UNSIGNED NOT NULL,
`service_id` INT(11) UNSIGNED NOT NULL,
`price_condition` ENUM('0','1') NULL DEFAULT NULL COMMENT 'выкл вкл',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;