<?php  use Cake\ORM\TableRegistry;
	$companies = TableRegistry::get('Companies'); 
	$schemename = TableRegistry::get('Mffunds');
	$branches = TableRegistry::get('Branches');
	$users = TableRegistry::get('Users');
?>
<?= $this->Html->script('schemeload.js'); ?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
      <?= $this->element('admin_sidebar') ?>
</nav>
<div class="mutualfunds index large-9 medium-8 columns content">
<h3><?= __('Pending Mutual Fund Switch Records') ?></h3>
	<div class="search-wrapper">
	    <div class="search-filter" style="width:100%"><?= $this->Search->filterForm($searchFilters) ?></div>
	</div>
    <table class="tbl-wrapper" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <th style="width:40px;" scope="col"><?= $this->Paginator->sort('Sr No') ?></th>                
                <th style="width:180px;"scope="col"><?= $this->Paginator->sort('Applicant Name') ?></th>
				<th style="width:140px;" scope="col"><?= $this->Paginator->sort('Mutual Fund') ?></th>
				<th style="width:180px;" scope="col"><?= $this->Paginator->sort('Switch Out Scheme') ?></th>
				<th style="width:180px;" scope="col"><?= $this->Paginator->sort('Switch In Scheme') ?></th> 
                <th scope="col"><?= $this->Paginator->sort('Amount') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Despatch Date') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Branch') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Company') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Entry Date') ?></th>
                <th scope="col" class="actions"><?= __('Actions') ?></th>
            </tr>
        </thead>
        <tbody>
            <?php
             $srlno = ($this->request->params['paging']['Mutualfunds']['page']-1) * $this->request->params['paging']['Mutualfunds']['perPage'];
            foreach ($mutualfunds as $mutualfund): $srlno++;
            ?>
            <tr>
                <td style="width:40px;"><?= $srlno; ?></td>               
                <td><?php if($mutualfund->minor == 1) {
                             echo  $mutualfund->minorname.'&nbsp;&nbsp;U/G&nbsp;&nbsp;'.$mutualfund->firstapplicantname;
                          }else{
                              echo  $mutualfund->firstapplicantname;
                          } ?></td>
				 <td>
        		<?php
        		if($mutualfund->productcompanyid > 0){
        		$companiesdata = $companies->find()->where(['id' => $mutualfund->productcompanyid]);
        		$data2 = $companiesdata->toArray();
        		if($data2){
        		echo $companiesname = $data2[0]->company;
        		}
        		} 
        		?>
        		</td>
        
        		<td>
        		<?php		
        		if($mutualfund->mffund_id > 0){
        		$scheme= $schemename->find()->where(['id' => $mutualfund->mffund_id]);
        		$data = $scheme->toArray();
        		if($data) {
        		echo $mfscheme = $data[0]->fundname;
        		}
        		}
        		?>
        		</td>
        		<td>
        		<?php		
        		if($mutualfund->newmfid > 0){
        		$scheme= $schemename->find()->where(['id' => $mutualfund->newmfid]);
        		$data = $scheme->toArray();
        		if($data) {
        		echo $mfscheme = $data[0]->fundname;
        		}
        		}
        		?>
        		</td>
                <td><?php echo (($mutualfund->swichall == 1)? 'All' : $mutualfund->amount) ?></td>
                <td><?= h($mutualfund->despatchdate) ?></td>
                <td><?= h($mutualfund->branch->branchname) ?></td>
                <td><?= h($mutualfund->company->company); ?></td>
                <td><?php $created = explode(" ", $mutualfund->created);
                 echo $created[0]; 
                ?></td>
                <td class="actions">
  <?= $this->Html->link(__('View'), ['action' => 'view', $mutualfund->id],['class' => 'view','title'=>__('View')]) ?>
<?php  if($this->request->session()->read('Auth.User.group_id')=='3'){ ?>  
                   
                    <?= $this->Html->link(__('Edit'), ['action' => 'edit', $mutualfund->id],['class' => 'edit','title'=>__('Edit')]) ?>
                    <!--<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $mutualfund->id], ['class' => 'delete','title'=>__('Delete'),'confirm' => __('Are you sure you want to delete # {0}?', $mutualfund->id)]) ?>-->
 <?php } ?>

 <?php  if($this->request->session()->read('Auth.User.group_id')=='2'){ ?>  

                    <?= $this->Html->link(__('Edit'), ['action' => 'edit', $mutualfund->id],['class' => 'edit','title'=>__('Edit')]) ?>
                    <!--<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $mutualfund->id], ['class' => 'delete','title'=>__('Delete'),'confirm' => __('Are you sure you want to delete # {0}?', $mutualfund->id)]) ?>-->
 <?php } ?>
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    <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>
