<script>
$(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();
            });
        });	
//	$('#acctCodel').select2();savedetails
	jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
			});

	function changeList(obj){
		var id = obj.value;
		$.ajax({
			type: "POST",
			url: "<?php base_url()?>../setting/getState/",
			data: "region="+id,
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
					items.push('<option>-Please Select-</option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].fldid+'">'
						+ content.message[i].fldname + '</option>');
					}
					jQuery("#bankStateID").empty();
					jQuery("#bankStateID").append(items.join('</br>'));
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
			}
		});
		return false;
	}
</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 $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                    <li><a href="#"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                    <li class="active"><?php echo $this->lang->line('title') ?></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">
           <div class="row-fluid">
                <div class="span12">
					<?php
						$hidden = array('order_time' => date('Y-m-d H-i-s'));
						if ($bankmaster)
							$hidden['ID'] = $bankmaster->ID;
							$attrib = array('id' => 'validate');
						echo form_open('', $attrib, $hidden);
                    ?>
					<div class="block">
						<div class="head">
							<h2><?php echo $this->lang->line('title') ?></h2>
								<ul class="buttons">                                            
									<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
								</ul>   
							<div class="side fr">
								<button class="btn-form btn-danger-form" onClick="clear_form('#validate');" type="button"><?php echo $this->lang->line('clearForm') ?></button>
							</div>						
						</div>
						
						<div class="content np"> <!-- Content 1 -->   
                            <div class="controls-row"> <!-- row 1  -->
								<div class="span2"><?php echo $this->lang->line('bankName') ?></div>
								<div class="span10">
									<?php
										$data = array(
										'name'=>'bankName', 
										'id'=>'bankName', 									
										'class'=>'span8 validate[required,maxSize[128]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->bankName); 
										}else{
											echo form_input($data, set_value('bankName')); 
										}                       
									?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 2  -->
								<div class="span2"><?php echo $this->lang->line('bankShortName') ?></div>
								<div class="span10">
									<?php 								
										$data = array(
										'name'=>'bankShortName', 
										'id'=>'bankShortName', 
										'class'=>'span4 validate[required,maxSize[8]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->bankShortName); 
										}else{
											echo form_input($data, set_value('bankShortName')); 
										}                      
									?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 3  -->
								<div class="span2"><?php echo $this->lang->line('branch') ?></div>
								<div class="span10">
									<?php 								
										$data = array(
										'name'=>'branch', 
										'id'=>'branch', 
										'class'=>'span4 validate[required,maxSize[64]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->branch); 
										}else{
											echo form_input($data, set_value('branch')); 
										}                       
									?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 4  -->
								<div class="span2"><?php echo $this->lang->line('bankAccountNo') ?></div>
								<div class="span10">
									<?php 								
										$data = array(
										'name'=>'bankAccountNo', 
										'id'=>'bankAccountNo', 
										'class'=>'span4 validate[required,maxSize[32]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->bankAccountNo); 
										}else{
											echo form_input($data, set_value('bankAccountNo')); 
										}                       
									?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 5  -->
								<div class="span2"><?php echo $this->lang->line('currentBalance') ?></div>
								<div class="span10">
									<?php 								
										$data = array(
										'name'=>'currentBalance', 
										'id'=>'currentBalance', 
										'class'=>'span4 validate[required,maxSize[128]]',); 
										if($bankmaster){		
											echo form_input($data, 'Hide'); //$bankmaster->currentBalance); 
										}else{
											echo form_input($data, set_value('currentBalance')); 
										}                       
									?> 
								</div>
							</div>						
						</div><!-- End Content 1-->						
					</div> <!-- Block-->
					
					<div class="block">
						<div class="head">
							<h2><?php echo $this->lang->line('addressinfo') ?></h2>
							<ul class="buttons">                                            
								<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
							</ul>                                         
						</div>
						<div class="content np"> <!-- Content 2 -->   
							<div class="controls-row"> <!-- row 1 -->
								<div class="span2"><?php echo $this->lang->line('address') ?></div>
								<div class="span8">
									<?php
									$data = array(
										'name'=>'line1', 
										'id'=>'line1', 									
										'class'=>'span12 validate[maxSize[128]]',); 
									if($bankmaster){		
										echo form_input($data, $bankmaster->line1); 
									}else{
										echo form_input($data, set_value('line1')); 
									}                       
									?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 2 -->
								<div class="span2">&nbsp;</div>
								<div class="span8">
									<?php
										$data = array(
											'name'=>'line2', 
											'id'=>'line2', 									
											'class'=>'span12 validate[maxSize[128]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->line2); 
										}else{
											echo form_input($data, set_value('line2')); 
										}                   
									?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 3 -->
								<div class="span2">&nbsp;</div>
								<div class="span8">
									<?php
										$data = array(
										'name'=>'line3', 
										'id'=>'line3', 									
										'class'=>'span12 validate[maxSize[128]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->line3); 
										}else{
											echo form_input($data, set_value('line3')); 
										}                       ?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 4 -->
								<div class="span2"><?php echo $this->lang->line('city') ?></div>
								<div class="span4">
									<?php
										$data = array(
										'name'=>'city', 
										'id'=>'city', 									
										'class'=>'span12',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->city); 
										}else{
											echo form_input($data, set_value('city')); 
											}                       ?>         
								</div>
								<div class="span1" TAR><?php echo $this->lang->line('postCode') ?></div>
								<div class="span3">
									<?php
									$data = array(
										'name'=>'PostCode', 
										'id'=>'PostCode', 									
										'class'=>'span12 validate[minSize[5],maxSize[5]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->PostCode); 
										}else{
											echo form_input($data, set_value('PostCode')); 
										}                       ?> 
								</div>
							</div>
							<div class="controls-row"> <!-- row 5 -->
								<div class="span2"><?php echo $this->lang->line('bankCountryID') ?></div>
								<div class="span4">
									<?php
										if($bankmaster){		
											$preselstat = $bankmaster->bankCountryID;
										}else{
											$preselstat = '458';
										}                        
										$options[] = '--Please Select--';
											foreach($country as $row){
											$options[$row->fldid] = $row->fldcountry;
											}
											$js='onChange="changeList(this)" class="span12"';
												echo form_dropdown('bankCountryID', $options, $preselstat, $js);
									?>       
								</div>                
								<div class="span1" TAR><?php echo $this->lang->line('bankStateID') ?></div>
								<div class="span3">
									<?php
									if($bankmaster){		
										$preselcat = $bankmaster->bankStateID;
									}else{
										$preselcat = '0';
									}                        
									$options='';
									$options[] = '--Please Select--';
									if($state != ''){
										foreach($state as $row){
										$options[$row->fldid] = $row->fldname;
										}
									}
									$js='id=bankStateID class="span12"';
										echo form_dropdown('bankStateID', $options, $preselstat, $js);
									?>       
								</div>                
							</div><!-- End Row 5 -->						
						</div><!-- End Content 2-->
					</div><!-- Block-->
					
					<div class="block">
						<div class="head">
							<h2><?php echo $this->lang->line('contactinfo') ?></h2>
							<ul class="buttons">                                            
								<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
							</ul>								
						</div>
						<div class="content np">    
							<div class="controls-row"> <!-- row 1 -->
								<div class="span2"><?php echo $this->lang->line('attention') ?></div>
								<div class="span10">
									<?php
										$data = array(
										'name'=>'attention',
										'id'=>'attention',
										'class'=>'span5',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->attention); 
										}else{
											echo form_input($data, set_value('attention')); 
										}                       
									?> 
								</div>                            
							</div> 
							<div class="controls-row"> <!-- row 2 -->
								<div class="span2"><?php echo $this->lang->line('email') ?></div>
								<div class="span10">
									<?php
										$data = array(
										'name'=>'email', 
										'class'=>'span5 validate[custom[email]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->email); 
										}else{
											echo form_input($data, set_value('email')); 
										}                      									
									?> 
									<span class="help-inline"><?php echo $this->lang->line('example') ?>: accounts@salihin.com.my</span>
								</div>                        
							</div> 
							<div class="controls-row"> <!-- row 3 -->
								<div class="span2"><?php echo $this->lang->line('phonenumber1') ?></div>
								<div class="span10">
									<?php
										$data = array(
										'name'=>'phonenumber1', 
										'id'=>'phonenumber1', 
										'class'=>'span5 validate[maxSize[16]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->phoneNumber1); 
										}else{
											echo form_input($data, set_value('phonenumber1')); 
										}                       
									?> 
									<span class="help-inline"><?php echo $this->lang->line('example') ?>: +603-2261 4180</span>
								</div>                
							</div>
							<div class="controls-row"> <!-- row 4 -->
								<div class="span2"><?php echo $this->lang->line('fax') ?></div>
								<div class="span10">
									<?php
										$data = array(
										'name'=>'fax', 
										'class'=>'span5 validate[maxSize[16]]',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->fax); 
										}else{
											echo form_input($data, set_value('fax')); 
										}                       
									?> 
									<span class="help-inline"><?php echo $this->lang->line('example') ?>: +603-2261 4182</span>
								</div>                        
							</div> 		
							
							
						
						</div> <!--Content -->
					</div> <!--Block-->
					
					<div class="block">
							<div class="head">
								<h2><?php echo $this->lang->line('othersinfo') ?></h2>
								<ul class="buttons">                                            
									<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
								</ul>                                         
							</div>
							<div class="content np">    
								<div class="controls-row"> <!-- row 1 -->
									<div class="span2"><?php echo $this->lang->line('generalNote') ?></div>
									<div class="span10">
										<?php
										$data = array(
										'name'=>'generalNote', 
										'class'=>'span10',); 
										if($bankmaster){		
											echo form_input($data, $bankmaster->generalNote); 
										}else{
											echo form_input($data, set_value('generalNote')); 
										}                       ?> 
									</div>                                                
								</div>	
								<div class="controls-row"> <!-- row 2 -->
									<div class="span2"><?php echo $this->lang->line('linkedAccountID') ?></div>
									<div class="span4">
										<?php
										//if($suppliermaster){	
											$preselacct = ($bankmaster)?$bankmaster->linkAccountID:$defaultacct;	
										//$presellinkAP = $suppliermaster->linkedAPAccountID; 
										//	}else{
										//	$presellinkAP = ''; 
										//     }                       
											$options = '';
											$options[] = '--Please Select--';
											if ($chartAccounts) 
												foreach($chartAccounts as $row){
													$options[$row->ID] =  substr($row->acctCode,0,4).'-'.substr($row->acctCode,4,3).'-'.substr($row->acctCode,7)." [" .$row->acctName."]";
												}
											$js='style="width: 250px;"';
												echo form_dropdown('linkAccountID', $options, $preselacct, $js);
										?>       
									</div> 
								</div>  
								
								<div class="controls-row"> <!-- row 3 -->
									<div class="span2"><?php echo $this->lang->line('currencyID') ?></div>
									<div class="span4">
									<?php
										if($bankmaster){		
											$preselcurr = $bankmaster->currencyID; 
										}else{
											$preselcurr = '1'; 
										}                       
										$options = '';
										$options[] = '--Please Select--';
										foreach($currency as $row){
											$options[$row->fldid] = $row->fldcurr_code . " [" . $row->fldcurr_desc . "]";
										}
										$js='style="width: 250px;"';
											echo form_dropdown('currencyID', $options, $preselcurr, $js);
									?>       
									</div> 
								</div>		
								
						</div> <!--Content -->
						<div class="content np">    
							<div class="footer">
								<div class="side fr">
									<div class="btn-group">
                                    <?php
                                    $data = array(
                                        'name' => 'validat',
                                        'class' => 'btn-form btn-warning-form',
                                        'onClick' => "$('#validate').validationEngine('hide');");
                                    echo form_button($data, 'Hide prompts');
                                    $data = array(
                                        'name' => 'mysubmit',
                                        'class' => 'btn-form btn-success-form');
                                    echo form_submit($data, 'Submit');
                                    ?>
									</div>
								</div>
							</div>                                    
						</div>		
						
					</div> <!--Block-->					
				</div> <!--span12-->
				</form>
			</div> <!--row fluids-->
		</div> <!--content-->
		
	</div> <!--wrap-->
</div> <!--content-->