<div class="popup_inner_element">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
    'id' => 'order-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
    ));
?>

<input type="hidden" name="hid_file_id" id="hid_file_id" value="<?php echo $file_id;?>">

   <ul class="nav nav-tabs company-nav-tabs nav-tab-theme">
        <li class="active"><a href="#tab1" data-toggle="tab">General</a></li>
        <li><a href="#tab2" data-toggle="tab">Details</a></li>
        <li><a href="#tab3" data-toggle="tab">Terms and Conditions</a></li>
       <!-- <li><a href="#tab3" data-toggle="tab">Non Stock Details</a></li>
        <li><a href="#tab4" data-toggle="tab" onclick="tableRefresh('#tbl_document_details')">Documents</a></li>
        <li  onclick="tableRefresh('#tbl_notes_details')"><a href="#tab5" data-toggle="tab" onclick="tableRefresh('#tbl_notes_details')">Notes</a></li>-->
    </ul>
   <div class="tab-content">
        <div class="tab-pane active" id="tab1">
                <?php if($type == 'sc'){ ?>
               <?php $this->renderPartial('general_sc', array('model' => $model, 'form' => $form,'file_id'=>$file_id,'enq_id'=>$enq_id,'vendor_id'=>$vendor_id)); ?>
                  <?php }else{ ?>
              <?php $this->renderPartial('general', array('model' => $model, 'form' => $form,'file_id'=>$file_id,'enq_id'=>$enq_id,'vendor_id'=>$vendor_id)); ?>
                 <?php } ?>
        </div>
        <div class="tab-pane" id="tab2">
            <?php if($type == 'sc'){ ?>
             <?php $this->renderPartial('stock_item_sc', array('model' => $model, 'form' => $form,'modelOrderStockItem'=>$modelOrderStockItem,'modelOrderAdditions'=>$modelOrderAdditions,'modelOrderDeductions'=>$modelOrderDeduction)); ?>
            <?php }else{ ?>
            <?php $this->renderPartial('stock_item', array('model' => $model, 'form' => $form,'modelOrderStockItem'=>$modelOrderStockItem,'modelOrderAdditions'=>$modelOrderAdditions,'modelOrderDeductions'=>$modelOrderDeduction)); ?>
            <?php } ?>
        </div>
        <div class="tab-pane" id="tab3">
            <?php $this->renderPartial('terms_and_conditions', array('model' => $model, 'form' => $form,'modelNotes'=>$modelNotes,'modelDocument'=>$modelDocument)); ?>
        </div>
        <!--div class="tab-pane" id="tab4">
            <?php //$this->renderPartial('documents', array('model' => $model, 'form' => $form,'modelNotes'=>$modelNotes,'modelDocument'=>$modelDocument)); ?>
        </div>
      <div class="tab-pane" id="tab5">
            <?php //$this->renderPartial('notes', array('model' => $model, 'form' => $form,'modelNotes'=>$modelNotes)); ?>
        </div-->
    </div> 
     <div class="modal-footer">
         <button type="button" class="btn btn-danger" id="order_close" data-dismiss="modal">Close</button>
        <?php 
            
            $url = Yii::app()->createUrl('purchasingorder/saveApproval');
            echo CHtml::ajaxSubmitButton('Approve', $url, array(
                            'dataType' => 'json',
                            'type' => 'post',
                            //'data'=>'js:$("#order-form").serialize()+"&terms_and_conditions="+encodeURIComponent(CKEDITOR.instances.PurchasingOrder_terms_and_conditions.getData())',
                            'success' => 'function(data) {
                                $("#loader").hide();
                                var id= data.id;
                                    if(data.status=="success"){  
                                        $("#order_close").click();
                                        t8.success("Order Approved!");
                                        reloadTable("#tbl_order_details");
                                    } else { 
                                        $("#order-form .order-save-btn").prop("disabled", false);                                
                                        $("#order-form .order-save-btn").addClass("btn-theme").removeClass("btn_loding");                                 
                                        $.each(data, function(key, val) {
                                            $("#order-form #"+key+"_em_").text(val).show(); 
                                            t8.error(""+val+""); 
                                        }); 
                                    } 
                            }',
                            'beforeSend' => 'function(){
                                $("#loader").show();
                                $("#order-form .order-save-btn").prop("disabled", true);                                
                                $("#order-form .order-save-btn").addClass("btn_loding").removeClass("btn-theme"); 
                                $(".toast8-error").hide(); 
                            }',
                            
                                
                    ), array('id' => 'mybtn' . rand(), 'class' => 'order-save-btn btn btn-theme'));
                

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