<div class="popup_inner_element">
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'inventory-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
        ));
?>
<ul class="nav nav-tabs company-nav-tabs nav-tab-theme">
    <li class="active"><a href="#inventory_tab1" data-toggle="tab">General</a></li>
    <li><a href="#inventory_tab2" data-toggle="tab">Details</a></li>
    <li><a href="#inventory_tab3" data-toggle="tab">History</a></li>
    <li><a href="#inventory_tab4" data-toggle="tab">Distributer Type</a></li>
</ul>
    <div class="tab-content">
        <div class="tab-pane active" id="inventory_tab1">
            <?php $this->renderPartial('inventory', array('model' => $model, 'form' => $form)); ?>                
        </div> 
    
        <div class="tab-pane" id="inventory_tab2">
            <?php $this->renderPartial('details', array('model' => $model,'modelDetails' => $modelDetails, 'form' => $form)); ?>                
        </div> 
        <div class="tab-pane" id="inventory_tab3">
            <?php $this->renderPartial('price_details', array( 'model' => $model,'form' => $form)); ?>
        </div>
        <div class="tab-pane" id="inventory_tab4">
            <?php $this->renderPartial('hiddenGmcs', array( 'model' => $model,'form' => $form)); ?>
        </div>
    </div>

 <div class="modal-footer">
    <button type="button" class="btn btn-default" id="inventory_close" data-dismiss="modal">Close</button>
    <?php
    $url = Yii::app()->createUrl('inventory/Save');
    if($type!='view'){
        
    
    echo CHtml::ajaxSubmitButton('Save', $url, array(
        'dataType' => 'json',
        'type' => 'post',
        'success' => 'function(data) {
            $("#loader").hide();
                if(data.status=="success"){  
                    t8.success("GMC Saved Successfully!");
                    $("#inventory_close").click();
                    reloadTable("#tbl_inventory_details");
                } else { 
                    $("#inventory-form .inventory-save-btn").prop("disabled", false);                      
                    $("#inventory-form .inventory-save-btn").addClass("btn-theme").removeClass("btn_loading"); 
                    $.each(data, function(key, val) {
                        t8.error(""+val+""); 
                    }); 
                } 
        }',
        'beforeSend' => 'function(){ 
            $("#loader").show();
            $(".toast8-error").hide();
            $("#inventory-form .inventory-save-btn").prop("disabled", true);                      
            $("#inventory-form .inventory-save-btn").addClass("btn_loading").removeClass("btn-theme"); 

        }'
    ), 
    array('id' => 'mybtn' . rand(), 'class' => 'inventory-save-btn btn btn-theme'));
    }
    ?>
</div>
<?php $this->endWidget(); ?>