<?php
if ($tray_items)
    foreach ($tray_items as $tray_item) {
        $tray_matrix = $tray_item['tray_matrix'];
                        $tray_matrix = array_reverse(explode(',', $tray_matrix));
                        $tray_prices = $tray_item['tray_prices'];
                        $tray_prices = array_reverse(explode(',', $tray_prices));
        ?>
        <li class="media">
            <form method="post" name="item_form<?= $tray_item['tray_item_id'] ?>" action="<?= SITE_URL('add_to_cart') ?>">
                <div class="media-left">
                    <img alt="<?= $tray_item['item_name'] ?>" src="<?= $this->config->item('uploads') ?>tray_item_images/<?= $tray_item['item_image'] ?>" class="media-object">
                </div>
                <div class="media-body">
                    <h4 class="media-heading"><?= $tray_item['item_name'] ?></h4>
                    <h6>Product Code: <?= $tray_item['item_code'] ?></h6>
                    <p><?= $tray_item['item_description'] ?></p>
                    <div class="clearfix"></div>
                    <table class="table"><tbody>
                            <tr>                                      
                                <td width="120">
                                    <div class="input-group">
                                        <span class="input-group-btn">
                                            <button class="btn btn-default amount_decrease" type="button">-</button>
                                        </span>
                                        <?php $default_value = $this->common_model->getSingleFieldFromAnyTable('default_value', 'matrix_id', $tray_matrix[0], 'tbl_matrix'); ?>
                                        <input type="text" class="form-control quantity" name="quantity" value="<?php echo $default_value ?>">
                                        <span class="input-group-btn">
                                            <button class="btn btn-default amount_increase" type="button">+</button>
                                        </span>
                                    </div>
                                </td>
                                <td width="100">                                        
                                    <select class="form-control matrix_selector" name="matrix_id" >  
                                        <?php
                                        foreach ($tray_matrix as $key => $value) {
                                            $matrix_data = $this->common_model->getSingleRowFromAnyTable('matrix_id', $value, 'tbl_matrix');
                                            ?>
                                            <option value="<?= $value ?>" data-default-price="<?= $tray_prices[$key] ?>" data-default-value="<?= $matrix_data->default_value ?>" data-breakdown="<?= $matrix_data->breakdown_value ?>"><?= $matrix_data->unit_name ?></option>   
                                        <?php } ?>
                                    </select>
                                </td>
                                <td align="right"><strong class="total_item_price">$<?php echo number_format($tray_prices[0], 2, '.', '') ?></strong></td>
                            </tr>
                        </tbody>
                    </table>
                    <?php if($tray_item['show_note']=='yes') { ?>
                    <div class="row">
                        <div class="col-md-3">
                            <label>Product Note:</label>
                        </div>
                        <div class="col-md-6">
                            <textarea name="item_note" class="form-control" style="resize: none;"></textarea>
                        </div>
                    </div>
                    <?php } ?>
                    <input type="hidden" name="item_id" value="<?= $tray_item['tray_item_id'] ?>">
                    <input type="hidden" name="item_code" value="<?= $tray_item['item_code'] ?>">
                    <input class="btn btn-primary" type="submit" name="submit" value="Add to Cart">
                </div>
            </form>
        </li>
    <?php } ?>
<script>
    $(document).ready(function() {
        $('#paging').html('<?= $paging ?>');
    });
</script>