/application/views/js_init/js_shipment.php
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
- <script>
- //Validasi tanggal shipment planning, tanggal planning harus >= tanggal sekarang
- $("#TanggalKirim").change(function(){
- Sel_date= $(this).val();
- IdCabang= $('#shipTime').val();
- IdTransaksi= $('#IdTransaksi').val();
- url= "<?php echo $this->configlib->site_url(); ?>/customer/shipment/get_arrival";
- data= {'IdCabang': IdCabang, 'IdTransaksi': IdTransaksi, 'tglnow': Sel_date };
- $.ajax({
- type: "POST",
- url: url,
- data: data,
- success: function(data){
- $('#estim_time').val(data);
- }
- });
-
- });
-
- function getAjaxCountry(idNegara)
- {
- $.ajax({
- type: "POST",
- dataType: "html",
- url: "<?php echo $this->configlib->site_url(); ?>/customer/master/getAJAX/region/"+idNegara,
- success: function(msg){
- if(msg == ''){
- $("select#IdRegion").html('<option value="">--Select Region--</option>');
- }else{
- $("select#IdRegion").html(msg);
- }
- $("img#imgLoad").hide();
- getAjaxKota();
- }
- });
- }
-
- function getAjaxKota()
- {
- $("img#imgLoadKota").show();
- var idRegion = $("#IdRegion").val();
- $.ajax({
- type: "POST",
- dataType: "html",
- url: "<?php echo $this->configlib->site_url(); ?>/customer/master/getAJAX/kota/"+idRegion,
- success: function(msg){
- if(msg == ''){
- $("select#IdKota").html('<option value="">--Select City--</option>');
- }else{
- $("select#IdKota").html(msg);
- }
- $("img#imgLoadKota").hide();
- }
- });
- }
- /*
- $("#IdNegara").change(function(){
- $("img#imgLoad").show();
- var idNegara = $(this).val();
- getAjaxCountry(idNegara)
- });
- alert(currentDate+'-'+currentMonth+'-'+currentYear);
- */
-
- var date = new Date();
- var currentMonth = date.getMonth();
- var currentDate = date.getDate();
- var currentYear = date.getFullYear();
- $("#TanggalKirim").datepicker({
- changeMonth: true,
- changeYear: true,
- yearRange: "-0:+1",
- dateFormat: "yy-mm-dd",
- minDate: new Date(currentYear, currentMonth, currentDate),
- });
-
- $("#IdRegion").change(function(){
- getAjaxKota();
- });
-
- $("#chkmakesame").change(function(){ //Jika tanda centang set as default cust address diklik
- if($(this).is(':checked'))
- {
- getAJAXOrderHistory($("#prodType").val(),$("#IdTransaksi").val(),"1");
- $(".usedefault").each(function(){
- $(this).attr("readonly","readonly");
- })
- }else{
- $(".usedefault").each(function(){
- $(this).removeAttr("readonly");
- })
- }
- })
-
- $("#IdTransaksi").change(function(){
- getAJAXOrderHistory($("#prodType").val(),$(this).val())
- })
-
- $("#Kg").change(function(){
- var IdNegara = $("#IdNegara").val();
- var IdRegion = $("#IdRegion").val();
- var IdKota = $("#IdKota").val();
- var weight = $(this).val();
- $.post("<?php echo $this->configlib->site_url(); ?>/customer/shipment/getShippingCost",{"IdNegara":IdNegara,"IdRegion":IdRegion,"IdKota":IdKota,"weight":weight},function(data){
- if(data=='0')
- {
- alert("<?php echo lang("abdi.shipp_date") ?>");
- }else{
- $("#TotalHarga").val(data);
- }
- })
- })
-
- $("a[href='#AddAnother']").click(function(){ //menambahkan transaksi lainnya untuk dilakukan shipment
- if($("#IdTransaksi").val()=="")
- {
- }else{
- $('#jqTableTrans tr').each(function(){
- $("#jqTableDelivered").append("<tr role='row' class='ui-widget-content jqgrow ui-row-ltr'>" +
- $(this).html() + "</td>");
- });
- $("#productsTrans").empty();
- $("#productsTrans").append("<table id='jqTableTrans'></table>");
- var transAllTemp = $("#IdTransAll").val(); //untuk menyimpan semua id transaksi yang diakukan
- if($("#IdTransaksi").val()!="")
- {
- $("#IdTransAll").val(transAllTemp + $("#IdTransaksi").val() + "~");
- }
- }
- })
-
- $("#jqTableDelivered").jqGrid({
- datatype: "xml",
- rowList:[10,20,30],
- sortorder: 'asc',
- viewrecords: true,
- colNames:['<?php echo lang("abdi.product") ?>','<?php echo lang("abdi.product_name") ?>','<?php echo lang("abdi.product_number") ?>'],
- colModel : [
- {name : 'IdProduk',index: 'IdProduk', width : 100, align: 'center',sortable:false},
- {name : 'NamaProduk',index: 'NamaProduk', width : 110, align: 'left'},
- {name : 'NoSerial',index: 'NoSerial', width : 120, align: 'center'}
- ]
- })
-
- function getAJAXOrderHistory(opt,id, sameAddress)
- {
- if(opt=="S")
- {
- return;
- //Ajax for selling transaction
- }
-
- if(opt=="R")
- {
- $.post("<?php echo $this->configlib->site_url(); ?>/customer/shipment/getAjaxHistory/R",{"id":id},function(data){
- //alert(data);
- if(data!="")
- {
- var split = data.split("~");
- if(split[0] == $("#IdKonsumen").val() || $("#custChecker").val()=="") //Untuk memerika apakah transaksi lain yang ditambahkan punya id konsumen yang sama
- {
- $("#custChecker").val(split[0]);
- $("#IdKonsumen").val(split[0]);
- $("#TanggalOrder").val(split[1]);
- $("select#IdNegara").append("<option value='"+split[3]+"' selected='selected'>"+split[4]+"</option>");
- $("select#IdRegion").append("<option value='"+split[5]+"' selected='selected'>"+split[6]+"</option>");
- $("select#IdKota").append("<option value='"+split[7]+"' selected='selected'>"+split[8]+"</option>");
- $("#Alamat").val($.trim(split[9]));
- $("#Source").val($.trim(split[12]));
- $("#shipTime").val($.trim(split[13]));
-
- $("#chkmakesame").attr("checked","checked");
- $(".usedefault").each(function(){
- $(this).attr("readonly","readonly");
- })
- if(sameAddress != "1")
- {
- $("#jqTableTrans").jqGrid({
- datatype: "xml",
- rowList:[10,20,30],
- sortorder: 'asc',
- viewrecords: true,
- colNames:['<?php echo lang("abdi.product") ?>','<?php echo lang("abdi.product_name") ?>','<?php echo lang("abdi.product_number") ?>'],
- colModel : [
- {name : 'IdProduk',index: 'IdProduk', width : 100, align: 'center',sortable:false},
- {name : 'NamaProduk',index: 'NamaProduk', width : 100, align: 'left'},
- {name : 'NoSerial',index: 'NoSerial', width : 100, align: 'center'}
- ],
- url : "<?php echo $this->configlib->site_url(); ?>/customer/shipment/xml_product_shipment/" + id
- })
- }
- }else{
- alert("<?php echo lang("abdi.salah_id") ?>");
- $("#IdTransaksi").val("");
- }
- }else{
- alert("<?php echo lang("abdi.trans_gagal") ?>");
- }
- })
- }
- }
-
- $("a[href='#BrowseProd']").click(function(){
- if($("#prodType").val()=="S")
- {
- //Show the pop up for product selling
- }
- if($("#prodType").val()=="R")
- {
- popup_browse("repair");
- $("#browseDialog").dialog("open");
- }
- if($("#prodType").val()=="")
- {
- alert("<?php echo lang("abdi.type_trans") ?>");
- $("#prodType").focus();
- }
- })
-
- function popup_browse(opt) //Pop up to shown what's belong to browse
- {
- if(opt=="repair")
- {
- theTitle = "Popup - repair";
- theWidth = 800;
- theHeight = 445;
- theUrl = "<?php echo $this->configlib->site_url(); ?>/popup_browse/browse_repair";
- }else{
- theTitle = "Popup - Product";
- theWidth = 700;
- theHeight = 400;
- theUrl = "<?php echo $this->configlib->site_url(); ?>/popup_browse/browse_product/index/product";
- };
-
- $("#browseDialog").dialog({
- title : theTitle,
- width: theWidth,
- height: theHeight,
- modal: true,
- show : "blind",
- hide : "blind",
- buttons: {
- close: function() {
- $(this).empty();
- $(this).dialog("close");
- }
- },
- open : function()
- {
- $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' />"+
- "</span><br />Please Wait ....</center>");
- $(this).load(theUrl);
- }
- });
- }
-
- </script>