<?php use Cake\Routing\Router; ?>

<!-- Breadcrumb -->
<ol class="breadcrumb">
    <li class="breadcrumb-item">Dashboard</li>
    <li class="breadcrumb-item"><a href="<?= Router::url('/admin01/plans/', true); ?>">Plans</a></li>
    <li class="breadcrumb-item">Edit</li>
    <!-- Breadcrumb Menu-->
    <li class="breadcrumb-menu d-md-down-none">
        <div class="btn-group" role="group" aria-label="Button group">

        </div>
    </li>
</ol>

<div class="container-fluid">

    <div id="ui-view" class="row">

        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <i class="fa fa-align-justify"></i> Edit Plan
                </div>
                <div class="card-body">

                    <ul class="nav nav-tabs">
                        <li class="nav-item">
                            <a class="nav-link" href="<?= Router::url('/admin01/plans/edit/'.$plan->id, true); ?>">Plan Information</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="<?= Router::url('/admin01/plans/addons/'.$plan->id, true); ?>">Plan Addons</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link active" href="<?= Router::url('/admin01/plans/features/'.$plan->id, true); ?>">Plan Features</a>
                        </li>
                    </ul>
                    <div class="tab-content" id="myTab1Content">
                        <div class="tab-pane fade active show" id="home" role="tabpanel" aria-labelledby="home-tab">
                            <form method="post" action="<?= $this->Url->build('/admin01/plan-features/add/') ?>">
                            <?= $this->Form->control('feature_id',['class'=>'form-control select2','required','options'=>$features]); ?>
                            <?= $this->Form->control('value',['class'=>'form-control','required']); ?>
                            <?= $this->Form->control('is_hero',['type'=>'checkbox','style'=>'margin-top:20px;']); ?>    
                            <?= $this->Form->control('plan_id',['class'=>'form-control','value'=>$plan->id,'type'=>'hidden']); ?>    
                            <hr/>
                            <button type="submit" class="btn btn-primary">Submit</button>
                            <?= $this->Form->end() ?>
                            <hr/>
                            <table class="table table-hover" id="plans">
                                <thead>
                                    <tr>
                                        <th scope="col"><?= $this->Paginator->sort('id') ?></th>
                                        <th scope="col"><?= $this->Paginator->sort('name') ?></th>
                                        <th scope="col"><?= $this->Paginator->sort('value') ?></th>
                                        <th scope="col"><?= $this->Paginator->sort('is_hero') ?></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 foreach ($plan->plan_features as $plan_feature): ?>
                                    <tr>
                                        <td><?= h($plan_feature->id) ?></td>
                                        <td><?= ($plan_feature->has('feature'))? $plan_feature->feature->name : '' ?></td>
                                        <td><?= h($plan_feature->value) ?></td>
                                        <td><?= h($plan_feature->is_hero) ?></td>
                                        <td><?= h($plan_feature->created) ?></td>
                                        <td><?= h($plan_feature->modified) ?></td>
                                        <td class="actions">
                                            <?= $this->Form->postLink(__('Delete'), ['controller'=>'PlanFeatures','action' => 'delete', $plan_feature->id], ['confirm' => __('Are you sure you want to delete # {0}?', $plan_feature->id), 'class'=>'btn btn-danger btn-xs']) ?>
                                        </td>
                                    </tr>
                                    <?php endforeach; ?>
                                </tbody>
                            </table>
                        </div>

                    </div>


                </div>
            </div>
        </div>
    </div>
</div>
