<?php
//error_reporting(E_ALL ^ E_NOTICE);
/* require_once 'excel_reader2.php';
$data = new Spreadsheet_Excel_Reader("stock_awal.xls"); */
?>

<style>
table.excel {
	border-style:ridge;
	border-width:1;
	border-collapse:collapse;
	font-family:sans-serif;
	font-size:12px;
}
table.excel thead th, table.excel tbody th {
	background:#CCCCCC;
	border-style:ridge;
	border-width:1;
	text-align: center;
	vertical-align:bottom;
}
table.excel tbody th {
	text-align:center;
	width:20px;
}
table.excel tbody td {
	vertical-align:bottom;
}
table.excel tbody td {
    padding: 0 3px;
	border: 1px solid #EEEEEE;
}
</style>


	<div id="divtabbahanpenolong_out_upload_ct" >
		<div style="height:40px">
			Periode : <input type="text" id="txt_tgl_awal_bp_bc_out_ct" value="<?php echo date("Y-m-d") ?>" style="width:80px"/> sampai  
			<input type="text" id="txt_tgl_akhir_bp_bc_out_ct" value="<?php echo date("Y-m-d") ?>" style="width:80px"/> 
			<button id="btnsearch_bp_bc_out_ct" >SEARCH</button>
			<button id="btn_bp_bc_out_ct_update" >UPDATE</button>
			<button id="btnupload_bp_bc_out_ct" >DATA OUT CT01</button>
		</div>
		<table id="tbl_data_bp_bc_out_ct"></table> <div id="ptbl_data_bp_bc_out_ct"></div>   
	</div>
	
	
</div>
<script type="text/javascript">
    
    $(document).ready(function(){
		
		var currentDate = new Date(); 
		var datesetopt = {
			showOn: "button",
			buttonImageOnly: true,
			buttonImage: "<?php echo base_url()."assets/images/icons/16x16/timespan.png"  ?>",
			buttonText: "Tanggalan",
			dateFormat: 'yy-mm-dd'
		};
		
		$("#txt_tgl_awal_bp_bc_out_ct").datepicker(datesetopt);
		$("#txt_tgl_akhir_bp_bc_out_ct").datepicker(datesetopt); 	
		
		
		var datePick = function (el) {
			$(el).datepicker({
				changeYear: true,
				changeMonth: true,
				showButtonPanel: true,
				onSelect: function () {
					
					if (this.id.substr(0, 3) === "gs_") {
                // in case of searching toolbar
					setTimeout(function(){
					jQuery("#tbl_view_upload_data__bp_out_ct").jqGrid()[0].triggerToolbar();
						}, 50);
					} else {
						// refresh the filter in case of
						// searching dialog
						$(this).trigger('change');
					}
				}    
			});
		};
		
		$("#btnsearch_bp_bc_out_ct").button().click(function(){
			var form_data={
				tglawal:$("#txt_tgl_awal_bp_bc_out_ct").val(), tglakhir:$("#txt_tgl_akhir_bp_bc_out_ct").val(), doc_out_to:'1'
			};
			jQuery("#tbl_data_bp_bc_out_ct").jqGrid('setGridParam', { postData:form_data });
			$("#tbl_data_bp_bc_out_ct").trigger("reloadGrid");
				
		
		});
		
		jQuery("#tbl_data_bp_bc_out_ct").jqGrid({
			url:'<?php echo base_url().'settings/ct_barangbahanpenolong/data_bahanpenolong_out_ct'; ?>',
			mtype : "post",
			postData:{'q':'1',tglawal:$("#txt_tgl_awal_bp_bc_out_ct").val(), tglakhir:$("#txt_tgl_akhir_bp_bc_out_ct").val(), doc_out_to:'1' },
			datatype: "json",
			colNames:['id_bp_out_dtl','no_invoice','tgl_invoice', 'part_no', 'part_name', 'qty'
					,'uom','doc_no','doc_date','doc_out_to','filename','container_number'
					,'car','status','create_date','create_by'],
			colModel:[
				{name:'id_bp_out_dtl',index:'id_bp_out_dtl', width:139, hidden:true},
				{name:'no_invoice',index:'no_invoice', width:139, hidden:false},
				{name:'tgl_invoice',index:'tgl_invoice', width:139, hidden:false},
				{name:'part_no',index:'part_no', width:139, hidden:false},
				{name:'part_name',index:'part_name', width:159, hidden:false},
				{name:'qty',index:'qty', width:77, hidden:false, align:'right'},
				{name:'uom',index:'uom', width:139, hidden:false},
				{name:'doc_no',index:'doc_no', width:139, hidden:false},
				{name:'doc_date',index:'doc_date', width:139, hidden:false},
				{name:'doc_out_to',index:'doc_out_to', width:139, hidden:true},
				{name:'filename',index:'filename', width:139, hidden:true},
				{name:'container_number',index:'container_number', width:139, hidden:false},
				{name:'car',index:'car', width:139, hidden:false},
				{name:'status_data',index:'status_data', width:139, hidden:false},
				{name:'create_date',index:'create_date', width:139, hidden:false},
				{name:'create_by',index:'create_by', width:139, hidden:false}
				
			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbl_data_bp_bc_out_ct',
			sortname: 'id_bp_out_dtl',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:300,
			jsonReader: { repeatitems : false },
			caption:"DATA ITEM OUT",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},
			onSelectRow: function(id){
				var stret = jQuery("#tbl_data_bp_bc_out_ct").jqGrid('getRowData',id);
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_data_bp_bc_out_ct").getDataIDs(); 
				var rowData = $("#tbl_data_bp_bc_out_ct").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_data_bp_bc_out_ct'));
				   
					switch (rowData[i].status_data) {
						
						case '':
						   trElement.css({ "text-decoration": "line-through"});
						break;
						case 'CANCEL':
						   trElement.css({ "text-decoration": "line-through"});
						break;
						
						
					}
				}
			},  
		}); 
		
		jQuery("#tbl_data_bp_bc_out_ct").jqGrid('navGrid','#ptbl_data_bp_bc_out_ct',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_data_bp_bc_out_ct").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		
		
		
		$("#btndownload_bp_bc_out_ct").button().click(function(){
		
		});
		
		$("#btn_bp_bc_out_ct_update").button().click(function(){
			var id = jQuery("#tbl_data_bp_bc_out_ct").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_data_bp_bc_out_ct").jqGrid('getRowData',id);
				
			} else {
				alert("Please Select Row");
				return false;
			};	
			var form_data = {
				id_bp_out_dtl:ret.id_bp_out_dtl,
				part_no:ret.part_no,
				part_name:ret.part_name,
				qty:ret.qty,
				status_data:ret.status_data,
				no_invoice:ret.no_invoice,
				tgl_invoice:ret.tgl_invoice
			};
			
			
			$("#frm_bp_out_update_ct_dlg").load('<?php echo base_url().'settings/ct_barangbahanpenolong/view_bahanpenolong_out_update_ct'; ?>',  form_data, function() {
				$("#frm_bp_out_update_ct_dlg").dialog({
					modal:true,
					width : 340,
					height : 300,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frm_bp_out_update_ct_dlg').dialog("destroy"); 
					    $(".frm_bp_out_update_ct_dlg_cl").remove(); 
					    $("body").append('<div id="frm_bp_out_update_ct_dlg" title="UPDATE BAHAN PENOLONG OUT" class="frm_bp_out_update_ct_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
		});
		
		$("#btnupload_bp_bc_out_ct").button().click(function(){
			$("#frmdata_outbahanpenolong_ct_dlg").load('<?php echo base_url().'settings/ct_barangbahanpenolong/view_bahanpenolong_data_out_ct_upload'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmdata_outbahanpenolong_ct_dlg").dialog({
					modal:true,
					width : 1000,
					height : 599,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmdata_outbahanpenolong_ct_dlg').dialog("destroy"); 
					    $(".frmdata_outbahanpenolong_ct_dlg_cl").remove(); 
					    $("body").append('<div id="frmdata_outbahanpenolong_ct_dlg" title="DATA PENGELUARAN CT01" class="frmdata_outbahanpenolong_ct_dlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
			
			
		});
		
		
		
	});
	
	/* 
	
	new Date($("#ms_prod_car_line_edit_doc_date").datepicker('getDate')
	jQuery("#tbl_view_upload_data_bp_out_ct").jqGrid({
			url:'<?php echo base_url().'settings/ct_barangbahanpenolong/loaddatax'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:[
			'tbl_bahanpenolong_out_id_bp_out_dtl','tbl_bahanpenolong_out_container_number','tbl_bahanpenolong_out_no_invoice','tbl_bahanpenolong_out_tgl_invoice','tbl_bahanpenolong_out_part_no','tbl_bahanpenolong_out_part_name'
			,'tbl_bahanpenolong_out_qty','tbl_bahanpenolong_out_qty_out','tbl_bahanpenolong_out_uom','tbl_bahanpenolong_out_doc_no','tbl_bahanpenolong_out_doc_date'
			,'tbl_bahanpenolong_out_doc_out_to','tbl_bahanpenolong_out_filename','tbl_bahanpenolong_out_car','tbl_bahanpenolong_out_create_date','tbl_bahanpenolong_out_create_by'
			,'tbl_bahanpenolong_out_update_date','tbl_bahanpenolong_out_update_by'
			]
			,colModel:[
			{name:'rID',index:'rID', width:80, hidden:false, align :'right'}
			,{name:'r1',index:'r1', width:80, hidden:false, align :'right'}
			,{name:'r2',index:'r2', width:80, hidden:false, align :'right'}
			,{name:'r3',index:'r3', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#table_name")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}
			,{name:'r4',index:'r4', width:80, hidden:false, align :'right'}
			,{name:'r5',index:'r5', width:80, hidden:false, align :'right'}

			,{name:'r6',index:'r6', width:80, hidden:false, align :'right'}
			,{name:'r7',index:'r7', width:80, hidden:false, align :'right'}
			,{name:'r8',index:'r8', width:80, hidden:false, align :'right'}
			,{name:'r9',index:'r9', width:80, hidden:false, align :'right'}
			,{name:'r10',index:'r10', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#table_name")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}

			,{name:'r11',index:'r11', width:80, hidden:false, align :'right'}
			,{name:'r12',index:'r12', width:80, hidden:false, align :'right'}
			,{name:'r13',index:'r13', width:80, hidden:false, align :'right'}
			,{name:'r14',index:'r14', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#table_name")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}
			,{name:'r15',index:'r15', width:80, hidden:false, align :'right'}

			,{name:'r16',index:'r16', width:80, hidden:false, align :'left', searchoptions:{searchhidden: true,dataInit:function(el){$(el).datepicker({onSelect: function(date){jQuery("#table_name")[0].triggerToolbar();},changeMonth: true,changeYear: true,dateFormat:'dd/mm/yy', showButtonPanel: true, beforeShow: function(input) {  setTimeout(function() { var buttonPane = $(input).datepicker("widget").find( ".ui-datepicker-buttonpane" );   var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');   btn.unbind("click").bind("click", function () {   $.datepicker._clearDate( input );   });   btn.appendTo( buttonPane );  }, 1 );  }  });}}}
			,{name:'r17',index:'r17', width:80, hidden:false, align :'right'}

			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ptbl_view_upload_data_bp_out_ct',
			sortname: 'rID',
			viewrecords: true,
			sortorder: "desc",
			width: '',
			height:290,
			jsonReader: { repeatitems : false },
			caption:"DATA UPLOAD BP OUT",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
				
				
			},			
			gridComplete: function(){
				var rowIDs = jQuery("#tbl_view_upload_data_bp_out_ct").getDataIDs(); 
				var rowData = $("#tbl_view_upload_data_bp_out_ct").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#tbl_view_upload_data_bp_out_ct'));
				   
					switch (rowData[i].status_upload) {
						
						case 'cancel':
						   trElement.css({"color":"green"});
						break;
						case 'Deleted':
						   trElement.css({"color":"red", "text-decoration": "line-through"});
						break;
						case 'DATA PROCESSED':
						   trElement.css({"color":"blue"});
						break;
						
						
					}
				}
			},
		}); 
		
		jQuery("#tbl_view_upload_data_bp_out_ct").jqGrid('navGrid','#ptbl_view_upload_data_bp_out_ct',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_view_upload_data_bp_out_ct").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		 */
		  	
</script>
<div id="frm_bp_out_update_ct_dlg" title="UPDATE BAHAN PENOLONG OUT" class="frm_bp_out_update_ct_dlg_cl"></div>
<div id="frmdata_outbahanpenolong_ct_dlg" title="DATA PENGELUARAN CT01" class="frmdata_outbahanpenolong_ct_dlg_cl"></div>


	
	