<div class="order-summary-content">
  <div class="top">
    <div class="basket-summary left">
      Data zamówienia: <span><?= \Shared\Helpers\Helpers::pretty_date( 'j f Y', strtotime( $this -> order['date_order'] ) );?></span>
    </div>
    <div class="basket-summary left">
      Status zamówienia: <span><?= $this -> statuses[ $this -> order['status'] ];?></span>
    </div>
  </div>
  <div class="top-second">
    <div class="column">
      <h5><?= ucfirst( \Shared\Helpers\Helpers::lang( 'dane-do-dostawy' ) );?></h5>
      <p>
        <?= $this -> order['client_surname'];?> <?= $this -> order['client_name'];?><br />
        <?= $this -> order['client_street'];?><br />
        <?= $this -> order['client_postal_code'];?> <?= $this -> order['client_city'];?><br />
        <?= $this -> order['client_email'];?><br />
        <?= $this -> order['client_phone'];?>
        <? if ( $this -> order['inpost_paczkomat'] ):?>
          <br /><br />Paczkomat: <b><?= $this -> order['inpost_paczkomat'];?>
        <? endif;?>
        <? if ( $this -> order['orlen_point'] ):?>
          <br /><br />Punkt Orlen: <b><?= $this -> order['orlen_point'];?>
        <? endif;?>
      </p>
    </div>
    <div class="column">
      <? if ( $this -> order['firm_name'] ):?>
        <h5><?= \Shared\Helpers\Helpers::lang( 'dane-do-faktury' );?>:</h5>
        <p>
          <?= $this -> order['firm_name'];?><br />
          <?= $this -> order['firm_street'];?><br />
          <?= $this -> order['firm_postal_code'];?> <?= $this -> order['firm_city'];?><br />
          NIP: <?= $this -> order['firm_nip'];?>
        </p>
      <? endif;?>
    </div>
  </div>
  <div class="products">
    <? if ( is_array( $this -> order['products'] ) and count( $this -> order['products'] ) ):?>
      <? foreach ( $this -> order['products'] as $product ):?>
        <? $product_tmp = (new \Domain\Product\ProductRepository($GLOBALS['mdb']))->findCached( $product['product_id'], $lang['id'] );?>
        <div class="basket-product">
          <div class="image">
            <? if ( file_exists( substr( $product_tmp['images'][0]['src'], 1 ) ) ):?>
              <img class="main-img" src="<?= $product_tmp['images'][0]['src'];?>" alt="">
            <? else:?>

            <? endif;?>
          </div>
          <div class="details">
              <div class="name">
              <?= $product['name'];?>
              <div class="attributes">
                <?= $product['attributes'];?>
              </div>
              <div class="custom-fields">
                <?= $product['custom_fields'];?>
              </div>
              <div class="product-message">
                <?= $product['message'] != '' ? '<strong>Wiadomość:</strong> ' . $product['message'] : '';?>
              </div>
            </div>
          </div>
          <div class="prices">
            <div class="price">
              <?
                $_promo = round( (float)$product['price_brutto_promo'], 2 );
                $_base  = round( (float)$product['price_brutto'], 2 );
                if ( $_promo > 0 and $_promo < $_base ) {
                  echo \Shared\Helpers\Helpers::decimal( $_promo ) . ' zł';
                  echo '<u>' . \Shared\Helpers\Helpers::decimal( $_base ) . ' zł</u>';
                  $discount += \Shared\Helpers\Helpers::normalize_decimal( ( $_base - $_promo ) * $product['quantity'] );
                } else {
                  echo \Shared\Helpers\Helpers::decimal( $_base ) . ' zł';
                }
                $effective_price = ( $_promo > 0 and $_promo < $_base ) ? $_promo : $_base;
              ?>
              <span>x <?= $product['quantity'];?></span>
              <?= \Shared\Helpers\Helpers::decimal( \Shared\Helpers\Helpers::normalize_decimal( $effective_price * $product['quantity'] ) );?> zł
            </div>
          </div>
        </div>
        <? $summary += \Shared\Helpers\Helpers::normalize_decimal( $_base * $product['quantity'] );?>
      <? endforeach;?>
      <div class="basket-summary">
        Wartość koszyka <span><?= \Shared\Helpers\Helpers::decimal( $summary );?> zł</span>
      </div>
      <? if ( $discount ):?>
        <div class="basket-summary">
          Rabat <span class="text-danger"><?= \Shared\Helpers\Helpers::decimal( $discount );?> zł</span>
        </div>
      <? endif;?>
      <? if ( $this -> coupon ):?>
        <div class="basket-summary">
          Kod rabatowy: <span style="color: #cc0000;"><?= $this -> coupon['name'];?> - <?= $this -> coupon['amount'];?> <?= $this -> coupon['type'] == 1 ? '%' : 'zł';?></span>
        </div>
      <? endif;?>
      <div class="basket-summary">
        <?= $this -> order['transport'];?> <span><?= \Shared\Helpers\Helpers::decimal( $this -> order['transport_cost'] );?> zł</span>
      </div>
      <div class="basket-summary big">
        <?= ucfirst( \Shared\Helpers\Helpers::lang( 'razem-z-dostawa' ) );?>: <span><?= \Shared\Helpers\Helpers::decimal( $summary - $discount + $this -> order['transport_cost'] );?> zł</span>
      </div>
    <? endif;?>
    <? if ( $this -> order['message'] ):?>
      <div class="basket-summary">
        Wiadomość:
        <span class="comment"><?= $this -> order['message'];?></span>
      </div>
    <? endif;?>
  </div>
</div>