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

if(!function_exists('getItem')) 
    require_once(MUDDER_ROOT.'./'.$_modules['shop']['directory'].'/include/fun_item.php');
if(!function_exists('reviewToArray')) 
    require_once(MUDDER_ROOT.'./'.$_modules['shop']['directory'].'/include/fun_review.php');

if(!check_submit('mysubmit')) {
    $query = $db->query("SELECT sid,shopname,subname FROM {$dbpre}shops WHERE ownerid='$user->uid'");
    $ids = '';
    $items = array();
    while($row = $db->fetch_array($query)) {
        $ids[] .= "'".$row['sid']."'";
        $items[$row['sid']] = $row['shopname'].$row['subname'];
    }
    if($ids) {
        $ids = implode(',',$ids);
        $total = $db->get_value("SELECT COUNT(*) FROM {$dbpre}reviews WHERE shopid IN ($ids)");
        if($total > 0) {
            $offset = 10;
            $limit = get_limit($page, $offset);
            $multipage = multi($total, $offset, $page, "index.php?ac=$ac");
            $query = $db->query("SELECT * FROM {$dbpre}reviews WHERE shopid IN ($ids) ORDER BY posttime DESC LIMIT $limit");
            $reviews = array();
            while($row = $db->fetch_array($query)) {
                $row['fullname'] = $items[$row['shopid']];
                $reviews[] = reviewToArray($row);
            }
        }
    }
} else {
    if(!is_array($reviewids) || count($reviewids) == 0 ) {
        redirect("未选择删除项，请返回选择。");
    }
    deleteReview($reviewids,'rid', -1);
    redirect('您选择的点评项已被删除。', 'index.php?ac=itemreviews');
}
?>