Browse Source

implemented building dynamically upto 13 buildings

master
AJITH 7 months ago
parent
commit
1b1c74fed6
  1. BIN
      co-workspaceDocuments/bid_1.jpg
  2. BIN
      co-workspaceDocuments/bid_2.jpg
  3. BIN
      co-workspaceDocuments/bid_3.jpeg
  4. BIN
      co-workspaceDocuments/coming_soon.jpeg
  5. 9
      src/main/java/com/gcc/coworkspace/configuration/DataSourceConfig.java
  6. 4
      src/main/java/com/gcc/coworkspace/constants/AppConstants.java
  7. 13
      src/main/java/com/gcc/coworkspace/controller/BookingController.java
  8. 21
      src/main/java/com/gcc/coworkspace/controller/BuildingController.java
  9. 18
      src/main/java/com/gcc/coworkspace/controller/controller.java
  10. 4
      src/main/java/com/gcc/coworkspace/service/AttendanceService.java
  11. 142
      src/main/java/com/gcc/coworkspace/service/BookingService.java
  12. 9
      src/main/java/com/gcc/coworkspace/service/BuildingService.java
  13. 26
      src/main/java/com/gcc/coworkspace/service/HomeService.java
  14. 4
      src/main/resources/templates/fragments/caretaker-navmenu.html
  15. 167
      src/main/resources/templates/user/book-Conferance.html
  16. 156
      src/main/resources/templates/user/book-reading.html
  17. 263
      src/main/resources/templates/user/book-workdesk.html
  18. 54
      src/main/resources/templates/user/home.html
  19. 26
      src/main/resources/templates/user/razor-pay.html

BIN
co-workspaceDocuments/bid_1.jpg

After

Width: 2560  |  Height: 1703  |  Size: 444 KiB

BIN
co-workspaceDocuments/bid_2.jpg

After

Width: 1280  |  Height: 960  |  Size: 200 KiB

BIN
co-workspaceDocuments/bid_3.jpeg

After

Width: 1600  |  Height: 721  |  Size: 118 KiB

BIN
co-workspaceDocuments/coming_soon.jpeg

After

Width: 2151  |  Height: 1434  |  Size: 644 KiB

9
src/main/java/com/gcc/coworkspace/configuration/DataSourceConfig.java

@ -25,13 +25,12 @@ public class DataSourceConfig {
// pass - Bonton#2K24
// DB:- coworkspace
// private static String host = "13.232.20.48";
// private static String dbpassword = "Bonton#2K24";
// private static String host = "13.232.20.48";
// private static String dbpassword = "Bonton#2K24";
// AWS
// private static String host =
// "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306";
// private static String dbpassword = "gcc-facial-password";
// private static String host = "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306";
// private static String dbpassword = "gcc-facial-password";
private static String host = "localhost:3306";
private static String dbpassword = "root";

4
src/main/java/com/gcc/coworkspace/constants/AppConstants.java

@ -1,8 +1,8 @@
package com.gcc.coworkspace.constants;
public final class AppConstants {
// public static String key_id="rzp_live_ySI5Ns54Y7qOcJ";
// public static String key_secret="Nwf1TjhUtaskof8vePkRR8Sb";
// public static String key_id="rzp_live_ySI5Ns54Y7qOcJ";
// public static String key_secret="Nwf1TjhUtaskof8vePkRR8Sb";
// uncomment for testing payment
public static String key_id = "rzp_test_tDkHFEqWXmuEi8";

13
src/main/java/com/gcc/coworkspace/controller/BookingController.java

@ -143,6 +143,19 @@ public class BookingController {
return bookingService.checkAvailabilityByBdate(bid, cid, bDate, scid, noOfPerson, slotId);
}
@GetMapping("/checkAvailslots")
public Integer checkAvailability(
@RequestParam int bid,
@RequestParam int cid,
@RequestParam LocalDate bDate,
@RequestParam int scid,
@RequestParam int slotId) {
System.out.println("Check availability API called");
return bookingService.getAvailableSeats(bid, cid, bDate, scid, slotId);
}
@GetMapping("/hasTodayAttendance")
public ResponseEntity<Map<String, Object>> hasTodayAttendance(
@RequestParam("buildingid") int buildingid) {

21
src/main/java/com/gcc/coworkspace/controller/BuildingController.java

@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.gcc.coworkspace.service.BuildingService;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -61,10 +62,28 @@ public class BuildingController {
// public List<Map<String, Object>> getBuildingCategoryDetails(@RequestParam int categoryId) {
// return buildingService.getBuildingCategoryDetailsById(categoryId);
// }
/*
@GetMapping("/getSlotBySid")
public List<Map<String, Object>> showSlotBySubCatId(@RequestParam int scid) {
return calendarService.getCalendarBasedOnSubCatId(scid);
// Replace with the actual view name
}*/
@GetMapping("/getSlotBySid")
public List<Map<String, Object>> showSlotBySubCatId(
@RequestParam(required = false) Integer scid) {
if (scid == null) {
return Collections.emptyList();
}
return calendarService.getCalendarBasedOnSubCatId(scid);
}
//ak dynamic
@GetMapping("/getSubCategoryByCid")
public List<Map<String, Object>> getSubCategoryByCid(@RequestParam int cid) {
return buildingService.getSubCategoryByCid(cid);
}
}

18
src/main/java/com/gcc/coworkspace/controller/controller.java

@ -291,10 +291,17 @@ public class controller {
: (spaces.isEmpty() ? null : (Integer) spaces.get(0).get("cid"));
// Pricing details
//ak dynamic
System.out.println("trete");
System.out.println(cid);
List<Map<String, Object>> readingZoneDetails = homeService.getPricingDetailsByCid(cid);
List<Map<String, Object>> deskSpaceDetails = homeService.getPricingDetailsByCid(cid);
List<Map<String, Object>> conferenceHallDetails = homeService.getPricingDetailsByCid(cid);
System.out.println("Reading Zone Details: " + readingZoneDetails);
System.out.println("Desk Space Details: " + deskSpaceDetails);
System.out.println("Conference Hall Details: " + conferenceHallDetails);
// Images
List<Map<String, Object>> homeImg = (cid != null)
? homeService.getImgByCid(cid)
@ -325,6 +332,15 @@ public class controller {
public List<Map<String, Object>> getPricingDetails(@RequestParam int cid) {
return homeService.getPricingDetailsByCid(cid);
}
/* @GetMapping("/api/pricing")
@ResponseBody
public List<Map<String, Object>> getPricingDetails(
@RequestParam int cid,
@RequestParam int bid) {
return homeService.getPricingDetailsByCidAndBid(cid, bid);
}*/
// @GetMapping("/book")
// public String showCategoryPage(@RequestParam int buildingId,@RequestParam int

4
src/main/java/com/gcc/coworkspace/service/AttendanceService.java

@ -286,6 +286,10 @@ public class AttendanceService {
sql.append("AND cat.name = ? ");
params.add(type);
}
if (bid != null && !bid.isEmpty()) {
sql.append(" AND c.bid = ? ");
params.add(bid);
}
if (typeName != null && !typeName.isEmpty()) {
sql.append("AND cat.display_name = ? ");

142
src/main/java/com/gcc/coworkspace/service/BookingService.java

@ -231,7 +231,7 @@ public class BookingService {
System.out.println("count======================: " + count1);
System.out.println("count: " + count);
if (cid == 2 && LocalDate.now().equals(Bdate)) // Allow only Disc Work Space and today date
if (cid == 2 || cid== 6 || cid ==16 && LocalDate.now().equals(Bdate)) // Allow only Disc Work Space and today date
{
int acount = getacountfromtable(bid);
System.out.println("acount: " + acount);
@ -254,6 +254,40 @@ public class BookingService {
return false;
}
//ak
public int getAvailableSeats(int bid, int cid, LocalDate bDate, int scid, int slotId) {
System.out.println("bid: " + bid);
System.out.println("cid: " + cid);
System.out.println("bDate: " + bDate);
System.out.println("scid: " + scid);
System.out.println("slotId: " + slotId);
Map<String, Object> calendar = getCalendarBySlotId(bid, cid, bDate, slotId);
Map<String, Object> capacity = getCapacity(scid, cid);
int capacityint = Integer.parseInt(capacity.get("capacity").toString());
int bookedSeats = 0;
if (!calendar.isEmpty()) {
bookedSeats = Integer.parseInt(calendar.get("filed").toString());
}
int availableSeats = capacityint - bookedSeats;
if (availableSeats < 0) {
availableSeats = 0;
}
System.out.println("Total capacity: " + capacityint);
System.out.println("Booked seats: " + bookedSeats);
System.out.println("Available seats: " + availableSeats);
return availableSeats;
}
public Map<String, Object> getCapacity(int sId, int catId) {
System.out.println("sid" + sId);
System.out.println("catId" + catId);
@ -272,8 +306,78 @@ public class BookingService {
public Map<String, Object> getCalendarBySlotId(int bid, int cid, LocalDate Bdate, int slotId) {
String sql = "";
if (cid == 2 || cid == 6 || cid == 16) {
boolean isHalfDay = false;
String slotCondition = "";
if (cid == 2) {
// Deskspace group
if (slotId == 6 || slotId == 7) {
isHalfDay = true;
}
slotCondition = "slotId IN (?,8,9)";
}
else if (cid == 6) {
if (slotId == 59 || slotId == 60) {
isHalfDay = true;
}
slotCondition = "slotId IN (?,61,62)";
}
if (cid == 2) {
else if (cid == 16) {
if (slotId == 108 || slotId == 109) {
isHalfDay = true;
}
slotCondition = "slotId IN (?,110,111)";
}
if (isHalfDay) {
sql = "SELECT SUM(bcount) AS filed, bdate " +
"FROM calendar " +
"WHERE bdate = ? AND cid = ? AND bid = ? " +
"AND " + slotCondition + " " +
"GROUP BY bdate";
System.out.println("SELECT SUM(bcount) AS filed, bdate FROM calendar " +
"WHERE bdate = '" + Bdate + "' AND cid = " + cid +
" AND bid = " + bid +
" AND " + slotCondition +
" GROUP BY bdate");
} else {
sql = "SELECT SUM(bcount) AS filed, bdate " +
"FROM calendar " +
"WHERE bdate = ? AND cid = ? AND bid = ? AND slotId = ? " +
"GROUP BY bdate";
System.out.println("SELECT SUM(bcount) AS filed, bdate FROM calendar " +
"WHERE bdate = '" + Bdate + "' AND cid = " + cid +
" AND bid = " + bid +
" AND slotId = " + slotId +
" GROUP BY bdate");
}
} else {
sql = "SELECT SUM(bcount) AS filed, bdate " +
"FROM calendar " +
"WHERE bdate = ? AND cid = ? AND bid = ? AND slotId = ? " +
"GROUP BY bdate";
System.out.println("SELECT SUM(bcount) AS filed, bdate FROM calendar " +
"WHERE bdate = '" + Bdate + "' AND cid = " + cid +
" AND bid = " + bid +
" AND slotId = " + slotId +
" GROUP BY bdate");
}
/* if (cid == 2) {
if (slotId == 6 || slotId == 7) {
sql = "select sum(bcount) as filed, bdate "
+ "from calendar where bdate = ? and cid = ? and bid = ? and slotId IN (?,8,9) "
@ -302,7 +406,7 @@ public class BookingService {
+ "from calendar where bdate = '" + Bdate + "' and cid = '" + cid + "' and bid = '" + bid
+ "' and slotId = '" + slotId + "' "
+ "group by bdate");
}
}*/
// Using query() instead of queryForMap to handle no results
List<Map<String, Object>> result = jdbcTemplate.query(sql, (rs, rowNum) -> {
@ -696,12 +800,14 @@ public class BookingService {
* whatsAppService.sendTConfeNmsg(mobile, from_date, slottxt, amount,bookingId);
* }
*/
if (cid.equals("1") || cid.equals("4")) {
System.out.println("cid"+cid);
if (cid.equals("1") || cid.equals("4") || cid.equals("5") || cid.equals("7") || cid.equals("8") || cid.equals("9") || cid.equals("10") || cid.equals("11") || cid.equals("12") || cid.equals("13") || cid.equals("14") || cid.equals("15") || cid.equals("17")) {
whatsAppService.sendELearnNmsg(mobile, no_of_person, fromDateFormatted, slottxt, smsename, amount,
bookingId);
whatsAppService.sendTLearnNmsg(mobile, no_of_person, fromDateFormatted, slottxt, amount, bookingId);
} else if (cid.equals("2")) {
if (sid.equals("4")) {
} else if (cid.equals("2") || cid.equals("6") || cid.equals("16") ) {
if (sid.equals("4") || sid.equals("12") || sid.equals("24")) {
whatsAppService.sendEMonthDeskspaceNmsg(mobile, no_of_person, fromDateFormatted, toDateFormatted,
slottxt, smsename, amount, bookingId);
whatsAppService.sendTMonthDeskspaceNmsg(mobile, no_of_person, fromDateFormatted, toDateFormatted,
@ -1162,9 +1268,9 @@ public class BookingService {
String sql = "SELECT " +
"b.bid, " +
"COALESCE(SUM(b.amount), 0) AS overall_amount_collected, " +
"COALESCE(SUM(CASE WHEN b.sid IN (1,8) THEN b.amount ELSE 0 END), 0) AS learning_zone_amount_collected, "
"COALESCE(SUM(CASE WHEN b.sid IN (1,8,9,13,14,15,16,17,18,19,20,21,25) THEN b.amount ELSE 0 END), 0) AS learning_zone_amount_collected, "
+
"COALESCE(SUM(CASE WHEN b.sid IN (2, 3, 4) THEN b.amount ELSE 0 END), 0) AS desk_space_amount_collected, "
"COALESCE(SUM(CASE WHEN b.sid IN (2, 3, 4,10,11,12,22,23,24) THEN b.amount ELSE 0 END), 0) AS desk_space_amount_collected, "
+
"COALESCE(SUM(CASE WHEN b.sid IN (5, 6, 7) THEN b.amount ELSE 0 END), 0) AS meeting_room_amount_collected "
+
@ -1264,16 +1370,16 @@ public class BookingService {
* "COALESCE(SUM(CASE WHEN sid = 1 AND slotids = 5 THEN 1 ELSE 0 END), 0) AS slotId_5_count, "
* +
*/
"COALESCE(SUM(CASE WHEN sid in (1,8) AND slotids in (1,49) THEN 1 ELSE 0 END), 0) AS slotId_1_count, "
"COALESCE(SUM(CASE WHEN sid in (1,8,9,13,14,15,16,17,18,19,20,21,25) AND slotids in (1,49,54,63,68,73,78,83,88,93,98,103,112) THEN 1 ELSE 0 END), 0) AS slotId_1_count, "
+
"COALESCE(SUM(CASE WHEN sid in (1,8) AND slotids in (2,50) THEN 1 ELSE 0 END), 0) AS slotId_2_count, " +
"COALESCE(SUM(CASE WHEN sid in (1,8) AND slotids in (3,51) THEN 1 ELSE 0 END), 0) AS slotId_3_count, " +
"COALESCE(SUM(CASE WHEN sid in (1,8) AND slotids in (4,52) THEN 1 ELSE 0 END), 0) AS slotId_4_count, " +
"COALESCE(SUM(CASE WHEN sid in (1,8) AND slotids in (5,53) THEN 1 ELSE 0 END), 0) AS slotId_5_count, " +
"COALESCE(SUM(CASE WHEN sid in (1,8,9,13,14,15,16,17,18,19,20,21,25) AND slotids in (2,50,55,64,69,74,79,84,89,94,99,104,113) THEN 1 ELSE 0 END), 0) AS slotId_2_count, " +
"COALESCE(SUM(CASE WHEN sid in (1,8,9,13,14,15,16,17,18,19,20,21,25) AND slotids in (3,51,56,65,70,75,80,85,90,95,100,105,114) THEN 1 ELSE 0 END), 0) AS slotId_3_count, " +
"COALESCE(SUM(CASE WHEN sid in (1,8,9,13,14,15,16,17,18,19,20,21,25) AND slotids in (4,52,57,66,71,76,81,86,91,96,101,106,115) THEN 1 ELSE 0 END), 0) AS slotId_4_count, " +
"COALESCE(SUM(CASE WHEN sid in (1,8,9,13,14,15,16,17,18,19,20,21,25) AND slotids in (5,53,58,67,72,77,82,87,92,97,102,107,116) THEN 1 ELSE 0 END), 0) AS slotId_5_count, " +
"COALESCE(SUM(CASE WHEN sid = 2 AND slotids IN (6,7) THEN 1 ELSE 0 END), 0) AS half_day_count, " +
"COALESCE(SUM(CASE WHEN sid = 3 AND slotids = 8 THEN 1 ELSE 0 END), 0) AS full_day_count, " +
"COALESCE(SUM(CASE WHEN sid = 4 AND slotids = 9 THEN 1 ELSE 0 END), 0) AS monthly_count, " +
"COALESCE(SUM(CASE WHEN sid in (2,10,22) AND slotids IN (6,7,59,60,108,109) THEN 1 ELSE 0 END), 0) AS half_day_count, " +
"COALESCE(SUM(CASE WHEN sid in (3,11,23) AND slotids IN (8,61,110) THEN 1 ELSE 0 END), 0) AS full_day_count, " +
"COALESCE(SUM(CASE WHEN sid in (4,12,24) AND slotids IN (9,62,111) THEN 1 ELSE 0 END), 0) AS monthly_count, " +
"COALESCE(SUM(CASE WHEN sid = 5 AND slotids IN (10,11,12,13,14,15,16,17,18,19,20,21,22) THEN 1 ELSE 0 END), 0) AS RoomNo1_Count, "
+
@ -1311,8 +1417,8 @@ public class BookingService {
String sql = "SELECT " +
"COUNT(booking_id) AS Total_booking_count, " +
"SUM(CASE WHEN cid in (1,4) THEN 1 ELSE 0 END) AS Learning_zone_count, " +
"SUM(CASE WHEN cid = 2 THEN 1 ELSE 0 END) AS Desk_space_count, " +
"SUM(CASE WHEN cid in (1,4,5,7,8,9,10,11,12,13,14,15,17) THEN 1 ELSE 0 END) AS Learning_zone_count, " +
"SUM(CASE WHEN cid in (2,6,16) THEN 1 ELSE 0 END) AS Desk_space_count, " +
"SUM(CASE WHEN cid = 3 THEN 1 ELSE 0 END) AS Meeting_room_count " +
"FROM booking " +
"WHERE booking_status = 'success' " +

9
src/main/java/com/gcc/coworkspace/service/BuildingService.java

@ -167,4 +167,13 @@ public List<Map<String, Object>> getBuildingDetails() {
return jdbcTemplate.queryForList(sql,categoryId);
}
//ak dynamic
public List<Map<String, Object>> getSubCategoryByCid(int categoryId) {
String sql = "SELECT * FROM subcategory where cid = ?";
return jdbcTemplate.queryForList(sql,categoryId);
}
}

26
src/main/java/com/gcc/coworkspace/service/HomeService.java

@ -141,6 +141,7 @@ public List<Map<String, Object>> getActiveCoWorkingSpacesByBuilding(int bid) {
public List<Map<String, Object>> getPricingDetailsByCid(int cid) {
System.out.println("Fetching pricing details for CID: " + cid); // Debugging line to check the input parameter
String sql = """
SELECT sc.scid, sc.name, sc.display_name, sc.cid, sc.orderby, sc.cdate, sc.isactive,
sc.isdelete, sc.limits, sc.capacity, c.description
@ -150,6 +151,31 @@ public List<Map<String, Object>> getActiveCoWorkingSpacesByBuilding(int bid) {
""";
return jdbcTemplate.queryForList(sql, cid);
}
/* public List<Map<String, Object>> getPricingDetailsByCidAndBid(int cid, int bid) {
String sql = """
SELECT sc.scid,
sc.name,
sc.display_name,
sc.cid,
sc.orderby,
sc.cdate,
sc.isactive,
sc.isdelete,
sc.limits,
sc.capacity,
c.description
FROM subcategory sc
JOIN category c ON sc.cid = c.cid
WHERE sc.cid = ?
AND c.bid = ? -- 🔥 CRITICAL FIX
AND sc.isactive = 1
AND sc.isdelete = 0
ORDER BY sc.orderby
""";
return jdbcTemplate.queryForList(sql, cid, bid);
}*/
public List<Map<String, Object>> getImgByCid(int cid) {
String sql = """

4
src/main/resources/templates/fragments/caretaker-navmenu.html

@ -35,14 +35,14 @@
</li>
<li class="pcoded-hasmenu">
<a href="/muthalvarpadaippagam/attendance" th:if="${session.bid!=2}">
<a href="/muthalvarpadaippagam/attendance" th:if="${session.bid==1 or session.bid==3 or session.bid==12 }">
<span class="pcoded-micon"><i class="fa fa-list-alt"></i></span>
<span class="pcoded-mtext">Attendance</span>
<span class="pcoded-mcaret"></span>
</a>
</li>
<li class="pcoded-hasmenu">
<a href="/muthalvarpadaippagam/attendancereport" th:if="${session.bid!=2}">
<a href="/muthalvarpadaippagam/attendancereport" th:if="${session.bid==1 or session.bid==3 or session.bid==12}">
<span class="pcoded-micon"><i class="fa fa-list-alt"></i></span>
<span class="pcoded-mtext">Attendance Report</span>
<span class="pcoded-mcaret"></span>

167
src/main/resources/templates/user/book-Conferance.html

@ -347,7 +347,9 @@
<div id="timeSlots" class="d-flex flex-wrap">
<!-- Time slots will be generated here dynamically -->
</div>
<div id="seatAvailabilityMsg" style="margin-top:5px; font-size:13px; color:red;"></div>
</div>
</div>
<!-- Selected Time Slot
@ -608,6 +610,7 @@
</div>
<script th:replace="~{fragments/user-script :: script}"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
// let catId=3;
// let subId =5;
@ -706,7 +709,105 @@
});
}
function selectTimeSlot(element) {
$('#numSeats').change(function () {
document.getElementById('timeSlots').innerHTML = '';
document.getElementById('selectDate').value = '';
// clear availability text
$('#seatAvailabilityMsg').text('');
console.log("Slots reset because number of seats changed");
});
function selectTimeSlot(element) {
slots = [];
let slotId = element.value;
let bid = $('#buildingId').val();
let cid = $('#categoryId').val();
// let scid = $('#subId').val();
let scid =document.querySelector('input[name="booking_type"]:checked').value;
let bDate = $('#selectDate').val();
let noOfPerson = $('#numSeats').val();
$.ajax({
url: '/muthalvarpadaippagam/book/api/checkAvailslots',
type: 'GET',
data: {
bid: bid,
cid: cid,
bDate: bDate,
scid: scid,
slotId: slotId
},
success: function (availableSeats) {
// show message below slots
$('#seatAvailabilityMsg').text("Available Seats : " + availableSeats);
if (availableSeats == 0) {
$('#seatAvailabilityMsg').text("Slot Full");
// show slot as selected
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
return;
}
if (parseInt(noOfPerson) > availableSeats) {
$('#seatAvailabilityMsg').text("Only " + availableSeats + " seats available");
// still store selected slot
document.getElementById('selectedSlot').value =
element.nextSibling.nodeValue.trim();
slots.push(slotId);
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
return;
}
document.getElementById('selectedSlot').value =
element.nextSibling.nodeValue.trim();
slots.push(slotId);
console.log("Selected slots:", slots);
// reset colors
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
if (element.checked) {
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
}
}
});
}
/* function selectTimeSlot(element) {
slots = [];
document.getElementById('selectedSlot').value = element.nextSibling.nodeValue.trim(); // Get the displayed time
slots.push(element.value);
@ -723,7 +824,7 @@
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
}
}
}*/
// Calculate Total Payable Amount
@ -813,9 +914,31 @@
function saveBooking() {
// console.log("buildId: "+buildId);
// console.log("catId: "+catId);
// console.log("subId: "+subId);
let msg = $('#seatAvailabilityMsg').text();
if (msg.includes("Only")) {
// alert(msg);
swal.fire({
title: "Seat Availability",
text: msg,
icon: "warning",
button: "OK",
});
return;
}
if (msg.includes("Slot Full")) {
swal.fire({
title: "Slot Full",
text: "This slot is full. Please select another slot.",
icon: "error",
button: "OK",
});
return;
}
// console.log("buildId: "+buildId);
// console.log("catId: "+catId);
// console.log("subId: "+subId);
//console.log(from_date);
//e.preventDefault(); // Prevent form submission for this example
@ -830,7 +953,13 @@
// Proceed with form submission
//alert("Form is valid!");
} else {
alert("Please correct the errors in the form.");
// alert("Please correct the errors in the form.");
swal.fire({
title: "Form Validation",
text: "Please correct the errors in the form.",
icon: "error",
button: "OK",
});
return false;
}
@ -838,12 +967,18 @@
let name = $('#personName').val();
let phone = $('#personPhone').val();
let fromDate = $('#selectDate').val(); // Ensure this is a different element
let subId = $('#subId').val();
const bookingType = document.querySelector('input[name="booking_type"]:checked').value;
//let subId = $('#subId').val();
let subId =document.querySelector('input[name="booking_type"]:checked').value;
let buildId = $('#buildingId').val();
let catId = $('#categoryId').val();
let toDate = $('#selectDate').val(); // Ensure this is a different element
let selectedSlot = $('#selectedSlot').val();
let noOfPeople = $('#numSeats').val();
console.log("subId" ,subId);
console.log("buildId" ,buildId);
console.log("catId" ,catId);
// Populate the span elements with the retrieved values
$('.name').text(name);
@ -899,7 +1034,13 @@
msg = xhr.responseJSON.message;
}
alert(msg);
// alert(msg);
swal.fire({
title: "Booking Failed",
text: msg,
icon: "error",
button: "OK",
});
}
});
}
@ -948,6 +1089,8 @@
$('input[name="booking_type"]').on('change', async function () {
const bookingType = document.querySelector('input[name="booking_type"]:checked').value;
console.log("Selected booking type:", bookingType);
$('#seatAvailabilityMsg').text(''); // Clear seat availability message when booking type changes
subId = bookingType; // Retrieve scid dynamically if needed
//subId
if (subId == 5 || subId == 6) {
@ -996,7 +1139,13 @@
url = "https://my.matterport.com/show/?m=2n8cHdtUfs8";
modalId = "visitTourModal";
} else {
alert("No tour available for this category."); // Fallback for other cases
// alert("No tour available for this category."); // Fallback for other cases
swal.fire({
title: "No Tour Available",
text: "No tour available for this category.",
icon: "info",
button: "OK",
});
return;
}

156
src/main/resources/templates/user/book-reading.html

@ -283,7 +283,9 @@
<div class="col-sm-12">
<div id="timeSlots" class="d-flex flex-wrap">
<!-- Time slots will be generated here dynamically -->
</div>
<div id="seatAvailabilityMsg" style="margin-top:5px; font-size:13px; color:red;"></div>
</div>
</div>
@ -547,6 +549,7 @@
</div>
<script th:replace="~{fragments/user-script :: script}"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
//ak
document.addEventListener('DOMContentLoaded', () => {
@ -574,6 +577,13 @@
const catId = document.getElementById("#categoryId")
let subId = document.getElementById("#subId")
console.log("Category ID:", catId);
console.log("Building ID:", buildId);
console.log("Sub ID:", subId);
@ -644,7 +654,7 @@
});
}
function selectTimeSlot(element) {
/* function selectTimeSlot(element) {
slots = [];
document.getElementById('selectedSlot').value = element.nextSibling.nodeValue.trim(); // Get the displayed time
slots.push(element.value);
@ -661,7 +671,102 @@
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
}
}*/
$('#numSeats').change(function () {
document.getElementById('timeSlots').innerHTML = '';
document.getElementById('selectDate').value = '';
// clear availability text
$('#seatAvailabilityMsg').text('');
console.log("Slots reset because number of seats changed");
});
function selectTimeSlot(element) {
slots = [];
let slotId = element.value;
let bid = $('#buildingId').val();
let cid = $('#categoryId').val();
let scid = $('#subId').val();
let bDate = $('#selectDate').val();
let noOfPerson = $('#numSeats').val();
$.ajax({
url: '/muthalvarpadaippagam/book/api/checkAvailslots',
type: 'GET',
data: {
bid: bid,
cid: cid,
bDate: bDate,
scid: scid,
slotId: slotId
},
success: function (availableSeats) {
// show message below slots
$('#seatAvailabilityMsg').text("Available Seats : " + availableSeats);
if (availableSeats == 0) {
$('#seatAvailabilityMsg').text("Slot Full");
// show slot as selected
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
return;
}
if (parseInt(noOfPerson) > availableSeats) {
$('#seatAvailabilityMsg').text("Only " + availableSeats + " seats available");
// still store selected slot
document.getElementById('selectedSlot').value =
element.nextSibling.nodeValue.trim();
slots.push(slotId);
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
return;
}
document.getElementById('selectedSlot').value =
element.nextSibling.nodeValue.trim();
slots.push(slotId);
console.log("Selected slots:", slots);
// reset colors
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
if (element.checked) {
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
}
}
});
}
// Calculate Total Payable Amount
@ -671,6 +776,7 @@
document.getElementById('timeSlots').innerHTML = ''; // Clear the time slots
document.getElementById('selectedSlot').value = ''; // Clear selected slot
document.getElementById('totalAmount').value = 'Rs. 0.00'; // Reset total amount
$('#seatAvailabilityMsg').text(''); // Clear seat availability message
}
// Booking Action
@ -744,6 +850,28 @@
// console.log(subId);
//console.log(from_date);
//e.preventDefault(); // Prevent form submission for this example
let msg = $('#seatAvailabilityMsg').text();
if (msg.includes("Only")) {
// alert(msg);
swal.fire({
title: "Seat Availability",
text: msg,
icon: "warning",
button: "OK",
});
return;
}
if (msg.includes("Slot Full")) {
swal.fire({
title: "Slot Full",
text: "This slot is full. Please select another slot.",
icon: "error",
button: "OK",
});
return;
}
const isMobileValid = validateMobileNumber();
const isNameValid = validatePersonName();
@ -755,7 +883,13 @@
// Proceed with form submission
//alert("Form is valid!");
} else {
alert("Please correct the errors in the form.");
// alert("Please correct the errors in the form.");
swal.fire({
title: "Form Validation",
text: "Please correct the errors in the form.",
icon: "error",
button: "OK",
});
return false;
}
@ -769,6 +903,7 @@
let toDate = $('#selectDate').val(); // Ensure this is a different element
let selectedSlot = $('#selectedSlot').val();
let noOfPeople = $('#numSeats').val();
console.log(buildId);
// Populate the span elements with the retrieved values
$('.name').text(name);
@ -827,7 +962,13 @@
msg = xhr.responseJSON.message;
}
alert(msg);
// alert(msg);
swal.fire({
title: "Booking Failed",
text: msg,
icon: "error",
button: "OK",
});
}
});
}
@ -876,6 +1017,7 @@
$('#selectDate').on('change', async function () {
//alert('Date changed');
const selectedDate = $("#selectDate").val();
$('#seatAvailabilityMsg').text('');
const scid = $('#subId').val();
console.log("Subcategory ID:", scid);
@ -918,7 +1060,13 @@
url = "https://my.matterport.com/show/?m=2n8cHdtUfs8";
modalId = "visitTourModal1";
} else {
alert("No tour available for this category."); // Fallback for other cases
// alert("No tour available for this category."); // Fallback for other cases
swal.fire({
title: "No Tour Available",
text: "No tour available for this category.",
icon: "info",
button: "OK",
});
return;
}

263
src/main/resources/templates/user/book-workdesk.html

@ -357,26 +357,27 @@
required for :</label>
<div class="col-sm-8">
<div id="seatfor" class="d-flex flex-wrap">
<div class="btn-group" data-toggle="buttons">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary2 me-2 mb-2"
style="margin: 5px;">
<input type="radio" name="booking_type"
id="booking_type" autocomplete="off"
value="2"> Half Day
id="halfDay" autocomplete="off"
value=""> Half Day
</label>
<label class="btn btn-primary2 me-2 mb-2"
style="margin: 5px;">
<input type="radio" name="booking_type"
id="booking_type" autocomplete="off"
value="3"> Full Day
id="fullDay" autocomplete="off"
value=""> Full Day
</label>
<label class="btn btn-primary2 mb-2"
style="margin: 5px;">
<input type="radio" name="booking_type"
id="booking_type" autocomplete="off"
value="4"> Month
id="month" autocomplete="off"
value=""> Month
</label>
</div>
</div>
</div>
</div>
</div>
@ -390,6 +391,7 @@
<div id="timeSlots" class="d-flex flex-wrap">
<!-- Time slots will be generated here dynamically -->
</div>
<div id="seatAvailabilityMsg" style="margin-top:5px; font-size:13px; color:red;"></div>
</div>
</div>
@ -648,6 +650,7 @@
</div>
<script th:replace="~{fragments/user-script :: script}"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
//ak
document.addEventListener('DOMContentLoaded', () => {
@ -697,6 +700,12 @@
const catId = document.getElementById("#categoryId")
let subId = document.getElementById("#subId")
console.log("Category ID:", catId);
console.log("Building ID:", buildId);
console.log("Sub ID:", subId);
let slots = [];
let timeSlots = [];
@ -710,6 +719,7 @@
async function loadSlots(scid) {
timeSlots = []; // Clear previous slots
subId = scid;
try {
const response = await $.ajax({
url: '/muthalvarpadaippagam/api/getSlotBySid',
@ -722,6 +732,36 @@
console.error('Error loading slots:', error);
}
}
//ak dynamic
async function assignScidToStaticRadios() {
let catId = $('#categoryId').val();
try {
const response = await $.ajax({
url: '/muthalvarpadaippagam/api/getSubCategoryByCid',
type: 'GET',
data: { cid: catId }
});
response.forEach(function(item) {
if (item.display_name.toLowerCase().includes("half")) {
$('#halfDay').val(item.scid);
}
else if (item.display_name.toLowerCase().includes("full")) {
$('#fullDay').val(item.scid);
}
else if (item.display_name.toLowerCase().includes("month")) {
$('#month').val(item.scid);
}
});
} catch (error) {
console.error("Error assigning scid:", error);
}
}
function loadTimeSlots(selectedDate) {
@ -765,8 +805,113 @@
}
});
}
$('#numSeats').change(function () {
document.getElementById('timeSlots').innerHTML = '';
document.getElementById('selectDate').value = '';
// clear availability text
$('#seatAvailabilityMsg').text('');
console.log("Slots reset because number of seats changed");
});
$('input[name="booking_type"]').change(function () {
// clear seat availability message
$('#seatAvailabilityMsg').text('');
// optional: reset selected slot
});
function selectTimeSlot(element) {
slots = [];
let slotId = element.value;
let bid = $('#buildingId').val();
let cid = $('#categoryId').val();
let scid = $('#subId').val();
let bDate = $('#selectDate').val();
let noOfPerson = $('#numSeats').val();
$.ajax({
url: '/muthalvarpadaippagam/book/api/checkAvailslots',
type: 'GET',
data: {
bid: bid,
cid: cid,
bDate: bDate,
scid: scid,
slotId: slotId
},
success: function (availableSeats) {
// show message below slots
$('#seatAvailabilityMsg').text("Available Seats : " + availableSeats);
if (availableSeats == 0) {
$('#seatAvailabilityMsg').text("Slot Full");
// show slot as selected
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
return;
}
if (parseInt(noOfPerson) > availableSeats) {
$('#seatAvailabilityMsg').text("Only " + availableSeats + " seats available");
// still store selected slot
document.getElementById('selectedSlot').value =
element.nextSibling.nodeValue.trim();
slots.push(slotId);
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
return;
}
document.getElementById('selectedSlot').value =
element.nextSibling.nodeValue.trim();
slots.push(slotId);
console.log("Selected slots:", slots);
// reset colors
document.querySelectorAll('input[name="timeSlot"]').forEach(slot => {
slot.parentElement.style.backgroundColor = '';
slot.parentElement.style.color = '';
});
if (element.checked) {
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
}
}
});
}
//exisisting
function selectTimeSlot(element) {
/* function selectTimeSlot(element) {
slots = [];
document.getElementById('selectedSlot').value = element.nextSibling.nodeValue.trim(); // Get the displayed time
slots.push(element.value);
@ -783,7 +928,7 @@
element.parentElement.style.backgroundColor = '#E29D25';
element.parentElement.style.color = '#FFF';
}
}
}*/
// Calculate Total Payable Amount
@ -793,6 +938,7 @@
document.getElementById('timeSlots').innerHTML = ''; // Clear the time slots
document.getElementById('selectedSlot').value = ''; // Clear selected slot
document.getElementById('totalAmount').value = 'Rs. 0.00'; // Reset total amount
$('#seatAvailabilityMsg').text(''); // Clear seat availability message
}
// Booking Action
@ -872,6 +1018,28 @@
}
function saveBooking() {
let msg = $('#seatAvailabilityMsg').text();
if (msg.includes("Only")) {
// alert(msg);
swal.fire({
title: "Seat Availability",
text: msg,
icon: "warning",
button: "OK",
});
return;
}
if (msg.includes("Slot Full")) {
swal.fire({
title: "Slot Full",
text: "This slot is full. Please select another slot.",
icon: "error",
button: "OK",
});
return;
}
// console.log(catId);
// console.log(buildId);
@ -890,7 +1058,13 @@
// Proceed with form submission
//alert("Form is valid!");
} else {
alert("Please correct the errors in the form.");
// alert("Please correct the errors in the form.");
swal.fire({
title: "Form Validation",
text: "Please correct the errors in the form.",
icon: "error",
button: "OK",
});
return false;
}
@ -899,10 +1073,12 @@
let phone = $('#personPhone').val();
let fromDate = $('#selectDate').val(); // Ensure this is a different element
let subId = $('input[name="booking_type"]:checked').val();
//let subId = $('#subId').val();
let buildId = $('#buildingId').val();
let catId = $('#categoryId').val();
console.log(subId);
let toDate = fromDate; // Ensure this is a different element
if (subId == 4) {
if (subId == 4 || subId==12 || subId==24) {
//toDate = convertDateFormat(toDate);
let endDate = new Date(fromDate);
endDate.setDate(endDate.getDate() + 30);
@ -971,7 +1147,13 @@
msg = xhr.responseJSON.message;
}
alert(msg);
// alert(msg);
swal.fire({
title: "Booking Failed",
text: msg,
icon: "error",
button: "OK",
});
}
});
}
@ -1029,14 +1211,38 @@
// Allow reopening the datepicker on click even after readonly
$("#selectDate").on("click", function () {
$(this).datepicker("show");
});*/
});*/
// Function to load available time slots
//ak dynamic
assignScidToStaticRadios();
$('#selectDate').on('change', async function () {
//alert('Date changed');
const bookingType = document.querySelector('input[name="booking_type"]:checked').value;
const scid = bookingType; // Retrieve scid dynamically if needed
// const bookingType = document.querySelector('input[name="booking_type"]:checked').value;
// const scid = bookingType; // Retrieve scid dynamically if needed
const selectedRadio = document.querySelector('input[name="booking_type"]:checked');
$('#seatAvailabilityMsg').text('');
if (!selectedRadio || !selectedRadio.value) {
console.log("Invalid scid. Skipping slot load.");
return;
}
const scid = selectedRadio.value;
const selectedDate = $("#selectDate").val();
let catId = $('#categoryId').val();
console.log("cat")
console.log(catId);
console.log("sleted")
console.log(scid);
if (scid) {
await loadSlots(scid);
loadTimeSlots(selectedDate);
@ -1045,8 +1251,21 @@
});
$('input[name="booking_type"]').on('change', async function () {
const bookingType = document.querySelector('input[name="booking_type"]:checked').value;
const scid = bookingType; // Retrieve scid dynamically if needed
const selectedRadio = document.querySelector('input[name="booking_type"]:checked');
if (!selectedRadio || !selectedRadio.value) {
console.log("Invalid scid. Skipping slot load.");
return;
}
const scid = selectedRadio.value;
// const bookingType = document.querySelector('input[name="booking_type"]:checked').value;
// const scid = bookingType; // Retrieve scid dynamically if needed
// const scid = $('#subId').val();
let catId = $('#categoryId').val();
console.log("cat12")
console.log(catId);
const selectedDate = $("#selectDate").val();
await loadSlots(scid);
loadTimeSlots(selectedDate);
@ -1085,7 +1304,13 @@
url = "https://my.matterport.com/show/?m=2n8cHdtUfs8";
modalId = "visitTourModal";
} else {
alert("No tour available for this category."); // Fallback for other cases
// alert("No tour available for this category."); // Fallback for other cases
swal.fire({
title: "No Tour Available",
text: "No tour available for this category.",
icon: "info",
button: "OK",
});
return;
}

54
src/main/resources/templates/user/home.html

@ -1147,6 +1147,7 @@
</div>
</div> -->
<!-- th:classappend="${ (bid == 1 and space.cid == 1) or (bid == 2 and space.cid == 4) } ? ' active' : ''" -->
<!-- Dynamic Tab Buttons -->
<div class="custom-tabs text-center my-3">
@ -1155,10 +1156,7 @@
class="custom-tab-btn"
th:data-cid="${space.cid}"
th:data-bid="${space.bid}"
th:classappend="${
(bid == 1 and space.cid == 1) or
(bid == 2 and space.cid == 4)
} ? ' active' : ''"
th:classappend="${space.cid == cid} ? ' active' : ''"
th:text="${space.display_name}">
</a>
</th:block>
@ -1461,6 +1459,10 @@ document.addEventListener('DOMContentLoaded', () => {
const pricingContainer = document.getElementById('pricingCardsContainer');
const buildingId = document.getElementById('buildingId').value;
const categoryId = document.getElementById('categoryId').value;
console.log("buildingid");
console.log(buildingId);
console.log("categoryId");
console.log(categoryId);
function loadPricingDetails(cid, type) {
$.ajax({
@ -1468,7 +1470,7 @@ document.addEventListener('DOMContentLoaded', () => {
type: 'GET',
dataType: 'json',
success: function (data) {
//console.log(data);
console.log(data);
renderPricingCards(data, type);
},
error: function () {
@ -1490,9 +1492,12 @@ document.addEventListener('DOMContentLoaded', () => {
html += `
<div class="card" style="margin-top:5px;background-color:#083959;border:6px solid #d6d4fa;border-radius:25px;">
<h2 style="color:white;">${item.display_name}</h2>
<p style="color:white;">Capacity: 38 persons</p>
<!--<p style="color:white;">Capacity: 38 persons</p>-->
<p style="color:white;">
Capacity: ${buildingId === '1' ? '38' : (item.capacity || 'N/A')} persons
</p>
<ul style="color:white;">
<li>${item.scid == 2 ?
<li>${item.scid == 2 || item.scid == 10 || item.scid == 22 ?
"Slot Time:<br>09:00 AM - 03:00 PM<br>03:00 PM - 09:00 PM" :
"Slot Time:<br>09:00 AM - 09:00 PM"}</li>
<li>Wifi / Internet</li>
@ -1556,10 +1561,24 @@ document.addEventListener('DOMContentLoaded', () => {
// Tab click events
deskSpaceBtn.addEventListener('click', () => {
/*deskSpaceBtn.addEventListener('click', () => {
updateActiveTab(deskSpaceBtn);
loadPricingDetails(2, 'desk'); // use deskSpace cid
});
});*/
deskSpaceBtn.addEventListener('click', () => {
updateActiveTab(deskSpaceBtn);
if (buildingId === '3') {
loadPricingDetails(6, 'desk'); // Building 3 Desk CID
}
if(buildingId ==='12'){
loadPricingDetails(16, 'desk');
}
else {
loadPricingDetails(2, 'desk'); // Default Desk CID
}
});
conferenceHallBtn.addEventListener('click', () => {
updateActiveTab(conferenceHallBtn);
@ -1589,13 +1608,28 @@ document.addEventListener('DOMContentLoaded', () => {
updateActiveTab(readingZoneBtn);
loadPricingDetails(categoryId, 'reading');
}
else if (buildingId === '2') {
else if (buildingId === '2' || buildingId === '4' || buildingId === '5' || buildingId === '6' || buildingId === '7' || buildingId === '8' || buildingId === '9' || buildingId === '10' || buildingId === '11' || buildingId ==='13') {
// hide Desk + Conference for Building 2 (optional logic)
deskSpaceBtn.style.display = 'none';
conferenceHallBtn.style.display = 'none';
updateActiveTab(readingZoneBtn);
loadPricingDetails(categoryId, 'reading');
}
//for building3
else if (buildingId === '3' || buildingId === '12') {
// hide Desk + Conference for Building 2 (optional logic)
conferenceHallBtn.style.display = 'none';
updateActiveTab(readingZoneBtn);
loadPricingDetails(categoryId, 'reading');
}
else {
// default for all other cases
updateActiveTab(deskSpaceBtn);

26
src/main/resources/templates/user/razor-pay.html

@ -13,6 +13,7 @@
type: 'POST',
dataType: 'json',
success: function (response) {
$('#ackModal').modal('hide');
let amt = response.amount;
console.log("FIRST:==>");
console.log(response);
@ -33,8 +34,29 @@
console.log(response.razorpay_order_id);
console.log(response.razorpay_signature);
console.log("payment success");
alert("congrates !payment successfull");
updatePaymentInServer(response.razorpay_payment_id, response.razorpay_order_id, "paid", id, amt);
//alert("congrates !payment successfull");
//updatePaymentInServer(response.razorpay_payment_id, response.razorpay_order_id, "paid", id, amt);
Swal.fire({
title: "Payment Successful 🎉",
text: "Congratulations! Payment completed successfully.",
icon: "success",
confirmButtonText: "OK"
}).then((result) => {
if (result.isConfirmed) {
updatePaymentInServer(
response.razorpay_payment_id,
response.razorpay_order_id,
"paid",
id,
amt
);
}
});
},
"prefill": {
"name": "",

Loading…
Cancel
Save