<?php
$login_user_id    = Yii::app()->user->id;
$user_modal       = User::model()->find(array('condition'=>'t.id="'.$login_user_id.'"'));
$user_company     = $user_modal->company_id;
$modalMasCompany  = MasCompany::model()->find(array('condition'=>'t.id="'.$user_company.'"'));

?>
<ul class="clearfix form-ul material">
    <li class="col-sm-6"> 
    
    <?php
    if($model->vendor_currency_id == ''){
        $currency_id  = $modalMasCompany->currency_id;
    }
    else{
        $currency_id  = $model->vendor_currency_id;
    }
    $option=  array($currency_id=>array('selected'=>'selected'));
    ?>  
      <?php if(isset(Yii::app()->user->havePermissionOn['currency_add']) || Yii::app()->user->authorised_user == 1 ){ ?>
                      <div class="new-cst">
                            <div class="toggle-cst"><span class="cst-btn">+</span>
                            <div class="content-cst">
                                <div class="head" ripple="ripple" ripple-color="#FFF">
                                  <h5>Add Currency</h5>
                              </div>
                              <div class="body">
                                    <div class="row">
                                      <div class="col-sm-4">
                                        <?php echo CHtml::textField('currency_name','',array('data-label'=>'Currency <span style="color:red;">*</span>')); ?>
                                      </div>
                                       <div class="col-sm-4">
                                        <?php echo CHtml::textField('currency_code','',array('data-label'=>'Code <span style="color:red;">*</span>')); ?>
                                      </div>
                                      <div class="col-sm-4">
                                        <?php echo CHtml::textField('currency_rate','',array('data-label'=>'Rate <span style="color:red;">*</span>')); ?>
                                      </div>
                                    </div>
                                    <div class="btn-wrap text-center">
                                        <a href="#" class="plan-add-btn btn btn-theme go" onclick="AddMaster('vendor','currency')">SAVE</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                      </div>
                     <?php } ?>
          <div id="vendor_currency_div">
      
    <?php echo $form->dropDownList($model, 'vendor_currency_id', MasCurrency::getCurrency(), array('class' => 'tooltipster', 'title' => 'Currency', 'data-label' => 'Currency', 'options' => $option)); ?>     
          </div>
    </li>
<!--    <li class="col-sm-6">
        <?php // echo $form->dropDownList($model, 'vendor_currency_id', MasCurrency::getCurrency(), array('class' => '', 'prompt' => 'Select', 'title' => 'Select Currency','data-label'=>'Currency *','data-search'=>'true','data-validation'=>'required')); ?>
        <?php // echo $form->error($model, 'vendor_bank_name'); ?>
    </li>-->
     <li class="col-sm-6">
     <?php
     $modalPaymentTerm  = MasPaymentTerm::model()->find(array('condition'=>'t.isBasePaymentTerm="Y"'));
     if($model->vendor_payment_term == ''){
        $vendor_payment_term  = $modalPaymentTerm->id;
    }
    else{
        $vendor_payment_term  = $model->vendor_payment_term;
    }
    $payment_option=  array($vendor_payment_term=>array('selected'=>'selected'));
     ?>
     <?php if(isset(Yii::app()->user->havePermissionOn['paymentterm_add']) || Yii::app()->user->authorised_user == 1 ){ ?>
                      <div class="new-cst">
                            <div class="toggle-cst"><span class="cst-btn">+</span>
                            <div class="content-cst">
                                <div class="head" ripple="ripple" ripple-color="#FFF">
                                  <h5>Add Payment Term</h5>
                              </div>
                              <div class="body">
                                    <div class="row">
<!--                                      <div class="col-sm-4">
                                        <?php //echo CHtml::textField('paymentterm_code','',array('data-label'=>'Code <span style="color:red;">*</span>')); ?>
                                      </div>-->
                                       <div class="col-sm-6">
                                        <?php echo CHtml::textField('paymentterm_term','',array('data-label'=>'Term <span style="color:red;">*</span>')); ?>
                                      </div>
                                      <div class="col-sm-6">
                                        <?php echo CHtml::textField('paymentterm_days','',array('data-label'=>'Days <span style="color:red;">*</span>')); ?>
                                      </div>
                                    </div>
                                    <div class="btn-wrap text-center">
                                        <a href="#" class="plan-add-btn btn btn-theme go" onclick="AddMaster('vendor','paymentterm')">SAVE</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                      </div>
                     <?php } ?>
          <div id="vendor_paymentterm_div">
        <?php echo $form->dropDownList($model, 'vendor_payment_term', MasPaymentTerm::getPaymentTerms(), array('class' => '', 'title' => 'Select Payment Terms','data-label'=>'Payment Terms ', 'options' => $payment_option)); ?>
          </div>
    </li>
    
</ul>