<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\widgets\GridView;
$this->title = $model->fullname;
$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">
    <div class="row">
        <?php if(!Yii::$app->request->isAjax ) { ?>
            <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::A('Update', ['update', 'id' => $model->id], ['class' => 'btn-success nav-link mt-1 mb-1' ]); ?>
                    </li>
                    
                    <li class="nav-item">
                        <?= HTML::button('Add Note', ['class' => 'btn btn-primary nav-link w-100 notesModal']); ?>
                    </li>
                </ul>
            </div>
            <div class="col-12 col-lg-10 col-xl-11">
        <?php } else { ?>
            <div class="col-12 col-lg-12 col-xl-12">
        <?php } ?>
            <?= yii\bootstrap4\Tabs::widget([
                'navType' => 'nav nav-tabs nav-justified',
                'items' => [
                    ['label' => 'Details', 'content' => $this->render('NGclientdetails', ['model' => $model]), '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>
</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>