<div class="container">
    <div class="row">
        <div class="col-md-2">
            <div class="panel panel-default">

                <!--Left panel heading-->
                <div class="panel-heading">
                    <h3 class="panel-title">My Listings</h3>
                </div>

                <!--Left panel body-->
                <div class="panel-body">
                    <ul class="nav nav-pills nav-stacked">
                        <li><a href="<?php echo base_url(); ?>epc_listings/listings/my_engines_list">
                                <span class="badge pull-right"><?php echo $total; ?></span>
                                Total Engines</a></li>
                        <li class="active"><a href="<?php echo base_url(); ?>epc_listings/listings/my_engine_parts_list">
                                <span class="badge pull-right"><?php echo $ptotal; ?></span>
                                Total Parts</a></li>
                    </ul>  
                </div>
            </div>
        </div>


        <!--Mid panel heading-->

        <div class="col-md-10">
            <div class="panel panel-default">
                <div class="panel-heading">Parts

                    <div class="pull-right">
                        <a href="<?php echo base_url(); ?>epc_listings/listings/add_plisting"><button type="button" class="btn btn-primary btn-xs">Add New Part 
                                <i class="glyphicon glyphicon-log-in"></i></button></a>
                    </div>
                </div>

                <!--Mid panel body-->        
                <div class="panel-body">
                    
                    <?php if ($this->session->flashdata('engine_part_added')) : ?>
                    <p class="alert alert-dismissable alert-success"><?php echo $this->session->flashdata('engine_part_added'); ?></p>
                    <?php endif; ?>
                    
                    <?php if ($this->session->flashdata('engine_part_updated')) : ?>
                        <p class="alert alert-dismissable alert-success"><?php echo $this->session->flashdata('engine_part_updated'); ?></p>
                    <?php endif; ?>

                    <?php if ($this->session->flashdata('engine_part_deleted')) : ?>
                        <p class="alert alert-dismissable alert-success"><?php echo $this->session->flashdata('engine_part_deleted'); ?></p>
                    <?php endif; ?>

                    <table style="font-size: 13px;" class="table table-bordered table-hover table-condensed">
                        <thead>
                            <tr>
                                <th <?php if ($sort_by == 'part_number') echo "id=\"sort_$sort_order\"" ?>><?php
                                    echo anchor("epc_listings/listings/my_engine_parts_list/part_number/" .
                                            (($sort_order == 'asc' && $sort_by == 'part_number') ? 'desc' : 'asc'), 'Part Number: ');
                                    ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'part_description') echo "id=\"sort_$sort_order\"" ?>><?php
                                    echo anchor("epc_listings/listings/my_engine_parts_list/part_description/" .
                                            (($sort_order == 'asc' && $sort_by == 'part_description') ? 'desc' : 'asc'), 'Part Description: ');
                                    ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'part_condition') echo "id=\"sort_$sort_order\"" ?>><?php
                                echo anchor("epc_listings/listings/my_engine_parts_list/part_condition/" .
                                        (($sort_order == 'asc' && $sort_by == 'part_condition') ? 'desc' : 'asc'), 'Part Condition: ');
                                    ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'enginep_model') echo "id=\"sort_$sort_order\"" ?>><?php
                                    echo anchor("epc_listings/listings/my_engine_parts_list/enginep_model/" .
                                            (($sort_order == 'asc' && $sort_by == 'enginep_model') ? 'desc' : 'asc'), 'Engine Model: ');
                                    ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'tag') echo "id=\"sort_$sort_order\"" ?>><?php
                                    echo anchor("epc_listings/listings/my_engine_parts_list/tag/" .
                                            (($sort_order == 'asc' && $sort_by == 'tag') ? 'desc' : 'asc'), 'Tag: ');
                                    ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'quantity') echo "id=\"sort_$sort_order\"" ?>><?php
                                echo anchor("epc_listings/listings/my_engine_parts_list/quantity/" .
                                        (($sort_order == 'asc' && $sort_by == 'quantity') ? 'desc' : 'asc'), 'Quantity: ');
                                    ?></th>
                                <th class="col-md-1" <?php if ($sort_by == 'lister') echo "id=\"sort_$sort_order\"" ?>><?php
                                    echo anchor("epc_listings/listings/my_engine_parts_list/lister/" .
                                            (($sort_order == 'asc' && $sort_by == 'lister') ? 'desc' : 'asc'), 'Lister: ');
                                    ?></th>
                                <th class="hidden-xs col-md-1" <?php if ($sort_by == 'transaction') echo "id=\"sort_$sort_order\"" ?>><?php
                                    echo anchor("epc_listings/listings/my_engine_parts_list/transaction/" .
                                            (($sort_order == 'asc' && $sort_by == 'transaction') ? 'desc' : 'asc'), 'Transaction: ');
                                    ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'asking_price') echo "id=\"sort_$sort_order\"" ?>><?php
                                echo anchor("epc_listings/listings/my_engine_parts_list/asking_price/" .
                                        (($sort_order == 'asc' && $sort_by == 'asking_price') ? 'desc' : 'asc'), 'Asking Price: ');
                                    ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'monthly_rent') echo "id=\"sort_$sort_order\"" ?>><?php
                            echo anchor("epc_listings/listings/my_engine_parts_list/monthly_rent/" .
                                    (($sort_order == 'asc' && $sort_by == 'monthly_rent') ? 'desc' : 'asc'), 'Monthly Rent: ');
                            ?></th>
                                <th class="hidden-xs" <?php if ($sort_by == 'available_date') echo "id=\"sort_$sort_order\"" ?>><?php
                            echo anchor("epc_listings/listings/my_engine_parts_list/available_date/" .
                                    (($sort_order == 'asc' && $sort_by == 'available_date') ? 'desc' : 'asc'), 'Available Date: ');
                            ?></th>
                                <th colspan="2"></th>
                            </tr>
                        </thead>
                        <tbody>
<?php if (!empty($plistings)) { ?> 
    <?php foreach ($plistings as $plist) : ?>
                                    <tr>
                                        <td><a href="<?php echo base_url(); ?>epc_listings/listings/display_plisting/<?php echo $plist->list_id; ?>"><?php echo $plist->part_number; ?></a></td>
                                        <td class="hidden-xs"><?php echo substr($plist->part_description, 0, 25); ?></td>
                                        <td class="hidden-xs"><?php echo $plist->part_condition; ?></td>
                                        <td class="hidden-xs"><?php echo $plist->enginep_model; ?></td>
                                        <td class="hidden-xs"><?php echo $plist->tag; ?></td>
                                        <td class="hidden-xs"><?php echo $plist->quantity; ?></td>
                                        <td><?php echo $plist->lister; ?></td>
                                        <td class="hidden-xs"><?php echo $plist->transaction; ?></td>
                                        <td class="hidden-xs"><?php echo $plist->asking_price; ?></td>
                                        <td class="hidden-xs"><?php echo $plist->monthly_rent; ?></td>
                                        <td class="hidden-xs"><?php echo $plist->available_date; ?></td>
                                        <td>
                                            <a href="<?php echo base_url(); ?>epc_listings/listings/edit_plisting/<?php echo $plist->list_id; ?>"><i class="glyphicon glyphicon-edit"></i></a>             
                                        </td>
                                        <td>
                                            <a data-confirm="Are you sure you want to delete?" href="<?php echo base_url(); ?>epc_listings/listings/delete_plisting/<?php echo $plist->list_id; ?>"><i style="left: 0px" class="glyphicon glyphicon-trash"></i></a>
                                        </td>

                                    </tr>
    <?php endforeach; ?>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-md-4">

<?php if (!empty($pstart) && !empty($pend)) { ?>

                                Showing: <span id="label" class="label"><?php echo $pstart; ?> - <?php echo $pend; ?> of <?php echo $ptotal; ?> entries</span>

<?php } ?>
                        </div> 
                        <div class="col-md-7 pull-right">
                            <div id ="pgcol" class="pgPaginate" id="paginateInfo"> 
<?php echo $plinks; ?>
                            </div>
                        </div>
                    </div>  
                </div>

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