<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\ActiveForm;

use common\modules\support\models\redmine\RedmineHelper;

?>

<div class="client_interface">

    <div class="container">
        
        <div class="right_box_top row">
            <div class="col-md-6 col-xs-6 col-sm-12">
                <h2><strong>Список задач</strong></h2>
            </div>
            <div class="col-md-6 col-xs-6 col-sm-12">
                <div class="logo_taskon">
                    <span>Разработанно в:  </span>
                    <a href=""><img src="/images/logo_taskon.png" height="44" width="135" alt=""></a>
                </div>
            </div>
        </div>
        
        <div class="right_box_top row">

            <div class="col-md-3 col-xs-3 col-sm-12 dropdown-menu-my">
        
                <?=Html::a('<span class="glyphicon glyphicon-plus"></span> Добавить задачу', ['/support/create'], ['class' => 'btn btn-success-2  dropdown-menu-my-button'])?>
        
            </div>
        
            <div class="col-md-9 col-xs-9 col-sm-12">
                
                <?php $form = ActiveForm::begin([
                    'method' => 'GET',
                    'action' => '/support',
                    'options' => [
                        'class' => 'search-form'
                    ]
                ]); ?>
                    <div class="input-group">
                        <?=Html::textInput('s', Yii::$app->request->get('s'), ['class' => 'form-control']); ?>

                        <span class="input-group-btn">
                            <?= Html::submitButton('<span class="glyphicon glyphicon-search"></span>', ['class' => 'btn btn-default-2 btn-size-2']) ?>
                        </span>
                    </div>
                <?php ActiveForm::end(); ?>
                
            </div>
        
        </div>
        
        <br>
     

        <div class="table-responsive table-responsive-conf">
            
            <table class="table">
                <tr>
                    <td class="no_pad">

                        <div class="panel-group panel-group-2" id="accordion_2">

                            <?php 
                            if($issues = RedmineHelper::sortIsuues($models['issues']))
                            {
                                foreach ($issues as $issue) 
                                {
                                    if(!isset($issue['close']))
                                    {
                                        echo $this->render('_loop', ['output' => $issue, 'title' => $issue['title']]);
                                    }
                                    else
                                    {
                                        $accepteds = $issue['models'];
                                    }
                                }
                            }
                            ?>

                        </div>
                        
                    </td>
                </tr>
            </table>
        </div>

        <br>
       
        <?php if($accepteds) : ?>
            <div class="separator_close">Закрытые задачи</div>

            <?php foreach ($accepteds as $model) : ?>

                <div class="panel-body panel-body-ex-1 panel-body-ex-2">
                    <div>
                        <div class="text-mes">
                            <p><?=Html::a($model['subject'], ['/support/view/'.$model['id']])?></p>
                        </div>
                    </div>
                </div>

            <?php endforeach; ?>
        <?php endif; ?>
      
        <br>
        <br>

    </div>
</div>

<?=$this->render('@app/views/layouts/footer');?>