├── .gitignore ├── Backend ├── .gitignore └── bus_reservation │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── safar │ │ │ ├── BusReservationApplication.java │ │ │ ├── controller │ │ │ ├── AdminController.java │ │ │ ├── AdminLoginController.java │ │ │ ├── BusController.java │ │ │ ├── FeedbackController.java │ │ │ ├── ReservationController.java │ │ │ ├── RouteController.java │ │ │ ├── UserController.java │ │ │ └── UserLoginController.java │ │ │ ├── exception │ │ │ ├── AdminException.java │ │ │ ├── BusException.java │ │ │ ├── FeedBackException.java │ │ │ ├── GlobalExceptionHandler.java │ │ │ ├── LoginException.java │ │ │ ├── MyErrorDetails.java │ │ │ ├── ReservationException.java │ │ │ ├── RouteException.java │ │ │ └── UserException.java │ │ │ ├── model │ │ │ ├── Admin.java │ │ │ ├── AdminLoginDTO.java │ │ │ ├── Bus.java │ │ │ ├── CurrentAdminSession.java │ │ │ ├── CurrentUserSession.java │ │ │ ├── Feedback.java │ │ │ ├── Reservation.java │ │ │ ├── ReservationDTO.java │ │ │ ├── Route.java │ │ │ ├── User.java │ │ │ └── UserLoginDTO.java │ │ │ ├── repository │ │ │ ├── AdminRepository.java │ │ │ ├── BusRepository.java │ │ │ ├── CurrentAdminSessionRepository.java │ │ │ ├── CurrentUserSessionRepository.java │ │ │ ├── FeedbackRepository.java │ │ │ ├── ReservationRepository.java │ │ │ ├── RouteRepository.java │ │ │ └── UserRepository.java │ │ │ └── service │ │ │ ├── AdminLoginService.java │ │ │ ├── AdminLoginServiceImpl.java │ │ │ ├── AdminService.java │ │ │ ├── AdminServiceImpl.java │ │ │ ├── BusService.java │ │ │ ├── BusServiceImpl.java │ │ │ ├── FeedbackService.java │ │ │ ├── FeedbackServiceImpl.java │ │ │ ├── ReservationService.java │ │ │ ├── ReservationServiceImpl.java │ │ │ ├── RouteService.java │ │ │ ├── RouteServiceImpl.java │ │ │ ├── UserLoginService.java │ │ │ ├── UserLoginServiceImpl.java │ │ │ ├── UserService.java │ │ │ └── UserServiceImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── safar │ └── BusReservationApplicationTests.java ├── FrontEnd ├── admin.html ├── adminBuses.html ├── adminLogin.html ├── adminReservation.html ├── adminRoutes.html ├── adminUsers.html ├── adminfeedback.html ├── css │ ├── AdminLogin.css │ ├── admin.css │ ├── adminUser.css │ ├── button1.css │ ├── deletebutton.css │ ├── home.css │ ├── input1.css │ ├── login.css │ ├── pop.css │ └── table.css ├── data │ ├── busimg.jpeg │ ├── eye.png │ ├── logo.png │ └── trip.jpg ├── home.html ├── js │ ├── AdminLogin.js │ ├── admin.js │ ├── adminBuses.js │ ├── adminFeedBack.js │ ├── adminLogout.js │ ├── adminReservation.js │ ├── adminRoute.js │ ├── adminUser.js │ ├── home.js │ ├── modeToggle.js │ └── signup.js └── login.html └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /.metadata/ 2 | -------------------------------------------------------------------------------- /Backend/.gitignore: -------------------------------------------------------------------------------- 1 | /.metadata/ 2 | -------------------------------------------------------------------------------- /Backend/bus_reservation/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Backend/bus_reservation/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/Backend/bus_reservation/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Backend/bus_reservation/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar 19 | -------------------------------------------------------------------------------- /Backend/bus_reservation/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /usr/local/etc/mavenrc ] ; then 40 | . /usr/local/etc/mavenrc 41 | fi 42 | 43 | if [ -f /etc/mavenrc ] ; then 44 | . /etc/mavenrc 45 | fi 46 | 47 | if [ -f "$HOME/.mavenrc" ] ; then 48 | . "$HOME/.mavenrc" 49 | fi 50 | 51 | fi 52 | 53 | # OS specific support. $var _must_ be set to either true or false. 54 | cygwin=false; 55 | darwin=false; 56 | mingw=false 57 | case "`uname`" in 58 | CYGWIN*) cygwin=true ;; 59 | MINGW*) mingw=true;; 60 | Darwin*) darwin=true 61 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 62 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 63 | if [ -z "$JAVA_HOME" ]; then 64 | if [ -x "/usr/libexec/java_home" ]; then 65 | export JAVA_HOME="`/usr/libexec/java_home`" 66 | else 67 | export JAVA_HOME="/Library/Java/Home" 68 | fi 69 | fi 70 | ;; 71 | esac 72 | 73 | if [ -z "$JAVA_HOME" ] ; then 74 | if [ -r /etc/gentoo-release ] ; then 75 | JAVA_HOME=`java-config --jre-home` 76 | fi 77 | fi 78 | 79 | if [ -z "$M2_HOME" ] ; then 80 | ## resolve links - $0 may be a link to maven's home 81 | PRG="$0" 82 | 83 | # need this for relative symlinks 84 | while [ -h "$PRG" ] ; do 85 | ls=`ls -ld "$PRG"` 86 | link=`expr "$ls" : '.*-> \(.*\)$'` 87 | if expr "$link" : '/.*' > /dev/null; then 88 | PRG="$link" 89 | else 90 | PRG="`dirname "$PRG"`/$link" 91 | fi 92 | done 93 | 94 | saveddir=`pwd` 95 | 96 | M2_HOME=`dirname "$PRG"`/.. 97 | 98 | # make it fully qualified 99 | M2_HOME=`cd "$M2_HOME" && pwd` 100 | 101 | cd "$saveddir" 102 | # echo Using m2 at $M2_HOME 103 | fi 104 | 105 | # For Cygwin, ensure paths are in UNIX format before anything is touched 106 | if $cygwin ; then 107 | [ -n "$M2_HOME" ] && 108 | M2_HOME=`cygpath --unix "$M2_HOME"` 109 | [ -n "$JAVA_HOME" ] && 110 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 111 | [ -n "$CLASSPATH" ] && 112 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 113 | fi 114 | 115 | # For Mingw, ensure paths are in UNIX format before anything is touched 116 | if $mingw ; then 117 | [ -n "$M2_HOME" ] && 118 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 119 | [ -n "$JAVA_HOME" ] && 120 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 121 | fi 122 | 123 | if [ -z "$JAVA_HOME" ]; then 124 | javaExecutable="`which javac`" 125 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 126 | # readlink(1) is not available as standard on Solaris 10. 127 | readLink=`which readlink` 128 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 129 | if $darwin ; then 130 | javaHome="`dirname \"$javaExecutable\"`" 131 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 132 | else 133 | javaExecutable="`readlink -f \"$javaExecutable\"`" 134 | fi 135 | javaHome="`dirname \"$javaExecutable\"`" 136 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 137 | JAVA_HOME="$javaHome" 138 | export JAVA_HOME 139 | fi 140 | fi 141 | fi 142 | 143 | if [ -z "$JAVACMD" ] ; then 144 | if [ -n "$JAVA_HOME" ] ; then 145 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 146 | # IBM's JDK on AIX uses strange locations for the executables 147 | JAVACMD="$JAVA_HOME/jre/sh/java" 148 | else 149 | JAVACMD="$JAVA_HOME/bin/java" 150 | fi 151 | else 152 | JAVACMD="`\\unset -f command; \\command -v java`" 153 | fi 154 | fi 155 | 156 | if [ ! -x "$JAVACMD" ] ; then 157 | echo "Error: JAVA_HOME is not defined correctly." >&2 158 | echo " We cannot execute $JAVACMD" >&2 159 | exit 1 160 | fi 161 | 162 | if [ -z "$JAVA_HOME" ] ; then 163 | echo "Warning: JAVA_HOME environment variable is not set." 164 | fi 165 | 166 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 167 | 168 | # traverses directory structure from process work directory to filesystem root 169 | # first directory with .mvn subdirectory is considered project base directory 170 | find_maven_basedir() { 171 | 172 | if [ -z "$1" ] 173 | then 174 | echo "Path not specified to find_maven_basedir" 175 | return 1 176 | fi 177 | 178 | basedir="$1" 179 | wdir="$1" 180 | while [ "$wdir" != '/' ] ; do 181 | if [ -d "$wdir"/.mvn ] ; then 182 | basedir=$wdir 183 | break 184 | fi 185 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 186 | if [ -d "${wdir}" ]; then 187 | wdir=`cd "$wdir/.."; pwd` 188 | fi 189 | # end of workaround 190 | done 191 | echo "${basedir}" 192 | } 193 | 194 | # concatenates all lines of a file 195 | concat_lines() { 196 | if [ -f "$1" ]; then 197 | echo "$(tr -s '\n' ' ' < "$1")" 198 | fi 199 | } 200 | 201 | BASE_DIR=`find_maven_basedir "$(pwd)"` 202 | if [ -z "$BASE_DIR" ]; then 203 | exit 1; 204 | fi 205 | 206 | ########################################################################################## 207 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 208 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 209 | ########################################################################################## 210 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Found .mvn/wrapper/maven-wrapper.jar" 213 | fi 214 | else 215 | if [ "$MVNW_VERBOSE" = true ]; then 216 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 217 | fi 218 | if [ -n "$MVNW_REPOURL" ]; then 219 | jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 220 | else 221 | jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 222 | fi 223 | while IFS="=" read key value; do 224 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 225 | esac 226 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 227 | if [ "$MVNW_VERBOSE" = true ]; then 228 | echo "Downloading from: $jarUrl" 229 | fi 230 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 231 | if $cygwin; then 232 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 233 | fi 234 | 235 | if command -v wget > /dev/null; then 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Found wget ... using wget" 238 | fi 239 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 240 | wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 241 | else 242 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 243 | fi 244 | elif command -v curl > /dev/null; then 245 | if [ "$MVNW_VERBOSE" = true ]; then 246 | echo "Found curl ... using curl" 247 | fi 248 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 249 | curl -o "$wrapperJarPath" "$jarUrl" -f 250 | else 251 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 252 | fi 253 | 254 | else 255 | if [ "$MVNW_VERBOSE" = true ]; then 256 | echo "Falling back to using Java to download" 257 | fi 258 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 259 | # For Cygwin, switch paths to Windows format before running javac 260 | if $cygwin; then 261 | javaClass=`cygpath --path --windows "$javaClass"` 262 | fi 263 | if [ -e "$javaClass" ]; then 264 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 265 | if [ "$MVNW_VERBOSE" = true ]; then 266 | echo " - Compiling MavenWrapperDownloader.java ..." 267 | fi 268 | # Compiling the Java class 269 | ("$JAVA_HOME/bin/javac" "$javaClass") 270 | fi 271 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 272 | # Running the downloader 273 | if [ "$MVNW_VERBOSE" = true ]; then 274 | echo " - Running MavenWrapperDownloader.java ..." 275 | fi 276 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 277 | fi 278 | fi 279 | fi 280 | fi 281 | ########################################################################################## 282 | # End of extension 283 | ########################################################################################## 284 | 285 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 286 | if [ "$MVNW_VERBOSE" = true ]; then 287 | echo $MAVEN_PROJECTBASEDIR 288 | fi 289 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 290 | 291 | # For Cygwin, switch paths to Windows format before running java 292 | if $cygwin; then 293 | [ -n "$M2_HOME" ] && 294 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 295 | [ -n "$JAVA_HOME" ] && 296 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 297 | [ -n "$CLASSPATH" ] && 298 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 299 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 300 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 301 | fi 302 | 303 | # Provide a "standardized" way to retrieve the CLI args that will 304 | # work with both Windows and non-Windows executions. 305 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 306 | export MAVEN_CMD_LINE_ARGS 307 | 308 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 309 | 310 | exec "$JAVACMD" \ 311 | $MAVEN_OPTS \ 312 | $MAVEN_DEBUG_OPTS \ 313 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 314 | "-Dmaven.home=${M2_HOME}" \ 315 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 316 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 317 | -------------------------------------------------------------------------------- /Backend/bus_reservation/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /Backend/bus_reservation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.0.6 9 | 10 | 11 | com.bus 12 | bus_reservation 13 | 0.0.1-SNAPSHOT 14 | bus_reservation 15 | Bus Reservation System Project 16 | 17 | 17 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-validation 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-devtools 36 | runtime 37 | true 38 | 39 | 40 | com.mysql 41 | mysql-connector-j 42 | runtime 43 | 44 | 45 | org.projectlombok 46 | lombok 47 | true 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-test 52 | test 53 | 54 | 55 | 56 | 57 | 58 | org.springdoc 59 | springdoc-openapi-starter-webmvc-ui 60 | 2.1.0 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-maven-plugin 71 | 72 | 73 | 74 | org.projectlombok 75 | lombok 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/BusReservationApplication.java: -------------------------------------------------------------------------------- 1 | package com.safar; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class BusReservationApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(BusReservationApplication.class, args); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.model.Admin; 5 | import com.safar.service.AdminService; 6 | import jakarta.validation.Valid; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | @RestController 13 | @CrossOrigin(origins = "*") 14 | @RequestMapping("/safar") 15 | public class AdminController { 16 | 17 | @Autowired 18 | private AdminService service; 19 | 20 | @PostMapping("/admin/register") 21 | public ResponseEntity registerAdmin(@Valid @RequestBody Admin admin) throws AdminException { 22 | System.out.println("Admin Controller: " + admin); 23 | Admin savedAdmin = service.createAdmin(admin); 24 | return new ResponseEntity<>(savedAdmin, HttpStatus.CREATED); 25 | } 26 | 27 | @PutMapping("/admin/update") 28 | public ResponseEntity updateAdmin(@Valid @RequestBody Admin admin, @RequestParam(required = false) String key) throws AdminException { 29 | Admin updatedAdmin = service.updateAdmin(admin, key); 30 | return new ResponseEntity<>(updatedAdmin, HttpStatus.OK); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/AdminLoginController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.LoginException; 5 | import com.safar.model.AdminLoginDTO; 6 | import com.safar.model.CurrentAdminSession; 7 | import com.safar.service.AdminLoginService; 8 | import jakarta.validation.Valid; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | @RestController 15 | @CrossOrigin(origins = "*") 16 | @RequestMapping("/safar") 17 | public class AdminLoginController { 18 | 19 | @Autowired 20 | private AdminLoginService loginService; 21 | 22 | @PostMapping("/admin/login") 23 | public ResponseEntity loginAdmin(@RequestBody AdminLoginDTO loginDTO) throws AdminException, LoginException { 24 | // System.out.println(loginDTO); 25 | CurrentAdminSession currentAdminSession = loginService.adminLogin(loginDTO); 26 | return new ResponseEntity<>(currentAdminSession, HttpStatus.ACCEPTED); 27 | } 28 | 29 | @PostMapping("/admin/logout") 30 | public String logoutAdmin(@RequestParam(required = false) String key) throws LoginException { 31 | return loginService.adminLogout(key); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/BusController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.BusException; 5 | import com.safar.model.Bus; 6 | import com.safar.service.BusService; 7 | import jakarta.validation.Valid; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.List; 14 | 15 | @RestController 16 | @CrossOrigin(origins = "*") 17 | @RequestMapping("/safar") 18 | public class BusController { 19 | 20 | @Autowired 21 | private BusService busServ; 22 | 23 | //admin endpoints 24 | 25 | @PostMapping("/admin/bus/add") 26 | public ResponseEntity addBusHandler(@Valid @RequestBody Bus bus,@RequestParam(required = false) String key)throws BusException , AdminException { 27 | 28 | Bus newBus = busServ.addBus(bus,key); 29 | return new ResponseEntity<>(newBus, HttpStatus.CREATED); 30 | 31 | 32 | } 33 | 34 | @PutMapping("/admin/bus/update") 35 | public ResponseEntity updateBusHandler(@Valid @RequestBody Bus bus,@RequestParam(required = false) String key) throws BusException, AdminException{ 36 | Bus newBus = busServ.updateBus(bus,key); 37 | return new ResponseEntity<>(newBus,HttpStatus.OK); 38 | } 39 | 40 | 41 | 42 | @DeleteMapping("/admin/bus/delete/{busId}") 43 | public ResponseEntity deleteBusByBusIdHandler(@PathVariable("busId") Integer busId,@RequestParam(required = false) String key) throws BusException, AdminException{ 44 | Bus deletedBus = busServ.deleteBus(busId,key); 45 | return new ResponseEntity<>(deletedBus,HttpStatus.OK); 46 | } 47 | 48 | //shared endpoints (user and admin both) 49 | @GetMapping("/bus/all") 50 | public ResponseEntity> getAllBusesHandler()throws BusException{ 51 | List allBuses = busServ.viewAllBuses(); 52 | return new ResponseEntity<>(allBuses,HttpStatus.OK); 53 | } 54 | 55 | @GetMapping("/bus/{busId}") 56 | public ResponseEntity getBusByIdHandler(@PathVariable("busId") Integer busId) throws BusException{ 57 | Bus bus = busServ.viewBus(busId); 58 | return new ResponseEntity<>(bus,HttpStatus.OK); 59 | } 60 | 61 | @GetMapping("/bus/type/{busType}") 62 | public ResponseEntity> getBusesByBusTypeHandler(@PathVariable("busType") String busType) throws BusException{ 63 | List busList = busServ.viewBusByBusType(busType); 64 | return new ResponseEntity<>(busList,HttpStatus.OK); 65 | } 66 | } 67 | 68 | // format for sending post request 69 | //{ 70 | // "busName": "16thBus", 71 | // "driverName": "yash", 72 | // "busType": "ac", 73 | // "routeFrom": "mumbai", 74 | // "routeTo": "lucknow", 75 | // "busJourneyDate": "2023-05-08", 76 | // "arrivalTime":"09:00:00", 77 | // "departureTime":"12:00:00", 78 | // "seats": 35, 79 | // "availableSeats": 35, 80 | // "fare": 350, 81 | // "route": { 82 | // "routeFrom": "a", 83 | // "routeTo": "b", 84 | // "distance": 2000 85 | // } 86 | // } -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/FeedbackController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | import java.util.List; 4 | import jakarta.validation.Valid; 5 | 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import com.safar.exception.BusException; 14 | import com.safar.exception.FeedBackException; 15 | import com.safar.exception.UserException; 16 | import com.safar.model.Feedback; 17 | import com.safar.service.FeedbackService; 18 | 19 | 20 | @RestController 21 | @CrossOrigin(origins = "*") 22 | @RequestMapping("/safar") 23 | public class FeedbackController { 24 | 25 | @Autowired 26 | private FeedbackService feedbackService; 27 | 28 | @PostMapping("/user/feedback/add/{busId}") 29 | public ResponseEntity addFeedback(@Valid @RequestBody Feedback feedback, 30 | @PathVariable("busId") Integer busId, 31 | @RequestParam(required = false) String key) throws UserException,BusException{ 32 | 33 | Feedback feedback2 = feedbackService.addFeedBack(feedback,busId,key); 34 | 35 | return new ResponseEntity(feedback2,HttpStatus.ACCEPTED); 36 | 37 | } 38 | 39 | 40 | 41 | @PutMapping("/user/feedback/update") 42 | public ResponseEntity updateFeedback(@Valid @RequestBody Feedback feedback,@RequestParam(required = false) String key) throws FeedBackException, UserException { 43 | 44 | Feedback feedback2 = feedbackService.updateFeedBack(feedback,key); 45 | 46 | return new ResponseEntity(feedback2,HttpStatus.ACCEPTED); 47 | 48 | } 49 | 50 | @DeleteMapping("/user/feedback/delete/{id}") 51 | public ResponseEntity deleteFeedback(@PathVariable("id") Integer feedbackId,@RequestParam(required = false) String key) throws FeedBackException, UserException { 52 | 53 | Feedback feedback2 = feedbackService.deleteFeedBack(feedbackId,key); 54 | 55 | return new ResponseEntity(feedback2,HttpStatus.ACCEPTED); 56 | 57 | } 58 | 59 | 60 | // viewFeedback 61 | 62 | @GetMapping("/feedback/{id}") 63 | public ResponseEntity viewFeedback(@PathVariable("id") Integer ID) throws FeedBackException { 64 | 65 | Feedback feedback2 = feedbackService.viewFeedback(ID); 66 | 67 | return new ResponseEntity(feedback2,HttpStatus.ACCEPTED); 68 | 69 | } 70 | 71 | @GetMapping("/feedback/all") 72 | public ResponseEntity> viewFeedbackAll() throws FeedBackException { 73 | 74 | List feedback2 = feedbackService.viewFeedbackAll(); 75 | 76 | return new ResponseEntity>(feedback2,HttpStatus.ACCEPTED); 77 | 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/ReservationController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | 4 | import com.safar.exception.ReservationException; 5 | import com.safar.model.Reservation; 6 | import com.safar.model.ReservationDTO; 7 | import com.safar.service.ReservationService; 8 | import jakarta.validation.Valid; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import java.util.List; 15 | 16 | @RestController 17 | @CrossOrigin(origins = "*") 18 | @RequestMapping("/safar") 19 | public class ReservationController { 20 | @Autowired 21 | private ReservationService service; 22 | 23 | @PostMapping("/user/reservation/add") 24 | public ResponseEntity addReservation(@Valid @RequestBody ReservationDTO dto, @RequestParam(required = false) String key) throws ReservationException { 25 | Reservation reservation = service.addReservation(dto, key); 26 | 27 | return new ResponseEntity<>(reservation, HttpStatus.CREATED); 28 | } 29 | 30 | @PutMapping("/user/reservation/update/{rid}") 31 | public ResponseEntity updateReservation(@Valid @RequestBody ReservationDTO dto, @RequestParam(required = false) String key, @PathVariable Integer rid) throws ReservationException{ 32 | Reservation reservation = service.updateReservation(rid, dto, key); 33 | 34 | return new ResponseEntity<>(reservation, HttpStatus.OK); 35 | } 36 | 37 | @DeleteMapping("/user/reservation/delete/{rid}") 38 | public ResponseEntity deleteReservation( @RequestParam(required = false) String key, @PathVariable Integer rid) throws ReservationException{ 39 | Reservation reservation = service.deleteReservation(rid, key); 40 | 41 | return new ResponseEntity<>(reservation, HttpStatus.ACCEPTED); 42 | } 43 | 44 | @GetMapping("/reservation/{rid}") 45 | public ResponseEntity viewReservationById(@PathVariable Integer rid, @RequestParam(required = false) String key) throws ReservationException { 46 | Reservation reservation = service.viewReservation(rid, key); 47 | 48 | return new ResponseEntity<>(reservation, HttpStatus.FOUND); 49 | } 50 | 51 | @GetMapping("/reservation/all") 52 | public ResponseEntity> viewAllReservation(@RequestParam(required = false) String key) throws ReservationException { 53 | List reservations = service.getAllReservation(key); 54 | 55 | return new ResponseEntity<>(reservations, HttpStatus.FOUND); 56 | } 57 | 58 | @GetMapping("/user/reservation/{uid}") 59 | public ResponseEntity> viewReservationsByUserId(@PathVariable Integer uid, @RequestParam(required = false) String key) throws ReservationException{ 60 | List reservations = service.viewReservationByUerId(uid, key); 61 | 62 | return new ResponseEntity<>(reservations, HttpStatus.FOUND); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/RouteController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import com.safar.exception.AdminException; 11 | import com.safar.exception.RouteException; 12 | import com.safar.model.Route; 13 | import com.safar.service.RouteService; 14 | 15 | import jakarta.validation.Valid; 16 | 17 | @RestController 18 | @CrossOrigin(origins = "*") 19 | @RequestMapping("/safar") 20 | public class RouteController { 21 | 22 | @Autowired 23 | private RouteService routeService; 24 | 25 | @PostMapping("/admin/route/add") 26 | public ResponseEntity addRoute(@Valid @RequestBody Route route,@RequestParam(required = false) String key) throws RouteException, AdminException{ 27 | 28 | Route newRoute= routeService.addRoute(route, key); 29 | 30 | return new ResponseEntity(newRoute,HttpStatus.ACCEPTED); 31 | } 32 | 33 | @GetMapping("/route/all") 34 | public ResponseEntity> getAllRouteHandler() throws RouteException{ 35 | 36 | List route= routeService.viewAllRoute(); 37 | 38 | return new ResponseEntity<>(route,HttpStatus.OK); 39 | } 40 | 41 | 42 | @GetMapping("/route/{routeID}") 43 | public ResponseEntity getAllRouteByRouteIdHandler( @PathVariable Integer routeID) throws RouteException{ 44 | 45 | Route route= routeService.viewRoute(routeID); 46 | 47 | return new ResponseEntity<>(route,HttpStatus.OK); 48 | } 49 | 50 | 51 | 52 | @PutMapping("/admin/route/update") 53 | public ResponseEntity updateRoute(@Valid @RequestBody Route route,@RequestParam(required = false) String key) throws RouteException, AdminException{ 54 | 55 | Route newRoute= routeService.updateRoute(route,key); 56 | 57 | return new ResponseEntity(newRoute,HttpStatus.OK); 58 | } 59 | 60 | @DeleteMapping("/admin/route/delete/{routeID}") 61 | public ResponseEntity DeleteRoute(@PathVariable Integer routeID,@RequestParam(required = false) String key) throws RouteException, AdminException{ 62 | 63 | Route route = routeService.deleteRoute(routeID,key); 64 | 65 | return new ResponseEntity(route,HttpStatus.OK); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.UserException; 5 | import com.safar.model.User; 6 | import com.safar.service.UserService; 7 | import jakarta.validation.Valid; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.List; 14 | 15 | @RestController 16 | @CrossOrigin(origins = "*") 17 | @RequestMapping("/safar") 18 | public class UserController { 19 | 20 | @Autowired 21 | private UserService userService; 22 | 23 | @GetMapping("/hello") 24 | public String hello() { 25 | return "Hello"; 26 | } 27 | 28 | @PostMapping("/user/register") 29 | public ResponseEntity registerUser(@Valid @RequestBody User user) throws UserException { 30 | User savedUser = userService.createUser(user); 31 | return new ResponseEntity(savedUser, HttpStatus.CREATED); 32 | } 33 | 34 | @PutMapping("/user/update") 35 | public ResponseEntity updateUser(@Valid @RequestBody User user, @RequestParam(required = false) String key) throws UserException { 36 | User updatedUser = userService.updateUser(user, key); 37 | return new ResponseEntity(updatedUser, HttpStatus.OK); 38 | } 39 | 40 | @DeleteMapping("/admin/user/delete/{userId}") 41 | public ResponseEntity deleteUser(@PathVariable("userId") Integer userId, @RequestParam(required = false) String key) throws UserException, AdminException { 42 | User deletedUser= userService.deleteUser(userId, key); 43 | return new ResponseEntity(deletedUser, HttpStatus.OK); 44 | } 45 | 46 | @GetMapping("/admin/user/{userId}") 47 | public ResponseEntity viewUserById(@PathVariable("userId") Integer userId, @RequestParam(required = false) String key) throws UserException, AdminException { 48 | User user= userService.viewUserById(userId, key); 49 | return new ResponseEntity(user, HttpStatus.FOUND); 50 | } 51 | 52 | @GetMapping("/admin/user/all") 53 | public ResponseEntity> viewAllUser(@RequestParam(required = false) String key) throws UserException, AdminException { 54 | List list = userService.viewAllUser(key); 55 | return new ResponseEntity>(list, HttpStatus.OK); 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/controller/UserLoginController.java: -------------------------------------------------------------------------------- 1 | package com.safar.controller; 2 | 3 | import com.safar.exception.LoginException; 4 | import com.safar.model.CurrentUserSession; 5 | import com.safar.model.UserLoginDTO; 6 | import com.safar.service.UserLoginService; 7 | import jakarta.validation.Valid; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | @RestController 14 | @CrossOrigin(origins = "*") 15 | @RequestMapping("/safar") 16 | public class UserLoginController { 17 | 18 | @Autowired 19 | private UserLoginService userLoginService; 20 | 21 | @PostMapping("/user/login") 22 | public ResponseEntity logInUser(@Valid @RequestBody UserLoginDTO loginDTO) throws LoginException { 23 | CurrentUserSession currentUserSession = userLoginService.userLogin(loginDTO); 24 | return new ResponseEntity(currentUserSession, HttpStatus.ACCEPTED ); 25 | } 26 | 27 | @PostMapping("/user/logout") 28 | public String logoutUser(@RequestParam(required = false) String key) throws LoginException { 29 | return userLoginService.userLogout(key); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/AdminException.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | public class AdminException extends Exception{ 4 | public AdminException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/BusException.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | public class BusException extends Exception{ 4 | public BusException(){} 5 | public BusException(String msg){super(msg);} 6 | } 7 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/FeedBackException.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | public class FeedBackException extends Exception{ 4 | 5 | 6 | public FeedBackException() { 7 | // TODO Auto-generated constructor stub 8 | } 9 | 10 | 11 | public FeedBackException(String msg) { 12 | super(msg); 13 | // TODO Auto-generated constructor stub 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.MethodArgumentNotValidException; 6 | import org.springframework.web.bind.annotation.ControllerAdvice; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.context.request.WebRequest; 9 | 10 | import java.time.LocalDateTime; 11 | 12 | @ControllerAdvice 13 | public class GlobalExceptionHandler { 14 | @ExceptionHandler(Exception.class) 15 | public ResponseEntity exceptionHandler(Exception e, WebRequest w){ 16 | MyErrorDetails details = new MyErrorDetails(); 17 | details.setTime(LocalDateTime.now()); 18 | details.setMessage(e.getMessage()); 19 | details.setDetails(w.getDescription(false)); 20 | return new ResponseEntity<>(details, HttpStatus.BAD_REQUEST); 21 | } 22 | 23 | @ExceptionHandler(MethodArgumentNotValidException.class) 24 | public ResponseEntity MethodArgExceptionHandler(MethodArgumentNotValidException m){ 25 | MyErrorDetails details = new MyErrorDetails(); 26 | details.setTime(LocalDateTime.now()); 27 | details.setMessage("Validation Error"); 28 | details.setDetails(m.getBindingResult().getFieldError().getDefaultMessage()); 29 | return new ResponseEntity<>(details, HttpStatus.BAD_REQUEST); 30 | } 31 | 32 | //Handling the busException here 33 | @ExceptionHandler(BusException.class) 34 | public ResponseEntity busExceptionHandler(BusException busEx, WebRequest webReq){ 35 | MyErrorDetails error = new MyErrorDetails(LocalDateTime.now(),busEx.getMessage(),webReq.getDescription(false)); 36 | return new ResponseEntity<>(error,HttpStatus.BAD_REQUEST); 37 | } 38 | 39 | @ExceptionHandler(AdminException.class) 40 | public ResponseEntity adminExceptionHandler(AdminException e, WebRequest w){ 41 | MyErrorDetails details = new MyErrorDetails(); 42 | details.setTime(LocalDateTime.now()); 43 | details.setMessage(e.getMessage()); 44 | details.setDetails(w.getDescription(false)); 45 | return new ResponseEntity<>(details, HttpStatus.BAD_REQUEST); 46 | } 47 | 48 | @ExceptionHandler(LoginException.class) 49 | public ResponseEntity loginExceptionHandler(LoginException e, WebRequest w){ 50 | MyErrorDetails details = new MyErrorDetails(); 51 | details.setTime(LocalDateTime.now()); 52 | details.setMessage(e.getMessage()); 53 | details.setDetails(w.getDescription(false)); 54 | return new ResponseEntity<>(details, HttpStatus.BAD_REQUEST); 55 | 56 | } 57 | 58 | @ExceptionHandler 59 | public ResponseEntity reservationExceptionHandler(ReservationException ex, WebRequest w){ 60 | MyErrorDetails details = new MyErrorDetails(); 61 | details.setMessage(ex.getMessage()); 62 | details.setTime(LocalDateTime.now()); 63 | details.setDetails(w.getDescription(false)); 64 | 65 | return new ResponseEntity<>(details, HttpStatus.BAD_REQUEST); 66 | } 67 | 68 | @ExceptionHandler(UserException.class) 69 | public ResponseEntity userExceptionHandler(UserException e, WebRequest w){ 70 | MyErrorDetails details = new MyErrorDetails(); 71 | details.setTime(LocalDateTime.now()); 72 | details.setMessage(e.getMessage()); 73 | details.setDetails(w.getDescription(false)); 74 | return new ResponseEntity<>(details, HttpStatus.BAD_REQUEST); 75 | } 76 | 77 | @ExceptionHandler(RouteException.class) 78 | public ResponseEntity routeExceptionHandler(RouteException e,WebRequest w){ 79 | 80 | MyErrorDetails details = new MyErrorDetails(); 81 | details.setTime(LocalDateTime.now()); 82 | details.setMessage(e.getMessage()); 83 | details.setDetails(w.getDescription(false)); 84 | return new ResponseEntity<>(details, HttpStatus.BAD_REQUEST); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/LoginException.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | public class LoginException extends Exception{ 4 | public LoginException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/MyErrorDetails.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import lombok.EqualsAndHashCode; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | 11 | 12 | import java.time.LocalDateTime; 13 | 14 | 15 | 16 | @Data 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class MyErrorDetails { 20 | private LocalDateTime time; 21 | private String message; 22 | private String details; 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/ReservationException.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | public class ReservationException extends Exception{ 4 | public ReservationException(){} 5 | 6 | public ReservationException(String message){ 7 | super(message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/RouteException.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | public class RouteException extends Exception{ 4 | 5 | public RouteException(String message) { 6 | super(message); 7 | } 8 | 9 | public RouteException() { 10 | 11 | } 12 | } 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/exception/UserException.java: -------------------------------------------------------------------------------- 1 | package com.safar.exception; 2 | 3 | public class UserException extends Exception{ 4 | public UserException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/Admin.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.GeneratedValue; 6 | import jakarta.persistence.GenerationType; 7 | import jakarta.persistence.Id; 8 | import jakarta.validation.constraints.Email; 9 | import jakarta.validation.constraints.NotBlank; 10 | import jakarta.validation.constraints.NotNull; 11 | import jakarta.validation.constraints.Pattern; 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @Entity 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | public class Admin { 21 | @Id 22 | @GeneratedValue(strategy = GenerationType.AUTO) 23 | private Integer adminID; 24 | 25 | @NotNull(message = "Name can not be null!") 26 | @NotBlank(message = "Name can not be blank!") 27 | private String name; 28 | 29 | @Email 30 | @Column(unique = true) 31 | private String email; 32 | 33 | @NotNull(message="Password can not be null!") 34 | @NotBlank(message= "Password can not be blank!") 35 | @Pattern(regexp = "[A-Za-z0-9!@#$%^&*_]{8,15}", message = "Password must be 8-15 characters including alphanumerics and special characters") 36 | private String password; 37 | } 38 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/AdminLoginDTO.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import jakarta.validation.constraints.Email; 4 | import jakarta.validation.constraints.NotBlank; 5 | import jakarta.validation.constraints.NotNull; 6 | import jakarta.validation.constraints.Pattern; 7 | import lombok.Data; 8 | 9 | @Data 10 | public class AdminLoginDTO { 11 | @Email 12 | private String email; 13 | 14 | @NotNull(message="Password can not be null!") 15 | @NotBlank(message= "Password can not be blank!") 16 | @Pattern(regexp = "[A-Za-z0-9!@#$%^&*_]{8,15}", message = "Password must be 8-15 characters including alphanumerics and special characters") 17 | private String password; 18 | } 19 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/Bus.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 5 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 6 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; 7 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; 8 | import jakarta.persistence.*; 9 | import jakarta.validation.constraints.NotBlank; 10 | import jakarta.validation.constraints.NotNull; 11 | import lombok.AllArgsConstructor; 12 | import lombok.Data; 13 | import lombok.NoArgsConstructor; 14 | import org.springframework.format.annotation.DateTimeFormat; 15 | 16 | import java.time.LocalDate; 17 | import java.time.LocalTime; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | @Entity 22 | @Data 23 | @NoArgsConstructor 24 | @AllArgsConstructor 25 | public class Bus { 26 | @Id 27 | @GeneratedValue(strategy = GenerationType.IDENTITY) 28 | private Integer busId; 29 | 30 | @NotBlank(message = "Bus name can't be null/blank, Please provide a valid name first!") 31 | private String busName; 32 | 33 | @NotBlank(message = "Driver name can't be null/blank, Please provide a valid name first!") 34 | private String driverName; 35 | 36 | @NotBlank(message = "Bus Type can't be null/blank, Please provide a valid bus type") 37 | private String busType; 38 | 39 | @NotBlank(message = "Choose a valid starting point.") 40 | private String routeFrom; 41 | 42 | @NotBlank(message = "Choose a valid destination.") 43 | private String routeTo; 44 | 45 | @NotNull(message = "Bus Journey Date can't be null, Please provide correct date") 46 | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) 47 | private LocalDate busJourneyDate; 48 | 49 | @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) 50 | private LocalTime arrivalTime; 51 | 52 | @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) 53 | private LocalTime departureTime; 54 | 55 | @Column(name = "total_seats") 56 | private Integer seats; 57 | 58 | private Integer availableSeats; 59 | 60 | @NotNull(message = "fare can't be null") 61 | private Integer fare; 62 | 63 | @ManyToOne(cascade = CascadeType.ALL) 64 | private Route route; 65 | 66 | @JsonIgnore 67 | @OneToMany(mappedBy = "bus",cascade = CascadeType.ALL) 68 | private List reservationList = new ArrayList<>(); 69 | } 70 | 71 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/CurrentAdminSession.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import lombok.Data; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @Entity 12 | public class CurrentAdminSession { 13 | @Id 14 | @Column(unique = true) 15 | private Integer adminID; 16 | private String aid; 17 | private LocalDateTime time; 18 | } 19 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/CurrentUserSession.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import lombok.Data; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @Entity 12 | public class CurrentUserSession { 13 | @Id 14 | @Column(unique = true) 15 | private Integer userID; 16 | private String uuid; 17 | private LocalDateTime time; 18 | } 19 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/Feedback.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import java.time.LocalDateTime; 4 | 5 | import jakarta.persistence.Entity; 6 | import jakarta.persistence.GeneratedValue; 7 | import jakarta.persistence.GenerationType; 8 | import jakarta.persistence.Id; 9 | import jakarta.persistence.OneToOne; 10 | import jakarta.validation.constraints.Max; 11 | import jakarta.validation.constraints.Min; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | 18 | @Data 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @Entity 22 | public class Feedback { 23 | 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.AUTO) 26 | private Integer feedBackId; 27 | private Integer driverRating; 28 | 29 | @Min(value=1, message="Rating must be in range of 1-5") 30 | @Max(value=5, message="Rating must be in range of 1-5") 31 | private Integer serviceRating; 32 | 33 | @Min(value=1, message="Rating must be in range of 1-5") 34 | @Max(value=5, message="Rating must be in range of 1-5") 35 | private Integer overallRating; 36 | 37 | private String comments; 38 | 39 | private LocalDateTime feedbackDateTime; 40 | 41 | @OneToOne 42 | private User user; 43 | 44 | @OneToOne 45 | private Bus bus; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/Reservation.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.time.LocalDate; 9 | import java.time.LocalTime; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Entity 15 | public class Reservation { 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.AUTO) 18 | private Integer reservationID; 19 | private String status; 20 | private LocalDate date; 21 | private LocalTime time; 22 | 23 | private String source; 24 | private String destination; 25 | private LocalDate journeyDate; 26 | private Integer bookedSeat; 27 | private Integer fare; 28 | 29 | @ManyToOne 30 | private User user; 31 | 32 | @ManyToOne 33 | private Bus bus; 34 | } 35 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/ReservationDTO.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import jakarta.validation.constraints.Min; 5 | import jakarta.validation.constraints.NotBlank; 6 | import jakarta.validation.constraints.NotNull; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | import org.springframework.format.annotation.DateTimeFormat; 11 | 12 | import java.time.LocalDate; 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class ReservationDTO { 18 | @NotNull(message = "Source required to book a reservation") 19 | @NotBlank(message = "Source should not be blanked") 20 | private String source; 21 | 22 | @NotNull(message = "Destination required to book a reservation") 23 | @NotBlank(message = "Destination should not be blanked") 24 | private String destination; 25 | 26 | @NotNull 27 | @JsonFormat(pattern = "yyyy-MM-dd") 28 | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) 29 | private LocalDate journeyDate; 30 | 31 | @Min(1) 32 | private Integer bookedSeat; 33 | } 34 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/Route.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | import jakarta.persistence.*; 9 | import jakarta.validation.constraints.NotBlank; 10 | import jakarta.validation.constraints.NotEmpty; 11 | import jakarta.validation.constraints.NotNull; 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.EqualsAndHashCode; 15 | import lombok.Getter; 16 | import lombok.NoArgsConstructor; 17 | import lombok.Setter; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | import java.util.Objects; 22 | 23 | 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | @EqualsAndHashCode 27 | @Data 28 | @Entity 29 | public class Route { 30 | @Id 31 | @GeneratedValue(strategy = GenerationType.AUTO) 32 | private Integer routeID; 33 | 34 | @NotNull(message = "Start point cannot be null !") 35 | @NotBlank(message = "Start point cannot be blank !") 36 | @NotEmpty(message = "Start point cannot be empty !") 37 | private String routeFrom; 38 | 39 | @NotNull(message = "Destination point cannot be null !") 40 | @NotBlank(message = "Destination point cannot be blank !") 41 | @NotEmpty(message = "Destination point cannot be empty !") 42 | private String routeTo; 43 | private Integer distance; 44 | 45 | @JsonIgnore 46 | @OneToMany(mappedBy = "route", cascade = CascadeType.ALL) 47 | private List busList = new ArrayList<>(); 48 | 49 | 50 | public Route(String routeFrom, String routeTo, Integer distance) { 51 | this.routeFrom = routeFrom; 52 | this.routeTo = routeTo; 53 | this.distance = distance; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/User.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import jakarta.persistence.*; 5 | import jakarta.validation.constraints.*; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | @Data 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | @Entity 17 | public class User { 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.AUTO) 20 | private Integer userID; 21 | 22 | @NotNull(message = "Name cannot be null!") 23 | @NotBlank(message = "Name cannot be blank!") 24 | private String firstName; 25 | private String lastName; 26 | 27 | @NotNull(message="Mobile number cannot be null!") 28 | @NotBlank(message= "Mobile number cannot be blank!") 29 | @Pattern(regexp = "[6789]{1}[0-9]{9}", message = "Enter valid 10 digit mobile number") 30 | @Size(min = 10, max = 10) 31 | private String mobile; 32 | 33 | @Email 34 | private String email; 35 | 36 | @NotNull(message="Password cannot be null!") 37 | @NotBlank(message= "Password cannot be blank!") 38 | @Pattern(regexp = "[A-Za-z0-9!@#$%^&*_]{8,15}", message = "Password must be 8-15 characters including alphanumerics and special characters") 39 | private String password; 40 | 41 | @JsonIgnore 42 | @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) 43 | private List reservationList = new ArrayList<>(); 44 | 45 | @JsonIgnore 46 | @OneToMany(mappedBy = "user") 47 | private List feedbackList = new ArrayList<>(); 48 | } 49 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/model/UserLoginDTO.java: -------------------------------------------------------------------------------- 1 | package com.safar.model; 2 | 3 | import jakarta.validation.constraints.Email; 4 | import jakarta.validation.constraints.NotBlank; 5 | import jakarta.validation.constraints.NotNull; 6 | import jakarta.validation.constraints.Pattern; 7 | import lombok.Data; 8 | 9 | @Data 10 | public class UserLoginDTO { 11 | @Email 12 | private String email; 13 | 14 | @NotNull(message="Password can not be null!") 15 | @NotBlank(message= "Password can not be blank!") 16 | @Pattern(regexp = "[A-Za-z0-9!@#$%^&*_]{8,15}", message = "Password must be 8-15 characters including alphanumerics and special characters") 17 | private String password; 18 | } 19 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/AdminRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | import com.safar.model.Admin; 4 | 5 | import java.util.List; 6 | 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | import org.springframework.stereotype.Repository; 9 | 10 | @Repository 11 | public interface AdminRepository extends JpaRepository { 12 | // public Admin findByEmail(String email); 13 | List findByEmail(String email); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/BusRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | import com.safar.model.Bus; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | import java.util.List; 7 | 8 | @Repository 9 | public interface BusRepository extends JpaRepository { 10 | public List findByBusType(String busType); 11 | 12 | public Bus findByRouteFromAndRouteTo(String routeFrom, String routeTo); 13 | } 14 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/CurrentAdminSessionRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | import com.safar.model.CurrentAdminSession; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public interface CurrentAdminSessionRepository extends JpaRepository { 10 | @Query("select c from CurrentAdminSession c where c.aid=?1") 11 | public CurrentAdminSession findByaid(String aid); 12 | } 13 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/CurrentUserSessionRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | import com.safar.model.CurrentUserSession; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface CurrentUserSessionRepository extends JpaRepository { 9 | public CurrentUserSession findByUuid(String uuid); 10 | } 11 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/FeedbackRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import com.safar.model.Feedback; 8 | 9 | @Repository 10 | public interface FeedbackRepository extends JpaRepository{ 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/ReservationRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | import com.safar.model.Reservation; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface ReservationRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/RouteRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import com.safar.model.Route; 9 | @Repository 10 | public interface RouteRepository extends JpaRepository{ 11 | 12 | public Route findByRouteFromAndRouteTo(String from,String to); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.safar.repository; 2 | 3 | import com.safar.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface UserRepository extends JpaRepository { 9 | public User findByEmail(String email); 10 | } 11 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/AdminLoginService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.LoginException; 5 | import com.safar.model.AdminLoginDTO; 6 | import com.safar.model.CurrentAdminSession; 7 | 8 | public interface AdminLoginService { 9 | public CurrentAdminSession adminLogin(AdminLoginDTO loginDTO) throws LoginException, AdminException; 10 | public String adminLogout(String key) throws LoginException; 11 | } 12 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/AdminLoginServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.LoginException; 5 | import com.safar.model.Admin; 6 | import com.safar.model.AdminLoginDTO; 7 | import com.safar.model.CurrentAdminSession; 8 | import com.safar.repository.AdminRepository; 9 | import com.safar.repository.CurrentAdminSessionRepository; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.time.LocalDateTime; 14 | import java.util.List; 15 | import java.util.Optional; 16 | import java.security.SecureRandom; 17 | import java.util.Base64; 18 | 19 | @Service 20 | public class AdminLoginServiceImpl implements AdminLoginService{ 21 | 22 | @Autowired 23 | private CurrentAdminSessionRepository adminSessionRepository; 24 | 25 | @Autowired 26 | private AdminRepository adminRepository; 27 | 28 | @Override 29 | public CurrentAdminSession adminLogin(AdminLoginDTO loginDTO) throws LoginException, AdminException { 30 | List admins = adminRepository.findByEmail(loginDTO.getEmail()); 31 | 32 | if(admins.isEmpty()) throw new AdminException("Please enter a valid email!"); 33 | 34 | Admin registeredAdmin = admins.get(0); 35 | 36 | if(registeredAdmin == null) throw new AdminException("Please enter a valid email!"); 37 | 38 | Optional loggedInAdmin = adminSessionRepository.findById(registeredAdmin.getAdminID()); 39 | if(loggedInAdmin.isPresent()) throw new LoginException("Admin is already loggedIn!"); 40 | 41 | if(registeredAdmin.getPassword().equals(loginDTO.getPassword())){ 42 | SecureRandom secureRandom = new SecureRandom(); 43 | byte[] keyBytes = new byte[10]; 44 | secureRandom.nextBytes(keyBytes); 45 | 46 | String key = Base64.getEncoder().encodeToString(keyBytes); 47 | 48 | CurrentAdminSession adminSession = new CurrentAdminSession(); 49 | adminSession.setAdminID(registeredAdmin.getAdminID()); 50 | adminSession.setAid(key); 51 | adminSession.setTime(LocalDateTime.now()); 52 | return adminSessionRepository.save(adminSession); 53 | }else 54 | throw new LoginException("Please enter valid password!"); 55 | } 56 | 57 | @Override 58 | public String adminLogout(String key) throws LoginException { 59 | CurrentAdminSession currentAdminSession = adminSessionRepository.findByaid(key); 60 | if(currentAdminSession == null) throw new LoginException("Invalid Admin login key!"); 61 | adminSessionRepository.delete(currentAdminSession); 62 | return "Admin logged out!"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/AdminService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.model.Admin; 5 | 6 | public interface AdminService { 7 | public Admin createAdmin(Admin admin) throws AdminException; 8 | public Admin updateAdmin(Admin admin, String key) throws AdminException; 9 | } 10 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/AdminServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.model.Admin; 5 | import com.safar.model.CurrentAdminSession; 6 | import com.safar.repository.AdminRepository; 7 | import com.safar.repository.CurrentAdminSessionRepository; 8 | 9 | import java.util.List; 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | @Service 15 | public class AdminServiceImpl implements AdminService{ 16 | 17 | @Autowired 18 | private AdminRepository adminRepository; 19 | 20 | @Autowired 21 | private CurrentAdminSessionRepository adminSessionRepository; 22 | 23 | @Override 24 | public Admin createAdmin(Admin admin) throws AdminException{ 25 | // Admin a = adminRepository.findByEmail(admin.getEmail()); 26 | List admins = adminRepository.findByEmail(admin.getEmail()); 27 | 28 | if(!admins.isEmpty()) throw new AdminException("Admin already present with the given email: " + admin.getEmail()); 29 | 30 | return adminRepository.save(admin); 31 | } 32 | 33 | @Override 34 | public Admin updateAdmin(Admin admin, String key) throws AdminException { 35 | CurrentAdminSession adminSession = adminSessionRepository.findByaid(key); 36 | if(adminSession == null) throw new AdminException("Please enter valid key or login first!"); 37 | if(admin.getAdminID() != adminSession.getAdminID()) throw new AdminException("Invalid admin details, please login for updating admin!"); 38 | return adminRepository.save(admin); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/BusService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.BusException; 5 | import com.safar.model.Bus; 6 | 7 | import java.util.List; 8 | 9 | public interface BusService { 10 | //admin methods 11 | public Bus addBus(Bus bus, String key) throws BusException , AdminException; 12 | public Bus updateBus(Bus bus, String key) throws BusException, AdminException; 13 | public Bus deleteBus(Integer busId, String key) throws BusException, AdminException; 14 | 15 | //admin + user methods 16 | public Bus viewBus(Integer busId) throws BusException; 17 | public List viewBusByBusType(String busType) throws BusException; 18 | public List viewAllBuses() throws BusException; 19 | } 20 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/BusServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.BusException; 5 | import com.safar.model.Bus; 6 | import com.safar.model.CurrentAdminSession; 7 | import com.safar.model.Route; 8 | import com.safar.repository.BusRepository; 9 | import com.safar.repository.CurrentAdminSessionRepository; 10 | import com.safar.repository.RouteRepository; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.time.LocalDate; 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | @Service 19 | public class BusServiceImpl implements BusService{ 20 | @Autowired 21 | private BusRepository busRepo; 22 | @Autowired(required = false) 23 | private RouteRepository routeRepo; 24 | @Autowired 25 | private CurrentAdminSessionRepository currAdminRepo; 26 | //admin access methods 27 | @Override 28 | public Bus addBus(Bus bus, String key) throws BusException , AdminException { 29 | CurrentAdminSession admin = currAdminRepo.findByaid(key); 30 | if(admin==null){ 31 | throw new AdminException("Key is not valid! Please provide a valid key."); 32 | } 33 | 34 | //finding and checking route 35 | // Route route = routeRepo.findByRouteFromAndRouteTo(bus.getRouteFrom(),bus.getRouteTo()); 36 | 37 | Route route = new Route(bus.getRouteFrom(),bus.getRouteTo(),bus.getRoute().getDistance()); 38 | if(route==null) throw new BusException("Route is not valid"); 39 | 40 | // routeRepo.save(route); 41 | 42 | //adding route for this new bus 43 | bus.setRoute(route); 44 | 45 | //adding this new bus to the route 46 | route.getBusList().add(bus); 47 | 48 | //saving bus 49 | return busRepo.save(bus); 50 | } 51 | 52 | @Override 53 | public Bus updateBus(Bus bus, String key) throws BusException , AdminException{ 54 | CurrentAdminSession admin = currAdminRepo.findByaid(key); 55 | if(admin==null){ 56 | throw new AdminException("Key is not valid! Please provide a valid key."); 57 | } 58 | Optional bus1 = busRepo.findById(bus.getBusId()); 59 | if(!bus1.isPresent()){ 60 | throw new BusException("Bus doesn't exist with busId: "+ bus.getBusId()); 61 | } 62 | Bus existBus = bus1.get(); 63 | //checking if bus scheduled or not , can be updated only if not scheduled 64 | //if(existBus.getAvailableSeats() != existBus.getSeats()) throw new BusException("Scheduled bus can't be updated"); 65 | 66 | Route route = routeRepo.findByRouteFromAndRouteTo(bus.getRouteFrom(),bus.getRouteTo()); //finding and checking route => pending 67 | 68 | // if(route==null) throw new BusException("Route is not valid"); 69 | if(route == null){ 70 | Route route1 = new Route(bus.getRouteFrom(),bus.getRouteTo(),bus.getRoute().getDistance()); 71 | routeRepo.save(route1); 72 | bus.setRoute(route1); 73 | return busRepo.save(bus); 74 | } 75 | routeRepo.save(route); 76 | bus.setRoute(route); 77 | return busRepo.save(bus); 78 | } 79 | 80 | @Override 81 | public Bus deleteBus(Integer busId, String key) throws BusException, AdminException { 82 | CurrentAdminSession admin = currAdminRepo.findByaid(key); 83 | if(admin==null){ 84 | throw new AdminException("Key is not valid! Please provide a valid key."); 85 | } 86 | 87 | Optional bus = busRepo.findById(busId); 88 | 89 | if(bus.isPresent()){ 90 | Bus existingBus = bus.get(); 91 | //checking if current date is before journey date it means bus scheduled so can't delete / or seats are reserved or not 92 | if(LocalDate.now().isBefore(existingBus.getBusJourneyDate()) && existingBus.getAvailableSeats()!=existingBus.getSeats()){ 93 | throw new BusException("Can't delete scheduled and reserved bus."); 94 | } 95 | 96 | busRepo.delete(existingBus); 97 | return existingBus; 98 | 99 | } else throw new BusException("Bus not found with busId: "+busId); 100 | 101 | } 102 | 103 | 104 | //admin + user access methods 105 | @Override 106 | public List viewAllBuses() throws BusException { 107 | List busList = busRepo.findAll(); 108 | if(busList.isEmpty()){ 109 | throw new BusException("No bus found at this moment. Try again later!"); 110 | } 111 | return busList; 112 | } 113 | 114 | @Override 115 | public Bus viewBus(Integer busId) throws BusException { 116 | Optional existingBus = busRepo.findById(busId); 117 | if(!existingBus.isPresent()){ 118 | throw new BusException("No bus exist with this busId: "+ busId); 119 | } 120 | return existingBus.get(); 121 | } 122 | 123 | @Override 124 | public List viewBusByBusType(String busType) throws BusException { 125 | List busListType = busRepo.findByBusType(busType); 126 | if(busListType.isEmpty()){ 127 | throw new BusException("There are no buses with bus type: "+ busType); 128 | } 129 | return busListType; 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/FeedbackService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import java.util.List; 4 | 5 | import com.safar.exception.BusException; 6 | import com.safar.exception.UserException; 7 | import com.safar.exception.FeedBackException; 8 | import com.safar.model.Feedback; 9 | 10 | 11 | public interface FeedbackService { 12 | 13 | 14 | public Feedback addFeedBack(Feedback feedBack,Integer busId,String key) throws BusException, UserException; 15 | 16 | public Feedback updateFeedBack(Feedback feedback,String key) throws FeedBackException, UserException; 17 | 18 | public Feedback deleteFeedBack(Integer feedbackId, String key)throws FeedBackException,UserException; 19 | 20 | public Feedback viewFeedback(Integer id) throws FeedBackException; 21 | 22 | public List viewFeedbackAll() throws FeedBackException; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/FeedbackServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import java.time.LocalDateTime; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | import com.safar.repository.*; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import com.safar.exception.BusException; 12 | import com.safar.exception.UserException; 13 | import com.safar.model.Bus; 14 | import com.safar.model.CurrentUserSession; 15 | import com.safar.model.User; 16 | 17 | import com.safar.repository.BusRepository; 18 | import com.safar.repository.CurrentUserSessionRepository; 19 | import com.safar.repository.UserRepository; 20 | 21 | import com.safar.exception.FeedBackException; 22 | import com.safar.model.Feedback; 23 | import com.safar.repository.UserRepository; 24 | 25 | @Service 26 | public class FeedbackServiceImpl implements FeedbackService { 27 | 28 | @Autowired 29 | private FeedbackRepository fdao; 30 | 31 | @Autowired 32 | private UserRepository userDao; 33 | 34 | @Autowired 35 | private BusRepository busDao; 36 | 37 | @Autowired 38 | private CurrentUserSessionRepository userSessionDao; 39 | 40 | @Override 41 | public Feedback addFeedBack(Feedback feedBack, Integer busId, String key) throws BusException, UserException { 42 | 43 | CurrentUserSession loggedInUser= userSessionDao.findByUuid(key); 44 | 45 | if(loggedInUser == null) { 46 | throw new UserException("Please provide a valid key to give Feedback!"); 47 | } 48 | 49 | User user = userDao.findById(loggedInUser.getUserID()).orElseThrow(()-> new UserException("User not found!")); 50 | 51 | Optional busOptional = busDao.findById(busId); 52 | if (busOptional.isEmpty()) { 53 | throw new BusException("Bus is not present with Id: "+ busId); 54 | } 55 | 56 | feedBack.setBus(busOptional.get()); 57 | feedBack.setUser(user); 58 | feedBack.setFeedbackDateTime(LocalDateTime.now()); 59 | Feedback savedFeedback = fdao.save(feedBack); 60 | 61 | return savedFeedback; 62 | } 63 | 64 | @Override 65 | public Feedback updateFeedBack(Feedback feedback,String key) throws FeedBackException, UserException { 66 | 67 | CurrentUserSession loggedInUser= userSessionDao.findByUuid(key); 68 | 69 | if(loggedInUser == null) { 70 | throw new UserException("Please provide a valid key to update Feedback!"); 71 | } 72 | 73 | User user = userDao.findById(loggedInUser.getUserID()).orElseThrow(()-> new UserException("User not found!")); 74 | 75 | Optional opt = fdao.findById(feedback.getFeedBackId()); 76 | 77 | if (opt.isPresent()) { 78 | Feedback feedback2 = opt.get(); 79 | Optional busOptional = busDao.findById(feedback2.getBus().getBusId()); 80 | if(!busOptional.isPresent()) throw new FeedBackException("Invalid bus details!"); 81 | feedback.setBus(busOptional.get()); 82 | feedback.setUser(user); 83 | user.getFeedbackList().add(feedback); 84 | feedback.setFeedbackDateTime(LocalDateTime.now()); 85 | 86 | return fdao.save(feedback); 87 | } 88 | else 89 | throw new FeedBackException("No feedback found!"); 90 | } 91 | 92 | @Override 93 | public Feedback viewFeedback(Integer id) throws FeedBackException { 94 | Optional fedOptional = fdao.findById(id); 95 | if (fedOptional.isPresent()) { 96 | return fedOptional.get(); 97 | } 98 | throw new FeedBackException("No feedback found!"); 99 | } 100 | 101 | @Override 102 | public List viewFeedbackAll() throws FeedBackException { 103 | Optional> fedOptional = Optional.of(fdao.findAll()); 104 | if (fedOptional.isPresent()) { 105 | return fedOptional.get(); 106 | } 107 | throw new FeedBackException("No feedbacks found!"); 108 | } 109 | 110 | @Override 111 | public Feedback deleteFeedBack(Integer feedbackId, String key) throws FeedBackException, UserException { 112 | CurrentUserSession loggedInUser= userSessionDao.findByUuid(key); 113 | if(loggedInUser == null) { 114 | throw new UserException("Please provide a valid key to update Feedback!"); 115 | } 116 | 117 | User user = userDao.findById(loggedInUser.getUserID()).orElseThrow(()-> new UserException("User not found!")); 118 | 119 | Optional fedOptional = fdao.findById(feedbackId); 120 | 121 | if (fedOptional.isPresent()) { 122 | Feedback existingFeedback = fedOptional.get(); 123 | fdao.delete(existingFeedback); 124 | return existingFeedback; 125 | } 126 | throw new FeedBackException("No feedback found!"); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/ReservationService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.ReservationException; 4 | import com.safar.exception.UserException; 5 | import com.safar.model.Reservation; 6 | import com.safar.model.ReservationDTO; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public interface ReservationService { 13 | 14 | public Reservation addReservation(ReservationDTO dto, String key) throws ReservationException; 15 | 16 | public Reservation viewReservation(Integer rid, String key) throws ReservationException; 17 | 18 | public List getAllReservation(String key) throws ReservationException; 19 | 20 | public List viewReservationByUerId(Integer uid, String key) throws ReservationException; 21 | 22 | public Reservation deleteReservation(Integer rid, String key) throws ReservationException; 23 | 24 | public Reservation updateReservation(Integer rid, ReservationDTO dto, String key) throws ReservationException; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/ReservationServiceImpl.java: -------------------------------------------------------------------------------- 1 | 2 | package com.safar.service; 3 | 4 | import com.safar.exception.ReservationException; 5 | import com.safar.exception.UserException; 6 | import com.safar.model.*; 7 | import com.safar.repository.*; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.time.LocalDate; 12 | import java.time.LocalTime; 13 | import java.util.List; 14 | import java.util.Optional; 15 | 16 | @Service 17 | public class ReservationServiceImpl implements ReservationService{ 18 | 19 | @Autowired 20 | private ReservationRepository reservationRepository; 21 | 22 | @Autowired 23 | private AdminRepository adminRepository; 24 | 25 | @Autowired 26 | private CurrentAdminSessionRepository currentAdminSessionRepository; 27 | 28 | @Autowired 29 | private CurrentUserSessionRepository currentUserSessionRepository; 30 | 31 | @Autowired 32 | private BusRepository busRepository; 33 | 34 | @Autowired 35 | private UserRepository userRepository; 36 | 37 | @Override 38 | public Reservation addReservation(ReservationDTO dto, String key) throws ReservationException { 39 | 40 | CurrentUserSession userSession = currentUserSessionRepository.findByUuid(key); 41 | 42 | if(userSession == null) throw new ReservationException("Invalid Session key for user"); 43 | 44 | Integer userIdInteger = userSession.getUserID(); 45 | 46 | Optional optional = userRepository.findById(userIdInteger); 47 | 48 | if(optional.isEmpty()) throw new ReservationException("User not found with the session key"); 49 | 50 | User user = optional.get(); 51 | 52 | Bus bus = busRepository.findByRouteFromAndRouteTo(dto.getSource(), dto.getDestination()); 53 | 54 | if(bus == null) throw new ReservationException("Bus not found for the given starting to destination"); 55 | 56 | Integer availableSeats = bus.getAvailableSeats(); 57 | 58 | if(availableSeats < dto.getBookedSeat()) throw new ReservationException("Only " + availableSeats + " seats are available"); 59 | 60 | availableSeats -= dto.getBookedSeat(); 61 | 62 | bus.setAvailableSeats(availableSeats); 63 | 64 | Reservation reservation = new Reservation(); 65 | 66 | if(dto.getJourneyDate().isBefore(LocalDate.now())) throw new ReservationException("Journey Date should be in Future"); 67 | 68 | reservation.setSource(dto.getSource()); 69 | reservation.setDestination(dto.getDestination()); 70 | reservation.setDate(dto.getJourneyDate()); 71 | reservation.setStatus("Successful"); 72 | reservation.setDate(LocalDate.now()); 73 | reservation.setTime(LocalTime.now()); 74 | reservation.setJourneyDate(dto.getJourneyDate()); 75 | reservation.setBus(bus); 76 | reservation.setFare(bus.getFare() * dto.getBookedSeat()); 77 | reservation.setBookedSeat(dto.getBookedSeat()); 78 | reservation.setUser(user); 79 | 80 | return reservationRepository.save(reservation); 81 | } 82 | 83 | @Override 84 | public Reservation viewReservation(Integer rid, String key) throws ReservationException { 85 | 86 | CurrentAdminSession currentAdminSession = currentAdminSessionRepository.findByaid(key); 87 | 88 | // CurrentUserSession currentUserSession = currentUserSessionRepository.findByUuid(key); 89 | 90 | if(currentAdminSession == null) throw new ReservationException("Invalid admin login key"); 91 | 92 | // if(currentUserSession == null) throw new ReservationException("Invalid user login key"); 93 | 94 | Optional optional = reservationRepository.findById(rid); 95 | 96 | if(optional.isEmpty()) throw new ReservationException("Reservation with given id is not found"); 97 | 98 | return optional.get(); 99 | } 100 | 101 | @Override 102 | public List getAllReservation(String key) throws ReservationException { 103 | 104 | CurrentAdminSession session = currentAdminSessionRepository.findByaid(key); 105 | 106 | if(session == null) throw new ReservationException("Please provide valid admin login key"); 107 | 108 | List list = reservationRepository.findAll(); 109 | 110 | if(list.isEmpty()) throw new ReservationException("Reservation Not found"); 111 | 112 | return list; 113 | } 114 | 115 | @Override 116 | public List viewReservationByUerId(Integer uid, String key) throws ReservationException { 117 | 118 | CurrentAdminSession currentAdminSession = currentAdminSessionRepository.findByaid(key); 119 | 120 | CurrentUserSession currentUserSession = currentUserSessionRepository.findByUuid(key); 121 | 122 | if(currentAdminSession == null && currentUserSession == null) throw new ReservationException("Invalid login key"); 123 | 124 | // if(currentUserSession == null) throw new ReservationException("Invalid user login key"); 125 | 126 | Optional optional = userRepository.findById(uid); 127 | 128 | if(optional.isEmpty()) throw new ReservationException("User not find with given user id: " + uid); 129 | 130 | User user = optional.get(); 131 | 132 | List reservations = user.getReservationList(); 133 | 134 | if(reservations.isEmpty()) throw new ReservationException("Reservation not found for this user"); 135 | 136 | return reservations; 137 | } 138 | 139 | @Override 140 | public Reservation deleteReservation(Integer rid, String key) throws ReservationException{ 141 | 142 | CurrentUserSession currentUserSession = currentUserSessionRepository.findByUuid(key); 143 | 144 | if(currentUserSession == null) throw new ReservationException("Invalid session key"); 145 | 146 | Optional optional = reservationRepository.findById(rid); 147 | 148 | if(optional.isEmpty()) throw new ReservationException("Reservation not found with the given id: " + rid); 149 | 150 | Reservation reservation = optional.get(); 151 | 152 | if(reservation.getJourneyDate().isBefore(LocalDate.now())) throw new ReservationException("Reservation Already Expired"); 153 | 154 | Integer n = reservation.getBus().getAvailableSeats(); 155 | 156 | reservation.getBus().setAvailableSeats(n + reservation.getBookedSeat()); 157 | 158 | Bus bus = reservation.getBus(); 159 | 160 | busRepository.save(bus); 161 | reservationRepository.delete(reservation); 162 | 163 | return reservation; 164 | } 165 | 166 | @Override 167 | public Reservation updateReservation(Integer rid, ReservationDTO dto, String key) throws ReservationException { 168 | 169 | CurrentUserSession userSession = currentUserSessionRepository.findByUuid(key); 170 | 171 | if(userSession == null) throw new ReservationException("Invalid Session key for user"); 172 | 173 | Bus bus = busRepository.findByRouteFromAndRouteTo(dto.getSource(), dto.getDestination()); 174 | 175 | if(bus == null) throw new ReservationException("Bus not found for the given starting to destination"); 176 | 177 | Integer availableSeats = bus.getAvailableSeats(); 178 | 179 | if(availableSeats < dto.getBookedSeat()) throw new ReservationException("Only " + availableSeats + " seats are available"); 180 | 181 | availableSeats -= dto.getBookedSeat(); 182 | 183 | bus.setAvailableSeats(availableSeats); 184 | 185 | Optional optional = reservationRepository.findById(rid); 186 | 187 | if(optional.isEmpty()) throw new ReservationException("Reservation not found with the given id: " + rid); 188 | 189 | Reservation reservation = optional.get(); 190 | reservation.setBookedSeat(dto.getBookedSeat()); 191 | reservation.setBus(bus); 192 | reservation.setDate(dto.getJourneyDate()); 193 | reservation.setDestination(dto.getDestination()) ; 194 | reservation.setFare(bus.getFare()); 195 | reservation.setJourneyDate(dto.getJourneyDate()); 196 | reservation.setSource(dto.getSource()); 197 | reservation.setDate(LocalDate.now()); 198 | reservation.setTime(LocalTime.now()); 199 | 200 | reservationRepository.save(reservation); 201 | 202 | return reservation; 203 | } 204 | 205 | 206 | } 207 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/RouteService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import java.util.List; 4 | 5 | import com.safar.exception.AdminException; 6 | import com.safar.exception.RouteException; 7 | import com.safar.model.Route; 8 | 9 | public interface RouteService { 10 | public Route addRoute(Route route,String key) throws RouteException, AdminException; 11 | public List viewAllRoute() throws RouteException; 12 | public Route viewRoute(int routeId) throws RouteException; 13 | public Route updateRoute(Route route,String key) throws RouteException, AdminException; 14 | public Route deleteRoute(int routeID,String key) throws RouteException, AdminException; 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/RouteServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import com.safar.exception.AdminException; 11 | import com.safar.exception.RouteException; 12 | import com.safar.model.Bus; 13 | import com.safar.model.CurrentAdminSession; 14 | import com.safar.model.Route; 15 | import com.safar.repository.AdminRepository; 16 | import com.safar.repository.BusRepository; 17 | import com.safar.repository.CurrentAdminSessionRepository; 18 | import com.safar.repository.RouteRepository; 19 | @Service 20 | public class RouteServiceImpl implements RouteService{ 21 | 22 | @Autowired 23 | private RouteRepository routerepository; 24 | 25 | // @Autowired 26 | // private BusRepository busrepository; 27 | 28 | @Autowired 29 | private CurrentAdminSessionRepository currentddminsessionrepository; 30 | 31 | @Autowired 32 | private AdminRepository adminrepository; 33 | 34 | 35 | 36 | 37 | @Override 38 | public Route addRoute(Route route,String key) throws RouteException, AdminException { 39 | 40 | CurrentAdminSession loggedInAdmin= currentddminsessionrepository.findByaid(key); 41 | 42 | if(loggedInAdmin == null) { 43 | throw new AdminException("Please provide a valid admin key!"); 44 | } 45 | 46 | Route newRoute = routerepository.findByRouteFromAndRouteTo(route.getRouteFrom(), route.getRouteTo()); 47 | 48 | if(newRoute != null) throw new RouteException("Route :"+ newRoute.getRouteFrom() +" to "+ newRoute.getRouteTo()+ " is already present !"); 49 | 50 | List buses = new ArrayList<>(); 51 | 52 | if(route != null) { 53 | route.setBusList(buses); 54 | return routerepository.save(route); 55 | } 56 | else { 57 | throw new RouteException("This root is not available"); 58 | } 59 | } 60 | 61 | @Override 62 | public List viewAllRoute() throws RouteException { 63 | 64 | List routes=routerepository.findAll(); 65 | 66 | if(routes.isEmpty()) 67 | throw new RouteException("No route available"); 68 | else 69 | return routes; 70 | 71 | } 72 | @Override 73 | public Route viewRoute(int routeId) throws RouteException { 74 | Optional opt=routerepository.findById(routeId); 75 | 76 | return opt.orElseThrow(()->new RouteException("There is no route present of this routeId :" + routeId)); 77 | } 78 | 79 | @Override 80 | public Route updateRoute(Route route,String key) throws RouteException, AdminException { 81 | CurrentAdminSession loggedInAdmin= currentddminsessionrepository.findByaid(key); 82 | if(loggedInAdmin == null) { 83 | throw new AdminException("Please provide a valid id to add route !"); 84 | } 85 | 86 | Optional existedRoute = routerepository.findById(route.getRouteID()); 87 | if(existedRoute.isPresent()) { 88 | 89 | Route presentRoute = existedRoute.get(); 90 | List busList = presentRoute.getBusList(); 91 | 92 | if(!busList.isEmpty()) throw new RouteException("Cannot update running route! Buses are already scheduled in the route."); 93 | 94 | return routerepository.save(route); 95 | } 96 | else 97 | throw new RouteException("Route doesn't exist of this routeId : "+ route.getRouteID()); 98 | 99 | } 100 | 101 | 102 | @Override 103 | public Route deleteRoute(int routeID,String key) throws RouteException, AdminException { 104 | 105 | CurrentAdminSession loggedInAdmin= currentddminsessionrepository.findByaid(key); 106 | 107 | if(loggedInAdmin == null) { 108 | throw new AdminException("Please provide a valid id to add route !"); 109 | } 110 | 111 | Optional route=routerepository.findById(routeID); 112 | 113 | if(route.isPresent()) { 114 | Route existingRoute=route.get(); 115 | routerepository.delete(existingRoute); 116 | return existingRoute; 117 | } 118 | else 119 | throw new RouteException("There is no route of this routeId : "+ routeID); 120 | 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/UserLoginService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.LoginException; 4 | import com.safar.model.CurrentUserSession; 5 | import com.safar.model.UserLoginDTO; 6 | 7 | public interface UserLoginService { 8 | public CurrentUserSession userLogin(UserLoginDTO userLoginDTO) throws LoginException; 9 | public String userLogout(String key) throws LoginException; 10 | } 11 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/UserLoginServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.LoginException; 4 | import com.safar.model.CurrentUserSession; 5 | import com.safar.model.User; 6 | import com.safar.model.UserLoginDTO; 7 | import com.safar.repository.CurrentUserSessionRepository; 8 | import com.safar.repository.UserRepository; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.time.LocalDateTime; 13 | import java.util.Optional; 14 | import java.security.SecureRandom; 15 | import java.util.Base64; 16 | 17 | @Service 18 | public class UserLoginServiceImpl implements UserLoginService{ 19 | 20 | @Autowired 21 | private UserRepository userRepository; 22 | 23 | @Autowired 24 | private CurrentUserSessionRepository userSessionRepository; 25 | 26 | @Override 27 | public CurrentUserSession userLogin(UserLoginDTO userLoginDTO) throws LoginException { 28 | User registeredUser = userRepository.findByEmail(userLoginDTO.getEmail()); 29 | if(registeredUser == null) throw new LoginException("Please enter valid email!"); 30 | 31 | Optional loggedInUser = userSessionRepository.findById(registeredUser.getUserID()); 32 | if(loggedInUser.isPresent()) throw new LoginException("User already Logged!"); 33 | 34 | if(registeredUser.getPassword().equals(userLoginDTO.getPassword())) { 35 | SecureRandom secureRandom = new SecureRandom(); 36 | byte[] keyBytes = new byte[10]; 37 | secureRandom.nextBytes(keyBytes); 38 | 39 | String key = Base64.getEncoder().encodeToString(keyBytes); 40 | 41 | CurrentUserSession currentUserSession = new CurrentUserSession(); 42 | currentUserSession.setUserID(registeredUser.getUserID()); 43 | currentUserSession.setUuid(key); 44 | currentUserSession.setTime(LocalDateTime.now()); 45 | return userSessionRepository.save(currentUserSession); 46 | }else 47 | throw new LoginException("Please enter a valid password!"); 48 | } 49 | 50 | @Override 51 | public String userLogout(String key) throws LoginException { 52 | CurrentUserSession loggedInUser = userSessionRepository.findByUuid(key); 53 | if(loggedInUser == null) throw new LoginException("Please enter a valid key or login first!"); 54 | userSessionRepository.delete(loggedInUser); 55 | return "User logged out!"; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.UserException; 5 | import com.safar.model.User; 6 | 7 | import java.util.List; 8 | 9 | public interface UserService { 10 | public User createUser(User user) throws UserException; 11 | public User updateUser(User user, String key) throws UserException; 12 | public User deleteUser(Integer userId, String key) throws UserException, AdminException; 13 | public User viewUserById(Integer userId, String key) throws UserException, AdminException; 14 | public List viewAllUser(String key) throws UserException, AdminException; 15 | } 16 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/java/com/safar/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.safar.service; 2 | 3 | import com.safar.exception.AdminException; 4 | import com.safar.exception.UserException; 5 | import com.safar.model.CurrentAdminSession; 6 | import com.safar.model.CurrentUserSession; 7 | import com.safar.model.User; 8 | import com.safar.repository.CurrentAdminSessionRepository; 9 | import com.safar.repository.CurrentUserSessionRepository; 10 | import com.safar.repository.UserRepository; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.List; 15 | 16 | @Service 17 | public class UserServiceImpl implements UserService{ 18 | 19 | @Autowired 20 | private UserRepository userRepository; 21 | 22 | @Autowired 23 | private CurrentUserSessionRepository userSessionRepository; 24 | 25 | @Autowired 26 | private CurrentAdminSessionRepository adminSession; 27 | 28 | @Override 29 | public User createUser(User user) throws UserException { 30 | User registeredUser = userRepository.findByEmail(user.getMobile()); 31 | if(registeredUser != null) throw new UserException("User is already registered!"); 32 | return userRepository.save(user); 33 | } 34 | 35 | @Override 36 | public User updateUser(User user, String key) throws UserException { 37 | CurrentUserSession loggedInUser = userSessionRepository.findByUuid(key); 38 | if(loggedInUser == null) throw new UserException("Please enter a valid key or login first!"); 39 | if(user.getUserID() != loggedInUser.getUserID()) throw new UserException("Invalid user details, please login for updating user!"); 40 | return userRepository.save(user); 41 | } 42 | 43 | @Override 44 | public User deleteUser(Integer userID, String key) throws UserException, AdminException { 45 | CurrentAdminSession loggedInAdmin = adminSession.findByaid(key); 46 | if(loggedInAdmin == null) throw new AdminException("Please enter a valid key or login first!"); 47 | User user = userRepository.findById(userID).orElseThrow(() -> new UserException("Invalid user Id!")); 48 | userRepository.delete(user); 49 | return user; 50 | } 51 | 52 | @Override 53 | public User viewUserById(Integer userID, String key) throws UserException, AdminException { 54 | CurrentAdminSession loggedInAdmin = adminSession.findByaid(key); 55 | if(loggedInAdmin == null) throw new AdminException("Please enter a valid key or login first!"); 56 | User user = userRepository.findById(userID).orElseThrow(() -> new UserException("Invalid user Id!")); 57 | return user; 58 | } 59 | 60 | @Override 61 | public List viewAllUser(String key) throws UserException, AdminException { 62 | CurrentAdminSession loggedInAdmin = adminSession.findByaid(key); 63 | if(loggedInAdmin == null) throw new AdminException("Please enter a valid key or login first!"); 64 | List list = userRepository.findAll(); 65 | if(list.isEmpty()) throw new UserException("No users found!"); 66 | return list; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #server.port=8999 2 | 3 | #db specific properties 4 | spring.datasource.url=jdbc:mysql://localhost:3306/busdb 5 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 6 | spring.datasource.username=root 7 | spring.datasource.password=root 8 | 9 | #ORM s/w specific properties 10 | spring.jpa.hibernate.ddl-auto=update 11 | spring.jpa.show-sql=true 12 | -------------------------------------------------------------------------------- /Backend/bus_reservation/src/test/java/com/safar/BusReservationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.safar; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BusReservationApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /FrontEnd/admin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 16 | 18 | 20 | 21 | Admin Panel 22 | 23 | 24 | 80 | 81 |
82 |
83 | 84 |
85 | 86 | 91 | 92 |
93 |
94 |
95 | 96 | Dashboard 97 |
98 | 99 |
100 |
101 | 102 | Admin 103 | -- 106 |
107 |
108 | 109 | Reservations 110 | -- 111 |
112 |
113 | 114 | FeedBacks 115 | -- 116 |
117 |
118 | 119 |
120 |
121 | 122 | Users 123 | -- 124 |
125 |
126 | 127 | Buses 128 | -- 129 |
130 |
131 | 132 | Routes 133 | -- 134 |
135 |
136 |
137 |
138 |
139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /FrontEnd/adminBuses.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 19 | 21 | 22 | Admin Panel 23 | 24 | 25 | 81 | 82 |
83 |
84 | 85 |
86 | 87 | 92 | 93 |
94 |
95 |
96 | 97 | Buses 98 |
99 | 100 |
101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 115 | 116 | 117 | 118 | 119 | 120 |
Bus IdBus NameDriver NameFromToJournery DateDepartureSeatsFareDelete
121 |
122 |
123 |
124 |
125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /FrontEnd/adminLogin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Admin Login 7 | 8 | 9 | 10 |
11 |
12 | 13 |
14 |

AdminDashboard

15 |
Sign in to your account.
16 | 18 | 19 | 22 | Forget Password? 23 | 24 |
25 |
26 |
27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /FrontEnd/adminReservation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Admin Panel 20 | 21 | 22 | 78 | 79 |
80 |
81 | 82 |
83 | 84 | 89 | 90 |
91 |
92 |
93 | 94 | Reservations 95 |
96 | 97 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 111 | 112 | 113 | 114 | 115 | 116 |
IdSourceDestinationStatusJourney DataBooking DataTotal SeatsTotal FareDelete
117 |
118 |
119 |
120 |
121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /FrontEnd/adminRoutes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Admin Panel 20 | 21 | 22 | 78 | 79 |
80 |
81 | 82 |
83 | 84 | 89 | 90 |
91 |
92 |
93 | 94 | Routes 95 |
96 | 97 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 107 | 108 | 109 | 110 | 111 | 112 |
Route IdSourceDestinationDistanceDelete
113 |
114 |
115 |
116 | 117 | 118 |
119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /FrontEnd/adminUsers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 21 | 23 | 24 | Admin Panel 25 | 26 | 27 | 83 | 84 |
85 |
86 | 87 |
88 | 89 | 94 | 95 |
96 |
97 |
98 | 99 | Users 100 |
101 | 102 |
103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 115 | 116 | 117 | 118 | 130 | 131 |
User IdFirst NameLast NameMobileEmailReservationsFeedBacksDelete
132 |
133 |
134 |
135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /FrontEnd/adminfeedback.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Admin Panel 20 | 21 | 22 | 78 | 79 |
80 |
81 | 82 |
83 | 84 | 89 | 90 |
91 |
92 |
93 | 94 | FeedBacks 95 |
96 | 97 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 110 | 111 | 112 | 113 | 114 | 115 |
IdUser IdBus IdDriver RatingService RatingOverall RatingDateDelete
116 |
117 |
118 |
119 |
120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /FrontEnd/css/AdminLogin.css: -------------------------------------------------------------------------------- 1 | 2 | @import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400'); 3 | 4 | body, html { 5 | font-family: 'Source Sans Pro', sans-serif; 6 | background-color: #1d243d; 7 | padding: 0; 8 | margin: 0; 9 | } 10 | 11 | #particles-js { 12 | position: absolute; 13 | width: 100%; 14 | height: 100%; 15 | } 16 | 17 | .container{ 18 | margin: 0; 19 | top: 50px; 20 | left: 50%; 21 | position: absolute; 22 | text-align: center; 23 | transform: translateX(-50%); 24 | background-color: rgb( 33, 41, 66 ); 25 | border-radius: 9px; 26 | border-top: 10px solid #79a6fe; 27 | border-bottom: 10px solid #8BD17C; 28 | width: 400px; 29 | height: 500px; 30 | box-shadow: 1px 1px 108.8px 19.2px rgb(25,31,53); 31 | } 32 | 33 | .box h4 { 34 | font-family: 'Source Sans Pro', sans-serif; 35 | color: #5c6bc0; 36 | font-size: 18px; 37 | margin-top:94px;; 38 | } 39 | 40 | .box h4 span { 41 | color: #dfdeee; 42 | font-weight: lighter; 43 | } 44 | 45 | .box h5 { 46 | font-family: 'Source Sans Pro', sans-serif; 47 | font-size: 13px; 48 | color: #a1a4ad; 49 | letter-spacing: 1.5px; 50 | margin-top: -15px; 51 | margin-bottom: 70px; 52 | } 53 | 54 | .box input[type = "text"],.box input[type = "password"] { 55 | display: block; 56 | margin: 20px auto; 57 | background: #262e49; 58 | border: 0; 59 | border-radius: 5px; 60 | padding: 14px 10px; 61 | width: 320px; 62 | outline: none; 63 | color: #d6d6d6; 64 | -webkit-transition: all .2s ease-out; 65 | -moz-transition: all .2s ease-out; 66 | -ms-transition: all .2s ease-out; 67 | -o-transition: all .2s ease-out; 68 | transition: all .2s ease-out; 69 | 70 | } 71 | ::-webkit-input-placeholder { 72 | color: #565f79; 73 | } 74 | 75 | .box input[type = "text"]:focus,.box input[type = "password"]:focus { 76 | border: 1px solid #79A6FE; 77 | 78 | } 79 | 80 | a{ 81 | color: #5c7fda; 82 | text-decoration: none; 83 | } 84 | 85 | a:hover { 86 | text-decoration: underline; 87 | } 88 | 89 | label input[type = "checkbox"] { 90 | display: none; 91 | } 92 | 93 | 94 | label span { 95 | height: 13px; 96 | width: 13px; 97 | border: 2px solid #464d64; 98 | border-radius: 2px; 99 | display: inline-block; 100 | position: relative; 101 | cursor: pointer; 102 | left: 7.5%; 103 | } 104 | 105 | .btn1 { 106 | border:0; 107 | background: #7f5feb; 108 | color: #dfdeee; 109 | border-radius: 100px; 110 | width: 340px; 111 | height: 49px; 112 | font-size: 16px; 113 | position: absolute; 114 | top: 79%; 115 | left: 8%; 116 | transition: 0.3s; 117 | cursor: pointer; 118 | } 119 | 120 | .btn1:hover { 121 | background: #5d33e6; 122 | } 123 | 124 | .rmb { 125 | position: absolute; 126 | margin-left: -24%; 127 | margin-top: 0px; 128 | color: #dfdeee; 129 | font-size: 13px; 130 | } 131 | 132 | .forgetpass { 133 | position: relative; 134 | float: right; 135 | right: 28px; 136 | } 137 | 138 | .dnthave{ 139 | position: absolute; 140 | top: 92%; 141 | left: 24%; 142 | } 143 | 144 | [type=checkbox]:checked + span:before { 145 | font-family: FontAwesome; 146 | font-size: 16px; 147 | content: "\f00c"; 148 | position: absolute; 149 | top: -4px; 150 | color: #896cec; 151 | left: -1px; 152 | width: 13px; 153 | } 154 | 155 | .typcn { 156 | position: absolute; 157 | left: 339px; 158 | top: 282px; 159 | color: #3b476b; 160 | font-size: 22px; 161 | cursor: pointer; 162 | } 163 | 164 | .typcn.active { 165 | color: #7f60eb; 166 | } 167 | 168 | .error { 169 | background: #ff3333; 170 | text-align: center; 171 | width: 337px; 172 | height: 20px; 173 | padding: 2px; 174 | border: 0; 175 | border-radius: 5px; 176 | margin: 10px auto 10px; 177 | position: absolute; 178 | top: 31%; 179 | left: 7.2%; 180 | color: white; 181 | display: none; 182 | } 183 | 184 | #eye{ 185 | width: 20px; 186 | margin-top: 5px; 187 | } 188 | 189 | .footer { 190 | position: relative; 191 | left: 0; 192 | bottom: 0; 193 | top: 605px; 194 | width: 100%; 195 | color: #78797d; 196 | font-size: 14px; 197 | text-align: center; 198 | } 199 | 200 | .footer .fa { 201 | color: #7f5feb;; 202 | } 203 | 204 | -------------------------------------------------------------------------------- /FrontEnd/css/admin.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600&display=swap'); 2 | *{ 3 | margin: 0; 4 | padding: 0; 5 | box-sizing: border-box; 6 | font-family: 'Poppins', sans-serif; 7 | } 8 | 9 | :root{ 10 | /* ===== Colors ===== */ 11 | --primary-color: #0E4BF1; 12 | --panel-color: #FFF; 13 | --text-color: #000; 14 | --black-light-color: #707070; 15 | --border-color: #e6e5e5; 16 | --toggle-color: #DDD; 17 | --box1-color: #4DA3FF; 18 | --box2-color: #FFE6AC; 19 | --box3-color: #E7D1FC; 20 | --title-icon-color: #fff; 21 | 22 | /* ====== Transition ====== */ 23 | --tran-05: all 0.5s ease; 24 | --tran-03: all 0.3s ease; 25 | --tran-03: all 0.2s ease; 26 | } 27 | 28 | body{ 29 | min-height: 100vh; 30 | background-color: var(--primary-color); 31 | } 32 | body.dark{ 33 | --primary-color: #3A3B3C; 34 | --panel-color: #242526; 35 | --text-color: #CCC; 36 | --black-light-color: #CCC; 37 | --border-color: #4D4C4C; 38 | --toggle-color: #FFF; 39 | --box1-color: #3A3B3C; 40 | --box2-color: #3A3B3C; 41 | --box3-color: #3A3B3C; 42 | --title-icon-color: #CCC; 43 | } 44 | /* === Custom Scroll Bar CSS === */ 45 | ::-webkit-scrollbar { 46 | width: 8px; 47 | } 48 | ::-webkit-scrollbar-track { 49 | background: #f1f1f1; 50 | } 51 | ::-webkit-scrollbar-thumb { 52 | background: var(--primary-color); 53 | border-radius: 12px; 54 | transition: all 0.3s ease; 55 | } 56 | 57 | ::-webkit-scrollbar-thumb:hover { 58 | background: #0b3cc1; 59 | } 60 | 61 | body.dark::-webkit-scrollbar-thumb:hover, 62 | body.dark .activity-data::-webkit-scrollbar-thumb:hover{ 63 | background: #3A3B3C; 64 | } 65 | 66 | nav{ 67 | position: fixed; 68 | top: 0; 69 | left: 0; 70 | height: 100%; 71 | width: 250px; 72 | padding: 10px 14px; 73 | background-color: var(--panel-color); 74 | border-right: 1px solid var(--border-color); 75 | transition: var(--tran-05); 76 | } 77 | nav.close{ 78 | width: 73px; 79 | } 80 | nav .logo-name{ 81 | display: flex; 82 | align-items: center; 83 | } 84 | nav .logo-image{ 85 | display: flex; 86 | justify-content: center; 87 | min-width: 45px; 88 | } 89 | nav .logo-image img{ 90 | width: 40px; 91 | object-fit: cover; 92 | border-radius: 50%; 93 | } 94 | 95 | nav .logo-name .logo_name{ 96 | font-size: 22px; 97 | font-weight: 600; 98 | color: var(--text-color); 99 | margin-left: 14px; 100 | transition: var(--tran-05); 101 | } 102 | nav.close .logo_name{ 103 | opacity: 0; 104 | pointer-events: none; 105 | } 106 | nav .menu-items{ 107 | margin-top: 40px; 108 | height: calc(100% - 90px); 109 | display: flex; 110 | flex-direction: column; 111 | justify-content: space-between; 112 | } 113 | .menu-items li{ 114 | list-style: none; 115 | } 116 | .menu-items li a{ 117 | display: flex; 118 | align-items: center; 119 | height: 50px; 120 | text-decoration: none; 121 | position: relative; 122 | } 123 | .nav-links li a:hover:before{ 124 | content: ""; 125 | position: absolute; 126 | left: -7px; 127 | height: 5px; 128 | width: 5px; 129 | border-radius: 50%; 130 | background-color: var(--primary-color); 131 | } 132 | body.dark li a:hover:before{ 133 | background-color: var(--text-color); 134 | } 135 | .menu-items li a i{ 136 | font-size: 24px; 137 | min-width: 45px; 138 | height: 100%; 139 | display: flex; 140 | align-items: center; 141 | justify-content: center; 142 | color: var(--black-light-color); 143 | } 144 | .menu-items li a .link-name{ 145 | font-size: 18px; 146 | font-weight: 400; 147 | color: var(--black-light-color); 148 | transition: var(--tran-05); 149 | } 150 | nav.close li a .link-name{ 151 | opacity: 0; 152 | pointer-events: none; 153 | } 154 | .nav-links li a:hover i, 155 | .nav-links li a:hover .link-name{ 156 | color: var(--primary-color); 157 | } 158 | body.dark .nav-links li a:hover i, 159 | body.dark .nav-links li a:hover .link-name{ 160 | color: var(--text-color); 161 | } 162 | .menu-items .logout-mode{ 163 | padding-top: 10px; 164 | border-top: 1px solid var(--border-color); 165 | } 166 | .menu-items .mode{ 167 | display: flex; 168 | align-items: center; 169 | white-space: nowrap; 170 | } 171 | .menu-items .mode-toggle{ 172 | position: absolute; 173 | right: 14px; 174 | height: 50px; 175 | min-width: 45px; 176 | display: flex; 177 | align-items: center; 178 | justify-content: center; 179 | cursor: pointer; 180 | } 181 | .mode-toggle .switch{ 182 | position: relative; 183 | display: inline-block; 184 | height: 22px; 185 | width: 40px; 186 | border-radius: 25px; 187 | background-color: var(--toggle-color); 188 | } 189 | .switch:before{ 190 | content: ""; 191 | position: absolute; 192 | left: 5px; 193 | top: 50%; 194 | transform: translateY(-50%); 195 | height: 15px; 196 | width: 15px; 197 | background-color: var(--panel-color); 198 | border-radius: 50%; 199 | transition: var(--tran-03); 200 | } 201 | body.dark .switch:before{ 202 | left: 20px; 203 | } 204 | 205 | .dashboard{ 206 | position: relative; 207 | left: 250px; 208 | background-color: var(--panel-color); 209 | min-height: 100vh; 210 | width: calc(100% - 250px); 211 | padding: 10px 14px; 212 | transition: var(--tran-05); 213 | } 214 | nav.close ~ .dashboard{ 215 | left: 73px; 216 | width: calc(100% - 73px); 217 | } 218 | .dashboard .top .sidebar-toggle{ 219 | font-size: 26px; 220 | color: var(--text-color); 221 | cursor: pointer; 222 | } 223 | .dash-content .title{ 224 | display: flex; 225 | align-items: center; 226 | margin: 60px 0 30px 0; 227 | } 228 | .dash-content .title i{ 229 | position: relative; 230 | height: 35px; 231 | width: 35px; 232 | background-color: var(--primary-color); 233 | border-radius: 6px; 234 | color: var(--title-icon-color); 235 | display: flex; 236 | align-items: center; 237 | justify-content: center; 238 | font-size: 24px; 239 | } 240 | .dash-content .title .text{ 241 | font-size: 24px; 242 | font-weight: 500; 243 | color: var(--text-color); 244 | margin-left: 10px; 245 | } 246 | .dash-content .boxes{ 247 | display: flex; 248 | align-items: center; 249 | justify-content: space-between; 250 | flex-wrap: wrap; 251 | } 252 | .dash-content .boxes .box{ 253 | display: flex; 254 | flex-direction: column; 255 | align-items: center; 256 | border-radius: 12px; 257 | width: calc(100% / 3 - 15px); 258 | padding: 15px 20px; 259 | background-color: var(--box1-color); 260 | transition: var(--tran-05); 261 | } 262 | 263 | /* */ 264 | .boxes .box i{ 265 | font-size: 35px; 266 | color: var(--text-color); 267 | } 268 | .boxes .box .text{ 269 | white-space: nowrap; 270 | font-size: 18px; 271 | font-weight: 500; 272 | color: var(--text-color); 273 | } 274 | .boxes .box .number{ 275 | font-size: 40px; 276 | font-weight: 500; 277 | color: var(--text-color); 278 | } 279 | .boxes .box.box2{ 280 | background-color: var(--box2-color); 281 | } 282 | .boxes .box.box3{ 283 | background-color: var(--box3-color); 284 | } 285 | 286 | .dash-content .activity .activity-data{ 287 | display: flex; 288 | justify-content: space-between; 289 | align-items: center; 290 | width: 100%; 291 | } 292 | .activity .activity-data{ 293 | display: flex; 294 | } 295 | .activity-data .data{ 296 | display: flex; 297 | flex-direction: column; 298 | margin: 0 15px; 299 | } 300 | .activity-data .data-title{ 301 | font-size: 20px; 302 | font-weight: 500; 303 | color: var(--text-color); 304 | } 305 | .activity-data .data .data-list{ 306 | font-size: 18px; 307 | font-weight: 400; 308 | margin-top: 20px; 309 | white-space: nowrap; 310 | color: var(--text-color); 311 | } 312 | 313 | @media (max-width: 1000px) { 314 | nav{ 315 | width: 73px; 316 | } 317 | nav.close{ 318 | width: 250px; 319 | } 320 | nav .logo_name{ 321 | opacity: 0; 322 | pointer-events: none; 323 | } 324 | nav.close .logo_name{ 325 | opacity: 1; 326 | pointer-events: auto; 327 | } 328 | nav li a .link-name{ 329 | opacity: 0; 330 | pointer-events: none; 331 | } 332 | nav.close li a .link-name{ 333 | opacity: 1; 334 | pointer-events: auto; 335 | } 336 | nav ~ .dashboard{ 337 | left: 73px; 338 | width: calc(100% - 73px); 339 | } 340 | nav.close ~ .dashboard{ 341 | left: 250px; 342 | width: calc(100% - 250px); 343 | } 344 | nav ~ .dashboard .top{ 345 | left: 73px; 346 | width: calc(100% - 73px); 347 | } 348 | nav.close ~ .dashboard .top{ 349 | left: 250px; 350 | width: calc(100% - 250px); 351 | } 352 | .activity .activity-data{ 353 | overflow-X: scroll; 354 | } 355 | } 356 | 357 | 358 | #popupButton{ 359 | cursor: pointer; 360 | } 361 | 362 | #overlay { 363 | display: none; 364 | position: fixed; 365 | top: 0; 366 | left: 0; 367 | width: 100%; 368 | height: 100%; 369 | background-color: rgba(0, 0, 0, 0.5); 370 | } 371 | 372 | .popup { 373 | display: none; 374 | position: fixed; 375 | top: 10%; 376 | left: 50%; 377 | transform: translate(-50%, -50%); 378 | padding: 20px; 379 | background-color: #fff; 380 | border-radius: 8px; 381 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); 382 | z-index: 999; 383 | } 384 | 385 | .popup p { 386 | margin: 0; 387 | margin-right: 20px; 388 | } 389 | 390 | .close { 391 | position: absolute; 392 | top: 10px; 393 | right: 10px; 394 | cursor: pointer; 395 | font-size: 18px; 396 | } 397 | 398 | @media screen and (max-height: 600px) { 399 | .popup { 400 | top: 40%; 401 | } 402 | #overlay { 403 | justify-content: flex-start; 404 | } 405 | } 406 | 407 | 408 | #signout{ 409 | padding: 5px 16px; 410 | font-size: 14px; 411 | line-height: 20px; 412 | white-space: nowrap; 413 | cursor: pointer; 414 | vertical-align: middle; 415 | border: 1px solid; 416 | border-radius: 6px; 417 | margin: 10px 10px 0px 10px; 418 | } 419 | 420 | #signout:hover{ 421 | background-color: #a5a5a5; 422 | border: 1px solid black; 423 | } 424 | 425 | 426 | @media (max-width: 400px) { 427 | nav{ 428 | width: 0px; 429 | } 430 | nav.close{ 431 | width: 73px; 432 | } 433 | nav .logo_name{ 434 | opacity: 0; 435 | pointer-events: none; 436 | } 437 | nav.close .logo_name{ 438 | opacity: 0; 439 | pointer-events: none; 440 | } 441 | nav li a .link-name{ 442 | opacity: 0; 443 | pointer-events: none; 444 | } 445 | nav.close li a .link-name{ 446 | opacity: 0; 447 | pointer-events: none; 448 | } 449 | nav ~ .dashboard{ 450 | left: 0; 451 | width: 100%; 452 | } 453 | nav.close ~ .dashboard{ 454 | left: 73px; 455 | width: calc(100% - 73px); 456 | } 457 | nav ~ .dashboard .top{ 458 | left: 0; 459 | width: 100%; 460 | } 461 | nav.close ~ .dashboard .top{ 462 | left: 0; 463 | width: 100%; 464 | } 465 | } -------------------------------------------------------------------------------- /FrontEnd/css/adminUser.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/FrontEnd/css/adminUser.css -------------------------------------------------------------------------------- /FrontEnd/css/button1.css: -------------------------------------------------------------------------------- 1 | .button1 { 2 | font-size: 17px; 3 | padding: 0.5em 2em; 4 | border: transparent; 5 | box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4); 6 | background: dodgerblue; 7 | color: white; 8 | border-radius: 4px; 9 | } 10 | 11 | .button1:hover { 12 | background: rgb(2, 0, 36); 13 | background: linear-gradient( 14 | 90deg, 15 | rgba(30, 144, 255, 1) 0%, 16 | rgba(0, 212, 255, 1) 100% 17 | ); 18 | } 19 | 20 | .button1:active { 21 | transform: translate(0em, 0.2em); 22 | } 23 | -------------------------------------------------------------------------------- /FrontEnd/css/deletebutton.css: -------------------------------------------------------------------------------- 1 | #btn{ 2 | /* border: 1px solid; */ 3 | margin: auto; 4 | display: flex; 5 | justify-content: center; 6 | align-items: center; 7 | } 8 | 9 | #btn i{ 10 | font-size: 20px; 11 | margin-top: 10px; 12 | } 13 | 14 | #btn i:hover{ 15 | transform: scale(1.2); 16 | transition: .7s; 17 | } -------------------------------------------------------------------------------- /FrontEnd/css/home.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/FrontEnd/css/home.css -------------------------------------------------------------------------------- /FrontEnd/css/input1.css: -------------------------------------------------------------------------------- 1 | .input1 { 2 | max-width: 190px; 3 | background-color: #f5f5f5; 4 | color: #242424; 5 | padding: .15rem .5rem; 6 | min-height: 40px; 7 | border-radius: 4px; 8 | outline: none; 9 | border: none; 10 | line-height: 1.15; 11 | box-shadow: 0px 10px 20px -18px; 12 | } 13 | 14 | .input1:focus { 15 | border-bottom: 2px solid #5b5fc7; 16 | border-radius: 4px 4px 2px 2px; 17 | } 18 | 19 | .input1:hover { 20 | outline: 1px solid lightgrey; 21 | } -------------------------------------------------------------------------------- /FrontEnd/css/login.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap"); 2 | 3 | * { 4 | margin: 0; 5 | padding: 0; 6 | box-sizing: border-box; 7 | font-family: "Poppins", sans-serif; 8 | } 9 | 10 | body { 11 | background: #dfe6e8; 12 | } 13 | 14 | section { 15 | width: 100%; 16 | height: 100vh; 17 | display: flex; 18 | justify-content: center; 19 | align-items: center; 20 | } 21 | 22 | .main { 23 | width: 70%; 24 | height: 80%; 25 | border-radius: 25px; 26 | background: white; 27 | border-radius: 30px; 28 | display: flex; 29 | } 30 | 31 | .bus-img > img { 32 | width: 100%; 33 | height: 100%; 34 | border-radius: 30px; 35 | } 36 | 37 | .wrapper { 38 | overflow: hidden; 39 | max-width: 390px; 40 | background: #fff; 41 | padding: 30px; 42 | border-radius: 30px; 43 | /* box-shadow: 0px 15px 20px rgba(0, 0, 0, 0.1); */ 44 | } 45 | .wrapper .title-text { 46 | display: flex; 47 | width: 200%; 48 | } 49 | .wrapper .title { 50 | width: 50%; 51 | font-size: 35px; 52 | font-weight: 600; 53 | text-align: center; 54 | transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); 55 | } 56 | .wrapper .slide-controls { 57 | position: relative; 58 | display: flex; 59 | height: 50px; 60 | width: 100%; 61 | overflow: hidden; 62 | margin: 30px 0 10px 0; 63 | justify-content: space-between; 64 | border: 1px solid lightgrey; 65 | border-radius: 15px; 66 | } 67 | .slide-controls .slide { 68 | height: 100%; 69 | width: 100%; 70 | color: #fff; 71 | font-size: 18px; 72 | font-weight: 500; 73 | text-align: center; 74 | line-height: 48px; 75 | cursor: pointer; 76 | z-index: 1; 77 | transition: all 0.6s ease; 78 | } 79 | .slide-controls label.signup { 80 | color: #000; 81 | } 82 | .slide-controls .slider-tab { 83 | position: absolute; 84 | height: 100%; 85 | width: 50%; 86 | left: 0; 87 | z-index: 0; 88 | border-radius: 15px; 89 | background: -webkit-linear-gradient(left, #003366, #004080, #0059b3, #0073e6); 90 | transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); 91 | } 92 | input[type="radio"] { 93 | display: none; 94 | } 95 | #signup:checked ~ .slider-tab { 96 | left: 50%; 97 | } 98 | #signup:checked ~ label.signup { 99 | color: #fff; 100 | cursor: default; 101 | user-select: none; 102 | } 103 | #signup:checked ~ label.login { 104 | color: #000; 105 | } 106 | #login:checked ~ label.signup { 107 | color: #000; 108 | } 109 | #login:checked ~ label.login { 110 | cursor: default; 111 | user-select: none; 112 | } 113 | .wrapper .form-container { 114 | width: 100%; 115 | overflow: hidden; 116 | } 117 | .form-container .form-inner { 118 | display: flex; 119 | width: 200%; 120 | } 121 | .form-container .form-inner form { 122 | width: 50%; 123 | transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); 124 | } 125 | .form-inner form .field { 126 | height: 50px; 127 | width: 100%; 128 | margin-top: 20px; 129 | } 130 | .form-inner form .field input { 131 | height: 100%; 132 | width: 100%; 133 | outline: none; 134 | padding-left: 15px; 135 | border-radius: 15px; 136 | border: 1px solid lightgrey; 137 | border-bottom-width: 2px; 138 | font-size: 17px; 139 | transition: all 0.3s ease; 140 | } 141 | .form-inner form .field input:focus { 142 | border-color: #1a75ff; 143 | /* box-shadow: inset 0 0 3px #fb6aae; */ 144 | } 145 | .form-inner form .field input::placeholder { 146 | color: #999; 147 | transition: all 0.3s ease; 148 | } 149 | form .field input:focus::placeholder { 150 | color: #1a75ff; 151 | } 152 | .form-inner form .pass-link { 153 | margin-top: 5px; 154 | } 155 | .form-inner form .signup-link { 156 | text-align: center; 157 | margin-top: 30px; 158 | } 159 | .form-inner form .pass-link a, 160 | .form-inner form .signup-link a { 161 | color: #1a75ff; 162 | text-decoration: none; 163 | } 164 | .form-inner form .pass-link a:hover, 165 | .form-inner form .signup-link a:hover { 166 | text-decoration: underline; 167 | } 168 | form .btn { 169 | height: 50px; 170 | width: 100%; 171 | border-radius: 15px; 172 | position: relative; 173 | overflow: hidden; 174 | } 175 | form .btn .btn-layer { 176 | height: 100%; 177 | width: 300%; 178 | position: absolute; 179 | left: -100%; 180 | background: -webkit-linear-gradient( 181 | right, 182 | #003366, 183 | #004080, 184 | #0059b3, 185 | #0073e6 186 | ); 187 | border-radius: 15px; 188 | transition: all 0.4s ease; 189 | } 190 | form .btn:hover .btn-layer { 191 | left: 0; 192 | } 193 | form .btn input[type="submit"] { 194 | height: 100%; 195 | width: 100%; 196 | z-index: 1; 197 | position: relative; 198 | background: none; 199 | border: none; 200 | color: #fff; 201 | padding-left: 0; 202 | border-radius: 15px; 203 | font-size: 20px; 204 | font-weight: 500; 205 | cursor: pointer; 206 | } 207 | -------------------------------------------------------------------------------- /FrontEnd/css/pop.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Lato:400,700'); 2 | 3 | h1 { 4 | font-size: 1em; 5 | font-weight: 100; 6 | letter-spacing: 3px; 7 | padding-top: 5px; 8 | color: #FCFCFC; 9 | padding-bottom: 5px; 10 | text-transform: uppercase; 11 | } 12 | 13 | .green { 14 | color: #4ec07d; 15 | } 16 | .red { 17 | color: #e96075; 18 | } 19 | 20 | .alert { 21 | font-weight: 700; 22 | letter-spacing: 5px; 23 | } 24 | 25 | p { 26 | margin-top: -5px; 27 | font-size: 0.7em; 28 | font-weight: 100; 29 | color: #5e5e5e; 30 | letter-spacing: 1px; 31 | } 32 | button, .dot { 33 | cursor: pointer; 34 | } 35 | 36 | .success-box { 37 | position: absolute; 38 | width: 300px; 39 | height: 300px; 40 | left: 50%; 41 | top: 0; 42 | background: linear-gradient(to bottom right, #B0DB7D 40%, #99DBB4 100%); 43 | border-radius: 20px; 44 | box-shadow: 5px 5px 20px rgba(203, 205, 211, 0.1); 45 | perspective: 40px; 46 | transform: translate(-50%, -50%) scale(0.1); 47 | visibility: hidden; 48 | transition: transform 0.4s, top 0.4s; 49 | } 50 | 51 | .open-success{ 52 | visibility: visible; 53 | top: 50%; 54 | transform: translate(-50%, -50%) scale(1); 55 | } 56 | 57 | .error-box { 58 | position: absolute; 59 | width: 300px; 60 | height: 300px; 61 | left: 50%; 62 | top: 0; 63 | background: linear-gradient(to bottom left, #EF8D9C 40%, #FFC39E 100%); 64 | border-radius: 20px; 65 | box-shadow: 5px 5px 20px rgba(203, 205, 211, 0.1); 66 | transform: translate(-50%, -50%) scale(0.1); 67 | visibility: hidden; 68 | transition: transform 0.4s, top 0.4s; 69 | } 70 | 71 | .open-error{ 72 | visibility: visible; 73 | top: 50%; 74 | transform: translate(-50%, -50%) scale(1); 75 | } 76 | 77 | .dot { 78 | width: 8px; 79 | height: 8px; 80 | background: #FCFCFC; 81 | border-radius: 50%; 82 | position: absolute; 83 | top: 4%; 84 | right: 6%; 85 | } 86 | .dot:hover { 87 | background: #c9c9c9; 88 | } 89 | .two { 90 | right: 12%; 91 | opacity: 0.5; 92 | } 93 | .face { 94 | position: absolute; 95 | width: 22%; 96 | height: 22%; 97 | background: #FCFCFC; 98 | border-radius: 50%; 99 | border: 1px solid #777777; 100 | top: 21%; 101 | left: 37.5%; 102 | z-index: 2; 103 | animation: bounce 1s ease-in infinite; 104 | } 105 | .face2 { 106 | position: absolute; 107 | width: 22%; 108 | height: 22%; 109 | background: #FCFCFC; 110 | border-radius: 50%; 111 | border: 1px solid #777777; 112 | top: 21%; 113 | left: 37.5%; 114 | z-index: 2; 115 | animation: roll 3s ease-in-out infinite; 116 | } 117 | .eye { 118 | position: absolute; 119 | width: 5px; 120 | height: 5px; 121 | background: #777777; 122 | border-radius: 50%; 123 | top: 40%; 124 | left: 20%; 125 | } 126 | .right { 127 | left: 68%; 128 | } 129 | .mouth { 130 | position: absolute; 131 | top: 43%; 132 | left: 41%; 133 | width: 7px; 134 | height: 7px; 135 | border-radius: 50%; 136 | } 137 | .happy { 138 | border: 2px solid; 139 | border-color: transparent #777777 #777777 transparent; 140 | transform: rotate(45deg); 141 | } 142 | .sad { 143 | top: 49%; 144 | border: 2px solid; 145 | border-color: #777777 transparent transparent #777777; 146 | transform: rotate(45deg); 147 | } 148 | .shadow { 149 | position: absolute; 150 | width: 21%; 151 | height: 3%; 152 | opacity: 0.5; 153 | background: #777777; 154 | left: 40%; 155 | top: 43%; 156 | border-radius: 50%; 157 | z-index: 1; 158 | } 159 | .scale { 160 | animation: scale 1s ease-in infinite; 161 | } 162 | .move { 163 | animation: move 3s ease-in-out infinite; 164 | } 165 | .message { 166 | position: absolute; 167 | width: 100%; 168 | text-align: center; 169 | height: 40%; 170 | top: 47%; 171 | } 172 | .button-box { 173 | position: absolute; 174 | background: #FCFCFC; 175 | width: 50%; 176 | height: 15%; 177 | border-radius: 20px; 178 | top: 73%; 179 | left: 25%; 180 | outline: 0; 181 | border: none; 182 | box-shadow: 2px 2px 10px rgba(119, 119, 119, 0.5); 183 | transition: all 0.5s ease-in-out; 184 | } 185 | .button-box:hover { 186 | background: #efefef; 187 | transform: scale(1.05); 188 | transition: all 0.3s ease-in-out; 189 | } 190 | @keyframes bounce { 191 | 50% { 192 | transform: translateY(-10px); 193 | } 194 | } 195 | @keyframes scale { 196 | 50% { 197 | transform: scale(0.9); 198 | } 199 | } 200 | @keyframes roll { 201 | 0% { 202 | transform: rotate(0deg); 203 | left: 25%; 204 | } 205 | 50% { 206 | left: 60%; 207 | transform: rotate(168deg); 208 | } 209 | 100% { 210 | transform: rotate(0deg); 211 | left: 25%; 212 | } 213 | } 214 | @keyframes move { 215 | 0% { 216 | left: 25%; 217 | } 218 | 50% { 219 | left: 60%; 220 | } 221 | 100% { 222 | left: 25%; 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /FrontEnd/css/table.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600&display=swap'); 2 | *{ 3 | margin: 0; 4 | padding: 0; 5 | box-sizing: border-box; 6 | font-family: 'Poppins', sans-serif; 7 | } 8 | 9 | table { 10 | border-spacing: 1; 11 | border-collapse: collapse; 12 | border-radius: 10px; 13 | overflow: hidden; 14 | width: 90%; 15 | position: relative; 16 | margin-left: 20px ; 17 | color: var(--text-color); 18 | } 19 | 20 | table * { 21 | position: relative 22 | } 23 | 24 | table td,table th { 25 | padding-left: 8px 26 | } 27 | 28 | table thead tr { 29 | height: 60px; 30 | background: #36304a 31 | } 32 | 33 | table tbody tr { 34 | height: 50px 35 | } 36 | 37 | table tbody tr:last-child { 38 | border: 0 39 | } 40 | 41 | table td,table th { 42 | text-align: left 43 | } 44 | 45 | table td.l,table th.l { 46 | text-align: right 47 | } 48 | 49 | table td.c,table th.c { 50 | text-align: center 51 | } 52 | 53 | table td.r,table th.r { 54 | text-align: center 55 | } 56 | 57 | .table100-head th { 58 | font-family: OpenSans-Regular; 59 | font-size: 18px; 60 | color:aqua; 61 | line-height: 1.2; 62 | font-weight: unset 63 | } 64 | 65 | /* tbody tr:nth-child(even) { 66 | background-color:aqua 67 | } */ 68 | 69 | tbody tr { 70 | font-family: OpenSans-Regular; 71 | font-size: 15px; 72 | color:var(--text-color); 73 | line-height: 1.2; 74 | font-weight: unset 75 | } 76 | 77 | .column1 { 78 | width: 120px; 79 | padding-left: 40px 80 | } 81 | 82 | .column2 { 83 | width: 130px 84 | } 85 | 86 | .column3 { 87 | width: 130px 88 | } 89 | 90 | .column4 { 91 | width: 100px; 92 | text-align: right 93 | } 94 | 95 | .column5 { 96 | width: 200px; 97 | text-align: right 98 | } 99 | 100 | .column6 { 101 | width: 100px; 102 | text-align: right 103 | } 104 | 105 | .column7 { 106 | width: 100px; 107 | text-align: right 108 | } 109 | 110 | .column8 { 111 | width: 100px; 112 | text-align: right; 113 | } -------------------------------------------------------------------------------- /FrontEnd/data/busimg.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/FrontEnd/data/busimg.jpeg -------------------------------------------------------------------------------- /FrontEnd/data/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/FrontEnd/data/eye.png -------------------------------------------------------------------------------- /FrontEnd/data/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/FrontEnd/data/logo.png -------------------------------------------------------------------------------- /FrontEnd/data/trip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/FrontEnd/data/trip.jpg -------------------------------------------------------------------------------- /FrontEnd/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Home 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /FrontEnd/js/AdminLogin.js: -------------------------------------------------------------------------------- 1 | let pwd = document.getElementById('pwd'); 2 | let eye = document.getElementById('eye'); 3 | 4 | eye.addEventListener('click',togglePass); 5 | 6 | function togglePass(){ 7 | 8 | eye.classList.toggle('active'); 9 | 10 | (pwd.type == 'password') ? pwd.type = 'text' : pwd.type = 'password'; 11 | } 12 | 13 | document.getElementById("submit").addEventListener("click", checkStuff); 14 | 15 | function checkStuff(event) { 16 | event.preventDefault(); 17 | let email = document.form1.email; 18 | let password = document.form1.password; 19 | let msg = document.getElementById('msg'); 20 | 21 | if (email.value == "") { 22 | msg.style.display = 'block'; 23 | msg.innerHTML = "Please enter your email"; 24 | email.focus(); 25 | return false; 26 | } else { 27 | msg.innerHTML = ""; 28 | } 29 | 30 | if (password.value == "") { 31 | msg.innerHTML = "Please enter your password"; 32 | password.focus(); 33 | return false; 34 | } else { 35 | msg.innerHTML = ""; 36 | } 37 | 38 | let re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 39 | if (!re.test(email.value)) { 40 | msg.innerHTML = "Please enter a valid email"; 41 | email.focus(); 42 | return false; 43 | } else { 44 | msg.innerHTML = ""; 45 | } 46 | 47 | let obj = { 48 | "email": email.value, 49 | "password": password.value 50 | } 51 | 52 | loginAdmin(obj) 53 | } 54 | 55 | 56 | 57 | async function loginAdmin(obj){ 58 | try { 59 | const res = await fetch("http://localhost:8080/safar/admin/login",{ 60 | method: 'POST', 61 | body: JSON.stringify(obj), 62 | headers: { 63 | "Content-Type": "application/json" 64 | } 65 | }); 66 | 67 | const out = await res.json(); 68 | 69 | if(res.ok){ 70 | setTimeout(function() { 71 | const jsonData = JSON.stringify(out); 72 | localStorage.setItem("adminData", jsonData); 73 | window.location.href = "./admin.html"; 74 | }, 500); 75 | } 76 | else{ 77 | alert(out.message) 78 | } 79 | 80 | 81 | } catch (error) { 82 | alert(error); 83 | } 84 | } -------------------------------------------------------------------------------- /FrontEnd/js/admin.js: -------------------------------------------------------------------------------- 1 | // =-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= 2 | 3 | fetch('http://localhost:8080/safar/bus/count') 4 | .then(response => response.json()) 5 | .then(data => { 6 | document.querySelector("#buses").innerHTML = data 7 | }) 8 | .catch(error => { 9 | console.log('Error:', error); 10 | }); 11 | 12 | 13 | fetch('http://localhost:8080/safar/user/count') 14 | .then(response => response.json()) 15 | .then(data => { 16 | document.querySelector("#users").innerHTML = data 17 | }) 18 | .catch(error => { 19 | console.log('Error:', error); 20 | }); 21 | 22 | 23 | fetch('http://localhost:8080/safar/reservation/count') 24 | .then(response => response.json()) 25 | .then(data => { 26 | document.querySelector("#reservation").innerHTML = data 27 | }) 28 | .catch(error => { 29 | console.log('Error:', error); 30 | }); 31 | 32 | 33 | fetch('http://localhost:8080/safar/feedback/count') 34 | .then(response => response.json()) 35 | .then(data => { 36 | document.querySelector("#feedback").innerHTML = data 37 | }) 38 | .catch(error => { 39 | console.log('Error:', error); 40 | }); 41 | 42 | 43 | fetch('http://localhost:8080/safar/route/count') 44 | .then(response => response.json()) 45 | .then(data => { 46 | document.querySelector("#route").innerHTML = data 47 | }) 48 | .catch(error => { 49 | console.log('Error:', error); 50 | }); 51 | 52 | 53 | // =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 54 | 55 | let loginData = JSON.parse(localStorage.getItem("adminData")) 56 | document.querySelector("#admin").innerHTML = loginData.name 57 | -------------------------------------------------------------------------------- /FrontEnd/js/adminBuses.js: -------------------------------------------------------------------------------- 1 | let loginData = JSON.parse(localStorage.getItem("adminData")) 2 | 3 | fetch(`http://localhost:8080/safar/bus/all`) 4 | .then(response => response.json()) 5 | .then(data => { 6 | 7 | console.log(data) 8 | 9 | data.forEach(element => { 10 | document.querySelector(".UserData").innerHTML += ` 11 | 12 | ${element.busId} 13 | ${element.busName} 14 | ${element.driverName} 15 | ${element.routeFrom} 16 | ${element.routeTo} 17 | ${element.busJourneyDate} 18 | ${element.departureTime} 19 | ${element.availableSeats} 20 | ${element.fare} 21 | 22 | 23 | 24 | 25 | ` 26 | }); 27 | }) 28 | .catch(error => { 29 | console.log('Error:', error); 30 | }); -------------------------------------------------------------------------------- /FrontEnd/js/adminFeedBack.js: -------------------------------------------------------------------------------- 1 | let loginData = JSON.parse(localStorage.getItem("adminData")) 2 | 3 | fetch(`http://localhost:8080/safar/feedback/all`) 4 | .then(response => response.json()) 5 | .then(data => { 6 | 7 | data.forEach(element => { 8 | document.querySelector(".UserData").innerHTML += ` 9 | 10 | ${element.feedBackId} 11 | ${element.userId} 12 | ${element.busId} 13 | ${element.driverRating} 14 | ${element.serviceRating} 15 | ${element.overallRating} 16 | ${element.feedbackDateTime.slice(0, 10)} 17 | 18 | 19 | 20 | 21 | ` 22 | }); 23 | }) 24 | .catch(error => { 25 | console.log('Error:', error); 26 | }); -------------------------------------------------------------------------------- /FrontEnd/js/adminLogout.js: -------------------------------------------------------------------------------- 1 | const popupButton = document.getElementById('popupButton'); 2 | const popupMessage = document.getElementById('popupMessage'); 3 | 4 | popupButton.addEventListener('click', () => { 5 | popupMessage.style.display = 'block'; 6 | }); 7 | 8 | function closePopup() { 9 | popupMessage.style.display = 'none'; 10 | } 11 | 12 | 13 | document.querySelector("#signout").addEventListener("click", logout); 14 | 15 | async function logout(){ 16 | try { 17 | 18 | let loginData = JSON.parse(localStorage.getItem("adminData")) 19 | 20 | const res = await fetch(`http://localhost:8080/safar/admin/logout?key=${loginData.aid}`,{ 21 | method: 'POST', 22 | headers: { 23 | "Content-Type": "application/json" 24 | } 25 | }); 26 | 27 | if(res.ok){ 28 | console.log("Logout..."); 29 | 30 | setTimeout(function() { 31 | localStorage.removeItem("adminData"); 32 | window.location.href = "./AdminLogin.html"; 33 | }, 500); 34 | } 35 | else{ 36 | alert(out.message) 37 | } 38 | 39 | 40 | } catch (error) { 41 | alert(error); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /FrontEnd/js/adminReservation.js: -------------------------------------------------------------------------------- 1 | let loginData = JSON.parse(localStorage.getItem("adminData")) 2 | 3 | fetch(`http://localhost:8080/safar/reservation/all?key=${loginData.aid}`) 4 | .then(response => response.json()) 5 | .then(data => { 6 | 7 | console.log(data) 8 | 9 | data.forEach(element => { 10 | document.querySelector(".UserData").innerHTML += ` 11 | 12 | ${element.reservationID} 13 | ${element.source} 14 | ${element.destination} 15 | ${element.status} 16 | ${element.journeyDate} 17 | ${element.date} 18 | ${element.bookedSeat} 19 | ${element.fare} 20 | 21 | 22 | 23 | 24 | ` 25 | }); 26 | }) 27 | .catch(error => { 28 | console.log('Error:', error); 29 | }); -------------------------------------------------------------------------------- /FrontEnd/js/adminRoute.js: -------------------------------------------------------------------------------- 1 | let loginData = JSON.parse(localStorage.getItem("adminData")) 2 | 3 | fetch(`http://localhost:8080/safar/route/all`) 4 | .then(response => response.json()) 5 | .then(data => { 6 | 7 | console.log(data) 8 | 9 | data.forEach(element => { 10 | document.querySelector(".UserData").innerHTML += ` 11 | 12 | ${element.routeID} 13 | ${element.routeFrom} 14 | ${element.routeTo} 15 | ${element.distance} 16 | 17 | 18 | 19 | 20 | ` 21 | }); 22 | }) 23 | .catch(error => { 24 | console.log('Error:', error); 25 | }); -------------------------------------------------------------------------------- /FrontEnd/js/adminUser.js: -------------------------------------------------------------------------------- 1 | let loginData = JSON.parse(localStorage.getItem("adminData")) 2 | 3 | fetch(`http://localhost:8080/safar/admin/user/all?key=${loginData.aid}`) 4 | .then(response => response.json()) 5 | .then(data => { 6 | 7 | console.log(data) 8 | 9 | data.forEach(element => { 10 | document.querySelector(".UserData").innerHTML += ` 11 | 12 | ${element.userID} 13 | ${element.firstName} 14 | ${element.lastName} 15 | ${element.mobile} 16 | ${element.email} 17 | ${element.totalReservation} 18 | ${element.totalFeedBack} 19 | 20 | 21 | 22 | 23 | ` 24 | }); 25 | }) 26 | .catch(error => { 27 | console.log('Error:', error); 28 | }); -------------------------------------------------------------------------------- /FrontEnd/js/home.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Github2k10/Safar/546d0ce4f040132a8069d30eaf83e43ff8b49d8e/FrontEnd/js/home.js -------------------------------------------------------------------------------- /FrontEnd/js/modeToggle.js: -------------------------------------------------------------------------------- 1 | const body = document.querySelector("body"), 2 | modeToggle = body.querySelector(".mode-toggle"); 3 | sidebar = body.querySelector("nav"); 4 | sidebarToggle = body.querySelector(".sidebar-toggle"); 5 | 6 | let getMode = localStorage.getItem("mode"); 7 | if(getMode && getMode ==="dark"){ 8 | body.classList.toggle("dark"); 9 | } 10 | 11 | let getStatus = localStorage.getItem("status"); 12 | if(getStatus && getStatus ==="close"){ 13 | sidebar.classList.toggle("close"); 14 | } 15 | 16 | modeToggle.addEventListener("click", () =>{ 17 | body.classList.toggle("dark"); 18 | if(body.classList.contains("dark")){ 19 | localStorage.setItem("mode", "dark"); 20 | }else{ 21 | localStorage.setItem("mode", "light"); 22 | } 23 | }); 24 | 25 | sidebarToggle.addEventListener("click", () => { 26 | sidebar.classList.toggle("close"); 27 | if(sidebar.classList.contains("close")){ 28 | localStorage.setItem("status", "close"); 29 | }else{ 30 | localStorage.setItem("status", "open"); 31 | } 32 | }) -------------------------------------------------------------------------------- /FrontEnd/js/signup.js: -------------------------------------------------------------------------------- 1 | let email = "abc@gmail.com"; 2 | let password = "abc123"; 3 | 4 | const loginText = document.querySelector(".title-text .login"); 5 | const loginForm = document.querySelector("form.login"); 6 | const loginBtn = document.querySelector("label.login"); 7 | const signupBtn = document.querySelector("label.signup"); 8 | const signupLink = document.querySelector("form .signup-link a"); 9 | 10 | 11 | signupBtn.onclick = (()=>{ 12 | loginForm.style.marginLeft = "-50%"; 13 | loginText.style.marginLeft = "-50%"; 14 | 15 | document.querySelector("#loginEmail").value = ""; 16 | document.querySelector("#loginPassword").value = ""; 17 | }); 18 | 19 | loginBtn.onclick = (()=>{ 20 | loginForm.style.marginLeft = "0%"; 21 | loginText.style.marginLeft = "0%"; 22 | }); 23 | 24 | signupLink.onclick = (()=>{ 25 | signupBtn.click(); 26 | return false; 27 | }); 28 | 29 | let forms = document.querySelectorAll("form"); 30 | 31 | forms[0].addEventListener("submit", login); 32 | 33 | function login(event){ 34 | event.preventDefault(); 35 | let mail = document.querySelector("#loginEmail"); 36 | let pass = document.querySelector("#loginPassword"); 37 | 38 | if(mail.value == email && pass.value == password){ 39 | document.querySelector("#success").classList.add("open-success"); 40 | } else { 41 | document.querySelector("#error").classList.add("open-error"); 42 | } 43 | } 44 | 45 | function closeSuccess(){ 46 | document.querySelector("#success").classList.remove("open-success"); 47 | } 48 | 49 | function closeError(){ 50 | document.querySelector("#error").classList.remove("open-error"); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /FrontEnd/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Safar.com 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 | 24 | 25 |
26 |
27 |
28 | 29 | 30 | 31 | 32 |
33 |
34 |
35 | 49 | 50 | 68 |
69 |
70 |
71 |
72 |
73 | 74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |

Success!

yay, everything is working.

85 | 86 |
87 | 88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |

Error!

oh no, something went wrong.

98 | 99 |
100 |
101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## SAFAR :- BUS RESERVATION MANAGEMENT PORTAL 4 | 5 | The bus reservation system portal is a web-based application that enables users to book bus tickets online. The system will allow users book available buses based on their source and destination cities, reserve the seats, and make payments securely. The system will also provide a UI based dashboard for admin to manage their bus related operations. 6 | 7 | 8 | ## Features 9 | 10 | * User and Admin authentication & validation with session uuid. 11 | 12 | #### Admin Features: 13 | 14 | - Administrator Role of the entire application 15 | - Only registered admins with valid session token can add/update/delete route and bus from main database 16 | - Admin can access the details of different users and reservations. 17 | #### User Features: 18 | - Registering themselves with application, and logging in to get the valid session token 19 | - Viewing list of available buses and booking a reservation 20 | - Only logged in user can access his reservations, profile updation and other features. 21 | 22 |
23 | 24 | ## ER Diagrm 25 | 26 | 27 |
28 | 29 | ## Flow Chart 30 | 31 | 32 | ## Modules 33 | 34 | * Login, Logout Module 35 | * Admin Module 36 | * User Module 37 | * Route Module 38 | * Bus Module 39 | * Reservation Module 40 | * Feedback Module 41 | 42 | ## 🏷️ Tech Stack Used :- 43 | * Java 44 | * Spring Framework 45 | * Spring Boot 46 | * Spring Data JPA 47 | * Hibernate 48 | * MySQL 49 | * HTML 50 | * CSS 51 | * JavaScript 52 | 53 | ## Installation & Run 54 | 55 | * Before running the API server, you should update the database config inside the [application.properties](https://github.com/AbhayKumarVishwakarma/few-houses-4121/blob/main/Bus%20Reservation%20System%20Portal/Backend/bus_reservation/src/main/resources/application.properties) file. 56 | * Update the port number, username and password as per your local database config. 57 | 58 | ``` 59 | #db specific properties 60 | spring.datasource.url=jdbc:mysql://localhost:3306/busdb 61 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 62 | spring.datasource.username=root 63 | spring.datasource.password=root 64 | 65 | #ORM s/w specific properties 66 | spring.jpa.hibernate.ddl-auto=update 67 | spring.jpa.show-sql=true 68 | 69 | ``` 70 | 71 | ## API Root Endpoint 72 | 73 | `https://localhost:8080/` 74 | 75 | `http://localhost:8080/swagger-ui/index.html` 76 | 77 | --------------------------------------------------------------------------------