<?
	ob_start();
	session_start();
	include_once("../sistem/database.php");
	include_once("sistem/admin.php");
	 $db     	= new database();
	 $admin		= new user(); 
	  $db->baglanti();
	  $login = $admin->giris();
	 if($login=="fail"){
        header("location: login.php");
    }else{
?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
	<meta charset="utf-8" />
	<title>TICARETIUMbasic Admin Paneli</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
	<link href="assets/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" />
	<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
	<link href="css/style.css" rel="stylesheet" />
	<link href="css/style_responsive.css" rel="stylesheet" />
	<link href="css/style_default.css" rel="stylesheet" id="style_color" />

	<link href="assets/fancybox/source/jquery.fancybox.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="assets/uniform/css/uniform.default.css" />
	<link href="assets/fullcalendar/fullcalendar/bootstrap-fullcalendar.css" rel="stylesheet" />
	<link href="assets/jqvmap/jqvmap/jqvmap.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="../css/font.css" rel="stylesheet" type="text/css">
       <link rel="stylesheet" type="text/css" href="assets/bootstrap-wysihtml5/bootstrap-wysihtml5.css" />


</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="fixed-top">
	<!-- BEGIN HEADER -->
	<div id="header" class="navbar navbar-inverse navbar-fixed-top">
		<!-- BEGIN TOP NAVIGATION BAR -->
		<div class="navbar-inner">
			<div class="container-fluid">
				<!-- BEGIN LOGO -->
				<a class="brand" href="index.php">
				    <img src="img/logo.png" alt="Admin Lab" />
				</a>
				<!-- END LOGO -->
				<!-- BEGIN RESPONSIVE MENU TOGGLER -->
				<a class="btn btn-navbar collapsed" id="main_menu_trigger" data-toggle="collapse" data-target=".nav-collapse">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="arrow"></span>
				</a>
				<!-- END RESPONSIVE MENU TOGGLER --><!-- END  NOTIFICATION -->
                <div class="top-nav ">
                    <ul class="nav pull-right top-menu" >
                        <!-- BEGIN SUPPORT --><!-- END SUPPORT -->
						<!-- BEGIN USER LOGIN DROPDOWN -->
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            	<img src="img/yvzshn.jpg" alt="">
                                <span class="username"><?=$admin->admininfo($_SESSION['a_adminus']);?></span>
							<b class="caret"></b>
							</a>
							<ul class="dropdown-menu">
								
								<li><a href="logout.php"><i class="icon-key"></i> Çıkış Yap</a></li>
							</ul>
						</li>
						<!-- END USER LOGIN DROPDOWN -->
					</ul>
					<!-- END TOP NAVIGATION MENU -->
				</div>
			</div>
		</div>
		<!-- END TOP NAVIGATION BAR -->
	</div>
	<!-- END HEADER -->
	<!-- BEGIN CONTAINER -->
	<div id="container" class="row-fluid">
		<!-- BEGIN SIDEBAR -->
		<div id="sidebar" class="nav-collapse collapse">
			<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
			<div class="sidebar-toggler hidden-phone"></div>
			<!-- BEGIN SIDEBAR MENU -->
			<ul class="sidebar-menu">
             	<li><a class="" href="index.php"><span class="icon-box"><i class="icon-dashboard"></i></span> Anasayfa</a></li>
                 <li><a class="" href="ayarlar.php"><span class="icon-box"><i class="icon-wrench"></i></span> Ayarlar</a></li>
                 <li><a class="" href="teklif.php"><span class="icon-box"><i class="icon-money"></i></span> Teklif Talepleri</a></li>
				<li class="has-sub">
					<a href="javascript:;" class="">
					    <span class="icon-box"> <i class="icon-bookmark"></i></span> Sayfalar
                        <span class="arrow"></span>
                    </a>
                    <ul class="sub">
                        <li><a class="" href="sayfa.php?p=ekle">Sayfa Ekle</a></li>
                        <li><a class="" href="sayfa.php?p=tum">Tüm Sayfalar</a></li>

                    </ul>
				</li>
				<li class="has-sub active open">
					<a href="javascript:;" class="">
					    <span class="icon-box"> <i class="icon-sitemap"></i></span> Kategoriler
                        <span class="arrow"></span>
                    </a>
                    <ul class="sub">
                        <li><a class="" href="kategoriler.php?p=ekle">Yeni Ekle</a></li>
                        <li><a class="" href="kategoriler.php?p=tum">Tüm Kategoriler</a></li>

                    </ul>
				</li>
				<li class="has-sub">
					<a href="javascript:;" class="">
					    <span class="icon-box"> <i class="icon-barcode"></i></span> Ürünler
                        <span class="arrow"></span>
                    </a>
                    <ul class="sub">
                        <li><a class="" href="urunler.php?p=ekle">Yeni Ekle</a></li>
                        <li><a class="" href="urunler.php?p=tum">Tüm Ürünler</a></li>

                    </ul>
				</li>
                <li><a class="" href="iletisim.php"><span class="icon-box"><i class="icon-phone-sign"></i></span> İletişim</a></li>
			</ul>
			<!-- END SIDEBAR MENU -->
		</div>
		<!-- END SIDEBAR -->
		<!-- BEGIN PAGE -->
		<div id="main-content">
			<!-- BEGIN PAGE CONTAINER-->
			<div class="container-fluid">
				<!-- BEGIN PAGE HEADER-->
			  <div class="row-fluid">
					<div class="span12">
						<!-- BEGIN PAGE TITLE & BREADCRUMB-->
						<ul class="breadcrumb">
							<li>
                                <a href="#"><i class="icon-home"></i></a><span class="divider">&nbsp;</span>
							</li>
                            <li>
                                <a href="index.php">TICARETIUMbasic</a> <span class="divider">&nbsp;</span>
                            </li>
							<li><a href="#">Kategoriler</a><span class="divider-last">&nbsp;</span></li>
						</ul>
						<!-- END PAGE TITLE & BREADCRUMB-->
					</div>
				</div>
			  <div class="row-fluid">
			    <div class="span12">
			      <!-- BEGIN EXAMPLE TABLE widget-->
			      <div class="widget">
			        <div class="widget-title">
			          <h4><i class="icon-sitemap"></i>Kategoriler</h4>
			          <span class="tools"> <a href="javascript:;" class="icon-chevron-down"></a> </span> </div>
			        <div class="widget-body">
                    <?
                    	if(isset($_GET['p'])){
							$p = $_GET['p'];
						}else{
							$p = "";
						}
						switch($p){
							default:
					?>
			          <div class="portlet-body">
			            <div class="space15"></div>
			            <table class="table table-striped table-hover table-bordered" id="sample_1">
			              <thead>
			                <tr>
			                  <th width="90%">Kategori Adı</th>
			                  <th width="10%">İşlem</th>
		                    </tr>
		                  </thead>
			              <tbody>
                        <?php
                           $n = mysql_query("SELECT * FROM `kategoriler`");
							while($y = mysql_fetch_object($n)){
						?>
                        <tr class="center text-center">
			                  <td><strong><?=$y->kategori;?></strong></td>
			                  <td>
                                  <a class="duzenle" href="kategoriler.php?p=duzenle&pID=<?=$y->kID;?>"><i class="icon-pencil"></i></a>
                                  <a class="duzenle" href="kategoriler.php?p=sil&pID=<?=$y->kID;?>"><i class="icon-trash"></i></a>
		                    </tr>
                        <?
							}
						?>
		                  </tbody>
		                </table>
		              </div>
                      <?
					  break;
                      case'ekle':
					  ?>
                      <form action="?p=kaydet" class="form-horizontal" method="post">
                      		<input type="hidden" name="pID" value="<?=$pID;?>">
                           <div class="control-group">
                              <label class="control-label">Kategori Başlığı</label>
                              <div class="controls">
                                 <input type="text" class="input-large m-wrap " name="baslik" />
                              </div>
                           </div>
                           <div class="control-group">
                              <label class="control-label">Üst Kategori</label>
                              <div class="controls">
                                        <select class="input-large m-wrap" name="ust" tabindex="1">
                                            <option value="0">Bu Bir Üst Kategori</option>
                                            <?php
                                            $n = mysql_query("SELECT * FROM `kategoriler`");
							                     while($y = mysql_fetch_object($n)){
						                  ?>
                                            <option value="<?=$y->kID;?>"><?=$y->kategori;?></option>
                                            <?
							}
						?>
                                        </select>
                                    </div>
                           </div>
                           <div class="form-actions">
                              <button type="submit" class="btn btn-success">Ekle</button>
                           </div>
                      </form>
                      <?
					  break;
					  case'duzenle':
					  $pID = $_GET['pID'];
					  	$n = mysql_query("SELECT * FROM `kategoriler` WHERE `kID`='$pID'");
							$m = mysql_fetch_object($n);
					  ?>
                      <form action="?p=guncelle" class="form-horizontal" method="post">
                      		<input type="hidden" name="pID" value="<?=$pID;?>">
                           <div class="control-group">
                              <label class="control-label">Kategori Başlığı</label>
                              <div class="controls">
                                 <input type="text" class="span6 " name="baslik" value="<?=$m->kategori;?>" />
                              </div>
                           </div>
                           <div class="control-group">
                              <label class="control-label">Üst Kategori</label>
                              <div class="controls">
                                        <select class="input-large m-wrap" name="ust" tabindex="1">
                                            <option value="0" <?php if($m->uscat==0){?> selected<?php }?>>Bu Bir Üst Kategori</option>
                                            <?php
                                            $n = mysql_query("SELECT * FROM `kategoriler`");
							                     while($y = mysql_fetch_object($n)){
						                  ?>
                                            <option value="<?=$y->kID;?>" <?php if($m->uskat==$y->kID){?> selected<?php }?>><?=$y->kategori;?></option>
                                            <?php
							                 }
						                      ?>
                                        </select>
                                    </div>
                           </div>
                           <div class="form-actions">
                              <button type="submit" class="btn btn-success">Güncelle</button>
                           </div>
                      </form>
                      <?
					  break;case'kaydet':
					  	$baslik = $_POST['baslik'];
						$icerik	= $_POST['ust'];
							$n = mysql_query("INSERT INTO `kategoriler`(`kID`, `kategori`, `uskat`) VALUES (NULL,'$baslik','$icerik')");
								if($n){
					 ?>
                     <script>
							$(function(){
								$('body,html').animate({scrollTop:0},800);
							});
							</script>
                        	<div class="alert alert-success">
                            	<button class="close" data-dismiss="alert">×</button>
                            	<strong>İşlem Başarılı!</strong> Kategori Başarıyla Eklendi.
                        	</div>
                     <?		header("refresh:2; url=kategoriler.php");
								}else{
					?>
                    <script>
							$(function(){
								$('body,html').animate({scrollTop:0},800);
							});
							</script>
                            <div class="alert alert-error">
                            	<button class="close" data-dismiss="alert">×</button>
                            	<strong>Bir Hata Oluştu!</strong> Kategori Eklenemedi.
                        	</div>
                    <?		header("refresh:2; url=kategoriler.php");
								}
					  break;
					  case'guncelle':
					  	$pID	= $_POST['pID'];
					  	$baslik = $_POST['baslik'];
						$icerik	= $_POST['ust'];
							$n = mysql_query("UPDATE `kategoriler` SET kategori='$baslik', uskat='$icerik' WHERE `kID`='$pID'");
								if($n){
					 ?>
                     <script>
							$(function(){
								$('body,html').animate({scrollTop:0},800);
							});
							</script>
                        	<div class="alert alert-success">
                            	<button class="close" data-dismiss="alert">×</button>
                            	<strong>İşlem Başarılı!</strong> Kategori Başarıyla Güncellendi.
                        	</div>
                     <?		header("refresh:2; url=kategoriler.php");
								}else{
					?>
                    <script>
							$(function(){
								$('body,html').animate({scrollTop:0},800);
							});
							</script>
                            <div class="alert alert-error">
                            	<button class="close" data-dismiss="alert">×</button>
                            	<strong>Bir Hata Oluştu!</strong> Kategori Güncellenemedi.
                        	</div>
                    <?		header("refresh:2; url=kategoriler.php");
								}
					  break;
					  case'sil':
					  	$pID = $_GET['pID'];
					  	$n = mysql_query("DELETE FROM `kategoriler` WHERE `kID`='$pID'");
					  	if($n){?>
                     <script>
							$(function(){
								$('body,html').animate({scrollTop:0},800);
							});
							</script>
                        	<div class="alert alert-success">
                            	<button class="close" data-dismiss="alert">×</button>
                            	<strong>İşlem Başarılı!</strong> Kategori Başarıyla Silindi.
                        	</div>
                     <?		header("refresh:2; url=kategoriler.php");
								}else{
					?>
                    <script>
							$(function(){
								$('body,html').animate({scrollTop:0},800);
							});
							</script>
                            <div class="alert alert-error">
                            	<button class="close" data-dismiss="alert">×</button>
                            	<strong>Bir Hata Oluştu!</strong> Kategori Silinemedi.
                        	</div>
                    <?		header("refresh:2; url=kategoriler.php");
								}
					  break;
						}
					  ?>
		            </div>
		          </div>
			      <!-- END EXAMPLE TABLE widget-->
		        </div>
		      </div>
			  <!-- END PAGE HEADER-->
				<!-- BEGIN PAGE CONTENT-->
				<div id="page" class="dashboard">
                    <!-- BEGIN OVERVIEW STATISTIC BLOCKS--><!-- END OVERVIEW STATISTIC BLOCKS--><!-- BEGIN SQUARE STATISTIC BLOCKS-->
                    <div class="square-state"></div>
              <!-- END SQUARE STATISTIC BLOCKS--></div>
				<!-- END PAGE CONTENT-->
			</div>
			<!-- END PAGE CONTAINER-->
		</div>
		<!-- END PAGE -->
	</div>
	<!-- END CONTAINER -->
	<!-- BEGIN FOOTER -->
	<div id="footer">
		2013 &copy; TICARETIUMbasic Admin Paneli
		<div class="span pull-right">
			<span class="go-top"><i class="icon-arrow-up"></i></span>
		</div>
	</div>
	<!-- END FOOTER -->
	<!-- BEGIN JAVASCRIPTS -->
	<!-- Load javascripts at bottom, this will reduce page load time -->
	<script src="js/jquery-1.8.3.min.js"></script>
   <script src="assets/bootstrap/js/bootstrap.min.js"></script>   
   <script src="js/jquery.blockui.js"></script>
   <!-- ie8 fixes -->
   <!--[if lt IE 9]>
   <script src="js/excanvas.js"></script>
   <script src="js/respond.js"></script>
   <![endif]-->
   <script type="text/javascript" src="assets/uniform/jquery.uniform.min.js"></script>
   <script type="text/javascript" src="assets/data-tables/jquery.dataTables.js"></script>
   <script type="text/javascript" src="assets/data-tables/DT_bootstrap.js"></script>
   <script src="js/scripts.js"></script>
	<script src="js/jquery.form.js"></script>
  <script type="text/javascript" src="assets/bootstrap-wysihtml5/wysihtml5-0.3.0.js"></script> 
   <script type="text/javascript" src="assets/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>
      <script src="js/table-editable.js"></script>

	<script>
		jQuery(document).ready(function() {
			// initiate layout and plugins
			App.init();
			TableEditable.init();
		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>
<?
	}
?>