
<?php  $_results = $this->getTrackingInfo() ?>
<?php if(sizeof($_results)>0): ?>
<?php foreach($_results as $shipid => $_result): ?>
    <?php if($shipid): ?>
    <h2><?php echo $this->__('Shipment #').$shipid; ?></h2>
    <?php endif; ?>
    <?php if(sizeof($_result)>0): ?>
        <?php $rowCount = sizeof($_result); $counter = 1; ?>
        <?php foreach($_result as $track): ?>
        <table class="tracking-table-popup">
            <tbody>
                <?php if(is_object($track)): ?>
                <tr>
                    <th><?php echo $this->__('Tracking Number:'); ?></th>
                    <td><?php echo $track->getTracking(); ?></td>
                </tr>
                <?php if ($track->getCarrierTitle()): ?>
                <tr>
                    <th><?php echo $this->__('Carrier:'); ?></th>
                    <td><?php echo $track->getCarrierTitle(); ?></td>
                </tr>
                <?php endif; ?>
                <?php if($track->getErrorMessage()): ?>
                <tr>
                    <th><?php echo $this->__('Error:'); ?></th>
                    <td class="error"><?php echo $this->__('Tracking information is currently not available. Please '); if ($this->getContactUsEnabled()) : ?><a href="<?php echo $this->getContactUs() ?>" onclick="this.target='_blank'"><?php echo $this->__('contact us') ?></a><?php echo $this->__(' for more information or '); endif; echo $this->__('email us at '); ?><a href="mailto:<?php echo $this->getStoreSupportEmail() ?>"><?php echo $this->getStoreSupportEmail() ?></a></td>
                </tr>
                <?php elseif($track->getTrackSummary()): ?>
                <tr>
                    <th><?php echo $this->__('Info:'); ?></th>
                    <td><?php echo $track->getTrackSummary(); ?></td>
                </tr>
                <?php elseif($track->getUrl()): ?>
                <tr>
                    <th><?php echo $this->__('Track:'); ?></th>
                    <td><a href="<?php echo $track->getUrl(); ?>" onclick="this.target='_blank'"><?php echo $track->getUrl(); ?></a></td>
                </tr>
                <?php else: ?>
                    <?php if ($track->getStatus()): ?>
                    <tr>
                        <th><?php echo $this->__('Status:'); ?></th>
                        <td><?php echo $track->getStatus(); ?></td>
                    </tr>
                    <?php endif; ?>

                    <?php if ($track->getDeliverydate()): ?>
                    <tr>
                        <th><?php echo $this->__('Delivered on:'); ?></th>
                        <td><?php echo $this->formatDeliveryDateTime($track->getDeliverydate(),$track->getDeliverytime()); ?></td>
                    </tr>
                    <?php endif; ?>

                    <?php if ($track->getSignedby()): ?>
                    <tr>
                        <th><?php echo $this->__('Signed by:'); ?></th>
                        <td><?php echo $track->getSignedby(); ?></td>
                    </tr>
                    <?php endif; ?>

                    <?php if ($track->getDeliveryLocation()): ?>
                    <tr>
                        <th><?php echo $this->__('Delivered to:'); ?></th>
                        <td><?php echo $track->getDeliveryLocation(); ?></td>
                    </tr>
                    <?php endif; ?>

                    <?php if ($track->getShippedDate()): ?>
                    <tr>
                        <th><?php echo $this->__('Shipped or billed on:'); ?></th>
                        <td><?php echo $track->getShippedDate(); ?></td>
                    </tr>
                    <?php endif; ?>

                    <?php if ($track->getService()): ?>
                    <tr>
                        <th><?php echo $this->__('Service Type:'); ?></th>
                        <td><?php echo $track->getService(); ?></td>
                    </tr>
                    <?php endif; ?>

                    <?php if ($track->getWeight()): ?>
                    <tr>
                        <th><?php echo $this->__('Weight:'); ?></th>
                        <td><?php echo $track->getWeight(); ?></td>
                    </tr>
                    <?php endif; ?>

                    <?php endif; ?>
                    <?php elseif(isset($track['title']) && isset($track['number']) && $track['number']): ?>
                    <!--if the tracking is custom value-->
                    <tr>
                        <th><?php echo ($track['title'] ? $this->escapeHtml($track['title']) : $this->__('N/A')); ?>:</th>
                        <td><?php echo (isset($track['number']) ? $this->escapeHtml($track['number']) : ''); ?></td>
                    </tr>
                    <?php endif; ?>
                    </tbody>
                </table>
                <div class="divider"></div>
                <?php if (is_object($track) && sizeof($track->getProgressdetail())>0): ?>
                <table class="data-table" id="track-history-table-<?php echo $track->getTracking(); ?>">
                    <col />
                    <col width="1" />
                    <col width="1" />
                    <col />
                    <thead>
                        <tr>
                            <th><?php echo $this->__('Location') ?></th>
                            <th><?php echo $this->__('Date') ?></th>
                            <th><?php echo $this->__('Local Time') ?></th>
                            <th><?php echo $this->__('Description') ?></th>
                        </tr>
                   </thead>
                   <tbody>
                   <?php foreach($track->getProgressdetail() as $_detail): ?>
                    <?php $_detailDate = (isset($_detail['deliverydate']) ? $this->formatDeliveryDate($_detail['deliverydate']) : '') ?>
                    <?php $_detailTime = (isset($_detail['deliverytime']) ? $this->formatDeliveryTime($_detail['deliverytime'], $_detailDate) : '') ?>
                        <tr>
                            <td><?php echo (isset($_detail['deliverylocation']) ? $_detail['deliverylocation'] : ''); ?></td>
                            <td><?php echo $_detailDate ?></td>
                            <td><?php echo $_detailTime ?></td>
                            <td><?php echo (isset($_detail['activity']) ? $_detail['activity'] : '') ?></td>
                        </tr>
                   <?php endforeach; ?>
                   </tbody>
                </table>
                <script type="text/javascript">decorateTable('track-history-table-<?php echo $track->getTracking(); ?>');</script>
                <?php endif; ?>
            <?php if($counter!=$rowCount): ?>
            <?php endif; ?>
            <?php $counter++; ?>
        <!--end for each tracking information-->
        <?php endforeach; ?>
    <?php else: ?>
        <p><?php echo $this->__('There is no tracking available for this shipment.'); ?></p>
    <?php endif; ?>

<?php endforeach; ?>
<?php else: ?>
    <div><?php echo $this->__('There is no tracking available.'); ?></div>
<?php endif; ?>