Viewing file: service_one.php (13.35 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? include 'index_IncludeAdmin.php'; $_SESSION['page'] = 'service.php'; if (isset($_GET[service_id])){ $_SESSION[service_id] = $_GET[service_id]; } $service_id = $_SESSION[service_id] ; if ($_POST['service_pictureAdd']) { if(isset($_FILES['service_picture_photo']['name'])&&$_FILES['service_picture_photo']['name']!=''){ $Count = count($_FILES['service_picture_photo']['name']); for ($i=0; $i < $Count; $i++) { $service_picture_photo = rand().$_FILES["service_picture_photo"]["name"][$i]; if(move_uploaded_file($_FILES["service_picture_photo"]["tmp_name"][$i],"../Files/service_picture_photo/".$service_picture_photo)){ $service_picture_Add = "INSERT INTO `service_picture` (`service_id`,`service_picture_photo`) VALUES ('$service_id','$service_picture_photo')"; $service_picture_Reult = mysqli_query($con,$service_picture_Add); if (!$service_picture_Reult) { echo"<script>alert('Error service_picture'); window.history.back(); </script>"; } } else{ echo"<script>alert('Error move_uploaded_file'); window.history.back(); </script>"; } } echo"<script> window.location='service_one.php?INSERT'; </script>"; } } if ($_GET['service_pictureDel']) { $service_picture_id = $_GET[service_picture_id]; $service_picture_SL = " SELECT * FROM service_picture WHERE service_picture_id = '$service_picture_id'"; $service_picture_QR = mysqli_query($con,$service_picture_SL); $service_picture = mysqli_fetch_array($service_picture_QR); @unlink("../Files/service_picture_photo/".$service_picture['service_picture_photo']); $service_picture_Del ="DELETE FROM `service_picture` WHERE service_picture_id = '$service_picture_id' "; $service_picture_Qurey = mysqli_query($con,$service_picture_Del); if($service_picture_Qurey) { echo"<script> window.location='service_one.php?DELETE'; </script>"; } else{ echo"<script>alert('เกิดข้อผิดพลาด'); window.history.back(); </script>"; } } if ($_POST['serviceUpdate']) { if($_FILES['service_photo']['name']!=''){ @unlink("../Files/service_photo/".$service['service_photo']); $file = rand().$_FILES["service_photo"]["name"]; $upload = move_uploaded_file($_FILES["service_photo"]["tmp_name"],"../Files/service_photo/".$file); $service_photo_Update = "UPDATE `service` SET `service_photo` = '$file' WHERE `service_id` = '$service_id'"; $service_photo_Reult = mysqli_query($con,$service_photo_Update); if (!$service_photo_Reult) { echo"<script>alert('เกิดข้อผิดพลาด'); window.history.back(); </script>"; } if ($service_photo_Reult) { echo"<script> window.location='service_one.php?UPDATE'; </script>"; } } } $service_SL = " SELECT * FROM service WHERE service_id = '$service_id'"; $service_QR = mysqli_query($con,$service_SL); $service = mysqli_fetch_array($service_QR); ?> <!DOCTYPE html> <html> <head> <? include 'index_Head.php'; ?> </head> <body> <? include 'index_Navbar.php'; ?> <div class="container-fluid"> <div class="row"> <div class="col-md-2" id="main-left"> <div class="row"> <div class="col-md-12"> <? include 'index_AdminMenu.php'; ?> </div> </div> </div> <div class="col-md-10"> <div class="row"> <div class="col-md-12"> <h3> บริการ : <span class="text-primary bold"> <?php echo $service[service_name]; ?> </span> </h3> <hr> </div> </div> <? include 'index_Alerts.php'; ?> <div class="row"> <div class="col-md-12 br-margin2"> <a href="service.php" class="btn btn-primary"><span class="glyphicon glyphicon-step-backward"></span> กลับ </a> <a href="service_update.php?service_id=<?php echo $service[service_id]; ?>" class="btn btn-info"><span class="glyphicon glyphicon-wrench"></span> แก้ไข</a> <a href="service_del.php?service_id=<?php echo $service[service_id]; ?>" onclick="return confirm(' ยืนยันการลบข้อมูล ? ')" class="btn btn-danger"> <span class="glyphicon glyphicon-remove-sign"></span> ลบ </a> </div> <div class="col-md-8"> <div class="panel panel-default"> <div class="panel-heading"> รายละเอียดบริการ : <span class="text-primary bold"> <?php echo $service[service_name]; ?> </span> </div> <div class="panel-body"> <div class="row br-margin2"> <div class="col-md-12"> <form class="form-horizontal"> <div class="form-group"> <label class="control-label col-md-3" > ชื่อ บริการ </label> <label class="control-label col-md-9 text-left"> <? echo $service[service_name]; ?> </label> </div> <div class="form-group"> <label class="control-label col-md-3" >รายละเอียดเบื้องต้น</label> <label class="control-label col-md-9 text-left"> <? echo $service[service_detail]; ?> </label> </div> <div class="form-group"> <label class="control-label col-md-3" >ลงข้อมูลเมื่อ</label> <label class="control-label col-md-9 text-left"> <? echo displaydate($service[service_date]); ?> </label> </div> </form> </div> </div> <!-- row --> </div> <!-- panel body --> </div> <!-- panel --> <div class="panel panel-default"> <div class="panel-heading"> เนื้อหา </div> <div class="panel-body"> <?php echo $service[service_review]; ?> </div> <div class="panel-footer"> แก้ไขล่าสุด : <?php echo $service[service_datetime]; ?> </div> </div> </div> <!-- 12 --> <div class="col-md-4"> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-md-4"> จัดการรูปภาพ </div> <div class="col-md-8 text-right" style="margin: -5px;"> <button type="button" class="btn btn-sm btn-info " data-toggle="modal" data-target="#serviceUpdate"> <span class="glyphicon glyphicon-picture"></span> แก้ไขรูปภาพหลัก </button> <button type="button" class="btn btn-sm btn-success " data-toggle="modal" data-target="#service_pictureAdd"> <span class="glyphicon glyphicon-picture"></span> เพิ่มรูปภาพ </button> </div> </div> </div> <div class="panel-body"> <div class="row"> <div class="col-md-12"> <p class="text-muted"> รูปภาพหลักของ บริการ </p> </div> <div class="col-md-12 br-margin2"> <img class="full" style="cursor: zoom-in;" id="myImgmain<?php echo $service[service_id]; ?>" src="../Files/service_photo/<?php echo $service[service_photo]; ?>" /> <div id="myModal" class="w3-modal"> <span class="zoom-close w3-close">×</span> <img class="w3-modal-content w3-close" id="img01"> </div> <script> var w3modal = document.getElementById("myModal"); var img = document.getElementById("myImgmain<?php echo $service[service_id]; ?>"); var modalImg = document.getElementById("img01"); img.onclick = function(){ w3modal.style.display = "block"; modalImg.src = this.src; } var span = document.getElementsByClassName("w3-close")[0]; span.onclick = function() { w3modal.style.display = "none"; } window.onclick = function(event) { if (event.target == w3modal) { w3modal.style.display = "none"; } } </script> </div> </div> <div class="row"> <? $service_picture_SL = " SELECT * FROM service_picture WHERE service_id = '$service[service_id]'"; $service_picture_QR = mysqli_query($con,$service_picture_SL); $service_picture_Row = mysqli_num_rows($service_picture_QR); if ($service_picture_Row == '0') { ?> <div class="col-md-12"> <p class="text-muted"> ยังไม่มีรูปภาพเพิ่มเติม </p> </div> <? } else{ ?> <div class="col-md-12"> <p class="text-muted"> รูปภาพเพิ่มเติมของ บริการ </p> </div> <? } while ($service_picture = mysqli_fetch_array($service_picture_QR)) { ?> <div class="col-md-6"> <div class="thumbnail"> <div class="img80"> <img style="cursor: zoom-in;" id="myImg<?php echo $service_picture[service_picture_id]; ?>" src="../Files/service_picture_photo/<?php echo $service_picture[service_picture_photo]; ?>" /> <div id="myModal" class="w3-modal"> <span class="zoom-close w3-close">×</span> <img class="w3-modal-content w3-close" id="img01"> </div> <script> var w3modal = document.getElementById("myModal"); var img = document.getElementById("myImg<?php echo $service_picture[service_picture_id]; ?>"); var modalImg = document.getElementById("img01"); img.onclick = function(){ w3modal.style.display = "block"; modalImg.src = this.src; } var span = document.getElementsByClassName("w3-close")[0]; span.onclick = function() { w3modal.style.display = "none"; } window.onclick = function(event) { if (event.target == w3modal) { w3modal.style.display = "none"; } } </script> </div> <div class="caption"> <a href="service_one.php?service_picture_id=<?php echo $service_picture[service_picture_id]; ?>&service_pictureDel=x" onclick="return confirm('ยืนยันการลบข้อมูล ? ')" ><span class="glyphicon glyphicon-remove-sign"></span> ลบรูปนี้</a> </div> </div> </div> <? } ?> </div> </div> </div> </div> <!-- 12 --> </div> <!-- row --> </div> <!-- 10 --> </div> <!-- row --> </div> <!-- container --> <div id="service_pictureAdd" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <form class="form" enctype="multipart/form-data" method="post"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="exampleModalLabel">เพิ่มรูปภาพเพิ่มเติม</h4> </div> <div class="modal-body"> <div class="form-group"> <label for="recipient-name" class="control-label">เลือกรูปภาพ <span class="text-muted normal">เป็นรูปภาพที่จะแสดงต่อจาก รูปหลักของ บริการ</span></label> <input type="file" required class="form-control" multiple="multiple" name="service_picture_photo[]"> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-success"> <span class="glyphicon glyphicon-plus-sign"></span> ยืนยันการเพิ่ม </button> <input type="hidden" name="service_pictureAdd" value="x"> <button type="button" class="btn btn-default" data-dismiss="modal">ยกเลิก</button> </div> </form> </div> </div> </div> <div id="serviceUpdate" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <form class="form" enctype="multipart/form-data" method="post"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="exampleModalLabel">แก้ไขรูปภาพหลักของ บริการ</h4> </div> <div class="modal-body"> <div class="form-group"> <label for="recipient-name" class="control-label">เลือกรูปภาพ <span class="text-muted normal">เป็นรูปภาพที่จะนำมาแทนรูปเดิม</span></label> <input type="file" required class="form-control" multiple="multiple" name="service_photo"> </div> </div> <div class="modal-footer"> <button onclick="return confirm('ยืนยันการแก้ไข ? ')" type="submit" class="btn btn-success"> <span class="glyphicon glyphicon-floppy-disk"></span> บันทึกการแก้ไข </button> <input type="hidden" name="serviceUpdate" value="x"> <button type="button" class="btn btn-default" data-dismiss="modal">ยกเลิก</button> </div> </form> </div> </div> </div> </body> </html>
|