<?php
$form = $this->cancellationform;
$form->setAttribute('action', $this->url('cabfare', ['action' => 'add-fees-fare']));
$form->setAttribute('method', 'post');
echo $this->form()->openTag($form);

if(isset($VndViewFare)){
    
    foreach ($form->getElements() as $element) {
    $element->setAttribute('disabled', true);
    $element->setAttribute('readonly',true);
    }
}

$cancellation_fare = isset($fareDetails['cancellation_fare'])?$fareDetails['cancellation_fare']:'';
$waiting_fee_upto = isset($fareDetails['waiting_fare'])?$fareDetails['waiting_fare']:'';
//echo '<pre>';print_r($waiting_fee_upto);die();
//$waiting_fee_upto = isset($waiting_fare['waiting_fee_upto_minutes'])?$waiting_fare['waiting_fee_upto_minutes']:'';
$kmRateString="";
$preWaitingstring="";

if($waiting_fee_upto!=''){
   //$waiting_fareArr  = json_decode($waiting_fee_upto);
   $kmRateSting = '';
   foreach($waiting_fee_upto as $key=>$value){
        $counter = $key;
        //$kmRate  = explode('_',$value);
        $kmRateString  .='<div class="row form-group"><div class="col-sm-2"><input type="text" class="form-control" id="kms_'.$counter.'" name="waiting_time_minutes_upto[]" value="'.$value['waiting_minute_upto'].'"></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['waiting_fees'].'" name="waiting_time_fees[]" ></div></div><div class="col-sm-1 removeDistanceFields"  id="removeDistanceFields_"'.$counter.'><a href="#"><i class="fa fa-trash-o fa-2x"></i></a></div><div class="col-sm-2">&nbsp;</div></div>';

   }
}

/* 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 removeDistanceFields"  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 */

echo $this->formElement($form->get('cancellation_fees_id')->setValue(isset($cancellation_fare['id'])?$cancellation_fare['id']:''));
echo $this->formElement($form->get('waiting_charge_id')->setValue(isset($waiting_fare['id'])?$waiting_fare['id']:''));
echo $this->formElement($form->get('pre_waiting_charge_id')->setValue(isset($pre_waiting_fare['id'])?$pre_waiting_fare['id']:''));

?>

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

                <form role="form">


                    <!--<label class="control-label" style="margin-right:30px;">Cancellation Fee</label>-->
                    <h4 class="cancellationFees_distance">Cancellation Fees</h4>
                    <div class="form-inline">

                        <div class="col-sm-1 no-padding">
                            <div class="carbooking">
                                <input type="radio" value="%" name="cancellation_type" id="cancellationFee1" <?php if(isset($cancellation_fare['cancellation_type']) && $cancellation_fare['cancellation_type'] =='%'){ ?> checked="checked" <?php } else{echo 'checked="checked"';}?> />
                                <label for="cancellationFee1"><span class="radio">%</span></label>
                            </div>
                        </div>

                        <div class="col-sm-1 no-padding margin0x5">
                            <div class="carbooking">
                                <input type="radio" value="Rs" name="cancellation_type" id="cancellationFee2" <?php if(isset($cancellation_fare['cancellation_type']) && $cancellation_fare['cancellation_type'] =='Rs'){ ?> checked="checked" <?php }?> />
                                <label for="cancellationFee2"><span class="radio"><i class="fa fa-inr"></i></span></label>
                            </div>


                        </div>


                        <div class="input-group col-sm-2"><span class="input-group-addon" id="cancellationUnit">Rs</span>
                            <?php echo $this->formElement($form->get('cancellation_fees')->setValue(isset($cancellation_fare['cancellation_value'])?$cancellation_fare['cancellation_value']:'')); ?>
                        </div>
                    </div>
                    <hr>



                    <h4 class="waitingTime_hour">Waiting Time Fees</h4>
                    <p class="waitingTimeDetail_hour">You Can Charge An Additional Fee For Waiting Time Upto 10 Minutes, Another From 11- 20 Minutes, And So On</p>

                    <div class="col-sm-12">
                        <div class="col-sm-2">
                            <label class="waitingMinutesUpTo_hour"><?php echo $this->translate($form->get('waiting_time_minutes_upto[]')->getLabel()); ?></label>
                        </div>

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

                    <div id="mainWaitningFee">
                        <div class="row form-group">
                            <div class="col-sm-2 margin-left0">
                               <?php echo $this->formElement($form->get('waiting_time_minutes_upto[]'));?>
                            </div>

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

                        <?php if(!isset($VndViewFare)){ ?>
                             <div class="col-sm-4"><div class="col-sm-4 addWaitingFee no-padding" id="addWaitingFee_3 ">

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

                            <div class="col-sm-2">&nbsp;</div>
                         </div>
                         <?php } ?>
                        </div>
                    </div>

                    <div id="append_waiting_fee"></div>
                    <?php echo $kmRateString;?>

                    <hr>

                    <h4>Pre Waiting Fees</h4>

                    <div class="row">
                        <div class="col-sm-3"><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[]'));?>
                            </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[]'));?>
                                </div>
                            </div>
                              <?php if(!isset($VndViewFare)){?>
                              <div class="col-sm-2">
                                  <div class="addprewaiting_on_plus no-padding" id="addprewaiting_3">

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

                                  </div>
                              </div>
                             <?php }?>
                            <div class="col-sm-1"></div>
                        </div>

                    </div>

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

                    <hr>



<!--                    <div class="col-sm-12 no-padding">
                        <div class="col-sm-3">
                            <label class="booking-check">Update All Rows
                                <input type="checkbox"  value="1" name="UpdatedStatus_tax_basic" id="UpdatedStatus_tax_basic">
                                <span class="checkmark"></span>
                            </label>
                        </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-r-10">
                            <a href="#PremiumVehicle" id="basicVehiclen" data-toggle="tab">
                                <button class="btn btn-info form-control margin-bttom10px">Next</button>
                            </a>
                        </div>-->
                        <div class="col-sm-2 pull-right margin-bttom10px"> <a href="#" data-toggle="tab">
                                 <?php if(!isset($VndViewFare)){echo $this->formElement($form->get('save'));}?>
                            </a>
                        </div>
                        <div class="col-sm-2 pull-right display-none" id="basic_fair_manage_vehicle">
                            <a href="#" data-toggle="tab">
                                <button class="btn btn-info form-control margin-bttom10px">Save</button>
                            </a> </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="col-sm-4 col-md-4"></div>
    </div>
</div>
<?php echo $this->form()->closeTag(); ?>