<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\widgets\GridView;
use yii\bootstrap4\Tabs;
$status = ['active' => 'Active', 'inactive' => 'Inactive'];
$preferences = ['phone' => 'Phone', 'textservice' => 'Text Service Reminders + Updates', 'emailmarketing' => 'Email Marketing', 'emailsafety' => 'E-Mail Safety Alerts + Recalls'];

?>
<div class="form">
    <?php $form =  ActiveForm::begin(); ?>
    	<div class="row">
            <div class="col-12 col-lg-2 col-xl-1 pr-0">
                <ul class="nav nav-pills nav-stacked">
                    <li class="nav-item">
                        <?= HTML::button('Cancel', ['class' => 'btn btn-danger nav-link w-100' ]); ?>
                    </li>
                    <li class="nav-item">
                        <?= HTML::button('Add Note', ['class' => 'btn btn-primary nav-link w-100 notesModal']); ?>
                    </li>
                    <li class="nav-item">
                        <?= HTML::Submitbutton('SAVE', ['class' => 'btn btn-submit nav-link mt-' ]); ?>
                    </li>
                </ul>
            </div>
            <div class="col-12 col-lg-10 col-xl-11">
                <?= Tabs::widget([
                    'navType' => 'nav nav-tabs nav-justified',
                    'items' => [
                       ['label' => 'Details', 'content' => $this->render('_details', ['model' => $model, 'form' => $form]), 'active' => true],
                       ['label' => 'Activities', 'content' => $this->render('NGactivities', ['model' => $model, 'actvitiesProvider' => $actvitiesProvider ]), 'active' => false],
                       ['label' => 'Addresses', 'content' => $this->render('_addresses', ['model' => $model]), 'active' => false],
                       ['label' => 'Service and Products', 'content' => $this->render('NGservicing', ['model' => $model, 'assetProvider' => $assetProvider]), 'active' => false],
                       ['label' => 'Contact Preferences', 'content' => $this->render('NGprefs', ['model' => $model]), 'active' => false],
                //     ['label' => 'Invoices and Orders', 'content' => $this->render('NGinvoices', ['model' => $model]), 'active' => false],
                        ]
                    ]);
                ?>
            </div>
        </div>
    <?php ActiveForm::end(); ?>
</div>

<script>
    $(document).on('click', '.notesModal', function(){
        $.ajax({
            url: '/NGauge/notes/ajaxcreate', 
            type: 'get',
            data: {
                relatedid: '<?= $model->id; ?>',
                relatedto: 'account',
            },
            success: function(result){
                $('#LGmodal .modal-header .title').html(result.modal_header);
                $('#LGmodal .modal-footer').html(result.modal_footer);
                $('#LGmodal .modal-body').html(result.modal_body);
                $('#LGmodal').modal();
            }
        })
    })
    $(document).on('click', '.notesuModal', function(){
        $.ajax({
            url: '/NGauge/notes/ajaxupdate', 
            type: 'get',
            data: {
                id: $(this).data('id'),                
            },
            success: function(result){
                $('#LGmodal .modal-header .title').html(result.modal_header);
                $('#LGmodal .modal-footer').html(result.modal_footer);
                $('#LGmodal .modal-body').html(result.modal_body);
                $('#LGmodal').modal();
            }
        })
    })
    </script>