{* Smarty *}

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

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

function showResponseDemandsAnswFormAdd(responseText){
  if(typeof(responseText['error'])=='undefined'){
    $("#demandscomments_comment").val("");
    DialogStandartMessageOpen("message", responseText['message']);
    DemandsDetailCommentsLoad();
    $("#DemandsCommentEdit").dialog("close");
  }
  else{
    DialogStandartMessageOpen("error", responseText['error']);
  }
}

$(function() {
  $("textarea").css("width","400px");
  $("textarea").css("height","120px");
  //$("textarea").resizable();
});
  
$(function() {
  var options = {
    success: showResponseDemandsAnswFormAdd,
    timeout: 3000
  };
  $("#DemandsAnswFormAdd").validate({
    submitHandler: function(form) {
      $(form).ajaxSubmit(options);
    },
    rules : {
      demandscomments_comment : {required : 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/DemandsAnswSave.ajax.php" method="post" name="DemandsAnswFormAdd" id="DemandsAnswFormAdd">
  <input id="demands_id" name="demands_id" type="hidden" value="{if isset($smarty.get.demands_id)}{$smarty.get.demands_id}{/if}" />
  <input id="demandscommentsparent_id" name="demandscommentsparent_id" type="hidden" value="{if isset($smarty.get.demandscommentsparent_id)}{$smarty.get.demandscommentsparent_id}{/if}" />
  <input id="demandscomments_id" name="demandscomments_id" type="hidden" value="{if isset($smarty.get.demandscomments_id)}{$smarty.get.demandscomments_id}{/if}" />
  <table>
    <tr>
      <td><label for="FrmUsersHidden">Комментарий  от <span class="ui-state-error">* </span>:&nbsp;</label><span></span></td>
      <td>
        {foreach $ArrUsers as $val}
          {if $val@first}
            <select id="FrmAgreeUsersCheckboxes" name="FrmAgreeUsersCheckboxes[]">
          {/if}
              <option value="{$val.users_id}" {if isset($ArrDemandsComments.users_id) && $ArrDemandsComments.users_id eq $val.users_id}selected="selected"{/if}>{$val.users_fio}</option>
          {if $val@last}
            </select>
          {/if}
        {/foreach}
      </td>
    </tr>
    <tr>
      <td><label for="demandscomments_comment">Содержание <span class="ui-state-error">* </span>:&nbsp;</label><span></span></td>
      <td><textarea cols="50" rows="2" id="demandscomments_comment" name="demandscomments_comment">{if isset($ArrDemandsComments.demandscomments_comment)}{$ArrDemandsComments.demandscomments_comment}{/if}</textarea></td>
    </tr>
    <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>