<?php
/**
 * 订单列表ACTION
 * @author billow.wang<admin@ivears.com>
 * @date 2013-04-16
 */
class OrdersAction extends AdminAction{
    
    /**
     * 控制器初始化
     * @author billow.wang <admin@ivears.com>
     * @date 2013-04-01
     */
    public function _initialize() {
        parent::_initialize();
    }
    
    public function index(){
        import('ORG.Net.IpLocation');// 导入IpLocation类
        $Ip = new IpLocation(); // 实例化类
        $name = $this->getActionName();
        $message = D($name);
        $ary_get['pageall'] = $this->_get('pageall', 'htmlspecialchars', 10);
        $count = $message->where()->count();
        $obj_page = $this->_Page($count, $ary_get['pageall']);
        $page = $obj_page->newshow();
        $ary_data = $message->where()->limit($obj_page->firstRow, $obj_page->listRows)->order('id desc')->select();
        if(!empty($ary_data) && is_array($ary_data)){
            foreach ($ary_data as $k=>$v){
                $ary_data[$k]['ip_location'] = $Ip->getlocation($v['log_ip']);
            }
        }
        $this->assign("data", $ary_data);
        $this->assign("page", $page);
        $this->assign("filter",$ary_get);
        $this->display();
    }
    
    /**
     * 更新订单状态
     * @author billow.wang<admin@ivears.com>
     * @date 2013-04-16
     */
    public function doEditAudit(){
        
    }
    
    /**
     * 删除订单
     * @author billow.wang<admin@ivears.com>
     * @date 2013-04-16
     */
    public function doDelete(){
        $mod = D($this->_name);
        $pk = $mod->getPk();
        $ids = $this->_request('ids');
        if ($ids) {
			if(is_array($ids)){
				$idstr=implode(',',$ids);
			}else{
				$idstr=$ids;	
			}			
            if (false !== $mod->delete($idstr)) {
                $this->success("删除成功",'/Admin/'.$this->_name.'/');
            } else {
                $this->error("删除失败",'/Admin/'.$this->_name.'/');
            }
        } else {
            $this->error("请选择删除的对象",'/Admin/'.$this->_name.'/');
        }
    }
}