<?php  use Cake\ORM\TableRegistry;
	$companies = TableRegistry::get('Companies'); 
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
      <?= $this->element('admin_sidebar') ?>
</nav>
<div class="ipos index large-9 medium-8 columns content">
<div class="col-md-6">
    <h3><?= __('IPO Edit/Update') ?></h3>
</div>
<div class="col-md-6">
 <div class="btn-link margintop-fifteen"><?= $this->Html->link(__('Add IPO Entry'), ['controller' => 'Ipos','action' => 'add'],['class'=>'green-btn', 'title' => 'Add New IPO', 'type' => 'button']) ?></div>
</div>
    <div class="search-wrapper">  
	<div class="search-filter"><?= $this->Search->filterForm($searchFilters) ?></div>
   
    <table class="tbl-wrapper" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <tr>
               <th style="width:40px;" scope="col"><?= $this->Paginator->sort('S No') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Applicant Name') ?></th>
                <th scope="col"><?= $this->Paginator->sort('product') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Deposit type') ?></th>
                <th scope="col"><?= $this->Paginator->sort('MainBroker') ?></th>
                <th scope="col"><?= $this->Paginator->sort('amount') ?></th>  
                <th scope="col"><?= $this->Paginator->sort('period (months)') ?></th>
                <th scope="col"><?= $this->Paginator->sort('company') ?></th>
               <th scope="col" class="actions"><?= __('Actions') ?></th>
            </tr>
        </thead>
        <tbody>
            <?php 
            $srlno = ($this->request->params['paging']['Ipos']['page']-1) * $this->request->params['paging']['Ipos']['perPage'];
            foreach ($ipos as $ipo): $srlno++; ?>
            <tr>
                <td><?= $srlno; ?></td>
                <td><?php if($ipo->minor == 1) {
                             echo  $ipo->minorname.'&nbsp;&nbsp;U/G&nbsp;&nbsp;'.$ipo->biddername;
                          }else{
                              echo  $ipo->biddername;
                          } ?></td>
               <!--  <td><?= h($fd->panno) ?></td>-->
               <td>
		<?php
		//pr($fd->productcompanyid);//die();
		if($ipo->productcompanyid > 0){
		$companiesdata = $companies->find()->where(['id' => $ipo->productcompanyid]);
		$data2 = $companiesdata->toArray();
		if($data2){
		echo $companiesname = $data2[0]->company;
		}
		} 
		?>
		</td>
              
                <td><?= h($ipo->typeofdeposit) ?></td>
                
                <td><?= $ipo->has('broker') ? $this->Html->link($ipo->broker->name, ['controller' => 'Brokers', 'action' => 'view', $ipo->broker->broker_id]) : '' ?></td> 
                <td><?= h($ipo->amount) ?></td>
                <td><?= h($ipo->tenure) ?></td>
            <td><?= $ipo->has('company') ? $this->Html->link($ipo->company->company, ['controller' => 'Companies', 'action' => 'view', $ipo->productcompanyid]) : '' ?></td>
                
                
               <td class="actions">
                    <?= $this->Html->link(__('View'), ['action' => 'view', $ipo->id],['class' => 'view','title'=>__('View')]) ?>
<?php  if($this->request->session()->read('Auth.User.group_id')=='2'){ ?> 
                    <?= $this->Html->link(__('Edit'), ['action' => 'edit', $ipo->id],['class' => 'edit','title'=>__('Edit')]) ?>
                    <?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $ipo->id], ['class' => 'delete','title'=>__('Delete'),'confirm' => __('Are you sure you want to delete # {0}?', $ipo->id)]) ?>
<?php } ?>
<?php  if($this->request->session()->read('Auth.User.group_id')=='3'){ ?> 
                    <?= $this->Html->link(__('Edit'), ['action' => 'edit', $ipo->id],['class' => 'edit','title'=>__('Edit')]) ?>
                    <!--<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $ipo->id], ['class' => 'delete','title'=>__('Delete'),'confirm' => __('Are you sure you want to delete # {0}?', $ipo->id)]) ?>-->
<?php } ?>
                </td>
            </tr>
            <?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>
