{~@stock_error=false~}
<div class="receiptlines {{@return?'returns':''}} {{@correct_return || @correct_sales?'correct':''}} {{@receipttype==@receipt_print?'receipt_print':''}}" href="{{@URI}}">
        <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}}">
              <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>
                  <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>
                  <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)~}
                      {~@line_discount=0~}
                      {~if(@line['loyalty']==0):~}
                      {~@receipt['discount']>@line.max_discount?@line_discount=@price/100*@line.max_discount:@line_discount=@price/100*@receipt['discount']~}
                      {~endif;~}
                      {~@price-=@line_discount~}
                      {~@count+=@line.count~}

                      {~@total=@price*@line.count~}
                      {~@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, '.', '')}}
                    </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}}" {{@s==@line.id && @line.price>=0?"checked=checked":''}}>
                  <span class="small product_title">{{@line.product_title}}</span>
                  <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']}}</small>
                  </check>
                  <check if="{{!@control_sno}}">
                    <small class="false">У товаров разные СНО. {{@sno[@line['sno']?@line['sno']:@sno_org]}}</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}}">
                    <true>
                  <span class="{{@receipt['bonus_pay']>0?'false':''}}">
                    <b>
                      Оплачено баллами: <span id="bonus_value">{{@receipt['bonus_pay']>0?number_format(@receipt['bonus_pay'], 2, '.', ''):'0.00'}}</span>
                    </b>
                  </span>
                  <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)}}">
                    </true>
                    <false>
                  <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>
                    </false>
                  </check>
                  <span class="green_bg nowrap right">
                    <b>Итого</b>: <b class="receipt_sum">{{number_format(@sum+@sum0-@receipt['bonus_pay'], 2, '.', '')}}</b>
                  </span>
                </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>
