<section class="content">
    <div class="row">
        <div class="col-sm-12">
            <div class="tabbable">
                <div class="tab-content no-border padding-24">
                    <div class="tab-pane fade in active" id="faq-tab-1">
                        <div class="space-8"></div>
                        <div class="panel-group accordion-style1 accordion-style2" id="faq-list-1">
                            <div class="panel panel-default">
                                <div class="panel-headingnew"><?php echo $this->translate('Pre Waiting Fees'); ?> </div>
                                <div class="left_panel col-sm-12 padding_margin0 pull-left bgwhite">
                                    <?php echo $this->partial('menu-sidebar.phtml'); ?>
                                    <div class="tab-content tab_editprofile col-sm-10 padding-left0 marginbott10px margintop10px">
                                        <div id="common-tab" class="tab-pane fade in tab_editprofile tab_editprofile1 active">
                                            <div class="col-sm-col-sm-offset-1 margin-10auto0 paddingRL10px">
                                                <?php
                                                $form = $this->form;
                                                $form->prepare();
                                                $form->setAttribute('action', $this->url('setting', ['action' => 'add-prewaiting-fees-fare']));
                                                $form->setAttribute('method', 'post');
                                                echo $this->form()->openTag($form);

                                                
                                                $preWaitingstring = "";

                                                /* Pre waiting minute fees upto */
   $pre_waiting_min_fee = isset($fareDetails['pre_waiting_fare']) ? $fareDetails['pre_waiting_fare'] : '';
   //$pre_waiting_min_fee = isset($pre_waiting_fare['pre_waiting_fee_upto_minutes'])?$pre_waiting_fare['pre_waiting_fee_upto_minutes']:'';
                                                if ($pre_waiting_min_fee != '') {
                                                    //$pre_waiting_fareArr  = json_decode($pre_waiting_min_fee);
                                                    $preWaitingstring = '';

                                                    foreach ($pre_waiting_min_fee as $key => $value) {
                                                        $counter = $key;
                                                        //$kmRate  = explode('_',$value);
                                                        $preWaitingstring .= '<div class="row form-group"><div class="col-sm-2"><input type="text" class="form-control" id="kms_' . $counter . '" name="pre_waiting_minutes_upto[]" value="' . $value['pre_waiting_upto_minutes'] . '"></div><div class="col-sm-2" ><div class="input-group"><span class="input-group-addon">Rs</span><input type="text" class="form-control" id="rs_' . $counter . '" value="' . $value['pre_waiting_fees'] . '" name="pre_waiting_fee[]" ></div></div><div class="col-sm-1 remove_prewaitingtime_row_user"  id="removeDistanceFields_"' . $counter . '><a href="#"><i class="fa fa-trash-o fa-2x"></i></a></div><div class="col-sm-2">&nbsp;</div></div>';
                                                    }
                                                }
                                                /* END */
                                                ?>

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

                                                               
                                                                <h4 class="cancellationFees_distance">Pre Waiting Fees</h4>

                                                                <div class="row form-group">
                            <div class="col-sm-3 form-group">
 <label class="nightRateBegin_premium"><?php //echo $this->translate($form->get('booking_type')->getLabel()); ?></label>
<h4>Booking Type</h4>
<?php echo $this->FormElement($form->get('booking_type')->setValue(isset($pre_waiting_min_fee[0]['booking_type']) ? $pre_waiting_min_fee[0]['booking_type'] : '')); ?>
                            </div>
                                                                 
                                                                </div>
                                                                <hr>

                                                                <h4>Pre Waiting Fees</h4>

                                                                <div class="row">
                                                                   
                                                                    <div class="col-sm-2"><label><?php echo $this->translate($form->get('pre_waiting_minutes_upto[]')->getLabel()); ?></label></div>
                                                                    <div class="col-sm-2"><label><?php echo $this->translate($form->get('pre_waiting_fee[]')->getLabel()); ?></label></div>
                                                                    <div class="col-sm-3"></div>
                                                                    <div class="col-sm-3">&nbsp;</div>
                                                                </div>


                                                                <div id="PreWaitingTimeDiv_package">
                                                                    <div class="row form-group">
                                                                        
                                                                        <div class="col-sm-2">
<?php echo $this->formElement($form->get('pre_waiting_minutes_upto[]')->setValue('')); ?>
                                                                        </div>
                                                                        <div class="col-sm-2">
                                                                            <div class="input-group">
                                                                                <span class="input-group-addon">Rs</span>
                                                                        <?php echo $this->formElement($form->get('pre_waiting_fee[]')->setValue('')); ?>
                                                                            </div>
                                                                        </div>

                                                                            <div class="col-sm-2">
                                                                                <div class="addprewaiting_on_plus_user no-padding" id="addprewaiting_3">

                                                                                    <a href="#" class="btn btn-info form-control">Add More</a>

                                                                                </div>
                                                                            </div>

                                                                        <div class="col-sm-1"></div>
                                                                    </div>

                                                                </div>

                                                                <div id="appended_PreWaitingTime_package"></div>
<?php echo $preWaitingstring; ?>
                                                                <hr>


                                                                <div class="row ">
                                                                    <div class="col-sm-3"></div>
                                                                    <div class="col-sm-3"></div>
                                                                    <div class="col-sm-2 pull-right margin-bttom10px">
                                                                        <?php echo $this->formElement($form->get('save'));?>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4 col-md-4"></div>
                                                    </div>
                                                </div>

<?php echo $this->form()->closeTag(); ?>

<span class="checkbox_error"></span>                                                
                                                <div class="panel panel-default">
                                                    <div class="panel-headingnew"> View/Update Records </div>
                                                    <div id="faq-1-3" class="panel-collapse collapse in" aria-expanded="false">
                                                        <div class="box">
                                                            <!-- /.box-header -->
                                                            <div class="box-body table-responsive listing-data">
                                                                <?php echo $this->partial('prewaiting-fees-listing.phtml'); ?>
                                                            </div>
                                                            <!-- /.box-body -->
                                                        </div>
                                                    </div>
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <br>
        <!-- /.widget-box -->
    </div>
    <!-- /.col -->
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).on('click', '.addprewaiting_on_plus_user', function () {
    var addButtonId = $(this).attr('id');
    var counterArr = addButtonId.split("_");
    var counter = counterArr[1];
    counter++;
    var detailsdiv = "";
    detailsdiv += '<div class="row form-group" style="margin-top:10px;"><div class="col-sm-2"><input type="text" name="pre_waiting_minutes_upto[]" id="pre_waiting_minutes_' + counter + '" class="form-control"/></div><div class="col-sm-2"><div class="input-group"> <span class="input-group-addon waitingFeeRupees_hour">Rs</span><input type="text" name="pre_waiting_fee[]" id="pre_waiting_fees_' + counter + '" class="form-control"/></div></div><div class="col-sm-1 remove_prewaitingtime_row_user"><a href="#"  id="removePreWaitingPkgFields_' + counter + '"><i class="fa fa-trash-o fa-2x"></i></a></div></div>';
    appendedPreWaitingTimeLength++;
    $("#appended_PreWaitingTime_package").append(detailsdiv);
    return false;

});


$(document).on('click', '.remove_prewaitingtime_row_user', function () {
    var addId = $(".addprewaiting_on_plus_user").attr('id');
    var addIdArr = addId.split("_");
    var counter = addIdArr[1];
    counter--;
    $(this).closest('.row').remove();
    var addbtn_length = $("#appended_PreWaitingTime_package .addprewaiting_on_plus_user").length;
    var row_leng = $("#appended_PreWaitingTime_package .row").length;
    appendedPreWaitingTimeLength--;
    return false;
});
</script>

