Ejemplo n.º 1
0
    public function report($exam_id)
    {
        $sql1 = <<<EOT
SELECT count(1) as 'count' 
from rd_student rs,rd_exam_place_student reps , rd_exam_place rep 
where rep.exam_pid='{$exam_id}' and rep.place_id=reps.place_id and rs.uid=reps.uid
EOT;
        $sql2 = <<<EOT
SELECT rs.exam_ticket,CONCAT(rs.last_name,rs.first_name) as xname 
from rd_student rs,rd_exam_place_student reps , rd_exam_place rep 
where rep.exam_pid='{$exam_id}' and rep.place_id=reps.place_id and rs.uid=reps.uid
EOT;
        $result1 = Fn::db()->fetchRow($sql1);
        // 读取数据
        if ($result1['count'] > 0) {
            $sql3 = "SELECT exam_name FROM rd_exam WHERE exam_id={$exam_id}";
            $row = Fn::db()->fetchRow($sql3);
            $title = $row['exam_name'] . '.xls';
            $data = array();
            $data['list'] = $this->db->query($sql2)->result_array();
            $header = array('准考证号', '姓名');
            $excel_model = new ExcelModel();
            $excel_model->addHeader($header);
            $excel_model->addBody($data['list']);
            $excel_model->download($title);
        } else {
            echo '暂无学生,请先添加学生';
        }
    }
Ejemplo n.º 2
0
 public function testGet()
 {
     $_ = $this;
     $ExcelModel = new ExcelModel();
     $dirPath = 'etc/template/test/etc/excel';
     $fileName = 'Apple.xlsx';
     $result = $ExcelModel->get("{$dirPath}/{$fileName}");
     var_dump($result);
     $this->assertTrue(is_array($result));
     $this->assertNotEquals(0, count($result));
 }
Ejemplo n.º 3
0
 public function createCode()
 {
     $before = '<!DOCTYPE html><html>';
     $after = '<html>';
     $code = trim($before . $_POST['code'] . $after);
     $rs = ExcelModel::model()->filterEcho($code);
     echo $rs;
 }
Ejemplo n.º 4
0
    public function detail_report()
    {
        if (!$this->check_power('statistics_manage')) {
            return;
        }
        $where = array();
        if (isset($_GET['p_id']) && !empty($_GET['p_id'])) {
            $where[] = 'tr_pid = ' . intval($_GET['p_id']);
        }
        if (isset($_GET['begin_time']) && !empty($_GET['begin_time'])) {
            $title = $_GET['begin_time'];
            $where[] = 'tr_createtime >= ' . strtotime($_GET['begin_time'] . '00:00:00');
        }
        if (isset($_GET['end_time']) && !empty($_GET['end_time'])) {
            $title .= '~' . $_GET['end_time'];
            $where[] = 'tr_createtime <= ' . strtotime($_GET['end_time'] . '23:59:59');
        }
        if (empty($where)) {
            $sql_where = '';
        } else {
            $sql_where = ' AND ' . implode(' AND ', $where);
        }
        $sql = <<<EOT
SELECT p_name, pc_name, tr_uid, exam_ticket, CONCAT(last_name, first_name) AS fullname, email, 
p_price, p_price_pushcourse, tr_trade_amount, tr_createtime 
FROM v_transaction_record a
LEFT JOIN rd_student b ON a.tr_uid = b.uid
WHERE tr_type = 3 AND tr_pid IS NOT NULL {$sql_where}
ORDER BY tr_id DESC
EOT;
        $db = Fn::db();
        $list = $db->fetchAll($sql);
        $data['list'] = $list;
        if (!empty($title)) {
            $title .= '产品交易明细数据';
        } else {
            $title .= '全部产品交易明细数据';
        }
        $excel_model = new ExcelModel();
        $data['header'] = $excel_model->getExcelHeader($title, 6, count($list) + 1);
        $data['footer'] = $excel_model->getExcelFooter();
        Func::dumpExcel($title . '.xls');
        $this->load->view('account/detail_report_excel', $data);
    }