/**
 * Created by Tony on 2017/3/13.
 */

import express from "express";
let rptRouter = express.Router();
import reportController from "../controllers/rpt_controller_operation";

module.exports =function (app) {
    app.get('/report',  function(req, res) {
        if (!req.session.managerData.username) {
            res.redirect('/login');
        }
        else {
            res.render('maintain/report/html/rpt_test.html',
                {userAccount: req.session.userAccount,
                    userID: req.session.managerData.userID});
        }
    });

    //test
    rptRouter.post('/getTestReport', reportController.getTestReportAllPages);
    rptRouter.get('/getTestExcel/:id/:size/:rptName/:isOneSheet/:option', reportController.getTestExcel);
    rptRouter.get('/getTestExcelInOneBook/:ids/:size/:rptName/:option', reportController.getTestExcelInOneBook);
    rptRouter.get('/getTestPDF/:id/:size/:rptName', reportController.getTestPDF);
    //now is the real:
    rptRouter.post('/getReport', reportController.getReportAllPages);
    rptRouter.post('/getPreviewPage', reportController.getPreviewPage);
    // rptRouter.get('/getExcel/:id/:size/:rptName/:isOneSheet/:option', reportController.getExcel);
    // rptRouter.get('/getExcelInOneBook/:ids/:size/:rptName/:option', reportController.getExcelInOneBook);
    // rptRouter.get('/getPDF/:id/:size/:rptName', reportController.getPDF);

    app.use("/report_api", rptRouter);
};
