{* Smarty *}

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

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

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

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

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

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

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