{* Smarty *}

{literal}
<script type="text/javascript">
//<![CDATA[
$(function(){
  $.datepicker.setDefaults($.datepicker.regional['ru']);
  var VarYearE = (new Date).getFullYear()+1;
  $("#demands_statusdate_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}{$MS_SP->Sp_PathToSmarty}/{$MS_SP->Sp_TemplateName}/css/images/ms_check_calendar.png{literal}'}));
  $("#demands_statusdate_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}{$MS_SP->Sp_PathToSmarty}/{$MS_SP->Sp_TemplateName}/css/images/ms_check_calendar.png{literal}'}));
  $("#demands_statusdate_b").datepicker( "setDate", '-1m');
  $("#demands_statusdate_e").datepicker( "setDate", '0d');
});

$(function(){
  var param = GetParamForGrid($("#DateForm").serialize());
  $("#GridDemandsReportByPeriod").jqGrid({
    caption:"Отчет по заявкам за период",
    datatype: "json",
    url:"{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/DemandsForOperatorsList.ajax.php{literal}",
    colNames:['№ заявки','Дата','Статус','Тип СВТ','Наименование сет.','Наименование бух.','Инв. №','Сер. №','Подразделение','Заявка от','Телефон','Вн. телефон','№ служ. записки','Дата служ. записки'],
    colModel:[
      {name:'demands_id', index:'demands_id', width:55},
      {name:'demands_date', index:'demands_date', width:60, align:"right", sorttype:'date'},
      {name:'sprstatus_name', index:'sprstatus_name', width:100},
      {name:'svttype_name', index:'svttype_name', width:90},
      {name:'svt_name', index:'svt_name',	width:100},
      {name:'svt_buxname', index:'svt_buxname',	width:120},
      {name:'svt_invnum', index:'svt_invnum', width:60},
      {name:'svt_serialnum', index:'svt_serialnum', width:90},
      {name:'structureorganization_title', index:'structureorganization_title', width:70},
      {name:'e.users_fio', index:'e.users_fio', width:100},
      {name:'e.users_tel', index:'e.users_tel', width:65},
      {name:'e.users_telint', index:'e.users_telint', width:65},
      {name:'demands_intdocnum', index:'demands_intdocnum', width:85},
      {name:'demands_intdocdate', index:'demands_intdocdate', width:100, align:"right", sorttype:'date'}
    ],
//    multiselect: true,
    rowNum:100,
    rowList:[10,25,100,500],
    pager: "#GridDemandsPager",
    sortname: 'demands_id',
    sortorder: "desc",
    viewrecords: true,
    rownumbers: true,
    width: "100%",
    height: 290,
    postData: param
  });
  $("#GridDemandsReportByPeriod").jqGrid('navGrid','#GridDemandsPager', {edit:false,add:false,del:false,search:false,refresh:false});
});

$(function(){
  $("#DateForm").submit(function() {
    var param = GetParamForGrid($(this).serialize());
    $('#GridDemandsReportByPeriod').setGridParam({postData: param});
    $("#GridDemandsReportByPeriod").trigger("reloadGrid");
    return false;
  });
});
//]]>
</script>
{/literal}

<form id="DateForm" name="DateForm" action="" method="get">
<table>
  <tr>
    <td><span>Дата с:</span></td>
    <td>
  		<input type="text" id="demands_statusdate_b" name="demands_statusdate_b" value="" />
  		<span>по:</span>
  		<input type="text" id="demands_statusdate_e" name="demands_statusdate_e" value="" />
  	</td>
  </tr>
  <tr>
    <td colspan="2" class="MsFormSubmit"><input class="AltButtons" name="FormSubmit" value="искать" type="submit" /></td>
  </tr>
</table>
</form>
<br />
<table id="GridDemandsReportByPeriod"><tr><td></td></tr></table>
<div id="GridDemandsPager"></div>