<?php
    use yii\helpers\Html;
    /* @var $this yii\web\View */
?>

<?php 
    if(yii::$app->session->hasFlash('message')) {
        echo yii::$app->session->getFlash('message');
    } 
?>
<div class="site-about">
    <h1>Locations</h1>
</div>

<div class="site-index">
    <p>
        <span><?= Html::a('Create', ['/site/create'], ['class' => 'btn btn-small btn-primary']); ?></span>
    </p>
    <div class="body-content">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Company Name</th>
                    <th>Website</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                    if(count($locations) > 0 ) {
                        foreach ($locations as $key => $value) {
                ?>
                            <tr>
                                <td><?php echo $key; ?></td>
                                <td><?php echo $value->company_name; ?></td>
                                <td><a href="<?php echo $value->website; ?>" target="_blank"><?php echo $value->website; ?></a></td>
                                <td>
                                    <span><?= Html::a('View', ['view', 'id' => $value->id], ['class' => 'label label-primary']); ?></span>
                                    <span><?= Html::a('Update', ['view', 'id' => $value->id], ['class' => 'label label-default']); ?></span>
                                    <span><?= Html::a('Delete', ['view', 'id' => $value->id], ['class' => 'label label-danger']); ?></span>
                                </td>
                            </tr>
                <?php 
                        }
                    } else { 
                ?>
                        <tr>
                            <td>No record found.</td>
                        </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
</div>
