<?php
$nightFare    =   isset($fareDetails['night_charge'])?$fareDetails['night_charge']:'';
$premiumsFare =   isset($fareDetails['premiums_charge'])?$fareDetails['premiums_charge']:'';
$peakTimeFare =   isset($fareDetails['peak_time_fare'])?$fareDetails['peak_time_fare']:'';
$extrasFare   =   isset($fareDetails['extras_fare'])?$fareDetails['extras_fare']:'';

$peakTimeString="";
$extrasFareString="";

if(!empty($peakTimeFare)){
   foreach($peakTimeFare as $key=>$value){
        $counter = $key;
        $peakTimeString  .='<div class="row form-group"><div class="col-sm-2 input-group"><input type="text" class="form-control timepicker"  name="start_time[]" value="'.$value['start_time'].'"></div><div class="col-sm-2 input-group" ><input type="text" class="form-control timepicker"  value="'.$value['end_time'].'" name="end_time[]" ></div><div class="col-sm-2 input-group"><input type="text" class="form-control"  name="peaktime_value[]" value="'.$value['peaktime_value'].'"></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>';
   }
}
//echo '<pre>';print_r($extrasFare);die();

if(!empty($extrasFare)){
    foreach($extrasFare as $key1=>$val){
        $counter1 = $key1;
        if(isset($val['extra_value_type']) && $val['extra_value_type'] =='%'){
             $perchecked='checked';
        }else{
             $perchecked='';
        }
        if(isset($val['extra_value_type']) && $val['extra_value_type'] =='Rs'){
            $rschecked='checked';
        }else{
             $rschecked='';
        }
        $extrasFareString .='<div style="margin-top:10px;" class="rowextra"><div class="input-group col-sm-3" style="margin-right:30px;"><input type="text" name="extras_no_name1[]" class="form-control allowtext" placeholder="" value="'.$val['extras_master_id'].'"></div><div class="input-group col-sm-3" style="margin-right:30px;"><input type="text" class="form-control" placeholder="" name="extras_no_name2[]" value="'.$val['extra_value'].'"></div><div class="input-group col-sm-4"><div class="col-sm-6"><div class="carbooking"><input type="radio" value="%" name="extrasvaluetype['.$counter1.']" id="extrasvaluetypeper_'.$counter1.'" checked="'.$perchecked.'"/><label for="extrasvaluetypeper_'.$counter1.'"><span class="radio">%</span></label></div></div><div class="col-sm-6"><div class="carbooking"><input type="radio" value="Rs" name="extrasvaluetype['.$counter1.']" id="extrasvaluetypers_'.$counter1.'" checked="'.$rschecked.'"/><label for="extrasvaluetypers_'.$counter1.'"><span class="radio">Rs</span></label></div></div></div><div class="input-group" id="removeExtraFields"> <a href="#" style="width:90px;"><i class="fa fa-trash-o fa-2x"></i></a> </div></div>';
    }
}

?>
<?php
$form = $this->premiumform;
$form->setAttribute('action', $this->url('cabfare', ['action' => 'add-price-premium']));
$form->setAttribute('method', 'post');
echo $this->form()->openTag($form);
echo $this->formHidden($form->get('night_premium_id')->setValue(isset($nightFare['id'])?$nightFare['id']:''));
echo $this->formHidden($form->get('premiums_id')->setValue(isset($premiumsFare['id'])?$premiumsFare['id']:''));

if(isset($VndViewFare)){
    
    foreach ($form->getElements() as $element) {
    $element->setAttribute('disabled', true);
    $element->setAttribute('readonly',true);
    }
}
?>
<div class="row">
    <div class="col-sm-12">

        <div class="col-sm-12 col-md-12">
            <div class="portlet-body">
                <div class="col-sm-12 padding10px">
                        <h4 class="nightPremium_premium"><?php echo $this->translate('Night Premium'); ?></h4>

                        <div class="form-inline form-group">

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

                            </div>

                            <div class="col-sm-2 no-padding margin-top10px">
                                <div class="carbooking">
                                    <input type="radio" value="Rs" name="night_rate_type" id="nightCh2" <?php if(isset($nightFare['night_rate_type']) && $nightFare['night_rate_type']=='Rs'){ echo 'checked="checked"';}?>/>
                                    <label for="nightCh2"><span class="radio">Rs</span></label>
                                </div>

                            </div>

                            <div class="input-group">
                                    <?php echo $this->FormElement($form->get('night_rate_value')->setValue(isset($nightFare['night_rate_value'])?$nightFare['night_rate_value']:'')); ?>
                                    <?php echo $this->formElementErrors($form->get('night_rate_value'), ['class' => 'error']); ?>
                            </div>

                        </div>

                        <hr>
                        <div class="row form-group">
                            <div class="col-sm-4 margin-left15 form-group">
                                <label class="nightRateBegin_premium"><?php echo $this->translate($form->get('night_rate_begins')->getLabel()); ?></label>
<?php echo $this->formElement($form->get('night_rate_begins')->setValue(isset($nightFare['night_rate_begins'])?$nightFare['night_rate_begins']:'')); ?>
                                <?php echo $this->formElementErrors($form->get('night_rate_begins'), ['class' => 'error']); ?>
                            </div>
                            <div class="col-sm-4 form-group">
                                <label class="nightRateEnd_premium"><?php echo $this->translate($form->get('night_rate_ends')->getLabel()); ?></label>
<?php echo $this->formElement($form->get('night_rate_ends')->setValue(isset($nightFare['night_rate_ends'])?$nightFare['night_rate_ends']:'')); ?>
                                <?php echo $this->formElementErrors($form->get('night_rate_ends'), ['class' => 'error']); ?>
                            </div>
                        </div>
                        <hr>
                        <h4 class="premiums_premium">Premiums</h4>
                        <p class="premiumsDetail_premium">A Premium is a Fee Automatically Added To a Fare At
                            The Time Of Booking Note, This Ts Different From An
                            Extra Add On. Premiums Might Include Bookings
                            taken by credit Card. or on bank Holidays</p>
                        <label class="control-label creditCard_premium" style="margin-right:30px;">Credit Card</label>
                        <div class="form-inline">

                            <div class="col-sm-2 no-padding margintop10px">

                                <div class="carbooking">
                                    <input type="radio" value="1" name="premiums_type" id="premiumCh1" <?php if(isset($premiumsFare['premiums_type']) && $premiumsFare['premiums_type']==1){ echo 'checked="checked"';}else{echo 'checked="checked"';}?>/>
                                    <label for="premiumCh1"><span class="radio">%</span></label>
                                </div>

                            </div>

                            <div class="col-sm-2 no-padding margintop10px">
                                <div class="carbooking">
                                    <input type="radio" value="2" name="premiums_type" id="premiumCh2" <?php if(isset($premiumsFare['premiums_type']) && $premiumsFare['premiums_type']==2){ echo 'checked="checked"';}?>/>
                                    <label for="premiumCh2"><span class="radio">Rs</span></label>
                                </div>


                            </div>


                            <div class="input-group form-group">
<?php echo $this->formElement($form->get('premiums_value')->setValue(isset($premiumsFare['premiums_value'])?$premiumsFare['premiums_value']:'')); ?>
                                 <?php echo $this->formElementErrors($form->get('premiums_value'), ['class' => 'error']); ?>
                            </div>
                        </div>

                        <hr>


                        <h4>Peak Time Charges</h4>

                        <div class="col-sm-12">
                            <div class="col-sm-2"><label>From</label></div>
                            <div class="col-sm-2"><label>To</label></div>
                            <div class="col-sm-2"><label>Percentage</label></div>
                            <div class="col-sm-2">&nbsp;</div>
                            <div class="col-sm-2">&nbsp;</div>
                        </div>




                        <div id="PeakTimeDiv_package" class="PeakTimeDiv_package">
<?php echo $peakTimeString;?>
                            <div class="row form-group">
                                <div class="col-sm-2 input-group">
                                    <?php echo $this->formElement($form->get('start_time[]')); ?>
                                </div>
                                <div class="col-sm-2 input-group" >
                                    <?php echo $this->formElement($form->get('end_time[]')); ?>
                                </div>
                                <div class="col-sm-2 input-group" >
                                    <?php echo $this->formElement($form->get('peaktime_value[]')); ?>
                                </div>


<?php if(!isset($VndViewFare)){ ?>
                                <div class="input-group"><div class="input-group addpeaktime_on_plus no-padding" id="addpeaktime_1"><a  class="btn btn-info form-control">Add</a></div></div> <?php } ?>

                            </div>
                        </div>

                        <div id="appended_PeakTime_package" class="PeakTimeDiv_package">

                        </div>





                        <h4 class="extras_premium">Extras</h4>
                        <p class="extrasDetail_premium">An Extra Is Any Additional Cost On Top Of The Quoted
                            Fare. E.g. You May Wish To Charge Extra For A Child
                            Seat Or A Parking Fee. Add Bespoke Extras Here.
                            With a Percentage Of The Fare Or Fixed Amount
                            Added</p>
                         <div class="col-sm-12">
                            <div class="col-sm-3"><label>Extra Type</label></div>
                            <div class="col-sm-3"><label>Price</label></div>
                        </div>

                        <div class="col-sm-12">

                            <div id="mainIdExtra" class="display-inline extraPeakTimeDiv">
                             <?php echo $extrasFareString;?>
                            <div class="input-group col-sm-3">
                                <?php echo $this->formElement($form->get('extras_no_name1[]'));?>
                            </div>
                            <div class="input-group col-sm-3">
                                <?php echo $this->formElement($form->get('extras_no_name2[]'));?>
                            </div>


                            <div class="input-group col-sm-4" id="extras_fee_div">
                                <div class="col-sm-6">
                                    <div class="carbooking">
                                        <input type="radio" value="%" name="extrasvaluetype[1]" id="extrasvaluetypeper_1" checked="checked"/>
                                        <label for="extrasvaluetypeper_1"><span class="radio">%</span></label>
                                    </div>


                                </div>

                                <div class="col-sm-6">
                                    <div class="carbooking">
                                        <input type="radio" value="Rs" name="extrasvaluetype[1]" id="extrasvaluetypers_1"/>
                                        <label for="extrasvaluetypers_1"><span class="radio">Rs</span></label>
                                    </div>

                                </div>

                            </div>
                                    <?php if(!isset($VndViewFare)){ ?>
                                <div class="input-group addExtras margin-right20" id="addExtras_1">
                                   <a class="btn btn-info form-control">Add More</a>
                                </div>
                                    <?php }?>


                            </div>
                            <div id="append_extras" class="margintopbottom20 extraPeakTimeDiv">
                               </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 margin-top10px"> <a href="#Fixed_RoutesVehicle" id="PremiumVehiclen" data-toggle="tab">
                                        <button class="btn btn-info form-control margin-bttom10px widthpersent100">Next</button>
                                    </a> </div>-->
                                <div class="col-sm-2 pull-right margin-top10px"> <a href="#" data-toggle="tab">

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

                        </div>
                </div>
            </div>
        </div>

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