<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 src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>     
-->      
 
<script>
    //.....only show selected Class Primary account in PopUp
    $(document).ready(function() {
        $("select.accountType").change(function() {
            var selectedAccountType = $(".accountType option:selected").val();
            //alert(selectedAccountType);
            document.getElementById("primaryAccountClass").value = selectedAccountType;
            document.getElementById("popUpPrimaryAccountclass").value = selectedAccountType;
            document.getElementById("popUpSecondPrimaryAccountclass").value = selectedAccountType;

        });
    });
    // .....only show selected Primary account's SecondLevel in PopUp
    $(document).ready(function() {
        $("select.primaryClass").change(function() {
            var selectedPrimaryAccountId = $(".primaryClass option:selected").val();
            var selectedPrimaryName = $(".primaryClass option:selected").text();
            document.getElementById("popUpPrimaryAccountId").value = selectedPrimaryAccountId;
            document.getElementById("popUpSecondPrimaryAccountId").value = selectedPrimaryAccountId;
            document.getElementById("popUpSecondPrimaryAccountName").value = selectedPrimaryName;
            document.getElementById("popUpPrimaryAccountName").value = selectedPrimaryName;

        });
    });
    // .....only show selected SecondLevel account's Third Level in PopUp
    $(document).ready(function() {
        $("select.secondlevelClass").change(function() {
            var selectedId = $(".secondlevelClass option:selected").val();
            var selectedName = $(".secondlevelClass option:selected").text();
            document.getElementById("popUpSecondAccountId").value = selectedId;
            document.getElementById("popUpSecondAccountName").value = selectedName;

        });
    });
    //Check account Name Exists or NOt
    function check_if_exists() {
        var accountName = $("#accountName").val();
        $.ajax({
            type: "post",
            url: "<?php echo base_url(); ?>index.php/AccountRegister/AccountRegister/accountName_exists",
            data: {
                accountName: accountName
            },
            success: function(response) {
                if (response == true) {
                    $('#accountNameExistMsg').html('<span style="color: red;"> Account Name Already Exist </span>');
                } else {
                    $('#accountNameExistMsg').html('<span></span>');
                }
            }
        });
    }
    //Check account Code Exists or NOt
    function checkIfExistsAccountCode() {
        var accountCode = $("#accountCode").val();
        $.ajax({
            type: "post",
            url: "<?php echo base_url(); ?>index.php/AccountRegister/AccountRegister/accountCode_exists",
            data: {
                accountCode: accountCode
            },
            success: function(response) {
                if (response == true) {
                    $('#accountCodeExistMsg').html('<span style="color: red;"> Account Code Already Exist </span>');
                } else {
                    $('#accountCodeExistMsg').html('<span></span>');
                }
            }
        });
    }
    //Check Primary Account Exists or NOt
    function checkIfExistsPrimaryAccount() {
        var primaryAccountName = $("#primaryAccountName").val();
        $.ajax({
            type: "post",
            url: "<?php echo base_url(); ?>index.php/AccountRegister/AccountRegister/PrimaryAccountName_exists",
            data: {
                primaryAccountName: primaryAccountName,
                PrimaryAccountclass: document.getElementById("popUpPrimaryAccountclass").value
            },
            success: function(response) {
                if (response == true) {
                    $('#primaryAccountExistMsg').html('<span style="color: red;"> Primary Account Already Exist </span>');
                } else {
                    $('#primaryAccountExistMsg').html('<span></span>');
                }
            }
        });
    }
    //Check SecondLevel Account Exists or NOt
    function checkIfExistsSecondaryAccount() {
        var popUpPrimaryAccountId = $("#popUpPrimaryAccountId").val();
        $.ajax({
            type: "post",
            url: "<?php echo base_url(); ?>index.php/AccountRegister/AccountRegister/SecondaryAccountNameExists",
            data: {
                popUpPrimaryAccountId: popUpPrimaryAccountId,
                secondLevelAccountName: document.getElementById("secondLevelAccountName").value
            },
            success: function(response) {
                if (response == true) {
                    $('#secondaryAccountExistMsg').html('<span style="color: red;"> SecondLevel Account Already Exist </span>');
                } else {
                    $('#secondaryAccountExistMsg').html('<span></span>');
                }
            }
        });
    }
    //Check ThirdLevel Account Exists or NOt
    function checkIfExistsThirdLevelAccount() {
        var secondLevelAccountId = $("#popUpSecondAccountId").val();
        var primaryAccountId = $("#popUpSecondPrimaryAccountId").val();
        var thirdLevelAccountName = $("#thirdLevelAccountName").val();
        $.ajax({
            type: "post",
            url: "<?php echo base_url(); ?>index.php/AccountRegister/AccountRegister/thirdLevelAccountNameExists",
            data: {
                popUpSecondAccountId: secondLevelAccountId,
                popUpSecondPrimaryAccountId: primaryAccountId,
                thirdLevelAccountName: thirdLevelAccountName
            },
            success: function(response) {
                if (response == true) {
                    $('#thirdLvlAccountExistMsg').html('<span style="color: red;"> Third Level Account Already Exist </span>');
                } else {
                    $('#thirdLvlAccountExistMsg').html('<span></span>');
                }
            }
        });
    }
    //Check Numeric or NOt
    function checkNumeric(argId) {
        //alert('numeric');
        var quantity = (document.getElementById(argId).value);
        if (quantity == "")
            document.getElementById(argId).value = '';
        else {
            if (isNaN(quantity) == true) {
                quantity = quantity.trim();
                var tempQuantity = quantity.replace(/\D+/, '');
                if (tempQuantity == "")
                    document.getElementById(argId).value = '';
                else
                    document.getElementById(argId).value = tempQuantity;
            }
        }
    }
    //-------Insert Primary Account using PopUp-------
    function insertPrimaryAccountPopUp() {
        var primaryAccountName = $("#primaryAccountName").val();
        var primaryAccountType = $("#primaryAccountClass").val();
		//alert(primaryAccountType);
        $.ajax({
            type: "post",
            url: "<?php echo base_url(); ?>index.php/AccountRegister/AccountRegister/getdataPrimary",
            data: {
                primaryAccountName: primaryAccountName,
                primaryAccountType: primaryAccountType
            },
			success: function(response) {
               //if (response == affectedRow) {
					alert(response);
                    /*$('#primaryAccountSucessMsg').html('<span style="color: red;"> Primary Account Added </span>');*/
					
           			//var primaryAccountId = $('#primaryAccount').val();
					//var myselect=document.getElementById("primaryAccount");
					//alert(primaryAccountId);
					var temp=$("#primaryAccountName").val();
					//var valuetemp= $("#lastId").val();
					/*myselect.options[myselect.length]=new Option(temp,response);
					document.getElementById('primaryAccount').value = temp;*/
					$('#primaryAccount').append($('<option>', {
   					 value: response,
   					 text: temp
					}));
    				//document.getElementById('primaryAccount').value = temp;
                 /*else {
                    $('#primaryAccountSucessMsg').html('<span></span>');
                }*/
            }
        });
    }
           
	 //-------Insert Second Level Account using PopUp-------
    function insertSecondLevelAccountPopUp() {
        var popUpPrimaryAccountId = $("#popUpPrimaryAccountId").val();
        var secondLevelAccountName = $("#secondLevelAccountName").val();
        $.ajax({
            type: "post",
            url: "<?php echo base_url(); ?>index.php/AccountRegister/AccountRegister/getPoUpLedger",
            data: {
                popUpPrimaryAccountId: popUpPrimaryAccountId,
                secondLevelAccountName: secondLevelAccountName
            },
            success: function(response) {
                if (response == true) {
                    $('#SecondLevelAccountSucessMsg').html('<span style="color: red;"> Second Level Account Added </span>');
					var myselect=document.getElementById("secondlevel");
					var temp=$("#secondLevelAccountName").val(); 
					myselect.options[myselect.length]=new Option(temp);
					document.getElementById('secondlevel').value = temp;
   					
    				
                } else {
                    $('#SecondLevelAccountSucessMsg').html('<span></span>');
                }
            }
        });
    }
</script>
<script type="text/javascript">
   $(document).ready(function(){
   //	alert();
       $('#accountType').on('change',function(){
           var primaryAccountType = $(this).val();
           if(primaryAccountType){
               $.ajax({
                   type:'POST',
                   url:'<?php echo site_url('index.php/AccountRegister/AccountRegister/getprimaryAccount');?>',
                   data:'primaryAccountType='+primaryAccountType,
                   success:function(html){
                       $('#primaryAccount').html(html);
                   }
               }); 
           }else{
               $('#primaryAccount').html('<option value="">Select</option>')
           }
       });
       
   	
   	 
   });

   $(document).ready(function(){
   	
       $('#primaryAccount').on('change',function(){
           var primaryAccountId = $(this).val();
           if(primaryAccountId){
               $.ajax({
                   type:'POST',
                   url:'<?php echo site_url('index.php/AccountRegister/AccountRegister/getSecondLevelAccount');?>',
                   data:'primaryAccountId='+primaryAccountId,
                   success:function(html){
                       $('#secondlevel').html(html);
                   }
               }); 
           }else{
               $('#secondlevel').html('<option value="">Select</option>')
           }
       });
       
   	
   	 
   });

   $(document).ready(function(){
   	
       $('#secondlevel').on('change',function(){
           var secondLevelAccountId = $(this).val();
           if(secondLevelAccountId){
               $.ajax({
                   type:'POST',
                   url:'<?php echo site_url('index.php/AccountRegister/AccountRegister/getThirdLevelAccount');?>',
                   data:'secondLevelAccountId='+secondLevelAccountId,
                   success:function(html){
                       $('#thirdlevelaccount').html(html);
                   }
               }); 
           }else{
               $('#thirdlevelaccount').html('<option value="">Select</option>')
           }
       });
     
   });
</script>

  


<!-- autocomplete..-->
<?php /*?><script>
$(function(){
$('#primaryAccountName').autocomplete({
source: function( request, response ) {
$.ajax({
url : '<?php echo site_url('index.php/AccountRegister/AccountRegister/getAccountName');?>',
dataType: "json",
method: 'post',
data: {
name_startsWith: request.term,
type: 'accountclass'
},
success: function( data ) {
response( $.map( data, function( item ) {
var code = item.split("|");
return {
label: code[0],
value: code[0],
data : item
}
}));
}
});
},
autoFocus: true,
minLength: 0,
select: function( event, ui ) {
var names = ui.item.data.split("|");
$('#primaryAccountId').val(names[1]);
},
change: function(event,ui)
{
if (ui.item==null)
{
$('#primaryAccountNmae').val('');
$('#primaryAccountId').val('');
}
}
});
});
</script><?php */ ?>

<center>
    <h3 class="modal-title" id="myModalLabel">ADD ACCOUNT REGISTER </h3>
</center>

<form action="<?php echo base_url() ?>index.php/AccountRegister/AccountRegister/getdata/" method="POST">
    <div class="row">
        <div class="col-md-4">

            <div class="form-group">
                <label style="color:#900">Account Code</label><span class="mandatory" style="color:#F00">*</span>
                <input type="text" name="accountCode" id="accountCode" placeholder="accountCode" class="form-control input-sm" onKeyUp="checkIfExistsAccountCode()" autocomplete="off">
                <span style="color:red;"> <?php echo form_error('accountCode'); ?></span>
                <p id="accountCodeExistMsg"></p>
                <!--<input type"hidden" name="accountcode">-->
            </div>
            <div class="form-group">
                <label style="color:#900">Account Name</label><span class="mandatory" style="color:#F00">*</span>
                <input type="text" name="accountName" id="accountName" placeholder="accountName" autocomplete="off" class="form-control input-sm" onKeyUp="check_if_exists()">
                <span style="color:red;"> <?php echo form_error('accountName'); ?></span>
                <p id="accountNameExistMsg"></p>
            </div>
            <div class="form-group">
                <label style="color:#900">Category</label> <span class="mandatory" style="color:#F00">*</span>
                <select name="category" id="category" class="form-control input-sm">
                    <?php echo '<option value="">Select</option>'; ?>
                    <option value="PL">PL</option>
                    <option value="BS">BS</option>
                </select> <span style="color:red;"> <?php echo form_error('category'); ?></span>

            </div>
            <div class="form-group">
                <label style="color:#900">Credit Limit</label><span class="mandatory" style="color:#F00">*</span>
                <input type="text" name="creditLimit" id="creditLimit" placeholder="creditLimit" class="form-control input-sm">
                <span style="color:red;"> <?php echo form_error('creditLimit'); ?></span>
            </div>
        </div>

        <div class="col-md-4">
            <div class="form-group">
                <label for="accountType" style="color:#900">Account Class</label>
                <span style="color:#F00" class="mandatory">*</span>
                <select name="accountType" id="accountType" required class="accountType form-control input-sm">
                    <?php echo '<option value="">Select</option>'; foreach($this->utils->getAccountClasses() as $row) { echo '
                    <option value=' . $row . '>' . $row . '</option>'; }; ?>
                </select>
                <span style="color:red;"> <?php echo form_error('accountType'); ?></span>
            </div>



            <div class="form-group">


                <input type="hidden" name="primaryAccountId" id="primaryAccountId" required class="form-control input-sm">
                <input type="hidden" name="secondLevelAccountId" id="secondLevelAccountId" required class="form-control input-sm">
                <span style="color: red;"><?php echo form_error('primaryAccountId'); ?></span>

                <label for="primaryAccount" style="color:#900">Primary Acc. Name</label>
                <span style="color:#F00" class="mandatory">*</span>
                <span style="color:red;"> <?php echo form_error('primary'); ?></span>

                <div class="input-group">

                    <select name="primaryAccount" id="primaryAccount" class=" primaryClass form-control input-sm" required >
                    </select>
                    <span class="input-group-btn">
                    <button type="button" onclick="myFunction()" id="save" name="save" value="" 
                            class="btn btn-sm btn-info" data-toggle="modal" data-target="#accountRegister">
                       <i class="ace-icon fa fa-plus bigger-110"></i>
                    </button>
                </span>
                </div>
            </div>

            <div class="form-group">
                <label style="color:#900">Second Level Acc.Name</label>
                <span style="color:red;"> <?php echo form_error('ledger'); ?></span>

                <div class="input-group">
                    <select name="secondlevel" id="secondlevel" class="secondlevelClass form-control input-sm" required>

                    </select>
                    <span class="input-group-btn">
                    <button type="button" onclick="myFunction()" id="save1" name="save1" value="" 
                                class="btn btn-sm btn-info" data-toggle="modal" data-target="#popupLedger">
                        <i class="ace-icon fa fa-plus bigger-110"></i>
                    </button>         
                </span>
                </div>
            </div>

            <div class="form-group">
                <label style="color:#900">Third Level Acc.Name</label>
                <span style="color:red;"> <?php echo form_error('ledger'); ?></span>

                <div class="input-group">
                    <select name="thirdlevelaccount" id="thirdlevelaccount" class="form-control input-sm">

                    </select>
                    <span class="input-group-btn">
                    <button type="button" onclick="myFunction()" id="save2" name="save2" value="" 
                            class="btn btn-sm btn-info" data-toggle="modal" data-target="#thirLevelPopUp">
                        <i class="ace-icon fa fa-plus bigger-110"></i>
                    </button>
                </span>
                </div>
            </div>


        </div>

        <div class="col-md-4">
            <div class="form-group">
                <label style="color:#900">Opening Balance</label><span class="mandatory" style="color:#F00">*</span>
                <input type="text" name="openingBalance" id="openingBalance" placeholder="openingBalance" class="form-control input-sm" onkeyup="checkNumeric(this.id);">
                <span style="color:red;"> <?php echo form_error('openingBalance'); ?></span>
            </div>
            <div class="form-group">
                <label style="color:#900">Closing Balance</label><span class="mandatory" style="color:#F00">*</span>
                <input type="text" name="closingBalance" id="closingBalance" placeholder="closingBalance" class="form-control input-sm" onkeyup="checkNumeric(this.id);">
                <span style="color:red;"> <?php echo form_error('closingBalance'); ?></span>
            </div>
            <div class="form-group">
                <label style="color:#900">Current Balance</label><span class="mandatory" style="color:#F00">*</span>
                <input type="text" name="currentBalance" id="currentBalance" placeholder="currentBalance" class="form-control input-sm" onkeyup="checkNumeric(this.id);">
                <span style="color:red;"> <?php echo form_error('currentBalance'); ?></span>
            </div>
            <div class="form-group">
                <label style="color:#900">Type of Balance</label> <span class="mandatory" style="color:#F00">*</span>
                <select name="typeOfBalance" id="typeOfBalance" class="form-control input-sm">
                    <?php echo '<option value="">Select</option>'; ?>
                    <?php echo '<option value="CREDIT">CREDIT</option>'; ?>
                    <?php echo '<option value="DEBIT">DEBIT</option>'; ?>
                </select>
            </div>

        </div>
    </div>


    <div class="row">
        <div class="col-md-7 pull-right">
            <button type="submit" id="add" name="add" value="" class="btn btn-lg btn-primary">
                <i class="fa fa-save"></i> Save
            </button>
        </div>
    </div>
</form>

<hr/>



<h3><center>ACCOUNT REGISTER DETAILS</center></h3>
<form method="POST">
    <?php if ($query->num_rows() > 0) { ?>
    <div class="row" style="margin-top: 5px;">
        <div class="col-md-12">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" data-page-size="5" data-page-navigation="pagination" class="table table-condensed table-responsive table-bordered footable">
                <thead>
                    <tr>
                        <th width="5%">Sl.No</th>
                        <th width="10%">Account Code</th>
                        <th width="15%">Account Name</th>
                        <th width="10%">Account Class</th>
                        <th width="15%">Primary Account Name</th>
                        <th width="10%">Second Level Account</th>
                        <?php /*?>
                        <th width="10%">Third Level Account</th>
                        <?php */?>
                        <th width="5%">Category</th>
                        <th width="10%">Credit Limit</th>
                        <th width="10%">Opening Balance</th>
                        <th width="10%">Closing Balance</th>
                        <th width="10%">Current Balance</th>
                        <th width="5%">Type Of Balance</th>
                        <th width="15%">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php /*?>
                    <?php echo $tables; ?>
                    <?php */ ?>
                    <tr>
                        <?php $i=1 ; foreach($query->result() as $row) { // if($row->closeStatus==0){ ?>
                        <td>
                            <center>
                                <?php echo $i++; ?>
                            </center>
                        </td>
                        <td>
                            <?php echo $row->accountCode; ?></td>
                        <td>
                            <?php echo $row->accountName; ?></td>
                        <td>
                            <?php $accountType='' ; foreach($primaryAccountType->result() as $r) { if ($row->primaryAccountId == $r->primaryAccountId) { $accountType = $r->primaryAccountType; break; } } echo $accountType; ?>
                        </td>
                        <td>
                            <?php $primaryAccount='' ; foreach($primaryAccountName->result() as $r) { if ($row->primaryAccountId == $r->primaryAccountId) { $primaryAccount = $r->primaryAccountName; break; } } echo $primaryAccount; ?>
                        </td>
                        <td>
                            <?php $ledger='' ; foreach($ledgername->result() as $r1) { if ($row->secondLevelAccountId == $r1->secondLevelAccountId) { $ledger = $r1->secondLevelAccountName; break; } } echo $ledger; ?>
                        </td>
                        <?php /*?>
                        <td>
                            <?php $thirdlevelaccount='' ; foreach($thirdlevelname->result() as $r) { if ($row->thirdLevelAccountId == $r->thirdLevelAccountId) { $thirdlevelaccount = $r->thirdLevelAccountName; break; } } echo $thirdlevelaccount; //var_dump($row); //echo $row->companyGroupName; ?>
                            <?php */?>
                        </td>
                        <?php /*?>
                        <td>
                            <?php $caty='' ; foreach($category->result() as $r ){ if($row->primaryAccountId==$r->primaryAccountId) {$caty=$r->category; break;} } echo $caty; //echo $row->companyGroupName;?></td>
                        <?php */ ?>
                        <td>
                            <?php echo $row->category; ?></td>
                        <td style="text-align:right">
                            <?php echo number_format($row->creditLimit, 2); ?></td>
                        <td style="text-align:right">
                            <?php echo number_format($row->openingBalance, 2); ?></td>
                        <td style="text-align:right">
                            <?php echo number_format($row->closingBalance, 2); ?></td>
                        <td style="text-align:right">
                            <?php echo number_format($row->currentBalance, 2); ?></td>
                        <td>
                            <?php echo $row->typeOfBalance; ?></td>
                        <?php /*?>
                        <!-- <td><?php echo $row->accountRegisterId;?></td>-->
                        <?php */ ?>
                        <td>
                            <center>
                                <a href="<?php
							echo base_url('index.php/AccountRegister/AccountRegister/edit/' . $row->accountRegisterId); ?>">
                                    <button type="button" class="btn btn-sm btn-primary" value="EDIT" title="edit">
                                        <i class="fa fa-edit"></i>
                                    </button>
                                </a>
                                <a href="<?php
							echo base_url('index.php/AccountRegister/AccountRegister/delete/' . $row->accountRegisterId); ?>">
                                    <!--<button type="button" class="btn btn-sm btn-danger" value="DELETE" title="delete"> 
                            	<i class="fa fa-times"></i> 
                          	</button>-->
                                </a>
                            </center>
                        </td>
                    </tr>
                    <?php } ?>
                    <?php } ?>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="13">
                            <div class="pagination pagination-centered hide-if-no-paging"></div>
                            <p id="msg1"></p>
                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
</form>



<!-- ======== pop up primary account start ========= -->
<div class="modal fade" id="accountRegister" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel"> </h4>
            </div>
            <div class="modal-body">

                <div class="row">
                    <div class="col-sm-12 col-md-12 col-lg-12">

                        <div class="box box-solid box-primary">
                            <div class="box-header">
                                <h4 class="box-title">ADD PRIMARY ACCOUNT</h4>
                            </div>
                            <div class="box-body" style="border-top:thin">
                                <p id="primaryAccountSucessMsg"></p>
                                <div class="form-group" style="color:#900">
                                    <label for="primaryAccount">Account Classes</label>
                                    <span style="color:#F00" class="mandatory">*</span>
                                    <input name="primaryAccountClass" id="primaryAccountClass" type="text" class="form-control input-sm" readonly="readonly" />


                                </div>
                                <div class="form-group" style="color:#900">
                                    <label>Primary Acc. Name </label>
                                    <span class="mandatory" style="color:#F00">*</span>
                                    <input type="text" name="primaryAccountName" id="primaryAccountName" autocomplete="off" placeholder="Primary Acc. Name" class="form-control input-sm" onKeyUp="checkIfExistsPrimaryAccount()">
                                    <span style="color:red;"> <?php echo form_error('primaryAccountName'); ?></span>
                                    <p id="primaryAccountExistMsg"></p>
                                </div>
                            </div>
                            <div class="box-footer">
                                <div class="form-group">
                                    <button type="submit" id="save" name="save" onclick="insertPrimaryAccountPopUp()" class="btn btn-primary">SAVE </button>
                                    <input type="hidden" name="lastId" id="lastId" value="<?php if(isset($lastId)){ echo $lastId; }?>"/>

                                </div>
                            </div>
                        </div>

                    </div>
                </div>


            </div>
        </div>
    </div>
</div>
<!-- ======== pop up primary account end ========= -->




<!-- ======== pop up ledger start ========= -->
<div class="modal fade" id="popupLedger" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel1"> </h4>
            </div>
            <div class="modal-body">


                <div class="row">
                    <div class="col-sm-12 col-md-12 col-lg-12">
                        
                            <div class="box box-solid box-primary">
                                <div class="box-header">
                                    <h4 class="box-title">SECOND LEVEL ACCOUNT</h4>
                                </div>
                                <div class="box-body">
                                <p id="SecondLevelAccountSucessMsg"></p>
                                    <div class="form-group" style="color:#900">
                                        <label for="primaryAccount">Account Class</label>
                                        <span style="color:#F00" class="mandatory">*</span>
                                        <input type="text" name="popUpPrimaryAccountclass" id="popUpPrimaryAccountclass" class="form-control input-sm" disabled="disabled" />


                                    </div>
                                    <div class="form-group" style="color:#900">
                                        <label for="primaryAccount">Primary Account Name</label>
                                        <span style="color:#F00" class="mandatory">*</span>
                                        <input type="hidden" name="popUpPrimaryAccountId" id="popUpPrimaryAccountId" class="form-control input-sm" />
                                        <input type="" name="popUpPrimaryAccountName" id="popUpPrimaryAccountName" class="form-control input-sm" disabled/>

                                    </div>
                                    <div class="form-group" style="color:#900">
                                        <label>Second Level Account Name</label><span class="mandatory">*</span>
                                        <input type="text" name="secondLevelAccountName" id="secondLevelAccountName" class="form-control input-sm" autocomplete="off" required="required" onKeyUp="checkIfExistsSecondaryAccount()">
                                        <span style="color: red;" class="mandatory"><?php echo form_error('ledgerName'); ?></span>
                                        <p id="secondaryAccountExistMsg"></p>
                                    </div>
                                </div>
                                <div class="box-footer">
                                    <div class="form-group">
                                        <button type="submit" id="save1" name="save1" class="btn btn-primary" onclick="insertSecondLevelAccountPopUp()">SAVE </button>
                                    </div>
                                </div>
                            </div>
                    </div>
                </div>



            </div>
        </div>
    </div>
</div>
<!-- ======== pop up ledger end ========= -->



<!-- ======== pop up third level account start ========= -->
<div class="modal fade" id="thirLevelPopUp" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel3"> </h4>
            </div>
            <div class="modal-body">




                <div class="row">
                    <div class="col-sm-12 col-md-12 col-lg-12">
                        <form method="POST" action="<?php echo base_url() ?>index.php/AccountRegister/AccountRegister/getdataPopUpThirdLevel">
                            <div class="box box-solid box-primary">
                                <div class="box-header">
                                    <h4 class="box-title">THIRD LEVEL ACCOUNT</h4>
                                </div>
                                <div class="box-body">

                                    <div class="form-group" style="color:#900">
                                        <label for="primaryAccount">Account Class</label>
                                        <span style="color:#F00" class="mandatory">*</span>
                                        <input type="text" name="popUpSecondPrimaryAccountclass" id="popUpSecondPrimaryAccountclass" class="form-control input-sm" disabled="disabled" />


                                    </div>
                                    <div class="form-group" style="color:#900">
                                        <label for="primaryAccount">Primary Account Name</label>
                                        <span style="color:#F00" class="mandatory">*</span>
                                        <input type="hidden" name="popUpSecondPrimaryAccountId" id="popUpSecondPrimaryAccountId" class="form-control input-sm" />
                                        <input type="" name="popUpSecondPrimaryAccountName" id="popUpSecondPrimaryAccountName" class="form-control input-sm" disabled/>

                                    </div>
                                    <div class="form-group" style="color:#900">
                                        <label for="secondlevel">Second Level Account Name</label>
                                        <span style="color:#F00" class="mandatory">*</span>
                                        <input type="hidden" name="popUpSecondAccountId" id="popUpSecondAccountId" class="form-control input-sm" />
                                        <input type="" name="popUpSecondAccountName" id="popUpSecondAccountName" class="form-control input-sm" disabled/>

                                    </div>
                                    <div class="form-group" style="color:#900">
                                        <label>Third Level Account Name</label><span class="mandatory">*</span>
                                        <input type="text" name="thirdLevelAccountName" id="thirdLevelAccountName" class="form-control input-sm" required="required" autocomplete="off" onKeyUp="checkIfExistsThirdLevelAccount()">
                                        <span style="color: red;" class="mandatory"><?php echo form_error('thirdLevelAccountName'); ?></span>
                                        <p id="thirdLvlAccountExistMsg"></p>
                                    </div>

                                </div>
                                <div class="box-footer">
                                    <div class="form-group">
                                        <button type="submit" id="save1" name="save1" class="btn btn-primary">SAVE </button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>



            </div>
        </div>
    </div>
</div>
<!-- ======== pop up third level account end ========= -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
	$(function() {
		$('.footable').footable();
	});
</script>
