
<div id="tabbc25_scr_dtl_ex_bc">
	<div id="divtabscr_memo_dtl_ex_bc" >
		<input id="part_no_ex_bc" type="hidden" value="<?php echo $part_no; ?>">
		<input id="id_scrap_memo_dtl" type="hidden" value="<?php echo $id_scrap_memo_dtl; ?>">
		<input id="id_scrap_memo_dtl_tgl" type="text" value="<?php echo '2018-12-31'; ?>">
		<button id="btn_scrap_memo_dtl_search">Search</button>
		<button id="btn_scrap_memo_dtl_proses">Update Ex BC</button>
		<table>
			<tr>
				<td>
					<table>
						<tr>
							<td></td><td></td><td>
								
							</td>
						</tr>
						
					</table>
					<table id="tbl_scrap_memo_ex_bc_dtl"></table> <div id="ptbl_scrap_memo_ex_bc_dtl"></div>
				</td>
				<td>
					<table>
						<tr>
							<td></td><td></td><td>
						</tr>
					
					</table>
					<table id="tbL_bc23_memo_scrap_dtl_ex_bc"></table> <div id="ptbL_bc23_memo_scrap_dtl_ex_bc"></div>
				</td>
			</tr>
		</table>
	</div>
	

</div>
<script type="text/javascript">
	$(document).ready(function(){
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'yy-mm-dd'
		};
		$("#id_scrap_memo_dtl_tgl").datepicker(datesetopt);
		
		var datePick = function (el) {
			$(el).datepicker({
				changeYear: true,
				changeMonth: true,
				showButtonPanel: true,
				onSelect: function () {
					
					if (this.id.substr(0, 3) === "gs_") {
               
					setTimeout(function(){
					jQuery("#tblst_loaddata_vgi_detil").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						
						$(this).trigger('change');
					}
				}    
			});
		};
		
		function myformatter ( cellvalue, options, rowObject )
		{
			if (cellvalue == "new")
				 return '<font color="red">' + cellvalue + '</font>';//or use classes
			else
				 return '<font color="blue">' + cellvalue + '</font>';//or use classes
		}
		
		
	
		jQuery("#tbl_scrap_memo_ex_bc_dtl").jqGrid({
			url:'<?php echo base_url().'inventory/ct_scrap/v_data_in_dtl_bc_part'; ?>',
			mtype : "post",
			postData:{'q':'1', part_no:$("#part_no_ex_bc").val(), tgl:'2018-12-31'},
			datatype: "json",
			colNames:['id_data_in_dtl', 'id_data_in_hdr', 'id_bc_in_hdr', 'doc_in_from_id'
			,'doc_in_no'
			,'doc_in_date'
			,'CAR'
			,'BC23No'
			,'BC23Tg'
			,'part_no'
			,'part_name'
			,'part_name_customs'
			,'qty_in'
			,'unit_in'
			,'harga'
			,'kdval'
			
			
			
			],
			colModel:[
				{name:'id_data_in_dtl',index:'id_data_in_dtl', width:60, hidden:true},
				{name:'id_data_in_hdr',index:'id_data_in_hdr', width:437, hidden:true},
				{name:'id_bc_in_hdr',index:'id_bc_in_hdr', width:437, hidden:true},
				{name:'doc_in_from_id',index:'doc_in_from_id', width:437, hidden:true},
				{name:'doc_in_no',index:'doc_in_no', width:101, hidden:false},
				{name:'doc_in_date',index:'doc_in_date', width:89, hidden:false,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},
				{name:'CAR',index:'CAR', width:149, hidden:false},
				{name:'BC23No',index:'BC23No', width:119, hidden:false},
				{name:'BC23Tg',index:'BC23Tg', width:89, hidden:false,stype:"text",searchoptions:{dataInit:datePick, att:{title:'Select Date'}}},
				{name:'part_no',index:'part_no', width:149, hidden:false},
				{name:'part_name',index:'part_name', width:149, hidden:false},
				{name:'part_name_customs',index:'part_name_customs', width:149, hidden:false},
				{name:'qty_in',index:'qty_in',  width:120, align:'right', formatter:'number'},
				{name:'unit_in',index:'unit_in', width:109, hidden:false},
				{name:'harga',index:'harga',  width:120, align:'right', formatter:'number'},
				{name:'kdval',index:'kdval', width:109, hidden:false},
				
			],
			rowNum:100,
			rowList:[100,200,300],
			pager: '#ptbl_scrap_memo_ex_bc_dtl',
			sortname: 'doc_in_date',
			viewrecords: true,
			sortorder: "desc",
			width: 500,
			height:265,
			jsonReader: { repeatitems : false },
			caption:"DATA BC IN",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},
			onSelectRow: function (id) {
				var grididpr = jQuery("#tbl_scrap_memo_ex_bc_dtl").jqGrid('getGridParam','selrow');
				if(grididpr){
					var stret = jQuery("#tbl_scrap_memo_ex_bc_dtl").jqGrid('getRowData',grididpr);
					var form_data={
						idhdrbc23:stret.id_bc_in_hdr
					};
					jQuery("#tbL_bc23_memo_scrap_dtl_ex_bc").jqGrid('setGridParam', { postData:form_data });
					$("#tbL_bc23_memo_scrap_dtl_ex_bc").trigger("reloadGrid");
					
				
				}
					
            },
		}); 
		
		jQuery("#tbl_scrap_memo_ex_bc_dtl").jqGrid('navGrid','#ptbl_scrap_memo_ex_bc_dtl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_scrap_memo_ex_bc_dtl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
		jQuery("#tbL_bc23_memo_scrap_dtl_ex_bc").jqGrid({
			url:'<?php echo base_url().'inventory/ct_scrap/loaddata_bc23dtl'; ?>',
			mtype : "post",
			postData:{'q':'1', idhdrbc23:'0'},
			datatype: "json",
			colNames:['ID', 'id_hdr', 'CAR','Serial','Part No', 'JnsBarangDtl', 'TujuanKirimDtl', 'NoHs', 'SeriTrp', 'BrgUrai'
					,'Merk','SpfLain','KdBrg','Penggunaan','KemasJn','KemasJm','KdFasDtl','BrgAsal','DNilInv','KdSat','JmlSat','NettoDtl'
					,'SatBmJm','SatCukJm','DtlOk','create_date','create_by','update_date','update_by'
					],
			colModel:[
				{name:'id_bc_in_dtl',index:'id_bc_in_dtl', width:30, hidden:true},
				{name:'id_bc_in_hdr',index:'id_bc_in_hdr', width:30, hidden:true},
				{name:'CAR',index:'CAR', width:30, hidden:true},
				{name:'Serial',index:'Serial', width:30, hidden:false},
				{name:'Tipe',index:'Tipe', width:129, hidden:false},
				{name:'JnsBarangDtl',index:'JnsBarangDtl', width:30, hidden:true},
				{name:'TujuanKirimDtl',index:'TujuanKirimDtl', width:30, hidden:true},
				{name:'NoHs',index:'NoHs', width:94, hidden:true},
				{name:'SeriTrp',index:'SeriTrp', width:30, hidden:true},
				{name:'BrgUrai',index:'BrgUrai', width:149, hidden:false},
				{name:'Merk',index:'Merk', width:30, hidden:true},
				
				{name:'SpfLain',index:'SpfLain', width:30, hidden:true},
				{name:'KdBrg',index:'KdBrg', width:89, hidden:false},
				{name:'Penggunaan',index:'Penggunaan', width:30, hidden:true},
				{name:'KemasJn',index:'KemasJn', width:30, hidden:true},
				{name:'KemasJm',index:'KemasJm', width:30, hidden:true},
				{name:'KdFasDtl',index:'KdFasDtl', width:30, hidden:true},
				{name:'BrgAsal',index:'BrgAsal', width:30, hidden:true},
				{name:'DNilInv',index:'DNilInv', width:129, hidden:false, align:'right', formatter:'number'},
				{name:'KdSat',index:'KdSat', width:60, hidden:false},
				{name:'JmlSat',index:'JmlSat', width:91, hidden:false, align:'right', formatter:'number'},
				{name:'NettoDtl',index:'NettoDtl', width:30, hidden:true},
				{name:'SatBmJm',index:'SatBmJm', width:30, hidden:true},
				{name:'SatCukJm',index:'SatCukJm', width:30, hidden:true},
				{name:'DtlOk',index:'DtlOk', width:30, hidden:true},
				{name:'create_date',index:'create_date', width:30, hidden:true},
				{name:'create_by',index:'create_by', width:30, hidden:true},
				{name:'update_date',index:'update_date', width:30, hidden:true},
				{name:'update_by',index:'update_by', width:30, hidden:true},
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbL_bc23_memo_scrap_dtl_ex_bc',
			sortname: 'id_bc_in_dtl',
			viewrecords: true,
			sortorder: "asc",
			width: 500,
			height:265,
			jsonReader: { repeatitems : false },
			caption:"Detil Barang",
			//rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			}	
		
		});
		
		jQuery("#tbL_bc23_memo_scrap_dtl_ex_bc").jqGrid('navGrid','#ptbL_bc23_memo_scrap_dtl_ex_bc',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbL_bc23_memo_scrap_dtl_ex_bc").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true}); 
		
		$("#btn_scrap_memo_dtl_search").button().click(function(){
			var form_data = {
				id_scrap_memo_dtl : $("#id_scrap_memo_dtl").val()
				,part_no : $("#part_no_ex_bc").val()
				,tgl:$("#id_scrap_memo_dtl_tgl").val()
				
			}
			
			jQuery("#tbl_scrap_memo_ex_bc_dtl").jqGrid('setGridParam', { postData:form_data });
			$("#tbl_scrap_memo_ex_bc_dtl").trigger("reloadGrid");
			
			
		});
		
		$("#btn_scrap_memo_dtl_proses").button().click(function(){
			var id = jQuery("#tbL_bc23_memo_scrap_dtl_ex_bc").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbL_bc23_memo_scrap_dtl_ex_bc").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			var form_data = {
				id_scrap_memo_dtl : $("#id_scrap_memo_dtl").val()
				,id_bc23_dtl : ret.id_bc_in_dtl
				,serial : ret.Serial
				,id_bc_in_hdr:ret.id_bc_in_hdr
				,unit:ret.KdSat
			}
			
			$("#dlgscrap_memo_update_dtl_ex_bc").dialog( "destroy" );
			$(".dlgscrap_memo_update_dtl_ex_bccl").remove();
			$(".dlgscrap_memo_update_dtl_ex_bccl").html('');
			$("body").append('<div id="dlgscrap_memo_update_dtl_ex_bc" title="Warning" class="dlgscrap_memo_update_dtl_ex_bccl"><p>Apakah anda akan memproses data ini?!?</p></div>');
			$("#dlgscrap_memo_update_dtl_ex_bc").dialog({
				height: 200,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'inventory/ct_scrap/proses_update_memo_dtl_ex_bc'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlgscrap_memo_update_dtl_ex_bc").dialog("close");
								$('#dlgscrap_memo_update_dtl_ex_bc').dialog("destroy"); 
								$(".dlgscrap_memo_update_dtl_ex_bccl").remove(); 
								jQuery("#tbl_scrap_memo_dtl").trigger('reloadGrid');
								
							} else { 
								alert(msg.sts+' '+msg.desc); 
								$("#dlgscrap_memo_update_dtl_ex_bc").dialog("close");
								$('#dlgscrap_memo_update_dtl_ex_bc').dialog("destroy"); 
								$(".dlgscrap_memo_update_dtl_ex_bccl").remove(); 
								jQuery("#tbl_scrap_memo_dtl").trigger('reloadGrid');

							}
						}
					});
				},
					"CANCEL": function() {
						$( "#dlgscrap_memo_update_dtl_ex_bc" ).dialog( "close" );

					}
				},
				close : function(){
					$('#dlgscrap_memo_update_dtl_ex_bc').dialog("destroy"); 
					$(".dlgscrap_memo_update_dtl_ex_bccl").remove(); 
					$("body").append('<div id="dlgscrap_memo_update_dtl_ex_bc" title="Warning" class="dlgscrap_memo_update_dtl_ex_bccl"><p>Apakah anda akan memproses data ini?!?</p></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});	
			
			
			
			
			
		});
		
		
	});
</script>

