<?php
$cs = Yii::app()->getClientScript();
$cs->registerScript("downloadMasterExcel", "function downloadMasterExcel(){
    var credit_hold_id = $('#CH_credit_hold_id').val();
    var distributer_id = $('#CH_distributer_id').val();
    var region_id = $('#CH_region_id').val();
    var product_cat_id = $('#CH_product_cat_id').val();
    var statusArray = $('#CH_status').val(); // Gets an array of selected values
    var status = statusArray ? statusArray.join(',') : ''; // Join selected values into a comma-separated string
    window.open($('#liveSite').val()+'index.php?r=Credithold/DownloadCreditHoldMaster&credit_hold_id='+credit_hold_id+'&distributer_id='+distributer_id+'&region_id='+region_id+'&product_cat_id='+product_cat_id+'&status=' + status, '_blank');   
}", CClientScript::POS_HEAD);
?>
<div class="tab-content">
    <div class="tab-pane active">
        <ul class="clearfix form-ul material">
            <?php echo CHtml::hiddenField('CH_credit_hold_id', $credit_hold_id); ?>
            <li class="col-sm-4">
                <?php echo CHtml::dropDownList('CH_distributer_id','', Distributers::getDistributers(), array('data-label' => 'Distributor', 'empty'=>'-Select-','data-search'=>'true')); ?>
            </li>
            <li class="col-sm-4">
            <?php echo CHtml::dropDownList('CH_product_cat_id','', MasProductCategory::getProductCategory(), array('data-label' => 'Product category', 'empty' => '-Select-')); ?>
            </li>
            <li class="col-sm-4">
                <?php echo CHtml::dropDownList('CH_region_id','', MasRegion::getRegions(), array('data-label' => 'Region','empty'=>'-Select-')); ?>
            </li>
            <li class="col-sm-4">
                <?php echo CHtml::listBox('CH_status', '', [0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4'], [
                    'data-label' => 'Status',
                    'multiple' => 'multiple',// Enable multiselect
                    'class' => 'multiple', // Add Select2 class
                    'data-placeholder' => '-Select-', // Placeholder
                    'data-search' => true, // Placeholder
                    //'size' => 5, // Number of visible options in the box
                ]); ?>
            </li>
        </ul>
    </div>
</div>
<div class= "modal-footer">
<button type="button"  class="btn btn-sm btn-theme" onclick="downloadMasterExcel();"><i class="fa fa-download"></i>Excel</button>
</div>