Advertisement
Guest User

Untitled

a guest
Dec 5th, 2018
413
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.99 KB | None
  1. <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  2. <!-- Content Header (Page header) -->
  3. </style>
  4. <section class="content-header">
  5. <h1>
  6. Buat Pesanan
  7. </h1>
  8. <ol class="breadcrumb">
  9. <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
  10. <li><a href="#">Halaman Pesanan</a></li>
  11. <li><a href="#">Buat Pesanan</a></li>
  12. </ol>
  13. </section>
  14.  
  15. <!-- Main content -->
  16. <section class="content">
  17.  
  18. <!-- Default box -->
  19. <div class="box">
  20. <div class="box-header with-border">
  21. <h3 class="box-title"></h3>
  22. <div class="box-tools pull-right">
  23. <button class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"><i class="fa fa-minus"></i></button>
  24. </div>
  25. </div>
  26. <div class="box-body">
  27. <div class="box-body table-responsive no-padding">
  28. <form method="POST" action="<?php echo base_url().'tambah_pesanan/simpan'?>">
  29. <table class="table table-hover">
  30. <tr>
  31. <td>Nama Agen</td>
  32. <td>:</td>
  33. <td><input type="text" id="autocomplete" class="auto" name="namaagen" autocomplete="off" placeholder="Nama Lengkap"></td>
  34. <td>Nama Penerima</td>
  35. <td>:</td>
  36. <td><input type="text" id="napem" name="napem" placeholder="Nama Lengkap" readonly><input type="hidden" id="idpem" name="idpem"></td>
  37. </tr>
  38. <tr>
  39. <td>Pengiriman</td>
  40. <td>:</td>
  41. <td><input type="radio" class="a" name="a" value="agen" checked> Agen</input>&nbsp;&nbsp;&nbsp;<input type="radio" class="a" value="dropship" name="a"> Dropship</input></td>
  42. <td>Alamat</td>
  43. <td>:</td>
  44. <td><input type="text" id="alamatpem" name="alamatpem" placeholder="Alamat" readonly></td>
  45. </tr>
  46. <tr>
  47. <td></td>
  48. <td></td>
  49. <td></td>
  50. <td>Provinsi</td>
  51. <td>:</td>
  52. <td><select id="provpem" name="provinsi" disabled>
  53. <option>-- Provinsi --</option>
  54. <?php
  55. foreach($raja->rajaongkir->results as $mydata)
  56. {
  57. echo "<option value=".$mydata->province_id.">".$mydata->province."</option>";
  58. }?>
  59. </select></td>
  60. </tr>
  61. <tr>
  62. <td></td>
  63. <td></td>
  64. <td></td>
  65. <td>Kota</td>
  66. <td>:</td>
  67. <td><select id="kotapem" name="kota" disabled>
  68. <option>-- Kota --</option>
  69. </select></td>
  70. </tr>
  71. <tr>
  72. <td></td>
  73. <td></td>
  74. <td></td>
  75. <td>Kontak</td>
  76. <td>:</td>
  77. <td><input type="text" id="konpem" name="konpem" placeholder="Kontak" readonly></td>
  78. </tr>
  79. </table>
  80. <hr>
  81. <h3><i>Orders</i></h3>
  82. <table class="table table-hover order-list">
  83. <tr>
  84. <th>Item</th>
  85. <th>Harga</th>
  86. <th>Qty</th>
  87. <th>Diskon (%)</th>
  88. <th>Total</th>
  89. <th></th>
  90. </tr>
  91. <tr>
  92. <td><input type="text" style="width: 200px;" autocomplete="off" id="item0" name="item[0]" placeholder="Item"></td>
  93. <td><input type="text" style="width: 100px;" id="harga0" name="harga[0]" placeholder="Harga"> </td>
  94. <td><input type="text" style="width: 50px;" id="qty0" name="qty[0]" placeholder="Qty" onkeyup="findTotal(); findJumlah()"> </td>
  95. <td><input type="text" style="width: 100px;" id="diskon0" name="diskon[0]" placeholder="Diskon"> </td>
  96. <td><input type="text" id="total0" name="total[0]" placeholder="Total"></td>
  97. <td><input type="button" style="width: 50px;" class="btn btn-success" id="addrow" value="+"></input></td>
  98. </tr>
  99. <tr class="isi">
  100. </tr>
  101. <tr class="ongkir">
  102. <td><select style="width: 200px;" name="kurir"><option>-- Pilih Kurir --</option><option value="jne">JNE</option><option value="tiki">TIKI</option><option value="pos">POS INDONESIA</option></select></td>
  103. <td></td>
  104. <td></td>
  105. <td></td>
  106. <td><input type="text" id="totalongkir" name="totalongkir" placeholder="Total"></td>
  107. <td><input type="button" style="width: 50px;" class="ibtnDel btn btn-md btn-danger" value="-"></td>
  108. </tr>
  109. </table>
  110. <table class="table table-hover" border="0">
  111. <tr width="100%">
  112. <td align="right" width="85%"><h4>Jumlah : Rp. <input id="totalsemua" name="totalsemua" style="width: 180px;" readonly></input></h4></td>
  113. <td align="left" width="15%"><h4></h4></td>
  114. </tr>
  115. <tr>
  116. <td align="right"><h3 class="box-title"><input type="submit" class="btn btn-success" value=" + Buat Pesanan"></input></h3></td>
  117. <td><h3 class="box-title"> <a href="<?php echo site_url('Pesanan') ?>"><button type="button" class="btn btn-primary"><i class="fa fa-reply"></i> Kembali</button></a></h3></td>
  118. </tr>
  119. </table>
  120. </form>
  121. </div>
  122. </div><!-- /.box-body -->
  123. <div class="box-footer">
  124. </div><!-- /.box-footer-->
  125. </div><!-- /.box -->
  126. </section>
  127.  
  128. <!-- AutoComplete -->
  129. <script type="text/javascript">
  130.  
  131. $(document).ready(function () {
  132. var counter = 1;
  133.  
  134. $("#addrow").on("click", function () {
  135. var newRow = $("<tr>").data("counter",counter);
  136. var cols = "";
  137. cols += '<td><input type="text" style="width: 200px;" id="item' + counter + '" name="item[' + counter + ']" autocomplete="off" placeholder="Item"></td>';
  138. cols += '<td><input type="text" style="width: 100px;" id="harga' + counter + '" name="harga[' + counter + ']" placeholder="Harga"> </td>';
  139. cols += '<td><input type="text" style="width: 50px;" id="qty' + counter + '" name="qty[' + counter + ']" placeholder="Qty" onkeyup="findTotal(); findJumlah()"> </td>';
  140. cols += '<td><input type="text" style="width: 100px;" id="diskon' + counter + '" name="diskon[' + counter + ']" placeholder="Diskon"> </td>';
  141. cols += '<td><input type="text" id="total' + counter + '" name="total[' + counter + ']" placeholder="Total"></td>';
  142. cols += '<td><input type="button" style="width: 50px;" class="ibtnDel btn btn-md btn-danger" value="-" onclick="findJumlah()"></td>';
  143. newRow.append(cols);
  144. newRow.insertBefore("tr.isi");
  145. $("#item"+counter).autocomplete({
  146. source: function(request, response) {
  147. $.ajax({
  148. url: "<?php echo site_url('Produk/data'); ?>",
  149. data: { id_barang: $("#item"+counter).val()},
  150. dataType: "json",
  151. type: "POST",
  152. success: function(data){
  153. console.log(data);
  154. response(data);
  155. }
  156. });
  157. },
  158. });
  159. $("#item"+counter).change(function(){
  160. var nmbarang = $(this).closest("tr").data("counter");
  161. $.ajax({
  162. url: '<?php echo site_url('Produk/tampil_where'); ?>',
  163. type: 'POST',
  164. dataType: 'json',
  165. data: {
  166. 'nmbarang': nmbarang
  167. },
  168. success: function (barang) {
  169. console.log(barang);
  170. $("#harga"+counter).val(barang[0]['harga_barang']);
  171. }
  172. });
  173. });
  174. counter++;
  175. });
  176.  
  177. $("table.order-list").on("click", ".ibtnDel", function (event) {
  178. $(this).closest("tr").remove();
  179. // counter -= 1;
  180. });
  181.  
  182.  
  183. $(function () {
  184. $( "#item0" ).autocomplete({
  185. source: function(request, response) {
  186. $.ajax({
  187. url: "<?php echo site_url('Produk/data'); ?>",
  188. data: { id_barang: $("#item0").val()},
  189. dataType: "json",
  190. type: "POST",
  191. success: function(data){
  192. response(data);
  193. }
  194. });
  195. },
  196. });
  197. });
  198.  
  199. $(function() {
  200. $("#item0").change(function(){
  201. var nmbarang = $("#item0").val();
  202. $.ajax({
  203. url: '<?php echo site_url('Produk/tampil_where'); ?>',
  204. type: 'POST',
  205. dataType: 'json',
  206. data: {
  207. 'nmbarang': nmbarang
  208. },
  209. success: function (barang) {
  210. console.log(barang);
  211. $("#harga0").val(barang[0]['harga_barang']);
  212. }
  213. });
  214. });
  215. });
  216.  
  217. $(function () {
  218. $( "#autocomplete" ).autocomplete({
  219. source: function(request, response) {
  220. $.ajax({
  221. url: "<?php echo site_url('Pelanggan/data'); ?>",
  222. data: { kode: $("#autocomplete").val()},
  223. dataType: "json",
  224. type: "POST",
  225. success: function(data){
  226. response(data);
  227. }
  228. });
  229. },
  230. });
  231. });
  232.  
  233. $(function() {
  234. $("#autocomplete").change(function(){
  235. var namaagen = $("#autocomplete").val();
  236. $.ajax({
  237. url: '<?php echo site_url('Pelanggan/tampil_where'); ?>',
  238. type: 'POST',
  239. dataType: 'json',
  240. data: {
  241. 'namaagen': namaagen
  242. },
  243. success: function (agen) {
  244. $("#napem").val(agen[0]['nama_pelanggan']);
  245. $("#idpem").val(agen[0]['id_pelanggan']);
  246. $("#alamatpem").val(agen[0]['alamat_jalan']);
  247. $("#konpem").val(agen[0]['kontak_pelanggan']);
  248. }
  249. });
  250. });
  251. });
  252.  
  253. $('#provpem').change(function(){
  254. //Mengambil value dari option select provinsi kemudian parameternya dikirim menggunakan ajax
  255. var prov = $('#provpem').val();
  256. $.ajax({
  257. type : 'GET',
  258. url : '<?php echo base_url().'Pelanggan/rajacity'?>',
  259. data : 'prov_id=' + prov,
  260. success: function (data) {
  261. //jika data berhasil didapatkan, tampilkan ke dalam option select kabupaten
  262. $("#kotapem").html(data);
  263. }
  264. });
  265. });
  266. });
  267. </script>
  268.  
  269. <!-- customJS -->
  270. <script src="<?php echo base_url('assets/js/js-tambahpesanan/costum.js') ?>"></script>
  271. <?php
  272. $this->load->view('template/js');
  273. $this->load->view('template/foot');
  274. ?>
Advertisement
RAW Paste Data Copied
Advertisement