<?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();
if($model->vendor_currency_id == ''){
    $currency_id  = $modalMasCompany->currency_id;
}
else{
    $currency_id  = $model->vendor_currency_id;
}
?>
<ul class="clearfix form-ul material">

 <?php  if ((int) Yii::app()->user->haveLevelPermissionOn['master_level_permission_currency'] > 0 || Yii::app()->user->authorised_user == 1) {?>
    <li class="col-sm-6"> 
    
    <?php
    
    $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>
<?php }else {
       $model->vendor_currency_id = MasCurrency::base_currency_id(); 
       echo  $form->hiddenField($model, 'vendor_currency_id');
   }
   ?>
   <!-- <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
      //echo $form->hiddenField($model, 'vendor_currency_id',array('value'=>$currency_id));
     $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 
        if($model->vendor_payment_term==''){
            $model->vendor_payment_term=MasPaymentTerm::getDefaultID();//1;
        }
        echo $form->dropDownList($model, 'vendor_payment_term', MasPaymentTerm::getPaymentTerms(), array('class' => '', 'title' => 'Select Payment Terms','data-label'=>'Payment Terms ', 'options' => $payment_option)); ?>
          </div>
    </li>
    
    <!--<li class="col-sm-6">
         <?php 
         
        // echo $form->textField($model, 'score', array('class'=>'','title' => 'Score','data-label'=>'Score ')); ?> 

    </li>-->
     <li class="col-sm-6">
         <?php
          $status=false;
        if($model->approve == 1){
            $status=true;
        }
     echo CHtml::checkBox('approve',$status,array('data-label' => 'Approved By Finance'));
     ?>
    </li>

    <li class="col-sm-6">      
                          <?php echo $form->dropDownList($model,'isActive',array('Y'=>'Active','N'=>'Dormant'),array('data-label'=>'Status'));?>
                          <?php echo $form->hiddenField($model, 'type',array('value'=>'1')); ?><!--                    ,'Hold'=>'Hold',-->           
                      </li>
                      
                       <li class="col-sm-3">
        <?php
        $modelAccLedger = new AccLedger();
        ?>
        <?php echo $form->dropdownlist($model, 'ledger_id', $modelAccLedger->getPayableChilds(), array('data-label' => ' Ledger', 'data-search' => 'true', 'prompt' => 'Choose')); ?>
    </li>
</ul>