<?php // $cs = Yii::app()->getClientScript(); ?>
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'Portal-form',
'enableAjaxValidation' => false,
'enableClientValidation' => false,
));
?>
<div class="tab-content">
<div class="tab-pane active">
<ul class="clearfix form-ul material">
    <li class="col-sm-6">
        <?php echo $form->textField($model, 'portal_name',array('data-label'=>'Portal <span style="color:red">*</span>')); ?>
        <?php echo $form->hiddenField($model, 'id');?>
     </li>
    <li class="col-sm-2">
          <?php echo $form->textField($model, 'sort_order',array('data-label'=>'Sort Order')); ?>
     </li>
     <li class="col-sm-3">
                <div>
                    <b>Upload </b>
                    <?php

                    $allowedExtensions = array("zip", "png", "txt", "jpg", "jpeg", "gif");
                    $this->widget('ext.EAjaxUpload.EAjaxUpload', array(
                        'id' => rand(),
                        'config' => array(
                            'action' => Yii::app()->createUrl(Yii::app()->controller->id . '/UploadPortalImage', array('folder' => 'uploads/portalimages',)),
                            // 'filename'=>$model->id
                            'multiple' => true,
                            'allowedExtensions' => $allowedExtensions,
                            'sizeLimit' => 30 * 1024 * 1024,
                            'onStart' => "js:function(){}",
                            'class' => 'pull-right',
                            'onComplete' => "js:function(id, fileName, responseJSON){
                       console.log(responseJSON.fileName);
                            $('#app_images').val(responseJSON.filename);
                            $('.app_images').html('<div class=\"each_image\"><input type=\"hidden\" value=\"'+responseJSON.filename+'\" name=\"MasPortal[thumbnail]\"><img width=\'100\' height=\'100\' src=\"" . Yii::app()->baseUrl . "/uploads/portalimages/'+responseJSON.filename+'\" />');                                                                    }",
                        )
                    ));
                    ?>
                    <input type="hidden" name="MasPortal[thumbnail]" value="<?php echo $model->thumbnail; ?>" id="app_images">
                    <br> <br>
                    <div class="app_images">
                        <?php if ($model->thumbnail != '') { ?>
                            <div class="each_images">
                                <input type="hidden" name="MasPortal[thumbnail]" value="<?php echo $model->thumbnail; ?>">
                                <img src="<?php echo Yii::app()->baseUrl; ?>/uploads/portalimages/<?php echo $model->thumbnail; ?>" width='100' height='100' />
                                <!-- <i class="fa fa-trash-o"></i></a> -->
                            </div>


                        <?php } ?>
                    </div>
                    <?php echo $form->error($model, 'thumbnail'); ?>
                </div>
            </li>
     <li class="col-sm-12">
          <?php echo $form->textField($model, 'return_url',array('data-label'=>'Return Url')); ?>
     </li>
</ul>
</div>

</div>
<div class="modal-footer">
<a href="index.php"></a>

<button type="button" class="btn btn-danger" id="Portal_close" data-dismiss="modal">Close</button>
<?php
    $url = Yii::app()->createUrl('Portal/Save');
    echo CHtml::ajaxSubmitButton('Save', $url, array(
                'dataType' => 'json',
                'type' => 'post',
                'success' => 'function(data) {
                    $("#loader").hide();
                        if(data.status=="success"){  
                                t8.success("Portal Code Saved Successfully!");
                                reloadTable("#tbl_Portal_details");
                                $("#Portal_close").click();
                                
                        } else { 
                            $("#Portal-form .Portal-save-btn").prop("disabled", false);
                            $("#Portal-form .Portal-save-btn").addClass("btn-theme").removeClass("btn_loding"); 
                            $.each(data, function(key, val) {
                                    $("#Portal-form #"+key+"_em_").text(val).show(); 
                                    t8.error(""+val+""); 
                                }); 
                        } 
                        }',
                'beforeSend' => 'function(){ 
                    $("#loader").show();
                    $("#Portal-form .Portal-save-btn").prop("disabled", true);
                    $("#Portal-form .Portal-save-btn").addClass("btn_loding").removeClass("btn-theme"); 
                    $(".toast8-error").hide();
                }'
                    
        ), array('id' => 'mybtn' . rand(), 'class' => 'Portal-save-btn btn btn-theme'));

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




