<script>
    $('.write_forwardingset').click(function () {

        var readCheckBox = $(this).parent().parent().find('.read_forwardingset');
        var readHiddenId = this.id.replace('write_forwardingset_cb', 'read_forwardingset');

        var hiddenField = $('#' + readHiddenId);
        var isChecked = $(this).is(':checked');

        if ($(this).attr('data-isPreset') === 'true') {
            isChecked = !isChecked;
            $(this).removeAttr('data-isPreset');
        }
        if ($(this).attr('data-isSelf') === 'true') {
            isChecked = !isChecked;
            $(this).removeAttr('data-isSelf');
        }

        if (readCheckBox.attr('data-parent') !== 'true') {
            if (isChecked) {
                readCheckBox.attr("disabled", true);
            } else {
                readCheckBox.removeAttr("disabled");
            }
            readCheckBox.attr('checked', isChecked);
            hiddenField.val(isChecked ? 1 : 0);
        }
    });
</script>
<?php
$presetsModel = ForwardPreset::model()->search();

// Get rawData and create dataProvider
$rawData = ForwardPreset::model()->findAllByTypes(array(
    ForwardPresetType::PublicPreset,
    ForwardPresetType::SytemPreset
        ));
$dataProvider = new CArrayDataProvider($rawData, array('pagination' => false,));
$this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'forwardSet-permissions-grid-update',
    'enableHistory' => false,
    'type' => 'striped bordered condensed',
    'itemsCssClass' => 'plTable',
    'dataProvider' => $dataProvider,
    'summaryText' => false,
    'columns' => $model->getColumns('forwardingSets')
));
