<?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 remove_peaktime_row"  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;
        $extrasFareString .='<div style="margin-top:10px;" class="rowextra"><div class="input-group col-sm-4" 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-4" style="margin-right:30px;"><input type="text" class="form-control" placeholder="" name="extras_no_name2[]" value="'.$val['extra_value'].'"></div><div class="input-group" id="removeExtraFields"> <a href="#" style="width:90px;"><i class="fa fa-trash-o fa-2x"></i></a> </div></div>';
    }
}

?>

<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('Premium'); ?> </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->setAttribute('action', $this->url('setting', ['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']:''));

?>
<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="row form-group">
                            <div class="col-sm-4 form-group">
 <h5>Booking Type</h5>
<?php echo $this->FormElement($form->get('booking_type')->setValue(isset($nightFare['booking_type']) ? $nightFare['booking_type'] : '')); ?>
                            </div>
                             
                             <div class="col-sm-3 form-group">
                                <h5>From Date</h5>
<?php echo $this->formElement($form->get('night_fare_date_from')->setValue(isset($nightFare['from_date'])? date('d-m-Y',strtotime($nightFare['from_date'])):'')); ?>
                            </div>
                            <div class="col-sm-3 form-group">
                                <h5>To Date</h5>
<?php echo $this->formElement($form->get('night_fare_date_to')->setValue(isset($nightFare['to_date'])? date('d-m-Y',strtotime($nightFare['to_date'])):'')); ?>
                            </div>
                        </div>

                        <hr>
                        <div class="row form-group">
                            <div class="col-sm-2 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-2 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 class="col-sm-2" style="margin-top: 30px;">
                                <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" style="margin-top: 30px;">
                                <div class="carbooking">
                                    <input type="radio" value="Value" name="night_rate_type" id="nightCh2" <?php if(isset($nightFare['night_rate_type']) && $nightFare['night_rate_type']=='Value'){ echo 'checked="checked"';}?>/>
                                    <label for="nightCh2"><span class="radio">Value</span></label>
                                </div>

                            </div>

                            <div class="col-sm-2" style="margin-top: 25px;">
                                    <?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 class="col-sm-1 form-group">
                                                                        <label class="nightRateEnd_premium">&nbsp;</label>
         
                                                                        <input type="submit" name="premium_fare_btn" id="premium_fare_btn" class="save_data_btn btn btn-primary btn-new-vehile profile_save btn-warning" value="Save">
                                                                    </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="%" name="premiums_type" id="premiumCh1" <?php if(isset($premiumsFare['premiums_type']) && $premiumsFare['premiums_type']=='%'){ 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="Rs" name="premiums_type" id="premiumCh2" <?php if(isset($premiumsFare['premiums_type']) && $premiumsFare['premiums_type']=='Rs'){ 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>

                        <div class="row form-group">
                            <div class="col-sm-4 margin-left15 form-group">
                                <label class="nightRateBegin_premium"><?php echo $this->translate($form->get('premium_fare_date_from')->getLabel()); ?></label>
<?php echo $this->formElement($form->get('premium_fare_date_from')->setValue(isset($premiumsFare['from_date'])? date('d-m-Y',strtotime($premiumsFare['from_date'])):'')); ?>
                            </div>
                            <div class="col-sm-4 form-group">
                                <label class="nightRateEnd_premium"><?php echo $this->translate($form->get('premium_fare_date_to')->getLabel()); ?></label>
<?php echo $this->formElement($form->get('premium_fare_date_to')->setValue(isset($premiumsFare['to_date'])? date('d-m-Y',strtotime($premiumsFare['to_date'])):'')); ?>
                            </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>


                                <div class="input-group"><div class="input-group addpeaktime_on_plus no-padding" id="addpeaktime_1"><a  class="btn btn-info form-control">Add More</a></div></div>

                            </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-4">
                                <?php echo $this->formElement($form->get('extras_no_name1[]'));?>
                            </div>
                            <div class="input-group col-sm-4">
                                <?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>-->
                                <div class="input-group addExtras margin-right20" id="addExtras_1">
                                   <a class="btn btn-info form-control">Add More</a>
                                </div>


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

                                        <?php echo $this->formElement($form->get('premium_fare_btn'));?>
                                    </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(); ?>

                                                <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('night-fare-listing.phtml'); ?>
                                                            </div>
                                                            <!-- /.box-body -->
                                                        </div>
                                                    </div>
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <br>
        <!-- /.widget-box -->
    </div>
    <!-- /.col -->
</section>



