{* Smarty *}

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

$(function(){
  var param = GetParamForGrid($("#DateForm").serialize());
  $("#GridDemandsReportByEngineer").jqGrid({
    caption:"Отчет по выполненным заявкам по системным инженерам",
    datatype: "json",
    url:"{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/ReportDemandsByEngineerList.ajax.php{literal}",
    colNames:['Статус','ФИО','Количество','Подразделение','Должность','Телефон','Телефон вн.','Телефон сот.','E-mail'],
    colModel:[
      {name:'users_status', index:'users_status', width:55},
      {name:'users_fio', index:'users_fio', width:180},
      {name:'demands_count', index:'demands_count', width:70, align:"right"},
      {name:'structureorganization_title', index:'structureorganization_title', width:100},
      {name:'users_jobtitle', index:'users_jobtitle',	width:120},
      {name:'users_tel', index:'users_tel',	width:80},
      {name:'users_telint', index:'users_telint', width:70},
      {name:'users_telcell', index:'users_telcell', width:80, hidden:true},
      {name:'users_email', index:'users_email', width:160}
    ],
//    multiselect: true,
    rowNum:100,
    rowList:[10,25,100,500],
    pager: "#GridDemandsPager",
    sortname: 'users_fio',
    sortorder: "asc",
    viewrecords: true,
    rownumbers: true,
    footerrow: true,
    userDataOnFooter: true,
    altRows: true,
    width: "100%",
    height: 290,
    postData: param
  });
  $("#GridDemandsReportByEngineer").jqGrid('navGrid','#GridDemandsPager', {edit:false,add:false,del:false,search:false,refresh:false});
});

$(function(){
  $("#DateForm").submit(function() {
    var param = GetParamForGrid($(this).serialize());
    $('#GridDemandsReportByEngineer').setGridParam({postData: param});
    $("#GridDemandsReportByEngineer").trigger("reloadGrid");
    return false;
  });
});

//function DemandsByEngineerList(VarId){
//  $.ajax({
//    async: false,
//    timeout: 3000,
//    type: "GET",
//    url: "{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/ReportDemandsByEngineerId.ajax.php{literal}",
//    data: {
//      UrlId: VarId
//    },
//    success: function(answ){
//      $("#DemandsByEngineerList").html(answ);
//    }
//  });
//  $("#DemandsByEngineerList").dialog({
//    title: "Заявки.",
//    autoOpen: true,
//    width: 740,
//    resizable: true,
//    modal: true,
//    buttons: {
//      "Закрыть": function() {
//        $(this).dialog("close");
//      }
//    }
//  });
//}
//]]>
</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="GridDemandsReportByEngineer"><tr><td></td></tr></table>
<div id="GridDemandsPager"></div>