<?php

defined('ABSPATH') || die('Access Denied');

$order_product_rows = $row->order_product_rows;
$products = $order_product_rows['products'];
$totals = $order_product_rows['totals'];
if (!$products) {
  return;
}

wp_enqueue_style('wde_orderproducts');
?>
<fieldset>
  <legend><?php _e('Order products', 'wde'); ?></legend>
  <table class="adminlist table table-striped widefat fixed pages">
    <thead>
      <tr>
        <th class="col_num">#</th>
        <th class="col_product_image"><?php _e('Image', 'wde'); ?></th>
        <th class="col_product_name"><?php _e('Name', 'wde'); ?></th>
        <th class="col_price"><?php _e('Price', 'wde'); ?></th>
        <th class="col_count"><?php _e('Quantity', 'wde'); ?></th>
        <th class="col_subtotal"><?php _e('Total', 'wde'); ?></th>
      </tr>
    </thead>
    <tbody>
      <?php
      foreach ($products as $i => $product) {
        $alternate = (!isset($alternate) || $alternate == 'alternate') ? '' : 'alternate';
        ?>
      <tr class="<?php echo $alternate; ?>">
        <td class="col_num"><?php echo $i + 1; ?></td>
        <td class="col_product_image">
          <?php
          if ($product->product_image != '') {
            ?>
          <img class="order_product_image" src="<?php echo $product->product_image; ?>" alt="<?php echo $product->product_name; ?>" title="<?php echo $product->product_name; ?>" />
            <?php
          }
          else {
            ?>&nbsp;<?php
          }
          ?>
        </td>
        <td class="col_product_name">
          <a href="<?php echo $product->product_edit_link; ?>" target="_blank"><?php echo $product->product_name; ?></a>
          <br/><?php echo $product->product_parameters; ?>
        </td>
        <td class="col_price"><?php echo $product->product_price_text; ?></td>
        <td class="col_count"><?php echo $product->product_count; ?></td>
        <td class="col_subtotal"><?php echo $product->subtotal_text; ?></td>
      </tr>
        <?php
      }
      ?>
    </tbody>
    <tfoot>
      <tr>
        <td colspan="4" class="col_total">
          <?php if ($totals->total_tax_text) { ?>
          <div><?php _e('Total tax', 'wde'); ?>:</div>
          <?php } if ($totals->total_shipping_method_text) { ?>
          <div><?php _e('Total shipping', 'wde'); ?>:</div>
          <?php } ?>
          <div><?php _e('Order total', 'wde'); ?>:</div>
        </td>
        <td colspan="2" class="col_total">
          <?php if ($totals->total_tax_text) { ?>
          <div><?php echo $totals->total_tax_text; ?></div>
          <?php } if ($totals->total_shipping_method_text) { ?>
          <div><?php echo $totals->total_shipping_method_text; ?></div>
          <?php } ?>
          <div><?php echo $totals->total_text; ?></div>
        </td>
      </tr>
    </tfoot>
  </table>
</fieldset>