<?php
$data = [];
$recentItems = $this->mainMenu()->getRecentlyViewedItems($data);
?>  

<h3><i class="fa fa-inbox"></i> <?php echo $this->translate('Recent Viewed Booking');?></h3>
  <div>
<div class="nav-tabs-custom">
    <!--<ul class="nav nav-tabs pull-right">
        <li class="pull-left header"><i class="fa fa-inbox"></i> <?php echo $this->translate('Recent Booking');?></li>
    </ul>-->
    <div class="tab-content">
        <div>
            <div class="listingTableContainer">
                <div class="table-responsive">
                    <table id="myTable" class="table table-bordered with-pager table-striped" style="color:#333;">
                        <thead>
                            <tr>
                                <th>S.No</th>
                                <th>User</th>
                                <th>PickupDate</th>
                                <th>Booking Stage</th>
                                <th>City</th>
                                <th>BookingType</th>
                                <th>Partner</th>
                                <th>Departure</th>
                                <th>DropArea</th>
                                <th>Price</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                           <?php 
                            if (!empty($recentItems)) {
                            $config = new \Zend\Config\Config(include BASE_PATH . '/config/autoload/global.php');
                            $masterPackageArr = $config->masterPackageId;
                            $masterPackageArr = $masterPackageArr->toArray();
                            $moduleTypeArr = $config->moduleType;
                            $moduleTypeArr = $moduleTypeArr->toArray();
                            $i=1;
                            foreach ($recentItems as $val) {
                            $booking_data = json_decode($val['booking_data']);
                            //echo '<pre>';print_r($booking_data);
                            $masterPackageName = $masterPackageArr[$booking_data->master_package_type];
                            if(isset($booking_data->module_type) && $booking_data->module_type!=""){
                            $moduleTypeName = $moduleTypeArr[$booking_data->module_type];
                            }
                            if(isset($booking_data->city_id) && $booking_data->city_id!=""){
                            $cityName = $this->mainMenu()->getCityName($booking_data->city_id);
                            }else{
                            $cityName = $this->mainMenu()->getCityName($booking_data->pickcity_id);    
                            }
                            ?>
                            <tr>
                                <td><?php echo $i;?></td>
                                <td><?php echo $val['first_name'].''.$val['last_name'];?><br>
                                    <?php echo $val['email'];?><br>
                                    <?php echo $val['mobile'];?>
                                </td>
                                <td>
                                    <?php if(isset($booking_data->pickup_date) && $booking_data->pickup_date!=""){?>
                                    <?php echo date('d-m-Y',strtotime($booking_data->pickup_date)); ?>
                                    <?php }?>                                    
                                </td>
                                <td><?php echo $val['booking_stage'];?></td>
                                <td><?php echo $cityName['name']; ?></td>
                                <td>
                                    <?php echo $masterPackageName;?><br/>
                                     <?php if(isset($booking_data->module_type) && $booking_data->module_type!=""){?>
                                     (<?php echo $moduleTypeName;?>)
                                     <?php } ?>
                                </td>
                                <td>
                                     <strong>Nationality -</strong><?php echo $booking_data->nationality; ?></br>
                                     <strong>Adult -</strong><?php echo $booking_data->adults; ?></br>
                                     <strong>Child -</strong><?php echo $booking_data->childs; ?></br>
                                     <?php if(isset($booking_data->luggages) && $booking_data->luggages!=""){?>
                                     <strong>Luggage -</strong><?php echo $booking_data->luggages; ?></br>
                                     <?php }?> 
                                     <?php if(isset($booking_data->no_of_vehicles) && $booking_data->no_of_vehicles!=""){?>
                                     <strong>Vehicles -</strong><?php echo $booking_data->no_of_vehicles; ?></br>
                                     <?php }?> 
                                </td>
                                <td><?php echo $booking_data->pickup_address; ?></td>
                                <td>
                                    <?php if(isset($booking_data->drop_area) && $booking_data->drop_area!=""){?>
                                    <?php echo $booking_data->drop_area; ?>
                                    <?php }?>                                    
                                </td>
                                <td>
                                    <?php if(isset($booking_data->total_price) && $booking_data->total_price!=""){?>
                                    <?php echo $booking_data->total_price; ?>
                                    <?php }?>     
                                </td>
                                <td><?php if($val['status']==1){ echo "Active";}else{echo'InActive';}?></td>
                         <!--<td><a href="javascript: void(0);" onclick="claimBooking('<?php echo $val['id'];?>');">Claim</td>-->
                                <td><div class="hidden-sm hidden-xs action-buttons">
                                                <ul class="icons-list margin-left0" style="list-style:none;">
                                                    <li class="dropdown text-muted">
                                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Action <span class="caret"></span></a>
                                                        <ul class="dropdown-menu dropdown-menu-right">
                                                            <li><a href="javascript:void(0)" onclick="return deleteRecentlyViewed(<?php echo $val['id']; ?>)"><i class="ace-icon fa fa-trash bigger-130"></i> Delete</a></li>
                                                            <!--<li><a href="<?php echo '/usermanagement/personal-detail/' . $listing['user_id']; ?>"><i class="ace-icon fa fa-user bigger-130"></i> Profile</a></li>

                                                            <li class="updatestatus" user_id="<?php echo $listing['user_id']; ?>" user_status="<?php echo $listing['is_active']; ?>"><a href="#" data-toggle="modal" data-target="#statuspopup" ><i class="ace-icon fa fa-user bigger-130"></i> Status</a></li>
                                                            <li class="relationmanager" user_id="<?php echo $listing['user_id']; ?>" relation_id="<?php echo $listing['relation_manager_id']; ?>"><a href="#" data-toggle="modal" data-target="#relationpopup" ><i class="ace-icon fa fa-user bigger-130"></i> Relation Manager</a></li>
                                                            <li><a href="/credit"><i class="ace-icon fa  fa-history bigger-130"></i> Credit Limit</a></li>-->
                                                        </ul>
                                                    </li>
                                                </ul>
                                            </div></td>
                                
                                
                            </tr>
                            <?php $i++;} }else{?>
                               <tr></tr>
                        <?php }?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
  </div>
