<?php
/**
 * Created by JetBrains PhpStorm.
 * User: yzxh24
 * Date: 11-11-7
 * Time: 下午4:19
 * To change this template use File | Settings | File Templates.
 */
class CancelAction extends BaseAction
{
    public function run()
    {
        $this->getController()->addBreadcrumb(array('完成请求列表'=>array('/admin/tasker/respone')));
        $id = Yii::app()->request->getQuery('id');
        $respone = TaskRespone::model()->findByPk($id);
        $task = Task::model()->findByPk($respone->task_id);

        if (isset($_POST['remark']))
        {
            $remark = Yii::app()->request->getPost('remark');
            $respone->delete();
            $tasker = Tasker::model()->find(array('condition'=>'id='.$respone->tasker_id));
            $tasker->delete();

            $subject = '[系统消息]任务未通过';
            Messages::model()->create($subject, $remark, $respone->uid);
            $this->getController()->redirect(array('respone'));
        }

        $defaultRemark = '您提交的任务《'.$task->subject.'》未达到指定的要求，不能获得奖励，你可以在[url=http://25800.net/system.php?s=member&c=task]任务中心[/url]重新接此任务，感谢您的参与！';
        $this->getController()->render('cancel', array(
                'respone' => $respone,
                'task' => $task,
                'defaultRemark' => $defaultRemark,
            )
        );
    }
}