{form->start name="formReplySubmit" method="post"} 
{if $resMessages}
<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($id,$resParents)}              
                <li >
  {if $message.parentID==0}
  <h4>{$message.subject}</h4>
   <p>{$language.lblType}: {$message.type|ucfirst}</p>
    <p>{$language.lblFrom}: {$message.businessName}</p>
     {/if}
<p> {if $message.parentID==0}{$language.lblDate}:{else}<strong>{if $msglastsentBy=='Merchant'} {$message.businessName}{else}{$language.lblAdmin}{/if}</strong> {/if}{$message.createdDate|date_format:$settingsDateFormat} {$message.createdDate|date_format:$time_format}</p>
<div class="cmt">
{$message.message}
</div>
</li>
                {if $showid==$id}
                        <li class="clearfix">                
                            <p class="fixing_left pr10"> {$language.lblMessage}&nbsp;</p>
                            <p  class="fixing_left width85">
                         {form->textarea id="replyText" name="replyText" cols="45" rows="5" tabindex="1" class="textarea01" validate="required" error=$language.errMessage} 
                            {if $message.originID>0}
                                 {assign var="orgID" value=$message.originID}
                            {else}
                                  {assign var="orgID" value=$id}
                            {/if}
                            {form->hidden value=$orgID name="originID" id="originID"}
                            {form->hidden value=$msglastsentBy name="lastsentBy"}
                            {form->hidden value=$message.merchantID name="businessID" id="businessID"}
                            {form->hidden value=$id name="messageID" id="messageID"}
                            {form->hidden class="textbox" name="messageType"}
                            {form->hidden value=$message.type name="msgtype" id="msgtype"}
                            {form->hidden value=$message.subject name="subject" id="subject"}
                            {form->hidden value='Admin' name="sentBy" id="sentBy"}                     
                        
                        {form->button name="submitReply" class="button02 curve-3" 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'] level=$level+1}  <!--menu function calling-->
                  {/if} 
        {/if}
        {/foreach}
         {/function}
{call messages data=$resMessages}         
    	</ul>
{/if}
{form->close}  
{form->validate_script form="formReplySubmit"}
{form->basepath_script}
{form->rootpath_script}