<section class="pcoded-main-container">
<div class="pcoded-content">
    <div class="page-header">
        <div class="page-block">
            <div class="row align-items-center">
                <div class="col-md-12">
                    <div class="page-header-title">
                         <h5 class="m-b-10">Bids Request
                         <?php if(@$userright_arr[0]['add_r']):?>
                            <?php echo $this->Html->link('<i class="feather icon-plus-square" ></i> Add Bid Request',array('controller'=>'Bids','action'=>'add'), array('class' => 'btn btn-primary pull-right','escape'=>false),array());?>
                         <?php endif;?>

                        </h5>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xl-12 col-md-12">
            <div class="card">
                <div class="card-body table-border-style">
                    <div class="table-responsive dataTables_wrapper dt-bootstrap4" scroll="no" style="overflow: hidden">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="pull-right">
                                  <?= $this->Form->create('bid') ?>
                                    <div id="colum-rendr_filter" class="dataTables_filter">
                                        <label><input type="search" placeholder='Search by project and freelancer' name="search"  class="form-control"  aria-controls="bids"></label>
                                         <?= $this->Form->button('<i class="fas fa-search"></i> Submit',['type' => 'submit','class'=>'btn btn-success'],['escape' =>false]) ?>
                                      </div>
                                 
                                     <?= $this->Form->end() ?>
                                     </div>

                                <table class="table">
                                    <thead>
                                        <tr>
                                            <th scope="col">#</th>
                                            <th scope="col"><?= $this->Paginator->sort('project_id') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('freelancer_id') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('allotment_status',['lable' =>'A status']) ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('created') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('modified') ?></th>
                                            <th scope="col" class="actions"><?= __('Actions') ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php if(!empty($bids)){ $i = 1; foreach ($bids as $bid):  ?>
                                        <tr>
                                            <td><?= $i++ ?></td>
                                            <td><?= $bid->has('project') ? $this->Html->link($bid->project->topic, ['controller' => 'Projects', 'action' => 'view', $bid->project->id]) : '' 
                                            ?></td>
                                            <td><?= $bid->has('freelancer') ? $this->Html->link($bid->freelancer->name, ['controller' => 'Freelancers', 'action' => 'view', $bid->freelancer->id]) : '' ?></td>
                                            <td class="actions"><?php
                                                if($bid->allotment_status ==1){
                                                    echo "<span class=' btn btn-danger' title='Allotted'>A</span>";
                                                }else{
                                                    echo "<span class='btn btn-success' title='Not allotted'>N</span>";
                                                }
                                             ?></td>
                                            <td><?= date('d-M-y H:i A',strtotime($bid->created)) ?></td>
                                            <td><?= date('d-M-y H:i A',strtotime($bid->modified)) ?></td>
                                            <td class="actions">
                                                <?php if(@$userright_arr[0]->details_r):?>
                                                <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"fas fa-eye btn btn-success")), array('action' => 'view', $bid->id),array('escape'=>false)) ?>
                                                <?php endif; ?>
                                                <?php if(@$userright_arr[0]->edit):?>
                                                <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"feather icon-edit btn btn-primary")), array('action' => 'edit', $bid->id),array('escape'=>false)) ?>
                                                <?php endif; ?>
                                                <?php if(@$userright_arr[0]['edit']):?>
                                                <?= (@$userright_arr[0]->delete_r) ? $this->Form->postLink($this->Html->tag('i', '', array('class' => "feather icon-trash-2 btn btn-danger")),
                                                    array('action' => 'delete', $bid->id),
                                                    array('escape'=>false,'confirm' => __('Are you sure you want to delete # {0}?', $bid->id))):'' ?>
                                                    <?php endif; ?>
                                            </td>
                                        </tr>
                                        <?php endforeach; }else{ ?>
                                            <tr><td colspan="10">No Records Found</td></tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <?php if($filter==0){ ?>
                        <div class="row">
                            <div class="col-sm-12 col-md-5">
                            <div class="dataTables_info" id="user-list-table_info" role="status" aria-live="polite"><?= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?></div>
                            </div>
                            <div class="col-sm-12 col-md-7">
                                <div class="dataTables_paginate paging_simple_numbers" id="user-list-table_paginate">
                                    <ul class="pagination">
                                       <?php 
                                        echo $this->Paginator->prev( '<<', array( 'class' => '', 'tag' => 'li' ), null, array( 'class' => 'dsisabled myclass', 'tag' => 'li' ) );
                                        echo $this->Paginator->numbers( array( 'tag' => 'li', 'separator' => '', 'currentClass' => 'disabled myclass' ) );
                                        echo $this->Paginator->next( '>>', array( 'class' => '', 'tag' => 'li' ), null, array( 'class' => 'disabled myclass', 'tag' => 'li' ) );
                                        ?>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                    </div>
                </div> 
            </div>
         </div> 
    </div>     
</div>
</section>