
<div id="container_pasi_ceisa_output_tbl_item_list" style="height:100%; margin:0px; padding:0px;overflow:'hidden'; border: 0px solid #cd0a0a">
	<div class="pane-header ui-state-active" style="height:25px" id="pasi_ceisa_output_tbl_item_list_bar" >
	<table style="width:100%">
	<tr>
		<td>LIST ITEM OUTPUT</td>
		<td>
<!--		<button type="button" id="pasi_ceisa_output_qty_update" style="float: right;" >QTY Update</button> 
		<button type="button" id="pasi_ceisa_output_finish" style="float: right;" >Finish</button> 
-->		</td>
	</tr>
	</table> 
</div>
<table id="pasi_ceisa_output_tbl_item_list"></table> <div id="ppasi_ceisa_output_tbl_item_list"></div>
</div> 

<script type="text/javascript">
 	
    $(document).ready(function(){ 
	
//	$("#pasi_ceisa_output_qty_update").button(); 
//	$("#pasi_ceisa_output_finish").button(); 




//-----------------edit qty...................

jQuery("#pasi_ceisa_output_qty_update").click(function(){  
			var mark_id = jQuery('#pasi_ceisa_output_tbl_item_list').jqGrid('getGridParam','selrow');   
						 	if(!mark_id){ alert("Pilih record dahulu");exit;}    
			var $dialog =  $('<div />')
				.html(' <div class="ui-layout-content ui-widget-content-panel" style="margin-top:10px"> \
				Perubahan jumlah output untuk proses produksi \
				</div>\
				 <div class="pane-header ui-state-active" id="pasi_ceisa_beli_bar2" >JUMLAH output</div>\
				 <div class="ui-layout-content ui-widget-content-panel">\
			 	 <label class="lbfield55">QTY</label><label class="lbcolon">:</label><input id="jumlah_qty" name="jumlah_qty"  style="width:185px"   type="text" /><br \>\
			 	 <label class="lbfield55">SATUAN</label><label class="lbcolon">:</label><input id="satuan" name="satuan"  style="width:185px"   type="text" /><br \>\
				</div>\
				<div class="pane-footer ui-state-default" />')
				.dialog({
					modal:true,
					width : 500,
					height : 250,
					title :'EDIT QTY',
					buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
					} ,
					"SIMPAN": function(){ 
							var mark_id = jQuery('#pasi_ceisa_output_tbl_item_list').jqGrid('getGridParam','selrow');   
						 	if(!mark_id){ alert("Pilih produk yang akan di edit");exit;}    
								var ret = jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid('getRowData',mark_id);    
						 	
							var form_edit = {      
									id_detail  : ret.rID, 
					 				qty_actual  : $( "#jumlah_qty" ).val(), 
									satuan     : $("#satuan").val(), 
								 
							}; 
							
							$.ajax({    
							url:'<?php echo base_url().'pasi_ceisa_produksi/ct_produksi_save/edit_qty_output'; ?>',
							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_output_tbl_item_list').trigger('reloadGrid');
				},

			}); 

	}); 

// mapping otomatis

	jQuery("#pasi_ceisa_output_finish").click(function(){  

		var $dialog =  $('<div />')
				.html(' <div class="ui-layout-content ui-widget-content-panel" style="margin-top:10px"> \
				Proses produksi ini selesai ? <br /><br />\
 				</div>')

				 .dialog({
					modal:true,
					width : 500,
					height : 200,
					title :'FINISHING PRODUCTION',
					buttons: {
					"CLOSE": function(){
						$dialog.dialog("close");  
						} ,

					"FINISH": function(){  
						var mark_id = jQuery('#pasi_ceisa_output_tbl_item_list').jqGrid('getGridParam','selrow');   
						 	if(!mark_id){ alert("Pilih produk yang akan di edit");exit;}    
								var ret = jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid('getRowData',mark_id);    
						 	
							var form_edit = {      
									id_detail  : ret.rID, 
	 
								 
							}; 
							
				  
					$.ajax({    			 
					url:'<?php echo base_url().'pasi_ceisa_produksi/ct_produksi_save/finish_rdd'; ?>',
					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_output_tbl_item_list').trigger('reloadGrid');
		  			},
					open: function(){  
				 
						 $("body").unblock();  
					 }

				}); 	 


	}); 	

	//--------------------------load data 
    jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid({  
			url:'<?php echo base_url().'pasi_ceisa_produksi/ct_produksi_data/loaddata_produksi_rdd_output'; ?>',
			datatype: "json",
			mtype : "post",
			postData:{	id_header:'<?php echo $id_header;  ?>'  
						},
						colNames:[
							'ID_DETAIL','STATUS','CODE','NAME','ITEM NO',
							'QTY','QTY ACT','SATUAN','POSISI'
					 

						]
						,colModel:[
						{name:'rID',index:'rID', width:80, hidden:true, align :'right'}
						,{name:'r7',index:'r7', width:100, hidden:false, align :'center'}
						,{name:'r1',index:'r1', width:100, hidden:false, align :'left'}  //kode
						,{name:'r2',index:'r2', width:150, hidden:false, align :'left'}  //nama
						,{name:'r3',index:'r3', width:250, hidden:false, align :'left'}  //item no

						,{name:'r4',index:'r4', width:80, hidden:false, align :'center'} //qty
						,{name:'r5',index:'r5', width:80, hidden:false, align :'center'} // qty act
						,{name:'r6',index:'r6', width:80, hidden:false, align :'left'}
						,{name:'r8',index:'r8', width:80, hidden:false, align :'left'}
					 
				
 
						],
		//	rowNum:-1,
		//	multiselect: true, 
			rowNum:50,
		 	rowList:[10,20,30,50,100,200],
	 		pager: '#ppasi_ceisa_output_tbl_item_list',
			sortname: 'r4',
			viewrecords: true,
			sortorder: "asc",
			width: '',
			height: 100,
			//width: 950,
			//height:300,
			jsonReader: { repeatitems : false }, 
			rownumbers: true,
			loadonce: false,
			shrinkToFit: false, 
			multiselect: false,
			afterInsertRow: function(rowid, aData){
				/*switch (aData.statusdok) {
					case 'DATA SENT':
						jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid('setCell',rowid,'statusdok','',{color:'green'});
					break;
					case '2':
						jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid('setCell',rowid,'statusdok','',{color:'red'});
					break;
					case '1':
						jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid('setCell',rowid,'statusdok','',{color:'blue'});
					break;
					
				} */
			},
		    onSelectRow: function(rowid){ 
				var rowData = $("#pasi_ceisa_output_tbl_item_list").getRowData(rowid); 
		 		if (rowData.rg == 'Yes' ){
					$("#pasi_ceisa_output_map_item_manual").show(); 
				}
				else{
			//		$("#pasi_ceisa_output_map_item_manual").hide(); 
			   }
	 
  		 	 },
			gridComplete: function(){
				var rowIDs = jQuery("#pasi_ceisa_output_tbl_item_list").getDataIDs(); 
				var rowData = $("#pasi_ceisa_output_tbl_item_list").getRowData();
			
				for (var i = 0; i < rowData.length; i++) 
				{
				   var trElement = jQuery("#"+ rowIDs[i],jQuery('#pasi_ceisa_output_tbl_item_list'));
				   
					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_output_tbl_item_list").jqGrid('setGroupHeaders', 
            { useColSpanStyle: true, groupHeaders:[
			{startColumnName: 'r1', numberOfColumns: 3, titleText: '<em><center>OUTPUT</center></em>'},
			{startColumnName: 'r4', numberOfColumns: 2, titleText: '<em><center>QTY</center></em>'},
        ] });       
		jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid('navGrid','#ppasi_ceisa_output_tbl_item_list',{del:false,add:false,edit:false},{},{},{},{multipleSearch:false});
		jQuery("#pasi_ceisa_output_tbl_item_list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true, defaultSearch: 'cn', ignoreCase: true});
		 
	
	setTimeout(function(){
	 		setGridHight($("#pasi_ceisa_output_tbl_item_list"),$("#container_pasi_ceisa_output_tbl_item_list"),$("#pasi_ceisa_output_tbl_item_list_bar")); 
	},100); 



	});
		  	
</script>

	
	