<nav class="large-3 medium-4 columns" id="actions-sidebar">
      <?= $this->element('admin_sidebar') ?>
</nav>
<div class="customer-report index large-9 medium-8 columns content">
    <h3><?= __('Customers Reports') ?></h3>
    <div class="search-wrapper">  
    	<div class="btn-link">
        <?= $this->Html->link(__('Excel Export'), [
           'controller' => 'Reports', 'action' => 'customerdetailreports',
           '?' =>['customername'=> $customername,
            'panno' => $panno,   
            'datedform'=> $datedform,
            'datedto'=> $datedto,
            'customerid'=>$customerid]],['class'=>'green-btn']); ?></div> 
    	<fieldset class="fieldset2">
        <div class="search-filter"><?= $this->Search->filterForm($searchFilters) ?></div>       
          </fieldset>
        
    </div>

   <table class="tbl-wrapper" cellpadding="0" cellspacing="0">
        <thead>
            <tr><th colspan="7">CUSTOMERS</th></tr>
            <tr>
                <!--<th scope="col"><?= $this->Paginator->sort('id') ?></th>-->
                <th scope="col"><?= $this->Paginator->sort('accountno') ?></th>
                <th scope="col"><?= $this->Paginator->sort('firstname') ?></th>
                <th scope="col"><?= $this->Paginator->sort('lastname') ?></th>
               <!-- <th scope="col"><?= $this->Paginator->sort('dob') ?></th>-->
                <th scope="col"><?= $this->Paginator->sort('panno') ?></th>
               <!-- <th scope="col"><?= $this->Paginator->sort('email') ?></th>-->
                <th scope="col"><?= $this->Paginator->sort('gender') ?></th>
              <!--  <th scope="col"><?= $this->Paginator->sort('address') ?></th>-->
              <!--  <th scope="col"><?= $this->Paginator->sort('City') ?></th>-->
              <!--  <th scope="col"><?= $this->Paginator->sort('State') ?></th>-->
              <!--  <th scope="col"><?= $this->Paginator->sort('Country') ?></th>-->
              <!--  <th scope="col"><?= $this->Paginator->sort('Zipcode') ?></th>-->
              <!--  <th scope="col"><?= $this->Paginator->sort('phoneno') ?></th>-->
                <th scope="col"><?= $this->Paginator->sort('company_id') ?></th>
                <th scope="col"><?= $this->Paginator->sort('branch_id') ?></th>
              <!--  <th scope="col"><?= $this->Paginator->sort('created') ?></th>-->
             <!--   <th scope="col"><?= $this->Paginator->sort('modified') ?></th>-->
              
            </tr>
        </thead>
        <tbody>
            <?php foreach ($customers as $customer): ?>
            <tr>
              <!--  <td><?= $this->Number->format($customer->id) ?></td>-->
                <td><?= h($customer->accountno) ?></td>
                <td><?= h($customer->firstname) ?></td>
                <td><?= h($customer->lastname) ?></td>
              <!--  <td><?= h($customer->dob) ?></td>-->
                <td><?= h($customer->panno) ?></td>
             <!--   <td><?= h($customer->email) ?></td>-->
                <td><?= h($customer->gender) ?></td>
              <!--  <td><?= h($customer->address) ?></td>-->
              <!--  <td><?= h($customer->City) ?></td>-->
              <!--  <td><?= h($customer->State) ?></td>-->
               <!-- <td><?= h($customer->Country) ?></td>-->
              <!--  <td><?= h($customer->Zipcode) ?></td>-->
              <!--  <td><?= $this->Number->format($customer->phoneno) ?></td>-->
                
                <td><?= $customer->has('company') ? $this->Html->link($customer->company->company, ['controller' => 'Companies', 'action' => 'view', $customer->company->id]) : '' ?></td>
                <td><?= $customer->has('branch') ? $this->Html->link($customer->branch->branchname, ['controller' => 'Branches', 'action' => 'view', $customer->branch->id]) : '' ?></td>
              <!--  <td><?= h($customer->created) ?></td>-->
               <!-- <td><?= h($customer->modified) ?></td>-->
               
            </tr>  
            <?php if(!empty($customer->fds)){ ?>
            <!-- FDS -->            
            <tr>
                 <table class="tbl-wrapper" cellpadding="0" cellspacing="0">                    
                    <thead>
                        <tr><th colspan="7">FDS</th></tr>
                        <tr>
                            <th scope="col"><?= $this->Paginator->sort('Application No') ?></th> 
                            <th scope="col"><?= $this->Paginator->sort('Payment Option') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Maturity Date') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Maturity Amount') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Renewal Amount') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Refended Balance') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Total Investment') ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($customer->fds as $fd): ?>
                        <tr>
                            <td><?= h($fd->applicationno) ?></td>
                            <td><?= h($fd->paymentoption) ?></td>
                            <td><?= h($fd->maturitydate) ?></td>
                            <td><?= $this->Number->format($fd->maturityamount) ?></td>
                            <td><?= $this->Number->format($fd->renewalamount) ?></td>
                            <td><?= $this->Number->format($fd->refendedbalance) ?></td>
                            <td><?= $this->Number->format($fd->totalinvestment) ?></td>
                        </tr>  
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </tr>
            <?php } if(!empty($customer->ncds)){ ?>
            <!-- NCDS -->            
            <tr>
                 <table class="tbl-wrapper" cellpadding="0" cellspacing="0">                    
                    <thead>
                        <tr><th colspan="5">NCDS</th></tr>
                        <tr>
                            <th scope="col"><?= $this->Paginator->sort('Application No') ?></th> 
                            <th scope="col"><?= $this->Paginator->sort('Account No') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('IFSC Code') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('MIRC Code') ?></th> 
                            <th scope="col"><?= $this->Paginator->sort('Amount') ?></th>
                           
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($customer->ncds as $ncd): ?>
                        <tr>
                            <td><?= h($ncd->applicationno) ?></td> 
                            <td><?= h($ncd->accountno) ?></td>
                            <td><?= h($ncd->ifsccode) ?></td>
                            <td><?= h($ncd->micrcode) ?></td> 
                            <td><?= $this->Number->format($ncd->amount) ?></td>
                        </tr>  
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </tr>
           <?php } if(!empty($customer->mutualfunds)){ ?>
             <!-- Mutual Fund -->            
            <tr>
                 <table class="tbl-wrapper" cellpadding="0" cellspacing="0">                    
                    <thead>
                        <tr><th colspan="6">MUTUAL FUNDS</th></tr>
                        <tr>
                            <th scope="col"><?= $this->Paginator->sort('Application No') ?></th> 
                            <th scope="col"><?= $this->Paginator->sort('Advisor ARN / RIA code') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Sub-broker/Branch Code') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Sub-broker ARN') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Representative EUIN') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Customer Folio No') ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($customer->mutualfunds as $mutualfund): ?>
                        <tr>
                            <td><?= h($mutualfund->applicationno) ?></td>
                            <td><?= h($mutualfund->advisorARNcode) ?></td>
                            <td><?= h($mutualfund->subbrokerbranchcode) ?></td>
                            <td><?= h($mutualfund->subbrokerARN) ?></td>
                            <td><?= h($mutualfund->representativeEUIN) ?></td>                
                            <td><?= h($mutualfund->customerFolioNo) ?></td>
                        </tr>  
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </tr>
          <?php } if(!empty($customer->ipos)){ ?>  
             <!-- ipo -->            
            <tr>
                 <table class="tbl-wrapper" cellpadding="0" cellspacing="0">                    
                    <thead>
                        <tr><th colspan="5">IPOS</th></tr>
                        <tr>
                            <th scope="col"><?= $this->Paginator->sort('Application No') ?></th> 
                            <th scope="col"><?= $this->Paginator->sort('Payment Option') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Amount') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Bank Name') ?></th>
                            <th scope="col"><?= $this->Paginator->sort('Bank Branch') ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($customer->ipos as $ipo): ?>
                        <tr>
                            <td><?= h($ipo->applicationno) ?></td>
                            <td><?= h($ipo->paymentoption) ?></td>
                            <td><?= $this->Number->format($ipo->amount) ?></td>  
                            <td><?= $ipo->has('bank') ? $this->Html->link($ipo->bank->banks, ['controller' => 'Banks', 'action' => 'view', $ipo->bank->id]) : '' ?></td>
                            <td><?= $ipo->has('bankbranch') ? $this->Html->link($ipo->bankbranch->branchaddress, ['controller' => 'Bankbranchs', 'action' => 'view', $ipo->bankbranch->id]) : '' ?></td>

                        </tr>  
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </tr>            
            <?php } ?>  
            <?php endforeach; ?>
        </tbody>
    </table>
    
    
    
    
    
    
    
    
    
    <div class="btn-link"><input type="button" value="Back" onclick="window.history.back()" class="green-btn" /> </div>
    <div class="paginator">
        <ul class="pagination">
            <?= $this->Paginator->prev('< ' . __('previous')) ?>
            <?= $this->Paginator->numbers() ?>
            <?= $this->Paginator->next(__('next') . ' >') ?>
        </ul>
        <p><?= $this->Paginator->counter() ?></p>
    </div>
</div>
