<!---- 
    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">
	<?php foreach($detail as $row) : ?>
    <!-- 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">
                    	<input type="checkbox" name="chk_suspended" id="chk_suspended" value="3" onClick="suspend(1)" style="margin-top:0px;margin-right:1px;" <?php if($row->TransStatus == 3){echo"checked";} ?> <?=(!in_array($row->TransStatus, array(5,1))?"disabled":"")?>/>
                        <span style="display:inline-block;margin-top:2px;<?=(($row->TransStatus==3)?'color:gray;':'')?>"><?=(($row->TransStatus!=3)?"Suspend":"Suspend")?> Transaction</span>
                        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="location.reload();">Refresh</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">
     	<?php if($row->TransStatus==3){ ?>
             <div class="blanket"></div>
             <div class="suspend-box"><b>Suspended</b></div>
        <?php
        }
        ?>
        <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" value="<?php echo $row->DepriciateRate; ?>"/>
				<input type="hidden" name="id" id="txt_no" value="<?php echo $row->FixedAssetTypeID; ?>" />
                <input type="hidden" name="txt_asset_type_hidden" value="<?php echo $row->FixedAssetType; ?>" />
                <input type="hidden" name="text_trans_status" value="<?php echo $row->TransStatus; ?>" />
                <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" value="<?php echo $row->FixedAssetType; ?>" 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" <?=($row->TransStatus==3)?'readonly':''?>
                            data-options="
                            	value:'<?php echo $row->DepMethodID; ?>',
                                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" value="<?php echo $row->EstimatedLife; ?>" onkeyup="set_depreciation_rate(this.value);" <?=($row->TransStatus==3)?'readonly':''?>/>  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" class="easyui-validatebox" size="4" value="<?php echo $row->DepriciateRate; ?>"  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" value="<?php echo $row->InitialCategory; ?>" id="txt_name_initial" class="easyui-validatebox td_input_min" data-options="required:true" style="width:55px;;text-transform:uppercase" MAXLENGTH="4" <?=($row->TransStatus==3)?'readonly':''?>/>
                    </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;"><?php echo $row->FixedAssetDesc; ?></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,
                                value:'<?php echo $row->AccumAccountNumber;?>',
                                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',
                                value:'<?php echo $row->ExpenseAccountNumber;?>',
                                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>
     <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 app-button" iconCls="icon-ok" onclick="app_dir()" <?=($row->TransStatus==5 and $this->session->userdata('jobtitle_status')==0)?'':'disabled'?>>App. Dir</a>		
                    <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="save();" <?=(in_array($row->TransStatus,array(3)))?'disabled':''?> <?php echo $cek_autority_save;?>>Save</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton  form-button" iconCls="icon-cancel" onclick="<?=($this->session->userdata('jobtitle_status')==0)?'suspend(2)':'parent.tab_close(\'tt\')'?>" <?=($this->session->userdata('jobtitle_status')==0 && !in_array($row->TransStatus,array(1,4,7)))?'disabled':''?>><?=($this->session->userdata('jobtitle_status')==0)?'Cancel':'Close'?></a>
                </td>
            </tr>
        </table>
    </div>
    <?php endforeach; ?>
</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 suspend(type){
	suspend_data_new('F',type,'<?php echo $menu_link?>',$('#txt_no').val(),'Fixed Asset Type');
}

function app_dir(){
	custom_data('<?=$menu_link?>/approval_dir','#fm_fixed_asset_type');
}

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