<?php  use Cake\ORM\TableRegistry;
    $products = TableRegistry::get('Mheaders');  
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
      <?= $this->element('admin_sidebar') ?>
</nav>
<div class="companies index large-9 medium-8 columns content">
<div class="col-md-6">
    <h3><?= __('Field Mapping') ?></h3></div>
	<div class="col-md-6">
	<div class="search-wrapper">
        <div class="search-filter"><?= $this->Search->filterForm($searchFilters) ?></div>         
    </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 scope="col"><?= $this->Paginator->sort('Excel Header') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Master Header') ?></th>
                <th scope="col" class="actions"><?= __('Field Mapped') ?></th>
            </tr>
        </thead>
        <tbody>
            <?php $srlno = ($this->request->params['paging']['Cheaders']['page']-1) * $this->request->params['paging']['Cheaders']['perPage'];
            $j = 1;
            
            foreach ($csvtables as $csvtable): $srlno++; ?>
			
            <tr>
                <td><?=$srlno ?></td>
                <td><?= h($csvtable->cname) ?></td>
				<td>
		<?php
			if($csvtable->mapid > 0){
				
				$productids = explode(",",  $csvtable["mapid"]);
				foreach($productids as $productid){
				$productdata = $products->find()->where(['id' => $productid]);
				$data2 = $productdata->toArray();
				
				echo $productname = $data2[0]->mname;
				}
			}
		?>
	     </td>
                <td class="actions">
					<?= $this->Html->link(__('Mapping'), ['controller'=>'fds','action' => 'fdmapping', $csvtable->id],['class' => 'edit','title'=>__('Mapping')]) ?>
                </td>
            </tr>
            <?php 
            $j++;
            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->first(__('First', true), array('class' => 'disabled')); ?>
            <?= $this->Paginator->prev('< ' . __('previous',true), array('class' => 'disabled')) ?>
            <?= $this->Paginator->numbers() ?>
            <?= $this->Paginator->next(__('next' . ' >',true), array('class' => 'disabled')) ?>
		 <?=  $this->Paginator->last(__('Last', true), array('class' => 'disabled')); ?>
        </ul>
        <p><?= $this->Paginator->counter() ?></p>
    </div>
</div>

