<?php // $cs = Yii::app()->getClientScript(); ?>

<?php

$form = $this->beginWidget('CActiveForm', array(

    'id' => 'currency-form',

    'enableAjaxValidation' => false,

    'enableClientValidation' => false,

  //   'action'=>Yii::app()->createUrl('/Currency/SaveCurrency'),

    ));

?>

    <div class="tab-content">

        <div class="tab-pane active">

            

                   <ul class="clearfix form-ul material">

    			<?php echo $form->hiddenField($model, 'id');?>

    			<li class="col-sm-3">
                                
                               <?php echo $form->textField($model, 'currency',array('data-label'=>'Currency *','data-validation'=>'required')); ?>

                                 <?php echo $form->error($model,'currency'); ?>

                        </li>

    			<li class="col-sm-3">

                               <?php echo $form->textField($model, 'currency_code',array('data-label'=>'Currency Code *','data-validation'=>'required')); ?>

                               <?php echo $form->error($model,'currency_code'); ?>

                        </li>
                        <li class="col-sm-3">

                               <?php echo $form->textField($model, 'exchange_rate',array('data-label'=>'Exchange Rate *','data-validation'=>'required')); ?>

                               <?php echo $form->error($model,'exchange_rate'); ?>

                        </li>
                        
                        <li class="col-sm-3">

                        <?php echo $form->dropdownList($model, 'isBaseCurrency',array('N'=>'No','Y'=>'Yes'),array('data-label'=>'Want to make it as default?')); ?>

                        <?php echo $form->error($model,'	isBaseCurrency'); ?>
                        </li>
    			

    		</ul>

        </div>

      

    </div>

<div class="modal-footer">
    <button type="button" class="btn btn-danger" id="currency_close" data-dismiss="modal">Close</button>
    	<?php 
        
        $url = Yii::app()->createUrl('/Currency/SaveCurrency');
        echo CHtml::ajaxSubmitButton('Save', $url, array(

                            'dataType' => 'json',

                            'type' => 'post',

                            'success' => 'function(data) {

                                    $("#loader").hide();
                                    if(data.status=="success"){  

                                         t8.success("Currency Saved Successfully!");

                                         $("#currency_close").click();
                                        //location.reload();
                                        reloadTable("#tbl_currency_details");

                                    } else { 
                                        $("#currency-form .currency-save-btn").prop("disabled", false);
                                        $("#currency-form .currency-save-btn").addClass("btn-theme").removeClass("btn_loding");
                                        $.each(data, function(key, val) {

                                            $("#currency-form #"+key+"_em_").text(val).show(); 
                                            t8.error(""+val+""); 

                                        }); 

                                    } 

                                    }',

                            'beforeSend' => 'function(){

                                $("#loader").show();
                                $(".toast8-error").hide(); 
                                $("#currency-form .currency-save-btn").prop("disabled", true);
                                $("#currency-form .currency-save-btn").addClass("btn_loding").removeClass("btn-theme"); 
                            }'

                                

                    ), array('id' => 'mybtn' . rand(), 'class' => 'currency-save-btn btn btn-theme'));

           

    ?>

    </div>

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










