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

const express = require("express");
let rptRouter = express.Router();
const reportController = require("./../controllers/rpt_controller");

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

    //now is the real:
    rptRouter.post('/getReport', reportController.getReportAllPages);
    rptRouter.post('/getReportSvg', reportController.getReportAllPagesSvg);
    rptRouter.post('/getMultiReports', reportController.getMultiReports);
    rptRouter.post('/createExcelFiles', reportController.createExcelFiles);
    rptRouter.post('/createExcelFilesInOneBook', reportController.createExcelFilesInOneBook);
    rptRouter.post('/createPdfFiles', reportController.createPdfFiles);

    rptRouter.get('/getExcelInOneBook/:prj_id/:rpt_ids/:size/:rptName/:option', reportController.getExcelInOneBook);
    rptRouter.get('/getExcel/:prj_id/:rpt_id/:size/:orientation/:rptName/:isOneSheet/:option', reportController.getExcel);
    rptRouter.get('/getFileByUUID/:uuid/:rptName/:suffix', reportController.getFileByUUID);
    rptRouter.get('/getPDF/:prj_id/:rpt_id/:size/:orientation/:rptName', reportController.getPDF);

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