{* Smarty *}

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

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

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

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

$(function(){
  var options = {
    success: showResponseFormSprStatusAdd,
    timeout: 3000
  };
  $("#FormSprStatusAdd").validate({
    submitHandler: function(form) {
      $(form).ajaxSubmit(options);
    },
    ignore: "",
    rules : {
      "sprstatus_name" : {required : true},
      "sprstatus_color" : {required : true},
      "sprstatus_order" : {
        required : true,
        number: true
      }
    },
    errorPlacement: function(error, element) {
      var er = element.attr("name");
      error.appendTo($("label[for='" + er + "']").next() );
    }
  });
});

$(function(){
  $('#sprstatus_color').colorPicker();
});  
  
//]]>
</script>
{/literal}

<form action="{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/SprStatusSave.ajax.php" method="post" name="FormSprStatusAdd" id="FormSprStatusAdd">
  <input id="sprstatus_id" name="sprstatus_id" type="hidden" value="{if isset($ArrSprStatus.sprstatus_id)}{$ArrSprStatus.sprstatus_id}{/if}" />
  <table>
    <tr>
      <td><label for="sprstatus_name">Наименование <span class="ui-state-error">* </span>:&nbsp;</label><span></span></td>
      <td colspan="2"><input type="text" id="sprstatus_name" name="sprstatus_name" value="{if isset($ArrSprStatus.sprstatus_name)}{$ArrSprStatus.sprstatus_name}{/if}" /></td>
    </tr>
    <tr>
      <td><label for="sprstatus_color">Цвет для отображения :&nbsp;</label><span></span></td>
      <td colspan="2"><input type="text" id="sprstatus_color" name="sprstatus_color" value="{if isset($ArrSprStatus.sprstatus_color)}{$ArrSprStatus.sprstatus_color}{/if}" /></td>
    </tr>
    <tr>
      <td><label for="sprstatus_order">Сортировка <span class="ui-state-error">* </span>:&nbsp;</label><span></span></td>
      <td colspan="2"><input type="text" id="sprstatus_order" name="sprstatus_order" value="{if isset($ArrSprStatus.sprstatus_order)}{$ArrSprStatus.sprstatus_order}{/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>