<?php
$path="../../";
include("../../map.php");
include("../../scripts.php");
?>
<?php $sql=mysqli_query($conn, "select * from genel where id=".$_GET["id"]." order by s10 asc"); $rs=mysqli_fetch_assoc($sql);?>
<html style="background-color:white;">
<head>
    <meta http-equiv="Content-Language" content="tr">
</head>
<body>
    <?php if($_GET["durum"]=="ok"){?>
     <div class="alert alert-success" role="alert"> <?php echo $sdil[212]; //İşlem Başarıyla Gerçekleştirilmiştir !?> </div>
 <?php }?>
 <form name="frm" method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=duzenle&id=<?php echo $_GET["id"];?>" enctype="multipart/form-data">
  <div class="panel panel-default">
     <div class="panel-heading"><?php echo $sdil[7]; //Sevkiyat & Desi İşlemleri?> <?php echo $sdil[207]; //Detay?></div>
     <div class="panel-body"> 
        <div class="row">
          <div class="col-xs-8">
            <input type="text" name="t1" value="<?php echo $rs["t1"];?>" class="form-control" style="margin-bottom:5px; margin-top:3px; float: left;" title="(t1) Ad" placeholder="ad">
        </div>
        <div class="col-xs-4">
         <select class="form-control" name="s4">
            <option value="0" <?php if($rs["s4"]=="0"){echo "Selected";}?>>Model</option>
            <option value="1" <?php if($rs["s4"]=="1"){echo "Selected";}?>>Ücretsiz Kargo</option>
            <option value="2" <?php if($rs["s4"]=="2"){echo "Selected";}?>>Alıcı Ödemeli</option>
        </select>
    </div>
</div>
<div class="row">
    <div class="col-xs-4">
      <input type="checkbox" class="" name="r1" value="ON" style="display:none; float:left; border:#fff; margin-right:5px; margin-top:3px; margin-left:2px;" alt="Resim Var/Yok" title="Resim Var/Yok">
      <input class="form-control" type="file" name="n7" style="" onchange="document.frm.r1.checked=true;" accept="*">
      <P>* 180x40px logosu</P>
  </div>
  <div class="col-xs-4">
   <input type="text" name="t4" value="<?php echo $rs["t4"];?>" class="form-control" style="" title="(t4) Limit" placeholder="Limit">
</div>
<div class="col-xs-4">
   <input type="text" name="t5" value="<?php echo $rs["t5"];?>" class="form-control" style="" title="(t5) Extra" placeholder="Extra">
</div>
<div class="col-xs-4">
   <input type="text" name="t7" value="<?php echo $rs["t7"];?>" class="form-control" style="" title="(t7) Extra" placeholder="Extra">
</div>
</div>
<button type="submit" style="float:right; margin-right:10px; margin-top:5px;" id="btn" class="btn btn-primary">Kaydet</button>
<?php if(!empty($rs["n7"])){?>
  <div style="clear:both;"></div>
  <a href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&durum=rsil"><i class="fa fa-times" style="position:absolute; margin-top:-8px; margin-left:5px;"></i></a>
  <img src="../../../deppo/image/<?php echo $rs["n7"];?>" style="margin-left:5px; height:65px;">
<?php }?>
</div>
</div>
</form>
<table class="table table-no-more table-bordered table-striped mb-0" style="overflow:auto; font-size:14px;">
    <tr class="tittr mdn">
        <td><?php echo translate("#Min-Desi")?></td>
        <td><?php echo translate("#Max Desi")?></td>
        <td><?php echo translate("#Fiyat")?></td>
        <td class="dn"><?php echo translate("#Sıra")?></td>
        <td class="w8"><?php echo translate("#İşlem")?></td>
    </tr>
    <form method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&durum=ekle2">
        <input type="hidden" value="desi" name="ne"> 
        <tr class="addtr">
            <td class="mpr">
                <input type="text" name="s2" size="5" value="0" onfocus="if(this.value == '0') { this.value = ''} "  onblur="if(this.value == '') { this.value='0'; }" title="Desi-1" class="with-tip form-control">
                <span class="rph ddn mfs10">Min-Desi</span>
            </td>
            <td class="mpr">                                        
                <input type="text" name="s3" size="5" value="0" onfocus="if(this.value == '0') { this.value = ''} "  onblur="if(this.value == '') { this.value='0'; }" title="Desi-2" class="with-tip form-control">
                <span class="rph ddn mfs10">Max-Desi</span>
            </td>
            <td class="mpr">
                <input type="text" name="pb1" size="5" value="0,00"  onfocus="if(this.value == '0,00') { this.value = ''} "  onblur="if(this.value == '') { this.value='0,00'; }" title="fiyat" class="with-tip form-control">
                <span class="rph ddn mfs10">Fiyat</span>
            </td>
            <td class="dn mdn">
                <input type="text" name="s10" value="0" class="form-control">
                <span class="rph ddn mfs10">Sıra</span>
            </td>
            <td class="mpr">
                <div class="input-group-btn">
                    <button tabindex="-1" class="btn btn-warning " type="submit" <?php if($e10==1 and $MSA<>1){?>disabled<?php }?>><i class="fa fa-plus" ></i></button>
                </div>
            </td>
        </tr>
    </form>
    <?php
    $durum=$_GET["durum"];
    $sql=mysqli_query($conn, "select * from genel where ne='desi' and s1=".$_GET["id"]." order by s10 asc"); while($rs=mysqli_fetch_assoc($sql)){
        $s1==$rs["s1"];
        ?>
        <form method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=duzenle2&id=<?php echo $rs["id"];?>" id="xf<?php echo $rs["id"];?>" name="xf<?php echo $rs["id"];?>">
            <input type="hidden" value="desi" name="ne">
            <tr class="btr">
                <td class="mpr">
                    <input type="text" name="s2" size="5" value="<?php echo $rs["s2"];?>" title="<?php echo $rs["s2"];?> Desi ile" class="form-control">
                    <span class="rph ddn mfs10">Min-Desi</span>
                </td>
                <td class="mpr">                                                    
                    <input type="text" name="s3" size="5" value="<?php echo $rs["s3"];?>" title="<?php echo $rs["s3"];?> Desi Arası" class="form-control">
                    <span class="rph ddn mfs10">Max-Desi</span>
                </td>
                <td class="mpr">
                    <input type="text" name="pb1" size="5" value="<?php echo wprice($rs["pb1"]);?>" title="Fiyat" class="form-control">
                    <span class="rph ddn mfs10">Fiyat</span>
                </td>
                <td class="dn mdn">
                    <input type="text" name="s10" value="<?php echo $rs["s10"];?>" class="form-control">
                    <span class="rph ddn">Sıra</span>
                </td>
                <td>
                    <div class="input-group-btn">
                        <button tabindex="-1" class="btn btn-warning " type="button" id="b<?php echo $rs["id"];?>" onclick="Ajaxs('<?php echo $rs["id"];?>','#result','AjaxPost');" <?php if($e10==1 and $MSA<>1){?>disabled<?php }?>  style="margin-right:5px;"><i class="fa fa-refresh"></i></button>
                        <?php if($e10==1 and $MSA<>1){?>
                            <button type="button" style="margin-left: 1px" tabindex="-1" class="btn btn-danger " href="#"><i class="fa fa-ban"></i></button>
                        <?php }else{?>
                            <button type="button" style="margin-left: 1px" tabindex="-1" class="btn btn-danger" onclick="if(confirm('Bu Kayıt Silinecektir! Onaylıyor musunuz?')) {location.href='?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&item=<?php echo $rs["id"];?>&durum=sil'; } return false;"><i class="fa fa-trash"></i></button>
                        <?php }?>
                    </div>
                </td>
            </tr>
        </form>
    <?php }?>
</table>
</body>
</html>
<?php
if($_GET["durum"]=="duzenle"){
   if($_POST["r1"]<>""){
      $kaydedilecekyer = "../../../deppo/image";
      $kaynak  = $_FILES['n7']['tmp_name'];  //Burası resminiz kök klasörünün yerini verir  
      $tipi = $_FILES['n7']['type']; // Dosyanın Tipi
      $adi  = $_FILES["n7"]["name"]; // Dosyanın PCdeki Adı
      $uzanti = explode('.',$_FILES['n7']['name']);
      $rand = substr(md5(uniqid(rand())),0,10);
      $yeni = "".$rand.".".$uzanti[count($uzanti)-1]."";
      move_uploaded_file ($_FILES['n7']['tmp_name'], $kaydedilecekyer . "/".$yeni);
      $Rs = mysqli_query($conn, "update genel set n7='".$yeni."' where id=".$_GET["id"]."");
  }
  if(!empty($_POST["s4"])){$s4=$_POST["s4"];}else{$s4="0";}
  if(!empty($_POST["s5"])){$s5=$_POST["s5"];}else{$s5="0";}
  $Rs = mysqli_query($conn, "update genel set t1='".$_POST["t1"]."', t4='".$_POST["t4"]."', t5='".$_POST["t5"]."', n1='".$_POST["n1"]."', n2='".$_POST["n2"]."', n3='".$_POST["n3"]."', n4='".$_POST["n4"]."', n5='".$_POST["n5"]."', n6='".$_POST["n6"]."', n8='".$_POST["n8"]."', s4='".$s4."', s5='".$s5."' where id=".$_GET["id"]."");
  echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok",self,0,0);
}elseif($_GET["durum"] == "rsil"){
    $dosya="../../../deppo/image/".$rs["n7"]."";
    unlink($dosya);
    $Rs = mysqli_query($conn, "update genel set n7='' where id=".$_GET["id"]."");
    echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok",self,0,0);
}elseif($_GET["durum"]=="ekle2"){
    $sql = $conn->query("insert into genel(s1,s2,s3,s10,t1,pb1,ne) values ('".$_GET["id"]."', '".$_POST["s2"]."','".$_POST["s3"]."','".$_POST["s10"]."', '".$_POST["t1"]."', '".sprice($_POST["pb1"])."', '".$_POST["ne"]."')");
    echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok_2",self,0,0);
}elseif($_GET["durum"]=="duzenle2"){
    $Rs = mysqli_query($conn, "update genel set s2='".$_POST["s2"]."', s3='".$_POST["s3"]."', pb1='".sprice($_POST["pb1"])."', s10='".$_POST["s10"]."' where id=".$_GET["id"]."");
    echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok_2",self,0,0);
}elseif($_GET["durum"]=="sil"){
    $sql = mysqli_query($conn, "delete from genel where id=".$_GET["item"]."");
    $sql = mysqli_query($conn, "delete from genel where ne='desi' and s1=".$_GET["item"]."");
    echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok_1",self,0,0);
}
?>