PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/application/views/js_init/js_shipment.php

https://bitbucket.org/remobius/crm
PHP | 257 lines | 228 code | 17 blank | 12 comment | 19 complexity | ea29a06da0312a66c7936ffbed307da2 MD5 | raw file
Possible License(s): GPL-2.0, MIT, LGPL-3.0, LGPL-2.1, GPL-3.0
  1. <script>
  2. //Validasi tanggal shipment planning, tanggal planning harus >= tanggal sekarang
  3. $("#TanggalKirim").change(function(){
  4. Sel_date= $(this).val();
  5. IdCabang= $('#shipTime').val();
  6. IdTransaksi= $('#IdTransaksi').val();
  7. url= "<?php echo $this->configlib->site_url(); ?>/customer/shipment/get_arrival";
  8. data= {'IdCabang': IdCabang, 'IdTransaksi': IdTransaksi, 'tglnow': Sel_date };
  9. $.ajax({
  10. type: "POST",
  11. url: url,
  12. data: data,
  13. success: function(data){
  14. $('#estim_time').val(data);
  15. }
  16. });
  17. });
  18. function getAjaxCountry(idNegara)
  19. {
  20. $.ajax({
  21. type: "POST",
  22. dataType: "html",
  23. url: "<?php echo $this->configlib->site_url(); ?>/customer/master/getAJAX/region/"+idNegara,
  24. success: function(msg){
  25. if(msg == ''){
  26. $("select#IdRegion").html('<option value="">--Select Region--</option>');
  27. }else{
  28. $("select#IdRegion").html(msg);
  29. }
  30. $("img#imgLoad").hide();
  31. getAjaxKota();
  32. }
  33. });
  34. }
  35. function getAjaxKota()
  36. {
  37. $("img#imgLoadKota").show();
  38. var idRegion = $("#IdRegion").val();
  39. $.ajax({
  40. type: "POST",
  41. dataType: "html",
  42. url: "<?php echo $this->configlib->site_url(); ?>/customer/master/getAJAX/kota/"+idRegion,
  43. success: function(msg){
  44. if(msg == ''){
  45. $("select#IdKota").html('<option value="">--Select City--</option>');
  46. }else{
  47. $("select#IdKota").html(msg);
  48. }
  49. $("img#imgLoadKota").hide();
  50. }
  51. });
  52. }
  53. /*
  54. $("#IdNegara").change(function(){
  55. $("img#imgLoad").show();
  56. var idNegara = $(this).val();
  57. getAjaxCountry(idNegara)
  58. });
  59. alert(currentDate+'-'+currentMonth+'-'+currentYear);
  60. */
  61. var date = new Date();
  62. var currentMonth = date.getMonth();
  63. var currentDate = date.getDate();
  64. var currentYear = date.getFullYear();
  65. $("#TanggalKirim").datepicker({
  66. changeMonth: true,
  67. changeYear: true,
  68. yearRange: "-0:+1",
  69. dateFormat: "yy-mm-dd",
  70. minDate: new Date(currentYear, currentMonth, currentDate),
  71. });
  72. $("#IdRegion").change(function(){
  73. getAjaxKota();
  74. });
  75. $("#chkmakesame").change(function(){ //Jika tanda centang set as default cust address diklik
  76. if($(this).is(':checked'))
  77. {
  78. getAJAXOrderHistory($("#prodType").val(),$("#IdTransaksi").val(),"1");
  79. $(".usedefault").each(function(){
  80. $(this).attr("readonly","readonly");
  81. })
  82. }else{
  83. $(".usedefault").each(function(){
  84. $(this).removeAttr("readonly");
  85. })
  86. }
  87. })
  88. $("#IdTransaksi").change(function(){
  89. getAJAXOrderHistory($("#prodType").val(),$(this).val())
  90. })
  91. $("#Kg").change(function(){
  92. var IdNegara = $("#IdNegara").val();
  93. var IdRegion = $("#IdRegion").val();
  94. var IdKota = $("#IdKota").val();
  95. var weight = $(this).val();
  96. $.post("<?php echo $this->configlib->site_url(); ?>/customer/shipment/getShippingCost",{"IdNegara":IdNegara,"IdRegion":IdRegion,"IdKota":IdKota,"weight":weight},function(data){
  97. if(data=='0')
  98. {
  99. alert("<?php echo lang("abdi.shipp_date") ?>");
  100. }else{
  101. $("#TotalHarga").val(data);
  102. }
  103. })
  104. })
  105. $("a[href='#AddAnother']").click(function(){ //menambahkan transaksi lainnya untuk dilakukan shipment
  106. if($("#IdTransaksi").val()=="")
  107. {
  108. }else{
  109. $('#jqTableTrans tr').each(function(){
  110. $("#jqTableDelivered").append("<tr role='row' class='ui-widget-content jqgrow ui-row-ltr'>" +
  111. $(this).html() + "</td>");
  112. });
  113. $("#productsTrans").empty();
  114. $("#productsTrans").append("<table id='jqTableTrans'></table>");
  115. var transAllTemp = $("#IdTransAll").val(); //untuk menyimpan semua id transaksi yang diakukan
  116. if($("#IdTransaksi").val()!="")
  117. {
  118. $("#IdTransAll").val(transAllTemp + $("#IdTransaksi").val() + "~");
  119. }
  120. }
  121. })
  122. $("#jqTableDelivered").jqGrid({
  123. datatype: "xml",
  124. rowList:[10,20,30],
  125. sortorder: 'asc',
  126. viewrecords: true,
  127. colNames:['<?php echo lang("abdi.product") ?>','<?php echo lang("abdi.product_name") ?>','<?php echo lang("abdi.product_number") ?>'],
  128. colModel : [
  129. {name : 'IdProduk',index: 'IdProduk', width : 100, align: 'center',sortable:false},
  130. {name : 'NamaProduk',index: 'NamaProduk', width : 110, align: 'left'},
  131. {name : 'NoSerial',index: 'NoSerial', width : 120, align: 'center'}
  132. ]
  133. })
  134. function getAJAXOrderHistory(opt,id, sameAddress)
  135. {
  136. if(opt=="S")
  137. {
  138. return;
  139. //Ajax for selling transaction
  140. }
  141. if(opt=="R")
  142. {
  143. $.post("<?php echo $this->configlib->site_url(); ?>/customer/shipment/getAjaxHistory/R",{"id":id},function(data){
  144. //alert(data);
  145. if(data!="")
  146. {
  147. var split = data.split("~");
  148. if(split[0] == $("#IdKonsumen").val() || $("#custChecker").val()=="") //Untuk memerika apakah transaksi lain yang ditambahkan punya id konsumen yang sama
  149. {
  150. $("#custChecker").val(split[0]);
  151. $("#IdKonsumen").val(split[0]);
  152. $("#TanggalOrder").val(split[1]);
  153. $("select#IdNegara").append("<option value='"+split[3]+"' selected='selected'>"+split[4]+"</option>");
  154. $("select#IdRegion").append("<option value='"+split[5]+"' selected='selected'>"+split[6]+"</option>");
  155. $("select#IdKota").append("<option value='"+split[7]+"' selected='selected'>"+split[8]+"</option>");
  156. $("#Alamat").val($.trim(split[9]));
  157. $("#Source").val($.trim(split[12]));
  158. $("#shipTime").val($.trim(split[13]));
  159. $("#chkmakesame").attr("checked","checked");
  160. $(".usedefault").each(function(){
  161. $(this).attr("readonly","readonly");
  162. })
  163. if(sameAddress != "1")
  164. {
  165. $("#jqTableTrans").jqGrid({
  166. datatype: "xml",
  167. rowList:[10,20,30],
  168. sortorder: 'asc',
  169. viewrecords: true,
  170. colNames:['<?php echo lang("abdi.product") ?>','<?php echo lang("abdi.product_name") ?>','<?php echo lang("abdi.product_number") ?>'],
  171. colModel : [
  172. {name : 'IdProduk',index: 'IdProduk', width : 100, align: 'center',sortable:false},
  173. {name : 'NamaProduk',index: 'NamaProduk', width : 100, align: 'left'},
  174. {name : 'NoSerial',index: 'NoSerial', width : 100, align: 'center'}
  175. ],
  176. url : "<?php echo $this->configlib->site_url(); ?>/customer/shipment/xml_product_shipment/" + id
  177. })
  178. }
  179. }else{
  180. alert("<?php echo lang("abdi.salah_id") ?>");
  181. $("#IdTransaksi").val("");
  182. }
  183. }else{
  184. alert("<?php echo lang("abdi.trans_gagal") ?>");
  185. }
  186. })
  187. }
  188. }
  189. $("a[href='#BrowseProd']").click(function(){
  190. if($("#prodType").val()=="S")
  191. {
  192. //Show the pop up for product selling
  193. }
  194. if($("#prodType").val()=="R")
  195. {
  196. popup_browse("repair");
  197. $("#browseDialog").dialog("open");
  198. }
  199. if($("#prodType").val()=="")
  200. {
  201. alert("<?php echo lang("abdi.type_trans") ?>");
  202. $("#prodType").focus();
  203. }
  204. })
  205. function popup_browse(opt) //Pop up to shown what's belong to browse
  206. {
  207. if(opt=="repair")
  208. {
  209. theTitle = "Popup - repair";
  210. theWidth = 800;
  211. theHeight = 445;
  212. theUrl = "<?php echo $this->configlib->site_url(); ?>/popup_browse/browse_repair";
  213. }else{
  214. theTitle = "Popup - Product";
  215. theWidth = 700;
  216. theHeight = 400;
  217. theUrl = "<?php echo $this->configlib->site_url(); ?>/popup_browse/browse_product/index/product";
  218. };
  219. $("#browseDialog").dialog({
  220. title : theTitle,
  221. width: theWidth,
  222. height: theHeight,
  223. modal: true,
  224. show : "blind",
  225. hide : "blind",
  226. buttons: {
  227. close: function() {
  228. $(this).empty();
  229. $(this).dialog("close");
  230. }
  231. },
  232. open : function()
  233. {
  234. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' />"+
  235. "</span><br />Please Wait ....</center>");
  236. $(this).load(theUrl);
  237. }
  238. });
  239. }
  240. </script>