{* Smarty *}

{literal}
<script type="text/javascript">
//<![CDATA[
$(function(){
  $.datepicker.setDefaults($.datepicker.regional['ru']);
  var VarYearE = (new Date).getFullYear()+1;
  $("#repair_numdocdate_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}'}));
  $("#repair_numdocdate_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}'}));
  $("#repair_numdocdate_b").datepicker( "setDate", '-1m');
  $("#repair_numdocdate_e").datepicker( "setDate", '0d');
});

$(function(){
  var param = GetParamForGrid($("#DateForm").serialize());
  $("#GridRepairReportByPeriod").jqGrid({
    caption:"Отчет по ремонтам",
    datatype: "json",
    url:"{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/ReportRepairForOperatorsList.ajax.php{literal}",
    colNames:['№ ремонта','№ заявки','Статус','Поставщик услуг','Сумма','Вид работ','№ платежного документа','Дата платежного документа','Сист. инженер','Дата нач. ремонта','Дата оконч. ремонта'],
    colModel:[
      {name:'repair_id', index:'repair_id', width:55},
      {name:'demands_id', index:'demands_id', width:55},
      {name:'repairstatus_name', index:'repairstatus_name'},
      {name:'organiz_name', index:'organiz_name', width:100},
      {name:'repair_summa', index:'repair_summa', width:90, align:"right", formatter:"number", summaryType:'sum'},
      {name:'repair_content', index:'repair_content',	width:100},
      {name:'repair_numdoc', index:'repair_numdoc',	width:70},
      {name:'repair_numdocdate', index:'repair_numdocdate', width:80, align:"right", sorttype:'date'},
      {name:'users_fio', index:'users_fio', width:100},
      {name:'repair_date_b', index:'repair_date_b', width:80, align:"right", sorttype:'date'},
      {name:'repair_date_e', index:'repair_date_e', width:80, align:"right", sorttype:'date'}
    ],
//    multiselect: true,
    rowNum:100,
    rowList:[10,25,100,500],
    pager: "#GridRepairPager",
    sortname: 'repair_id',
    sortorder: "desc",
    viewrecords: true,
    rownumbers: true,
    footerrow: true,
    userDataOnFooter: true,
    altRows: true,
    width: "100%",
    height: 290,
    postData: param
  });
  $("#GridRepairReportByPeriod").jqGrid('navGrid','#GridRepairPager', {edit:false,add:false,del:false,search:false,refresh:false});
});

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

<form id="DateForm" name="DateForm" action="" method="post">
<table>
  <tr>
    <td><span>Дата с:</span></td>
    <td>
  		<input type="text" id="repair_numdocdate_b" name="repair_numdocdate_b" value="" />
  		<span>по:</span>
  		<input type="text" id="repair_numdocdate_e" name="repair_numdocdate_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="GridRepairReportByPeriod"><tr><td></td></tr></table>
<div id="GridRepairPager"></div>