<?php
$this->widget('ext.PlGrid.PlGridView', array(
        'id'=>'conference-grid',
        'headerTitle'=>'Header_title', // optional
        'addButtonTitle'=>'ADD_NEW_CONFERENCE', // optional
        'searchButtonTitle'=>'SEARCH_CONFERENCE', // optional
        'modalCreateHeader'=>'CONFERENCE_HEADER_CREATE', // optional
        'modalUpdateHeader'=>'CONFERENCE_HEADER_UPDATE', // optional
        'afterAjaxUpdate'=> 'function(){    
            setCreateButtonVisibility();
        }',
        'headerAttribute'=>'name', // attribute wich appends to the update header 
        
        'itemsCssClass'=>'plTable items',
        'modalSize' => 'large', // null, 'large', 'small', 'huge'
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'columns'=>array(
            array(
                'name'=>'name',
                'header' => $model->getAttributeLabel('name'),
                'headerHtmlOptions'=>array('data-translation-id'=>'CONFERENCE_MODEL_NAME'),
            ),
            array(
                'name'=>'extension',
                'header' => $model->getAttributeLabel('extension'),
                'headerHtmlOptions'=>array('data-translation-id'=>'CONFERENCE_MODEL_EXTENSION'),
                ),            
            array(
                'class'=>'ext.PlGrid.PlCButtonColumn',
                'template'=>'{ajaxUpdate}{delete}',
            )
        ),

    )
);

$routingConferenceMax = PhonalisaLicenseManager::routingConferenceMax();
?>
<script>
    function setCreateButtonVisibility() {
        if (
            $("#conference-grid tbody tr").length >= <?php  echo $routingConferenceMax; ?>  
            && !$("#conference-grid tbody tr td:first-child").hasClass("empty")
            && <?php  echo $routingConferenceMax; ?> >= 0
        ) {
            $("#conference-gridCreateBtn").hide();
        } else {
            $("#conference-gridCreateBtn").show();
        }
    }
    setCreateButtonVisibility();
</script>