{* Smarty *}

<form id="SearchSimpleForm" name="SearchSimpleForm" action="" method="get">
<table>
  <tr>
    <td><span class="N1QFLabelC N1QFLabelT">Дата с:</span></td>
    <td colspan="2">
  		<input type="text" id="svt_date_b" name="svt_date_b" value="" autocomplete="off" />
  		<span class="N1QFLabelC N1QFLabelT">по:</span>
  		<input type="text" id="svt_date_e" name="svt_date_e" value="" autocomplete="off" />
  	</td>
  </tr>
	<tr>
  	<td colspan="3" style="text-align:center;">
      {literal}
      <script type="text/javascript">
      <!--
        var VarYearE = (new Date).getFullYear()+1;
        $("#svt_date_b").datepicker($.extend({yearRange: '1970:'+VarYearE, dateFormat: "dd.mm.yy", changeMonth: true, changeYear: true, closeText: 'X', showButtonPanel: true, showStatus: true,showOn: 'both', buttonText: 'Выбрать дату', buttonImageOnly: true, buttonImage: '{/literal}{$MS_SP->Sp_PathTop}/images/ms_check_calendar.png{literal}'}));
        $("#svt_date_e").datepicker($.extend({yearRange: '1970:'+VarYearE, dateFormat: "dd.mm.yy", changeMonth: true, changeYear: true, closeText: 'X', showButtonPanel: true, showStatus: true,showOn: 'both', buttonText: 'Выбрать дату', buttonImageOnly: true, buttonImage: '{/literal}{$MS_SP->Sp_PathTop}/images/ms_check_calendar.png{literal}'}));
        $("#svt_date_b").datepicker( "setDate", '-1m');
        $("#svt_date_e").datepicker( "setDate", '0d');
      //-->
      </script>
      {/literal}
    </td>
  </tr>
  <tr>
    <td colspan="3" style="text-align:center;">
      <div class="AltButtons">
        {literal}
        <script type="text/javascript">
          $(function() {
            $(".AltButtons button").button()
          });
          </script>
        {/literal}
        <button OnClick="$('#SearchSimpleForm').submit();">Искать</button>
      </div>
  	</td>
  </tr>
</table>
</form>
<br />
<table id="flexReportByPeriod" style="display:none"></table>

{literal}
<script type="text/javascript">
  $("#flexReportByPeriod").flexigrid({
    url: "{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/ReportSvtByPeriodForOperatorsList.ajax.php{literal}",
    dataType: "json",
    colModel : [
      {display: "Наименование сет.", name : "svt_name", width : 100, sortable : true, align: "left"},
      {display: "Наименование бух.", name : "svt_buxname", width : 100, sortable : true, align: "left"},
      {display: "Тип СВТ", name : "svttype_name", width : 80, sortable : true, align: "left"},
      {display: "Инв. номер", name : "svt_invnum", width : 60, sortable : true, align: "left"},
      {display: "Сер. номер", name : "svt_serialnum", width : 90, sortable : true, align: "left"},
      {display: "Подразделение", name : "structureorganization_title", width : 80, sortable : true, align: "left"},
      {display: "Пользователь", name : "users_fio", width : 80, sortable : true, align: "left"},
      {display: "Поставщик", name : "organiz_name", width : 80, sortable : true, align: "left"},
      {display: "Дата поставки", name : "svt_date", width : 70, sortable : true, align: "left"},
      {display: "Гарантия", name : "svt_garant_date", width : 70, sortable : true, align: "left"}
    ],
    sortname: "svt_id",
    sortorder: "desc",
    title: "Отчет по СВТ за период",
    usepager: true,
    pagetext: "Страница",
    outof: "из",
    findtext: "Искать",
    errormsg: "Нет соединения",
    pagestat: "Отображается с {from} по {to} из {total} записей",
    pagetext: "Страница",
    procmsg: "Идет запрос, подождите пожалуйста ...",
    nomsg: "Нет записей",
    singleSelect: true,
    nowrap: false,
    useRp: true,
    rp: 100,
    rpOptions: [100,250,500,1000],
    showTableToggleBtn: true,
    onSubmit: FlexReportByPeriodData,
    height: 400
  });

  function FlexReportByPeriodData(){
    var dt = $("#SearchSimpleForm").serializeArray();
    $("#flexReportByPeriod").flexOptions({params: dt});
    return true;
  }

  $("#SearchSimpleForm").submit(
    function (){
      $("#flexReportByPeriod").flexOptions({newp: 1}).flexReload();
      return false;
    }
  );
</script>
{/literal}