<?php
require_once('classes/body.class.php');
require_once('classes/db.class.php');
require_once('classes/system.class.php');
$title= new Body;
$title->SetTitle(homeurl.' - Тема оформления');
$title->GetHeader();

if ($b == false){
header('location:/');
die();
}
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/office"style="text-decoration:none; color:white;"> Кабинет</a> :: Тема оформления</div></div></div>';

echo '<div class="list-group-item media"><form method="post" action="?style">Выбрать дизайн:<br/><select  class="form-control" name="style">';
 ////////////////////////////////////////////////////////////
 $s_default = DB::$dbs->querySingle( "SELECT COUNT(*) FROM `blogger` WHERE (`style` = 'default')" );
 echo '<option value="default"';
 if ( $b[ 'style' ] == "default" ) echo 'selected';
 echo '>Стандартный (' . $s_default . ')</option>';
 ////////////////////////////////////////////////////////////
 $s_green = DB::$dbs->querySingle( "SELECT COUNT(*) FROM `blogger` WHERE (`style` = 'green')" );
 echo '<option value="green"';
 if ( $b[ 'style' ] == "green" ) echo 'selected';
 echo '>Темно зеленый (' . $s_green . ')</option>';
 ////////////////////////////////////////////////////////////


 echo '</select><br/><input type="submit" class="btn btn-primary" value="Установить"/></form></div>';
 if ( isset( $_GET[ 'style' ] ) ) {
     DB::$dbs->query( "UPDATE `blogger` SET `style` = ? WHERE `id` = ?", [ $_POST[ 'style' ],$b[ 'id' ]  ] );
     header( 'refresh:3; url=/' );
     echo '<div class="alert alert-success"role="alert">Тема оформления успешно изменена!</div>';
 } 

$title->GetMenu();
$title->GetFooter();
?>
