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

<?php
if(p('adi') && g('islem')=="")
{
	$adi 		= $_POST['adi'];
	$ingadi 	= $_POST['ingadi'];
	$durum 		= p('durum');
	$aciklama	= $_POST['aciklama'];
	$ingaciklama= $_POST['ingaciklama'];
	$seo		= seo($adi);
	include_once('class.upload.php');
	$upload = new upload($_FILES['resim']);
	if ($upload->uploaded){
	$upload->file_auto_rename = true;
	$upload->process("../resimler/markalar");
	
	$upload->file_auto_rename = true;
	$upload->image_resize = true;
	$upload->image_ratio_crop = true;
	$upload->image_x = 127;
	$upload->image_y = 27;
	$upload->image_ratio_y = true;
	$upload->process("../resimler/markalar/kücük");
	if ($upload->processed){
	$sayfaresim=''.$upload->file_dst_name.'';
	}
	}
	$gitti=$sayfaresim=''.$upload->file_dst_name.'';
	
	$sayfa_sorgu	=	mysql_query("INSERT INTO markalar SET
										adi		=	'$adi', 
										ingadi	=	'$ingadi', 
										resim	=	'$sayfaresim',
										seo		=	'$seo', 
										aciklama=	'$aciklama',
										ingaciklama=	'$ingaciklama',
										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('adi') && g('islem')=="duzenle")
{
	$adi 		= $_POST['adi'];
	$ingadi 	= $_POST['ingadi'];
	$ingaciklama= $_POST['ingaciklama'];
	$durum 		= p('durum');
	$d_id 		= g('id');
	$aciklama	= $_POST['aciklama'];
	$seo		= seo($adi);
	
	include_once('class.upload.php');
	$upload = new upload($_FILES['resim']);
	if ($upload->uploaded){
	$upload->file_auto_rename = true;
	$upload->process("../resimler/markalar");
	
	$upload->file_auto_rename = true;
	$upload->image_resize = true;
	$upload->image_ratio_crop = true;
	$upload->image_x = 127;
	$upload->image_y = 27;
	$upload->image_ratio_y = true;
	$upload->process("../resimler/markalar/kücük");
	if ($upload->processed){
	$sayfaresim=''.$upload->file_dst_name.'';
	}
	}
	if($sayfaresim!="")
	{
		$resim_bul=mysql_fetch_object(mysql_query("SELECT * FROM markalar WHERE id='$d_id'"));
		$resim_sil=unlink("../resimler/markalar/büyük/".$resim_bul->resim);
		$resim_sil2=unlink("../resimler/markalar/kücük/".$resim_bul->resim);
	
		$sayfa_duzenle_sorgu	=	Sorgu("UPDATE markalar SET 
											adi		=	'$adi',
											ingadi	=	'$ingadi',	
											ingaciklama=	'$ingaciklama',
											resim	=	'$sayfaresim', 
											aciklama=	'$aciklama',
											seo		=	'$seo', 
											durum	=	'$durum' 
											WHERE id=	'$d_id'");
		$gitti=$sayfaresim=''.$upload->file_dst_name.'';
	}else{	
		$sayfa_duzenle_sorgu = Sorgu("UPDATE markalar SET 
											durum	=	'$durum', 
											ingadi	=	'$ingadi',
											ingaciklama=	'$ingaciklama',
											aciklama=	'$aciklama', 
											seo		=	'$seo', 
											adi		=	'$adi' 
											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" ;
	
	$SayfaSonuc = Sonuc(Sorgu("SELECT * FROM markalar 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">
                            Marka 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">Marka Adı</label>
                                      <div class="col-sm-10">
                                        <input type="text" class="form-control" name="adi" value="<?php echo $SayfaSonuc->adi;?>" id="adi" placeholder="Marka Adı">
                                      </div>
                                  </div>
                             
                           <div class="form-group">
                                      <label class="col-sm-2 col-sm-2 control-label">Marka Linki</label>
                                      <div class="col-sm-10">
                                         <input type="text" class="form-control" name="ingadi" value="<?php echo $SayfaSonuc->ingadi;?>" id="ingadi" placeholder="Marka Urlsi">
                                      </div>
                                  </div>
						 
						 
						             <div class="form-group last">
                                          <label class="col-sm-2 col-sm-2 control-label">Marka 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/markalar/<?php echo $SayfaSonuc->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($SayfaSonuc->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");?>