<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id 3 2008-08-25 18:35 $
*/
!defined('IN_MUDDER') && exit('Access Denied');

if(!check_submit('mysubmit')) {

    $from = "{$dbpre}responds a LEFT JOIN {$dbpre}reviews b ON(a.reviewid=b.rid) LEFT JOIN {$dbpre}members c ON(b.uid=c.uid) LEFT JOIN {$dbpre}shops d ON(b.shopid=d.sid)";
    $where = "a.uid='{$user->uid}'";
    $row = $db->get_one("SELECT COUNT(*) as count FROM $from WHERE $where");
    $total = &$row['count'];
    if($total > 0) {
        $query = $db->query("SELECT a.rid as respondid, a.status,d.sid,d.shopname,d.subname,b.rid as reviewid,b.respond,c.uid,c.username,FROM_UNIXTIME(a.posttime,'%Y-%m-%d %H:%i:%s')as posttime FROM $from WHERE $where ORDER BY a.posttime DESC");
        while($respond = $db->fetch_array($query)) {
            $respond['shopname'] .= ($respond['subname'] ? "({$respond['subname']})" : "");
            $respond['statusname'] = $respond['status'] == 1 ? '正常' : ($respond['status'] == 2 ? '未审核' : '隐藏');
            $responds[] = $respond;
        }
        $multipage = multi($total, $offset, $page, "index.php?ac=$ac");
    }

} else {

    if($respondids && is_array($respondids)) {
        require_once MUDDER_ROOT.'./include/addnew.func.php';
        foreach($respondids as $id) {
            delete_respond($id, true);
        }
        redirect('删除完毕！',"index.php?ac=$ac");
    } else {
        redirect('未选择，请返回修改，至少选择一项。');
    }

}
?>