<!---- 
    Author 	: Herpan
    Tanggal : 12-08-2014	
    Revisi 	:
-->

<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">
							<a href="#" class="easyui-linkbutton" iconCls="icon-document" plain="true" onclick="location.reload()">New</a>
							<a href="#" class="easyui-linkbutton" iconCls="icon-journal" plain="true" onClick="parent.tab_edit('Journal Sweep Bank', '<?php echo $menu_link; ?>', 'icon-bank', 'to_journal',$('#txt_swapbank_no').val())">Journal</a>
						
                        </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">
    <?php if($detail->TransStatus == 3){ ?>
    	 <div class="blanket"></div>
         <div class="suspend-box"><b>Suspended</b></div>
	<?php
	}else if($detail->TransStatus == 2){
	?>
    	<div class="blanket"></div>
        <div class="finished-box"><b>Finished</b></div>
	<?php
	}
	?>
		<div id="form-wrapper" class="easyui-panel"  style="width:1180%;padding:5px;" fit='true'>
			<form id="fm_swift_bank" name="fm_swift_bank" method="post">
            <input name="id" id="id" value="<?php echo $detail->BSweepNumber; ?>" type="hidden" style="width:100px" />
				<table cellpadding="0" cellspacing="1" width="100%" height="100%" border="0">				    
					<tr>
						 <td valign="middle" height="24" align="left"><label>Transfer From</label></td>
						 <td valign="middle" align="left">
						 <select name="cmb_bank_from" editable='false' class="easyui-combogrid" id="cmb_bank_from" required="required" style="width:259px; height:18px;" <?php if($detail->TransStatus == 3 || $detail->TransStatus == 2){ echo "disabled";} else if($detail->AppLevel2Status ==1 || $detail->AppLevel1Status == 1){  echo "disabled";}?> data-options="
								value:'<?php echo $detail->BankTransfer; ?>', 
								panelWidth: 300,
								idField: 'AccountNumber',
								textField: 'AccountName',
								url: '<?php echo base_url(); ?><?php echo"activities/swift_bank"; ?>/get_akun_bank_cabang/<?php echo $detail->BranchCode; ?>',   
								columns: [[
								{field:'AccountName',title:'Account Name',width:190}
								]],
								fitColumns: true
								">
								</select>	
						 </td>
						 <td>
							 <table cellpadding="0" cellspacing="1" width="100%" border="0">
								<tr>
									  <td width="80" align="center" valign="middle" bgcolor="#333399"><label><span style="color: #fff">Sweep Bank No.</span></label></td>
							    </tr>
								<tr>
									  <td valign="top" align="left">
										 <input type="text" name="txt_swapbank_no" value="<?php echo $detail->BSweepNumber; ?>" id="txt_swapbank_no" class="easyui-validatebox" style="width:150px;" readonly  required="required" <?php if($detail->TransStatus == 3 || $detail->TransStatus == 2){ echo "disabled";} else if($detail->AppLevel2Status ==1 || $detail->AppLevel1Status == 1){  echo "disabled";}?>/>
									  </td>
								</tr>
							</table>
						 </td>
				    </tr>
					<tr>
						<td valign="top" height="24" width="80" align="left">
							<label>Transfer To</label></td>
						<td valign="top" width="998" align="left">
							<select name="cmb_bank_to" editable='false' class="easyui-combogrid" id="cmb_bank_to" required="required" style="width:259px; height:18px;" <?php if($detail->TransStatus == 3 || $detail->TransStatus == 2){ echo "disabled";} else if($detail->AppLevel2Status ==1 || $detail->AppLevel1Status == 1){  echo "disabled";}?> data-options="
							value:'<?php echo $detail->BankReceipt; ?>', 
							panelWidth: 300,
							idField: 'AccountNumber',
							textField: 'AccountName',
							url: '<?php echo base_url(); ?><?php echo"activities/swift_bank"; ?>/get_akun_bank/<?php echo $detail->CompRecpCode; ?>',                
							columns: [[
							{field:'AccountName',title:'Account Name',width:190}
							]],
							fitColumns: true
							">
							</select>	
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td valign="top" height="26" align="left">
							<label>Date</label>
						</td>
						<td valign="top" align="left">
							<input name="txt_date" id="txt_date" type="text" value="<?php echo date("d-m-Y", strtotime($detail->BSweepDate)); ?>" class="easyui-datebox" style="width:80px;" required="required" readonly/>
					  </td>
					  <td>&nbsp;</td>
					</tr>
					<tr>
						<td valign="top" height="37" align="left">
							<label>Memo</label>
						</td>
						<td height="37" valign="top" align="left">
							<textarea class="textbox" style="resize:none;" name="txa_memo" id="txa_memo" cols="50" rows="2" <?php if($detail->TransStatus == 3 || $detail->TransStatus == 2){ echo "disabled";} else if($detail->AppLevel2Status ==1 || $detail->AppLevel1Status == 1){  echo "disabled";}?>><?php echo $detail->BSweepDesc; ?></textarea>
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
					  <td valign="top" height="23" align="left"><label>Amount</label></td>
					  <td valign="top" align="left">
						<input name="txt_amount_rp" id="txt_amount_rp" type="text" value="<?php echo $detail->BSweepAmount; ?>" onkeyup="cek_amount(this.value)" class="easyui-validatebox currency" style="width:100px;height:18px" required="required" <?php if($detail->TransStatus == 3 || $detail->TransStatus == 2){ echo "disabled";} else if($detail->AppLevel2Status ==1 || $detail->AppLevel1Status == 1){  echo "disabled";}?>/>
						<!--<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-calculator',size:'small'" onClick="">-->
						<input name="txt_amount" id="txt_amount" type="hidden" value="<?php echo $detail->BSweepAmount; ?>" />
					  </td>
					  <td>&nbsp;</td>
					</tr>
					<tr>
						<td valign="middle" height="21" align="left">
							<label>Suspended</label>
						</td>
						<td align="left" valign="middle">
							<input type="checkbox" name="chk_status" id="chk_status" onClick="suspend(1)" class="easyui-validatebox" value="<?php if($detail->TransStatus == 3 || $detail->TransStatus ==4 || $detail->TransStatus ==5 || $detail->TransStatus ==6){ echo"3"; } else { echo"6"; } ?>"  <?php if($detail->TransStatus == 3){ echo"checked='checked'"; echo"disabled"; } else if($detail->AppLevel2Status ==1 || $detail->AppLevel1Status == 1){  echo "disabled";} ?> /> 
						</td>
					</tr>	
				</table>				  
			</form>
		</div>
		
    </div>
    <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>
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button app-button" iconCls="icon-ok" 
                      <?php 
                            if($detail->TransStatus == 3 || $detail->TransStatus == 2 || date('Y-m-d') < date('Y-m-d', strtotime($detail->BSweepDate))){ echo "disabled"; }
                            else if($this->session->userdata("jobtitle_status") == 0 &&  $detail->AppLevel2Status !=1){ echo " enabled "; } 
                            else { echo"disabled"; } 
                      ?>
                      onclick="app_dir();"> App. Dir</a>
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button app-button" iconCls="icon-ok"
                     <?php 
                            if($detail->TransStatus == 3 || $detail->TransStatus == 2 || date('d-m-Y') < date('d-m-Y', strtotime($detail->BSweepDate))){ echo "disabled"; }
                            else if($this->session->userdata("jobtitle_status") == 1 &&  $detail->AppLevel1Status !=1){ echo " enabled "; } 
                            else { echo"disabled"; } 
                      ?>
                     onclick="app_mgr();"> App. Mgr</a>
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="save_data()" <?php if($detail->TransStatus == 3 || $detail->TransStatus == 2){ echo "disabled";} else if( $detail->AppLevel1Status ==1 ){ echo "disabled";} else if( $detail->AppLevel2Status ==1 ){ echo "disabled";}?> >Save</a> 								
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-print" onclick="parent.tab_add('Print <?php echo $menu_label; ?>', '<?php echo"list/swift_bank"; ?>', 'icon-bank', 'to_preview')">Preview & Print</a>   
                     <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="<?=($this->session->userdata('jobtitle')=='DIR')?'suspend(2)':'parent.tab_close(\'tt\')'?>" <?=(in_array($detail->TransStatus,array(3,9)) || $detail->AppLevel2Status==1)?'disabled':''?>>Cancel</a>	
                </td>
             </tr>
        </table>				
    </div>	
</div>

<script type="text/javascript">	
$(document).ready(function(){
	$('#txt_date').datebox('setValue', '<?php echo date("d-m-Y", strtotime($detail->BSweepDate));?>');
});

function app_mgr(){
	$.messager.confirm('Confirm','Setelah Di Approve Transaksi Akan Masuk Kedalam Coa, Silahkan Cek Kembali Transaksi Ini',function(r){
			if(r){
		  		custom_data('<?php echo"activities/swift_bank"; ?>/approval2','#fm_swift_bank');
		  	}
		});
}

function app_dir(){
	$.messager.confirm('Confirm','Setelah Di Approve Transaksi Akan Masuk Kedalam Coa, Silahkan Cek Kembali Transaksi Ini',function(r){
			if(r){
		  		custom_data('<?php echo"activities/swift_bank"; ?>/approval1','#fm_swift_bank');
		  	}
		});
	
}
function save_data(){
	var total = $("#txt_amount").val();
	if(total < 1){
		$.messager.show({
			title: 'Unseccessfull',
			msg: 'Amount Tidak Boleh Nol',
			style:{
					right:'',
					bottom:''
			}
		});
	} else {
		//$("#fm_swift_bank").submit();
		$.messager.confirm('Confirm','Pastikan Semua Data Transaksi Sudah Terisi Benar',function(r){
			if(r){
		  		edit_data('<?php echo"$menu_link"; ?>', '#fm_swift_bank');
		  	}
		});
		
	}
}
function cek_amount(value){
	var total = toAngka(value);
	$("#txt_amount").val(total);
}

function suspend(type){
	suspend_data_new('F', type, '<?=$menu_link?>', $('#txt_swapbank_no').val(), 'Sweep Bank');
}
</script>