<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'currency-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
    ));
?>
<style>
.bott_dec span{
display: block;
line-height: 20px;
font-weight: normal;
font-size: 12px !important;
color: #4d4c4c;
padding-left: 20px;
letter-spacing: 0.25px;
}
</style>
    <div class="tab-content">
        <div class="tab-pane active">
                   <ul class="clearfix form-ul material">
    			       <li class="col-sm-2">
                             <?php
                    $allowedExtensions = array("csv");
                    $this->widget('ext.EAjaxUpload.EAjaxUpload', array(
                        'id' => 'currencycsv_0_upload_csv',
                        'config' => array(
                            'action' => Yii::app()->createUrl('/'.Yii::app()->controller->id . '/UploadEmployeecsv', array('folder' => 'uploads/currency_csv')),
                            'multiple' => false,
                            'allowedExtensions' => $allowedExtensions,
                            'sizeLimit' => 1 * 1024 * 1024,
                            'onStart' => "js:function(){}",
                            'class' => 'pull-right',
                            'onComplete' => "js:function(id, fileName, responseJSON){
                                        $('#Currencycsv_0').val(responseJSON.filename);
                                        CurrencyUpload(responseJSON.filename);
                                    }",
                    )));
                    ?>
                        </li>
						 <li class="col-sm-2">
						 <div  id="csv_msg">
						 </div>
						 </li>
						<li class="col-sm-8 bott_dec">
	<span style="color:red;">* All fields in the excel are Mandatory *</span>
	<span style="color:red;">* Currency Name should be unique *</span>
        <span style="color:red;">* Upload files in .csv format *</span>
                        </li>
						 <li class="col-sm-4">
               <?= CHtml::link('Download Template',array('currency/DownloadSampleCsv'), array('target'=>'_blank', 'style'=>'color: #007bff; text-decoration: underline;')); ?>
            </li>
    		            </ul>
        </div>
		 <button type="button" class="btn btn-danger" style="display:none;" id="upload_close" data-dismiss="modal">Close</button>
    </div>
<?php
$this->endWidget();
$cs = Yii::app()->getClientScript();

$cs->registerScript("CurrencyUpload", "function CurrencyUpload(filename)
{

if(filename != ''){
  jQuery.ajax({
    'type': 'post',
    'dataType': 'json',
    'data': {
            filename: filename
            },
    'url'  : '" . Yii::app()->createUrl("currency/SaveCurrencyUploadCsv") . "',
    'cache': false,
    'success': function (data) {
      if (data.status == 'success') {
        $('#loader').hide();
         if(data.error!=''){
           $('#csv_msg').html(data.link);
           
               $.each(data.error, function(key, val) {
                           t8.error(''+val+''); 
                   }); 
        }else{
            
        t8.success('Details Uploaded Successfully');    
        $('#upload_close').click();  
        reloadTable('#tbl_currency_details'); 
        }
      }
    },
    'beforeSend':function(){
            $('#loader').show();
    },
    'complete':function(){
        $('#loader').hide();
    }
  });
}else{
    t8.error('File not found');
    
}
}", CClientScript::POS_HEAD);
?>










