<?php

Doo::loadController('base', true);

# 后台界面框架

class frame extends base{
    
    public function index(){        
        $this->renderc_admin('admin/frame', $this->data);
    }
    
    public function top(){
        $channels = service::channels(true);
        sort($channels);
        $this->data['channels'] = $channels;
        $this->data['selected'] = PROJECT_ID;
        $this->renderc_admin('admin/frame_top', $this->data);
    }
    
    public function left(){
        $this->renderc('admin/left', $this->data);
    }
    
    public function main(){
        $diff = time() - 86400;
        $option = array(
            'where' => 'dateline >= ?',
            'param' => array($diff)
        );
        Doo::loadModel('ShopUsers');
        $SU = new ShopUsers();
        $this->data['todayAddUsers'] = $SU->count($option);
        $this->data['totalUsers'] = $SU->count();
        $this->data['todayIndex'] = round($this->data['todayAddUsers']/$this->data['totalUsers'], 2)*100;
        Doo::loadModel('ShopQrcode');
        $SQ = new ShopQrcode();
        $this->data['qrcodeTotal'] = $SQ->count();
        $diff = time() - 604800;
        $option = array(
            'where' => 'dateline >= ? and type1 = ?',
            'param' => array($diff, 1)
        );
        $this->data['qrcodeQun'] = $SQ->count($option);
        $SQ->type1 = 0;
        $this->data['qrcodePerson'] = $SQ->count();
        Doo::loadModel('ShopOrders');
        $SO = new ShopOrders();
        $diff = time() - 86400;
        $option = array(
            'where' => 'dateline >= ? and status = 1',
            'param' => array($diff)
        );
        $this->data['todayOrders'] = $SO->count($option);
        $option = array('where' => 'status = 1');
        $this->data['totalOrders'] = $SO->count($option);
        $this->renderc('admin/main', $this->data);
    }
    
}