<!--
Author 		  : Wahyu
Last update   : 02-09-2014
Desc          : 
-->

<?php
	//---------Untuk privellege jika dia ada tombol save----------
	if($group_user->AddPrivillage == 1){
		$cek_autority_add 		= "";
	}
	else{
		$cek_autority_add 		= "disabled";
	}
	
	if($group_user->DeletePrivillage == 1){
		$cek_autority_delete 		= "";
	}
	else{
		$cek_autority_delete 		= "disabled";
	}
	
	if($group_user->EditPrivillage == 1){
		$cek_autority_edit 		= "";
	}
	else{
		$cek_autority_edit 		= "disabled";
	}
	//-------------end----------------------------
?>


<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:false" style="height:30px">
        <div style="padding:2px">
            <a href="#" class="easyui-linkbutton" id="new-linkbutton" data-options="plain:true,iconCls:'icon-add'" onClick="parent.tab_add('New Term','<?=$menu_link?>','icon-add','add');" <?php echo $cek_autority_add;?>>New</a>
        <a href="#" class="easyui-linkbutton" id="edit-linkbutton" data-options="plain:true,iconCls:'icon-edit'" onclick="parent.tab_edit('Edit Terms', '<?php echo $menu_link; ?>', 'icon-edit', 'edit', $('#grid').datagrid('getSelected').TermspaymentID)" <?php echo $cek_autority_edit;?>>Edit</a>
        <a href="#" class="easyui-linkbutton" id="suspend-linkbutton" data-options="plain:true,iconCls:'icon-remove'" onclick="suspend_data_new('L',1,'<?php echo $menu_link; ?>', $('#grid').datagrid('getSelected').TermspaymentID,'#grid');" <?php echo $cek_autority_delete;?>>Suspend</a>
        <a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="$('#grid').datagrid('reload',{});">Refresh</a>
        </div>
    </div>
    
    
    <div id="west-panel" data-options="region:'west',split:true,border:true" title="Filter" style="width:190px;background-color:#CCCCFF;">
        <div style="padding:5px">
            <table width="100%" cellpadding="0" cellspacing="0"  id="tab_transstatus">
            <tr>
                <td width="190" align="left" style="padding-bottom:8px;">
                    <b>Find</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<input id="txt_no" name="txt_no" placeholder="< Net Due In >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC;">
                </td>
            </tr>
            <tr>
                <td align="left">
                	<input id="txt_desc" name="txt_desc" placeholder="< Desc >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC;">
                </td>
            </tr>
            <tr><td><div class="tr-divider"></div></td></tr>
            <tr>
            	<td height="38"><div style="float:right;"><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onClick="location.reload();" >Reset</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onClick="searching_data();" >Search</a></div></td>
            </tr>
            
<!--            
            copy dari sini untuk by status-------------------------------------------
            <tr>
                <td width="283" align="left" colspan="2">
                    <input type="checkbox" name="chk_TransStatus" value="1" style="margin-left:0px;" checked /> Active
                </td>
            </tr>

            <tr>
                <td width="283" align="left" colspan="2">
                    <input type="checkbox" name="chk_TransStatus" value="3" style="margin-left:0px;" /> Suspended
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                  <input type="checkbox" name="chk_TransStatus" value="4" style="margin-left:0px;"  /> Need App. Mgr.
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                  <input type="checkbox" name="chk_TransStatus" value="5" style="margin-left:0px;"  /> Need App. Dir.
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                    <input type="checkbox" name="chk_TransStatus" value="6" style="margin-left:0px;" /> App. Dir & Mgr
                </td>
            </tr>
            end------------------------------------------------------
            ----ini separator-
            <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
            end------------------
            
            copy dari sini untuk button reset dan search
            <tr>
            	<td height="38"><div style="float:right;"><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onClick="location.reload();" >Reset</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onClick="searching_data();" >Search</a></div></td>
            </tr>
            end------------------------
            -->
            </table>
        </div>
    </div>
    
    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
			<!-- gaya table baru di grid -->
			<table id="grid" 
        	title="" iconCls="icon-save" 
            singleSelect="true" rowNumbers="true" 
            pageSize="50" 
            fitColumns="true" remoteSort="false" 
			url="<?=base_url($menu_link.'/ajax')?>" 
            style="width:auto;height:560px" 
            data-options = "border:false,view:scrollview,autoRowheight:false"
    >
        <thead>
        <tr>
            <th halign="center" width="100" field="TermspaymentID" align="center" hidden="true">Terms Payment ID</th>
<!--            <th halign="center" width="200" field="PaidWithin" align="center" sortable="true">Paid With in</th>
            <th halign="center" width="100" field="DiscountPercent" align="center" sortable="true">Discount (%)</th>-->
            <th halign="center" width="100" field="NetDueIn" align="center" sortable="true">Net Due In</th>			
            <th halign="center" width="100" field="TermDesc" align="center">Description</th>
        </tr>
        </thead>
    </table>
    </div>
</div>


<script type="text/javascript">
$(document).ready(function(){
	
	var status_privelage_delete = '<?php echo $group_user->DeletePrivillage;?>';
	var status_privelage_edit 	= '<?php echo $group_user->EditPrivillage;?>';
	
	$('#grid').datagrid({
		onDblClickRow:function(){
			if(status_privelage_edit == 1){
				parent.tab_edit('Edit Terms', '<?php echo $menu_link; ?>', 'icon-edit', 'edit', $('#grid').datagrid('getSelected').TermspaymentID);
			}
		},
		onClickRow:function(index,value){
			if(value.Status !='Need App. Dir & Mgr' || value.Status !='App. Limit' || value.Status != 'Active'){
				$('#suspend-linkbutton').linkbutton('enable');
			}
			else{
				if(status_privelage_delete == 1){
					$('#suspend-linkbutton').linkbutton('enable');
				}
				else{
					$('#suspend-linkbutton').linkbutton('disable');
				}
				
				if(status_privelage_edit == 1){
					$('#edit-linkbutton').linkbutton('enable');
				}
				else{
					$('#edit-linkbutton').linkbutton('disable');
				}
			}
		}
	});
});

function searching_data(){
		var txt_no 		= $('#txt_no').val();
		var txt_desc 	= $('#txt_desc').val();
		
		
		
		$('#grid').datagrid('load',{
			NetDueIn 	: txt_no,
			TermDesc 	: txt_desc
		});	
}
</script>