<table id="myTable" class="table table-bordered table-striped">
    <thead>
        <tr>
            <th><input type="checkbox" class="selectall">All</th>
            <th>S.No</th>
            <th>City</th>
            <th>Fare type</th>
            <th>Package</th>
            <th>Vehicle</th>
            <th>Price/KM</th>
            <th>Beyond/KM</th>
            <th>Charges/Min</th>
            <th>Dispatch</th>
            <th>Valid Date</th>
             <th>Created By</th>
            <th>Market</th>
            <th>Status</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>

        <?php
       //echo'<pre>';print_r($cabfareListing);die();
        if (count($cabfareListing) > 0) {
            $i = 1;
            foreach ($cabfareListing as $listing) {
                    $base_combination_id = $listing['base_combination_id'];
                    $fareData = $listing['fare_data'];
                    
                    $minimum_charge=0;
                    $minimum_distance=0;
                    $per_km_charge=0;
                    $minimum_hrs=0;
                    if(!empty($fareData)){
                        $minimum_charge   = (isset($fareData['minimum_charge']))?$fareData['minimum_charge']:'0';
                        $minimum_distance = (isset($fareData['minimum_distance']))?$fareData['minimum_distance']:'0';
                        $per_km_charge    = (isset($fareData['per_km_charge']))?$fareData['per_km_charge']:'0'; 
                        $minimum_hrs      = (isset($fareData['minimum_hrs']))?$fareData['minimum_hrs']:'0'; 
                        if($listing['master_package_mode_id']==2){
                         $per_km_charge     = (isset($fareData['per_hr_charge']))?$fareData['per_hr_charge']:'0'; 
                        }
                    }
                if($listing['garage_type']==1){
                    $garage_type="Own";
                }elseif($listing['garage_type']==2){
                    $garage_type="Company";
                }else{
                    $garage_type="NA";
                }

                ?>

                <tr class="odd">
                    <td class="sorting_1"><input type="checkbox" class="check" rel="<?php echo $listing['base_combination_id']; ?>"></td>
                    <td class="sorting_1"><?php echo $i; ?></td>
                    <td><?php echo $listing['city_name'].'<br> ('.$listing['county_name'].', '.$listing['state_name'].')';?>
                        <?php if(isset($listing['master_package_id']) && $listing['master_package_id']==5) { ?>
                        <br/>
                        <strong>To City-&nbsp;&nbsp;&nbsp;</strong><?php echo $listing['destination_city_name'].'<br> ('.$listing['destination_state_name'].', '.$listing['destination_country_name'].')';?>
                        <?php }?>
                    </td>
                    <td><?php if($listing['client_name']!=""){ echo $listing['client_name'];}else{ echo "Public";}?></td>
                    <td><?php echo $listing['package_name'];?></td>
                    <td><?php echo $listing['vehicle_type'].'<br> ('.$listing['package_mode'].')';?></td>
                    <?php if(isset($listing['master_package_id']) && $listing['master_package_id']==1) { ?>
                    <td>
                        <table style="border:0px;">
                <?php if(!empty($listing['fare_package_data'])){
                    foreach($listing['fare_package_data'] as $val){
                    $localId = $val['id'];   
                    $fare_value =  isset($listing['local_package_fare'][$localId])?$listing['local_package_fare'][$localId]:0;
                 ?>
                            <tr>
                                <td style="padding:2px;"><?php echo $val['name']; ?></td>
                                <td style="padding:2px;"><?php echo $fare_value;?></td>
                            </tr>
                           <?php } }?>
                        
                        
                </table></td>
                    <?php } else { ?>
                    <td><?php echo $minimum_charge;?>/<?php echo $per_km_charge; ?>KM</td>
                    <?php }?>
                    <td><?php echo $minimum_distance; ?>/KM</td>
                    <td><?php echo $minimum_hrs; ?>/Hours</td>
                    <td><?php echo ($listing['type_of_dispatch'] == '1' ? 'Point To Point' : 'Garage To Garage'); ?></td>
                    <td>
                        Start - <?php echo date('d-m-Y',strtotime($listing['date_from'])); ?><br/>
                        End - <?php echo date('d-m-Y',strtotime($listing['date_to'])); ?></td>
                    <td><?php echo $listing['vendor_name'];?></td>
                    <td><div id="changestatus1" class="<?php if($listing['market_place']==1) echo "aprovestatus";else{ echo "unapproved";}?> iconsize" name="ChangeStatus"></div></td>
                    
                    <td><div id="changestatus1" class="<?php echo ($listing['bs_status'] == '1' ? 'aprovestatus' : 'unaprovestatus'); ?> iconsize" name="ChangeStatus" onclick="changeRecordStatus('<?php echo $base_combination_id; ?>','cabfare','change-record-status','<?php echo $listing['bs_status'];?>')"></div></td>
                    <td>
                        <a href="<?php echo $this->url().'/add-fare/'.$base_combination_id; ?>" style="color:#333; font-size:18px;" title='Edit Fare'>
                            <i class="fa fa-edit" style="height:20px;"></i>
                        </a>
                        <a target="_blank" href="<?php echo $this->url().'/view-vendor-fare/'.$base_combination_id; ?>" style="color:#333; font-size:18px;" title='View Fare'>
                            <i class="fa fa-eye"></i>
                        </a>

                    </td>
                </tr>

                <?php
                $i++;
            }
        } else {
            ?>
            <tr>
                <td colspan="10" style="text-align: center;">No Records Found</td>
            </tr>
        <?php } ?>
    </tbody>
</table>