const express = require("express");
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json({ limit: '100mb' }));
const mongoose = require("mongoose");
app.use(bodyParser.urlencoded({ limit: '500mb', extended: true, parameterLimit: 100000 }));
const { catchErrors } = require("../handlers/errorHandlers");
const authenticateUserByToken = require("../apps/middlewares/authenticateUserByToken");


const router = express.Router();
var cron = require('node-cron');       

const AuthController = require("../controllers/AuthController");
const WebCronController = require("../controllers/ShopperrDS/WebCronController");
const WmsController = require("../controllers/Wms/WmsController");
const ReturnController = require("../controllers/Wms/ReturnController");
const WmsCronController = require("../controllers/Wms/WmsCronController");
const BillingController = require("../controllers/BillingController");
const ManifestController = require("../controllers/Wms/ManifestController");
//_______________________________ Start Amz SP-API List Orders management_______________________________
// router.route("/marketplace/login").post(catchErrors(AuthController.Login));
 
//Admin Routes
// router.route("/adminProfile:admin_id").get(AdminController.AdminProfile);
router.route("/uploadInwardCsv").post(WmsController.UploadInwardCsv);
router.route("/uploadReturnCsv").post(WmsController.UploadReturnCsv);
router.route("/getUploadInwardCsv").get(WmsController.GetUploadInwardCsv);
router.route("/getUploadReturnCsv").get(WmsController.GetUploadReturnCsv);
router.route("/orderPickup").get(WmsController.OrderPickupList);
router.route("/inwards").get(WmsController.InwardList);
router.route("/orderMap/:opcode").get(WmsController.OrderMap);
router.route("/offshelfScan/:offshelfNumber").get(WmsController.OffshelfScan);
router.route("/get_qty").post(WmsController.GetQuantity);
router.route("/scan").post(WmsController.AwbScanUpdate);
router.route("/confirm_barcode").post(WmsController.ConfirmBarcode);
router.route("/unlinkpdf").post(WmsController.unlinkPdf);
router.route("/re_print").post(WmsController.rePrint);
router.route("/re_printindia").post(WmsController.rePrintIndia);
router.route("/orderOpCode/:combineCode").get(WmsController.OrderOpCodeList);  
// router.route("/uploadwmsorders").get(WmsCronController.UploadWmsOrders);
//router.route("/products/:code").get(WmsController.ProductChallan)  
//router.route("/save-challan").post(WmsController.SaveChallan) 
router.route("/Inoffshelf").get(WmsCronController.InOffshelf);
router.route("/indiaOffshelf").get(WmsController.IndiaOffshelfList);
router.route("/offshelfPrint/:offshelf").get(WmsController.offshelfPrintData);

router.route("/indiaOffshelfScan/:offshelfNumber").get(WmsController.IndiaOffshelfScan);
router.route("/indiaConfirmBarcode").post(WmsController.IndiaConfirmBarcode);
router.route("/indiaOffshelfDownload").get(WmsController.IndiaOffshelfDownload);
router.route("/billing").get(BillingController.exportExcelNewAction);
// router.route("/exportTest").get(BillingController.exportTest);
router.route("/codeTest").get(BillingController.codeTest);
router.route("/uploadRefundCsv").post(WmsController.UploadRefundCsv);
router.route("/getShelfLocation").post(WmsController.GetShelfLocation);
router.route("/products/:code").get(WmsController.ProductChallan)  
router.route("/save-challan").post(WmsController.SaveChallan)    
router.route("/AddVendor").post(WmsController.AddVendor)
router.get("/get_vendors", WmsController.getVendors);
router.route("/GateEntry").post(WmsController.AddGateEntry)
router.route("/addPurchaseOrder").post(WmsController.addPurchaseOrder)
router.route("/getManifest").post(ManifestController.getManifest);
router.route("/bagList").get(ManifestController.getBagList);
// router.route("/incomingUpdate").post(WmsController.incomingUpdate)
router.route("/dataManagementList").get(WmsController.DataManagementList);
router.route("/downloadBagList").post(ManifestController.DownloadBagList);
router.route("/unscannedOrders").post(WmsController.UnscannedOrders);
  
router.route('/get_GateEntrys').get(WmsController.getGateEntrys)
router.route('/binlocationUpdate').post(WmsController.BinLocationUpdate)
router.route('/getQtyShelflocation').post(WmsController.GetQtyShelflocation)
router.route("/getwinward").get(WmsController.WinwardList);
router.route("/uploadSafeTClaim").post(WmsController.UploadSafeTClaimCsv);
router.route("/safetclaim").get(WmsController.SafeTClaimList);
router.route("/notwinward").get(WmsController.NotWinwardList);
router.route('/freshIncomingStockUpdate').post(WmsController.IncomingStockUpdate)
router.route('/uploadProduct').post(WmsController.UploadProduct)
router.route("/unallocatedDownload").get(WmsController.UnallocatedDownload);
router.route("/updateGst").post(WmsController.UpdateGst);
router.route("/stockManagementList").get(WmsController.StockManagementList);
router.route("/tempManagementHistory").get(WmsController.TempHistory);
router.route("/stockManagementExport").get(WmsController.StockManagementExport);
router.route("/orderReturnAwbUpdate").post(WmsController.OrderReturnAwbUpdate);
router.route("/pdfCreate").get(WmsController.pdfCreate);
router.route("/dateTest").post(WmsController.DateTest);
router.route("/checkOrderSerial").post(WmsController.checkOrderSerial);
router.route("/checkOrderInvoice").post(WmsController.checkOrderInvoice);
router.route("/scanBulk").post(WmsController.AwbScanUpdateBulk);
router.route("/get-return-scanned-data").post(ReturnController.getReturnScannedDataByDateRange);

// router.route("/updateInQty").post(WmsController.updateInQty);
// var DS_CRON_TAB = process.env.DS_CRON_TAB; 
// if (DS_CRON_TAB == 1) {
//     // cron.schedule('0 */4 * * * *', function () { 
//     cron.schedule('* * * * * *', function () { 
//         WmsCronController.UploadWmsOrders();
//     });

//     cron.schedule('* * * * * *', function () { 
//         WebCronController.InwardCron();
//     });
// }
  
module.exports = router;
