<script type="text/javascript">
$(document).ready(function() {   
	$('select').select2();
	$.each($(".select2-container"), function(i, n) {
        $(n).next().show().fadeTo(0, 0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
        $(n).prepend($(n).next());
        $(n).delay(500).queue(function() {
            $(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
            $(this).dequeue();
        });
    });
	//Datepicker
   jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
  	<?php if($insert): ?>
  		alertbox("Cheque saved successfully.",1);
   	<?php endif; ?>
}); 

function validate(){
	//FADHIRUL CHANGED 05/02/2015
	//if($("#unpresentedCheque").validationEngine('validate') && finanEngine('financhk'))
	if($("#unpresentedCheque").validationEngine('validate'))
		return true;
	else
		return false;
}
function chkValue(me){
	if($(me).hasClass('credit')){
		$('.debit').val(0);
	}else{
		$('.credit').val(0);
	}
}
</script>

<div id="content">                        
<div class="wrap">
<div class="head">
	<div class="info">
        <!--<h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
            <?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>-->
        <ul class="breadcrumb">
            <li><a href='<?php echo base_url(); ?>'><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
            <li><a href="<?php echo base_url(); ?>/locationtransfer"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
            <li class="active"><?php echo $this->lang->line('unpresentedChq') ?></li>
        </ul>
	</div>
	<div class="search">
		<form action="<?php echo base_url() ?>admin/search" method="post">
			<input name="search_text" type="text" placeholder="search..."/>                                
            <button type="submit"><span class="i-magnifier"></span></button>
		</form>
	</div>                        
</div><!-- head --> 
<div class="content">
	<!--Company information start-->
   	<?php //$this->load->view('layouts/rptheader'); ?>
    <!--Company information end-->
    
	<div class="wrap">        
        <div class="content">
            <div class="wrap">                 
                <div class="row-fluid">
                    <div class="span12">        
	                    <div class="block">
		        	        <div class="head">
		     					<h2><strong><?php echo $this->lang->line('unpresentedChq') ?></strong></h2>
							</div><!-- head -->
							<?php echo form_open('bankreconciliation/cheque_add',array('id'=>'unpresentedCheque')); ?>
		                    <div class="content np">    
		                        <!--Location transfer top form-->  
					            <div class="row-fluid scRow">
					                <div class="span6 scCol">           	
			                            <div class="controls-row">
			                                <div class="span4"><?php echo $this->lang->line('bank') ?>*</div>
			                                <div class="span8">
			                                    <?php
			                                    	$preselcat = '';
													$options = '<option value="null">'.$this->lang->line('pleaseSelect').'</option>';
													if (!empty($bank)){
														//$options = '<option value="null">--Select Please--</option>';
				                                        foreach($bank as $row){
				                                        	if(isset($chequeInfo) && $chequeInfo[0]->bankID==$row->ID){
				                                            	$options .='<option value="'.$row->ID.'" selected="selected" >'.$row->bankName." (".substr($row->acctCode,0,4).'-'.substr($row->acctCode,4,3).'-'.substr($row->acctCode,7).")".'</option>';
				                                        	}else{
				                                        		$options .='<option value="'.$row->ID.'" >'.$row->bankName." (".substr($row->acctCode,0,4).'-'.substr($row->acctCode,4,3).'-'.substr($row->acctCode,7).")".'</option>';
				                                        	}
				                                        }
				                                    }
			                                        $js=' class="validate[required] span10 bankID"';
			                                        echo '<select id="bankID" name="bankID" class="validate[required] span10 bankID">'.$options.'</select>';
			                                    ?>
			                                </div>                          
			                            </div> 
			                            <div class="controls-row">
					                    	<div class="span4"><?php echo $this->lang->line('transactionDate'); ?></div>
					                        <div class="input-prepend" style="margin-left:7px;">
						                        <span class="add-on"><i class="i-calendar"></i></span>
												<?php
																$data = array(
																'value' => isset($chequeInfo)?date('d-m-Y',strtotime($chequeInfo[0]->transDate)):'',
																'name' => 'transDate',
																'id' => 'transDate',
																'type' => 'text',
																'class' => 'validate[required] input-small datepicker2 financhk',);
																$js='';
																echo form_input($data, date('d-m-Y'), $js);
																
															?>       
					                        </div>
					                    </div>  
					                    <div class="controls-row">
			                                <div class="span4"><?php echo $this->lang->line('debit') ?>*</div>
			                                <div class="span8">
			                                    <?php
			                                    $data = array(
			                                        'value'=>isset($chequeInfo)?$chequeInfo[0]->debit:'',
			                                        'name'=>'debit',
			                                        'id'=>'debit',
			                                        'class'=>'debit input-medium validate[required]',
			                                        'onfocus'=>'chkValue(this)'); 
			                                    echo form_input($data, '');//set_value($formNo));
			                                    ?>
			                                </div>                          
			                            </div>                        			                        
					                </div>
					                <div class="span6 scCol"> 
			                            <div class="controls-row">
			                                <div class="span4"><?php echo $this->lang->line('transNo') ?>*</div>
			                                <div class="span8">
			                                    <?php
			                                    $data = array(
			                                        'value'=>isset($chequeInfo)?$chequeInfo[0]->transNo:'',
			                                        'name'=>'transNo',
			                                        'id'=>'transNo',
			                                        'class'=>'input-medium validate[required]',); 
			                                    echo form_input($data, '');//set_value($formNo));
			                                    ?>
			                                </div>                       
			                            </div>
			                            <div class="controls-row">
			                                <div class="span4"><?php echo $this->lang->line('referenceNo') ?>*</div>
			                                <div class="span8">
			                                    <?php
			                                    $data = array(
			                                    	'value'=>isset($chequeInfo)?$chequeInfo[0]->referenceNo:'',
			                                        'name'=>'referenceNo',
			                                        'id'=>'referenceNo',
			                                        'class'=>'input-medium validate[required]',); 
			                                    echo form_input($data, '');//set_value($formNo));
			                                    ?>
			                                </div>                       
			                            </div>
			                            <div class="controls-row" style="padding:10px 10px 8px;">
					                    	<div class="span4"><?php echo $this->lang->line('credit'); ?>*</div>
					                        <div class="span8">
			                                    <?php
			                                    $data = array(
			                                        'value'=>isset($chequeInfo)?$chequeInfo[0]->credit:'',
			                                        'name'=>'credit',
			                                        'id'=>'credit',
			                                        'class'=>'credit chkinput-medium validate[required]',
			                                        'onfocus'=>'chkValue(this)'
			                                        ); 
			                                    echo form_input($data, '');//set_value($formNo));
			                                    ?>
			                                </div> 
					                    </div>			                        	    			          
					                </div>
					            </div>
					            <div class="row-fluid scRow">
					            	<div class="span10 scCol"> 
					                	<div class="controls-row span12" style="padding:10px 10px 8px;">
					                    	<div class="span2"><?php echo $this->lang->line('description'); ?>*</div>
					                        <div class="span10">
			                                    <?php
			                                    $data = array(
			                                        'value'=>isset($chequeInfo)?$chequeInfo[0]->desc:'',
			                                        'name'=>'desc',
			                                        'id'=>'desc',
			                                        'col'=>20,
			                                        'row'=>3,
			                                        'class'=>'span10 input-medium validate[required]',); 
			                                    echo form_textarea($data, '');//set_value($formNo));
			                                    ?>
			                                </div> 
					                    </div>
					                </div>
					            </div>
					            <div class="footer">
					            	<div class="side fr">
					                	<div class="btn-group">
					                		<input type="hidden" name="chequeID" value="<?php echo isset($chequeInfo)?$chequeInfo[0]->ID:'0'; ?>">
					                        <input type="submit" name="mysubmit" value="<?php echo isset($chequeInfo)?"Update":"Submit"; ?>" 
											onclick="return validate();" class="btn-form btn-success-form">
					                    </div>
					                </div>
					            </div>
					        </div>
					        <?php echo form_close(); ?>
	                    </div><!-- span12 -->
                    </div>
                </div><!-- row-fluid -->	
            </div><!-- wrap -->
        </div><!-- content -->
	</div>
</div></div></div></div>
