|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
const { Tanker, Tankerbooking,Bore,GovtPipeLine } = require('../models/tankers')
|
|
|
|
|
const { User,Counter, generateBookingId,resetCounter,generateCustomerId } = require('../models/User')
|
|
|
|
|
|
|
|
|
|
const User = require("../models/User");
|
|
|
|
|
|
|
|
|
|
//const User = require("../models/User");
|
|
|
|
|
const boom = require("boom");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -97,26 +99,25 @@ exports.deleteTankerInfo = async (req, reply) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let bookingCount = 0
|
|
|
|
|
exports.tankerBooking = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var customerId = req.params.customerId;
|
|
|
|
|
var b_id = await generateBookingId()
|
|
|
|
|
const date = new Date()
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
|
|
|
|
const day = date.getDate().toString().padStart(2, '0')
|
|
|
|
|
const count = bookingCount.toString().padStart(4, '0')
|
|
|
|
|
const bookingId = `ARM${year}${month}${day}${count}`
|
|
|
|
|
bookingCount = (bookingCount + 1) % 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bookingId = `ARM${year}${month}${day}${b_id}`
|
|
|
|
|
|
|
|
|
|
var booking_id = await Tankerbooking.findOne({ bookingid: bookingId})
|
|
|
|
|
if(booking_id){
|
|
|
|
|
|
|
|
|
|
await generateCustomerId()
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
bookingsData = {
|
|
|
|
|
customerId:customerId,
|
|
|
|
|
bookingid : bookingId,
|
|
|
|
|
typeofwater: req.body.typeofwater,
|
|
|
|
|
capacity: req.body.capacity,
|
|
|
|
@ -130,7 +131,8 @@ exports.tankerBooking = async (req, reply) => {
|
|
|
|
|
checkFormEncoding = isUserFormUrlEncoded(req);
|
|
|
|
|
if (checkFormEncoding.isUserFormUrlEncoded) {
|
|
|
|
|
usertobeInserted = checkFormEncoding.tankersBookingData;
|
|
|
|
|
console.log("thsi true url string");s
|
|
|
|
|
console.log("thsi true url string");
|
|
|
|
|
tankersBookingData.customerId = customerId;
|
|
|
|
|
tankersBookingData.bookingid = bookingId;
|
|
|
|
|
tankersBookingData.capacity = usertobeInserted.capacity;
|
|
|
|
|
tankersBookingData.typeofwater = usertobeInserted.typeofwater;
|
|
|
|
|