<!---- 
    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";
				}
				
				if($group_user->DeletePrivillage == 1){
					$cek_autority_delete  = "";
				}
				else{
					$cek_autority_delete 	= "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 align="left">
                    <input type="checkbox" name="chk_suspended" id="chk_suspended" value="1" onClick="suspend(1)" style="margin-top:0px;margin-right:1px;" <?php if($row->TransStatus == 3) { echo " disabled checked"; } ?> <?php echo $cek_autority_delete;?> />
                    <span style="display:inline-block;margin-top:2px;<?=(($row->TransStatus==3)?'color:gray;':'')?>"><?=(($row->TransStatus!=3)?"Suspend":"Un-Suspend")?> Item Categories</span>
                	<a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="location.reload();">Refresh</a>
                </td>
                <td height="25" align="right" valign="middle">
                    <span class="form-title" style="margin-left:7px;">
                        <?=$menu_label?>
                    </span>
                </td>
            </tr>
            </table>		     	
        </div>			
    </div>
    <!-- End of top view -->
    
    <?php 
		if(($row->TransStatus == 3) || ($row->TransStatus == 4) ||($row->TransStatus == 5)) {
			$read_only_categori_name = "readonly";
			$read_only_desc_name = "readonly";
		} 
		else {
			$read_only_categori_name = "";
			$read_only_desc_name = "";
		}
	?>
    
    <div id="form-body" data-options="region:'center',border:false">
		<div id="form-wrapper" class="easyui-panel" style="width:1180%;height:526px;padding:5px;" fit='true'>
        	<form id="fm_item_categories" name="fm_item_categories" method="post">
            	<input type="hidden" name="id" id="id" value="<?php echo $row->ItemCategoryID; ?>" />
                <input type="hidden" name="trans_status" id="trans_status" value="<?php echo $row->TransStatus; ?>" />
                <input type="hidden" name="AssetStatus" value="<?php echo $row->AssetStatus; ?>" />
                <input type="hidden" name="kategori_name" value="<?php echo $row->ItemCategoryName; ?>" />
                
            	<table class="form-detail" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                    <td><b>Item Category Name</b></td>
                    <td width="850" style="padding:1px 0px 2px;">
                        <input type="text" name="txt_name" class="easyui-validatebox td_input_min" data-options="required:true" value="<?php echo $row->ItemCategoryName; ?>" style="width:850px;text-transform:uppercase" <?php echo $read_only_categori_name;?>/>
                    </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" value="<?php echo $row->InitialCategory; ?>" style="width:850px;text-transform:uppercase" MAXLENGTH="4" <?php echo $read_only_categori_name;?>/>
                    </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 $read_only_desc_name;?>><?php echo $row->ItemCategoryDesc; ?></textarea>
                    </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="custom_data('<?php echo $menu_link?>/approval_dir','#fm_item_categories');" <?=($this->session->userdata("jobtitle_status") != 0 || !in_array($row->TransStatus,array(5,6)))?'disabled':''?>>App Dir</a>		
                	  <!--<a href="javascript:void(0)" class="easyui-linkbutton form-button app-button" iconCls="icon-ok" onclick="custom_data('<?php echo $menu_link?>/approval_mgr','#fm_item_categories');" <?=($this->session->userdata("jobtitle_status") != 1 || !in_array($row->TransStatus,array(4,6)))?'disabled':''?>>App Mgr</a>	-->		
                      <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="save();" <?=(!in_array($row->TransStatus,array(1,5)))?'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,5,7)))?'disabled':''?>><?=($this->session->userdata('jobtitle_status')==0)?'Cancel':'Close'?></a>
	   		
                </td>
             </tr>
         </table>
    </div>
    <?php endforeach; ?>
</div>
<!-- Pembatas huruf / Muslih -->
<script type='text/javascript'>
function save() {
	var name_initial = $('#txt_name_initial').val();
	var leng = name_initial.length;
	if(leng == 4){
		edit_data('<?php echo $menu_link?>','#fm_item_categories');
	}
	else{
	$.messager.alert('Error','Name initial tidak boleh lebih dan kurang dari (4) karakter','error',function(){	
		});
	}
}

function suspend(type){
	suspend_data_new_master('F',type,'<?=$menu_link?>',$('#id').val(),'Item Kategori');
}
</script>
<!-- End Muslih -->