<div id="container_pasi_ceisa_master_description_po" style="display: block !important;height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" id="pasi_ceisa_master_description_po_bar" >   
		<button type="button" id="pasi_ceisa_master_description_po_add">Add</button> 
		<button type="button" id="pasi_ceisa_master_description_po_edit">Edit</button> 
		<button type="button" id="pasi_ceisa_master_description_po_delete">Delete</button> 
	</div>
<table id="pasi_ceisa_master_description_po_tbl"></table> <div id="ppasi_ceisa_master_description_po_tbl"></div>
</div> 

<script type="text/javascript">
    
    $(document).ready(function(){
	
	$(window).bind('resize', function() {  
		setTimeout(function(){
			setGridHight($("#pasi_ceisa_master_description_po_tbl"),$("#container_pasi_ceisa_master_description_po"),$("#pasi_ceisa_master_description_po_bar")); 
		},10); 
	}); 
		 
	$("#pasi_ceisa_master_description_po_add").button(); 
	$("#pasi_ceisa_master_description_po_edit").button(); 
	$("#pasi_ceisa_master_description_po_delete").button();   
	 jQuery("#pasi_ceisa_master_description_po_add").click(function(){
		 		var $dialog = jQuery('<div \>')
				 .html('<div class="ui-layout-content ui-widget-content-panel"> \
				 <label class="lbfield55">DESC</label><label class="lbcolon">:</label><input id="pasi_ceisa_master_description_po_desc" name="pasi_ceisa_master_description_po_desc" type="text" value="" style="width:280px" /><br \>\
				 <label class="lbfield55">TYPE</label><label class="lbcolon">:</label><select id="pasi_ceisa_master_description_po_type" style="width:180px">\
																								<option value=""></option>\
																								<option value="1">Finish Good</option>\
																								<option value="2">Material</option>\
																								<option value="3">Mechine</option>\
																								<option value="4">Sparepart</option>\
																								<option value="5">Equipment</option>\
																								<option value="6">Scrap</option>\
																								</select><br \>\
 				 <label class="lbfield55" for="pasi_ceisa_master_description_po_show">SHOW</label><label class="lbcolon">:</label><input  name="pasi_ceisa_master_description_po_show" type="checkbox" id="pasi_ceisa_master_description_po_show"  value=\'Yes\' offval=\'No\'  /><label  for="pasi_ceisa_master_description_po_show">(Show item on create bc from PO)</label><br \>\
				 <label class="lbfield55" for="pasi_ceisa_master_description_po_validation">VALIDATION</label><label class="lbcolon">:</label><input  name="pasi_ceisa_master_description_po_validation" type="checkbox" id="pasi_ceisa_master_description_po_validation"  value=\'Yes\' offval=\'No\'  /> <label  for="pasi_ceisa_master_description_po_validation">(validation item on process file PO)</label><br \>\
	 			</div>')
				 .dialog({
					modal:true,
					width : 500,
					height : 200,
						title :'ADD DESCRIPTION PO',
						buttons: {
							
							"CLOSE": function(){
								$dialog.dialog("close");  
							} ,"ADD": function(){
								 
							var form_edit = {
									desc :$('#pasi_ceisa_master_description_po_desc').val(),      
									item_type :$('#pasi_ceisa_master_description_po_type').val(),
									show :$('#pasi_ceisa_master_description_po_show').is(':checked')==true?'1':'0',
									validation :$('#pasi_ceisa_master_description_po_validation').is(':checked')==true?'1':'0',
									
							}; 
							
							$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_master/ct_pasi_description_po/add_data'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else { alert(msg.stsno+msg.stsmsg);  }
								} 
							});  
							
							}
						},
						close : function(){
							$dialog.dialog('destroy').remove();
							$('#pasi_ceisa_master_description_po_tbl').trigger('reloadGrid');
						},
						open: function(){
							$("body").unblock(); 
						}
					}); 
		});
		 
	 jQuery("#pasi_ceisa_master_description_po_edit").click(function(){
				var mark_id = jQuery('#pasi_ceisa_master_description_po_tbl').jqGrid('getGridParam','selrow');   
				if(!mark_id){ alert("Pililh dokumen yang akan di edit");exit;}    
				var ret = jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid('getRowData',mark_id);    
						 
		 		var $dialog = jQuery('<div \>')
				 .html('<div class="ui-layout-content ui-widget-content-panel"> \
				 <label class="lbfield55">DESC</label><label class="lbcolon">:</label><input id="pasi_ceisa_master_description_po_desc" name="pasi_ceisa_master_description_po_desc" type="text" value="" style="width:280px" /><br \>\
				 <label class="lbfield55">TYPE</label><label class="lbcolon">:</label><select id="pasi_ceisa_master_description_po_type" style="width:180px">\
																								<option value=""></option>\
																								<option value="1">Finish Good</option>\
																								<option value="2">Material</option>\
																								<option value="3">Mechine</option>\
																								<option value="4">Sparepart</option>\
																								<option value="5">Equipment</option>\
																								<option value="6">Scrap</option>\
																								</select><br \>\
 				 <label class="lbfield55" for="pasi_ceisa_master_description_po_show">SHOW</label><label class="lbcolon">:</label><input  name="pasi_ceisa_master_description_po_show" type="checkbox" id="pasi_ceisa_master_description_po_show"  value=\'Yes\' offval=\'No\'  /><label  for="pasi_ceisa_master_description_po_show">(Show item on create bc from PO)</label><br \>\
				 <label class="lbfield55" for="pasi_ceisa_master_description_po_validation">VALIDATION</label><label class="lbcolon">:</label><input  name="pasi_ceisa_master_description_po_validation" type="checkbox" id="pasi_ceisa_master_description_po_validation"  value=\'Yes\' offval=\'No\'  /> <label  for="pasi_ceisa_master_description_po_validation">(validation item on process file PO)</label><br \>\
	 			</div>')
				 .dialog({
					modal:true,
					width : 500,
					height : 200,
						title :'EDIT DESCRIPTION PO',
						buttons: {
							
							"CLOSE": function(){
								$dialog.dialog("close");  
							} ,"EDIT": function(){
								 
							var form_edit = {
									desc_old :ret.rID,      
									desc :$('#pasi_ceisa_master_description_po_desc').val(),      
									item_type :$('#pasi_ceisa_master_description_po_type').val(),
									show :$('#pasi_ceisa_master_description_po_show').is(':checked')==true?'1':'0',
									validation :$('#pasi_ceisa_master_description_po_validation').is(':checked')==true?'1':'0',
									
							}; 
							
							$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_master/ct_pasi_description_po/edit_data'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else { alert(msg.stsno+msg.stsmsg);  }
								} 
							});  
							
							}
						},
						close : function(){
							$dialog.dialog('destroy').remove();
							$('#pasi_ceisa_master_description_po_tbl').trigger('reloadGrid');
						},
						open: function(){
							$('#pasi_ceisa_master_description_po_desc').val(ret.rID);
							$('#pasi_ceisa_master_description_po_type').val(ret.r1); 
						if (ret.r7 == 'Yes'){
							$("#pasi_ceisa_master_description_po_show").prop("checked", true);
						} else {$("#pasi_ceisa_master_description_po_show").prop("checked", false);};
						
						if (ret.r8 == 'Yes'){
							$("#pasi_ceisa_master_description_po_validation").prop("checked", true);
						} else {$("#pasi_ceisa_master_description_po_validation").prop("checked", false);};
						
							
							$("body").unblock(); 
						}
					}); 
		});
		 
		  jQuery("#pasi_ceisa_master_description_po_delete").click(function(){ 
				var mark_id = jQuery('#pasi_ceisa_master_description_po_tbl').jqGrid('getGridParam','selrow');   
				if(!mark_id){ alert("Pililh dokumen yang akan di edit");exit;}    
				var ret = jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid('getRowData',mark_id);    
						  
			var $dialog = jQuery('<div \>')
				 .html('<div class="ui-layout-content ui-widget-content-panel"> Delete Data?\
					</div>')
				 .dialog({
					modal:true,
					width : 250,
					height : 150,
						title :'DELETE DESCRIPTION PO',
						buttons: {
							
							"CLOSE": function(){
								$dialog.dialog("close");  
							} 
							,"DELETE": function(){
								 
							var form_edit = {
									desc :ret.rID      
											
							}; 
							
							$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_master/ct_pasi_description_po/delete_data'; ?>',
							type : 'POST',
								data : form_edit,
								dataType: 'json',
								success: function(msg){
									if (msg.valid){
										alert(msg.stsmsg);  
										$dialog.dialog("close");  
									} else { alert(msg.stsno+msg.stsmsg);  }
								} 
							});  
							
							}
						},
						close : function(){
							$dialog.dialog('destroy').remove();
							$('#pasi_ceisa_master_description_po_tbl').trigger('reloadGrid');
						},
						open: function(){ 
							$("body").unblock(); 
						}
					}); 
	}); 
	jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid({
			url:'<?php echo base_url().'pasi_ceisa_master/ct_pasi_description_po/loaddata'; ?>',
			mtype : "post",
			postData:{'q':'1'},
			datatype: "json",
			colNames:[
			'Description Item PO','dt_descriptin_po_type_item_id','Type Item','Show','Validation','Create Date','Create By','Modify Date'
			,'Modify By'
			]
			,colModel:[
			{name:'rID',index:'rID', width:250, hidden:false, align :'left'}
			,{name:'r1',index:'r1', width:80, hidden:true, align :'right'}
			,{name:'r2',index:'r2', width:100, hidden:false, align :'left'}
			,{name:'r7',index:'r7', width:40, editable: false, formatter:'checkbox',  align: "center",stype: "select", searchoptions: { value: "-100:All;1:Yes;0:No" }}
			,{name:'r8',index:'r8', width:80, editable: false, formatter:'checkbox',  align: "center",stype: "select", searchoptions: { value: "-100:All;1:Yes;0:No" }}
			,{name:'r3',index:'r3', width:120, 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 :'left'}
			,{name:'r5',index:'r5', width:120, 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:'r6',index:'r6', width:80, hidden:false, align :'left'}

			],
			rowNum:10,
			rowList:[10,20,30],
			pager: '#ppasi_ceisa_master_description_po_tbl',
			sortname: 'rID',
			viewrecords: true,
			sortorder: "asc",
			width: '',
			height: 100,
			//width: 950,
			//height:300,
			jsonReader: { repeatitems : false },
			caption:"Data File PO",
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false,
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
			gridComplete: function(){
				var rowIDs = jQuery("#pasi_ceisa_master_description_po_tbl").getDataIDs(); 
				var rowData = $("#pasi_ceisa_master_description_po_tbl").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#pasi_ceisa_master_description_po_tbl'));
				   
					switch (rowData[i].status_2) {
						case 'DATA PROCESSED':
						   trElement.css({"color":"green"});
						break;
						
						case 'SENT TO INVENTORY CANCELED':
						   trElement.css({"color":"green"});
						break;
						
						case 'DATA SENT TO INVENTORY':
						   trElement.css({"color":"purple"});
						break;
						case 'DATA PROCESSED INVENTORY':
						   trElement.css({"color":"blue"});
						break;
						case 'APPROVED INVENTORY':
						   trElement.css({"color":"red"});
						break;
					}
				}
			},
		});  
		
		jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid('navGrid','#ppasi_ceisa_master_description_po_tbl',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#pasi_ceisa_master_description_po_tbl").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
	
	
		
	setTimeout(function(){
			setGridHight($("#pasi_ceisa_master_description_po_tbl"),$("#container_pasi_ceisa_master_description_po"),$("#pasi_ceisa_master_description_po_bar")); 
		},100); 
	});
		  	
</script>

	
	