{* Smarty *}

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

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

function showResponseFormUsersServicesAdd(responseText){
  if(typeof(responseText['error'])=='undefined'){
    $("#UsersEditFrm").dialog("close");
    DialogStandartMessageOpen("message", responseText['message']);
  }
  else{
    DialogStandartMessageOpen("error", responseText['error']);
  }
}

$(function(){
  var options = {
    success: showResponseFormUsersServicesAdd,
    timeout: 3000
  };
  $("#FormUsersServicesAdd").validate({
    submitHandler: function(form) {
      $(form).ajaxSubmit(options);
    },
//    rules : {
//      group_id : {required : true},
//      structureorganization_id : {required : true},
//      users_name : {required : true},
//      users_password : {required : true},
//      users_password2 : {
//        equalTo: "#users_password"
//      },
//      users_fio : {required : true},
//      users_email : {required : true, email: true}
//    },
    errorPlacement: function(error, element) {
      var er = element.attr("name");
      error.appendTo($("label[for='" + er + "']").next() );
    }
  });
});
//]]>
</script>
{/literal}

{foreach $ArrWebServices as $val}
  {if $val@first}
<form action="{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/UsersServicesSave.ajax.php" method="post" name="FormUsersServicesAdd" id="FormUsersServicesAdd">
  <input id="users_id" name="users_id" type="hidden" value="{if isset($smarty.get.users_id)}{$smarty.get.users_id}{/if}" />
  <table>
  {/if}
    <tr>
      <td><label for="users_status">{$val.webservices_name} <span class="ui-state-error"></span>:&nbsp;</label><span></span></td>
      <td><input type="checkbox" id="webservices_id[]" name="webservices_id[]" value="{$val.webservices_id}"{if isset($val.users_id) && 0 < $val.users_id} checked="checked"{/if} /></td>
    </tr>
  {if $val@last}
    <tr>
      <td colspan="2">
        <span class="ui-state-error"> * </span>поля обязательные для заполнения
      </td>
    </tr>
    <tr>
      <td colspan="2" class="MsFormSubmit"><input class="AltButtons" name="FormSubmit" value="сохранить" type="submit" /></td>
    </tr>
  </table>
</form>
  {/if}
{/foreach}