{* Smarty *}

{literal}
<script type="text/javascript">
//<![CDATA[

$(function() {
  AltButtons();
});

$(function() {
  $("input[name='svttype_name']").css("width","400px");
  $("input[name='svttype_writeoff']").css("width","400px");
});

function showResponseFormSvtTypeAdd(responseText){
  if(typeof(responseText['error'])=='undefined'){
    $("#GridSvtType").trigger("reloadGrid");
    $("#SvtTypeEditFrm").dialog("destroy");
    DialogStandartMessageOpen("message", responseText['message']);
  }
  else{
    DialogStandartMessageOpen("error", responseText['error']);
  }
}

$(function(){
  var options = {
    success: showResponseFormSvtTypeAdd,
    timeout: 3000
  };
  $("#FormSvtTypeAdd").validate({
    submitHandler: function(form) {
      $(form).ajaxSubmit(options);
    },
    ignore: "",
    rules : {
      "svttype_name" : {required : true},
      "svttype_writeoff" : {
        required : true,
        number: true
      }
    },
    errorPlacement: function(error, element) {
      var er = element.attr("name");
      error.appendTo($("label[for='" + er + "']").next() );
    }
  });
});
//]]>
</script>
{/literal}

<form action="{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/SvtTypeSave.ajax.php" method="post" name="FormSvtTypeAdd" id="FormSvtTypeAdd">
  <input id="svttype_id" name="svttype_id" type="hidden" value="{if isset($ArrSvtType.svttype_id)}{$ArrSvtType.svttype_id}{/if}" />
  <table>
    <tr>
      <td><label for="svttype_name">Наименование <span class="ui-state-error">* </span>:&nbsp;</label><span></span></td>
      <td colspan="2"><input type="text" id="svttype_name" name="svttype_name" value="{if isset($ArrSvtType.svttype_name)}{$ArrSvtType.svttype_name}{/if}" /></td>
    </tr>
    <tr>
      <td><label for="svttype_writeoff">Период списания (в годах) <span class="ui-state-error">* </span>:&nbsp;</label><span></span></td>
      <td colspan="2"><input type="text" id="svttype_writeoff" name="svttype_writeoff" value="{if isset($ArrSvtType.svttype_writeoff)}{$ArrSvtType.svttype_writeoff}{/if}" /></td>
    </tr>
    <tr>
      <td colspan="3">
        <span class="ui-state-error"> * </span>поля обязательные для заполнения
      </td>
    </tr>
    <tr>
      <td colspan="3" class="MsFormSubmit"><input class="AltButtons" name="FormSubmit" value="сохранить" type="submit" /></td>
    </tr>
  </table>
</form>