<!-- BEGIN: MAIN -->
<script src="themes/itbirja/js/chosen.jquery.min.js"></script>
<script src="themes/itbirja/js/components/file-uploader.min.js"></script>
<script src="themes/itbirja/js/libs/withinviewport.js" type="text/javascript"></script>
<script src="themes/itbirja/js/libs/jquery.withinviewport.min.js" type="text/javascript"></script>

<script src="themes/itbirja/js/pages/support_rating.js" type="text/javascript"></script>

<script>
  IS_ACTIVE_DIALOG = {DIALOG_ID};
  var DIALOG_SCROLL_TO_MSG = {PHP.msgcroll};
</script>

<div class="centerwrap pt20 mb20 conversations_top">
  <div class="clearfix mr30 m-mr0">
    <h1 class="f32 pull-left m-pull-reset">
      <!-- IF {PHP.issupport} -->
        Диалог с <a href="{DS_OPONENT_DETAILSLINK}">{DS_OPONENT_NICKNAME}</a>
      <!-- ELSE -->
        {PHP.cfg.ds.supportinfo.pagetitle}
      <!-- ENDIF -->
      <i class="icon ico-<!-- IF {DS_OPONENT_ONLINE} == 1 -->online<!-- ELSE -->offlineDark<!-- ENDIF -->" style="display: inline-block;vertical-align: middle;"></i>
    </h1>
  </div>
  <div id="currentPage" style="display:none;">{PHP.d}</div>
  <div class="block-response">
    <i class="ico-arrow-left dib v-align-m"></i>
    <a class="dib v-align-m f14 color-gray color-text" href="{PHP|cot_url('ds')}">К списку сообщений</a>
  </div>
  <div class="mt20 m-hidden"></div>
  <div class="mt10 m-visible"></div>
  <div class="w700 dib inbox-messages-js" style="position: relative;">
    <div class="paging" style="position: absolute;width: calc(100% - 320px);padding-right: 160px;top: -59px;right: 0px;">
      <div class="p1">
        <ul>
          {PAGENAV_PREV}
          {PAGENAV_PAGES}
          {PAGENAV_NEXT}
        </ul>
      </div>
    </div>
    <div id="msgresults" class="pl15 pr15<!-- IF {PHP.lastpage} --> islastpage<!-- ENDIF -->" data-lasthref="{PAGENAV_LAST}">
      <ul class="gig-reviews-list">
        <div class="clear pt0"></div>

        <!-- BEGIN: DS_ROW -->
          <!-- BEGIN: DS_HR -->
            <div class="conversation-date_separator">
              <div class="t-align-c">
                <div class="dib mb-8 pl10 pr10 bodybg f13 color-gray">{DS_ROW_HR}</div>
              </div>
              <hr class="gray m0">
            </div>
          <!-- END: DS_HR -->

        <div class="conversation-message conversation-message_<!-- IF {DS_ROW_TOUSER} != {PHP.usr.id} -->out out<!-- ELSE -->_in<!-- ENDIF --><!-- IF {DS_ROW_STATUS} --> unread<!-- ENDIF --><!-- IF {DS_ROW_STAR} --> _msg_in_star<!-- ENDIF -->" data-mid="{DS_ROW_ID}" data-track-id="{DS_ROW_ID}" {DS_ROW_SCROLL}>
          <li class="dib wMax mb0" id="message_{DS_ROW_ID}">

            <div class="message-head_wrap">
              <div class="message-icons floatright">
                <div class="floatright">
                  <svg title="Пометить как важное" class="message__star" data-midstar="{DS_ROW_ID}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18" height="18" viewBox="0 0 18 18">
                    <defs>
                      <path id="uo60a" d="M534.33 442.2l1.78 4.43 4.56.41c.32.03.45.44.2.66l-3.45 3.15 1.03 4.69c.08.32-.26.58-.53.4l-3.92-2.48-3.92 2.48c-.27.18-.6-.08-.53-.4l1.03-4.69-3.46-3.15c-.24-.22-.1-.63.2-.66l4.57-.41 1.78-4.43c.12-.3.54-.3.66 0z"/>
                    </defs>
                    <g>
                      <g transform="translate(-525 -440)">
                        <use fill="#d7d7db" xlink:href="#uo60a"/>
                      </g>
                    </g>
                  </svg>
                  <a role="button" data-href="{DS_ROW_ID|cot_url('ds', 'm=list&resend='$this)}" title="Переслать сообщение" class="im-mess--reply mr5" data-replymsd="{DS_ROW_ID}" onclick="cot_resendmsg($(this));"></a>
                </div>
              </div>
            </div>

            <div class="clearfix">
              <span class="review-avatar">
              <a href="{DS_ROW_USER_DETAILSLINK}" title="{DS_ROW_USER_NICKNAME}">
                <img alt="{DS_ROW_USER_NICKNAME}" src="<!-- IF {DS_ROW_USER_AVATAR_SRC} -->{DS_ROW_USER_AVATAR_SRC}<!-- ELSE -->themes/itbirja/files/avatar/medium/noprofilepicture.gif<!-- ENDIF -->" class="rounded" alt=""/>
              </a>
              </span>
              <span class="comment">
                <div class="clearfix">
                  <div class="f14 color-gray font-OpenSans floatright comment-time mr10">{DS_ROW_DATE}</div>
                  <span class="comment-meta">
                    <span data-is-online="{DS_ROW_USER_ONLINE}" data-darktheme="true" data-user-id="{DS_ROW_USER_ID}">
                      <i class="icon ico-<!-- IF {DS_ROW_USER_ONLINE} -->online<!-- ELSE -->offlineDark<!-- ENDIF -->"></i>
                    </span>
                    <a href="{DS_ROW_USER_DETAILSLINK}" class="username font-OpenSans">
                      {DS_ROW_USER_NICKNAME}
                    </a>
                  </span>
                </div>
                <div class="message-main-content">
                  <span class="comment-comment breakwords m-ml15">{DS_ROW_TEXT}</span>
                  <div class="conversation-message-file-wrap" data-json-files='null'>
                    <!-- IF {DS_MAVATARS.MAVATARCOUNT} > 0 -->
                      <!-- FOR {KEY}, {VALUE} IN {DS_MAVATARS.MAVATAR} -->
                        <div id="id{VALUE.ID}" class="mb5 file-item file-item-conversations">
                          <a href="{VALUE.FILE}" target="_blank" class="color-text">
                          <i class="ico-file-{VALUE.FILEEXTICON} dib v-align-m"></i>
                          <span class="v-align-m ml10 mw80p">{VALUE.FILEORIGNAME}.{VALUE.FILEEXT}</span>
                          </a>
                        </div>
                      <!-- ENDFOR -->
                    <!-- ENDIF -->
                  </div>
                  {DS_ROW_RESEND}
                  <!-- IF {DS_ROW_FRUSER} > 0 -->
                   <!-- IF {PHP.issupport} -->
                    <!-- IF {DS_ROW_TOUSER} != {PHP.usr.id} AND {DS_ROW_SCORE.s_mid} > 0-->
                      <!-- IF {PHP.usr.maingrp} == 5 OR {DS_ROW_SCORE.s_modvis} -->
                        <hr class="gray m0">
                        Получена оценка пользователя: <b>{DS_ROW_SCORE.s_score}</b>
                      <!-- ENDIF -->
                    <!-- ENDIF -->
                   <!-- ELSE -->
                    <!-- IF {DS_ROW_TOUSER_REAL} == {PHP.usr.id} -->
                    <hr class="gray m0">
                    <div class="score-block mb10" data-score-block="{DS_ROW_ID}">
                      <div class="rating-block-toggle"<!-- IF {DS_ROW_SCORE.s_mid} > 0 --> style="display:none"<!-- ENDIF -->>
                        <span class="f13">Оцените работу специалиста: </span>
                        <div class="stars-container dib ml15 lh20">
                          <input type="radio" name="score_{DS_ROW_ID}" class="rating score_input hidden" value="1"<!-- IF {DS_ROW_SCORE.s_score} == 1 --> checked<!-- ENDIF -->>
                          <input type="radio" name="score_{DS_ROW_ID}" class="rating score_input hidden" value="2"<!-- IF {DS_ROW_SCORE.s_score} == 2 --> checked<!-- ENDIF -->>
                          <input type="radio" name="score_{DS_ROW_ID}" class="rating score_input hidden" value="3"<!-- IF {DS_ROW_SCORE.s_score} == 3 --> checked<!-- ENDIF -->>
                          <input type="radio" name="score_{DS_ROW_ID}" class="rating score_input hidden" value="4"<!-- IF {DS_ROW_SCORE.s_score} == 4 --> checked<!-- ENDIF -->>
                          <input type="radio" name="score_{DS_ROW_ID}" class="rating score_input hidden" value="5"<!-- IF {DS_ROW_SCORE.s_score} == 5 --> checked<!-- ENDIF -->>
                        </div>
                        <span class="fs13 dib color-gray span-score"></span>
                        <div id="check-block" class="pt5 color-gray fs13">
                          <span>Оценку видит: </span>
                          <input type="checkbox" id="check-admin_{DS_ROW_ID}" class="styled-checkbox check-admin" checked disabled>
                          <label for="check-admin_{DS_ROW_ID}">администрация</label>
                          <input type="checkbox" id="check-support_{DS_ROW_ID}" class="styled-checkbox check-support"<!-- IF !{DS_ROW_SCORE.s_mid} OR {DS_ROW_SCORE.s_modvis} --> checked<!-- ENDIF -->>
                          <label for="check-support_{DS_ROW_ID}">специалист службы поддержки</label>
                        </div>
                      </div>
                      <div class="h55 lh55 rating-block-toggle"<!-- IF !{DS_ROW_SCORE.s_mid} --> style="display:none"<!-- ENDIF -->>
                        <span class="f13">Оценка принята. </span>
                        <a href="javascript: void(0)" class="requiredInfo-attention-link cur rating_show-link-js f13">Изменить?</a>
                      </div>
                    </div>
                   <!-- ENDIF -->
                  <!-- ENDIF -->
                 <!-- ENDIF -->
                </div>
              </span>
            </div>
            <div class="clear"></div>
          </li>
        </div>
        <!-- END: DS_ROW -->
      </ul>
    </div>

    <script>
    	$(document).on('click', '.score-star, .check-support', function () {
    		var scoreBlock = $(this).closest('.score-block');
    		var inboxId = scoreBlock.data("scoreBlock");
    		var score = scoreBlock.find('.score_input:checked').val();
    		var flag = scoreBlock.find('.check-support').prop("checked");
    		var el = this;
    		if (score) {
    			$.ajax({
    				url: "/api?method=ds_setscore",
    				type: "GET",
    				data: {inboxId: inboxId, score: score, check: (flag ? 1 : 0)},
    				dataType: "json",
    				success: function () {
    					ratingToggle(el);
    				}
    			});
    		}
    	});

    	function ratingToggle(el) {
    		var scoreBlock = $(el).closest('.score-block');
    		scoreBlock.find('.rating-block-toggle').toggle();
    	}

    	$('.rating_show-link-js').on('click', function () {
    		ratingToggle(this);
    	});

    	if ($('.stars-container').length > 0) {
    		$('.stars-container').rating();
    	}
    </script>

    <div class="pt5 pb5" data-newdialogmsg="{CNTNEWMSGS}" data-lastmsgurl="{DS_FORM_SEARCH}"><!-- IF !{PHP.lastpage} AND {CNTNEWMSGS} > 0 --><a href="{DS_FORM_SEARCH}">Есть новые сообщения ({CNTNEWMSGS})</a><!-- ENDIF --></div>

    <div class="p20 bgWhite mb20 pt20" id="block_message">
      <!-- IF !{PHP.issupport} -->
      <div class='pull-right f14'></div>
      <div class='pull-right f14' style="margin-top:-13px;margin-bottom:8px;">
        <div class="font-OpenSans">Техподдержка отвечает на вопросы в будни с 8:00 до 01:00 (МСК), а в выходные – с 13:00 до 02:00</div>
      </div>
      <!-- ELSE -->
      <div class='pull-right f14'></div>
      <div class='pull-right f14' style="margin-top:-13px;margin-bottom:8px;">
        <div class="font-OpenSans t-align-r">{DS_OPONENT_NICKNAME}</div>
        <div style='color:grey;' class="js-user-online-block font-OpenSansLight" data-is-online="{DS_OPONENT_ONLINE}" data-darktheme="true" data-with-text="true" data-user-id="{DS_OPONENT_ID}">
          <i class="icon ico-<!-- IF {DS_OPONENT_ONLINE} -->online<!-- ELSE -->offlineDark<!-- ENDIF -->"></i>
          <!-- IF {DS_OPONENT_ONLINE} -->Онлайн<!-- ELSE -->Оффлайн<!-- ENDIF -->
        </div>
      </div>
      <div class="clearfix"></div>
      <!-- ENDIF -->

      <!-- IF {PHP.usr.profile.user_MODERNAME} OR {PHP.usr.maingrp} == 5 OR !{PHP.issupport} -->
      <form action="{DS_FORM_SEND}" class="mb0" id="new_message" enctype="multipart/form-data" method="post" class="mb0">
        <input type="hidden" name="resend" value="" />
        <div class="">
          <!-- IF {PHP.issupport} -->
           <div style="margin-bottom: 10px">
            <!-- IF {PHP.usr.maingrp} == 5 -->
            <div style="margin-bottom: 10px;">
              <input type="text" name="rmodername" class="input-styled" placeholder="Имя менеджера" value="{PHP.usr.profile.user_MODERNAME}" style="width: 50%; float: left;" />
              <label style="float: left;width: calc(50% - 20px);padding: 5px 0px 0px 20px;">
                <input type="checkbox" name="rmodernameshide" value="1">
                Скрыть имя менеджера<br>(Отправитель "{PHP.cfg.ds.supportinfo.name}")
              </label>
              <div class="clearfix"></div>
            </div>
            <!-- ENDIF -->
            <input type="text" name="rmodertheme" class="input-styled" placeholder="Тема сообщения" style="width: 100%; margin-bottom: 10px;" />
            <!-- IF {PHP.usr.maingrp} == 5 -->
            <label>
              <input type="checkbox" name="rmoderfromauto" value="1">
              Отправить в виде уведомления
            </label>
            <!-- ENDIF -->
           </div>
          <!-- ENDIF -->

          <div class="">
            <div id="message_form_wrapper">
              <div class="msg-error">
                <p id="message_validation_error"></p>
              </div>
              <div class="write-wrap">
                <div class="write-row cf">
                  <div align="left">
                    <span id="message_body_len">0</span>
                    / 4000
                    <span class="message_resend_info" style="display: none">
                      <span></span>
                      <a role="button" title="Отменить пересылку сообщений" onclick="cot_resendmsg_clear();">Отмена</a>
                    </span>
                  </div>
                  <textarea maxlength="4000" class="control-en js-alt-send js-stopwords-check no-min-len styled-input f14 db wMax mh85 message_body" cols="35" rows="3" id="message_body" name="message_body" style="overflow:auto; margin-bottom: -1px;"></textarea>
                  <input id="message_message_format" name="message_message_format" type="hidden"/>
                </div>
                <input type="hidden" name="message_type" value=""/>
                <div class="message-form-control">
                  <div class="write-controls clearfix">
                    <div class="dialog__files mt10">
                      <div id="load-files-conversations" class="add-files"></div>
                    </div>
                    <div class="btn__add-group clearfix">
                      <input class="pull-left w50p border-box pr10 btn-send-message btn-disable-toggle disabled pull-left send-small green-btn btn--big18 p0 hoverMe h50 mt10 pull-reset" disabled name="commit" value="Отправить" type="submit">
                    </div>
                    <div class="message-form-control__error"></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </form>
      <!-- ELSE -->
      <div class="alert alert-warning">У Вас не заполнено имя менеджера, пожалуйста обратитесь к администратору</div>
      <!-- ENDIF -->
    </div>

    <script src="themes/itbirja/js/track/readTrackService.js" type="text/javascript"></script>
    <script src="modules/ds/js/ds.sendinbox.js" type="text/javascript"></script>

    <script>
      var ordersBetweenUsers = 1;

      var requestDodji = 0;
      var requestProject = 0;

      var conversationActorUserName = "{PHP.usr.profile.user_name}";
      var conversationActorUserAvatar = "<!-- IF {PHP.usr.profile.user_avatar} -->{PHP.usr.profile.user_avatar}<!-- ELSE -->themes/itbirja/files/avatar/big/noprofilepicture.gif<!-- ENDIF -->";
      var conversationImageUrl = "/images";

      var offer = {
          lang: "ru",
          prdPackages: [],
          maxDodjiCount: 10,
          multiDodjiRate: 0.5,
          comission: 20,
          customMinPrice: 500,
          customMaxPrice: 50000,
          workerDefaultPrice: "400",
          payerDefaultPrice: "500.00",
          customPricesOptionsHtml: '<option data-payer-value="100" data-seller-value="80" value="1">80 Р</option>'
      };
    </script>
    <div align="center" class="mb10">
      <div class="paging">
        <div class="p1">
          <ul>
            {PAGENAV_PREV}
            {PAGENAV_PAGES}
            {PAGENAV_NEXT}
          </ul>
        </div>
      </div>
    </div>
  </div>

  <script>
    var pageq = ($('.paging ul li').eq(0).hasClass('prev') ? 1 : 0);
    var newhref = $('.paging').eq(0).find('ul > li').eq(pageq).children().attr('href');
    $('.paging ul').each(function() {
      $(this).find('li').eq(pageq).children().attr('href', newhref+'?d=1');
    });
  </script>

  <div class="sidebarArea dib m-wMax m-m0 mb20" style="max-width: 250px;">
    <!-- IF {PHP.usr.maingrp} == 4 -->
    <div class="sidebar-info gray-bg-border">
      <div class="sidebar-info__title sidebar-info__title--danger">Продавцам</div>
      <div class="sidebar-info__message">
        <div class="sidebar-info__container">
          <div class="sidebar-info__attention">Уважаемые продавцы!</div>
          Запрещается предлагать оформить покупки и принуждать покупателей к оплате заказа вне сервиса RZ-WORK, поскольку в этом случае RZ-WORK не может обеспечить сделку и несет репутационные риски. В случае подобных нарушений, администрация сервиса оставляет за собой право заблокировать аккаунт продавца.
        </div>
      </div>
    </div>
    <!-- ELSE -->
    <div class="sidebar-info gray-bg-border">
      <div class="sidebar-info__title sidebar-info__title--danger">Покупателям</div>
      <div class="sidebar-info__message">
        <div class="sidebar-info__container">
          <div class="sidebar-info__attention">Уважаемые покупатели!</div>
          Остерегайтесь предложений оплатить услугу за пределами RZ-WORK. Такие предложения, особенно с требованием предоплаты, многократно повышают риск потери времени и денег.
          <!-- IF 1 == 2 -->
          <div class="white-btn w30p mt10 f14" style="width: 100%; padding: 7px 15px;" onclick="show_popup($('#popup-case-report').html(), 'popup-new popup-case-report')">Сообщить о таком случае</div>
          <!-- ENDIF -->
        </div>
      </div>
    </div>
    <div class="sidebar-info sidebar-info-contacts gray-bg-border mt20">
      <div class="sidebar-info__title sidebar-info-contacts__title sidebar-info__title--danger" style="padding-top: 16px;">Информация по обмену контактными данными</div>
      <div class="sidebar-info__container sidebar-info-contacts__container">
        <div>Как показывает практика, заказы и общение внутри RZ-WORK проходят более гладко, комфортно и безопасно, чем на сторонних сервисах. Поэтому размещать и передавать контактные данные запрещено. В случае нарушений контакты будут удалены, а аккаунт - деактивирован.</div>
      </div>
    </div>
    <!-- ENDIF -->

    <!-- BEGIN: MAVHISTORY -->
    <div class="p15-20 white-bg-border mt20">Файлы диалога</div>
    <div class="bgLightGray p15-20 f14 ds_mavfilehistory">
      <!-- BEGIN: MAVHIST_ROW -->
      <div class="w210 ovf-h nowrap t-ofv-el">
        <a href="{DS_MAV_HIST.FILE}" target="_blank" class="color-text">
          <i class="ico-file-{DS_MAV_HIST.FILEEXTICON} dib v-align-m"></i>
          <span class="v-align-m ml10 mw80p">{DS_MAV_HIST.FILEORIGNAME}.{DS_MAV_HIST.FILEEXT}</span>
        </a>
      </div>
      <hr class="gray">
      <!-- END: MAVHIST_ROW -->
    </div>
    <!-- END: MAVHISTORY -->
  </div>

  <div class="message_sound_block sm-hidden">
    <i class="tooltipster js-message-sound-ico icon ico-bell hidden" onclick="setMessageSound($(this));" data-tooltip-side="left" data-tooltip-text="Звуковые уведомления отключены. Включить"></i>
    <i class="tooltipster js-message-sound-ico icon ico-bell_active " onclick="setMessageSound($(this));" data-tooltip-side="left" data-tooltip-text="Звуковые уведомления включены. Отключить"></i>
  </div>
  <div class="message_sound_block m-visible">
    <i class="tooltipster js-message-sound-ico icon ico-bell hidden" onclick="setMessageSound($(this));" data-tooltip-side="left" data-tooltip-text="Звуковые уведомления отключены. Включить"></i>
    <i class="tooltipster js-message-sound-ico icon ico-bell_active " onclick="setMessageSound($(this));" data-tooltip-side="left" data-tooltip-text="Звуковые уведомления включены. Отключить"></i>
  </div>
</div>
<!-- END: MAIN -->