{if $resMessages}
    {form->start name="formReplySubmit" method="post"}
<div class="container-section msg-content-section">
<div class="clearfix padding rmv-padding-bottom visible-xs">
    <a class="back msg-back btn btn-primary btn-sm margin-left margin-top">{$language.lblBack}</a>
</div>
<ul>
               {function name=messages level=0}
                  {foreach from=$data item="message" key="key1"}
                      {assign var="id" value=$message.messageID}
                      {assign var="msgStatus" value=$message.status}
                      {assign var="msglastsentBy" value=$message.sentBy}
                 {if in_array($message.messageID,$resParents)}     
                <li class="{if $msglastsentBy!='Merchant'} merchant {/if}">
  {if $message.parentID==0}
  <h2>{$message.subject}</h2>
      <p>{$language.lblType}: 
          
  {if $message.type == 'brand'}
                        {$language.lblBrand}
                       
 {/if}          
          <br>
    {$language.lblFrom}: {$message.businessName}<br>
     {/if}
 {if $message.parentID==0}{$language.lblDate}:{else}<h4>
                    {if $msglastsentBy=='Merchant'} {$message.businessName}{else}{$language.lblAdmin}{/if}</h4> {/if}{$message.createdDate|date_format:$settingsDateFormat} {$message.createdDate|date_format:$time_format}</p>
<div class="cmt">
{$message.message}
</div>
</li>
 {if $showid==$message.messageID}
            <li class="clearfix msg-enter">                
                            <p>
                         {form->textarea id="replyText" name="replyText" cols="45" rows="5" tabindex="1" class="form-control" validate="required" placeholder="{$language.lblWriteComment}"  error=$language.errMessage} 
                    {if $message.originID>0}
                                 {assign var="orgID" value=$message.originID}
                            {else}
                                  {assign var="orgID" value=$message.messageID}
                            {/if}
                            {form->hidden value=$orgID name="originID"}   
                            {form->hidden value=$msglastsentBy name="lastsentBy"}
                            {form->hidden value=$message.messageID name="messageID"}
                            {form->hidden name="messageType"}
                            {form->hidden value=$message.type name="msgtype"}
                            {form->hidden value=$message.subject name="subject"}
                            {form->hidden value='Merchant' name="sentBy"}                     
                        
                        {form->submit name="submitReply" class="btn btn-primary btn-sm pull-right margin-top" value="{$language.lblSend}" tabindex="2"} 
                         </p>
                       </li>
                       {/if}  
                  
                   {if isset($message['replyMsg']) && is_array($message['replyMsg']) && !empty($message['replyMsg'])}                                           
                       {call name=messages data=$message['replyMsg']|default:'' level=$level+1}  <!--menu function calling-->
                 {/if}
        {/if}
        {/foreach}                 
         {/function}
          {call messages data=$resMessages} 
    	</ul>
</div>
{form->close}  
{form->validate_script form="formReplySubmit"}
{/if}
{form->basepath_script}
{form->rootpath_script}
<script>
$(document).ready(function(){
    $(".msg-back").click(function(){
                    $(".msg-sec-right").removeClass('msg-show');
                    $(".msg-sec-left").removeClass('msg-list-show');
                });
                });
                </script>