{extends "[shared]/window.tpl"}

{block tabs}
   {windowTab id='flapComments'}
{/block}

{block tabsContent}
   <div id="flapComments" class="tab-pane fade active in boxFlex">

      <div class="row">
         <div class="form-group form-group-flex">
            <div class="col-md-2 control-label">
               <label>
                  {if $body.type =='product'}
                     {'product'|translate}
                  {elseif $body.type == 'article'}
                     {'article'|translate}
                  {/if}
               </label>
            </div>
            <div class="col-md-8">
               {if $body.type =='product'}
                     <a href="javascript:nw('products', {$body.objectId})">{$body.object.title}</a>
                  {elseif $body.type == 'article'}
                     <a href="javascript:nw('articles', {$body.objectId})">{$body.object}</a>
               {/if}
            </div>
         </div>
      </div>

      <div class="row">
         <div class="form-group form-group-flex">
            <div class="col-md-2 control-label">
               <label>
                  {'author'|translate}
               </label>
            </div>
            <div class="col-md-8">
               {if $body.data.user}
                  <a href="javascript:nw('users', {$body.data.user.id})">{$body.data.user.name} {$body.data.user.surname} ({$body.data.user.email})</a>
               {/if}
            </div>
         </div>
      </div>

      <div class="row bottom-space">
         <div class="form-group form-group-flex">
            <div class="col-md-2 control-label">
               <label>{'comment'|translate}</label>
            </div>
            <div class="col-md-8">
               <textarea name="data[content]" id="comment" class="form-control">{$body.data.content}</textarea>
               {if $body.history}
                  {$last = reset($body.history)}
                  <span class="help-block">Naposledy upravil administrátor {$last.admin}, {$last.date_updated}</span>
               {/if}
            </div>
         </div>
      </div>

      <div class="row bottom-space">
         <div class="form-group form-group-flex">
            <div class="col-md-2 control-label">
               <label>{'reply'|translate}</label>
            </div>
            <div class="col-md-8">
               <textarea name="data[reply]" rows="8" cols="30"></textarea>
               {insert_wysiwyg target="data[reply]" type="ProductDescription"}
            </div>
         </div>
      </div>

      <div class="form-group">
         <div class="col-md-2 control-label">
            <label>{'status'|translate}</label>
         </div>
         <div class="col-md-10">
            <div class="radio pull-left">
               <input type="radio" name="data[status]" value="1" {if $body.data.status == 1}checked{/if} id="dS1" class="check"/>
               <label for="dS1">{'confirmed'|translate}</label>

               <input type="radio" name="data[status]" value="0" {if $body.data.status == 0}checked{/if} id="dS0" class="check"/>
               <label for="dS0">{'unconfirmed'|translate}</label>

               <input type="radio" name="data[status]" value="2" {if $body.data.status == 2}checked{/if} id="dS2" class="check"/>
               <label for="dS2">{'top'|translate}</label>
            </div>
         </div>
      </div>

      <div class="form-group">
         <div class="col-md-2 control-label">
            <label>{'solved'|translate}</label>
         </div>
         <div class="col-md-10">
            <div class="radio pull-left">
               <input type="radio" name="data[solved]" value="0" {if $body.data.solved == 0}checked{/if} id="dT0" class="check"/>
               <label for="dT0">{'no'|translate}</label>

               <input type="radio" name="data[solved]" value="1" {if $body.data.solved == 1}checked{/if} id="dT1" class="check"/>
               <label for="dT1">{'yes'|translate}</label>
            </div>
         </div>
      </div>

      <div class="form-group">
         <label class="col-md-2 control-label">{'answers'|translate}</label>
         <div class="col-md-10">
            <ul>
               {foreach $body.children as $comment}
                  <li><a href="javascript:nw('Comments', {$comment.id})">{$comment.content|strip_tags}</a></li>
               {/foreach}
            </ul>
         </div>
      </div>


      <input type="hidden" name="data[id_language]" value="{$body.data.id_language}">
      <input type="hidden" name="data[type]" value="{$body.type}">
      <input type="hidden" name="data[objectId]" value="{$body.objectId}">

   </div>

   <script>
      jQuery(function (){
         let $comment = $("#comment");
         $comment.height($comment[0].scrollHeight );
      });
   </script>

{/block}
