@extends('layouts/microfin_layout')
@section('title', '| Opening Balance')
@section('content')
<style type="text/css">
    .form-group, .form-control{
        font-size: 11px !important;
        color: black !important;
    }
    .form-control{
        padding: 5px !important;
    }
    #reportSubmit{
        font-size: 12px;
        margin-top: 20px;
    }
</style>
<script type="text/javascript">
    $("#loadingModal").show();
    $(document).keydown(function(e) {
        if (e.keyCode == 27) return false;
    });
</script>

<div class="row">
<div class="col-md-12">
<div class="" style="">
    <div class="">
        <div class="panel panel-default" style="background-color:#708090;">
            <div class="panel-heading" style="padding-bottom:0px">
                {{-- <div class="panel-options">
                    <button id="printIcon" class="btn btn-info pull-right print-icon"  target="_blank" style="">
                        <i class="fa fa-print fa-lg" aria-hidden="true"> Print</i>
                    </button>
                </div> --}}
                <h3 style=" text-align: center; font-family: Antiqua; letter-spacing: 2px; color: white;">Opening Balance</h3>
            </div>

            <div class="panel-body panelBodyView" >

                <!-- Filtering Start-->
                {!! Form::open(array('url' => '', 'role' => 'form', 'class'=>'form-horizontal form-groups', 'id' => 'filterFormId', 'method'=>'get')) !!}
                <div class="row">
                    <div class="col-md-12">

                        @if($userBranchId == 1)
                        <div class="col-md-2" id="branchDiv">
                            <div class="form-group">
                                <div class="col-md-12">
                                    {!! Form::label('', 'Branch:', ['class' => 'control-label pull-left']) !!}
                                </div>
                                <div class="col-md-12">
                                    {!! Form::select('filBranch', ['-1'=>'--All--']+$branchList, null ,['id'=>'filBranch','class'=>'form-control input-sm','autocomplete'=>'off']) !!}
                                    <p id='filBranchE' style="max-height:3px; color:red;"></p>
                                </div>
                            </div>
                        </div>                        
                        @endif

                        <div class="col-md-2">
                            <div class="form-group">
                                <div class="col-md-12">
                                    {!! Form::label('', 'Samity:', ['class' => 'control-label pull-left']) !!}
                                </div>
                                <div class="col-md-12">
                                    {!! Form::select('filSamity', ['-1'=>'--All--']+$samityList, null ,['id'=>'filSamity','class'=>'form-control input-sm','autocomplete'=>'off']) !!}
                                    <p id='filBranchE' style="max-height:3px; color:red;"></p>
                                </div>
                            </div>
                        </div>


                        <div class="col-md-2">
                            <div class="form-group">
                                <div class="col-md-12">
                                    {!! Form::label('limit', 'Limit*:', ['class' => 'control-label pull-left']) !!}
                                </div>
                                <div class="col-md-12">
                                    <div class="input-group">
                                        <input type="text" class="form-control" name="limitFrom" placeholder="From" value="1">
                                        <span class="input-group-addon">-</span>
                                        <input type="text" class="form-control" name="limitTo" placeholder="To" value="500">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-2">
                            <div class="form-group">
                                <div class="col-md-12">
                                    {!! Form::label('code', 'Member/Savings Code:', ['class' => 'control-label pull-left']) !!}
                                </div>
                                <div class="col-md-12">
                                        <input type="text" class="form-control" name="code" placeholder="Member Code(Optional)">
                                </div>
                            </div>
                        </div>

                        <div class="col-md-1">
                            <div class="form-group">
                                {!! Form::label('', '', ['class' => 'control-label col-md-12']) !!}
                                <div class="col-md-12">                                    
                                    {!! Form::submit('Search', ['id' => 'reportSubmit', 'class' => 'btn btn-primary btn-xs']); !!}
                                </div>
                            </div>
                        </div>

                        {{-- <div class="col-md-1 pull-right">
                            <div class="form-group" >
                                {!! Form::label('', 'Opening Date:', ['class' => 'control-label col-md-12']) !!}
                                <div class="col-md-12">                                 
                                    {!! Form::text('Opening Date',null ,['id' => 'openingDate', 'class' => 'form-control input-sm','readonly'=>'readyonly']); !!}
                                </div>
                            </div>
                        </div> --}}
                        
                    </div>
                </div>
                
                {!! Form::close()  !!}
                <!-- filtering end-->


                <div class="row">
                    <div class="col-md-12"  id="reportingDiv">
                        
                    </div>
                </div>


            </div>		{{-- panel-body panelBodyView DIV --}}
        </div>
    </div>
</div>
</div>
</div>

<script type="text/javascript">
$(document).ready(function() {

    $("#loadingModal").hide();

    $("#openingDate").datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange : "c-50:c",
        maxDate: "dateToday",
        dateFormat: 'dd-mm-yy',
        onSelect: function(){
            $(this).closest('div').find('.error').remove();
        }
    });

    /*filter the samity base on the branch selected*/
    $("#filBranch").change(function(event) {
        var branchId = $(this).val();

        $("#filSamity option:gt(0)").remove();

        if (branchId=='' || branchId==null) {
            return false;
        }

        $.ajax({
            url: './getMfnBranchWiseSamityList',
            type: 'POST',
            dataType: 'json',
            data: {branchId: branchId},
        })
        .done(function(samities) {
            $.each(samities, function(index, val) {
                 $("#filSamity").append("<option value='"+index+"'>"+val+"</option>")
            });
        })
        .fail(function() {
            alert("response error");
        });

    });

        
    
    /*end filter the samity base on the branch selected*/
 
    $("form").submit(function( event ) {
        event.preventDefault();

        var serializeValue=$(this).serialize();
        //alert(serializeValue);

        
        $('#loadingModal').show();
        $("#reportingDiv").load('{{URL::to("viewMfnOpeningSavingsBalanceData")}}'+'?'+serializeValue);
    });

});


</script>

@endsection
