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

import express from "express";
let rptRouter = express.Router();
import reportController from "./../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});
        }
    });

    //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('/getReportSvg', reportController.getReportAllPagesSvg);
    rptRouter.post('/getMultiReports', reportController.getMultiReportsEx);
    rptRouter.post('/createExcelFiles', reportController.createExcelFilesEx);
    rptRouter.post('/createExcelFilesInOneBook', reportController.createExcelFilesInOneBookEx);
    rptRouter.post('/createPdfFiles', reportController.createPdfFilesEx);
    rptRouter.post('/getBillsSummaryReport', reportController.getBillSummaryReportPages);
    rptRouter.post('/getGljSummaryReport', reportController.getGljSummaryReportPages);

    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);
};
