@extends('admin.layouts.master')

@section('title')
    Releases
@stop

@section('style')
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" />
    <link rel="stylesheet" type="text/css" href="{{asset('/css/jsteps/normalize.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('/css/jsteps/jquery.steps.css')}}">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
    <link href="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/css/select2.min.css" rel="stylesheet" />

    <style>
        .select2{
                width: 100% !important;
            }
        .select2-container, .select2-dropdown, .select2-search, .select2-results {
        -webkit-transition: none !important;
        -moz-transition: none !important;
        -ms-transition: none !important;
        -o-transition: none !important;
        transition: none !important;
        }
    </style>
@stop

@section('content')
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper" >
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <span class="fa fa-user-plus"></span> New Release
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-user-plus"></i> Admin Panel</a></li>
                <li class="active">New Release</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content" style=" padding-bottom: 5%;">
            <div class="page-header">
                <a href="{{route('releases')}}" class="btn btn-primary"><i class="fa fa-backward"></i> Back</a>
            </div>

           <form id="frmRelease" method="post" action="{{route('releases.new')}}" role="form">
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <div class="form-group">
                    <h3>Releasing Details</h3>
                    <section>

                    <div class="col-md-6">
                        <div class="form-group has-feedback @if($errors->has('reservation_date')) has-error @endif">
                            <label for="release_date" class="control-label">Release Date:</label>
                            <div class='input-group date datetimepicker1' id='datetimepicker1'>
                                <input type='text' class="form-control" id="release_date" name="release_date"  />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                            @if($errors->has('release_date')) <span class="help-block">{{$errors->first('release_date')}}</span> @endif
                        </div>

                        <div class="form-group has-feedback @if($errors->has('agent_id')) has-error @endif">
                            <label for="agent_id" class="control-label">Agent *:</label>
                            <select name="agent_id" id="agent_id" class="form-control" >
                                <option value="">Select Agent</option>
                                @foreach($agents as $agent)
                                    <option value="{{$agent->id}}">{{$agent->fullname}}</option>
                                @endforeach
                            </select>
                            <span class="fa form-control-feedback"></span>
                            @if($errors->has('agent_id')) <span class="help-block">{{$errors->first('agent_id')}}</span> @endif
                        </div>

                        <div class="form-group has-feedback @if($errors->has('umanager_id')) has-error @endif">
                            <label for="umanager_id" class="control-label">Unit Manager *:</label>
                            <select name="umanager_id" id="umanager_id" class="form-control" >
                                <option value="">Select Unit Manager</option>
                                @foreach($ums as $um)
                                    <option value="{{$um->id}}">{{$um->fullname}}</option>
                                @endforeach
                            </select>
                            <span class="fa form-control-feedback"></span>
                            @if($errors->has('umanager_id')) <span class="help-block">{{$errors->first('umanager_id')}}</span> @endif
                        </div>

                        <div class="form-group has-feedback @if($errors->has('referrer_id')) has-error @endif">
                            <label for="referrer_id" class="control-label">Referrer *:</label>
                            <select name="referrer_id" id="referrer_id" class="form-control" >
                                <option value="">Select Referrer</option>
                                @foreach($agents as $agent)
                                    <option value="{{$agent->id}}">{{$agent->fullname}}</option>
                                @endforeach
                            </select>
                            <span class="fa form-control-feedback"></span>
                            @if($errors->has('referrer_id')) <span class="help-block">{{$errors->first('referrer_id')}}</span> @endif
                        </div>
                    </div>

<div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('agent_pcg_rate')) has-error @endif">
                            <label for="agent_pcg_rate" class="control-label">Agent Rate (%):</label>
                            <input type="number" name="agent_pcg_rate" id="agent_pcg_rate" class="form-control comm_rate" value="{{$share[0]->shr_agent}}" style="text-align: right" step="1" min="1">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('agent_pcg_rate')) <span class="help-block">{{$errors->first('agent_pcg_rate')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('agent_com_rate')) has-error @endif">
                            <label for="agent_com_rate" class="control-label">Agent Commission Rate:</label>
                            <input type="number" name="agent_com_rate" id="agent_com_rate" class="form-control" value="}" style="text-align: right" step="0.1" min="1.0">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('agent_com_rate')) <span class="help-block">{{$errors->first('agent_com_rate')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('um_pcg_rate')) has-error @endif">
                            <label for="um_pcg_rate" class="control-label">Unit Manager Rate (%):</label>
                            <input type="number" name="um_pcg_rate" id="um_pcg_rate" class="form-control comm_rate" value="{{$share[0]->shr_um}}" style="text-align: right" step="1" min="1">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('um_pcg_rate')) <span class="help-block">{{$errors->first('um_pcg_rate')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('um_com_rate')) has-error @endif">
                            <label for="um_com_rate" class="control-label">Unit Manager Commission:</label>
                            <input type="number" name="um_com_rate" id="um_com_rate" class="form-control" value="" style="text-align: right" step="0.1" min="0.1">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('um_com_rate')) <span class="help-block">{{$errors->first('um_com_rate')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('broker_pcg_rate')) has-error @endif">
                            <label for="broker_pcg_rate" class="control-label">Broker Commission (%):</label>
                            <input type="number" name="broker_pcg_rate" id="broker_pcg_rate" class="form-control comm_rate" value="{{$share[0]->shr_broker}}" style="text-align: right" step="1" min="1">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('broker_pcg_rate')) <span class="help-block">{{$errors->first('broker_pcg_rate')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('broker_com_rate')) has-error @endif">
                            <label for="broker_com_rate" class="control-label">Broker Commission Rate:</label>
                            <input type="number" name="broker_com_rate" id="broker_com_rate" class="form-control" value="" style="text-align: right" step="0.1" min="0.1">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('broker_com_rate')) <span class="help-block">{{$errors->first('broker_com_rate')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('ref_pcg_rate')) has-error @endif">
                            <label for="ref_pcg_rate" class="control-label">Referrer Commission (%):</label>
                            <input type="number" name="ref_pcg_rate" id="ref_pcg_rate" class="form-control comm_rate" value="{{$share[0]->shr_refer}}" style="text-align: right" step="0.1" min="0.1">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('ref_pcg_rate')) <span class="help-block">{{$errors->first('ref_pcg_rate')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('ref_com_rate')) has-error @endif">
                            <label for="ref_com_rate" class="control-label">Referrer Commission Rate:</label>
                            <input type="number" name="ref_com_rate" id="ref_com_rate" class="form-control" value="" style="text-align: right" step="0.1" min="0.1">
                            <span class="glyphicon glyphicon-zoom-out form-control-feedback"></span>
                            @if($errors->has('ref_com_rate')) <span class="help-block">{{$errors->first('ref_com_rate')}}</span> @endif
                        </div>
                    </div>

                    {{--}}<div class="col-md-6">
                        <div class="form-group has-feedback @if($errors->has('developer_id')) has-error @endif">
                            <label for="developer_id" class="control-label">Developer *:</label>
                            <select name="developer_id" id="agent_id" class="form-control" >
                                <option value="">Select Developer</option>
                                    <option value="{{$devs[0]->developer->id}}">{{$devs[0]->developer->name}}</option>
                            </select>
                            <span class="fa form-control-feedback"></span>
                            @if($errors->has('developer_id')) <span class="help-block">{{$errors->first('developer_id')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('blk')) has-error @endif">
                            <label for="blk" class="control-label">Block:</label>
                            <select name="blk" id="blk" class="form-control">
                                <option value="">Select Block</option>
                            </select>
                            <span class="glyphicon form-control-feedback"></span>
                           @if($errors->has('blk')) <span class="help-block">{{$errors->first('blk')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('lot')) has-error @endif">
                            <label for="lot" class="control-label">Lot:</label>
                            <select name="lot" id="lot" class="form-control">
                                <option value="">Select Lot</option>
                            </select>
                            <span class="glyphicon form-control-feedback"></span>
                            @if($errors->has('lot')) <span class="help-block">{{$errors->first('lot')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('gross_amount')) has-error @endif">
                            <label for="gross_amount" class="control-label">Gross Receivable Amount:</label>
                            <input type="number" name="gross_amount" id="gross_amount" class="form-control" style="text-align: right" step="0.1" min="1.0">
                            <span class="glyphicon glyphicon-triangle-right form-control-feedback"></span>
                            @if($errors->has('gross_amount')) <span class="help-block">{{$errors->first('gross_amount')}}</span> @endif
                        </div>
                    </div>

                    <div class="col-md-3">
                        <div class="form-group has-feedback @if($errors->has('num_month')) has-error @endif">
                            <label for="num_month" class="control-label">No. of Months:</label>
                            <input type="number" name="num_month" id="num_month" class="form-control" style="text-align: right" step="1" min="1" max="24">
                            <span class="glyphicon glyphicon-triangle-right form-control-feedback"></span>
                            @if($errors->has('num_month')) <span class="help-block">{{$errors->first('num_month')}}</span> @endif
                        </div>
                    </div>--}}

                    <div class="col-md-6">
                        <div class="form-group has-feedback @if($errors->has('num_month')) has-error @endif">
                            <label for="remarks" class="control-label">Remarks:</label>
                            <textarea class="form-control txt" rows="3" name="remarks" id="remarks" placeholder=""></textarea>
                            @if($errors->has('remarks')) <span class="help-block">{{$errors->first('remarks')}}</span> @endif
                        </div>
                    </div>

                    <div style="height:220px;"></div>


                    <div class="col-md-12">
                        <div class="btn btn-success" id="add-more" >Add More</div>
                            <div class="row">
                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                    <input type='hidden' class="form-control" id="itm" name="itm">
                                    <table class="table table-bordered table-hover" id="invoiceItem">
                                        <tr>
                                            <th width="2%"><input id="checkAll" class="formcontrol" type="checkbox"></th>
                                            {{--<th width="8%">No.</th>--}}
                                            <th width="15%">Date</th>
                                            <th width="38%">Paymode</th>
                                            <th width="15%">Amount</th>
                                            {{--<th width="8%">Actions</th>--}}
                                            {{--<th width="15%">Price</th>
                                            <th width="15%">Total</th>--}}
                                        </tr>
                                        <tr>
                                            <td><input class="itemRow" type="checkbox"></td>
                                            {{--@foreach ($devs as $dev)
                                                {{$dev}}
                                            @endforeach--}}
                                            <td width="25%">
                                                <div class='input-group date datetimepicker1'>
                                                    <input type='text' class="form-control rcvddate" id="rcvddate_1" name="rcvddate[]" required="required" />
                                                    <span class="input-group-addon">
                                                        <span class="glyphicon glyphicon-calendar"></span>
                                                    </span>
                                                </div>
                                            </td>
                                            <td  width="20%">
                                                <select id="paymode_1" name="paymode[]" class="form-control paymode" required="required">
                                                    <option value="">Select Paymode</option>
                                                    {{--@foreach($paymode as $pm)
                                                        <option value="{{$pm}}" selected>{{$pm}}</option>
                                                    @endforeach--}}
                                                </select>
                                            </td>
                                            <td><input type="number" name="amount[]" id="amount_1" class="form-control amount" autocomplete="off" style="text-align:right;" required="required"></td>

                                        </tr>
                                    </table>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
                                    <button class="btn btn-danger delete" id="removeRows" type="button">- Delete</button>
                                    <button class="btn btn-success" id="addRows" name="addRows" type="button">+ Add More</button>
                                </div>
                            </div>
                    </div>

                    </section>
                    {{--<h3>Commission Info</h3>
                    <section>

                        <div class="col-md-12">
                            <table class="tbl-qa">
                              <thead>
                                <tr>
                                  <th class="table-header">Title</th>
                                  <th class="table-header">Description</th>
                                  <th class="table-header">Actions</th>
                                </tr>
                              </thead>
                              <tbody id="table-body">
                                  <tr class="table-row" id="table-row">
                                    <td contenteditable="true"></td>
                                    <td contenteditable="true"></td>
                                    <td><a class="ajax-action-links">Delete</a></td>
                                  </tr>
                              </tbody>
                            </table>
                            <div class="ajax-action-button" id="add-more" onClick="createNew();">Add More</div>
                        </div>
                        </section>
                    </div>
                    </form>
                    </section>--}}

        @if(Session('info'))
            <div class="row">
            <div class="col-md-6 col-md-offset-3 text-center">
            <div class="tem alert alert-success navbar-fixed-bottom"><span class="glyphicon glyphicon-ok-circle"></span> {{Session('info')}}</div>
            </div>
            </div>
        @endif

        <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <form method="post" action="{{route('gross.new')}}">
                    <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">Add New line item</h4>
                        </div>
                        <div class="modal-body text-left">
                            <input type="text" id="rcvd_id" name="rcvd_id" value="">
                            <div class="form-group">
                                <label for="rcvd_date1" class="control-label">Date</label>
                                <div class='input-group date datetimepicker1' id='rcvd_date1'>
                                    <input type='text' class="form-control" id="rcvd_date1" name="rcvd_date1"  />
                                    <span class="input-group-addon">
                                        <span class="glyphicon glyphicon-calendar"></span>
                                    </span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="pay_mode1" class="control-label">Payment Mode</label>
                                <select name="pay_mode1" id="pay_mode1" class="form-control">
                                    <option value="">Select Paymode</option>
                                    {{--@foreach($paymode as $pm)
                                        <option value="{{$pm}}" selected>{{$pm}}</option>
                                    @endforeach--}}
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="rls_amount" class="control-label">Release Amount</label>
                                <input value="" type="number" name="rls_amount" id="rls_amount" class="form-control" style="text-align: right" min="1" step="0.1">
                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                            <button type="submit" id="itmSave" name="itmSave" class="btn btn-primary">Save</button>
                        </div>
                    </div>
                    {{csrf_field()}}
                </form>
            </div>
        </div>

    </div>
        <!-- Main content -->
        {{--<section class="content" style=" padding-bottom: 60%;">
            <div class="page-header">
                <a href="{{route('releases')}}" class="btn btn-primary"><i class="fa fa-backward"></i> Back</a>
            </div>

            <div class="col-md-6 col-md-offset-3">
                <form method="post" action="{{route('releases.new')}}">

                    <div class="form-group has-feedback @if($errors->has('property_id')) has-error @endif">
                        <label for="property_id" class="control-label">Property</label>
                        <select name="property_id" id="property_id" class="form-control">
                            <option value="">Select Property</option>
                                @foreach($property as $prop)
                                    <option value="{{$prop->id}}">{{$prop->project->name}}</option>
                                @endforeach
                        </select>
                        <span class="fa form-control-feedback"></span>
                        @if($errors->has('property_id')) <span class="help-block">{{$errors->first('property_id')}}</span> @endif
                    </div>

                    <div class="form-group has-feedback @if($errors->has('agent_id')) has-error @endif">
                        <label for="agent_id" class="control-label">Agent</label>
                        <select name="agent_id" id="agent_id" class="form-control" >
                            <option value="">Select Agent</option>
                            @foreach($agents as $agent)
                                <option value="{{$agent->id}}">{{$agent->fullname}}</option>
                                @endforeach
                        </select>
                        <span class="fa form-control-feedback"></span>
                        @if($errors->has('agent_id')) <span class="help-block">{{$errors->first('agent_id')}}</span> @endif
                    </div>

                    <div class="form-group has-feedback @if($errors->has('blk')) has-error @endif">
                        <label for="blk" class="control-label">Blk / Lot</label>
                        <input type="text" name="blk" id="blk" class="form-control">
                        <span class="glyphicon glyphicon-book form-control-feedback"></span>
                        @if($errors->has('blk')) <span class="help-block">{{$errors->first('blk')}}</span> @endif
                    </div>

                    <div class="form-group has-feedback @if($errors->has('net_selling')) has-error @endif">
                        <label for="net_selling" class="control-label">Net Selling</label>
                        <input type="text" style="text-align: right" name="net_selling" id="net_selling" class="form-control" readonly>
                        <span class="glyphicon glyphicon-usd form-control-feedback"></span>
                        @if($errors->has('net_selling')) <span class="help-block">{{$errors->first('net_selling')}}</span> @endif
                    </div>
                    <div class="form-group has-feedback @if($errors->has('rate_amount')) has-error @endif">
                        <label for="rate_amount" class="control-label">Rate Amount</label>
                        <input type="text" style="text-align: right" name="rate_amount" id="rate_amount" class="form-control" readonly>
                        <span class="glyphicon glyphicon-usd form-control-feedback"></span>
                        @if($errors->has('rate_amount')) <span class="help-block">{{$errors->first('rate_amount')}}</span> @endif
                    </div>
                    <div class="form-group has-feedback @if($errors->has('ttl_amount_release')) has-error @endif">
                        <label for="ttl_amount_release" class="control-label">Total Amount Released</label>
                        <input type="text" style="text-align: right" name="ttl_amount_release" id="ttl_amount_release" class="form-control" readonly>
                        <span class="glyphicon glyphicon-usd form-control-feedback"></span>
                        @if($errors->has('ttl_amount_release')) <span class="help-block">{{$errors->first('ttl_amount_release')}}</span> @endif
                    </div>
                    <input type="hidden" style="text-align: right" name="release_amount2" id="release_amount2" class="form-control" readonly>
                    <div class="form-group has-feedback @if($errors->has('release_amount')) has-error @endif">
                        <label for="release_amount" class="control-label">Release Amount</label>
                        <input type="number" style="text-align: right" name="release_amount" id="release_amount" class="form-control">
                        <span class="glyphicon glyphicon-usd form-control-feedback"></span>
                        @if($errors->has('release_amount')) <span class="help-block">{{$errors->first('release_amount')}}</span> @endif
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary btn-lg">Create</button>
                    </div>
                    {{csrf_field()}}
                </form>
            </div>

        </section>--}}
        @if(Session('info'))
            <div class="row">
            <div class="col-md-6 col-md-offset-3 text-center">
            <div class="tem alert alert-success navbar-fixed-bottom"><span class="glyphicon glyphicon-ok-circle"></span> {{Session('info')}}</div>
            </div>
            </div>
        @endif

    </div>

    <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <form method="post" action=""> {{--{{route('gross.new')}}--}}
                <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">Add New line item</h4>
                    </div>
                    <div class="modal-body text-left">
                        {{--<input type="text" id="rcvd_id" name="rcvd_id">--}}
                        <div class="form-group">
                            <label for="rcvddate" class="control-label">Date</label>
                            <div class="input-group date datetimepicker1">
                                <input type="text" class="form-control" id="rcvddate" name="rcvddate"  />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pay_mod" class="control-label">Payment Mode</label>
                            <select name="pay_mod" id="pay_mod" class="form-control">
                                <option value="">Select Paymode</option>
                                {{--@foreach($paymode as $pm)
                                    <option value="{{$pm}}" selected>{{$pm}}</option>
                                @endforeach--}}
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="rls_amt" class="control-label">Release Amount</label>
                            <input value="" type="number" name="rls_amt" id="rls_amt" class="form-control" style="text-align: right" min="1" step="0.1">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        {{--<button type="submit" class="btn btn-primary">Save</button>--}}
                        <button type="button" id="itmSave" name="itmSave" class="btn btn-primary">Save</button>
                    </div>
                </div>
                {{csrf_field()}}
            </form>
        </div>
    </div>

@stop

@section('script')

    {{--<script type="text/javascript" src="{{ asset('js/invoice.js') }}" ></script>--}}
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-steps/1.1.0/jquery.steps.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/js/select2.min.js"></script>

    <script>
        var form = $("#frmRelease");
        /*form.validate({
            errorPlacement: function errorPlacement(error, element) { element.before(error); },
            rules: {
                confirm: {
                    equalTo: "#password"
                }
            }
        });*/
        form.children("div").steps({
            headerTag: "h3",
            bodyTag: "section",
            transitionEffect: "slideLeft",
            /*onStepChanging: function (event, currentIndex, newIndex)
            {
                form.validate().settings.ignore = ":disabled,:hidden";
                return form.valid();
            },*/
            /*: function (event, currentIndex)
            {
                form.validate().settings.ignore = ":disabled";
                return form.valid();
            },*/
            onFinished: function (event, currentIndex)
            {
                console.log("ready");
                $("#frmRelease").submit();
                //$("#frmSales").submit();
                 //var form = $(this);
                     //form.submit();
            }

        });
    </script>
    <script>
        $( document ).ready(function() {
            //$('#agent_id option:not(:selected)').remove();
            //$('#agent_id').prop("disabled", true);
            //$('#agent_id').attr('readonly', true)
            $('#agent_id').select2();
            $('#umanager_id').select2();
            $('#referrer_id').select2();
            $('#developer_id').select2();

            $('#gross-table').DataTable( {
                "bDestroy": true,
                searching: false,
                paging: true,
                /*"bInfo" : false,*/
                lengthChange: false,
                pageLength: 5,
                info: true,
                orderable: false,
                order: false,
                 columnDefs: [{
                     targets: "_all",
                     orderable: false
                 }]
                /*"order": [[ 0, "desc" ]]*/
            });

            $('#datetimepicker1').datetimepicker({
                 format: 'MM/DD/YYYY'
            });

            $('.datetimepicker1').datetimepicker({
                format: 'MM/DD/YYYY'
            });
            //$('#agent_id option:not(:selected)').prop('disabled', true);
        });

        $('#add-more').on('click', function () {
            $('#addModal').modal('toggle');
        });

        $('#property_id').on('change', function () {
            var property_id = $(this).find('option:selected').val();
            //alert(property_id);
            //alert($option.val());
            if(property_id==''){
                }
                else{
                    //$('#spinner').modal({backdrop: 'static', keyboard: false});
                        $.ajax({
                        url:"{{route('releases.getPropDetails')}}",
                        method: 'get',
                        headers:  {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
                        data:{
                          'property_id':property_id
                        },
                        dataType:'json',
                        success:function(data){
                            //console.log(data);
                            $.each(data.ttl_release, function() {
                              $.each(this, function(name, value) {
                                //console.log(value);
                                if (value == null) {
                                    value =0.00;
                                    value = value.toFixed(2);
                                }
                                $('#ttl_amount_release').val(value);

                              });
                            });

                            data.props.forEach(function(props){
                                //alert(prop.agent_id);
                               $('#project_id').val(props.project_id);
                               $('#agent_id').val(props.agent_id);
                               $('#blk').val('Blk '+props.blk+' Lot '+props.lot);
                               $('#net_selling').val(props.net_selling_price);
                               $('#rate_amount').val(props.rate_amount);
                               var rel_amt = props.rate_amount - $('#ttl_amount_release').val();
                               $('#release_amount').val(rel_amt.toFixed(2));
                               $('#release_amount2').val(rel_amt.toFixed(2));
                            });

                            // console.log(JSON.stringify(data));
                            // $('#city').val(data.city);
                            /*$('#agent_id').empty();
                            $('#agent_id').append("<option selected disabled>Select Agent</option>");
                            data.counter.forEach(function(agent){
                                $('#agent_id').append('<option value="'+agent.city+'">'+agent.city+'</option>');
                            });*/
                            /*data.suburb.forEach(function(suburb){
                                $('#suburb').append('<option value='+suburb.id+'>'+suburb.suburb+'-'+suburb.postcode+'</option>');
                            });*/
                        //$('#spinner').modal('toggle');

                    },
                    /*error:function(e){
                      console.log(e);
                    }*/
                    error: function (jqXHR, exception) {
                        console.log(jqXHR);
                    }
                });
                } //end else
            });

        $('#release_amount').on('keyup', function () {
            var rl = $('#release_amount2').val();
            var dInput = $(this).val();
            console.log(dInput);
            if (dInput > rl) {
                $('#release_amount').val(rl)
            }
            //alert('ready');
        });
    </script>

@stop