
 
             <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
 			 <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  			 <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
             
            
 			 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
   
 
<script type="text/javascript">
  function test()
  {
   	var numberr=document.getElementById("primaryAccount").value;
       
           if(numberr){
               $.ajax({
                   type:'POST',
                   url:'<?php echo site_url('index.php/ThirdLevelAccount/ThirdLevelAccount/getSecondLevelAccount')?>',
                   data:'primaryAccountId='+numberr,
                   success:function(html){
                       $('#secondlevel').html(html);
                   }
               }); 
           }else{
               $('#secondlevel').html('<option value="">Select</option>')
           }
       }
       
   	
   	 
   
</script>


<script type="text/javascript">
   $(document).ready(function(){
   	
       $('#primaryAccount').on('change',function(){
           var primaryAccountId = $(this).val();
           if(primaryAccountId){
               $.ajax({
                   type:'POST',
                   url:'<?php echo site_url('index.php/ThirdLevelAccount/ThirdLevelAccount/getSecondLevelAccount');?>',
                   data:'primaryAccountId='+primaryAccountId,
                   success:function(html){
                       $('#secondlevel').html(html);
                   }
               }); 
           }else{
               $('#secondlevel').html('<option value="">Select</option>')
           }
       });
       
   	
   	 
   });
</script>
 <?php foreach($query->result() as $TLA){ 
			  ?>
<script>
  function testSp()
  {
   /// alert("");
	var number=document.getElementById("accountType").value;
	 //alert(number);
	
	// var primaryAccountType = $(this).val();
	  //alert(primaryAccountType);
           if(number){
               $.ajax({
                   type:'POST',
                   url:'<?php echo base_url('index.php/ThirdLevelAccount/ThirdLevelAccount/getprimaryAccountEdit/'.$TLA->thirdLevelAccountId);?>',
                   data:'primaryAccountType='+number,
                   success:function(html){
					  // alert(html);
                       $('#primaryAccount').html(html);
                   }
               }); 
           }else{
               $('#primaryAccount').html('<option value="">Select</option>')
           }
  }
  window.onload=testSp;
</script>

<?php } ?>

<script>
function checkIfExistsThirdLevelAccount() {
	var thirdLevelAccountName = $("#thirdLevelAccountName").val();
$.ajax(
    {
        type:"post",
        url: "<?php echo base_url(); ?>index.php/ThirdLevelAccount/ThirdLevelAccount/thirdLevelAccountName_exists",
        data:{ thirdLevelAccountName:thirdLevelAccountName,secondLevelAccountName:document.getElementById("secondLevelAccountName").value},
        success:function(response)
        {
            if (response == true){
					$('#msgBox1').html('<span style="color: red;"> Third Level Account Already Exist </span>');
            }else {
					$('#msgBox1').html('<span></span>');
            }  
        }
    });
}
</script>

<div class="row">
	<div class="col-sm-3 col-md-3 col-lg-3">
      <form  method="post" action="<?php echo base_url('index.php/ThirdLevelAccount/ThirdLevelAccount/doEditThirdLevelAccount')?>">
	
		<div class="box box-solid box-primary">
			<div class="box-header">
    			<h4 class="box-title">EDIT THIRD LEVEL ACCOUNT</h4>
           	</div>
        	<div class="box-body">
             <?php foreach($query->result() as $TLA){ 
			// print_r($TLA);
			  ?>
              <div class="form-group">
              
              
                 <input type="hidden" name="thirdLevelAccountId"  class="form-control input-sm" value="<?php echo $TLA->thirdLevelAccountId?>" />
                 
                
				       <label>Account Classes</label><span style="color:#F00" class="mandatory">*</span>
                       
                      <input type="text" id="accountType" class="form-control input-sm" readonly="readonly" required="required" value="<?php  $lpan='';
                     foreach($listThirdLevelAccount->result() as $r ){
                             if($TLA->thirdLevelAccountId==$r->thirdLevelAccountId)
                             {$lpan=$r->primaryAccountType;break;}
                             } echo $lpan; ?>"/>
                          
                     <?php  ?>
                        
                       
                        
                        
                         <span style="color: red;" class="mandatory"><?php echo form_error('accountType'); ?></span>
                        
                         
			</div>       
            	<div class="form-group">
				       <label >Primary Account Name</label><span style="color:#F00" class="mandatory">*</span>
                       
                       <select name="primaryAccount" id="primaryAccount"  class="form-control input-sm"  required>
                      <?php /*?> <?php $lpan='';
                        foreach($listPrimaryAccountName->result() as $r){
                                if($TLA->primaryAccountId==$r->primaryAccountId)
                                {$lpan=$r->primaryAccountName;  break;}}
                              echo '<option value="'.$TLA->primaryAccountId.'">'.$lpan.'</option>';
                        
                        
                        
                        foreach ($listPrimaryAccountName->result() as $TLAA) {if($r->primaryAccountId!=$TLAA->primaryAccountId)
                        '<option value=' . $TLAA->primaryAccountId . '>' . $TLAA->primaryAccountName . '</option>'; }?><?php */?>
                     </select>
						
                         <span style="color: red;" class="mandatory"><?php echo form_error('primaryAccount'); ?></span>
				</div>
                
                <div class="form-group">
				       <label>Second Level Account Name</label><span style="color:#F00" class="mandatory">*</span>
                       <select name="secondLevelAccountName" id="secondLevelAccountName"  class="form-control input-sm" onfocus="test()"  required>
 						 <?php $lslan='';
                        foreach($listSecondLevelAccountName->result() as $r){
                                if($TLA->secondLevelAccountId==$r->secondLevelAccountId)
                                {$lslan=$r->secondLevelAccountName;  break;}}
                               echo'<option value="'.$TLA->secondLevelAccountId.'">'.$lslan.'</option>';
                        
                        
                        
                        foreach ($listSecondLevelAccountName->result() as $TLAA) {if($r->secondLevelAccountId!=$TLAA->secondLevelAccountId)
                         '<option value=' . $TLAA->secondLevelAccountId . '>' . $TLAA->secondLevelAccountName . '</option>'; }?>
						</select>
                         <span style="color: red;" class="mandatory"><?php echo form_error('secondLevelAccountName'); ?></span>
				</div>
                
         
                <div class="form-group">
                   	<label>Third Level Account Name</label><span style="color:#F00" class="mandatory">*</span>
                     <?php foreach($query->result() as $TLA){  ?>
              		<input type="text" name="thirdLevelAccountName" id="thirdLevelAccountName" class="form-control input-sm" value="<?php echo $TLA->thirdLevelAccountName?>" required>
                    <span style="color: red;" class="mandatory"><?php echo form_error('thirdLevelAccountName'); ?>
                     <p id="msgBox1" ></p> </span>
                </div>
                
                <?php }} ?>
                
         	</div>
            <div class="box-footer">
                <div class="form-group">
                    <button type="submit" id="update" name="update" class="btn btn-primary">UPDATE </button>
                </div>
            </div>
      	</div>
	</form>
	</div>