<!---- 
    Author 	: Herpan
    Tanggal : 12-08-2014	
    Revisi 	:
-->
	
	<?php
			//---------Untuk privellege jika dia ada tombol save----------
			if($group_user->SavePrivillage == 1){
				$cek_autority_save 		= "";
			}
			else{
				$cek_autority_save 		= "disabled";
			}
			//-------------end----------------------------
	?>
	
<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 height="26" align="left" valign="middle">
                    	<a href="#" class="easyui-linkbutton" iconCls="icon-document" plain="true" onclick="parent.tab_add('Add New Fixed Asset Type','<?=$menu_link?>','icon-add','add')">New</a>
                        <!--<input type="checkbox" id="chk_suspended" name="chk_suspended" value="1" /> Suspended-->
                    </td>
                    <td 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;padding:5px;height:524px;" fit="true">
            <form id="fm_fixed_asset_type" name="fm_fixed_asset_type" method="post">
				<input type="hidden" id="txt_depreciation_rate" name="txt_depreciation_rate" />
                
                <table class="form-detail" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                    <td><b>Fixed Asset Type</b></td>
                    <td width="850" style="padding:1px 0px 2px;">
                        <input type="text" name="txt_fixedassettype_name" class="easyui-validatebox" data-options="required:true" style="width:850px;text-transform:uppercase" />
                    </td>
                </tr>
                <tr>
                    <td><b>Depreciation Method</b></td>
                    <td style="padding:1px 0px 2px;">
                        <select class="combo-grid" name="cmb_depreciate_method" style="height:22px;width:852px;" required="required" editable="true"
                            data-options="
                                panelWidth: 852,
                                idField: 'DepreciateID',
                                textField: 'DepreciateName',
                                url: '<?php echo base_url(); ?>custom/get_data/depreciate_method',
                                method: 'get',
                                columns: [[
                                {field:'DepreciateName',title:'Depreciate Method Name',width:190}
                                ]],
                                fitColumns: true
                            "
                        >
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><b>Estimated Life</b></td>
                    <td style="padding:1px 0px 2px;">
						<input class="easyui-numberbox easyui-validatebox" type="text" name="txt_estimate_life" data-options="required:true" size="4" onkeyup="set_depreciation_rate(this.value);" />  Month
                    </td>
                </tr>
                <tr>
                    <td><b>Depreciation Rate</b></td>
                    <td style="padding:1px 0px 2px;">
						<input type="text" id="depreciation_rate" name="depreciation_rate" data-options="min:0,precision:2,decimalSeparator:',',groupSeparator:'.'" class="easyui-validatebox" size="4" readonly /> % / Year
                    </td>
                </tr>
                <tr>
                    <td><b>Name Initial</b></td>
                    <td width="850" style="padding:1px 0px 2px;">
                        <input type="text" name="txt_name_initial" id="txt_name_initial" class="easyui-validatebox td_input_min" data-options="required:true" style="width:55px;;text-transform:uppercase" MAXLENGTH="4"/>
                    </td>
                </tr>
                <tr>
                    <td valign="top" style="padding-top:4px;"><b>Description</b></td>
                    <td style="padding:1px 0px 2px;">
						<textarea name="txt_desc" rows="4" style="width:846px;resize:none;white-space:normal;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td><b>Akun Penyusutan</b></td>
                    <td style="padding:1px 0px 2px;">
                        <select class="combo-grid" name="cmb_akun_penyusutan" id="cmb_akun_penyusutan" style="height:22px;width:852px;" required="required" editable="true"
                            data-options="
                                panelWidth: 852,
                                idField: 'AccountNumber',
                                textField: 'AccountName',
                                url: '<?php echo base_url(); ?>list/fixed_asset_type/akun_penyusutan',
                                method: 'get',
                                columns: [[
                                {field:'AccountNumber',title:'Account Number',width:190},
                                {field:'AccountName',title:'Account Name',width:190}
                                ]],
                                fitColumns: true
                            "
                        >
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><b>Biaya Penyusutan</b></td>
                    <td style="padding:1px 0px 2px;">
                        <select class="combo-grid" name="cmb_biaya_penyusutan" id="cmb_biaya_penyusutan" style="height:22px;width:852px;" required="required" editable="true"
                            data-options="
                                panelWidth: 852,
                                idField: 'AccountNumber',
                                textField: 'AccountName',
                                url: '<?php echo base_url(); ?>list/fixed_asset_type/biaya_penyusutan',
                                method: 'get',
                                columns: [[
                                {field:'AccountNumber',title:'Account Number',width:190},
                                {field:'AccountName',title:'Account Name',width:190}
                                ]],
                                fitColumns: true
                            "
                        >
                        </select>
                    </td>
                </tr>
                </table>
            </form>
    	</div>
        
        <div id="form-footer">
			 
		</div>	
    </div>
    <div id="form-footer" data-options="region:'south',border:false">
    	<table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td>&nbsp;</td>
                <td align="right">
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-help" onclick="" plain="true">Help</a>			
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="save();" <?php echo $cek_autority_save;?>>Save</a>
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="">Cancel</a>	
                </td>
            </tr>
        </table>
    </div>
</div>

<script type="text/javascript">
function set_depreciation_rate(value) {
	var rate = 0;
	var pembagi = parseInt(value) / 12;
	
	if(isNaN(pembagi)) {
		rate = 0;
	}
	else {
		rate = 100 / parseFloat(pembagi);
	}
	
	$('#depreciation_rate').val(rate);
	$('#txt_depreciation_rate').val(rate);
}

function save() {
	var name_initial = $('#txt_name_initial').val();
	var leng = name_initial.length;
	if(leng == 4){
		save_data('<?php echo $menu_link?>','#fm_fixed_asset_type', 1);
	}
	else{
	$.messager.alert('Error','Name initial tidak boleh lebih dan kurang dari (4) karakter','error',function(){	
		});
	}
}
</script>