สอนทำระบบ POS (ระบบขายหน้าร้าน) Ep 18. สร้าง หน้ารายการสินค้า, ฟอร์มข้อมูลสินค้า (จัดการสินค้า Part 2)
สอนทำระบบ POS (ระบบขายหน้าร้าน) Ep 18.
สร้าง หน้ารายการสินค้า, ฟอร์มข้อมูลสินค้า
(จัดการสินค้า Part 2)
ระบบ บริหารจัดการร้านกาแฟ PHP | FD22-Cafe (Coffee AND Bakery)
ระบบบริหารจัดการ รีสอร์ท | Booking Resort System PHP
CART&POS (ระบบจัดการงานขายหน้าร้านและ ออนไลน์ สำหรับร้านค้าขนาดกลาง,SME)
ระบบ POS (Point of Sale) ระบบขายหน้าร้าน ตัวเต็ม
(มีระบบ BarCode และ QR-Code รองรับเครื่องแสกน)
สอนทำระบบ POS (ระบบขายหน้าร้าน) Ep 18. สร้าง หน้ารายการสินค้า, ฟอร์มข้อมูลสินค้า
(จัดการสินค้า Part 2)
Code หน้า list_product.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
<?php $menu = "product" ?> <?php include("header.php"); ?> <?php $query_product = " SELECT p.*,t.t_name, b.b_name FROM tbl_product as p " or die ("Error : ".mysqlierror($query_product)); $rs_product = mysqli_query($condb, $query_product); //echo $query_product; ?> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#blah').attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } </script> <!-- Content Header (Page header) --> <section class="content-header"> <div class="container-fluid"> <h1>Product</h1> </div><!-- /.container-fluid --> </section> <!-- Main content --> <section class="content"> <div class="card card-gray"> <div class="card-header "> <h3 class="card-title">รายการสินค้า</h3> <div align="right"> <button type="button" class="btn btn-light" data-toggle="modal" data-target="#exampleModal"><i class="fa fa-plus"></i> เพิ่มข้อมูล สินค้า</button> </div> </div> <br> <div class="card-body"> <div class="row"> <div class="col-md-12"> <table id="example1" class="table table-bordered table-hover table-striped"> <thead> <tr class="danger"> <th width="5%"><center>No.</center></th> <th width="10%">Img</th> <th width="20%">Name</th> <th width="10%">price</th> <th width="10%">qty</th> <th width="10%">edit</th> <th width="10%">del</th> </tr> </thead> <tbody> <?php foreach ($rs_product as $row_product) { ?> <tr> <td><?php echo @$l+=1; ?></td> <td><img src="../p_img/<?php echo $row_product['p_img']; ?>" width="100%"></td> <td><?php echo $row_product['t_name']; ?></td> <td><?php echo $row_product['p_price']; ?></td> <td><?php echo $row_product['p_qty']; ?></td> <td> <p style="margin-bottom: 10px;"> <a href="product_edit.php?p_id=<?php echo $row_product['p_id']; ?>" class="btn btn-warning"><i class="fas fa-pencil-alt"></i> edit</a> </p> <!-- <a href="level.php?ace=edit&l_id=<?php echo $row_product['l_id'];?>" class="btn btn-warning btn-xs"> edit</a> --> </td> <td><a href="product_db.php?p_id=<?php echo $row_product['p_id']; ?>" class="del-btn btn btn-danger"><i class="fas fas fa-trash"></i> del</a></td> </tr> <?php @$total+=$row_product['p_qty']; } //echo $total; ?> </tbody> </table> <?php if(isset($_GET['d'])){ ?> <div class="flash-data" data-flashdata="<?php echo $_GET['d'];?>"></div> <?php } ?> <script> $('.del-btn').on('click',function(e){ e.preventDefault(); const href = $(this).attr('href') Swal.fire({ imageUrl: '../logo_fordev22_2.png', imageWidth: 250, //imageHeight: 100, title: 'Are you sure to delete?', text: "You won't be able to revert this!", // icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, delete it!' }).then((result) => { if (result.value) { document.location.href = href; } }) }) const flashdata = $('.flash-data').data('flashdata') if(flashdata){ swal.fire({ type : 'success', title : 'Record Deleted', text : 'Record has been deleted', icon: 'success' }) } </script> </div> </div> </div> <div class="card-footer"> </div> </div> </section> <!-- /.content --> <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg" role="document"> <form action="product_db.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="product" value="add"> <div class="modal-content"> <div class="modal-header bg-dark"> <h5 class="modal-title" id="exampleModalLabel">เพิ่มข้อมูล สินค้า</h5> <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <div class="form-group row"> <label for="" class="col-sm-2 col-form-label">ชื่อ </label> <div class="col-sm-10"> <input name="p_name" type="text" required class="form-control" placeholder="member name" minlength="3"/> </div> </div> </span> <div class="form-group row"> <label for="" class="col-sm-2 col-form-label">Detail </label> <div class="col-sm-10"> <textarea name="p_detail" rows="3" class="form-control"></textarea> </div> </div> <div class="form-group row"> <label for="" class="col-sm-2 col-form-label">Price </label> <div class="col-sm-10"> <input name="p_price" type="number" min="0" required class="form-control" placeholder="Price" minlength="3"/> </div> </div> <div class="form-group row"> <label for="" class="col-sm-2 col-form-label">Qty </label> <div class="col-sm-10"> <input name="p_qty" type="number" min="0" required class="form-control" placeholder="Qty" minlength="3"/> </div> </div> <div class="form-group row"> <label for="" class="col-sm-2 col-form-label">img</label> <div class="col-sm-10"> เลือกไฟล์ใหม่<br> <div class="custom-file"> <input type="file" class="custom-file-input" id="p_img" name="p_img" onchange="readURL(this);" > <label class="custom-file-label" for="file">Choose file</label> </div> <br><br> <img id="blah" src="#" alt="your image" width="300" /> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">ปิด</button> <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> ยืนยัน</button> </div> </div> </form> </div> </div> <?php include('footer.php'); ?> <script> $(function () { $(".datatable").DataTable(); // $('#example2').DataTable({ // "paging": true, // "lengthChange": false, // "searching": false, // "ordering": true, // "info": true, // "autoWidth": false, // http://fordev22.com/ // }); }); </script> </body> </html> <!-- http://fordev22.com/ --> |
Code หน้า product_db.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php include('../condb.php'); if (isset($_POST['product']) && $_POST['product']=="add") { } elseif (isset($_POST['product']) && $_POST['product']=="edit") { }elseif (isset($_GET['product']) && $_GET['product']=="del"){ }else{ } ?> |