<div id="container_pasi_supplier_set" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="pasi_supplier_set_bar" >    
		<button id="btngetitemsupplier">Get Supplier Code List</button>
		<button id="btninsertsupplier">Insert Data</button> 
		<button id="btnupdatesupplier">Update Data</button>
		<button id="btndeletesupplier">Delete Data</button>
	</div>
	<table id="tbl_supplier"></table> <div id="ptbl_supplier"></div>
</div>
<script type="text/javascript">
    
    $(document).ready(function(){
		$(window).bind('resize', function() {  
			setTimeout(function(){
				setGridHight($("#tbl_supplier"),$("#container_pasi_supplier_set"),$("#pasi_supplier_set_bar")); 
			},10); 
		});
	

		$("#btngetitemsupplier").button().click(function(){
			$("#frmitemlistspldlg").load('<?php echo base_url().'pasi_settings/ct_supplier/view_supplier_itemlist'; ?>',  {parmeter:'parameter'}, function() {
				$("#frmitemlistspldlg").dialog({
					modal:true,
					width : 694,
					height : 499,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  
							
						}
                    },
					close : function(){
						$('#frmitemlistspldlg').dialog("destroy"); 
					    $(".frmitemlistspldlg_cl").remove(); 
					    $("body").append('<div id="frmitemlistspldlg" title="ITEM LIST" class="frmitemlistspldlg_cl"></div>'); 
						
					},
					open: function(){
						$("body").unblock();				
					}
				});
			});
		});

		$("#btnupdatesupplier").button().click(function(){
			var id = jQuery("#tbl_supplier").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_supplier").jqGrid('getRowData',id);	
			} else {
				alert("Please Select Row");
				return false;
			};	
			
			var form_data={
				idx:ret.id_master_supp_code,
				suppno:ret.suppno,
				suppname:ret.suppname,
				address1:ret.address1,
				address2:ret.address2,
				city:ret.city,
				prov:ret.prov,
				country:ret.country,
				npwp:ret.npwp,
				skepno:ret.skepno,
				skepdate:ret.skepdate,

			};			
			
			$("#frmsupplierupdate_dlg").load('<?php echo base_url().'pasi_settings/ct_supplier/view_supplier_update'; ?>',  form_data, function() {
				$("#frmsupplierupdate_dlg").dialog({
					modal:true,
					width : 520,
					height : 300,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  	
						}
                    },
					close : function(){
						$('#frmsupplierupdate_dlg').dialog("destroy"); 
					    $(".frmsupplierupdate_dlg_cl").remove(); 
					    $("body").append('<div id="frmsupplierupdate_dlg" title="Master Supplier" class="frmsupplierupdate_dlg_cl"></div>'); 
					},
					open: function(){
						$("body").unblock();
					}
				});
			});
		});
		
		$("#btninsertsupplier").button().click(function(){
						
			$("#frmsupplierinsert_dlg").load('<?php echo base_url().'pasi_settings/ct_supplier/view_supplier_insert'; ?>',  function() {
				$("#frmsupplierinsert_dlg").dialog({
					modal:true,
					width : 520,
					height : 300,
					buttons: {
                        "Close": function() {  
							$(".ui-dialog-titlebar-close").trigger('click');  	
						}
                    },
					close : function(){
						$('#frmsupplierinsert_dlg').dialog("destroy"); 
					    $(".frmsupplierinsert_dlg_cl").remove(); 
					    $("body").append('<div id="frmsupplierinsert_dlg" title="Supplier" class="frmsupplierinsert_dlg_cl"></div>'); 
	
					},
					open: function(){
						$("body").unblock();
						
					}
				});
			});
		});
		$("#btndeletesupplier").button().click(function(){
			var id = jQuery("#tbl_supplier").jqGrid('getGridParam','selrow');
			if (id) { 
				var ret = jQuery("#tbl_supplier").jqGrid('getRowData',id);	
			} else {
				alert("Please Select Row");
				return false;
			};
			
			var form_data={
				idx:ret.id_master_supp_code
			};
			
			$("#dlgsupplierdelete").dialog( "destroy" );
			$(".dlgsupplierdelete_cl").remove();
			$("body").append('<div id="dlgsupplierdelete" title="Warning" class="dlgsupplierdelete_cl"><p>Apakah anda akan menghapus kode barang ini?</p><br /></div>');
			
			
			
			$("#dlgsupplierdelete").dialog({
				height: 160,
				width: 250,
				modal: true,
				hide: 'Slide',
				autoOpen: 'false',
				buttons: {
					"CONFIRM": function() {
					$.ajax({
						url : "<?php echo base_url().'pasi_settings/ct_supplier/deletekodebarang'; ?>",
						type : 'POST',
						dataType: 'json',
						data : form_data,
						success: function(msg){
							if (msg.sts == '00'){
								alert(msg.desc);
								$("#dlgsupplierdelete").dialog("close");
								$('#dlgsupplierdelete').dialog("destroy"); 
								$(".dlgsupplierdelete_cl").remove(); 
								$('#tbl_supplier').trigger('reloadGrid');

							} else { 
								alert(msg.sts+msg.desc); 
								$("#dlgsupplierdelete").dialog("close");
								$('#dlgsupplierdelete').dialog("destroy"); 
								$(".dlgsupplierdelete_cl").remove(); 

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

					}
				},
				close : function(){
					$('#dlgsupplierdelete').dialog("destroy"); 
					$(".dlgsupplierdelete_cl").remove(); 
					$("body").append('<div id="dlgsupplierdelete" title="Warning" class="dlgsupplierdelete_cl"><p>Apakah anda akan menghapus kode barang ini?</p><br /></div>');     
					
				},
				open: function(){
					$("body").unblock();
					
				}
			});
		});
		
		jQuery("#tbl_supplier").jqGrid({
			url:'<?php echo base_url().'pasi_settings/ct_supplier/loadData'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:['id',
					'Supplier Code',
					'Supplier Name',
					'Address 1',
					'Address 2',
					'City',
					'Province',
					'Zip Code',
					'Country',
					'Phone',
					'Mobile',
					'Fax',
					'Email',
					'Contact',
					'prodsupplied',
					'NPWP',
					'Certificate',
					'Joint Date',
					'Acc. Number',
					'Acc. Name',
					'Bank Name',
					'Approved By',
					'Designation',
					'Suspended',
					'Doc. BC',
					'No SKEP',
					'Tanggal SKEP',
					'Create_date',
					'Create_by',
					'Update_date',
					'Update_by'],			
			
			colModel:[
			
					{name:'id_master_supp_code',index:'id_master_supp_code', width:471, hidden:true},
					{name:'suppno',index:'suppno', width:100, hidden:false},
					{name:'suppname',index:'suppname', width:400, hidden:false},
					{name:'address1',index:'address1', width:300, hidden:false},
					{name:'address2',index:'address2', width:250, hidden:false},
					{name:'city',index:'city', width:200, hidden:false},
					{name:'prov',index:'prov', width:200, hidden:false},
					{name:'zipcode',index:'zipcode', width:200, hidden:false},
					{name:'country',index:'country', width:200, hidden:false},
					{name:'phone',index:'phone', width:200, hidden:false},
					{name:'mobile',index:'mobile', width:200, hidden:false},
					{name:'fax',index:'fax', width:200, hidden:false},
					{name:'email',index:'email', width:200, hidden:false},
					{name:'contact',index:'contact', width:200, hidden:false},
					{name:'prodsupplied',index:'prodsupplied', width:300, hidden:false},
					{name:'npwp',index:'npwp', width:300, hidden:false},
					{name:'certificate',index:'certificate', width:300, hidden:false},
					{name:'jointdate',index:'jointdate', width:300, hidden:false},
					{name:'accno',index:'accno', width:300, hidden:false},
					{name:'accname',index:'accname', width:300, hidden:false},
					{name:'bankname',index:'bankname', width:300, hidden:false},
					{name:'approvedby',index:'approvedby', width:100, hidden:false},
					{name:'designation',index:'designation', width:100, hidden:false},
					{name:'suspended',index:'suspended', width:100, hidden:false},
					{name:'docbc',index:'docbc', width:100, hidden:false},
					{name:'skepno',index:'skepno', width:100, hidden:false},
					//{name:'skepdate',index:'skepdate', width:100, hidden:false},
					{name:'skepdate',index:'skepdate', width:100, formatter: 'date', formatoptions: { newformat: 'd/m/Y'}, searchoptions:{sopt:['eq']}},
					{name:'create_date',index:'create_date', width:150, hidden:false},
					{name:'create_by',index:'create_by', width:150, hidden:false},
					{name:'update_date',index:'update_date', width:150, hidden:false},
					{name:'update_by',index:'update_by', width:150, hidden:false},


				],
			rowNum:15,
			rowList:[15,25,35],
			pager: '#ptbl_supplier',
			sortname: 'id_master_supp_code',
			viewrecords: true,
			sortorder: "asc",
			width: '',
			height:100,
			jsonReader: { repeatitems : false },
			caption:"Data Master Supplier",
			rownumbers: true,
			shrinkToFit: false,
			afterInsertRow: function(){
						
			},			
			gridComplete: function(){
				
			},
		}); 
			
                        
		jQuery("#tbl_supplier").jqGrid('navGrid','#ptbl_supplier',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#tbl_supplier").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, defaultSearch: 'cn', ignoreCase: true});
		
			setTimeout(function(){
				setGridHight($("#tbl_supplier"),$("#container_pasi_supplier_set"),$("#pasi_supplier_set_bar")); 
			},100); 

	});
		  	
</script>
<div id="frmsupplierupdate_dlg" title="Supplier Name" class="frmsupplierupdate_dlg_cl"></div>
<div id="frmsupplierinsert_dlg" title="Supplier Name" class="frmsupplierinsert_dlg_cl"></div>
<div id="frmitemlistspldlg" title="ITEM LIST" class="frmitemlistspldlg_cl"></div>



	
	