<?php include("header.php"); $id = ""; $product = ""; if(isset($_GET['id'])) { $id = $_GET['id']; $query = "SELECT * from product where id='$id'"; $product =db::getRecord($query); } ?> <section id="breadcrumb-alignment"> <div class="row"> <div class="col-sm-12"> <div class="card"> <div class="card-body"> <div class="d-flex justify-content-between breadcrumb-wrapper"> <nav aria-label="breadcrumb "> <ol class="breadcrumb mt-2"> <li class="breadcrumb-item"><a href="javascript:void(0)"><i class='bx bx-home-alt mx-1'></i>Dashboard</a></li> <li class="breadcrumb-item"><a href="product.php">Products</a></li> <li class="breadcrumb-item"><a href="javascript:void(0)">Edit Sizes</a></li> </ol> </nav> </div> </div> </div> </div> </div> </section> <!-- Breadcrumb Alignment Ends --> <h2 class="mb-0 text-center h1 text-primary uppercase">Edit Sizes</h2> <hr> <div class="row justify-content-center pb-5 mb-5"> <?php if($product!=NULL) { ?> <div class="col-12 col-lg-10 col-xl-10"> <div class="card p-3"> <div> <?php $product_id=$product['id']; $query = "SELECT * from sizes where product_id='$product_id'"; $amenities =db::getRecords($query); $j=0; if($amenities!=NULL) { foreach($amenities as $amenitie) { $j++; ?> <form action="../ajax/update_size.php" method="post" enctype="multipart/form-data"> <div id="edit_custom<?php echo $j; ?>" class="form-group row align-items-end"> <div class="col-md-8"> <label class="h4 my-1 d-block">Old Image <?php echo $j; ?></label> <img class="img-fluid w-100" src="<?php echo "../product/images/".$amenitie['image_name']; ?>" alt="slide" style="height:200px; width:200px !important" /> </div> <div class="col-md-5"> <label class="h4 my-1 d-block">Image <?php echo $j; ?></label> <input type="file" class="form-control " name="filenew" id="imgval<?php echo $amenitie['id']; ?>" > </div> <div class="col-md-5"> <label class="h4 my-1 d-block">Title <?php echo $j; ?></label> <input type="text" class="form-control " name="title" required value="<?php echo $amenitie['title']; ?>"> </div> <div class="col-md-2"> <button type="submit" class="btn btn-success float-right bg-darken-2 bg-success" onclick="ncheckfile('<?php echo $amenitie['id']; ?>')">Update</button> </div> <div class="col-md-5"> <label class="h4 my-1 d-block">Size <?php echo $j; ?></label> <input type="text" class="form-control " name="size" required value="<?php echo $amenitie['size']; ?>"> </div> <div class="col-md-5"> <label class="h4 my-1 d-block">Price <?php echo $j; ?></label> <input type="text" class="form-control " name="price" required value="<?php echo $amenitie['price']; ?>"> </div> <div class="col-md-10"> <label class="h4">Quantity(Pcs) <?php echo $j; ?></label> <input type="number" name="quantity" class="form-control" required value="<?php echo $amenitie['quantity']; ?>" /> </div> <input type="text" id="checkfile<?php echo $amenitie['id']; ?>" value="0" name="check_file" hidden> <input type="text" id="p_id" value="<?php echo $product['id']; ?>" name="p_id" hidden> <input type="text" id="edit_id" value="<?php echo $amenitie['id']; ?>" name="edit_id" hidden> <div class="col-md-2"> <button type="button" class="btn btn-danger float-right bg-darken-2 bg-danger" onclick="delete_field('<?php echo $amenitie['id']; ?>')"> Delete</button> </div> </div> </form> <?php } } ?> </div> <hr /> <form action="../ajax/add_size.php" method="post" enctype="multipart/form-data"> <div id="edit_fields"> </div> <input type="text" id="edit_id" value="<?php echo $product['id']; ?>" name="p_id" hidden> <div class="form-group mt-3"> <button type="button" class="btn btn-success float-left btn-lg mr-2" onclick="edit_add_field(<?php echo $product['id']; ?>)">Add</button> <button type="submit" id="add_new_btn" style="display:none" class="btn btn-success float-right btn-lg " name="add_new_sizes">Add New Sizes </button> </div> </form> </div> </div> </div> <?php } else{ echo "Data is not Found!!"; } ?> <?php include("footer.php"); ?> <script> var j = '<?php echo $j; ?>'; function edit_add_field() { $('#add_new_btn').show(); j++; $("#edit_fields").append('<div id="edit_custom' + j + '" class="form-group row align-items-end"><div class="col-md-5"> <label class="h4 my-1 d-block">Upload Image ' + j + '</label> <input type="file" class="form-control " name="files[]" required > </div><div class="col-md-5"> <label class="h4 my-1 d-block">Title ' + j + '</label> <input type="text" class="form-control " name="title[]" required > </div><div class="col-md-5"> <label class="h4 my-1 d-block">Size ' + j + '</label> <input type="text" class="form-control " name="edit_details[]" required > </div><div class="col-md-5"> <label class="h4 my-1 d-block">Price ' + j + '</label> <input type="text" class="form-control " name="sizeprice[]" required > </div><div class="col-md-10"> <label class="h4 my-1 d-block">Quantity(pcs) ' + j + '</label> <input type="text" class="form-control " name="quantity[]" required > </div><div class="col-md-2"> <button type="button" id="remove_btn" class="btn btn-danger float-right bg-darken-2 bg-danger" onclick="edit_remove_field(' + j + ')"><i title="Remove Field" class="bx bx-trash"></i></button> </div></div>'); } function edit_remove_field(j) { $("#edit_custom" + j).remove(); j--; } </script> <script> function delete_field(id) { var id=id; $.ajax({ url: "../ajax/delete_size.php", type: "POST", data: { 'id': id, }, success: function(response) { location.reload(true); }, }); } </script> <script> function ncheckfile(id) { var getimgval = $('#imgval'+id).val(); if(getimgval){ $('#checkfile'+id).val(1); }else{ $('#checkfile'+id).val(0); } } </script>