<?php $cs = Yii::app()->getClientScript(); 
$cs->registerScript("ClickEvent", '
        $(document).on("keypress", ":not([type=submit])", function(event) { 
            return event.keyCode != 13;
            
           
      
        
    });', CClientScript::POS_HEAD);
?>
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'vendor-form-2',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
    ));
$baseUrl = Yii::app()->baseUrl;
 ?>
    <ul class="nav nav-tabs vendor-nav-tabs nav-tab-theme">
        <li class="active"><a href="#vendor_tab_1" data-toggle="tab">General</a></li>
        <li><a href="#vendor_tab_2" data-toggle="tab">Address</a></li>
        <li><a href="#vendor_tab_3" data-toggle="tab">Banking</a></li>
        <li><a href="#vendor_tab_4" data-toggle="tab">Finance</a></li>
        <li><a href="#vendor_tab_5" data-toggle="tab">Others</a></li>
        <?php if(empty($model->id)){?>
       <li><a href="#vendor_tab_6" data-toggle="tab">Contact</a></li>
        <?php }else{ ?>
       <li onclick="tableRefresh('#tbl_vendor_contact_details')"><a href="#vendor_tab_7"  data-toggle="tab">Contact List</a></li>
        <?php }?>
    <?php if(empty($model->id)){?>
       <li><a href="#vendor_tab_8" data-toggle="tab">Note</a></li>
        <?php }else{ ?>
    <li id="tab_list"><a href="#vendor_tab_9"  data-toggle="tab" >Note</a></li>
        <?php }?>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="vendor_tab_1">
            <?php $this->renderPartial('general_details', array('model' => $model, 'form' => $form)); ?>
        </div>
      <div class="tab-pane" id="vendor_tab_2">
            <?php $this->renderPartial('billing_details', array('model' => $model, 'form' => $form)); ?>
        </div>
         <div class="tab-pane" id="vendor_tab_3">
            <?php $this->renderPartial('banking_details', array('model' => $model, 'form' => $form)); ?>
        </div>
        <div class="tab-pane" id="vendor_tab_4">
            <?php $this->renderPartial('finance_details', array('model' => $model, 'form' => $form)); ?>
        </div>
        <div class="tab-pane" id="vendor_tab_5">
            <?php $this->renderPartial('others_details', array('model' => $model, 'form' => $form)); ?>
        </div>
         <?php if(empty($model->id)){?>
        <div class="tab-pane" id="vendor_tab_6">
            <?php $this->renderPartial('contact_form', array('models' => $models, 'form' => $form)); ?>
        </div>
         <?php }else {?>
        <div class="tab-pane" id="vendor_tab_7">
            <input type="hidden" name="hid_cust_id" id="hid_cust_id" value="<?php echo $model->id;?>">
          
            <?php $this->renderPartial('vendor_contact_list', array('model' => $model, 'form' => $form,'c_id'=>$model->id)); ?>  
        </div>
        <?php }?> 
        <?php if(empty($model->id)){?>
        <div class="tab-pane" id="vendor_tab_8">
            <?php $this->renderPartial('notes_details', array('modelnote' => $modelnote, 'form' => $form)); ?>
        </div>
         <?php }else {?>
        <div class="tab-pane" id="vendor_tab_9">
            <input type="hidden" name="hid_cust_id" id="hid_cust_id" value="<?php echo $model->id;?>">
           <?php $this->renderPartial('notes_details_list', array('modelnote' => $modelnote, 'form' => $form,'note_id'=>$model->id)); ?>  
        </div>
        <?php }?> 
    </div> 
<input type="hidden" name="vendor_form" value="<?php //echo $from;?>">
     
   
      
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
        <?php
                $url = Yii::app()->createUrl('vendor/saveEditedvendor');
                echo CHtml::ajaxSubmitButton('Save', $url, array(
                            'dataType' => 'json',
                            'type' => 'post',
                            'success' => 'function(data) {
                                var vendor_id= data.id;
                                    if(data.status=="success"){  
                                         t8.success("Saved Successfully!");
                                         location.reload();
                                    } else { 
                                         $.each(data, function(key, val) {
                                                $("#vendor-form-2 #"+key+"_em_").text(val).show(); 
                                                t8.error(""+val+""); 
                                            }); 
                                    } 
                                    }',
                            'beforeSend' => 'function(){
                               
                                $("#vendor-form-2.vendor-save-btn").prop("disabled", true);
                                
                                $("#vendor-form-2.vendor-save-btn").addClass("btn_loding").removeClass("btn btn-primary"); $(".errorMessage").hide(); }'
                                
                    ), array('id' => 'mybtn' . rand(), 'class' => 'vendor-save-btn btn btn-theme'));
           
    ?>
    </div>
    <?php $this->endWidget(); ?>
