<?php include("header.php");?>

<?php
if(p('slideradi') && g('islem')=="")
{
	$slideradi 	= $_POST['slideradi'];
	$link 		= $_POST['link'];
	$durum 		= $_POST['durum'];
	$tarih		= date("d-m-Y");
	
	include_once('class.upload.php');
	$upload = new upload($_FILES['resim']);
	if ($upload->uploaded){
	$upload->file_auto_rename = true;
	$upload->image_resize = true;
		$upload->image_x = 127;
	$upload->image_y = 27;
	$upload->process("../resimler/slider");
	if ($upload->processed){
	$sliderResim=''.$upload->file_dst_name.'';
	}
	}
	$gitti=$sliderResim=''.$upload->file_dst_name.'';
	
	$slider_sorgu	=	Sorgu("INSERT INTO slider SET
										adi		=	'$slideradi', 
										resim	=	'$sliderResim', 
										link	=	'$link',
										tarih	=	'$tarih',
										durum	=	'$durum'");	
																								   
		$bilgi = '   <div class="alert alert-success alert-block fade in">
                                  <button data-dismiss="alert" class="close close-sm" type="button">
                                      <i class="fa fa-times"></i>
                                  </button>
                                  <h4>
                                      <i class="fa fa-ok-sign"></i>
                                      Başarılı!
                                  </h4>
                                  <p>Başarıyla eklenmiştir...</p>
                              </div>
							  
		 ' ;
		
}


if(p('slideradi') && g('islem')=="duzenle")
{
	$slideradi 	= $_POST['slideradi'];
	$link 		= $_POST['link'];
	$durum 		= $_POST['durum'];
	$d_id 		= g('id');
	$tarih		= date("d-m-Y");
	
	include_once('class.upload.php');	
	$upload = new upload($_FILES['resim']);
	if ($upload->uploaded){
	$upload->file_auto_rename = true;
	$upload->image_resize = true;
		$upload->image_x = 127;
	$upload->image_y = 27;
	$upload->process("../resimler/slider");
	if ($upload->processed){
	$sliderResim=''.$upload->file_dst_name.'';
	}
	}
	if($sliderResim!="")
	{
		$resim_bul=Sonuc(Sorgu("SELECT * FROM slider WHERE id='$d_id'"));
		$resim_sil=unlink("../resimler/slider/".$resim_bul->resim);
	
		$slider_duzenle_sorgu	=	Sorgu("UPDATE slider SET 
											adi		=	'$slideradi', 
											resim	=	'$sliderResim',
											link	=	'$link',
											tarih	=	'$tarih',
											durum	=	'$durum' 
											WHERE id=	'$d_id'");
		$gitti=$sliderResim=''.$upload->file_dst_name.'';
	}else{	
		$slider_duzenle_sorgu = Sorgu("UPDATE slider SET 
											durum	=	'$durum', 
											tarih	=	'$tarih',
											link	=	'$link',
											adi		=	'$slideradi' 
											where id=	'$d_id'");
	}
				  $bilgi = '  	  
							  <div class="alert alert-success alert-block fade in">
                                  <button data-dismiss="alert" class="close close-sm" type="button">
                                      <i class="fa fa-times"></i>
                                  </button>
                                  <h4>
                                      <i class="fa fa-ok-sign"></i>
                                      Başarılı!
                                  </h4>
                                  <p>Başarıyla güncellenmiştir...</p>
                              </div>
							  
		 ' ;
}

if($_GET['islem']=="duzenle")
{
	$sayfaid = $_GET['id'];	
	$durum = "duzenle" ;
	$SliderSonuc = Sonuc(Sorgu("SELECT * FROM slider WHERE id='$sayfaid'"));
}

?>


 <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <!-- page start-->
        
            

              <div class="row">
                  <div class="col-lg-12">
				    <?php echo $bilgi;?>
                      <section class="panel">
                          <header class="panel-heading">
                            Slider Ekle
                          </header>
                          <div class="panel-body">
                              <form class="form-horizontal tasi-form" method="post" action="" enctype="multipart/form-data">
							  
							  

                                  <div class="form-group">
                                      <label class="col-sm-2 col-sm-2 control-label">Slider Adı</label>
                                      <div class="col-sm-10">
                                       <input type="text" class="form-control" name="slideradi" value="<?php echo $SliderSonuc->adi;?>" id="slideradi" placeholder="Slider Adı">
                                      </div>
                                  </div>
                             
                             <div class="form-group">
                                      <label class="col-sm-2 col-sm-2 control-label">Slider Linki</label>
                                      <div class="col-sm-10">
                                       <input type="text" class="form-control" name="link" value="<?php echo $SliderSonuc->link;?>" id="link" placeholder="Slider Linki">
                                      </div>
                                  </div>
                             
						 
						 
						             <div class="form-group last">
                                          <label class="col-sm-2 col-sm-2 control-label">Slider Resmi</label>
                                           <div class="col-sm-10">
                                              <div class="fileupload fileupload-new" data-provides="fileupload">
                                               <div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
                                               <?php if($_GET['islem']=='duzenle'){?>
                                               <img src="../resimler/slider/<?php echo $SliderSonuc->resim;?>" style="width: 200px; height: 200px;" alt="" />
                                               <?php } else { ?>
                                              <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt="" />
                                              <?php }?>
                                              </div>
                                                  <div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
                                                  <div>
                                                   <span class="btn btn-white btn-file">
                                                   <span class="fileupload-new"><i class="fa fa-paper-clip"></i> Resim Seç</span>
                                                   <span class="fileupload-exists"><i class="fa fa-undo"></i> Değiştir</span>
                                                   <input type="file" name="resim" class="default" />
                                                   </span>
                                                      <a href="#" class="btn btn-danger fileupload-exists" data-dismiss="fileupload"><i class="fa fa-trash"></i> Sil</a>
                                                  </div>
                                              </div>
                                            
                                          </div>
                                      </div>
						 
						 
						 
						          <div class="row m-bot15">
                                  <?php if($_GET['islem']=="duzenle"){?>
								 <label class="col-sm-2 col-sm-2 control-label">Durumu</label>
                                           <div class="col-sm-10">
                                           <input type="checkbox" name="durum" <?php if($SliderSonuc->durum == '1') {?> checked <?php } ?> value="1" data-toggle="switch"/>
                                          </div>
                                        	<?php }else{?>
											 <label class="col-sm-2 col-sm-2 control-label">Durumu</label>
                                          <div class="col-sm-10">
                                           	<input type="checkbox" name="durum" value="1" checked data-toggle="switch"/>
                                          </div>
										  <?php } ?>
                                      </div>
						 
						 
						 
						 
						 
						 
						 
						 
						 
						         <div class="form-group">
                                        <div class="col-sm-10">
									    <?php if($_GET['islem']=="duzenle"){?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                          <button class="btn btn-shadow btn-danger" type="submit">Güncelle</button>
										  <?php }else{?>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										  <button class="btn btn-shadow btn-success" type="submit">Kaydet</button>
										   <?php } ?>
                                      </div>
                                  </div>
						 
						 
						 
						 
						 
						 
                              </form>
                          </div>
                      </section>
                  
                      

           

               

                  </div>
              </div>
              <!-- page end-->
          </section>
      </section>
      <!--main content end-->





















<?php include("footer.php");?>