MMCT TEAM
Server IP : 111.118.215.189  /  Your IP : 18.116.82.179
Web Server : Apache
System : Linux md-in-83.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : a1673wkz ( 2475)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home1/a1673wkz/propstonerealty.com/Admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home1/a1673wkz/propstonerealty.com/Admin/edit-product-form.php
 <?php
    session_start();
    if(empty($_SESSION['username']))
    {
        echo '<script>window.location.href="login.php"</script>';
    }
    ?>
<!DOCTYPE html>
<html>
<?php //header link
include("header_link.php"); ?>
<link rel="stylesheet"href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.css"/>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
    <body>
        <?php
//database file link
include("config.php");
?>
               <?php
 // header
include("header.php");
?>
        <!-- Main Wrapper -->
        <div class="main-wrapper">
            <!-- Page Wrapper -->
            <div class="page-wrapper">
                <!-- Page Content -->
                <div class="content container-fluid">
                    <!-- Page Header -->
                    <div class="page-header">
                        <div class="row align-items-center">
                            <div class="col">
                                <h3 class="page-title">Product</h3>
                                <ul class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="index.html">Dashboard</a></li>
                                    <li class="breadcrumb-item active">Product</li>
                                </ul>
                            </div>
                            <div class="col-auto float-right ml-auto">
                                <a href="#" class="btn add-btn" data-toggle="modal" data-target="#add_holiday"><i class="fa fa-plus"></i> Add Product</a>
                            </div>
                        </div>
                    </div>
                    
                    <?php
                    $id=base64_decode($_GET['id']);
                    $cnt='0';
                    $val=$obj->arr("SELECT * FROM products WHERE id='$id'"); $old=$val['image'];?>
                    <!-- /Page Header -->
                    <script src="js/jquery-3.2.1.min.js"></script>
                    <div class="row">
                        <div class="col-md-12">
                          <div class="card-body">
                               <form id="edit_doctor">
                               <div class="form-group">
                                    <label>Menu <span class="text-danger">*</span></label>
                                    <!-- <input class="form-control" type="text" name="dr_name" id="dr_name" /> -->
                                    <select class="form-control" aria-label="Default select example" id="menu" name="menu">
                                        <option selected>Open this select menu</option>
                                        <?php 
                                        $fetch = $obj->fetch('SELECT * from menu');
                                        foreach($fetch as $va)
                                        {?>
                                            <option value="<?php echo $va['id'] ?>" <?php echo ($va['id']==$val['menu'])?'selected':''; ?>><?php echo $va['menu']?></option>
                                        
                                        <?php
                                        }?>
                                        <!-- <option value="1">One</option>
                                        <option value="2">Two</option> -->
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>Submenu <span class="text-danger">*</span></label>
                                    <select class="form-control" aria-label="Default select example" id="submenu" name="submenu">
                                    <?php 
                                    $mid=$val['menu'];
                                        $fet= $obj->fetch("SELECT * From submenu WHERE menu='$mid'");
                                        foreach($fet as $vaf)
                                        {?>
                                            <option value="<?php echo $vaf['id'] ?>" <?php echo ($vaf['id']==$val['submenu'])?'selected':''; ?>><?php echo $vaf['submenu']?></option>
                                        
                                        <?php
                                        }?>
                                    </select>

                                </div>
                                <div class="form-group">
                                    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
                                    <label>Category <span class="text-danger">*</span></label>
                                    <!-- <select class="form-control" aria-label="Default select example">
                                        <option selected>Open this select category</option>
                                        <option value="1">One</option>
                                        <option value="2">Two</option>
                                    </select> -->

                                    <select class="form-control cat" aria-label="Default select example" multiple id="sel" name="category[]" style="width: 100%;">
                                    <?php 
                                        $fetc= $obj->fetch('SELECT * FROM category');
                                        foreach($fetc as $v)
                                        {
                                            $unsel_cat=unserialize($val['category']);
                                                  $cat_cnt=count($unsel_cat);
                                                
                                                 for($i=0;$i<$cat_cnt;$i++)
                                                 {
                                            ?>
                                            <option value="<?php echo $v['id']; ?>" <?php echo ($v['id']==$unsel_cat[$i])?'selected':''; ?>>
                                            <?php echo $v['category']?></option>
                                            <?php } ?>
                                        
                                        <?php
                                        }?>
                                    </select>
                                    <script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
                                    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
                                    <script>
                                        $('#sel').select2();
                                    </script>

                                </div>                  
                                <div class="form-group">
                                    <label>Product Name <span class="text-danger">*</span></label>
                                    <input id="banner<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['product_name']; ?>" name="product_name" type="text" />
                                    <span class="dr_name"></span>
                                </div>
                                
                                <div class="form-group">
                                    <label>Price <span class="text-danger">*</span></label>
                                    <input id="qly<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['price']; ?>" type="text" name="price" />
                                    <span class="qly"></span>
                                </div>

                                <div class="form-group">
                                    <label>Offer(%) <span class="text-danger">*</span></label>
                                    <input id="qly<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['offer']; ?>" type="text" name="offer" />
                                    <span class="qly"></span>
                                </div>
                                <div class="form-group">
                                    <label>Qty <span class="text-danger">*</span></label>
                                    <input id="qly<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['qty']; ?>" type="text" name="qty" />
                                    <span class="qly"></span>
                                </div>
                                 <div class="form-group">
                                    <label>Description <span class="text-danger">*</span></label>
                                    <textarea class="form-control summernote" name="description"><?php echo base64_decode($val['description']); ?></textarea>
                                    <span class="des" style="color: red;"></span>
                                </div>
                                <?php
                                 $unser=unserialize($val['image']);
                                //print_r($unser);
                                $cn=count($unser);
                                $to_img=0;
                                    for($i=0;$i<$cn;$i++)
                                    {
                                          if( $unser[$i])
                                          {
                                              $to_img++;
                                    ?>
                                <div class="form-group">
                                    
                                    <label>Image <span class="text-danger">*</span></label><br />
                                    <a data-fancybox="image" id="imga" data-caption="<?php echo $unser[$i] ?>" data-src="<?php echo $unser[$i] ?>" style="cursor:pointer;">
                                    <img class="thumbnail img<?php echo $i; ?>" id="img" src="<?php echo $unser[$i]; ?>" style="width: 100px;" />
                                    </a>
                                    <input id="image<?php echo $val['id']; ?>" class="form-control file<?php echo $i; ?>" type="file" style="margin-top: 10px;" name="img[]" />
                                    <input type="hidden" name="old_image[]" value="<?php echo $unser[$i]; ?>" id="old_image" />
                                    
                                </div>
                                <script type="text/javascript">
                                    $(".file<?php echo $i; ?>").on("change", function (e) {
                                        e.preventDefault();
                                        var src = URL.createObjectURL(event.target.files[0]);
                                        //alert(src);
                                        $(".img<?php echo $i; ?>").prop("src", src);
                                    });
                                    </script>
                                <?php }} ?>
                                <div class="add_img"></div>
                                
                                <div class="submit-section">
                                    <span  class="btn btn-primary" id="add_input">+</span>
                                    <input type="hidden" class="total_img" name="total_img" value="<?php echo $to_img; ?>">
                                    <input type="hidden" name="doctor_id" value="<?php echo $val['id']; ?>" id="doctor_id" />
                                    <button name="submit" id="edit_banner_btn<?php echo $val['id']; ?>" class="btn btn-primary edit_banner_btn" >Submit</button>
                                </div>
                                <div class="preview1" style="text-align: center;"></div>
                            </form>
                          </div>
                        </div>
                    </div>
                </div>
                <!-- /Page Content -->

                

 
            </div>
        </div>
        <?php
//footer link
include("footer_link.php");

//footer
include("footer.php");

?>
    </body>
</html>
<script type="text/javascript">
    $(document).ready(function (e) {
        // Submit form data via Ajax
        $("#edit_doctor").on("submit", function (e) {
            e.preventDefault();
            $.ajax({
                type: "POST",
                url: "edit_product.php",
                data: new FormData(this),
                contentType: false,
                cache: false,
                processData: false,
                // beforeSend: function(){
                //     $('.submitBtn').attr("disabled","disabled");
                //     $('#fupForm').css("opacity",".5");
                // },
                success: function (data) {
                    //console.log(response);

                    // var mydata = JSON.parse(response);
                    //alert(data);
                    // console.log(response.message);
                    $(".preview1").html(data);
                    // setTimeout(function () {
                    setTimeout(location.reload.bind(location), 1500);
                                       
                    // if(response.status == 1){
                    //     $('#fupForm')[0].reset();
                    //     $('.statusMsg').html('<p class="alert alert-success">'+response.message+'</p>');
                    // }else{
                    //     $('.statusMsg').html('<p class="alert alert-danger">'+response.message+'</p>');
                    // }
                    // $('#fupForm').css("opacity","");
                    // $(".submitBtn").removeAttr("disabled");
                },
            });
        });
    });
</script>

<script type="text/javascript">
    $(".file").on("change", function (e) {
        e.preventDefault();
        var src = URL.createObjectURL(event.target.files[0]);
        //alert(src);
        $(".img").prop("src", src);
    });
</script>

  <script>
  $(document).ready(function(){
      var count = $('.total_img').val();
      $("#add_input").on("click", function(){
            count++;
           $('.total_img').val(count);
           var html_code = '';
            html_code +='<div class="form-group" id="ro_input'+count+'">';
            html_code +='<label>Image</label>';
            html_code +='<div style="width:100%;display:flex;">';
            html_code +='<input class="form-control" type="file" name="img[]" data-srno="'+count+'" id="image'+count+'" style="width:90%;">';
            html_code +='<span class="btn btn-danger remove_row" style="width:10%;" id="'+count+'"><i class="fa fa-remove" style="padding-top:8px;"></i></span>';
            html_code +='</div>';
            html_code +='</div>';
            $('.add_img').append(html_code);
      });
      $(document).on('click', '.remove_row', function(){
          var row_id = $(this).attr("id");
           $('#ro_input'+row_id).remove();
          count--;
          $('.total_img').val(count);
      });
  });
  </script>
  <script>
    $('#menu').on("change",function(){
        var menu = $('#menu').val();
        $.ajax({
            url: "fetch-submenu.php",
            type: "POST",
            data: {menu:menu},
            success: function(data)
            {
                $('#submenu').html(data);
            }
        })
    })
</script>
<script>
$(".cat option").each(function() {
  $(this).siblings('[value="'+ this.value +'"]').remove();
});
</script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.umd.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
 <script>
       $('.summernote').summernote();

 </script>
  

MMCT - 2023