<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'distributer-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
));
?>
<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-4">
                <?php echo $form->textField($model, 'distributer_name', array('data-label' => 'Distributor Name <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->textField($model, 'sort_order', array('data-label' => 'Sort Order <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->textField($model, 'alias_name', array('data-label' => 'Alias <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->textField($model, 'alias_2_name', array('data-label' => 'Alias 2<span style="color:red">(For Global BW)*</span>', 'data-validation' => 'required')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->textField($model, 'alias_3_name', array('data-label' => 'Alias 3<span style="color:red">(For Sales Upload)*</span>', 'data-validation' => 'required')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->textField($model, 'alias_4_name', array('data-label' => 'Alias 4')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->textField($model, 'alias_5_name', array('data-label' => 'Alias 5')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->dropdownList($model, 'region_id',MasRegion::getRegions() ,array('data-label' => 'PriceType <span style="color:red">*</span>', 'data-validation' => 'required','empty' => 'Select')); ?>
            </li>
            <li class="col-sm-4">
                <?php echo $form->dropdownList($model, 'distributer_type',MasDistributerType::getActiveDistributerType() ,array('data-label' => 'Distributer Type <span style="color:red">*</span>', 'data-validation' => 'required','empty' => 'Select')); ?>
            </li>
            <li class="col-sm-4">
                <?php echo $form->dropdownList($model, 'area_id',MasArea::getAreas()  ,array('data-label' => 'Region <span style="color:red">*</span>', 'data-validation' => 'required','empty' => 'Select')); ?>
            </li>
            <li class="col-sm-4">
                <?php echo $form->dropdownList($model, 'consider_for_ch_report', array('Y' => 'Yes', 'N' => 'No'), array('data-label' => 'Consider For CH Report')); ?>
            </li>
            <li class="col-sm-4">
                <?php echo $form->dropdownList($model, 'isActive', array('Y' => 'Yes', 'N' => 'No'), array('data-label' => 'Is Active')); ?>
            </li>
        </ul>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" id="distributer_close" data-dismiss="modal">Close</button>
    <?php
    $url = Yii::app()->createUrl('distributer/Save');
    echo CHtml::ajaxSubmitButton('Save', $url, array(
        'dataType' => 'json',
        'type' => 'post',
        'success' => 'function(data) {
            $("#loader").hide();
                if(data.status=="success"){  
                    t8.success("Distributor Saved Successfully!");
                    $("#distributer_close").click();
                    reloadTable("#tbl_distributer_details");
                } else { 
                    $("#distributer-form .distributer-save-btn").prop("disabled", false);                      
                    $("#distributer-form .distributer-save-btn").addClass("btn-theme").removeClass("btn_loading"); 
                    $.each(data, function(key, val) {
                        t8.error(""+val+""); 
                    }); 
                } 
        }',
        'beforeSend' => 'function(){ 
            $("#loader").show();
            $(".toast8-error").hide();
            $("#distributer-form .distributer-save-btn").prop("disabled", true);                      
            $("#distributer-form .distributer-save-btn").addClass("btn_loading").removeClass("btn-theme"); 

        }'
    ), array('id' => 'mybtn' . rand(), 'class' => 'distributer-save-btn btn btn-theme'));
    ?>
</div>
<?php $this->endWidget(); ?>