Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3a82f81c1a
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@ -6,6 +6,7 @@
|
|||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="delegatedBuild" value="true" />
|
<option name="delegatedBuild" value="true" />
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
|
<option name="disableWrapperSourceDistributionNotification" value="true" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="11" />
|
<option name="gradleJvm" value="11" />
|
||||||
|
@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'com.wasteinformationserver'
|
group 'com.wasteinformationserver'
|
||||||
version '0.1-Beta'
|
version '0.2-Beta'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.wasteinformationserver.website.datarequests;
|
package com.wasteinformationserver.website.datarequests;
|
||||||
|
|
||||||
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -27,7 +28,7 @@ public class AdminRequests extends PostRequest {
|
|||||||
|
|
||||||
/* is it a jar file? */
|
/* is it a jar file? */
|
||||||
if (!currentJar.getName().endsWith(".jar"))
|
if (!currentJar.getName().endsWith(".jar"))
|
||||||
System.out.println("not jar");
|
Log.warning("not jar --> cant restart");
|
||||||
|
|
||||||
/* Build command: java -jar application.jar */
|
/* Build command: java -jar application.jar */
|
||||||
final ArrayList<String> command = new ArrayList<String>();
|
final ArrayList<String> command = new ArrayList<String>();
|
||||||
|
@ -17,6 +17,8 @@ public class DataRequest extends PostRequest {
|
|||||||
@Override
|
@Override
|
||||||
public String request(HashMap<String, String> params) {
|
public String request(HashMap<String, String> params) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
ResultSet set = null;
|
||||||
|
int status = -1;
|
||||||
|
|
||||||
JDCB jdcb;
|
JDCB jdcb;
|
||||||
try {
|
try {
|
||||||
@ -33,7 +35,7 @@ public class DataRequest extends PostRequest {
|
|||||||
// check if wastezone and wasteregion already exists
|
// check if wastezone and wasteregion already exists
|
||||||
|
|
||||||
Log.debug(params.get("cityname") + params.get("wastetype") + params.get("wastezone"));
|
Log.debug(params.get("cityname") + params.get("wastetype") + params.get("wastezone"));
|
||||||
ResultSet set = jdcb.executeQuery("select * from `cities` where `name`='" + params.get("cityname") + "' AND `wastetype`='" + params.get("wastetype") + "' AND `zone`='" + params.get("wastezone") + "'");
|
set = jdcb.executeQuery("select * from `cities` where `name`='" + params.get("cityname") + "' AND `wastetype`='" + params.get("wastetype") + "' AND `zone`='" + params.get("wastezone") + "'");
|
||||||
int size = 0;
|
int size = 0;
|
||||||
try {
|
try {
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
@ -45,14 +47,12 @@ public class DataRequest extends PostRequest {
|
|||||||
}
|
}
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
//doesnt exist
|
//doesnt exist
|
||||||
System.out.println("doesnt exist");
|
|
||||||
int status = 0;
|
|
||||||
try {
|
try {
|
||||||
status = jdcb.executeUpdate("INSERT INTO `cities`(`userid`, `name`, `wastetype`, `zone`) VALUES ('0','" + params.get("cityname") + "','" + params.get("wastetype") + "','" + params.get("wastezone") + "');");
|
status = jdcb.executeUpdate("INSERT INTO `cities`(`userid`, `name`, `wastetype`, `zone`) VALUES ('0','" + params.get("cityname") + "','" + params.get("wastetype") + "','" + params.get("wastezone") + "');");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
System.out.println(status);
|
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
sb.append("\"status\" : \"inserted\"");
|
sb.append("\"status\" : \"inserted\"");
|
||||||
} else {
|
} else {
|
||||||
@ -64,7 +64,6 @@ public class DataRequest extends PostRequest {
|
|||||||
sb.append("\"status\" : \"exists\"");
|
sb.append("\"status\" : \"exists\"");
|
||||||
} else {
|
} else {
|
||||||
//already exists
|
//already exists
|
||||||
System.out.println("already exists");
|
|
||||||
sb.append("\"status\" : \"exists\"");
|
sb.append("\"status\" : \"exists\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,20 +71,18 @@ public class DataRequest extends PostRequest {
|
|||||||
sb.append("}");
|
sb.append("}");
|
||||||
break;
|
break;
|
||||||
case "getAllCities":
|
case "getAllCities":
|
||||||
ResultSet sett = jdcb.executeQuery("select * from cities");
|
set = jdcb.executeQuery("select * from cities");
|
||||||
Log.debug(sett.toString());
|
Log.debug(set.toString());
|
||||||
sb.append("{\"data\":[");
|
sb.append("{\"data\":[");
|
||||||
try {
|
try {
|
||||||
while (sett.next()) {
|
while (set.next()) {
|
||||||
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"");
|
sb.append("{\"cityname\":\"" + set.getString("name") + "\"");
|
||||||
sb.append(",\"wastetype\":\"" + sett.getString("wastetype") + "\"");
|
sb.append(",\"wastetype\":\"" + set.getString("wastetype") + "\"");
|
||||||
sb.append(",\"id\":\"" + sett.getString("id") + "\"");
|
sb.append(",\"id\":\"" + set.getString("id") + "\"");
|
||||||
sb.append(",\"zone\":\"" + sett.getString("zone") + "\"}");
|
sb.append(",\"zone\":\"" + set.getString("zone") + "\"}");
|
||||||
if (!sett.isLast()) {
|
if (!set.isLast()) {
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println(sett.getString("name"));
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -97,8 +94,6 @@ public class DataRequest extends PostRequest {
|
|||||||
case "deletecity":
|
case "deletecity":
|
||||||
//DELETE FROM `cities` WHERE `id`=0
|
//DELETE FROM `cities` WHERE `id`=0
|
||||||
sb.append("{");
|
sb.append("{");
|
||||||
Log.debug(params.get("id"));
|
|
||||||
int status = 0;
|
|
||||||
try {
|
try {
|
||||||
status = jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id") + "'");
|
status = jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id") + "'");
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
@ -121,49 +116,41 @@ public class DataRequest extends PostRequest {
|
|||||||
sb.append("}");
|
sb.append("}");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "getcollectionnumber": //todo maybe combine all three to one
|
case "getAllDates":
|
||||||
sb.append("{");
|
set = jdcb.executeQuery("SELECT pickupdates.id,pickupdates.pickupdate,cities.userid,cities.name,cities.wastetype,cities.zone " +
|
||||||
|
"FROM `pickupdates` INNER JOIN `cities` ON pickupdates.citywastezoneid = cities.id");
|
||||||
|
sb.append("{\"data\":[");
|
||||||
try {
|
try {
|
||||||
ResultSet settt = jdcb.executeQuery("select * from pickupdates");
|
while (set.next()) {
|
||||||
settt.last();
|
sb.append("{\"date\":\"" + set.getString("pickupdate") + "\"");
|
||||||
sb.append("\"collectionnumber\":\"" + settt.getRow() + "\"");
|
sb.append(",\"cityname\":\"" + set.getString("name") + "\"");
|
||||||
|
sb.append(",\"wastetype\":\"" + set.getString("wastetype") + "\"");
|
||||||
|
sb.append(",\"id\":\"" + set.getString("id") + "\"");
|
||||||
|
sb.append(",\"zone\":\"" + set.getString("zone") + "\"}");
|
||||||
|
if (!set.isLast()) {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.error("sql exception: " + e.getMessage());
|
e.printStackTrace();
|
||||||
sb.append("\"status\" : \"error\"");
|
|
||||||
}
|
}
|
||||||
|
sb.append("]");
|
||||||
sb.append(",\"query\":\"ok\"");
|
sb.append(",\"query\":\"ok\"");
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
break;
|
break;
|
||||||
case "getcollectioninfuture":
|
case "deletedate":
|
||||||
sb.append("{");
|
sb.append("{");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
status = jdcb.executeUpdate("DELETE FROM `pickupdates` WHERE `id`='" + params.get("id") + "'");
|
||||||
Date date = new Date();
|
if (status == 1) {
|
||||||
String time = sdf.format(date);
|
//success
|
||||||
ResultSet settt = jdcb.executeQuery("SELECT * FROM `pickupdates` WHERE `pickupdate` BETWEEN '"+time+"' AND '2222-12-27'");
|
sb.append("\"status\" : \"success\"");
|
||||||
settt.last();
|
} else {
|
||||||
sb.append("\"collectionnumber\":\"" + settt.getRow() + "\"");
|
sb.append("\"status\" : \"error\"");
|
||||||
} catch (SQLException e) {
|
}
|
||||||
Log.error("sql exception: " + e.getMessage());
|
} catch (SQLIntegrityConstraintViolationException e) {
|
||||||
sb.append("\"status\" : \"error\"");
|
Log.warning("dependencies of deletion exist");
|
||||||
}
|
sb.append("\"status\" : \"dependenciesnotdeleted\"");
|
||||||
|
|
||||||
sb.append(",\"query\":\"ok\"");
|
|
||||||
sb.append("}");
|
|
||||||
break;
|
|
||||||
case "getfinishedcollections":
|
|
||||||
sb.append("{");
|
|
||||||
|
|
||||||
try {
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
Date date = new Date();
|
|
||||||
String time = sdf.format(date);
|
|
||||||
ResultSet settt = jdcb.executeQuery("SELECT * FROM `pickupdates` WHERE `pickupdate` BETWEEN '0000-12-27' AND '"+time+"'");
|
|
||||||
settt.last();
|
|
||||||
sb.append("\"collectionnumber\":\"" + settt.getRow() + "\"");
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.error("sql exception: " + e.getMessage());
|
Log.error("sql exception: " + e.getMessage());
|
||||||
sb.append("\"status\" : \"error\"");
|
sb.append("\"status\" : \"error\"");
|
||||||
@ -179,6 +166,41 @@ public class DataRequest extends PostRequest {
|
|||||||
sb.append(",\"buildtime\" : \""+ Info.getBuilddate()+"\"");
|
sb.append(",\"buildtime\" : \""+ Info.getBuilddate()+"\"");
|
||||||
|
|
||||||
|
|
||||||
|
sb.append(",\"query\":\"ok\"");
|
||||||
|
sb.append("}");
|
||||||
|
break;
|
||||||
|
case "getStartHeaderData":
|
||||||
|
sb.append("{");
|
||||||
|
|
||||||
|
try {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date date = new Date();
|
||||||
|
String time = sdf.format(date);
|
||||||
|
set = jdcb.executeQuery("SELECT * FROM `pickupdates` WHERE `pickupdate` BETWEEN '0000-12-27' AND '"+time+"'");
|
||||||
|
set.last();
|
||||||
|
sb.append("\"finshedcollections\":\"" + set.getRow() + "\"");
|
||||||
|
|
||||||
|
sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
date = new Date();
|
||||||
|
date = new Date(date.getTime()+1 * 24 * 60 * 60 * 1000);
|
||||||
|
|
||||||
|
time = sdf.format(date);
|
||||||
|
set = jdcb.executeQuery("SELECT * FROM `pickupdates` WHERE `pickupdate` BETWEEN '"+time+"' AND '2222-12-27'");
|
||||||
|
set.last();
|
||||||
|
sb.append(",\"futurecollections\":\"" + set.getRow() + "\"");
|
||||||
|
|
||||||
|
set = jdcb.executeQuery("select * from pickupdates");
|
||||||
|
set.last();
|
||||||
|
sb.append(",\"collectionnumber\":\"" + set.getRow() + "\"");
|
||||||
|
|
||||||
|
set = jdcb.executeQuery("select * from `cities`");
|
||||||
|
set.last();
|
||||||
|
sb.append(",\"citynumber\":\"" + set.getRow() + "\"");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Log.error("sql exception: " + e.getMessage());
|
||||||
|
sb.append("\"status\" : \"error\"");
|
||||||
|
}
|
||||||
|
|
||||||
sb.append(",\"query\":\"ok\"");
|
sb.append(",\"query\":\"ok\"");
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
break;
|
break;
|
||||||
|
@ -14,6 +14,7 @@ public class NewDateRequest extends PostRequest {
|
|||||||
public String request(HashMap<String, String> params) {
|
public String request(HashMap<String, String> params) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
JDCB jdcb;
|
JDCB jdcb;
|
||||||
|
ResultSet set;
|
||||||
try {
|
try {
|
||||||
jdcb = JDCB.getInstance();
|
jdcb = JDCB.getInstance();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -22,21 +23,21 @@ public class NewDateRequest extends PostRequest {
|
|||||||
}
|
}
|
||||||
switch (params.get("action")) {
|
switch (params.get("action")) {
|
||||||
case "getCitynames":
|
case "getCitynames":
|
||||||
ResultSet sett = jdcb.executeQuery("select * from cities");
|
set = jdcb.executeQuery("select * from cities");
|
||||||
Log.debug(sett.toString());
|
Log.debug(set.toString());
|
||||||
sb.append("{\"data\":[");
|
sb.append("{\"data\":[");
|
||||||
try {
|
try {
|
||||||
String prev = "";
|
String prev = "";
|
||||||
while (sett.next()) {
|
while (set.next()) {
|
||||||
if (prev.equals(sett.getString("name"))) {
|
if (prev.equals(set.getString("name"))) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!sett.isFirst()) {
|
if (!set.isFirst()) {
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
}
|
}
|
||||||
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"}");
|
sb.append("{\"cityname\":\"" + set.getString("name") + "\"}");
|
||||||
}
|
}
|
||||||
prev = sett.getString("name");
|
prev = set.getString("name");
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -47,7 +48,7 @@ public class NewDateRequest extends PostRequest {
|
|||||||
Log.debug(sb.toString());
|
Log.debug(sb.toString());
|
||||||
break;
|
break;
|
||||||
case "getzones":
|
case "getzones":
|
||||||
ResultSet set = jdcb.executeQuery("select * from cities WHERE `name`='" + params.get("cityname") + "' ORDER BY zone ASC");
|
set = jdcb.executeQuery("select * from cities WHERE `name`='" + params.get("cityname") + "' ORDER BY zone ASC");
|
||||||
Log.debug(set.toString());
|
Log.debug(set.toString());
|
||||||
sb.append("{\"data\":[");
|
sb.append("{\"data\":[");
|
||||||
try {
|
try {
|
||||||
@ -70,16 +71,40 @@ public class NewDateRequest extends PostRequest {
|
|||||||
sb.append(",\"query\":\"ok\"");
|
sb.append(",\"query\":\"ok\"");
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
break;
|
break;
|
||||||
|
case "gettypes":
|
||||||
|
set = jdcb.executeQuery("select * from cities WHERE `name`='" + params.get("cityname") + "' AND `zone`='"+params.get("zonename")+"' ORDER BY zone ASC");
|
||||||
|
Log.debug(set.toString());
|
||||||
|
sb.append("{\"data\":[");
|
||||||
|
try {
|
||||||
|
String prev = "42";
|
||||||
|
while (set.next()) {
|
||||||
|
if (prev == set.getString("wastetype")) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sb.append("{\"wastetype\":\"" + set.getString("wastetype") + "\"}");
|
||||||
|
if (!set.isLast()) {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prev = set.getString("wastetype");
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sb.append("]");
|
||||||
|
sb.append(",\"query\":\"ok\"");
|
||||||
|
sb.append("}");
|
||||||
|
break;
|
||||||
case "newdate":
|
case "newdate":
|
||||||
sb.append("{");
|
sb.append("{");
|
||||||
Log.debug(params);
|
Log.debug(params);
|
||||||
ResultSet seti = jdcb.executeQuery("select * from cities WHERE `name`='" + params.get("cityname") + "' AND `zone`='" + params.get("zone") + "' AND `wastetype`='" + params.get("wastetype") + "'");
|
set = jdcb.executeQuery("select * from cities WHERE `name`='" + params.get("cityname") + "' AND `zone`='" + params.get("zone") + "' AND `wastetype`='" + params.get("wastetype") + "'");
|
||||||
try {
|
try {
|
||||||
seti.last();
|
set.last();
|
||||||
if (seti.getRow() == 1) {
|
if (set.getRow() == 1) {
|
||||||
Log.debug(seti.getInt("id"));
|
Log.debug(set.getInt("id"));
|
||||||
|
|
||||||
int status = jdcb.executeUpdate("INSERT INTO `pickupdates`(`citywastezoneid`, `pickupdate`) VALUES ('" + seti.getInt("id") + "','" + params.get("date") + "')");
|
int status = jdcb.executeUpdate("INSERT INTO `pickupdates`(`citywastezoneid`, `pickupdate`) VALUES ('" + set.getInt("id") + "','" + params.get("date") + "')");
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
sb.append("\"status\" : \"success\"");
|
sb.append("\"status\" : \"success\"");
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,14 +145,14 @@
|
|||||||
<!-- ./col -->
|
<!-- ./col -->
|
||||||
<div class="col-lg-3 col-6">
|
<div class="col-lg-3 col-6">
|
||||||
<!-- small box -->
|
<!-- small box -->
|
||||||
<div class="small-box bg-success">
|
<div class="small-box bg-gray">
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<h3>53<sup style="font-size: 20px">%</sup></h3>
|
<h3 id="total-city-number-label">42</h3>
|
||||||
|
|
||||||
<p>Verbundene Clients</p>
|
<p>total collect zones</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="ion ion-stats-bars"></i>
|
<i class="ion ion-android-globe" style="color: lightgrey"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
@ -167,7 +167,7 @@
|
|||||||
<p>Planned Collections</p>
|
<p>Planned Collections</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="ion ion-person-add"></i>
|
<i class="ion ion-calendar"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
@ -175,14 +175,14 @@
|
|||||||
<!-- ./col -->
|
<!-- ./col -->
|
||||||
<div class="col-lg-3 col-6">
|
<div class="col-lg-3 col-6">
|
||||||
<!-- small box -->
|
<!-- small box -->
|
||||||
<div class="small-box bg-danger">
|
<div class="small-box bg-success">
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<h3 id="finished-collection-label">65</h3>
|
<h3 id="finished-collection-label">65</h3>
|
||||||
|
|
||||||
<p>Finished Collections</p>
|
<p>Finished Collections</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="ion ion-pie-graph"></i>
|
<i class="ion ion-android-checkmark-circle"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
@ -311,11 +311,7 @@
|
|||||||
data-toggle="dropdown">
|
data-toggle="dropdown">
|
||||||
Select waste type
|
Select waste type
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div id="dropdown-type-drops" class="dropdown-menu">
|
||||||
<a class="dropdown-item-wastetype dropdown-item" href="#">Plastic</a>
|
|
||||||
<a class="dropdown-item-wastetype dropdown-item" href="#">Metal</a>
|
|
||||||
<a class="dropdown-item-wastetype dropdown-item" href="#">Residual waste</a>
|
|
||||||
<a class="dropdown-item-wastetype dropdown-item" href="#">Biowaste</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input id="input-wastetime" style="width: 50px;" class="form-control" id="date"
|
<input id="input-wastetime" style="width: 50px;" class="form-control" id="date"
|
||||||
|
@ -13,21 +13,15 @@ $(document).ready(function () {
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
|
|
||||||
//load total collections
|
//load total collections
|
||||||
$.post('/senddata/wastedata', 'action=getcollectionnumber', function (data) {
|
$.post('/senddata/wastedata', 'action=getStartHeaderData', function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
$("#total-connection-labels").html(data.collectionnumber);
|
$("#total-connection-labels").html(data.collectionnumber);
|
||||||
}, 'json');
|
|
||||||
|
|
||||||
//load future collections
|
$("#planed-collection-label").html(data.futurecollections);
|
||||||
$.post('/senddata/wastedata', 'action=getcollectioninfuture', function (data) {
|
|
||||||
console.log(data);
|
|
||||||
$("#planed-collection-label").html(data.collectionnumber);
|
|
||||||
}, 'json');
|
|
||||||
|
|
||||||
//load future collections
|
$("#finished-collection-label").html(data.finshedcollections);
|
||||||
$.post('/senddata/wastedata', 'action=getfinishedcollections', function (data) {
|
|
||||||
console.log(data);
|
$("#total-city-number-label").html(data.citynumber);
|
||||||
$("#finished-collection-label").html(data.collectionnumber);
|
|
||||||
}, 'json');
|
}, 'json');
|
||||||
|
|
||||||
//load version footer
|
//load version footer
|
||||||
@ -38,6 +32,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
|
|
||||||
var citytable;
|
var citytable;
|
||||||
|
var datetable;
|
||||||
|
|
||||||
function reloadtable() {
|
function reloadtable() {
|
||||||
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
||||||
@ -108,14 +103,63 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var DataTable;
|
|
||||||
function reloadDateTable() {
|
function reloadDateTable() {
|
||||||
$.post('/senddata/wastedata', 'action=getAllDates', function (data) {
|
$.post('/senddata/wastedata', 'action=getAllDates', function (data) {
|
||||||
if (DataTable != null) {
|
if (datetable != null) {
|
||||||
DataTable.destroy(); //delete table if already created
|
datetable.destroy(); //delete table if already created
|
||||||
}
|
}
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
//todo
|
if (data.query == "ok") {
|
||||||
|
$('#picupdates-tablebody').html("");
|
||||||
|
$(".delbtndate").off();
|
||||||
|
|
||||||
|
for (var i = 0; i < data.data.length; i++) {
|
||||||
|
$('#picupdates-tablebody').append("<tr>" +
|
||||||
|
"<td>" + data.data[i].cityname + "</td>" +
|
||||||
|
"<td>" + data.data[i].zone + "</td>" +
|
||||||
|
"<td>" + data.data[i].wastetype + "</td>" +
|
||||||
|
"<td>" + data.data[i].date + "</td>" +
|
||||||
|
"<td>" + "<button dataid='" + data.data[i].id + "' type='button' class='delbtndate btn btn-danger'>X</button>" + "</td>" +
|
||||||
|
"</tr>");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".delbtndate").click(function (event) {
|
||||||
|
var id = event.target.getAttribute("dataid");
|
||||||
|
console.log("clicked btn data " + id);
|
||||||
|
$.post('/senddata/wastedata', 'action=deletedate&id=' + id, function (data) {
|
||||||
|
console.log(data);
|
||||||
|
if (data.status == "success") {
|
||||||
|
Swal.fire({
|
||||||
|
type: "success",
|
||||||
|
title: 'Successfully deleted city!',
|
||||||
|
html: 'This alert closes automatically.',
|
||||||
|
timer: 1000,
|
||||||
|
}).then((result) => {
|
||||||
|
console.log('Popup closed. ')
|
||||||
|
|
||||||
|
});
|
||||||
|
reloadDateTable();
|
||||||
|
} else if (data.status == "dependenciesnotdeleted") {
|
||||||
|
Swal.fire({
|
||||||
|
type: "warning",
|
||||||
|
title: 'This city is a dependency of a date',
|
||||||
|
html: 'Do you want do delete it anyway with all dependencies?',
|
||||||
|
}).then((result) => {
|
||||||
|
console.log('Popup closed. ')
|
||||||
|
|
||||||
|
});
|
||||||
|
//todo set yes no button here
|
||||||
|
}
|
||||||
|
|
||||||
|
}, "json");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
datetable = $("#table-pickupdates").DataTable({
|
||||||
|
"order": [[ 3, "asc" ]]
|
||||||
|
} );
|
||||||
|
|
||||||
|
//todo picupdates-tablebody
|
||||||
},"json");
|
},"json");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,9 +267,31 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dropdown-item-wastetype").click(function (event) {
|
$("#dropdown-type-data").click(function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#dropdown-type-data").html($(this).html());
|
|
||||||
|
var dropdata = $("#dropdown-type-drops");
|
||||||
|
dropdata.html("");
|
||||||
|
console.log("clickeeeed");
|
||||||
|
|
||||||
|
$.post('/senddata/newdate', 'action=gettypes&cityname=' + $("#dropdown-city").html()+'&zonename='+$("#dropdown-zone").html(), function (data) {
|
||||||
|
console.log(data);
|
||||||
|
if (data.query == "ok") {
|
||||||
|
for (var i = 0; i < data.data.length; i++) {
|
||||||
|
var type = data.data[i].wastetype;
|
||||||
|
dropdata.append("<a class=\"dropdown-data-typename dropdown-item\" href=\"#\">" + type + "</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".dropdown-data-typename").off();
|
||||||
|
$(".dropdown-data-typename").click(function (evnt) {
|
||||||
|
evnt.preventDefault();
|
||||||
|
$("#dropdown-type-data").html($(this).html());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -253,6 +319,7 @@ $(document).ready(function () {
|
|||||||
zone.html("Select Zone");
|
zone.html("Select Zone");
|
||||||
wastetype.html("Select waste type");
|
wastetype.html("Select waste type");
|
||||||
date.val("");
|
date.val("");
|
||||||
|
reloadDateTable();
|
||||||
} else if (data.status == "citydoesntexist") {
|
} else if (data.status == "citydoesntexist") {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
type: "warning",
|
type: "warning",
|
||||||
|
Loading…
Reference in New Issue
Block a user