<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 高级评论投诉列表操作链接
 *
 * @author yzxh24
 */
Yii::import('zii.widgets.grid.CButtonColumn');
class BookPostComplaintsList extends CButtonColumn
{
    public $header;

    public $buttons = array(
        'delete' => array(
            'label' => '删除',
            'url' => 'Yii::app()->controller->createUrl("/admin/bookpostcomplaints/delete",array("id"=>$data->id))',
            'type' => 'raw',
        ),
        'punish' => array(
            'label' => '处罚',
            'url' => 'Yii::app()->controller->createUrl("/admin/bookpostcomplaints/punish",array("id"=>$data->id))',
            'type' => 'raw',
            'visible' => '$data->reply->ispunish == 0',
        ),
        'award' => array(
            'label' => '奖励',
            'url' => 'Yii::app()->controller->createUrl("/admin/bookpostcomplaints/award",array("id"=>$data->id))',
            'type' => 'raw',
            'visible' => '$data->isaward == 0',
        ),
    );

    protected function initDefaultButtons()
    {
        // nothing to do
        $confirmation="if(!confirm(".CJavaScript::encode(Yii::t('zii','确定要处罚?')).")) return false;";
        $this->buttons['punish']['click']=<<<EOD
function() {
	$confirmation
	$.fn.yiiGridView.update('{$this->grid->id}', {
		type:'POST',
		url:$(this).attr('href'),
		success:function() {
			$.fn.yiiGridView.update('{$this->grid->id}');
		}
	});
	return false;
}
EOD;

        $confirmation="if(!confirm(".CJavaScript::encode(Yii::t('zii','确定要奖励?')).")) return false;";
        $this->buttons['award']['click']=<<<EOD
function() {
	$confirmation
	$.fn.yiiGridView.update('{$this->grid->id}', {
		type:'POST',
		url:$(this).attr('href'),
		success:function() {
			$.fn.yiiGridView.update('{$this->grid->id}');
		}
	});
	return false;
}
EOD;

        $confirmation="if(!confirm(".CJavaScript::encode(Yii::t('zii','确定要删除?')).")) return false;";
        $this->buttons['delete']['click']=<<<EOD
function() {
	$confirmation
	$.fn.yiiGridView.update('{$this->grid->id}', {
		type:'POST',
		url:$(this).attr('href'),$csrf
		success:function() {
			$.fn.yiiGridView.update('{$this->grid->id}');
		}
	});
	return false;
}
EOD;
    }
}