<!---- 
    Author 	: Ladur / 14-08-2014
    Revisi 	: Ferry / 30-10-2014 / Cancel for Reload Form
-->
<div class="easyui-layout" data-options="fit:true,border:false">
    <!-- top view-->
    <div id="form-header" data-options="region:'north',border:false" >
        <div id="form-header-wrapper">
            <table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0">
                <tr>
                    <td align="left" valign="middle"></td>							

                    <td height="25" align="right" valign="middle">								
                        <span class="form-title">
                            <?php echo $menu_label; ?>
                        </span>
                    </td>
                </tr>
            </table>		     	
        </div>			
    </div>
    <!-- end top view -->

    <!-- center view -->
    <div id="form-body-grey" data-options="region:'center',border:false">
        <div id="form-wrapper" class="easyui-panel" style="width:auto;height:525px;padding:5px;" fit="true">
            <form id="fm_new_item" name="fm_new_item" method="post">
                <input type="hidden" id="cek_as_aset" />
                    <div id="wrapptabs" name="" class="easyui-tabs" >
                        <div title="General" style="padding:10px;">
                                <table>
                                    <tr>
                                        <td align="left">Item Category</td>
                                    
                                        <td>
                                            <select class="easyui-combogrid td_input" name="cmb_category" style="height:20px;width:850px;" readonly required="required" 
                                                data-options="
                                                    value:'<?php echo $detail->ItemCategoryID;?>',
                                                    panelWidth: 1000,
                                                    idField: 'ItemCategoryID',
                                                    textField: 'ItemCategoryName',
                                                    url: '<?php echo base_url(); ?>custom/get_data/itemcategory',
                                                    method: 'get',
                                                    columns: [[
                                                    {field:'ItemCategoryName',title:'Item Category Name',width:190}
                                                    ]],
                                                    fitColumns: true
                                                ">
                                            </select>
                                        </td>
                                    </tr>
								<tr>
                                    <td width="100"><label>Item Type</label></td>
                                    <td style="float:left;width:910px;">
                                        <select name="rdo_itemtype" id="rdo_itemtype" class="easyui-combobox" editable="false" readonly data-options="
                                        	value: '<?php echo $detail->ItemTypeID;?>',
                                            valueField:'ItemTypeID',
                                            textField:'ItemTypeName',
                                            url:'<?php echo base_url(); ?>custom/get_data/itemtype'
                                            " style="width:850px;" required="true" ></select>
                                    </td>

                                    
                                </tr>
                            </table>

                            <table>
                                <tr>
                                    <td width="100"><label>Item no</label></td>

                                    <td>
                                        <input type="text" id="txt_itemno" name="txt_itemno" class="easyui-validatebox" data-options="required:true" style="width:848px;text-transform:uppercase" value="<?php echo $detail->ItemCode;?>" readonly />
                                        <!--
                                        <input type="checkbox" id="chk_itemno" name="chk_itemno" onclick="showHideLoadItem()" /> Sub Item Of
                                        <input type="text" id="txt_codeitem" name="txt_codeitem" style="width:150px;" />
                                        <input type="button" id="btn_loaditem" name="btn_loaditem" value="..." onclick="showDialogItem()" />
                                        -->
                                    </td>
                                </tr>
                                <tr>
                                    <td><label>Description</label></td>
                                    <td>
                                        <textarea rows="2" id="" name="txa_desctiption" class="easyui-validatebox" data-options="required:true" style="resize:none;width:844px" disabled="disabled"><?php echo $detail->ItemDesc;?></textarea>
                                    </td>
                                </tr>
                                 <tr>
                                    <td align="left"><label>Qty</label></td>

                                    <td>
                                        <input type="text" id="qty" name="qty" style="width:848px;" readonly value="<?php echo $detail->ItemQty;?>" /> <b><?php echo $detail->ItemUnit;?></b>
                                    </td>
                                </tr>
                               
                                <tr>
                                    <td align="left"><label>Qty Book</label></td>

                                    <td>
                                    	
                                        <input type="text" id="txt_unit" name="txt_unit" class="easyui-numberbox" style="width:849px;" value="<?php echo $detail->ItemBooks;?>" readonly/> <b><?php echo $detail->ItemUnit;?></b>
                                        <!-- <input type="button" id="btn_unit" name="btn_unit" value="..." /> -->
                                    </td>
                                </tr>
                                <tr>
                                    <td align="left"><label>Qty On Hand</label></td>

                                    <td>
                                   		<?php
											$item_hand = $detail->ItemQty - $detail->ItemBooks;
										?>
                                        <input type="text" id="txt_unit" class="easyui-numberbox" name="txt_unit" style="width:849px;" value="<?php echo $item_hand;?>" readonly/> <b><?php echo $detail->ItemUnit;?></b>
                                        <!-- <input type="button" id="btn_unit" name="btn_unit" value="..." /> -->
                                    </td>
                                </tr>
                            </table>
                           
                    </div>					
                    
                    <div title="Custom Fields" style="padding:10px;">
                        <div style="height:250px;margin-top:5px;">
                            <table>
                                <tr>
                                    <td align="left" width="150">Merk</td>
                    
                                    <td>
                                        <input type="text" id="" name="txt_customfieldmerk" style="width:850px;" readonly value="<?php echo $detail->ItemMerk;?>"/>
                                    </td>
                                    
                                    <td></td>
                                </tr>

                                <tr>
                                    <td align="left">Design</td>
    
                                    <td>
                                        <input type="text" id="" name="txt_customfieldesign" style="width:850px;" readonly value="<?php echo $detail->ItemDesign;?>"/>
                                    </td>
                                    
                                    <td></td>
                                </tr>

                                <tr>
                                    <td align="left">Colour</td>

                                    <td>
                                        <input type="text" id="" name="txt_customfieldcolour" style="width:850px;" readonly value="<?php echo $detail->ItemColour;?>"/>
                                    </td>

                                    <td></td>
                                </tr>

                                <tr>
                                    <td align="left">Size</td>

                                    <td>
                                        <input type="text" id="" name="txt_customfieldsize" style="width:850px;" readonly value="<?php echo $detail->ItemSize;?>"/>
                                    </td>

                                    <td></td>
                                </tr>

                                <tr>
                                    <td align="left">Quality</td>

                                    <td>
                                        <input type="text" id="" name="txt_customfieldquality" style="width:850px;" readonly value="<?php echo $detail->ItemQuality;?>"/>
                                    </td>

                                    <td></td>
                                </tr>

                                <tr>
                                    <td align="left">Type</td>

                                    <td>
                                        <input type="text" id="" name="txt_customfieldtype" style="width:850px;" readonly value="<?php echo $detail->ItemType;?>"/>
                                    </td>

                                    <td></td>
                                </tr>

                                <tr>
                                    <td align="left">Shading</td>

                                    <td>
                                        <input type="text" id="" name="txt_customfieldshading" style="width:850px;" readonly value="<?php echo $detail->ItemShading;?>"/>
                                    </td>

                                    <td></td>
                                </tr>

                                <tr>
                                    <td align="left">Group</td>

                                    <td>
                                        <input type="text" id="" name="txt_customfieldgroup" style="width:850px;" readonly value="<?php echo $detail->ItemGroup;?>"/>
                                    </td>

                                    <td></td>
                                </tr>
                            </table>
                        </div>
                    </div>					
                </div>
            </form>	
        </div>	

        
    </div>
    <!-- end center view -->

    <div id="form-footer" data-options="region:'south',border:false">
        <table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0">
             <tr>
               <td align="left">
                    
               </td>
                <td align="right">                              
                     <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-help" onclick="" plain="true">Help</a>            
                </td>
             </tr>
        </table>                
    </div>	
</div>

<script>
function save_data_item(url,form_id,clear) {
	var item_type = $('#rdo_itemtype').combobox('getValue');
	var as_aset =  $('#cek_as_aset').val();
	
	if(item_type == "1" && as_aset == "0") {
		$.messager.alert('Error','Kategori Yang anda Pilih Bukan Termasuk Aset','error',function(){	
		})
	}
	
	url = base_url + url;
	$(form_id).form('submit',{
		url: url + '/insert',
		onSubmit: function(){
			return $(this).form('validate');
		},
		success: function(result){
		    var result = eval('('+result+')');
			if (result.status==true){
				$.messager.alert('Success',result.message,'info',function(){					
					location.reload();							
				});	
				
				if(clear==1){
					$(form_id).form('clear');
				}
			} 
			else {
				$.messager.show({
					title: 'Unseccessfull',
					msg: result.message,
					style:{
							right:'',
							bottom:''
					}
				});
			} 
		},
		statusCode: {
			404: function() {
			  alert("Page Not Found");
			}		
		}
	});
}
	
    function cek_as_aset(value){
        if(value == 0){
            $('#cek_as_aset').val(0);
			$('#rdo_itemtype').combobox('enable');
        }
        else{
			$('#cek_as_aset').val(1);
			$('#rdo_itemtype').combobox('select','1');
                // $('#rdo_itemtype').combobox({
					// url:'<?php echo base_url(); ?>list/items/set_aset',
					// valueField:'id',
					// textField:'text'
				// });
			$('#rdo_itemtype').combobox('disable');
        }
    } 
	
	/* function hidefixed(value){
        if(value == 1){
            $('.disableme').css('display','');		
        }
        else{
            $('.disableme').css('display','none');
        }
    } */
</script>