<?php
$form = $this->distancewatingform;
$form->setAttribute('action', $this->url('cabfare', ['action' => 'add-price-distance-waiting']));
$form->setAttribute('method', 'post');
echo $this->form()->openTag($form);

$bookingMode    = $this->bookingMode;
$masterlocalpkg = $this->masterLocalPkg;

$local_package_fare = isset($fareDetails['local_package_fare'])?$fareDetails['local_package_fare']:'';
if(!empty($local_package_fare)){
    $package_fare_data = array_column($local_package_fare, 'local_pkg_fare','local_pkg_id');
}

$distance_waiting_fare = isset($fareDetails['distance_waiting_fare'])?$fareDetails['distance_waiting_fare']:'';
/*$waiting_time_fees = $distance_waiting_fare['waiting_fees'];
if ($waiting_time_fees != '') {
    $waiting_time_fees_arr = explode('_', $waiting_time_fees);
}*/

echo $this->formElement($form->get('distance_waiting_fare_id')->setValue(isset($distance_waiting_fare['id'])?$distance_waiting_fare['id']:''));
?>
<div class="row">
    <div class="col-sm-12">
        <div class="col-sm-12 col-md-12 mrgin20auto5 padding10px">
        <div class="portlet-body">
            <h4 class="distanceRate_distanceWaiting">Distance Waiting Rates</h4>
            <div class="form-group clearfix">
                <div class="col-sm-2">
                   <label class="ratePerKm_distanceHour"><?php echo $this->translate($form->get('rate_per_km')->getLabel()); ?></label>
                    <div class="input-group"> <span class="input-group-addon ratePerKmRupees_distanceWaiting">Rs</span>
                       <?php echo $this->formElement($form->get('rate_per_km')->setValue(isset($distance_waiting_fare['per_km_charge'])?$distance_waiting_fare['per_km_charge']:'')); ?>
                    </div>
                </div>
                <div class="col-sm-3">
                        <label class="firstKmRate_distanceHour"><?php echo $this->translate($form->get('ignore_first_km_after')->getLabel()); ?></label>
                        <div class="input-group"> <span class="input-group-addon">Km</span>
                            <?php echo $this->formElement($form->get('ignore_first_km_after')->setValue(isset($distance_waiting_fare['minimum_distance'])?$distance_waiting_fare['minimum_distance']:'')); ?>
                        </div>
                    </div>
                 <div class="col-sm-2">
                        <label class="minimumFare_distanceHour"><?php echo $this->translate($form->get('minimum_fare')->getLabel()); ?></label>
                        <div class="input-group"> <span class="input-group-addon minimumFareRupees_distanceHour">Rs</span>
                            <?php echo $this->formElement($form->get('minimum_fare')->setValue(isset($distance_waiting_fare['minimum_charge'])?$distance_waiting_fare['minimum_charge']:'')); ?>
                        </div>
                    </div>
            </div>
            <div class="col-sm-12">
                <hr>
                <h4 class="waitTime_distanceWaiting">Waiting Time Fees</h4>
                <p class="waitTimeDetail_distanceWaiting">You Can Charge An Additional Fee For Waiting Time
                    Upto 10 Minutes, Another From 11- 20 Mminutes,
                    And So On</p>
                <div class="row">
                    <div class="col-sm-2 margin-left15">
                        <label class="minuteUpTo_distanceWaiting"><?php echo $this->translate($form->get('minutes_upto')->getLabel()); ?></label>
                    </div>
                    <div class="col-sm-2">
                        <label class="fee_distanceWaiting"><?php echo $this->translate($form->get('fee')->getLabel()); ?></label>
                    </div>
                    <div class="col-sm-2">
                        <label class="afterFees_distanceWaiting"><?php echo $this->translate($form->get('after_that_fees_per_minutes')->getLabel()); ?></label>
                    </div>
                    <div class="col-sm-3"></div>
                    <div class="col-sm-3">&nbsp;</div>
                </div>
                <div id="mainWaitningFee11">
                    <div class="row form-group">
                        <div class="col-sm-2 margin-left0 margin-top0">
                            <div class="input-group"> <span class="input-group-addon ">Rs</span>
                               <?php echo $this->formElement($form->get('minutes_upto')->setValue(isset($distance_waiting_fare['minutes_upto'])?$distance_waiting_fare['minutes_upto']:'')); ?>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="input-group"> <span class="input-group-addon feeRupees_distanceWaiting">Rs</span>
                                 <?php echo $this->formElement($form->get('fee')->setValue(isset($distance_waiting_fare['fees'])?$distance_waiting_fare['fees']:'')); ?>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="input-group"> <span class="input-group-addon afterFessRupees_distanceWaiting">Rs</span>
                              <?php echo $this->formElement($form->get('after_that_fees_per_minutes')->setValue(isset($distance_waiting_fare['fees_per_minute'])?$distance_waiting_fare['fees_per_minute']:'')); ?>
                            </div>
                            &nbsp; </div>
                    </div>
                </div>
                <div id="appended_text_form"></div>
<!--                <div>
                    <label class="booking-check"><?php //echo $this->translate($form->get('update_all_rows')->getLabel()); ?>
                         <?php //echo $this->formElement($form->get('update_all_rows')); ?>
                        <span class="checkmark"></span>
                    </label>

                </div>-->
                 <?php  if(!empty($masterlocalpkg) && $bookingMode==4){ ?>

                <div class="col-sm-12 no-padding">
                    <div class="col-sm-2"><label><?php echo $this->translate($form->get('distance_waiting_package_name[]')->getLabel()); ?></label></div>
                        <div class="col-sm-2"><label><?php echo $this->translate($form->get('distance_waiting_ignore_km[]')->getLabel()); ?></label></div>
                        <div class="col-sm-2"><label><?php echo $this->translate($form->get('distance_waiting_amount[]')->getLabel()); ?></label></div>
                    <div class="col-sm-2 margin-left15"></div>
                    <div class="col-sm-3">&nbsp;</div>
                </div>
                 <?php }?>
                <!-- Add more comment option
                <div id="DistWaitDiv_package"><div class="row margin-bttom10px">
                        <div class="col-sm-2"><?php //echo $this->formElement($form->get('distance_waiting_package_name[]')); ?></div>
                        <div class="col-sm-2"><?php //echo $this->formElement($form->get('distance_waiting_ignore_km[]')); ?></div>
                        <div class="col-sm-2"><?php //echo $this->formElement($form->get('distance_waiting_amount[]')); ?></div>
                    <div class="col-sm-4">
                        <div class="col-sm-4 add_DistWaitLCLpkg no-padding" id="DistWaitLCLpkgAdd_3">
                            <a href="#" class="btn btn-info form-control">Add More</a>
                        </div>
                    </div>
                    </div>
                </div>
                <div id="appended_Dis_Wait_pkgdiv"></div>-->

                <?php  if(!empty($masterlocalpkg) && $bookingMode==4){
                            foreach($masterlocalpkg as $val){
                                $localId = $val['id'];
                               $fare_value =  isset($package_fare_data[$localId])?$package_fare_data[$localId]:'';
                                ?>
                   <div class="col-sm-12 no-padding margin-bttom10px">
                            <div class="col-sm-2"><?php echo $val['name']; ?></div>
                            <div class="col-sm-2"><?php echo $val['km']; ?></div>
                            <div class="col-sm-2"><?php echo $this->formElement($form->get('distance_waiting_amount[]')->setValue($fare_value)); ?></div>
                            <input type="hidden" name="localpkgid[]" value="<?php echo $localId;?>"/>
                    </div>
                <?php }} ?>

                <div class="col-sm-2"></div>
                <div id="appended_Dis_Wait_pkgdiv"></div>

            </div>
                </div>



                <div class="row ">
                    <div class="col-sm-3"></div>
                    <div class="col-sm-3"></div>
                    <div class="col-sm-2 pull-right margin-bttom10px margin-r-10" id="Distance_Waitingn">
                        <a href="#basicVehicle" data-toggle="tab">
                             <?php echo $this->formElement($form->get('next')); ?>
                        </a>
                    </div>
                    <?php if(!isset($VndViewFare)){ ?>
                    <div class="col-sm-2 pull-right margin-bttom10px">
                        <a href="#" data-toggle="tab">
                             <?php echo $this->formElement($form->get('save')); ?>
                        </a>
                    </div>
                    <?php }?>
                    <div class="col-sm-2 pull-right display-none margin-bttom10px no-padding"> <a href="#" data-toggle="tab">
                            <button class="btn btn-info form-control">Save</button>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

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