<form action="/receipts/merge" method="POST">
  <div class="content2 all_opent_ticket">
    <h1>{{@page_data.title}}</h1>
    <p align="center">
      <check if="{{@GET.select_receipts}}">
      <button type="button" class="new_receipt" data-table="{{@GET.table_id}}">
        Новый чек
      </button>
      </check>
      <button type="button" class="merge_button">
        Объединить чеки
      </button>
      <button type="button" class="merge_cancel hide">
        Отмена
      </button>
      <button type="submit" class="merge_ok hide">
        Объединить
      </button>
    </p>
    <include href="pagination.htm" />

    <repeat group="{{@receipts}}" value="{{@receipt}}">
    <div class="open_ticket">
      <div class="ticket_body">
        <check if="{{@receipt.user_id==@authorization_user.id && ((@base_settings['cafe_mode']==1 && @receipt.table_id>0) || (@base_settings['cafe_mode']==0 &&  @receipt.table_id==0)) && !@receipt.ip}}">
        <input type="checkbox" name="receipt[]" id="receipt_{{@receipt.id}}" class="custom-checkbox" value="{{@receipt.id}}">
        <label for="receipt_{{@receipt.id}}" class="hide">Выбрать</label>
        </check>
        <table width="100%">
          <tr>
            <td width="68"></td>
            <td width="68"></td>
            <td width="48"></td>
            <td width="90"></td>
          </tr>
          <tr>
            <td>
              <big><b>{{@base_settings['cafe_mode']==1?@receipt.order_number:@receipt.id}}</b></big>
            </td>
            <td colspan="3">
              {{number_format(@receipt.lines_sum, 2, '.', '')}}
            </td>
          </tr>
          <check if="{{@receipt.time>0}}">
          <tr>
            <td colspan="4">
              <p class="small">Создан {{date('d.m.Y H:i:s', @receipt.time)}}</p>
            </td>
          </tr>
          </check>
          <tr>
            <td colspan="4">
              {{@receipt.short_name}}
            </td>
          </tr>
          <check if="{{@base_settings['multikassa']==1}}">
          <tr>
            <td>
              <b>Касса</b>
            </td>
            <td colspan="3">
              {{@receipt.rm_name}}
            </td>
          </tr>
          </check>
          <check if="{{@base_settings['cafe_mode']==1}}">
          <tr>
            <td>
              <b>Зал</b>
            </td>
            <td colspan="3">
              {{@receipt.room_title}}
            </td>
          </tr>
          <tr>
            <td>
              <b>Стол</b>
            </td>
            <td colspan="3">
              {{@receipt.table_title}}
            </td>
          </tr>
          </check>
          <check if="{{@receipt.partner_name}}">
          <tr>
            <td colspan="4">
              <b>Клиент</b>:
              {{@receipt.partner_name}}
            </td>
          </tr>
          </check>
          <check if="{{@receipt.description}}">
            <tr>
              <td colspan="4">
              <small>{{@receipt.description}}</small>
              </td>
            </tr>
          </check>
          <repeat group="{{@receipt.lines}}" value="{{@l}}">
          <tr>
            <td colspan="2">
              {{@l.product_title}}
            </td>
            <td align="right">
              {{numberformat(@l.count, 3, '.', '')}}X
            </td>
            <td align="right">
              {~@l.discount=@receipt.discount~}
              {~if(@l.loyalty) @l.discount=0~}
              {~@price=@l.price+(@l.price*(@l.vat/100))*max(0, @l.vat_type)~}
              {~@price=round(@price, 2)~}
              {~@d_sum=@price*(@l.discount/100)~}
              {~@price-=@d_sum~}
              {{number_format(@price, 2, '.', '')}}
              &equiv;
              {~@total=@price*@l.count~}
              {{number_format(@total, 2, '.', '')}}
            </td>
          </tr>
          </repeat>
        </table>
        <check if="{{@receipt.user_id!=@authorization_user.id || (@base_settings['cafe_mode']==1 &&  @receipt.table_id==0) || (@base_settings['cafe_mode']==0 &&  @receipt.table_id!=0) || @receipt.ip}}">
          <true>
        <input type="button" class="show_window" href="/messages/continue?uri={{urlencode("/receipts/intercept?id=".@receipt.id.(@receipt.ip?'-'.@receipt.ip:''))}}" value="Перехват">
          </true>
          <false>
        <input type="button" class="send_ajax" href="/receipts/switch?id={{@receipt.id}}" value="Выбрать">
          </false>
        </check>
      </div>
    </div>
    </repeat>
  </div>
</form>
<check if="{{@GET.select_receipts && !@receipts}}">
<script>
show_window();
$('#screen').load(location.pathname+'?not_ajax=1&table_id={{@GET.table_id}} #screen_window', function(){
  receiptlines_div_resize();
  close_all_window();
});
</script>
</check>