<div id='basicDIV' class='hide'>
  <div class='panel-heading with-nav-tabs'>
    <ul class='nav nav-tabs'>
      <li class='active'><a data-toggle='tab' href='#basicTab'><?php echo $lang->customer->basicInfo;?></a></li>
      <li><a data-toggle='tab' href='#issueTab'><?php echo $lang->customer->feedback;?></a></li>
    </ul>
  </div>
  <div class='tab-content'>
    <div id='basicTab' class='panel-body tab-pane active'>
    </div>
    <div id='issueTab' class='tab-pane panel-body no-padding-top'>
      <table class='table table-data table-form'>
        <thead>
          <tr>
            <th><?php echo $lang->feedback->product;?></th>
            <th><?php echo $lang->feedback->title;?></th>
          </tr>
        </thead>
        <?php foreach($issues as $issue):?>
        <tr>
          <td><?php echo zget($products, $issue->product);?></td>
          <td title='<?php echo $issue->title;?>'><?php if(!commonModel::printLink('feedback', 'view', "issueID={$issue->id}", $issue->title)) echo $issue->title;?></td>
        </tr>
        <?php endforeach;?>
      </table>
    </div>
  </div>
</div>

<?php
js::set('customerID', $customer->id);

$invoiceHtml    = '';
$hasInvoice     = commonModel::hasPriv('customer', 'invoice');
$hasInvoiceInfo = commonModel::hasPriv('customer', 'invoiceInfo');

if($hasInvoice)     $invoiceHtml .= html::a($this->createLink('customer', 'invoice', "customerID={$customer->id}"), $lang->customer->invoiceList, "class='invoice-list btn'");
if($hasInvoiceInfo) $invoiceHtml .= html::a($this->createLink('customer', 'invoiceInfo', "customerID={$customer->id}"), $lang->customer->invoiceInfo, "data-toggle='modal' data-width='80%' class='btn'");
if($invoiceHtml)    $invoiceHtml  = "<div class='divider'></div>" . $invoiceHtml;
?>
<script>
$('#basicDIV #basicTab').html($('.side-col div.panel:first .panel-body').html());
$('.side-col div.panel:first').html($('#basicDIV').html());

<?php if($invoiceHtml):?>
$('.main-actions .btn-toolbar a[href*=contract][href*=create]').after(<?php echo helper::jsonEncode($invoiceHtml);?>);
<?php endif;?>
<?php if($hasInvoiceInfo):?>
$.get(createLink('invoice', 'ajaxGetInvoiceCount', "customerID=" + v.customerID), function(invoiceCount)
{
    if(invoiceCount == 0)
    {
        $('.invoice-list').attr('href', createLink('crm.invoice', 'create', "customerID=" + v.customerID));
    }
    else
    {
        $('.invoice-list').modalTrigger({width: '80%'});
    }
});
<?php endif;?>
</script>
