<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>-->
        <?php /*if (!$model->isNewRecord) : ?>
        <!--<li><a href="#porder_approval_tab"  data-toggle="tab" onclick="approvalHistory(<?php echo $file_id; ?>);">Approval History</a></li>-->
        <?php endif;*/ ?>
    </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="porder_approval_tab">
                <div id="div_approval_history" style="display: none"></div>                        
            </div>-->
      
    </div> 
     <div class="modal-footer">
         <button type="button" class="btn btn-danger" id="order_close" data-dismiss="modal">Close</button>
        <?php 
           if($viewtype!='view'){
            if($type == 'sc'){
                $url = Yii::app()->createUrl('purchasingorder/shortclosure');
            }else{
                $url = Yii::app()->createUrl('purchasingorder/saveorder');
            }
            echo CHtml::ajaxSubmitButton('Save', $url, array(
                            'dataType' => 'json',
                            'data'=>'js:$("#order-form").serialize()',//+"&terms_and_conditions="+encodeURIComponent(CKEDITOR.instances.PurchasingOrder_terms_and_conditions.getData())
                            'type' => 'post',
                            'success' => 'function(data) {
                                $("#loader").hide();
                              
                                    if(data.status=="success"){  
                                        $(".x.close").click();
                                        t8.success("Saved!");
                                        var enquiry_id ='.$enq_id.';
                                        var temp_id = '.$temp_id.';
                                        if(enquiry_id > 0 || temp_id>0){
                                            reloadTable("#tbl_enquiry_details");
                                            location.href="index.php?r=purchasingorder/index";
                                        }
                                        else{
                                            reloadTable("#tbl_order_details");
                                            
                                        }
                                    } else { 
                                         $.each(data, function(key, val) {
                                              t8.error(""+val+""); 
                                        }); 
                                    } 
                            }',
                            'beforeSend' => 'function(){
                           
                                $("#loader").show();
                                $(".toast8-error").hide(); 
                                }',
                            
                                
                    ), array('id' => 'mybtn' . rand(), 'class' => 'order-save-btn btn btn-theme'));
                
          }
          
    ?>
        
    </div>
<?php $this->endWidget(); 
/*$cs = Yii::app()->getClientScript();
$cs->registerScript("approvalHistory", "function approvalHistory(file_id){
    jQuery.ajax({
      'data' :{'file_id':file_id},
      'type':'post',
      'url': '" . Yii::app()->createUrl('purchasingorder/getapprovalhistory') . "',
      'success': function(data) {
        $('#div_approval_history').show();   
        $('#div_approval_history').html(data);

  }
 });
}", CClientScript::POS_HEAD);*/
?>

</div>