<!-- BEGIN: MAIN -->           
<div class="m-hidden">
  <div class="userbanner" style="background: url(<!-- IF {PHP.usr.profile.user_photo} -->{PHP.usr.profile.user_photo}<!-- ELSE -->/files/cover/header1.jpg<!-- ENDIF -->) no-repeat center center; background-size: cover;">
    <div class="centerwrap clearfix ">
      <div class="contentArea mt40 sm-text-center">
        <div class=" pull-left sm-pull-reset">
          <img class="rounded" alt="{PHP.usr.profile.user_name}" src="<!-- IF {PHP.usr.profile.user_avatar} -->{PHP.usr.profile.user_avatar}<!-- ELSE -->themes/itbirja/files/avatar/big/noprofilepicture.gif<!-- ENDIF -->" width="80" height="80"/>
        </div>
        <div class="userbannertext pull-left ml15 sm-pull-reset m-text-center m-m0">
          <div>
            <h1 class="mt0">{PHP.usr.profile.user_name}</h1>
            <span class="font-OpenSans f14 ml14 is-online-block color-lightGray">
            <i class="icon ico-online"></i>
            Онлайн
            </span>
          </div>
          <div class="color-white2 sm-pull-reset mb10">{PHP.usr.profile.user_FNAME}</div>
          <div class="color-white">
            <div class="pull-left cusongsblock-panel__rating mti3">
              <ul class="rating-block dib v-align-m">
                <!-- IF {PHP.usr.tags.RSTAR} > 0 -->
                <li class="mr2 v-align-m">
                    <i class="fa fa-star gold" aria-hidden="true"></i>
                </li>
                <li class="rating-block__rating-item--number fw600 v-align-m">{PHP.usr.tags.RSTAR}&nbsp;</li>
                <!-- ENDIF -->
              </ul>
            </div>
            <p class="dib sm-pull-reset color-white2"><!-- IF {PHP.urr.user_maingrp} == 7 -->{PHP.usr.tags.MK_PAYER_GROUP}<!-- ELSE -->{PHP.usr.tags.MK_SELLER_GROUP}<!-- ENDIF --></p>
            <span class="ml5"></span>
          </div>
        </div>
      </div>
      <div class="sidebarArea ">
        <a class="js-blocked-prds hugeGreenBtn hoverMe GreenBtnStyle h50 wMax mt60" href="{PHP|cot_url('plug', 'e=ads&m=add')}">Создать рекламу</a>
      </div>
    </div>
  </div>
</div>

<style>
.table-style td {
    padding: 8px 15px 8px 0px;
}
</style>

<div class="centerwrap pt20">
  <div class="w700">
    <h1 class="f32">Моя реклама</h1>
  </div>
  <div class="clearfix"></div>

    <table class="wMax">
      <!-- BEGIN: ADS_ROW -->
      <tr>
        <td class="v-align-t sm-block">
          <div class="w700 card manage-prds-item sm-margin-reset prd-wrap js-prd-analytics js-prd-analytics-{PRD_ROW_ID}" data-prd-id="{PRD_ROW_ID}">
            <div class="d-flex flex-nowrap m-flex-wrap">
              <div class="newfoximg responsivefoximages w35p">
                <a href="{PRD_ROW_URL}">
                  <img src="{PRD_ROW_PHOTO_FIRST}" alt="{PRD_ROW_SHORTTITLE}" class="wMax mw230 db"/>
                </a>
              </div>
              <div class="newfoxdetails w63p pli0 pb10 relative ml15 m-ml0 ">
                <div class="pull-right hidden">
                  <input class="checkbox inactive styled-checkbox" id="gig_{PRD_ROW_ID}" name="gig[]" type="checkbox" value="{PRD_ROW_ID}"/>
                  <label for="gig_{PRD_ROW_ID}" class="pl20">&nbsp;</label>
                </div>

                <!-- IF {ADS_ROW_DEL_URL} -->
                <div class="pull-right">
                  <a href="{ADS_ROW_DEL_URL}" class="mt2 mr10 dib btn-delete-gigs autocheck" title="Удалить">
                  <i class="icon ico-trash-18"></i>
                  </a>
                </div>
                <!-- ENDIF -->

                <!-- IF {ADS_ROW_EXPIRE} == 0 AND {ADS_ROW_PAUSED} == 0 -->
                  <div class="pull-right">
                    <a href="{ADS_ROW_ID|cot_url('plug', 'e=ads&m=edit&act=buy&id='$this)}" class="btn-activate mt2 mr10 dib autocheck">
                    <i class="ico-play-gray"></i>
                    </a>
                  </div>
                <!-- ELSE -->
                  <!-- IF {ADS_ROW_EXPIRE} > {PHP.sys.now} -->
                    <div class="pull-right">
                      <a href="{ADS_ROW_ID|cot_url('plug', 'e=ads&m=edit&act=paused&id='$this)}" class="btn-suspend mt2 mr10 dib autocheck">
                        <i class="ico-pause-gray"></i>
                      </a>
                    </div>
                  <!-- ELSE -->
                    <!-- IF {ADS_ROW_PAUSED} > 0 -->
                      <div class="pull-right">
                        <a href="{ADS_ROW_ID|cot_url('plug', 'e=ads&m=edit&act=unpaused&id='$this)}" class="btn-activate mt2 mr10 dib autocheck">
                        <i class="ico-play-gray"></i>
                        </a>
                      </div>
                    <!-- ENDIF -->
                  <!-- ENDIF -->
                <!-- ENDIF -->

                <div class="mh92">
                  <div>
                  <!-- IF {ADS_ROW_EXPIRE} == 0 AND {ADS_ROW_PAUSED} == 0 -->
                     <span class="status-block first-letter dib">не оплачен</span>
                  <!-- ELSE -->
                    <!-- IF {ADS_ROW_EXPIRE} > {PHP.sys.now} -->
                     <span class="status-block status-block_green first-letter dib">активен</span>
                    <!-- ELSE -->
                      <!-- IF {ADS_ROW_EXPIRE} > 0 -->
                       <span class="status-block status-block_gray first-letter dib">завершен</span>
                      <!-- ENDIF -->
                      <!-- IF {ADS_ROW_PAUSED} > 0 -->
                       <span class="status-block status-block_blue first-letter dib">остановлен</span>
                      <!-- ENDIF -->
                    <!-- ENDIF -->
                  <!-- ENDIF -->
                  </div>

                  <h3 class="mt10">
                    <a href="{PRD_ROW_URL}">
                    <span class="dib">{PRD_ROW_SHORTTITLE}</span>
                    </a>
                  </h3>
                  <!-- IF {PRD_ROW_CATPATH|count($this)} > 0 -->
                  <div class="mt5">
                    <div class="bread-crump color-gray query-card__breadcrumbs ml0">
                      <!-- FOR {KEY}, {VAL} IN {PRD_ROW_CATPATH} -->
                        <!-- IF {KEY} < 4 -->
                          <span class="query-card__breadcrumb-item">{VAL.1}</span>
                        <!-- ENDIF -->
                      <!-- ENDFOR -->
                    </div>
                  </div>
                  <!-- ENDIF -->

                  <div class="mt5 fs14">
                    <table class="table-style response-table">
                      <tbody>
                        <tr class="m-clearfix">
                          <td>Блок</td>
                          <td>{ADS_ROW_POSITION.title}</td>
                        </tr>
                        <tr class="m-clearfix">
                          <td>Категория</td>
                          <td>{ADS_ROW_CAT.title}</td>
                        </tr>
                        <tr class="m-clearfix">
                          <td>Срок размещения</td>
                          <td>{ADS_ROW_PERIOD}</td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
            <div class="d-flex flex-nowrap m-flex-wrap justify-content-between t-align-c mt10 m-m0">
              <div class="m-w50p m-mb10">
                <div class="f18 fw600">{ADS_ROW_SHOWS}</div>
                <div class="f13 color-gray">{ADS_ROW_SHOWS|cot_declension($this, 'Просмотр,Просмотра,Просмотров', true)}</div>
              </div>
              <div class="m-w50p m-mb10">
                <a role="button" class="f18 fw600 link-color-black">{ADS_ROW_CLICKS}</a>
                <div class="f13 color-gray">{ADS_ROW_CLICKS|cot_declension($this, 'Переход,Перехода,Переходов', true)}</div>
              </div>
              <div class="m-w50p m-mb10" style="text-align: right;">
                <!-- IF {ADS_ROW_EXPIRE} == 0 AND {ADS_ROW_PAUSED} == 0 -->
                  <div class="f18 fw600 color-easy-green-important">
                    <a href="{ADS_ROW_ID|cot_url('plug', 'e=ads&m=edit&act=buy&id='$this)}" onclick="event.preventDefault();pay_ads_order({ADS_ROW_ID});">Оплатить размещение</a>
                  </div>
                  <div class="f13 color-gray">Не оплачен</div>
                <!-- ELSE -->
                  <!-- IF {ADS_ROW_EXPIRE} > {PHP.sys.now} -->
                    <div class="f18 fw600 color-easy-green-important">
                      <a href="{ADS_ROW_ID|cot_url('plug', 'e=ads&m=edit&act=paused&id='$this)}">Приостановить</a>
                    </div>
                    <div class="f13 color-gray">Размещен до <b>{ADS_ROW_EXPIRE|cot_date('d.m.Y H:i', $this)}</b></div>
                  <!-- ELSE -->
                    <!-- IF {ADS_ROW_EXPIRE} > 0 -->
                      <div class="f18 fw600 color-easy-green-important">
                        {ADS_ROW_EXPIRE|cot_date('d.m.Y H:i', $this)}
                      </div>
                      <div class="f13 color-gray">Завершен</b></div>
                    <!-- ENDIF -->
                    <!-- IF {ADS_ROW_PAUSED} > 0 -->
                      <div class="f18 fw600 color-easy-green-important">
                        <a href="{ADS_ROW_ID|cot_url('plug', 'e=ads&m=edit&act=unpaused&id='$this)}">Возобновить</a>
                      </div>
                      <div class="f13 color-gray">Остановлен <b>(Остаток {ADS_ROW_PAUSED_TIME})</b></div>
                    <!-- ENDIF -->
                  <!-- ENDIF -->
                <!-- ENDIF -->
              </div>
            </div>
          </div>
        </td>
      </tr>
      <!-- END: ADS_ROW -->
    </table>
  <!-- IF {ADS_COUNT} == 0 -->
    <p>Активных баннеров нет.</p>
  <!-- ENDIF -->
  <div class="clear"></div>
  <div align="center">
    <div class="clear"></div>
    <div class="mt20"></div>
  </div>
</div>

<div id="alertcheck">{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}</div>
<script>
  $(function() {
    if($('#alertcheck .alert.alert-error').length > 0) {
     var eul = $('#alertcheck').hide().find('.alert.alert-error ul');
     $('#event_list').after('<div class="fox_error"><p>'+eul.html().trim().replaceAll('<li>', '<p>').replaceAll('</li>', '</p>')+'</p></div>');
    }
    if($('#alertcheck .alert.alert-success').length > 0) {
     var eul = $('#alertcheck').hide().find('.alert.alert-success ul');
     $('#event_list').after('<div class="fox_success"><p>'+eul.html().trim().replaceAll('<li>', '<p>').replaceAll('</li>', '</p>')+'</p></div>');
    }
  });

  function pay_ads_order(id) {
  	$.ajax({
  		type: "GET",
  		url: '/api?method=ads_order&id=' + id,
  		dataType: 'json',
  		success: function(result) {
  			if (result.success === true) {
  				location.href = result.redirect;
  			} else {
          if(result.purse_amount > 0 && result.payment_id > 0) {
            show_balance_popup(result.purse_amount, 'ads', result.payment_id);
          } else {
  				  show_message('error', (result.error ? result : 'Произошла ошибка. Пожалуйста, попробуйте еще раз.'));
          }
  			}
  		}
  	});
    return false;
  }
  <!-- IF {ADS_NOW_PAY} > 0 -->
    pay_ads_order({ADS_NOW_PAY});
  <!-- ENDIF -->
</script>
<!-- END: MAIN -->