@@ -1073,9 +1073,7 @@ function isEmpty (object){
10731073router . post ( '/cancel_booking/:id' , verifyToken , ( req , res , next ) => {
10741074 Booking . findOne ( { booking_id :req . params . id } ) . then ( booking => {
10751075 Venue . findById ( { _id :booking . venue_id } ) . then ( venue => {
1076- Admin . findById ( { _id :req . userId } ) . then ( admin => {
1077- let role = req . role === "venue_staff" || req . role === "venue_manager"
1078- let date = new Date ( ) . addHours ( 8 , 30 )
1076+ Admin . findById ( { venue :{ $in :[ booking . venue_id ] } } ) . then ( admins => {
10791077 if ( booking . booking_type === "app" && req . body . refund_status ) {
10801078 axios . post ( 'https://' + rzp_key + '@api.razorpay.com/v1/payments/' + booking . transaction_id + '/refund' )
10811079 . then ( response => {
@@ -1100,10 +1098,11 @@ router.post('/cancel_booking/:id', verifyToken, (req, res, next) => {
11001098 } ) . catch ( error => {
11011099 console . log ( error . response )
11021100 } )
1103-
11041101 let obj = {
1105- name :req . name ,
1102+ name :req . username ,
1103+ venue_manager_name :venue . venue . name ,
11061104 date :date ,
1105+ phone :venue . venue . contact ,
11071106 time :datetime ,
11081107 booking_id :booking_id ,
11091108 venue_type :venue_type ,
@@ -1122,6 +1121,18 @@ router.post('/cancel_booking/:id', verifyToken, (req, res, next) => {
11221121 }
11231122 } )
11241123 } ) . catch ( next )
1124+ let manager_mail = ''
1125+ admins . map ( ( admin , index ) => { manager_mail += ( admin . length - 1 ) === index ?admin . email :admin . email + ',' } )
1126+ ejs . renderFile ( 'views/event_manager/venue_cancel_manager.ejs' , obj ) . then ( html => {
1127+ //let to_emails = `${req.body.email}, rajasekar@turftown.in`
1128+ mail ( "support@turftown.in" , manager_mail , booking_id + " has been cancelled" , "Slot Cancellation" , html , response => {
1129+ if ( response ) {
1130+ res . send ( { status :"success" } )
1131+ } else {
1132+ res . send ( { status :"failed" } )
1133+ }
1134+ } )
1135+ } ) . catch ( next )
11251136
11261137 //Activity Log
11271138 let activity_log = {
@@ -1983,7 +1994,7 @@ router.post('/cancel_event_booking/:id', verifyToken, (req, res, next) => {
19831994 let event_contact = eventBooking . event_id . event . contact
19841995 let event_email = eventBooking . event_id . event . email
19851996 let event_name1 = eventBooking . event_id . event . name
1986- // let total_teams = eventBooking.event_id.format.noofteams
1997+ let total_teams = eventBooking . event_id . format . noofteams
19871998 axios . get ( process . env . PHP_SERVER + '/textlocal/cancel_event.php?booking_id=' + booking_id + '&phone=' + phone + '&event_name=' + event_name + '&date=' + datetime + '&name=' + name + '&amount_paid=' + amount_paid + '&balance=' + balance + '&manager_phone=' + event_contact )
19881999 . then ( response => {
19892000 console . log ( response . data )
@@ -2000,7 +2011,7 @@ router.post('/cancel_event_booking/:id', verifyToken, (req, res, next) => {
20002011 team_name :eventBooking . team_name ,
20012012 total_team :15 ,
20022013 count :count ,
2003- status : req . body . refund_status ? `Advance of Rs ${ amount_paid } will be refunded within 3 - 4 working days` :`Advance of Rs ${ amount_paid } will be charged as cancellation fee`
2014+ status : req . body . refund_status ? `Advance of Rs ${ amount_paid } will be refunded to the user within 3 - 4 working days` :`Advance of Rs ${ amount_paid } will be charged as cancellation fee`
20042015 }
20052016
20062017 let to_emails_manager = `${ event_email } , rajasekar@turftown.in`
@@ -2597,9 +2608,9 @@ router.post('/test_mail', verifyToken, (req, res, next) => {
25972608 // let html = fs.readFileSync('views/mail.ejs',{encoding:'utf-8'});
25982609 console . log ( req . body )
25992610
2600- // EventBooking.find({}).populate("event_id").then(booking=>{
2601- // console.log(booking)
2602- // })
2611+ EventBooking . find ( { } ) . populate ( "event_id" ) . then ( booking => {
2612+ console . log ( booking [ 0 ] . event_id . format . noofteams )
2613+ } )
26032614 let booking_id = 'TT000121'
26042615 let obj = {
26052616 name :'Kumar' ,
@@ -2615,7 +2626,7 @@ router.post('/test_mail', verifyToken, (req, res, next) => {
26152626 let to_emails = `"akshay@turftown.in"`
26162627 mail ( "support@turftown.in" , to_emails , booking_id + " has been cancelled" , "Slot Cancellation" , html , response => {
26172628 if ( response ) {
2618- res . send ( { status :"success " } )
2629+ res . send ( { status :"booking " } )
26192630 } else {
26202631 res . send ( { status :"failed" } )
26212632 }
0 commit comments