
<style>
    .select2-container.select2-container-multi{
        height:auto !important;
        overflow-x: hidden !important;
        overflow-y:scroll !important;
        max-height:70px;
    }
    .table thead tr >th{

        background-color:#4c0870;
        width:16% !important;
        color:#fff;
    }
    .table thead tr th[class*='sorting_'] {
        color: #fff;
    }
    .bg-master-lighter {
        border:none;
        background-color:#fff;
        border-top:1px solid #ddd;  
    }
    #selected_entry{
        height:90px;
        color: black;
        margin-top:20px;
        font-size: 16px;
        padding-top: 2%;
    }
    .select_table td{
        padding-left: 70px;
    }
</style>

<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"><?php print CommonLanguage::getMessage('merge_accounts');?></div>
            <div id="mergeAccounts" class="alert alert-success hidden"></div>
            
            
        </div>
        <div class="panel-body">
            <div class="col-md-12" id="MyTable" >
                    
                <div class="MergeByCategory ">
                    <div class="col-md-12">
                        <div class="col-md-3"><h3><?php print CommonLanguage::getMessage('merge_on');?></h3></div>
                        <div class="col-md-6"><h3> <?php print CommonLanguage::getMessage('accounts_to_merge');?></h3></div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-3">
                            <select id="Merged_On" class="full-width " data-init-plugin="select2">
                                <?php for($i=0;$i<count($accounts);$i++){?>
                                <option value="<?php echo $accounts[$i]['Account_ID']?>"><?php echo ($accounts[$i]['Account_Name']." - ".$accounts[$i]['Account_Code'])?></option>
                                <?php } ?>
                            </select>
                        </div>

                    
                    <div class="col-md-6">
                        <select id="Merge_Account_Array" class="full-width " multiple tabindex="-1" data-init-plugin="select2">
                           <?php for($i=0;$i<count($accounts);$i++){?>
                                <option value="<?php echo $accounts[$i]['Account_ID']?>"><?php echo ($accounts[$i]['Account_Name']." - ".$accounts[$i]['Account_Code'])?></option>
                                <?php } ?>

                        </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="container-sm-height">
                <button class=" btn  btn-cons m-b-10 pull-right" id="SubmitButton" style="color:#fff;background-color:#4c0870 ;padding-top: 10px;top: 20px;min-width:253px;" type="button" ><i class="pg-form"></i> <span class="bold"><?php print CommonLanguage::getMessage('Save');?></span></button>
            </div>
        </div>
    </div>
</div>


<script>
    var account_merge_success = <?php echo json_encode(CommonLanguage::getMessage('account_merge_success'));?>,
        account_merge_failed = <?php echo json_encode(CommonLanguage::getMessage('account_merge_failed'));?>;
    $("#SubmitButton").on("click", function(){
//        $("#tableWithSearch tbody tr").each(function(e){
            var me = $(this);
            var Data = {
                   Merged_On :$("#Merged_On").val(),
                   Merge_Account_Array :$("#Merge_Account_Array").val()
            };
        $.ajax({
            url:"ACCAjax/mergeAccountsAjax",
            method:"POST",
            data:Data,
            complete:function(v1,v2){
                if(v2 == "success" && v1.responseText =="success"){
                    $("#mergeAccounts").attr("class","alert alert-success").html(account_merge_success)
					$("#SubmitButton").addClass('disabled')
                }else{
                    $("#mergeAccounts").attr("class","alert alert-danger").html(account_merge_failed)
                }
                $(document.body).animate({scrollTop:0},800)
            }
        })
    //})
    })
</script>
