<div class="popup_inner_element">

<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'user-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
));
?>

<ul class="nav nav-tabs company-nav-tabs nav-tab-theme">
    <li class="active">
        <a href="#users_tab1" data-toggle="tab">General</a>
    </li>
  
</ul>

<div class="tab-content">

    <!-- GENERAL TAB -->
    <div class="tab-pane active" id="users_tab1">
        <?php $this->renderPartial('general', array('model' => $model, 'form' => $form)); ?>
    </div>

    <!-- PORTAL TAB -->
   

</div>

<div class="modal-footer">

    <button type="button" class="btn btn-danger" id="user_close" data-dismiss="modal">
        Close
    </button>

    <?php
    $url = Yii::app()->createUrl('users/SaveUsers');

    echo CHtml::ajaxSubmitButton(
        'Save',
        $url,
        array(
            'type' => 'POST',
            'dataType' => 'json',

            'beforeSend' => 'function () {
                $("#loader").show();
                $(".errorMessage").hide().text("");
                return true;
            }',

            'success' => 'function (data) {

                $("#loader").hide();

                // SUCCESS
                if (data.status && data.status === "success") {

                    t8.success("User Saved Successfully!");
                    $("#user_close").click();
                    reloadTable("#tbl_user_details");

                } 
                // VALIDATION ERRORS
                else {
                    $.each(data, function(key, val) {
                                                $("#user-form #"+key+"_em_").text(val).show();
                                                t8.error(""+val+"");
                                        });

                    // $.each(data, function (key, messages) {
                    //     $("#" + key + "_em_")
                    //         .text(messages.join(", "))
                    //         .show();
                    // });
                }
            }',

            'error' => 'function () {
                $("#loader").hide();
                t8.error("Server error. Please try again.");
            }'
        ),
        array(
            'class' => 'user-save-btn btn btn-theme'
        )
    );
    ?>

</div>

<?php $this->endWidget(); ?>

</div>
