{~@stock_error=false~}
<div class="receiptlines {{@return?'returns':''}} {{@correct_return || @correct_sales?'correct':''}} {{@receipttype==@receipt_print?'receipt_print':''}} {{@receipttype==@receipt_writeoff?'receipt_writeoff':''}}" href="{{@PATH}}">
        <div class="reload">
          <button type="button" class="scroll_button" id="scroll_button_up">
            <i class="fas fa-chevron-up"></i>
            вверх
          </button>
          <div class="receiptlines_div {{@base_settings['product_menu']=='1'?'receiptlines_div_cafe':''}} {{@base_settings['balance']<=0?'limited_version':''}} {{!@api_data['domen']?'autonomous':''}} {{@base_settings['license_end']>0 && @base_settings['license_end']<time()+5*24*3600 && @base_settings['autonomous']>0?'license_alarm':''}}">
            <table class="work_table big_table">
              <check if="{{@base_settings['ticket_description'] || @receipt['type']==@receipt_print || @receipt['type']==@receipt_writeoff}}">
              <tr>
                <td>
                  <textarea placeholder="{{@receipt['type']==@receipt_print?'Название набора':'Комментарий к чеку'}}" name="ticket_description" class="ticket_description" id="ticket_description" data-id="{{@receipt['id']}}">{{@receipt['description']}}</textarea>
                  <div id="ticket_description_reset"><i class="fa fa-times"></i></div>
                </td>
              </tr>
              </check>
              {~@turn=0~}
            <repeat group="{{@receiptlines}}" key="{{@n}}" value="{{@line}}">
              <check if="{{@turn!=@line.turn && count(@turns)>1}}">
              <tr class="turn_tr">
                <td align="center">
                  <small>Очередь {{@line.turn}}</small>
                  {~@turn=@line.turn~}
                </td>
              </tr>
              </check>
              <tr class="line {{@s==@line.id && @line.price>=0?'select_line':''}} {{@line.parent_id>0?'tree':''}} {{@line.last>0?'last_tree':''}}" id="line_{{@line.id}}">
                <td style="position: relative;">
                  <check if="{{@line.print_group=='kitchen'}}">
                  <i class="kitchen_print_ok_{{@line.turn}} kitchen_print_ok_all fas fa-utensils right {{@line.complite_order>0?'complite_order_line':''}}" {{@line.kitchen!=1?'style="display:none;"':''}}></i>
                  </check>
                  <check if="{{@line.print_group=='bar'}}">
                  <i class="bar_print_ok_{{@line.turn}} bar_print_ok_all fas fa-glass-martini-alt right {{@line.complite_order>0?'complite_order_line':''}}" {{@line.bar!=1?'style="display:none;"':''}}></i>
                  </check>
                  <check if="{{@line.create_order>0 && @line.kitchen!=1 && @line.bar!=1}}">
                  <i class="bar_print_ok_{{@line.turn}} bar_print_ok_all fas fa-cookie-bite right {{@line.complite_order>0?'complite_order_line':''}}"></i>
                  </check>
                  <p align="right" class="right">
                    <span class="small">
                      {~if(@receipt['partner']['ignore_max_discount'])@line.max_discount=100;~}
                      {~@price=@line.price+(@line.price*(@line.vat/100))*max(0, @line.vat_type)~}
                      {~@price=round(@price, 2)~}
                      {~@price0=round(@price, 2)~}
                      {~@line_discount=0~}
                      {~if(@line['loyalty']==0):~}
                      {~@receipt['discount']>@line.max_discount?@line_discount=round(@price/100*@line.max_discount, 2):@line_discount=round(@price/100*@receipt['discount'], 2)~}
                      {~endif;~}
                      {~@price-=@line_discount~}
                      {~if(@line.mrp>0 && @price>@line.mrp/100 && @line.marking_group!=30) {@price=@line.mrp/100; @line_discount=@price0-@price;}~}
                      {~if(@line.smp>0 && @price<@line.smp/100) {@price=@line.smp/100; @line_discount=@price0-@price;}~}

                      {~@count+=@line.count~}

                      {~@total=round(@price*@line.count, 2)~}
                      {~@sum_discount+=@line_discount*@line.count~}
                      {~@sum_discount_line+=(@line.price0-@line.price)*@line.count~}
                      {~@line.loyalty>0?@sum0+=@total:@sum+=@total~}

                      {{number_format(@price, 2, '.', '').' x '.numberformat(@line.count, 3, '.', '').@line.unit_short_title}}
                    </span>
                    <br>
                    <b class="small">
                      &equiv;
                      <span class="line_sum {{@line.loyalty>0?'line_loyalty':''}} {{@line.loyalty==3?'round_kop':''}}">{{number_format(@total, 2, '.', '')}}</span>
                    </b>
                  </p>
                  <input tabindex="3" type="radio" name="line" value="{{@line.id}}" count="{{@line.count}}" quantity="{{@line.quantity}}" discount="{{@line.line_discount}}" max-discount="{{@line.max_discount}}" product_id="{{@line.product_id}}" parent_id="{{@line.parent_id}}" data-addtime="{{@line.add_time>0?date('d.m.Y H:i:s', @line.add_time):0}}" {{@s==@line.id && @line.price>=0?"checked=checked":''}}>
                  <span class="small product_title">{{@line.marking==1 && @line.mark!=''?'[M] ':''}}{{@line.product_title}}</span>
                  <check if="{{isset(@line['mark_code'])}}">
                  <small>
                    <i class="fas fa-qrcode"></i> {{@line['mark_code']['serial']}} {{@line['mark_code']['number']}}
                  </small>
                  <br>
                  </check>
                  <check if="{{@line.certificate!=''}}">
                  <small class="false">Номер сертификата: {{@line.certificate}}</small>
                  </check>
                  <check if="{{@line.description!=''}}">
                    <true>
                  <small class="false">{{@line.description}} {{@line.loyalty==1 && @line.bonus_pay>0?number_format(@line.bonus_pay, 2, '.', ''):''}}</small>
                    </true>
                    <false>
                      <check if="{{@line_discount!=0}}">
                  <small class="false">Цена указана с учётом {{@line_discount<0?'наценки':'скидки'}}</small>
                      </check>
                    </false>
                  </check>
                  <check if="{{@base_settings.control_stock>0 && @line.count>@line['stock'] && @line['product_id']>0}}">
                    {~@stock_error=true~}
                    <small class="false">Недостаточное кол-во для продажи. Осталось {{@line['stock']??0}}</small>
                  </check>
                  <check if="{{!@control_sno}}">
                    <small class="false">У товаров разные СНО. {{@sno[@line['sno']?@line['sno']:@sno_org]}}</small>
                  </check>
                  <check if="{{!@control_sno_status}}">
                    <small class="false">У товара недопустимая СНО. {{@sno[@line['sno']?@line['sno']:@sno_org]}}</small>
                  </check>
                  <check if="{{(int)@base_settings.show_product_code==1}}">
                    <small class="small products_code">Арт.: {{@line.code}}</small>
                  </check>
                </td>
              </tr>
            </repeat>
            </table>
          </div>
          <button type="button" class="scroll_button" id="scroll_button_down">
            <i class="fas fa-chevron-down"></i>
            вниз&nbsp;
          </button>

          <table class="work_table total_table">
            <tr>
              <td align="left">
                <p>
                  {~@discount=(@sum*(@receipt['discount']/100))~}
                  Строк: {{is_array(@receiptlines)?count(@receiptlines):0}}
                  <check if="{{@receipt['partner']['loyalty_type']!=2}}">
                  <span class="discount_span {{@sum_discount+@sum_discount_line!=0?'false':''}} {{@sum_discount+@sum_discount_line<0?'discount_span_hide':''}}">
                    <b>
                      {{@sum_discount+@sum_discount_line>=0?'Скидка':'Наценка'}}: <span id="discount_value">{{@sum_discount+@sum_discount_line!=0?number_format(abs(@sum_discount+@sum_discount_line), 2, '.', ''):'0.00'}}</span>
                    </b>
                  </span>
                  </check>
                  <span class="green_bg nowrap right">
                    <b>Итого</b>: <b class="receipt_sum">{{number_format(@sum+@sum0-@receipt['bonus_pay'], 2, '.', '')}}</b>
                  </span>
                  <check if="{{@receipt['partner']['loyalty_type']==2}}">
                    <table width="100%"></table>
                  <div align="center">
                    <small class="nowrap">Всего баллов: {{number_format(@receipt['partner']['bonus'], 0)}} |</small>
                    <check if="{{@partner_bonus!=0}}">
                    <small class="nowrap">К {{@receipttype==1 || @receipttype==128?'начислению':'возврату'}}: {{@partner_bonus}} |</small>
                    </check>
                    <small class="nowrap {{@receipt['bonus_pay']>0?'false':''}}">
                      Оплачено: <span id="bonus_value">{{@receipt['bonus_pay']>0?number_format(@receipt['bonus_pay'], 2, '.', ''):'0.00'}}</span>
                    </small>
                    <input type="hidden" id="max_bonus_pay" value="{{@receipt['max_bonus_pay']}}">
                    <input type="hidden" id="partner_all_bonus" value="{{number_format(@receipt['partner']['bonus'], 0)}}">
                  </div>
                  </check>
                </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
<check if="{{@base_settings['license_end']>0 && @base_settings['license_end']<time()+5*24*3600 && @base_settings['autonomous']>0}}">
<style>
.license_alarm:after {
  content: 'Через {{round((@base_settings['license_end']-time())/(24*3600))}} дн. срок действия лицензии закончится. Продлите лицензию.';
}
</style>
</check>
<script type="text/javascript">
stock_error={{@stock_error?'true':'false'}};
</script>
