<!-- Main content -->
<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">Allocation History</div>
                                <div class="left_panel col-sm-12 padding_margin0 pull-left bg-white" id="add_detail">
                                    <ul class="nav nav-tabs nav-tabs1 tab_ul col-sm-2 paddig-right0 margin-top15px">
                                        <?php echo $this->partial('menu.phtml'); ?>
                                    </ul>

                                    <div class="tab-content tab_editprofile col-sm-10 padding-left0 marginbott10px margintop10px">
                                        <div id="home" class="tab-pane fade in tab_editprofile tab_editprofile1 active">
                                            <div class="change_password tab_editprofile">
                                                <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">

                                                            <?php
                                                            $form = $this->form;
                                                            $form->prepare();
                                                            $form->setAttribute('action', $this->url('usermanagement', ['action' => 'allocation-history']));
                                                            echo $this->form()->openTag($form);
                                                            echo $this->formHidden($form->get('user_id'));
                                                            ?>

                                                            <div class="row">
                                                                <div class="col-sm-12">
                                                                    <div class="form-group clearfix margintopbottom20">
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new" id="Categorie Name"><?php echo $this->translate($this->formLabel($form->get('from_date'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('from_date')); ?>
                                                                        </div>
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new" id="point_airport"><?php echo $this->translate($this->formLabel($form->get('to_date'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('to_date')); ?>
                                                                        </div>
                                                                    </div>
                                                                </div>

                                                                <div class="form-group clearfix margintopbottom20">
                                                                    <label class="col-sm-3 control-label labelalign col-sm-3-new" id="">  </label>
                                                                    <div class="col-sm-4 col-sm-4-new">

                                                                    </div>

                                                                    <label class="col-sm-3 control-label labelalign col-sm-3-new" id="update_profiel"></label>
                                                                    <div class="col-sm-3 col-sm-4-new " align="right">
                                                                        <?php echo $this->FormElement($form->get('search')); ?>
                                                                    </div>
                                                                </div>
                                                            </div>

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

                                                            <div class="row">

                                                                <div class="col-sm-12">
                                                                    <div class="panel panel-default">
                                                                        <div class="panel-headingnew"> Driver Allocation Details </div>
                                                                        <div id="faq-1-3" class="panel-collapse collapse in" aria-expanded="false" >

                                                                            <div class="box">

                                                                                <!-- /.box-header -->
                                                                                <div class="box-body">
                                                                                    <table id="myTable" class="table table-bordered table-striped example3">
                                                                                        <thead>
                                                                                            <tr>
                                                                                                <th>S. No</th>
                                                                                                <th>Date</th>
                                                                                                <th>Accepted</th>
                                                                                                <th>Cancelled</th>
                                                                                                <th>Missed</th>
                                                                                                <th>Rejected</th>
                                                                                            </tr>
                                                                                        </thead>
                                                                                        <tbody>
                                                                                            <?php
                                                                                            //echo '<pre>';print_r($allocationHistory);//die();
                                                                                            if ($allocationHistory) {
                                                                                                $i = 1;
                                                                                                $totalAccepted=0;
                                                                                                $totalCancelled=0;
                                                                                                $totalMissed=0;
                                                                                                $totalRejected=0;
                                                                                                foreach ($allocationHistory as $listing) {
                                                                                                    $totalAccepted +=$listing['total_accepted'];
                                                                                                    $totalCancelled +=$listing['total_cancelled'];
                                                                                                    $totalMissed +=$listing['total_missed'];
                                                                                                    $totalRejected +=$listing['total_rejected'];
                                                                                                    $allocationDate =   date('Y-m-d', strtotime($listing['date']));
                                                                                                    ?>
                                                                                            <tr>

                                                                                            <tr>
                                                                                                <td><?php echo $i;?></td>
                                                                                                <td><?php echo $allocationDate; ?></td>
                                                                                                <td style="text-align: center;" class="show_data_<?php echo $i; ?>">
                                                                                                    <?php if($listing['total_accepted']>0){?>
                                                                                                    <a style="cursor:pointer;" onclick="showAllocationDetail('<?php echo $i;?>','<?php echo $id;?>','<?php echo $allocationDate;?>','A')"><?php echo $listing['total_accepted']; ?></a>
                                                                                                    <?php } else {?>
                                                                                                    <?php echo $listing['total_accepted']; ?>
                                                                                                    <?php }?>
                                                                                                </td>
                                                                                                <td style="text-align: center;"><?php echo $listing['total_cancelled']; ?></td>
                                                                                                <td style="text-align: center;"><?php echo $listing['total_missed']; ?></td>
                                                                                                <td style="text-align: center;"><?php echo $listing['total_rejected']; ?></td>
                                                                                            </tr>


                                                                                           <?php
                                                                                                    $i++;
                                                                                                }
                                                                                            } else {
                                                                                                ?>
                                                                                                <tr><th colspan="6" style="text-align: center;">No Record Found</th></tr>
                                                                                                    <?php } ?>

                                                                                        </tbody>
                                                                                        <tfoot>
                                                                                            <tr>

                                                                                                <th colspan="2" class="right" style="text-align:right;">Total</th>
                                                                                                <th style="text-align: center;"><?php echo isset($totalAccepted)?$totalAccepted:0;?></th>
                                                                                                <th style="text-align: center;"><?php echo isset($totalCancelled)?$totalCancelled:0;?></th>
                                                                                                <th style="text-align: center;"><?php echo isset($totalMissed)?$totalMissed:0;?></th>
                                                                                                <th style="text-align: center;"><?php echo isset($totalRejected)?$totalRejected:0;?></th>



                                                                                            </tr>
                                                                                        </tfoot>
                                                                                    </table>
                                                                                    <div class="col-sm-12 no-padding">
                                                                                        <a href="#" class="btn btn-default marginright export_status_history" style="margin-left: 10px;"><i class="fa fa-download marginright"></i>Download CSV</a>
                                                                                        <a href="#" class="btn btn-default marginright print_status_history" style="margin-left: 10px;"><i class="fa fa-download marginright"></i>Print</a>
                                                                                    </div>
                                                                                </div>
                                                                                <!-- /.box-body -->

                                                                            </div>

                                                                        </div>
                                                                    </div>


                                                                </div>


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