<?php 
$cabfare_details = isset($fareDetails['cabfare_detail']) ? $fareDetails['cabfare_detail'] : '';
//echo '<pre>';print_r($cabfare_details);die();
$fareId = $this->fareId;
$get_weak = [];
if (isset($cabfare_details['week_days']) && $cabfare_details['week_days'] != '') {
    $get_weak = explode(',', $cabfare_details['week_days']);
}
$distance_city_display = "display-none";
if (isset($cabfare_details['master_package_id']) && $cabfare_details['master_package_id'] == 5) {
    $distance_city_display = "";
}
$client_dropdown= "display-none";
if(isset($cabfare_details['client_id']) && $cabfare_details['client_id']>0){
    $client_dropdown= "display-block";
}
?>

<div class="panel panel-default" id="fare_add">

    <div class="panel-headingnew"><?php if(isset($VndViewFare)){ echo "View Vendor Fare";} else{echo "Add Fare";}?>


    </div>

    <div id="faq-1-1" class="panel-collapse collapse in" aria-expanded="true">
        <div class="panel-body">

            <div class="tab-content" id="myTabContent">
                <div id="home" class="tab-pane fade active in">
                    <div class="col-sm-col-sm-offset-1 margin-10auto0 paddingRL10px">
                        <div class="row">
                           <div class="col-sm-12 no-padding">
                                <?php
                                $form = $this->form;
                                $form->prepare();
                                $form->setAttribute('action', $this->url('cabfare', ['action' => 'add-fare']));
                                $form->setAttribute('method', 'post');
                                //$form->setAttribute('id', 'cab-add-fare');
                                echo $this->form()->openTag($form);

                                if(isset($VndViewFare)){
                                foreach ($form->getElements() as $element) {
                                $element->setAttribute('disabled', true);
                                $element->setAttribute('readonly',true);
                                }}
                                ?>
                                <div class="col-sm-12 no-padding padding-bottom15">
                                    <div class="col-sm-2 ">
                                        <div class="carbooking">
                                            <input type="radio" name="fare_type" id="public-fare" class="public-fare" <?php if(isset($cabfare_details['client_id']) && $cabfare_details['client_id']==0){?>checked="checked" <?php }else{?> checked="checked" <?php }?>value="1">
                                            <label for="public-fare"><span class="radio"><?php echo $this->translate('Public Fare'); ?></span></label>
                                            <?php echo $this->formElement($form->get('public_fare_selected')); ?>
                                        </div>

                                    </div>


                                    <div class="col-sm-2 ">
                                        <label class="booking-check"><strong><?php echo $this->translate($this->formLabel($form->get('market_place'))); ?></strong>
                                            <?php echo $this->FormElement($form->get('market_place')); ?>
                                            <span class="checkmark"></span>
                                        </label>


                                    </div>

                                    <div class="col-sm-2 ">
                                        <div class="carbooking">
                                            <input type="radio" name="fare_type" id="client-fare" <?php if(isset($cabfare_details['client_id']) && $cabfare_details['client_id']>0){?> checked="checked" <?php }?>  class="client-fare" value="2">
                                            <label for="client-fare"><span class="radio"><?php echo $this->translate('Client Fare'); ?></span></label>
                                            <?php echo $this->formElement($form->get('client_fare_selected')); ?>
                                        </div>
                                    </div>

                                </div>


                                <div class="form-group clearfix client_fare margintopbottom20 <?php echo $client_dropdown;?>"  id="client_fare">
                                    <label class="col-sm-2"><?php echo $this->translate($this->formLabel($form->get('client'))); ?></label>
                                    <div class="col-sm-4">
                                        <?php echo $this->FormElement($form->get('client')); ?>
                                        <?php echo $this->formElementErrors($form->get('client'), ['class' => 'error']); ?>
                                    </div>
                                    <div class="col-sm-4">
                                        <label class="col-sm-12"><a target="_blank" href="<?php echo $this->url('usermanagement', array('action' => 'add')); ?>" class="btn btn-adn" >Add Client</a></label>
                                    </div>

                                </div>

                                <!--<div class="form-group clearfix margintopbottom20">
                                    <label class="col-sm-2"><?php echo $this->translate($this->formLabel($form->get('fare_country'))); ?></label>
                                    <div class="col-sm-4">
                                        <div class="row-fluid form-group">
                                            <?php echo $this->FormElement($form->get('fare_country')->setValue(isset($cabfare_details['id'])?$cabfare_details['id']:'')); ?>
                                            <?php echo $this->formElementErrors($form->get('fare_country'), ['class' => 'error']); ?>
                                        </div>
                                    </div>

                                    <label class="col-sm-2"><?php echo $this->translate($this->formLabel($form->get('fare_state'))); ?></label>
                                    <div class="col-sm-4 form-group">
                                        <?php echo $this->FormElement($form->get('fare_state')); ?>
                                        <?php echo $this->formElementErrors($form->get('fare_state'), ['class' => 'error']); ?>
                                    </div>
                                </div>-->

                             <div class="form-group clearfix margintopbottom20">
                                    <label class="col-sm-2 "><?php echo $this->translate($this->formLabel($form->get('fare_city'))); ?></label>
                                    <div class="col-sm-4 form-group">
                                        <?php echo $this->FormElement($form->get('fare_city')); ?>
                                        <?php echo $this->FormElement($form->get('fare_country')); ?>
                                        <?php echo $this->FormElement($form->get('fare_state')); ?>
                                        <?php echo $this->FormElement($form->get('fare_city_id')); ?>
                                        <?php echo $this->formElementErrors($form->get('fare_city'), ['class' => 'error']); ?>
                                    </div>
                                    <label class="col-sm-2"><?php echo $this->translate($this->formLabel($form->get('booking_type'))); ?></label>
                                    <div class="col-sm-4">
                                        <div class="row-fluid form-group">
                                            <?php echo $this->FormElement($form->get('booking_type')->setValue(isset($cabfare_details['master_package_id'])?$cabfare_details['master_package_id']:'')); ?>
                                            <?php echo $this->formElementErrors($form->get('booking_type'), ['class' => 'error']); ?>
                                        </div>
                                    </div>
                                </div>
                                
                                <!-- Start - City Destination -->
                                <div class="from-group clearfix margintopbottom20 <?php echo $distance_city_display;?>" id="distance-city">
                                    <lable class="col-sm-2"><?php echo $this->translate($this->formLabel($form->get('destination_city'))); ?></lable>
                                    <div class="col-sm-4">
                                        <div class="row-fluid form-group">
                                            <?php echo $this->FormElement($form->get('destination_city')); ?>
                                               <?php echo $this->FormElement($form->get('destination_city_id')); ?>
                                               <?php echo $this->FormElement($form->get('city_distance_id')); ?>
                                        </div>
                                    </div>
                                    
                                    <lable class="col-sm-2"><?php echo $this->translate($this->formLabel($form->get('kilo_metor'))); ?></lable>
                                    <div class="col-sm-4">
                                        <div class="row-fluid form-group">
                                            <?php echo $this->FormElement($form->get('kilo_metor')); ?>
                                        </div>
                                    </div>  
                                </div>
                                <!-- END -->
                                
                                <div class="form-group clearfix margintopbottom20">


                                    <label class="col-sm-2"><?php echo $this->translate($this->formLabel($form->get('booking_mode_type'))); ?></label>
                                    <div class="col-sm-4">
                                        <div class="row-fluid form-group">
                                            <?php echo $this->FormElement($form->get('booking_mode_type')->setValue(isset($cabfare_details['master_package_mode_id'])?$cabfare_details['master_package_mode_id']:'')); ?>
                                            <?php echo $this->formElementErrors($form->get('booking_mode_type'), ['class' => 'error']); ?>
                                        </div>

                                    </div>
                                    
                                    <label class="col-sm-2 "><?php echo $this->translate($this->formLabel($form->get('vehicle_type'))); ?></label>
                                    <div class="col-sm-4">

                                        <div class="row-fluid form-group">
                                                <?php echo $this->FormElement($form->get('vehicle_type')->setValue(isset($cabfare_details['vehicle_type_id'])?$cabfare_details['vehicle_type_id']:'')); ?>
                                            <?php echo $this->formElementErrors($form->get('vehicle_type'), ['class' => 'error']); ?>
                                        </div>

                                    </div>
                                </div>
                                
                                
                                
                                    
<?php if(isset($usertype) && ($usertype==3 || $usertype==4 || $usertype==10)){ ?>
                                 

 <div class="form-group clearfix margintopbottom20">
                                     <label class="col-sm-2 "><?php echo $this->translate($this->formLabel($form->get('vehicle_list'))); ?></label>
                                    <div class="col-sm-10">

                                        <div class="row-fluid form-group">
                                                <?php echo $this->FormElement($form->get('vehicle_list')); ?>
                                            <?php echo $this->formElementErrors($form->get('vehicle_list'), ['class' => 'error']); ?>
                                        </div>

                                    </div>
                                     </div>
<?php } ?>

                                  
                                

                                <div class="form-group clearfix margintopbottom20">
                                    <label class="col-sm-2"><?php echo $this->translate('Type of Dispatch'); ?></label>
                                    <?php echo $this->formElement($form->get('dispatch_type_val')->setValue(isset($cabfare_details['type_of_dispatch'])?$cabfare_details['type_of_dispatch']:'')); ?>
                                    <?php echo $this->formElement($form->get('garage_type_val')->setValue(isset($cabfare_details['garage_type'])?$cabfare_details['garage_type']:'')); ?>
                                    <div class="clearfix"></div>
                                    <div class="col-sm-9 no-padding">

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

                                            <div class="carbooking">
                                                <input type="radio" name="dispatch_type" id="point-to-point-dispatch"   checked="checked" value="1">
                                                <label for="point-to-point-dispatch"><span class="radio"><?php echo $this->translate('Point to Point'); ?></span></label>
                                                <?php echo $this->formElement($form->get('point_dispatch_selected')); ?>
                                            </div>
                                        </div>

                                        <div class="col-sm-3">
                                            <div class="carbooking">
                                                <input type="radio" name="dispatch_type" id="garage-to-garage-dispatch"  checked="checked"  value="2">
                                                <label for="garage-to-garage-dispatch"><span class="radio"><?php echo $this->translate('Garage to Garage'); ?></span></label>
                                                <?php echo $this->formElement($form->get('garage_dispatch_selected')); ?>
                                            </div>


                                        </div>

                                        <div class="col-sm-6 no-padding display-none" id="garage">

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

                                                <div class="carbooking">
                                                    <input type="radio" name="dispatch_garage" id="dishpatch-garage-own" value="1">
                                                    <label for="dishpatch-garage-own"><span class="radio"><?php echo $this->translate('Own'); ?></span></label>
                                                    <?php echo $this->formElement($form->get('own_garage_selected')); ?>
                                                </div>

                                            </div>

                                            <div class="col-sm-6">
                                                <div class="carbooking">
                                                    <input type="radio" name="dispatch_garage" id="dishpatch-garage-company" value="2">
                                                    <label for="dishpatch-garage-company"><span class="radio"><?php echo $this->translate('Company Garage'); ?></span></label>
                                                    <?php echo $this->formElement($form->get('comp_garage_selected')); ?>
                                                </div>


                                            </div>

                                        </div>

                                    </div>


                                </div>

                                <div class="form-group clearfix margintopbottom20 display-none" id="garage-address-section">
                                    <div class="col-sm-4 form-group">
                                        <?php echo $this->FormElement($form->get('garage_address')->setValue(isset($cabfare_details['address'])?$cabfare_details['address']:'')); ?>
                                        <?php echo $this->formElementErrors($form->get('garage_address'), ['class' => 'error']); ?>
                                    </div>

                                    <div class="col-sm-2">
                                        <div class="row-fluid form-group">
                                        <?php echo $this->FormElement($form->get('garage_city')); ?>
                                        <?php echo $this->FormElement($form->get('garage_state')); ?>
                                        <?php echo $this->FormElement($form->get('garage_country')); ?>
                                        <?php echo $this->FormElement($form->get('garage_city_id')); ?>
                                        <?php echo $this->formElementErrors($form->get('garage_city'), ['class' => 'error']); ?>
                                     </div>
                                    </div>
                                    <div class="col-sm-2 form-group">
                                        <?php echo $this->FormElement($form->get('garage_pincode')->setValue(isset($cabfare_details['pincode'])?$cabfare_details['pincode']:'')); ?>
                                        <?php echo $this->formElementErrors($form->get('garage_pincode'), ['class' => 'error']); ?>
                                    </div>

                                    <div class="col-sm-4 pull-right" align="right" >
                                        <div>
<!--                                            <img src="<?php echo $this->basePath() ?>/images/map.jpg" width="100%">-->
                                            
                                                <div class="pac-card" id="pac-card">
                            <div style="display:none;">
                    <div id="title">Autocomplete Search</div>
                    <div id="type-selector" class="pac-controls">
             <input type="radio" name="type" id="changetype-all" checked="checked" />
                    <label for="changetype-all">All</label>

                    <input type="radio" name="type" id="changetype-establishment" />
                    <label for="changetype-establishment">establishment</label>

                    <input type="radio" name="type" id="changetype-address" />
                    <label for="changetype-address">address</label>

                    <input type="radio" name="type" id="changetype-geocode" />
                    <label for="changetype-geocode">geocode</label>

                    <input type="radio" name="type" id="changetype-cities" />
                    <label for="changetype-cities">(cities)</label>

                    <input type="radio" name="type" id="changetype-regions" />
                    <label for="changetype-regions">(regions)</label>
                    </div>
                    <br />
                    <div id="strict-bounds-selector" class="pac-controls">
                    <input type="checkbox" id="use-location-bias" value="" checked />
                    <label for="use-location-bias">Bias to map viewport</label>

                    <input type="checkbox" id="use-strict-bounds" value="" />
                    <label for="use-strict-bounds">Strict bounds</label>
                    </div>
                    </div>
                            <div id="pac-container" style="display:none">
                    <input id="pac-input" type="text" placeholder="Enter a location" />
                    </div>
                    </div>
                    <div id="map"></div>
                    <div id="infowindow-content">
                    <span id="place-name" class="title"></span><br />
                    <span id="place-address"></span>
                    </div>
                                        </div>
                                    </div>
                                    
                                     <div class="col-sm-2">
                                        <div class="row-fluid form-group">
                                        <?php echo $this->FormElement($form->get('latitude')->setValue(isset($cabfare_details['latitude'])?$cabfare_details['latitude']:'')); ?>
                                     </div>
                                    </div>
                                    
                                    <div class="col-sm-2">
                                        <div class="row-fluid form-group">
                                        <?php echo $this->FormElement($form->get('longitude')->setValue(isset($cabfare_details['longitude'])?$cabfare_details['longitude']:'')); ?>
                                     </div>
                                    </div>

                                </div>


                                <div class="col-sm-12">
                                    <div class="form-group clearfix margintop20 marginbottom20">

                                        <label class="col-sm-1 no-padding"><?php echo $this->translate($this->formLabel($form->get('fare_date_from'))); ?></label>
                                        <div class="col-sm-3 form-group">
                                            <?php echo $this->FormElement($form->get('fare_date_from')->setValue(isset($cabfare_details['date_from'])?date('d-m-Y', strtotime($cabfare_details['date_from'])):'')); ?>
                                            <?php echo $this->formElementErrors($form->get('fare_date_from'), ['class' => 'error']); ?>
                                        </div>

                                        <label class="col-sm-1 "><?php echo $this->translate($this->formLabel($form->get('fare_date_to'))); ?></label>
                                        <div class="col-sm-3 form-group">
                                            <?php echo $this->FormElement($form->get('fare_date_to')->setValue(isset($cabfare_details['date_to'])? date('d-m-Y', strtotime($cabfare_details['date_to'])):'')); ?>
                                            <?php echo $this->formElementErrors($form->get('fare_date_to'), ['class' => 'error']); ?>
                                        </div>

                                        <label class="col-sm-1 "><?php echo $this->translate($this->formLabel($form->get('currency'))); ?></label>
                                        <div class="col-sm-3 ">
                                            <div class="row-fluid form-group">
                                                <?php echo $this->FormElement($form->get('currency')->setValue(isset($cabfare_details['currency_id'])?$cabfare_details['currency_id']:'')); ?>
                                                <?php echo $this->formElementErrors($form->get('currency'), ['class' => 'error']); ?>
                                            </div>

                                        </div>

                                    </div>

                                    <div class="form-group clearfix margintop20 marginbottom20">

                                        <div class="col-sm-10 no-padding">

                                            <div class="col-sm-3 no-padding">

                                                <div class="carbooking">
                                                    <input type="radio" name="commission_type" id="net-rate" checked="checked" value="1"/>
                                                    <label for="net-rate"><span class="radio"><?php echo $this->translate('Net Rate'); ?></span></label>
                                                    <?php echo $this->FormElement($form->get('net_rate_selected')); ?>
                                                </div>

                                            </div>

                                            <div class="col-sm-3">
                                                <div class="carbooking">
                                                    <input type="radio" name="commission_type" id="commission-rate" value="2"/>
                                                    <label for="commission-rate"><span class="radio"><?php echo $this->translate('Commission Rate'); ?></span></label>
                                                    <?php echo $this->FormElement($form->get('commission_rate_selected')); ?>
                                                </div>

                                            </div>

                                            <div class="col-sm-6 no-padding display-none" id="type_of_commission">

                                                <div class="col-sm-3">
                                                    <div class="carbooking">
                                                        <input type="radio" name="comm_type" id="comm_per" checked="checked" value="%"/>
                                                        <label for="comm_per"><span class="radio">%</span></label>
                                                    </div>


                                                </div>

                                                <div class="col-sm-3">
                                                    <div class="carbooking">
                                                        <input type="radio" name="comm_type" id="comm_rs" value="RS"/>
                                                        <label for="comm_rs"><span class="radio"><i class="fa fa-inr"></i></span></label>
                                                    </div>

                                                </div>

                                                <div class="col-sm-6">
                                                    <?php echo $this->FormElement($form->get('commission_value')); ?>
                                                    <?php echo $this->formElementErrors($form->get('commission_value'), ['class' => 'error']); ?>
                                                </div>

                                            </div>

                                        </div>


                                    </div>


                                    <div class="form-group clearfix margintopbottom20">

                                        <label class="col-sm-1 no-padding"><?php echo $this->translate('Weekend'); ?></label>

                                        <?php foreach($week_days['data'] as $week){ ?>
                                                <div class="col-sm-1 radio_class">
                                                <label class="booking-check"><?php echo $week['name']; ?>
                                                    <?php
    if(count($get_weak)>0){
    if(in_array($week['id'],$get_weak))
   {
     echo $this->FormElement($form->get('weekend[]')->setCheckedValue($week['id']));
     echo $this->FormElement($form->get('weekend[]')->setAttribute('checked', true));
   }
   }
    else{
            echo $this->FormElement($form->get('weekend[]')->setCheckedValue($week['id']));

        }

   ?>

                                                    <span class="checkmark"></span>
                                                </label>
                                                </div>
                                        <?php } ?>
                                        <?php echo $this->formElementErrors($form->get('weekend[]'), ['class' => 'error']); ?>
                                    </div>

                                    <div class="row ">

                       <?php if($fareId==''){ ?>
                            <div class="col-sm-2 pull-right margin-bttom10px" id="basic_fair_manage_cab_save">
                            <?php echo $this->FormElement($form->get('add_fare')); ?>
                            </div>
                       <?php } else { ?>
                            <div class="col-sm-2 pull-right margin-bttom10px" id="">
                            <?php echo $this->FormElement($form->get('edit_fare')); ?>
                            </div>
                       <?php }?>

                    </div>


                                </div>

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


            </div>


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