Dinesh Veeran %!s(int64=3) %!d(string=hai) anos
achega
b07b53cb1f

+ 47 - 0
Admin/Asset/add.php

@@ -0,0 +1,47 @@
+<?php
+include_once "../../include/DB.php";
+
+$AssetID="";
+$AssetName="";
+$AssetCategoryID="";
+$IsInServiceCenter=1;
+
+if (isset($_POST["AssetID"]) && !empty($_POST["AssetID"])) {
+   $AssetID=$_POST["AssetID"];
+}
+if (isset($_POST["AssetName"]) && !empty($_POST["AssetName"])) {
+   $AssetName=$_POST["AssetName"];
+}
+if (isset($_POST["AssetCategoryID"]) && !empty($_POST["AssetCategoryID"])) {
+   $AssetCategoryID=$_POST["AssetCategoryID"];
+}
+if (isset($_POST["IsInServiceCenter"]) && !empty($_POST["IsInServiceCenter"])) {
+   $IsInServiceCenter=$_POST["IsInServiceCenter"];
+}
+
+$AssetInsertSql = "INSERT INTO asset(AssetID, AssetName, AssetCategoryID, IsInServiceCenter) VALUES ('$AssetID','$AssetName','$AssetCategoryID','$IsInServiceCenter')";
+
+$AssetInsertresult = $conn->query($AssetInsertSql);
+if ($AssetInsertresult === TRUE) {
+    $value = array(
+        "AssetID"=>$AssetID,
+        "AssetName"=>$AssetName,
+        "AssetCategoryID"=>$AssetCategoryID,
+        "IsInServiceCenter"=>$IsInServiceCenter,
+        "Message"=>"Data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 38 - 0
Admin/Asset/change_asset.php

@@ -0,0 +1,38 @@
+<?php
+include_once "../../include/DB.php";
+
+$AssetID="";
+$IsInServiceCenter=0;
+
+if (isset($_POST["AssetID"]) && !empty($_POST["AssetID"])) {
+    $AssetID=$_POST["AssetID"];
+}
+if (isset($_POST["IsInServiceCenter"]) && !empty($_POST["IsInServiceCenter"])) {
+    $IsInServiceCenter=$_POST["IsInServiceCenter"];
+}
+
+$AssetUpdateSql = "UPDATE asset SET IsInServiceCenter='$IsInServiceCenter' WHERE AssetID='$AssetID'";
+
+$AssetUpdateResult = $conn->query($AssetUpdateSql);
+if ($AssetUpdateResult === TRUE) {
+    $value = array(
+        "AssetID"=>$AssetID,
+        "IsInServiceCenter"=>(int)$IsInServiceCenter,
+        "Message"=>"Asset data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    // Declare an array with error message 
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 66 - 0
Admin/Asset/check_asset.php

@@ -0,0 +1,66 @@
+<?php
+include_once "../../include/DB.php";
+
+$AssetID="";
+
+if (isset($_POST["AssetID"]) && !empty($_POST["AssetID"])) {
+   $AssetID=$_POST["AssetID"];
+}
+
+$assetsql = "SELECT *,
+asset.CreatedAt AS AssetCreatedAt,
+asset.UpdatedAt AS AssetUpdatedAt,
+assetcategory.CreatedAt AS AssetCategoryCreatedAt,
+assetcategory.UpdatedAt AS AssetCategoryUpdatedAt
+FROM asset asset
+JOIN assetcategory assetcategory ON assetcategory.AssetCategoryID =asset.AssetCategoryID
+WHERE asset.AssetID='$AssetID'";
+$assetresult = $conn->query($assetsql);
+
+$assetlistArray= [];
+if ($assetresult!== false && $assetresult->num_rows > 0) {
+    while($sassetrow = $assetresult->fetch_assoc()) {
+        $assetvalue = array(
+            "AssetID"=>$sassetrow["AssetID"],
+            "AssetName"=>$sassetrow["AssetName"],
+            "AssetCategoryID"=>(int)$sassetrow["AssetCategoryID"],
+            "AssetCategory"=>array(
+                "AssetCategoryID"=>(int)$sassetrow["AssetCategoryID"],
+                "AssetCategoryTitle"=>$sassetrow["AssetCategoryTitle"],
+                "AssetCategoryCreatedAt"=>$sassetrow["AssetCategoryCreatedAt"],
+                "AssetCategoryUpdatedAt"=>$sassetrow["AssetCategoryUpdatedAt"],
+            ),
+            "IsInServiceCenter"=>(int)$sassetrow["IsInServiceCenter"],
+            "AssetCreatedAt"=>$sassetrow["AssetCreatedAt"],
+            "AssetUpdatedAt"=>$sassetrow["AssetUpdatedAt"],
+        );
+        $assetlistArray[]= $assetvalue;
+    }
+    $count = count($assetlistArray);
+    if($count==1){
+        // Use json_encode() function
+        $json = json_encode($assetlistArray[0]);
+    }else {
+        // Use json_encode() function
+        $json = json_encode($assetlistArray);
+    }
+}else { 
+    http_response_code(404);  
+    $errorMesage= $conn->error;
+    if ($errorMesage=="") {
+        $errorMesage = "AssetID not available";
+        if ($AssetID=="") {
+            $errorMesage = "AssetID is empty";
+        }
+    }
+    // Declare an array with error message 
+    $value = array(
+        "Message"=>"Failed to get data",
+        "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo($json);
+$conn->close();

+ 81 - 0
Admin/Recharge/add_recharge.php

@@ -0,0 +1,81 @@
+<?php
+include_once "../../include/DB.php";
+
+$RiderID="";
+$PaymentType="";
+$SwapRechargeCount="";
+$TransactionID="";
+
+if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
+    $RiderID=$_POST["RiderID"];
+}
+if (isset($_POST["PaymentType"]) && !empty($_POST["PaymentType"])) {
+    $PaymentType=$_POST["PaymentType"];
+}
+if (isset($_POST["SwapRechargeCount"]) && !empty($_POST["SwapRechargeCount"])) {
+    $SwapRechargeCount=$_POST["SwapRechargeCount"];
+}
+if (isset($_POST["TransactionID"]) && !empty($_POST["TransactionID"])) {
+    $TransactionID=$_POST["TransactionID"];
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+$RiderPostData = array(
+    'RiderID' => $RiderID
+);
+$CheckRidertURL = "http://localhost/cygnusa/batterySwap/api/User/";
+$CheckRidertCURL = curl_init($CheckRidertURL);
+curl_setopt($CheckRidertCURL, CURLOPT_HEADER, false);
+curl_setopt($CheckRidertCURL, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($CheckRidertCURL, CURLOPT_POST, true);
+curl_setopt($CheckRidertCURL, CURLOPT_POSTFIELDS, $RiderPostData);
+$CheckRidertJsonResponse = curl_exec($CheckRidertCURL);
+$RiderResult = json_decode($CheckRidertJsonResponse, true);
+
+$TotalRechargedSwapCount=$RiderResult["SwapData"]["RechargeData"]["Total"];
+$UsedRechargedSwapCount=$RiderResult["SwapData"]["RechargeData"]["Used"];
+$AvailableRechargedSwapCount=$RiderResult["SwapData"]["RechargeData"]["Available"];
+$SwapRechargeID=$RiderResult["SwapData"]["RechargeData"]["SwapRechargeID"];
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+$RechargePostData = array(
+    'SwapRechargeID' => $SwapRechargeID,
+    'TotalRechargedSwapCount' => ($TotalRechargedSwapCount+$SwapRechargeCount),
+    'UsedRechargedSwapCount' => $UsedRechargedSwapCount,
+    'AvailableRechargedSwapCount' => ($AvailableRechargedSwapCount+$SwapRechargeCount),
+);
+$RechargeURL = "http://localhost/cygnusa/batterySwap/api/Admin/Recharge/";
+$RechargeCURL = curl_init($RechargeURL);
+curl_setopt($RechargeCURL, CURLOPT_HEADER, false);
+curl_setopt($RechargeCURL, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($RechargeCURL, CURLOPT_POST, true);
+curl_setopt($RechargeCURL, CURLOPT_POSTFIELDS, $RechargePostData);
+$RechargeJsonResponse = curl_exec($RechargeCURL);
+$RechargeResult = json_decode($RechargeJsonResponse, true);
+
+$rechargehistoryInsertSql = "INSERT INTO rechargehistory(RiderID, TransactionID, PaymentTypeID, RechargeCount) VALUES ('$RiderID','$TransactionID','$PaymentType','$SwapRechargeCount')";
+
+$rechargehistoryInsertresult = $conn->query($rechargehistoryInsertSql);
+if ($rechargehistoryInsertresult === TRUE) { 
+   
+    
+    $value = array(
+        "RiderID"=>$RiderID,
+        "Recharge"=>$RechargeResult,
+        "Message"=>"Swap Data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    // Declare an array with error message 
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 48 - 0
Admin/Recharge/index.php

@@ -0,0 +1,48 @@
+<?php
+include_once "../../include/DB.php";
+
+$TotalRechargedSwapCount=0;
+$UsedRechargedSwapCount=0;
+$AvailableRechargedSwapCount=0;
+$SwapRechargeID="";
+
+if (isset($_POST["TotalRechargedSwapCount"]) && !empty($_POST["TotalRechargedSwapCount"])) {
+    $TotalRechargedSwapCount=$_POST["TotalRechargedSwapCount"];
+}
+if (isset($_POST["UsedRechargedSwapCount"]) && !empty($_POST["UsedRechargedSwapCount"])) {
+    $UsedRechargedSwapCount=$_POST["UsedRechargedSwapCount"];
+}
+if (isset($_POST["AvailableRechargedSwapCount"]) && !empty($_POST["AvailableRechargedSwapCount"])) {
+    $AvailableRechargedSwapCount=$_POST["AvailableRechargedSwapCount"];
+}
+if (isset($_POST["SwapRechargeID"]) && !empty($_POST["SwapRechargeID"])) {
+    $SwapRechargeID=$_POST["SwapRechargeID"];
+}
+
+$SwapRechargeUpdateSql = "UPDATE swaprecharge SET TotalRechargedSwapCount='$TotalRechargedSwapCount',UsedSwapCount='$UsedRechargedSwapCount',AvailableSwapCount='$AvailableRechargedSwapCount' WHERE SwapRechargeID='$SwapRechargeID'";
+
+$SwapRechargeUpdateResult = $conn->query($SwapRechargeUpdateSql);
+if ($SwapRechargeUpdateResult === TRUE) {
+    $value = array(
+        "SwapRechargeID"=>(int)$SwapRechargeID,
+        "TotalRechargedSwapCount"=>(int)$TotalRechargedSwapCount,
+        "UsedRechargedSwapCount"=>(int)$UsedRechargedSwapCount,
+        "AvailableRechargedSwapCount"=>(int)$AvailableRechargedSwapCount,
+        "Message"=>"Swap recharge data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    // Declare an array with error message 
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 57 - 0
Admin/Refer/add_refer.php

@@ -0,0 +1,57 @@
+<?php
+include_once "../../include/DB.php";
+
+$RiderID="";
+$SwapReferCount="";
+
+if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
+    $RiderID=$_POST["RiderID"];
+}
+if (isset($_POST["SwapReferCount"]) && !empty($_POST["SwapReferCount"])) {
+    $SwapReferCount=$_POST["SwapReferCount"];
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+$RiderPostData = array(
+    'RiderID' => $RiderID
+);
+$CheckRidertURL = "http://localhost/cygnusa/batterySwap/api/User/";
+$CheckRidertCURL = curl_init($CheckRidertURL);
+curl_setopt($CheckRidertCURL, CURLOPT_HEADER, false);
+curl_setopt($CheckRidertCURL, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($CheckRidertCURL, CURLOPT_POST, true);
+curl_setopt($CheckRidertCURL, CURLOPT_POSTFIELDS, $RiderPostData);
+$CheckRidertJsonResponse = curl_exec($CheckRidertCURL);
+$RiderResult = json_decode($CheckRidertJsonResponse, true);
+
+$TotalReferdSwapCount=$RiderResult["SwapData"]["ReferData"]["Total"];
+$UsedReferdSwapCount=$RiderResult["SwapData"]["ReferData"]["Used"];
+$AvailableReferdSwapCount=$RiderResult["SwapData"]["ReferData"]["Available"];
+$SwapReferID=$RiderResult["SwapData"]["ReferData"]["SwapReferID"];
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+$ReferPostData = array(
+    'SwapReferID' => $SwapReferID,
+    'TotalReferdSwapCount' => ($TotalReferdSwapCount+$SwapReferCount),
+    'UsedReferdSwapCount' => $UsedReferdSwapCount,
+    'AvailableReferdSwapCount' => ($AvailableReferdSwapCount+$SwapReferCount),
+);
+$ReferURL = "http://localhost/cygnusa/batterySwap/api/Admin/Refer/";
+$ReferCURL = curl_init($ReferURL);
+curl_setopt($ReferCURL, CURLOPT_HEADER, false);
+curl_setopt($ReferCURL, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($ReferCURL, CURLOPT_POST, true);
+curl_setopt($ReferCURL, CURLOPT_POSTFIELDS, $ReferPostData);
+$ReferJsonResponse = curl_exec($ReferCURL);
+$ReferResult = json_decode($ReferJsonResponse, true);
+
+$value = array(
+"RiderID"=>$RiderID,
+"Refer"=>$ReferResult,
+"Message"=>"Swap Data saved successfully",
+);
+// Use json_encode() function
+$json = json_encode($value);
+
+// Display the output
+echo ($json);
+$conn->close();

+ 48 - 0
Admin/Refer/index.php

@@ -0,0 +1,48 @@
+<?php
+include_once "../../include/DB.php";
+
+$SwapReferID="";
+$TotalReferdSwapCount=0;
+$UsedReferdSwapCount=0;
+$AvailableReferdSwapCount=0;
+
+if (isset($_POST["SwapReferID"]) && !empty($_POST["SwapReferID"])) {
+    $SwapReferID=$_POST["SwapReferID"];
+}
+if (isset($_POST["TotalReferdSwapCount"]) && !empty($_POST["TotalReferdSwapCount"])) {
+    $TotalReferdSwapCount=$_POST["TotalReferdSwapCount"];
+}
+if (isset($_POST["UsedReferdSwapCount"]) && !empty($_POST["UsedReferdSwapCount"])) {
+    $UsedReferdSwapCount=$_POST["UsedReferdSwapCount"];
+}
+if (isset($_POST["AvailableReferdSwapCount"]) && !empty($_POST["AvailableReferdSwapCount"])) {
+    $AvailableReferdSwapCount=$_POST["AvailableReferdSwapCount"];
+}
+
+$SwapRechargeUpdateSql = "UPDATE swaprefer SET TotalFreeSwapCount='$TotalReferdSwapCount',UsedSwapCount='$UsedReferdSwapCount',AvailableSwapCount='$AvailableReferdSwapCount' WHERE SwapReferID='$SwapReferID'";
+
+$SwapRechargeUpdateResult = $conn->query($SwapRechargeUpdateSql);
+if ($SwapRechargeUpdateResult === TRUE) {
+    $value = array(
+        "SwapReferID"=>(int)$SwapReferID,
+        "TotalReferdSwapCount"=>(int)$TotalReferdSwapCount,
+        "UsedReferdSwapCount"=>(int)$UsedReferdSwapCount,
+        "AvailableReferdSwapCount"=>(int)$AvailableReferdSwapCount,
+        "Message"=>"Swap refer data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    // Declare an array with error message 
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 62 - 0
Admin/Service/add_service.php

@@ -0,0 +1,62 @@
+<?php
+include_once "../../include/DB.php";
+
+$AssetID="";
+
+if (isset($_POST["AssetID"]) && !empty($_POST["AssetID"])) {
+   $AssetID=$_POST["AssetID"];
+}
+
+$ServiceCheckSQL = "SELECT * FROM servicehistory servicehistory WHERE servicehistory.AssetID='$AssetID' AND servicehistory.isServiced='0'";
+
+$ServiceCheckResult = $conn->query($ServiceCheckSQL);
+if ($ServiceCheckResult!== false && $ServiceCheckResult->num_rows > 0) {
+
+    while($ServiceCheckRow = $ServiceCheckResult->fetch_assoc()) {
+        $ServiceHistoryID = $ServiceCheckRow["ServiceHistoryID"];
+        $ServiceUpdateSQL = "UPDATE servicehistory servicehistory SET servicehistory.InWard='$currentDateTime',isServiced='1' WHERE servicehistory.ServiceHistoryID='$ServiceHistoryID'";
+        $ServiceUpdateResult = $conn->query($ServiceUpdateSQL);
+        if ($ServiceUpdateResult === TRUE) {
+            $value = array(
+                "Message"=>"Service updated successfully",
+              );
+              // Use json_encode() function
+              $json = json_encode($value);
+        }else {
+            http_response_code(404);
+            $errorMesage= $conn->error;
+            // Declare an array with error message 
+            $value = array(
+              "Message"=>"Something went wrong",
+              "Error"=>$errorMesage
+            );
+            // Use json_encode() function
+            $json = json_encode($value);
+        }
+    }
+    
+}else {
+
+    $ServiceInsertSQL = "INSERT INTO servicehistory(AssetID) VALUES ('$AssetID')";
+    $ServiceInsertResult = $conn->query($ServiceInsertSQL);
+    if ($ServiceInsertResult === TRUE) {
+        $value = array(
+            "Message"=>"Service insert successfully",
+          );
+          // Use json_encode() function
+          $json = json_encode($value);
+    }else {
+        http_response_code(404);
+        $errorMesage= $conn->error;
+        // Declare an array with error message 
+        $value = array(
+          "Message"=>"Something went wrong",
+          "Error"=>$errorMesage
+        );
+        // Use json_encode() function
+        $json = json_encode($value);
+    }
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 43 - 0
Admin/Swap/free_swap.php

@@ -0,0 +1,43 @@
+<?php
+include_once "../../include/DB.php";
+
+$RiderID="";
+$ReturnBatteryID="";
+$SwapBatteryID="";
+
+if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
+    $RiderID=$_POST["RiderID"];
+}
+if (isset($_POST["ReturnBatteryID"]) && !empty($_POST["ReturnBatteryID"])) {
+    $ReturnBatteryID=$_POST["ReturnBatteryID"];
+}
+if (isset($_POST["SwapBatteryID"]) && !empty($_POST["SwapBatteryID"])) {
+    $SwapBatteryID=$_POST["SwapBatteryID"];
+}
+
+$SwapInsertSql = "INSERT INTO swap(RiderID, ReturnBatterID, SwappedBatterID) VALUES ('$RiderID','$ReturnBatteryID','$SwapBatteryID')";
+
+$SwapInsertresult = $conn->query($SwapInsertSql);
+if ($SwapInsertresult === TRUE) {
+    $value = array(
+        "RiderID"=>$RiderID,
+        "ReturnBatteryID"=>$ReturnBatteryID,
+        "SwapBatteryID"=>$SwapBatteryID,
+        "Message"=>"Swap Data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    // Declare an array with error message 
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 145 - 0
Admin/Swap/index.php

@@ -0,0 +1,145 @@
+<?php
+include_once "../../include/DB.php";
+
+$RiderID="";
+$ReturnBatteryID="";
+$SwapBatteryID="";
+
+if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
+    $RiderID=$_POST["RiderID"];
+}
+if (isset($_POST["ReturnBatteryID"]) && !empty($_POST["ReturnBatteryID"])) {
+    $ReturnBatteryID=$_POST["ReturnBatteryID"];
+}
+if (isset($_POST["SwapBatteryID"]) && !empty($_POST["SwapBatteryID"])) {
+    $SwapBatteryID=$_POST["SwapBatteryID"];
+}
+
+$RaiderPostData = array(
+    'RiderID' => $RiderID
+);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+$CheckRaidertURL = "http://localhost/cygnusa/batterySwap/api/User/";
+$CheckRaidertCURL = curl_init($CheckRaidertURL);
+curl_setopt($CheckRaidertCURL, CURLOPT_HEADER, false);
+curl_setopt($CheckRaidertCURL, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($CheckRaidertCURL, CURLOPT_POST, true);
+curl_setopt($CheckRaidertCURL, CURLOPT_POSTFIELDS, $RaiderPostData);
+$CheckRaidertJsonResponse = curl_exec($CheckRaidertCURL);
+
+
+$RaiderResult = json_decode($CheckRaidertJsonResponse, true);
+$AvailableRemainingSwapCount=$RaiderResult["SwapData"]["RemainingData"]["Available"];
+$AvailableFreeSwapCount=$RaiderResult["SwapData"]["FreeData"]["Available"];
+
+$TotalRechargedSwapCount=$RaiderResult["SwapData"]["RechargeData"]["Total"];
+$UsedRechargedSwapCount=$RaiderResult["SwapData"]["RechargeData"]["Used"];
+$AvailableRechargedSwapCount=$RaiderResult["SwapData"]["RechargeData"]["Available"];
+$SwapRechargeID=$RaiderResult["SwapData"]["RechargeData"]["SwapRechargeID"];
+
+$TotalReferSwapCount=$RaiderResult["SwapData"]["ReferData"]["Total"];
+$UsedReferSwapCount=$RaiderResult["SwapData"]["ReferData"]["Used"];
+$AvailableReferSwapCount=$RaiderResult["SwapData"]["ReferData"]["Available"];
+$SwapReferID=$RaiderResult["SwapData"]["ReferData"]["SwapReferID"];
+
+if ($AvailableRemainingSwapCount>0) {
+    if ($AvailableFreeSwapCount>0) {
+        $FreeSwapPostData = array(
+            'RiderID' => $RiderID,
+            'ReturnBatteryID' => $ReturnBatteryID,
+            'SwapBatteryID' => $SwapBatteryID,
+        );
+        $FreeSwapBatteryURL = "http://localhost/cygnusa/batterySwap/api/Admin/Swap/free_swap.php";
+        $FreeSwapBatteryCURL = curl_init($FreeSwapBatteryURL);
+        curl_setopt($FreeSwapBatteryCURL, CURLOPT_HEADER, false);
+        curl_setopt($FreeSwapBatteryCURL, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($FreeSwapBatteryCURL, CURLOPT_POST, true);
+        curl_setopt($FreeSwapBatteryCURL, CURLOPT_POSTFIELDS, $FreeSwapPostData);
+        $SwapBatteryJsonResponse = curl_exec($FreeSwapBatteryCURL);
+    } 
+    else if ($AvailableReferSwapCount>0){
+        $ReferSwapPostData = array(
+            'RiderID' => $RiderID,
+            'ReturnBatteryID' => $ReturnBatteryID,
+            'SwapBatteryID' => $SwapBatteryID,
+            'SwapReferID' => $SwapReferID,
+            'TotalReferSwapCount' => ($TotalReferSwapCount),
+            'UsedReferSwapCount' => ($UsedReferSwapCount+1),
+            'AvailableReferSwapCount' => ($AvailableReferSwapCount-1),
+        );
+        $ReferSwapBatteryURL = "http://localhost/cygnusa/batterySwap/api/Admin/Swap/refer_swap.php";
+        $ReferSwapBatteryCURL = curl_init($ReferSwapBatteryURL);
+        curl_setopt($ReferSwapBatteryCURL, CURLOPT_HEADER, false);
+        curl_setopt($ReferSwapBatteryCURL, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ReferSwapBatteryCURL, CURLOPT_POST, true);
+        curl_setopt($ReferSwapBatteryCURL, CURLOPT_POSTFIELDS, $ReferSwapPostData);
+        $SwapBatteryJsonResponse = curl_exec($ReferSwapBatteryCURL);
+    }
+    else if ($AvailableRechargedSwapCount>0){
+        $RechargeSwapPostData = array(
+            'RiderID' => $RiderID,
+            'ReturnBatteryID' => $ReturnBatteryID,
+            'SwapBatteryID' => $SwapBatteryID,
+            'SwapRechargeID' => $SwapRechargeID,
+            'TotalRechargedSwapCount' => ($TotalRechargedSwapCount),
+            'UsedRechargedSwapCount' => ($UsedRechargedSwapCount+1),
+            'AvailableRechargedSwapCount' => ($AvailableRechargedSwapCount-1),
+        );
+        $RechargeSwapBatteryURL = "http://localhost/cygnusa/batterySwap/api/Admin/Swap/Recharge_swap.php";
+        $RechargeSwapBatteryCURL = curl_init($RechargeSwapBatteryURL);
+        curl_setopt($RechargeSwapBatteryCURL, CURLOPT_HEADER, false);
+        curl_setopt($RechargeSwapBatteryCURL, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($RechargeSwapBatteryCURL, CURLOPT_POST, true);
+        curl_setopt($RechargeSwapBatteryCURL, CURLOPT_POSTFIELDS, $RechargeSwapPostData);
+        $SwapBatteryJsonResponse = curl_exec($RechargeSwapBatteryCURL);
+    }
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    $ReturnBatteryPostData = array(
+        'AssetID' => $ReturnBatteryID,
+        "IsInServiceCenter"=>1,
+    );
+    $ChangeReturnBatteryAssetURL = "http://localhost/cygnusa/batterySwap/api/Admin/Asset/change_asset.php";
+    $ChangeReturnBatteryAssetCURL = curl_init($ChangeReturnBatteryAssetURL);
+    curl_setopt($ChangeReturnBatteryAssetCURL, CURLOPT_HEADER, false);
+    curl_setopt($ChangeReturnBatteryAssetCURL, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($ChangeReturnBatteryAssetCURL, CURLOPT_POST, true);
+    curl_setopt($ChangeReturnBatteryAssetCURL, CURLOPT_POSTFIELDS, $ReturnBatteryPostData);
+    $ReturnBatteryAssetJsonResponse = curl_exec($ChangeReturnBatteryAssetCURL);
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    $SwapBatteryPostData = array(
+        'AssetID' => $SwapBatteryID,
+        "IsInServiceCenter"=>0,
+    );
+    $ChangeSwapBatteryAssetURL = "http://localhost/cygnusa/batterySwap/api/Admin/Asset/change_asset.php";
+    $ChangeSwapBatteryAssetCURL = curl_init($ChangeSwapBatteryAssetURL);
+    curl_setopt($ChangeSwapBatteryAssetCURL, CURLOPT_HEADER, false);
+    curl_setopt($ChangeSwapBatteryAssetCURL, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($ChangeSwapBatteryAssetCURL, CURLOPT_POST, true);
+    curl_setopt($ChangeSwapBatteryAssetCURL, CURLOPT_POSTFIELDS, $SwapBatteryPostData);
+    $SwapBatteryAssetJsonResponse = curl_exec($ChangeSwapBatteryAssetCURL);
+    
+    $value = array(
+        "SwapResult"=>json_decode($SwapBatteryJsonResponse),
+        "ReturnBatteryResult"=>json_decode($ReturnBatteryAssetJsonResponse),
+        "SwapBatteryResult"=>json_decode($SwapBatteryAssetJsonResponse),
+        "Message"=>"Swap done",
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}else {
+    $value = array(
+        "Message"=>"Swap failed. Please recharge to swap",
+        "Error"=>"Please recharge to swap"
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo($json);
+
+$conn->close();

+ 74 - 0
Admin/Swap/recharge_swap.php

@@ -0,0 +1,74 @@
+<?php
+include_once "../../include/DB.php";
+
+$RiderID="";
+$ReturnBatteryID="";
+$SwapBatteryID="";
+$SwapRechargeID="";
+$TotalRechargedSwapCount="";
+$UsedRechargedSwapCount="";
+$AvailableRechargedSwapCount="";
+
+if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
+    $RiderID=$_POST["RiderID"];
+}
+if (isset($_POST["ReturnBatteryID"]) && !empty($_POST["ReturnBatteryID"])) {
+    $ReturnBatteryID=$_POST["ReturnBatteryID"];
+}
+if (isset($_POST["SwapBatteryID"]) && !empty($_POST["SwapBatteryID"])) {
+    $SwapBatteryID=$_POST["SwapBatteryID"];
+}
+if (isset($_POST["SwapRechargeID"]) && !empty($_POST["SwapRechargeID"])) {
+    $SwapRechargeID=$_POST["SwapRechargeID"];
+}
+if (isset($_POST["TotalRechargedSwapCount"]) && !empty($_POST["TotalRechargedSwapCount"])) {
+    $TotalRechargedSwapCount=$_POST["TotalRechargedSwapCount"];
+}
+if (isset($_POST["UsedRechargedSwapCount"]) && !empty($_POST["UsedRechargedSwapCount"])) {
+    $UsedRechargedSwapCount=$_POST["UsedRechargedSwapCount"];
+}
+if (isset($_POST["AvailableRechargedSwapCount"]) && !empty($_POST["AvailableRechargedSwapCount"])) {
+    $AvailableRechargedSwapCount=$_POST["AvailableRechargedSwapCount"];
+}
+
+$SwapInsertSql = "INSERT INTO swap(RiderID, SwapRechargeID, ReturnBatterID, SwappedBatterID,IsFreeSwap) VALUES ('$RiderID','$SwapRechargeID','$ReturnBatteryID','$SwapBatteryID','0')";
+
+$SwapInsertresult = $conn->query($SwapInsertSql);
+if ($SwapInsertresult === TRUE) {
+
+    $RechargePostData = array(
+        'SwapRechargeID' => $SwapRechargeID,
+        'TotalRechargedSwapCount' => $TotalRechargedSwapCount,
+        'UsedRechargedSwapCount' => $UsedRechargedSwapCount,
+        'AvailableRechargedSwapCount' => $AvailableRechargedSwapCount,
+    );
+    $RechargeURL = "http://localhost/cygnusa/batterySwap/api/Admin/Recharge/";
+    $RechargeCURL = curl_init($RechargeURL);
+    curl_setopt($RechargeCURL, CURLOPT_HEADER, false);
+    curl_setopt($RechargeCURL, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($RechargeCURL, CURLOPT_POST, true);
+    curl_setopt($RechargeCURL, CURLOPT_POSTFIELDS, $RechargePostData);
+    $RechargeJsonResponse = curl_exec($RechargeCURL);
+    $value = array(
+        "RiderID"=>$RiderID,
+        "ReturnBatteryID"=>$ReturnBatteryID,
+        "SwapBatteryID"=>$SwapBatteryID,
+        "Recharge"=>$RechargeJsonResponse,
+        "Message"=>"Swap Data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    // Declare an array with error message 
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 73 - 0
Admin/Swap/refer_swap.php

@@ -0,0 +1,73 @@
+<?php
+include_once "../../include/DB.php";
+
+$RiderID="";
+$ReturnBatteryID="";
+$SwapBatteryID="";
+$SwapReferID="";
+$TotalReferdSwapCount="";
+$UsedReferdSwapCount="";
+$AvailableReferdSwapCount="";
+
+if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
+    $RiderID=$_POST["RiderID"];
+}
+if (isset($_POST["ReturnBatteryID"]) && !empty($_POST["ReturnBatteryID"])) {
+    $ReturnBatteryID=$_POST["ReturnBatteryID"];
+}
+if (isset($_POST["SwapBatteryID"]) && !empty($_POST["SwapBatteryID"])) {
+    $SwapBatteryID=$_POST["SwapBatteryID"];
+}
+if (isset($_POST["SwapReferID"]) && !empty($_POST["SwapReferID"])) {
+    $SwapReferID=$_POST["SwapReferID"];
+}
+if (isset($_POST["TotalReferdSwapCount"]) && !empty($_POST["TotalReferdSwapCount"])) {
+    $TotalReferdSwapCount=$_POST["TotalReferdSwapCount"];
+}
+if (isset($_POST["UsedReferdSwapCount"]) && !empty($_POST["UsedReferdSwapCount"])) {
+    $UsedReferdSwapCount=$_POST["UsedReferdSwapCount"];
+}
+if (isset($_POST["AvailableReferdSwapCount"]) && !empty($_POST["AvailableReferdSwapCount"])) {
+    $AvailableReferdSwapCount=$_POST["AvailableReferdSwapCount"];
+}
+
+$SwapInsertSql = "INSERT INTO swap(RiderID, SwapReferID, ReturnBatterID, SwappedBatterID, IsFreeSwap) VALUES ('$RiderID','$SwapReferID','$ReturnBatteryID','$SwapBatteryID','0')";
+
+$SwapInsertresult = $conn->query($SwapInsertSql);
+if ($SwapInsertresult === TRUE) { 
+    $ReferPostData = array(
+        'SwapReferID' => $SwapReferID,
+        'TotalReferdSwapCount' => $TotalReferdSwapCount,
+        'UsedReferdSwapCount' => $UsedReferdSwapCount,
+        'AvailableReferdSwapCount' => $AvailableReferdSwapCount,
+    );
+    $ReferURL = "http://localhost/cygnusa/batterySwap/api/Admin/Refer";
+    $ReferCURL = curl_init($ReferURL);
+    curl_setopt($ReferCURL, CURLOPT_HEADER, false);
+    curl_setopt($ReferCURL, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($ReferCURL, CURLOPT_POST, true);
+    curl_setopt($ReferCURL, CURLOPT_POSTFIELDS, $ReferPostData);
+    $ReferJsonResponse = curl_exec($ReferCURL);
+    $value = array(
+        "RiderID"=>$RiderID,
+        "ReturnBatteryID"=>$ReturnBatteryID,
+        "SwapBatteryID"=>$SwapBatteryID,
+        "Refer"=>$ReferJsonResponse,
+        "Message"=>"Swap Data saved successfully",
+      );
+      // Use json_encode() function
+      $json = json_encode($value);
+}else {
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    // Declare an array with error message 
+    $value = array(
+      "Message"=>"Something went wrong",
+      "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 197 - 0
Admin/index.php

@@ -0,0 +1,197 @@
+<?php
+include_once "../include/DB.php";
+$UserID="";
+if (isset($_POST["UserID"]) && !empty($_POST["UserID"])) {
+   $UserID=$_POST["UserID"];
+}
+$sql = "SELECT user.UserID,
+user.UserName,
+user.PhoneNumber,
+user.IsAdmin,
+user.CreatedAt AS UserCreatedAt,
+user.UpdatedAt AS UserUpdatedAt
+FROM user user 
+WHERE user.UserID='$UserID'";
+$result = $conn->query($sql);
+if ($result!== false && $result->num_rows > 0) {
+    $listArray = [];
+
+    while($row = $result->fetch_assoc()) {
+//////////////////////////////////////////////////////////////////////////////////////////////
+        $swapsql = "SELECT *,
+        swap.CreatedAt AS SwapCreatedAt,
+        swap.UpdatedAt AS SwapUpdatedAt 
+        FROM swap swap";
+        $swapresult = $conn->query($swapsql);
+    
+        $swaplistArray= [];
+        if ($swapresult!== false && $swapresult->num_rows > 0) {
+            while($swaprow = $swapresult->fetch_assoc()) {
+              
+                $swapvalue = array(
+                    "SwapID"=>(int)$swaprow["SwapID"],
+                    "RiderID"=>$swaprow["RiderID"],
+                    "SwapReferID"=>$swaprow["SwapReferID"],
+                    "SwapRechargeID"=>$swaprow["SwapRechargeID"],
+                    "ReturnBatterID"=>$swaprow["ReturnBatterID"],
+                    "SwappedBatterID"=>$swaprow["SwappedBatterID"],
+                    "IsFreeSwap"=>$swaprow["IsFreeSwap"],
+                    "SwapCreatedAt"=>$swaprow["SwapCreatedAt"],
+                    "SwapUpdatedAt"=>$swaprow["SwapUpdatedAt"],
+                );
+                $swaplistArray[]= $swapvalue;
+            }
+        }
+        
+        $PaidSwapCount =array_count_values(array_column($swaplistArray, 'IsFreeSwap'))["0"]??0;
+        $FreeSwapCount =array_count_values(array_column($swaplistArray, 'IsFreeSwap'))["1"]??0;
+        $swapCount = count($swaplistArray);
+///////////////////////////////////////////////////////////////////////////////////////////////
+        $rechargesql = "SELECT *,
+        recharge.CreatedAt AS RechargeCreatedAt,
+        recharge.UpdatedAt AS RechargeUpdatedAt 
+        FROM rechargehistory recharge";
+        $rechargeresult = $conn->query($rechargesql);
+    
+        $rechargelistArray= [];
+        if ($rechargeresult!== false && $rechargeresult->num_rows > 0) {
+            while($rechargerow = $rechargeresult->fetch_assoc()) {
+                $rechargevalue = array(
+                    "RechargeID"=>(int)$rechargerow["RechargeHistoryID"],
+                    "RiderID"=>$rechargerow["RiderID"],
+                    "TransactionID"=>$rechargerow["TransactionID"],
+                    "PaymentTypeID"=>$rechargerow["PaymentTypeID"],
+                    "RechargeCreatedAt"=>$rechargerow["RechargeCreatedAt"],
+                    "RechargeUpdatedAt"=>$rechargerow["RechargeUpdatedAt"],
+                );
+                $rechargelistArray[]= $rechargevalue;
+            }
+        }
+        $rechargeCount = count($rechargelistArray);
+/////////////////////////////////////////////////////////////////////////////////////////////////
+        $servicehistorysql = "SELECT *,
+        servicehistory.CreatedAt AS ServiceHistoryCreatedAt,
+        servicehistory.UpdatedAt AS ServiceHistoryUpdatedAt 
+        FROM servicehistory servicehistory";
+        $servicehistoryresult = $conn->query($servicehistorysql);
+    
+        $servicehistorylistArray= [];
+        if ($servicehistoryresult!== false && $servicehistoryresult->num_rows > 0) {
+            while($servicehistoryrow = $servicehistoryresult->fetch_assoc()) {
+                $servicehistoryvalue = array(
+                    "ServiceHistoryID"=>(int)$servicehistoryrow["ServiceHistoryID"],
+                    "AssetID"=>$servicehistoryrow["AssetID"],
+                    "isServiced"=>(int)$servicehistoryrow["isServiced"],
+                    "InWard"=>$servicehistoryrow["InWard"],
+                    "outWard"=>$servicehistoryrow["outWard"],
+                    "ServiceHistoryCreatedAt"=>$servicehistoryrow["ServiceHistoryCreatedAt"],
+                    "ServiceHistoryUpdatedAt"=>$servicehistoryrow["ServiceHistoryUpdatedAt"],
+                );
+                $servicehistorylistArray[]= $servicehistoryvalue;
+            }
+        }
+        $InCompletedServiceCount =array_count_values(array_column($servicehistorylistArray, 'isServiced'))["0"]??0;
+        $servicehistoryCount = count($servicehistorylistArray);
+//////////////////////////////////////////////////////////////////////////////////////////////////
+        $assetsql = "SELECT *,
+        asset.CreatedAt AS AssetCreatedAt,
+        asset.UpdatedAt AS AssetUpdatedAt,
+        assetcategory.CreatedAt AS AssetCategoryCreatedAt,
+        assetcategory.UpdatedAt AS AssetCategoryUpdatedAt
+        FROM asset asset
+        JOIN assetcategory assetcategory ON assetcategory.AssetCategoryID =asset.AssetCategoryID  ";
+        $assetresult = $conn->query($assetsql);
+    
+        $assetlistArray= [];
+        if ($assetresult!== false && $assetresult->num_rows > 0) {
+            while($sassetrow = $assetresult->fetch_assoc()) {
+                $assetvalue = array(
+                    "AssetID"=>$sassetrow["AssetID"],
+                    "AssetName"=>$sassetrow["AssetName"],
+                    "AssetCategoryID"=>(int)$sassetrow["AssetCategoryID"],
+                    "AssetCategory"=>array(
+                        "AssetCategoryID"=>(int)$sassetrow["AssetCategoryID"],
+                        "AssetCategoryTitle"=>$sassetrow["AssetCategoryTitle"],
+                        "AssetCategoryCreatedAt"=>$sassetrow["AssetCategoryCreatedAt"],
+                        "AssetCategoryUpdatedAt"=>$sassetrow["AssetCategoryUpdatedAt"],
+                    ),
+                    "IsInServiceCenter"=>(int)$sassetrow["IsInServiceCenter"],
+                    "AssetCreatedAt"=>$sassetrow["AssetCreatedAt"],
+                    "AssetUpdatedAt"=>$sassetrow["AssetUpdatedAt"],
+                );
+                $assetlistArray[]= $assetvalue;
+            }
+        }
+        $assetCount = count($assetlistArray);
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+        $value = array(
+            "UserData"=>array(
+                "UserID"=>(int)$row["UserID"],
+                "UserName"=>$row["UserName"],
+                "PhoneNumber"=>$row["PhoneNumber"],
+                "IsAdmin"=>(int)$row["IsAdmin"],
+                "UserCreatedAt"=>$row["UserCreatedAt"],
+                "UserUpdatedAt"=>$row["UserUpdatedAt"],
+            ),
+            "SwapData"=>array(
+                "HistoryData"=>array(
+                    "TotalCount"=>$swapCount,
+                    "FreeSwapCount"=>$FreeSwapCount,
+                    "PaidSwapCount"=>$PaidSwapCount,
+                    "History"=>$swaplistArray
+                ),
+            ),
+            "RechargeData"=>array(
+                "HistoryData"=>array(
+                    "TotalCount"=>$rechargeCount,
+                    "History"=>$rechargelistArray
+                ),
+            ),
+            "ServiceData"=>array(
+                "HistoryData"=>array(
+                    "TotalCount"=>$servicehistoryCount,
+                    "InCompletedServiceCount"=>$InCompletedServiceCount,
+                    "History"=>$servicehistorylistArray
+                ),
+            ),
+            "AssetData"=>array(
+                "HistoryData"=>array(
+                    "TotalCount"=>$assetCount,
+                    "History"=>$assetlistArray
+                ),
+            ),
+                
+            "Message"=>"Date successfully get"
+        );
+        $listArray[]= $value;
+    }
+
+    $count = count($listArray);
+    if($count==1){
+      // Use json_encode() function
+      $json = json_encode($listArray[0]);
+    }else {
+      // Use json_encode() function
+      $json = json_encode($listArray);
+    }
+
+}else {   
+    http_response_code(404);
+    $errorMesage= $conn->error;
+    if ($errorMesage=="") {
+        $errorMesage = "UserID not available";
+        if (empty($_GET["UserID"])) {
+            $errorMesage = "UserID is empty";
+        }
+    }
+    // Declare an array with error message 
+    $value = array(
+        "Message"=>"Failed to get data",
+        "Error"=>$errorMesage
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+}
+// Display the output
+echo($json);
+$conn->close();

+ 74 - 0
Admin/login.php

@@ -0,0 +1,74 @@
+<?php
+include_once "../include/DB.php";
+$userPhoneNumber="";
+$userPassword="";
+
+if (isset($_POST["phonenumber"]) && !empty($_POST["phonenumber"])) {
+   $userPhoneNumber=$_POST["phonenumber"];
+}
+
+if (isset($_POST["password"]) && !empty($_POST["password"])) {
+   $userPassword=$_POST["password"];
+}
+
+$sql = "SELECT UserID,
+UserName,
+PhoneNumber,
+IsAdmin,
+CreatedAt AS UserCreatedAt,
+UpdatedAt AS UserUpdatedAt
+FROM user WHERE PhoneNumber='$userPhoneNumber' AND Password='$userPassword'";
+$result = $conn->query($sql);
+
+if ($result!== false && $result->num_rows > 0 ) {        
+    $listArray = [];
+    // output data of each row
+    while($row = $result->fetch_assoc()) {
+        if ($row["IsAdmin"]==1) { 
+            // Declare an array 
+            $value = array(
+                "UserID"=>(int)$row["UserID"],
+                "UserName"=>$row["UserName"],
+                "PhoneNumber"=>$row["PhoneNumber"],
+                "IsAdmin"=>(int)$row["IsAdmin"],
+                "UserCreatedAt"=>$row["UserCreatedAt"],
+                "UserUpdatedAt"=>$row["UserUpdatedAt"],
+                "Message"=>"Your login successful"
+            );
+        }else {
+            http_response_code(404);
+            $value = array(
+                "Message"=>"Your login failed, You are not a admin to access",
+                "Error"=>"You are not a admin"
+            );
+        }
+        $listArray[]= $value;
+    }
+
+    $count = count($listArray);
+
+    if($count==1){
+        // Use json_encode() function
+        $json = json_encode($listArray[0]);
+    }else {
+        // Use json_encode() function
+        $json = json_encode($listArray);
+    }
+ 
+} else {   
+  http_response_code(404);
+  $errorMesage= $conn->error;
+  if ($errorMesage=="") {
+    $errorMesage = "User name or password incorrect";
+  }
+  // Declare an array with error message 
+  $value = array(
+    "Message"=>"Your login failed",
+    "Error"=>$errorMesage
+  );
+  // Use json_encode() function
+  $json = json_encode($value);
+}
+// Display the output
+echo($json);
+$conn->close();

+ 0 - 0
Admin/report.php


+ 24 - 0
Include/DB.php

@@ -0,0 +1,24 @@
+<?php
+$servername = "localhost";
+$username = "root";
+$password = "";
+$database = "gozap";
+
+// Create connection
+$conn = new mysqli($servername, $username, $password, $database);
+
+// Check connection
+if ($conn->connect_error) {
+  die("Connection failed: " . $conn->connect_error);
+}
+date_default_timezone_set('Asia/Kolkata');
+$monthFirstDate = date('Y-m-01');
+$monthLastDate = date('Y-m-t');
+$currentDateTime =date("Y/m/d H:i:s");
+header('Content-type: application/json; charset=utf-8');
+header("Access-Control-Allow-Origin: *");
+header("Access-Control-Allow-Headers: *");
+
+// echo "Connected successfully";
+// INSERT INTO `details` (`DetailID`, `Name`, `PhoneNumber`, `Email`) VALUES (NULL, 'Suriya', '1234567890', 'suriya@cygnusa.com');
+?>

+ 152 - 0
User/index.php

@@ -0,0 +1,152 @@
+<?php
+include_once "../include/DB.php";
+$UserID="";
+$RiderID="";
+if (isset($_POST["UserID"]) && !empty($_POST["UserID"])) {
+   $UserID=$_POST["UserID"];
+}
+if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
+    $RiderID=$_POST["RiderID"];
+}
+$sql = "SELECT *,
+user.CreatedAt AS UserCreatedAt,
+user.UpdatedAt AS UserUpdatedAt,
+rider.CreatedAt AS RaiderCreatedAt,
+rider.UpdatedAt AS RaiderUpdatedAt,
+sref.TotalFreeSwapCount AS SwapReferTotalFreeSwapCount,
+sref.UsedSwapCount AS SwapReferUsedSwapCount,
+sref.AvailableSwapCount AS SwapReferAvailableSwapCount,
+sref.CreatedAt AS SwapReferCreatedAt,
+sref.UpdatedAt AS SwapReferUpdatedAt,
+srech.TotalRechargedSwapCount AS SwapRechargeTotalRechargedSwapCount,
+srech.UsedSwapCount AS SwapRechargeUsedSwapCount,
+srech.AvailableSwapCount AS SwapRechargeAvailableSwapCount,
+srech.CreatedAt AS SwapRechargeCreatedAt,
+srech.UpdatedAt AS SwapRechargeUpdatedAt
+FROM user user 
+JOIN rider rider ON user.UserID=rider.UserID 
+JOIN swaprecharge srech ON rider.RiderID=srech.RiderID 
+JOIN swaprefer sref ON rider.RiderID=sref.RiderID 
+WHERE user.UserID='$UserID' OR rider.RiderID='$RiderID'";
+$result = $conn->query($sql);
+
+if ($result!== false && $result->num_rows > 0) {
+  $listArray = [];
+  // output data of each row
+  while($row = $result->fetch_assoc()) {
+    $RiderID=$row["RiderID"];
+    $swapsql = "SELECT *,
+    swap.CreatedAt AS SwapCreatedAt,
+    swap.UpdatedAt AS SwapUpdatedAt 
+    FROM swap swap WHERE swap.RiderID='$RiderID' AND swap.CreatedAt BETWEEN '$monthFirstDate' AND '$monthLastDate' ";
+    $swapresult = $conn->query($swapsql);
+
+    $swaplistArray= [];
+    if ($swapresult!== false && $swapresult->num_rows > 0) {
+        while($swaprow = $swapresult->fetch_assoc()) {
+          
+            $swapvalue = array(
+                "SwapID"=>(int)$swaprow["SwapID"],
+                "RiderID"=>$swaprow["RiderID"],
+                "SwapReferID"=>$swaprow["SwapReferID"],
+                "SwapRechargeID"=>$swaprow["SwapRechargeID"],
+                "ReturnBatterID"=>$swaprow["ReturnBatterID"],
+                "SwappedBatterID"=>$swaprow["SwappedBatterID"],
+                "IsFreeSwap"=>$swaprow["IsFreeSwap"],
+                "SwapCreatedAt"=>$swaprow["SwapCreatedAt"],
+                "SwapUpdatedAt"=>$swaprow["SwapUpdatedAt"],
+            );
+            $swaplistArray[]= $swapvalue;
+        }
+    }
+    $totalFreeForMonth=2;
+    $PaidSwapCount =array_count_values(array_column($swaplistArray, 'IsFreeSwap'))["0"]??0;
+    $FreeSwapCount =array_count_values(array_column($swaplistArray, 'IsFreeSwap'))["1"]??0;
+    $AvailableFreeCount = $totalFreeForMonth-$FreeSwapCount;
+    $swapCount = count($swaplistArray);
+    $TotalRemainingSwapCount=$totalFreeForMonth+(int)$row["SwapReferTotalFreeSwapCount"]+(int)$row["SwapRechargeTotalRechargedSwapCount"];
+    $RemainingUsedSwapCount=$FreeSwapCount+(int)$row["SwapReferUsedSwapCount"]+(int)$row["SwapRechargeUsedSwapCount"];
+    $RemainingAvailableSwapCount=$AvailableFreeCount+(int)$row["SwapReferAvailableSwapCount"]+(int)$row["SwapRechargeAvailableSwapCount"];
+    // Declare an array 
+    $value = array(
+        "RaiderData"=>array(
+            "RiderID"=>$row["RiderID"],
+            "RaiderCreatedAt"=>$row["RaiderCreatedAt"],
+            "RaiderUpdatedAt"=>$row["RaiderUpdatedAt"],
+        ),
+        "UserData"=>array(
+            "UserID"=>(int)$row["UserID"],
+            "UserName"=>$row["UserName"],
+            "PhoneNumber"=>$row["PhoneNumber"],
+            "UserCreatedAt"=>$row["UserCreatedAt"],
+            "UserUpdatedAt"=>$row["UserUpdatedAt"],
+        ),
+        "SwapData"=>array(
+            "RemainingData"=>array(
+                "Total"=>$TotalRemainingSwapCount,
+                "Used"=>$RemainingUsedSwapCount,
+                "Available"=>$RemainingAvailableSwapCount,
+            ),
+            "ReferData"=>array(
+                "SwapReferID"=>(int)$row["SwapReferID"],
+                "Total"=>(int)$row["SwapReferTotalFreeSwapCount"],
+                "Used"=>(int)$row["SwapReferUsedSwapCount"],
+                "Available"=>(int)$row["SwapReferAvailableSwapCount"],
+                "SwapReferCreatedAt"=>$row["SwapReferCreatedAt"],
+                "SwapReferUpdatedAt"=>$row["SwapReferUpdatedAt"],
+            ),
+            "RechargeData"=>array(
+                "SwapRechargeID"=>(int)$row["SwapRechargeID"],
+                "Total"=>(int)$row["SwapRechargeTotalRechargedSwapCount"],
+                "Used"=>(int)$row["SwapRechargeUsedSwapCount"],
+                "Available"=>(int)$row["SwapRechargeAvailableSwapCount"],
+                "SwapRechargeCreatedAt"=>$row["SwapRechargeCreatedAt"],
+                "SwapRechargeUpdatedAt"=>$row["SwapRechargeUpdatedAt"],
+            ),
+            "FreeData"=>array(
+                "Total"=>$totalFreeForMonth,
+                "Used"=>$FreeSwapCount,
+                "Available"=>$AvailableFreeCount,
+            ),
+            "HistoryData"=>array(
+                "TotalCount"=>$swapCount,
+                "FreeSwapCount"=>$FreeSwapCount,
+                "PaidSwapCount"=>$PaidSwapCount,
+                "History"=>$swaplistArray
+            )
+        ),
+        "Message"=>"Date successfully get"
+    );
+    
+    $listArray[]= $value;
+  }
+
+  $count = count($listArray);
+
+  if($count==1){
+    // Use json_encode() function
+    $json = json_encode($listArray[0]);
+  }else {
+    // Use json_encode() function
+    $json = json_encode($listArray);
+  }
+} else {   
+  http_response_code(404);
+  $errorMesage= $conn->error;
+  if ($errorMesage=="") {
+    $errorMesage = "UserID not available";
+    if (empty($_GET["UserID"])) {
+        $errorMesage = "UserID is empty";
+    }
+  }
+  // Declare an array with error message 
+  $value = array(
+    "Message"=>"Failed to get data",
+    "Error"=>$errorMesage
+  );
+  // Use json_encode() function
+  $json = json_encode($value);
+}
+// Display the output
+echo($json);
+$conn->close();

+ 68 - 0
User/login.php

@@ -0,0 +1,68 @@
+<?php
+include_once "../include/DB.php";
+$userPhoneNumber="";
+$userPassword="";
+
+if (isset($_POST["phonenumber"]) && !empty($_POST["phonenumber"])) {
+   $userPhoneNumber=$_POST["phonenumber"];
+}
+
+if (isset($_POST["password"]) && !empty($_POST["password"])) {
+   $userPassword=$_POST["password"];
+}
+
+$sql = "SELECT UserID,
+UserName,
+PhoneNumber,
+IsAdmin,
+CreatedAt AS UserCreatedAt,
+UpdatedAt AS UserUpdatedAt
+FROM user WHERE PhoneNumber='$userPhoneNumber' AND Password='$userPassword'";
+$result = $conn->query($sql);
+
+if ($result!== false && $result->num_rows > 0) {
+  $listArray = [];
+  // output data of each row
+  while($row = $result->fetch_assoc()) {
+    // Declare an array 
+    $value = array(
+        "UserID"=>(int)$row["UserID"],
+        "UserName"=>$row["UserName"],
+        "PhoneNumber"=>$row["PhoneNumber"],
+        "IsAdmin"=>(int)$row["IsAdmin"],
+        "UserCreatedAt"=>$row["UserCreatedAt"],
+        "UserUpdatedAt"=>$row["UserUpdatedAt"],
+        "Message"=>"Your login successful"
+    );
+    
+    $listArray[]= $value;
+  }
+
+  $count = count($listArray);
+
+  if($count==1){
+    // Use json_encode() function
+    $json = json_encode($listArray[0]);
+  }else {
+    // Use json_encode() function
+    $json = json_encode($listArray);
+  }
+  // Display the output
+  echo($json);
+} else {   
+  http_response_code(404);
+  $errorMesage= $conn->error;
+  if ($errorMesage=="") {
+    $errorMesage = "User name or password incorrect";
+  }
+  // Declare an array with error message 
+  $value = array(
+    "Message"=>"Your login failed",
+    "Error"=>$errorMesage
+  );
+  // Use json_encode() function
+  $json = json_encode($value);
+  // Display the output
+  echo($json);
+}
+$conn->close();

+ 91 - 0
User/signup.php

@@ -0,0 +1,91 @@
+<?php
+include_once "../include/DB.php";
+
+$userName = "";
+$userPhoneNumber = "";
+$userPassword = "";
+$DEID="";
+
+if (isset($_POST["name"]) && !empty($_POST["name"])) {
+    $userName = $_POST["name"];
+}
+if (isset($_POST["phonenumber"]) && !empty($_POST["phonenumber"])) {
+    $userPhoneNumber = $_POST["phonenumber"];
+}
+if (isset($_POST["password"]) && !empty($_POST["password"])) {
+    $userPassword = $_POST["password"];
+}
+if (isset($_POST["DEID"]) && !empty($_POST["DEID"])) {
+    $DEID = $_POST["DEID"];
+}
+
+$phoneNumberChecksql = "SELECT * FROM user WHERE PhoneNumber='$userPhoneNumber'";
+$phoneNumberCheckresult = $conn->query($phoneNumberChecksql);
+
+if ($phoneNumberCheckresult !== false && $phoneNumberCheckresult->num_rows > 0) {
+    http_response_code(404);
+    // Declare an array with error message 
+    $value = array(
+        "Message" => "Your signup failed. Entered phone number is exist",
+        "Error" => "Entered phone number is exist"
+    );
+    // Use json_encode() function
+    $json = json_encode($value);
+} else {
+    $userInsertSql = "INSERT INTO user(UserName, PhoneNumber, Password, DEID) VALUES ('$userName','$userPhoneNumber','$userPassword','$DEID')";
+    $userInsertresult = $conn->query($userInsertSql);
+    $UserID = $conn->insert_id;
+
+    $raiderInsertSql = "INSERT INTO rider(RiderID, UserID) VALUES ('$userPhoneNumber','$UserID')";
+    $raiderInsertresult = $conn->query($raiderInsertSql);
+
+    $swapreferInsertSql = "INSERT INTO swaprefer(RiderID, TotalFreeSwapCount, UsedSwapCount, AvailableSwapCount) VALUES ('$userPhoneNumber','0','0','0')";
+    $swapreferInsertresult = $conn->query($swapreferInsertSql);
+
+    $swaprechargeInsertSql = "INSERT INTO swaprecharge(RiderID, TotalRechargedSwapCount, UsedSwapCount, AvailableSwapCount) VALUES ('$userPhoneNumber','0','0','0')";
+    $swaprechargeInsertresult = $conn->query($swaprechargeInsertSql);
+
+    $getUsersql = "SELECT UserID,UserName,PhoneNumber,CreatedAt AS UserCreatedAt,UpdatedAt AS UserUpdatedAt FROM user WHERE PhoneNumber='$userPhoneNumber' AND Password='$userPassword'";
+    $getUserresult = $conn->query($getUsersql);
+
+    if ($getUserresult !== false && $getUserresult->num_rows > 0) {
+        $listArray = [];
+        // output data of each row
+        while ($getUserresultrow = $getUserresult->fetch_assoc()) {
+            // Declare an array 
+            $value = array(
+                "UserID" => (int)$getUserresultrow["UserID"],
+                "UserName" => $getUserresultrow["UserName"],
+                "PhoneNumber" => $getUserresultrow["PhoneNumber"],
+                "UserCreatedAt" => $getUserresultrow["UserCreatedAt"],
+                "UserUpdatedAt" => $getUserresultrow["UserUpdatedAt"],
+                "Message" => "Your signup successful"
+            );
+
+            $listArray[] = $value;
+        }
+
+        $count = count($listArray);
+
+        if ($count == 1) {
+            // Use json_encode() function
+            $json = json_encode($listArray[0]);
+        } else {
+            // Use json_encode() function
+            $json = json_encode($listArray);
+        }
+    }else {
+        http_response_code(404);
+        $errorMesage= $conn->error;
+        // Declare an array with error message 
+        $value = array(
+          "Message"=>"Something went wrong",
+          "Error"=>$errorMesage
+        );
+        // Use json_encode() function
+        $json = json_encode($value);
+    }
+}
+// Display the output
+echo ($json);
+$conn->close();

+ 431 - 0
gozap.sql

@@ -0,0 +1,431 @@
+-- phpMyAdmin SQL Dump
+-- version 5.2.0
+-- https://www.phpmyadmin.net/
+--
+-- Host: 127.0.0.1
+-- Generation Time: Oct 30, 2022 at 09:23 AM
+-- Server version: 10.4.25-MariaDB
+-- PHP Version: 8.0.23
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+START TRANSACTION;
+SET time_zone = "+00:00";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+--
+-- Database: `gozap`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `asset`
+--
+
+CREATE TABLE `asset` (
+  `AssetID` varchar(50) NOT NULL,
+  `AssetName` varchar(100) NOT NULL,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp(1) NOT NULL DEFAULT current_timestamp(1),
+  `AssetCategoryID` int(11) NOT NULL,
+  `IsInServiceCenter` tinyint(1) NOT NULL DEFAULT 1
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `asset`
+--
+
+INSERT INTO `asset` (`AssetID`, `AssetName`, `IsActive`, `CreatedAt`, `UpdatedAt`, `AssetCategoryID`, `IsInServiceCenter`) VALUES
+('HE5130TK22157196', 'Lithium - ion Battery', 1, '2022-10-28 09:06:49', '2022-10-28 09:06:49.2', 1, 0),
+('HE5130TK22158489', 'Lithium - ion Battery', 1, '2022-10-28 09:09:14', '2022-10-28 09:09:14.1', 1, 1),
+('HE5130TK22159795', 'Lithium Battery', 1, '2022-10-28 10:41:17', '2022-10-28 10:41:17.3', 1, 1);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `assetcategory`
+--
+
+CREATE TABLE `assetcategory` (
+  `AssetCategoryID` int(11) NOT NULL,
+  `AssetCategoryTitle` varchar(20) NOT NULL,
+  `IsActive` tinyint(1) DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `assetcategory`
+--
+
+INSERT INTO `assetcategory` (`AssetCategoryID`, `AssetCategoryTitle`, `IsActive`, `CreatedAt`, `UpdatedAt`) VALUES
+(1, 'Battery', 1, '2022-10-28 09:08:24', '2022-10-28 09:08:24'),
+(2, 'Vehicle', 1, '2022-10-28 09:08:29', '2022-10-28 09:08:29');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `paymenttypes`
+--
+
+CREATE TABLE `paymenttypes` (
+  `PaymentTypeID` int(11) NOT NULL,
+  `PaymentTypeTitle` varchar(20) NOT NULL,
+  `IsActive` int(11) NOT NULL,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `rechargehistory`
+--
+
+CREATE TABLE `rechargehistory` (
+  `RechargeHistoryID` int(11) NOT NULL,
+  `RiderID` varchar(20) NOT NULL,
+  `TransactionID` varchar(20) DEFAULT NULL,
+  `PaymentTypeID` int(11) NOT NULL DEFAULT 1,
+  `IsActive` int(11) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `RechargeCount` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `rechargehistory`
+--
+
+INSERT INTO `rechargehistory` (`RechargeHistoryID`, `RiderID`, `TransactionID`, `PaymentTypeID`, `IsActive`, `CreatedAt`, `UpdatedAt`, `RechargeCount`) VALUES
+(1, '8124308141', '', 1, 1, '2022-10-28 09:10:21', '2022-10-28 09:10:21', 2),
+(2, '7305325141', '', 1, 1, '2022-10-28 10:38:37', '2022-10-28 10:38:37', 2);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `refer`
+--
+
+CREATE TABLE `refer` (
+  `ReferID` int(11) NOT NULL,
+  `UserID` int(11) NOT NULL,
+  `UserReferID` int(11) NOT NULL,
+  `ReferedUserID` int(11) NOT NULL,
+  `IsApproved` tinyint(1) NOT NULL DEFAULT 0,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `rider`
+--
+
+CREATE TABLE `rider` (
+  `RiderID` varchar(20) NOT NULL,
+  `UserID` int(11) NOT NULL,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `rider`
+--
+
+INSERT INTO `rider` (`RiderID`, `UserID`, `IsActive`, `CreatedAt`, `UpdatedAt`) VALUES
+('7305325141', 2, 1, '2022-10-28 10:32:23', '2022-10-28 10:32:23'),
+('8124308141', 1, 1, '2022-10-28 09:04:51', '2022-10-28 09:04:51'),
+('9789910828', 3, 1, '2022-10-28 11:35:19', '2022-10-28 11:35:19');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `servicehistory`
+--
+
+CREATE TABLE `servicehistory` (
+  `ServiceHistoryID` int(11) NOT NULL,
+  `AssetID` varchar(20) NOT NULL,
+  `isServiced` tinyint(1) NOT NULL DEFAULT 0,
+  `outWard` timestamp NOT NULL DEFAULT current_timestamp(),
+  `InWard` timestamp NULL DEFAULT NULL,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `servicehistory`
+--
+
+INSERT INTO `servicehistory` (`ServiceHistoryID`, `AssetID`, `isServiced`, `outWard`, `InWard`, `IsActive`, `CreatedAt`, `UpdatedAt`) VALUES
+(1, 'HE5130TK22157196', 1, '2022-10-28 09:09:44', '2022-10-28 09:09:54', 1, '2022-10-28 09:09:44', '2022-10-28 09:09:44'),
+(2, 'HE5130TK22157196', 1, '2022-10-28 10:39:54', '2022-10-28 10:40:16', 1, '2022-10-28 10:39:54', '2022-10-28 10:39:54'),
+(3, 'HE5130TK22158489', 1, '2022-10-28 10:55:03', '2022-10-28 10:55:22', 1, '2022-10-28 10:55:03', '2022-10-28 10:55:03');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `swap`
+--
+
+CREATE TABLE `swap` (
+  `SwapID` int(11) NOT NULL,
+  `RiderID` varchar(20) NOT NULL,
+  `SwapReferID` int(11) DEFAULT 0,
+  `SwapRechargeID` int(11) DEFAULT 0,
+  `ReturnBatterID` varchar(20) NOT NULL,
+  `SwappedBatterID` varchar(20) NOT NULL,
+  `IsFreeSwap` tinyint(1) NOT NULL DEFAULT 1,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `swap`
+--
+
+INSERT INTO `swap` (`SwapID`, `RiderID`, `SwapReferID`, `SwapRechargeID`, `ReturnBatterID`, `SwappedBatterID`, `IsFreeSwap`, `IsActive`, `CreatedAt`, `UpdatedAt`) VALUES
+(1, '8124308141', 0, 0, 'HE5130TK22157196', 'HE5130TK22158489', 1, 1, '2022-10-28 09:13:34', '2022-10-28 09:13:34'),
+(2, '8124308141', 0, 0, 'HE5130TK22158489', 'HE5130TK22157196', 1, 1, '2022-10-28 09:15:34', '2022-10-28 09:15:34'),
+(3, '8124308141', 0, 1, 'HE5130TK22157196', 'HE5130TK22158489', 0, 1, '2022-10-28 09:16:14', '2022-10-28 09:16:14'),
+(4, '8124308141', 0, 1, 'HE5130TK22158489', 'HE5130TK22157196', 0, 1, '2022-10-28 10:36:52', '2022-10-28 10:36:52');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `swaprecharge`
+--
+
+CREATE TABLE `swaprecharge` (
+  `SwapRechargeID` int(11) NOT NULL,
+  `RiderID` varchar(20) NOT NULL,
+  `TotalRechargedSwapCount` varchar(20) NOT NULL,
+  `UsedSwapCount` varchar(20) NOT NULL,
+  `AvailableSwapCount` varchar(20) NOT NULL,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `swaprecharge`
+--
+
+INSERT INTO `swaprecharge` (`SwapRechargeID`, `RiderID`, `TotalRechargedSwapCount`, `UsedSwapCount`, `AvailableSwapCount`, `IsActive`, `CreatedAt`, `UpdatedAt`) VALUES
+(1, '8124308141', '2', '2', '0', 1, '2022-10-28 09:04:51', '2022-10-28 09:04:51'),
+(2, '7305325141', '2', '0', '2', 1, '2022-10-28 10:32:23', '2022-10-28 10:32:23'),
+(3, '9789910828', '0', '0', '0', 1, '2022-10-28 11:35:19', '2022-10-28 11:35:19');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `swaprefer`
+--
+
+CREATE TABLE `swaprefer` (
+  `SwapReferID` int(11) NOT NULL,
+  `RiderID` varchar(20) NOT NULL,
+  `TotalFreeSwapCount` varchar(20) NOT NULL,
+  `UsedSwapCount` varchar(20) NOT NULL,
+  `AvailableSwapCount` varchar(20) NOT NULL,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `swaprefer`
+--
+
+INSERT INTO `swaprefer` (`SwapReferID`, `RiderID`, `TotalFreeSwapCount`, `UsedSwapCount`, `AvailableSwapCount`, `IsActive`, `CreatedAt`, `UpdatedAt`) VALUES
+(1, '8124308141', '0', '0', '0', 1, '2022-10-28 09:04:51', '2022-10-28 09:04:51'),
+(2, '7305325141', '0', '0', '0', 1, '2022-10-28 10:32:23', '2022-10-28 10:32:23'),
+(3, '9789910828', '0', '0', '0', 1, '2022-10-28 11:35:19', '2022-10-28 11:35:19');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `user`
+--
+
+CREATE TABLE `user` (
+  `UserID` int(11) NOT NULL,
+  `UserName` varchar(20) NOT NULL,
+  `PhoneNumber` varchar(20) NOT NULL,
+  `Password` varchar(50) NOT NULL,
+  `IsAdmin` int(11) NOT NULL DEFAULT 0,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `DEID` varchar(20) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Dumping data for table `user`
+--
+
+INSERT INTO `user` (`UserID`, `UserName`, `PhoneNumber`, `Password`, `IsAdmin`, `IsActive`, `CreatedAt`, `UpdatedAt`, `DEID`) VALUES
+(1, 'Dinesh', '8124308141', '12345', 1, 1, '2022-10-28 09:04:51', '2022-10-28 09:04:51', ''),
+(2, 'Dinesh', '7305325141', '12345', 0, 1, '2022-10-28 10:32:23', '2022-10-28 10:32:23', ''),
+(3, 'Vishnu', '9789910828', '12345', 0, 1, '2022-10-28 11:35:19', '2022-10-28 11:35:19', 'DIN001487459');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `userrefer`
+--
+
+CREATE TABLE `userrefer` (
+  `UserReferID` int(11) NOT NULL,
+  `UserID` int(11) NOT NULL,
+  `IsActive` tinyint(1) NOT NULL DEFAULT 1,
+  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
+  `UpdatedAt` timestamp NOT NULL DEFAULT current_timestamp()
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Indexes for dumped tables
+--
+
+--
+-- Indexes for table `asset`
+--
+ALTER TABLE `asset`
+  ADD PRIMARY KEY (`AssetID`);
+
+--
+-- Indexes for table `assetcategory`
+--
+ALTER TABLE `assetcategory`
+  ADD PRIMARY KEY (`AssetCategoryID`);
+
+--
+-- Indexes for table `rechargehistory`
+--
+ALTER TABLE `rechargehistory`
+  ADD PRIMARY KEY (`RechargeHistoryID`);
+
+--
+-- Indexes for table `refer`
+--
+ALTER TABLE `refer`
+  ADD PRIMARY KEY (`ReferID`);
+
+--
+-- Indexes for table `rider`
+--
+ALTER TABLE `rider`
+  ADD PRIMARY KEY (`RiderID`),
+  ADD UNIQUE KEY `UserID` (`UserID`);
+
+--
+-- Indexes for table `servicehistory`
+--
+ALTER TABLE `servicehistory`
+  ADD PRIMARY KEY (`ServiceHistoryID`);
+
+--
+-- Indexes for table `swap`
+--
+ALTER TABLE `swap`
+  ADD PRIMARY KEY (`SwapID`);
+
+--
+-- Indexes for table `swaprecharge`
+--
+ALTER TABLE `swaprecharge`
+  ADD PRIMARY KEY (`SwapRechargeID`),
+  ADD UNIQUE KEY `RaiderID` (`RiderID`);
+
+--
+-- Indexes for table `swaprefer`
+--
+ALTER TABLE `swaprefer`
+  ADD PRIMARY KEY (`SwapReferID`);
+
+--
+-- Indexes for table `user`
+--
+ALTER TABLE `user`
+  ADD PRIMARY KEY (`UserID`);
+
+--
+-- Indexes for table `userrefer`
+--
+ALTER TABLE `userrefer`
+  ADD PRIMARY KEY (`UserReferID`);
+
+--
+-- AUTO_INCREMENT for dumped tables
+--
+
+--
+-- AUTO_INCREMENT for table `assetcategory`
+--
+ALTER TABLE `assetcategory`
+  MODIFY `AssetCategoryID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
+
+--
+-- AUTO_INCREMENT for table `rechargehistory`
+--
+ALTER TABLE `rechargehistory`
+  MODIFY `RechargeHistoryID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
+
+--
+-- AUTO_INCREMENT for table `refer`
+--
+ALTER TABLE `refer`
+  MODIFY `ReferID` int(11) NOT NULL AUTO_INCREMENT;
+
+--
+-- AUTO_INCREMENT for table `servicehistory`
+--
+ALTER TABLE `servicehistory`
+  MODIFY `ServiceHistoryID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+
+--
+-- AUTO_INCREMENT for table `swap`
+--
+ALTER TABLE `swap`
+  MODIFY `SwapID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
+
+--
+-- AUTO_INCREMENT for table `swaprecharge`
+--
+ALTER TABLE `swaprecharge`
+  MODIFY `SwapRechargeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+
+--
+-- AUTO_INCREMENT for table `swaprefer`
+--
+ALTER TABLE `swaprefer`
+  MODIFY `SwapReferID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+
+--
+-- AUTO_INCREMENT for table `user`
+--
+ALTER TABLE `user`
+  MODIFY `UserID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+
+--
+-- AUTO_INCREMENT for table `userrefer`
+--
+ALTER TABLE `userrefer`
+  MODIFY `UserReferID` int(11) NOT NULL AUTO_INCREMENT;
+COMMIT;
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

BIN=BIN
gozap_api.zip