Uname: Linux sv2.orange-thailand.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Software: Apache/2
PHP version: 7.3.33 [ PHP INFO ] PHP os: Linux
Server Ip: 43.229.78.102
Your Ip: 3.15.221.191
User: huskies (1019) | Group: huskies (1021)
Safe Mode: OFF
Disable Function:
NONE

name : form_product_description.php
<?php  session_start(); ?>
<!doctype html>
<html class="fixed">
<?php require('inv_header.php'); ?>
<!-- Specific Page Vendor CSS -->
<link rel="stylesheet" href="assets/vendor/owl-carousel/owl.carousel.css" />
<link rel="stylesheet" href="assets/vendor/owl-carousel/owl.theme.css" />
<!-- Theme CSS -->
<link rel="stylesheet" href="assets/stylesheets/theme.css" />
<!-- Skin CSS -->
<link rel="stylesheet" href="assets/stylesheets/skins/default.css" />
<!-- Theme Custom CSS -->
<link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
<!-- Head Libs -->
<script src="assets/vendor/modernizr/modernizr.js"></script>
<link rel="stylesheet" href="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.css" />

  <style media="screen">
    .color{
      overflow: hidden;
      width: 40px;
      height: 40px;
      border: solid 2px #ddd;
      border-radius: 40px;
    }

      input[type=file]{
        display: inline;
      }
      #image_description{
       border: 1px solid black;
       padding: 10px;
     }
     #image_description img{
       width: 100%;
       padding: 15px;
     }
     /*  set model center */
     .modal {
         text-align: center;
         padding: 0!important;
       }

       .modal:before {
         content: '';
         display: inline-block;
         height: 100%;
         vertical-align: middle;
         margin-right: -4px;
       }

       .modal-dialog {
         display: inline-block;
         text-align: left;
         vertical-align: middle;
       }
  </style>
  <body>
    <section class="body">

      <?php $active = 2; ?>
      <?php $subactive = 1; ?>
      <?php
        $product = "SELECT * FROM `tb_product` WHERE `id_product` = '".$_GET['id']."'";
        $objproduct = mysqli_query($myConn,$product);
        $resultproduct = mysqli_fetch_array($objproduct);
       ?>
    <?php require('inv_nav.php'); ?>
    <?php require('inv_manu.php'); ?>
    <section role="main" class="content-body">
      <header class="page-header">
        <h2>รูปภาพรายละเอียดสินค้า</h2>

        <div class="right-wrapper pull-right">
          <ol class="breadcrumbs">
            <li>
              <a href="index.html">
                <i class="fa fa-home"></i>
              </a>
            </li>
            <li><a href="form_product.php"><span>สินค้า</span></a></li>
            <li><span>รายละเอียดสินค้า</span></li>
          </ol>

          <a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
        </div>
      </header>

      <!-- start: page -->
      <div class="owl-carousel" data-plugin-carousel data-plugin-options='{ "autoPlay": 100000, "items": 6, "itemsDesktop": [1199,4], "itemsDesktopSmall": [979,3], "itemsTablet": [768,2], "itemsMobile": [479,1] }'>
        <?php
        $sql = "SELECT * FROM `tb_product_description` WHERE `id_product` = '".$_GET['id']."' ";
        $obj = mysqli_query($myConn,$sql);
        while ($result = mysqli_fetch_array($obj)) {

           ?>
          <div class="item spaced" style=" text-align: right; ">
            <button type="button" class="mb-xs mt-xs mr-xs btn btn-danger" onclick="delete_Product_des(<?php echo $result['id_des'] ?>)">
              <i class="fa fa-times"> ลบ</i>
            </button>
            <img class="img-thumbnail" src="<?php echo $result['images'] ?>" alt="">
          </div>

        <?php } ?>
       </div>
      <hr>
        <div class="row">
              <div class="col-md-2"></div>
              <div class="col-md-9">
                <form  class="form-horizontal" id="saveimg_description" name="saveimg_description" enctype="multipart/form-data">
                  <input type="hidden" name="id" id="id" value="<?php echo $_GET['id']; ?>">
                  <section class="panel">
                    <header class="panel-heading">
                      <h2 class="panel-title">อัพโหลดรายละเอียดสินค้า</h2>
                      <p class="panel-subtitle">
                        รายละเอียดการอัพโหลด | ประเภทไฟล์ <code>JPG , PNG</code>
                      </p>
                        <div style=" text-align: right; ">
                            <button type="submit" id="submit" name="submit" class="btn btn-success">บันทึกข้อมูล</button>
                            <button type="reset" class="btn btn-default">ยกเลิก</button>
                        </div>
                    </header>
                    <div class="panel-body">
                      <div class="form-group">
                        <label class="col-md-3 control-label">File Upload</label>
                        <div class="col-md-6">
                          <input type="file" id="uploadFile" name="uploadFile[]" class="form-control" accept="image/jpeg,image/jpg" multiple/>
                        </div>
                      </div><br><br>
                      <label for="image_description"> Show Images.</label>
                      <div id="image_description"></div>
                    </div>
                  </section>
                </form>
              </div>
          </div>
      <!-- end: page -->
    </section>
    </section>


    <?php require('inv_footer.php'); ?>
    <!-- Specific Page Vendor -->
    <script src="assets/vendor/owl-carousel/owl.carousel.js"></script>
    <!-- Theme Base, Components and Settings -->
    <script src="assets/javascripts/theme.js"></script>
    <!-- Theme Custom -->
    <script src="assets/javascripts/theme.custom.js"></script>
    <!-- Theme Initialization Files -->
    <script src="assets/javascripts/theme.init.js"></script>
    <!-- Specific Page Vendor -->
    <script src="assets/vendor/jquery-autosize/jquery.autosize.js"></script>
    <script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>

    <script type="text/javascript">
      function delete_Product_des(id) {
        console.log(id);
        swal({
          title: "คุณต้องการลบรูปภาพสินค้านี้ หรือไม่?",
          text: "Item(s) will be removed from product!",
          buttons: true,
          dangerMode: true,
        })
        .then((willDelete) => {
          if (willDelete) {
              $.ajax({
                url: 'sql/sql_delete_description.php', 
                type: "POST",
                datatype: "json",
                data : {id:id},
                ContentType:"application/json",

                success: function(response){
                  console.log(response);
                  var x = jQuery.parseJSON(response);
                  if(x.flag == true){
                    console.log(x.message);
                    swal(
                      'Your imaginary file has been deleted!!',
                      '',
                      'success'
                    )
                    window.setTimeout('location.reload()', 1000); //Reloads after 2000 seconds
                  }else{
                    swal(
                      'error',
                      '',
                      'error'
                    )
                  }
                },error: function(err){
                  alert(err);
                }
              });
          }
        });
      }

      $("#saveimg_description").submit(function(e){
        e.preventDefault();
        var formData = new FormData(this);

               $.ajax({
                  type:'POST',
                  url: 'sql/sql_description.php',
                  data:formData,
                  cache:false,
                  contentType: false,
                  processData: false,
                  success:function(data){
                      console.log("process ->"+data);
                      if(data == "true"){
                        swal(
                          'ทำการเพิ่มรูปลงอัลบั้มสำเร็จ!!',
                          '',
                          'success'
                        )
                      }else{
                        swal(
                          'ผิดพลาด กรุณาลองใหม่อีกครั้ง!!',
                          '',
                          'error'
                        )
                      }
                      window.setTimeout('location.reload()', 800); //Reloads after 2000 seconds
                  },
                  error: function(data){
                      console.log("error");
                      console.log(data);
                      alert(data);
                  }
               });

      });

    </script>
    <script>
      $("#uploadFile").change(function(){
         $('#image_description').html("");
         var total_file=document.getElementById("uploadFile").files.length;

         for(var i=0;i<total_file;i++)
         {
          $('#image_description').append("<img src='"+URL.createObjectURL(event.target.files[i])+"'>");
         }
      });
    </script>

  </body>
</html>
© 2024 UnknownSec