create new Date entry
correct pop ups on create. added some city delete warnings
This commit is contained in:
parent
f132ca9602
commit
7748aa58bd
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -4,7 +4,7 @@
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="true" project-jdk-name="13" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
156
db.sql
Normal file
156
db.sql
Normal file
@ -0,0 +1,156 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.9.0.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Erstellungszeit: 06. Dez 2019 um 16:11
|
||||
-- Server-Version: 10.3.11-MariaDB
|
||||
-- PHP-Version: 5.6.40
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
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 */;
|
||||
|
||||
--
|
||||
-- Datenbank: `wasteinformation`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Tabellenstruktur für Tabelle `cities`
|
||||
--
|
||||
|
||||
CREATE TABLE `cities` (
|
||||
`id` int(11) NOT NULL,
|
||||
`userid` int(11) NOT NULL,
|
||||
`name` varchar(256) NOT NULL,
|
||||
`wastetype` varchar(64) NOT NULL,
|
||||
`zone` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `cities`
|
||||
--
|
||||
|
||||
INSERT INTO `cities` (`id`, `userid`, `name`, `wastetype`, `zone`) VALUES
|
||||
(2, 0, 'Steyr', 'Bio', 2),
|
||||
(3, 0, 'Steyr', 'Bio', 3),
|
||||
(4, 0, 'Steyr', 'Bio', 4),
|
||||
(128, 0, 'Steyr', 'Biowaste', 1),
|
||||
(130, 0, 'abc', 'Biowaste', 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Tabellenstruktur für Tabelle `pickupdates`
|
||||
--
|
||||
|
||||
CREATE TABLE `pickupdates` (
|
||||
`id` int(11) NOT NULL,
|
||||
`citywastezoneid` int(11) NOT NULL,
|
||||
`pickupdate` date NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `pickupdates`
|
||||
--
|
||||
|
||||
INSERT INTO `pickupdates` (`id`, `citywastezoneid`, `pickupdate`) VALUES
|
||||
(6, 4, '2019-12-06'),
|
||||
(7, 3, '2019-12-06'),
|
||||
(8, 2, '2019-12-06'),
|
||||
(9, 130, '2019-12-26');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Tabellenstruktur für Tabelle `user`
|
||||
--
|
||||
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) NOT NULL,
|
||||
`username` varchar(150) NOT NULL,
|
||||
`firstName` varchar(32) NOT NULL,
|
||||
`secondName` varchar(32) NOT NULL,
|
||||
`password` varchar(32) NOT NULL,
|
||||
`permission` int(11) NOT NULL DEFAULT 0,
|
||||
`email` varchar(64) NOT NULL,
|
||||
`logindate` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `user`
|
||||
--
|
||||
|
||||
INSERT INTO `user` (`id`, `username`, `firstName`, `secondName`, `password`, `permission`, `email`, `logindate`) VALUES
|
||||
(2, 'lheilige', 'lukas', 'heiligenbrunner', 'c6e2ddf577e0dfdc4366f788f1b27102', 0, 'lukas.heiligenbrunner@gmail.com', '2019-09-20 12:19:31'),
|
||||
(11, 'meindl', 'emil', 'meindl', '81dc9bdb52d04dc20036dbd8313ed055', 0, 'mailmeindl', '2019-09-27 10:23:46'),
|
||||
(15, 'horni', 'kk', 'kk', 'c4ca4238a0b923820dcc509a6f75849b', 1, 'kk', '2019-09-27 13:19:09');
|
||||
|
||||
--
|
||||
-- Indizes der exportierten Tabellen
|
||||
--
|
||||
|
||||
--
|
||||
-- Indizes für die Tabelle `cities`
|
||||
--
|
||||
ALTER TABLE `cities`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indizes für die Tabelle `pickupdates`
|
||||
--
|
||||
ALTER TABLE `pickupdates`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `citywastezoneid` (`citywastezoneid`);
|
||||
|
||||
--
|
||||
-- Indizes für die Tabelle `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT für exportierte Tabellen
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT für Tabelle `cities`
|
||||
--
|
||||
ALTER TABLE `cities`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=131;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT für Tabelle `pickupdates`
|
||||
--
|
||||
ALTER TABLE `pickupdates`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT für Tabelle `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
|
||||
|
||||
--
|
||||
-- Constraints der exportierten Tabellen
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints der Tabelle `pickupdates`
|
||||
--
|
||||
ALTER TABLE `pickupdates`
|
||||
ADD CONSTRAINT `pickupdates_ibfk_1` FOREIGN KEY (`citywastezoneid`) REFERENCES `cities` (`id`);
|
||||
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 */;
|
@ -3,10 +3,7 @@ package com.wasteinformationserver.db;
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.*;
|
||||
|
||||
public class JDCB {
|
||||
static Connection conn;
|
||||
@ -68,14 +65,9 @@ public class JDCB {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int executeUpdate(String sql) {
|
||||
try {
|
||||
public int executeUpdate(String sql) throws SQLException {
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
|
||||
return stmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||
import java.io.IOException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DataRequest extends PostRequest {
|
||||
@ -42,7 +43,12 @@ public class DataRequest extends PostRequest {
|
||||
if (size == 0) {
|
||||
//doesnt exist
|
||||
System.out.println("doesnt exist");
|
||||
int status = jdcb.executeUpdate("INSERT INTO `cities`(`userid`, `name`, `wastetype`, `zone`) VALUES ('0','" + params.get("cityname") + "','" + params.get("wastetype") + "','" + params.get("wastezone") + "');");
|
||||
int status = 0;
|
||||
try {
|
||||
status = jdcb.executeUpdate("INSERT INTO `cities`(`userid`, `name`, `wastetype`, `zone`) VALUES ('0','" + params.get("cityname") + "','" + params.get("wastetype") + "','" + params.get("wastezone") + "');");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(status);
|
||||
if (status == 1) {
|
||||
sb.append("\"status\" : \"inserted\"");
|
||||
@ -95,20 +101,27 @@ public class DataRequest extends PostRequest {
|
||||
//DELETE FROM `cities` WHERE `id`=0
|
||||
|
||||
StringBuilder sbb = new StringBuilder(); // TODO: 06.12.19 better naming and sb for all
|
||||
|
||||
Log.debug(params.get("id"));
|
||||
int status= jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id")+"'");
|
||||
Log.debug(status);
|
||||
|
||||
sbb.append("{");
|
||||
|
||||
if (status == 1){
|
||||
//success
|
||||
sbb.append("\"status\" : \"success\"");
|
||||
}else {
|
||||
Log.debug(params.get("id"));
|
||||
int status = 0;
|
||||
try{
|
||||
status= jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id")+"'");
|
||||
if (status == 1){
|
||||
//success
|
||||
sbb.append("\"status\" : \"success\"");
|
||||
}else {
|
||||
sbb.append("\"status\" : \"error\"");
|
||||
}
|
||||
}catch (SQLIntegrityConstraintViolationException e){
|
||||
Log.warning("dependencies of deletion exist");
|
||||
sbb.append("\"status\" : \"dependenciesnotdeleted\"");
|
||||
} catch (SQLException e) {
|
||||
Log.error("sql exception: "+e.getMessage());
|
||||
sbb.append("\"status\" : \"error\"");
|
||||
}
|
||||
|
||||
Log.debug(status);
|
||||
|
||||
sbb.append(",\"query\":\"ok\"");
|
||||
sbb.append("}");
|
||||
result = sbb.toString();
|
||||
|
@ -28,13 +28,13 @@ public class NewDateRequest extends PostRequest {
|
||||
try {
|
||||
String prev = "";
|
||||
while (sett.next()) {
|
||||
if (prev.equals(sett.getString("name"))){
|
||||
if (prev.equals(sett.getString("name"))) {
|
||||
|
||||
}else {
|
||||
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"}");
|
||||
if (!sett.isLast()) {
|
||||
} else {
|
||||
if (!sett.isFirst()) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"}");
|
||||
}
|
||||
prev = sett.getString("name");
|
||||
}
|
||||
@ -44,24 +44,24 @@ public class NewDateRequest extends PostRequest {
|
||||
sb.append("]");
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
Log.debug(sb.toString());
|
||||
break;
|
||||
case "getzones":
|
||||
ResultSet set = jdcb.executeQuery("select * from cities WHERE `name`='"+params.get("cityname")+"' ORDER BY zone ASC");
|
||||
ResultSet set = jdcb.executeQuery("select * from cities WHERE `name`='" + params.get("cityname") + "' ORDER BY zone ASC");
|
||||
Log.debug(set.toString());
|
||||
sb.append("{\"data\":[");
|
||||
try {
|
||||
int prev = 42;
|
||||
while (set.next()) {
|
||||
if (prev == set.getInt("zone")){
|
||||
if (prev == set.getInt("zone")) {
|
||||
|
||||
}else {
|
||||
} else {
|
||||
sb.append("{\"zone\":\"" + set.getInt("zone") + "\"}");
|
||||
if (!set.isLast()) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
prev = set.getInt("zone");
|
||||
System.out.println(prev);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@ -70,6 +70,32 @@ public class NewDateRequest extends PostRequest {
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
break;
|
||||
case "newdate":
|
||||
sb.append("{");
|
||||
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") + "'");
|
||||
try {
|
||||
seti.last();
|
||||
if (seti.getRow() == 1) {
|
||||
Log.debug(seti.getInt("id"));
|
||||
|
||||
int status = jdcb.executeUpdate("INSERT INTO `pickupdates`(`citywastezoneid`, `pickupdate`) VALUES ('" + seti.getInt("id") + "','" + params.get("date") + "')");
|
||||
if (status == 1) {
|
||||
sb.append("\"status\" : \"success\"");
|
||||
} else {
|
||||
sb.append("\"status\" : \"error\"");
|
||||
}
|
||||
} else {
|
||||
Log.warning("city doesnt exist!");
|
||||
sb.append("\"status\" : \"citydoesntexist\"");
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
break;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.wasteinformationserver.website.HttpTools;
|
||||
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RegisterRequest extends PostRequest {
|
||||
@ -22,7 +23,11 @@ public class RegisterRequest extends PostRequest {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation");
|
||||
int s = myjd.executeUpdate("INSERT INTO `user` (`username`, `firstName`, `secondName`, `password`, `email`, `logindate`) VALUES ('"+params.get("username")+"', '"+params.get("firstname")+"', '"+params.get("lastname")+"', '"+passhash+"', '"+params.get("email")+"', current_timestamp());");
|
||||
try {
|
||||
int s = myjd.executeUpdate("INSERT INTO `user` (`username`, `firstName`, `secondName`, `password`, `email`, `logindate`) VALUES ('"+params.get("username")+"', '"+params.get("firstname")+"', '"+params.get("lastname")+"', '"+passhash+"', '"+params.get("email")+"', current_timestamp());");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// TODO: 27.09.19 detect if register process was successful and reply right json
|
||||
return "{\"accept\": true}";
|
||||
|
@ -203,7 +203,28 @@
|
||||
</h3>
|
||||
</div><!-- /.card-header -->
|
||||
<div class="card-body">
|
||||
|
||||
<table id="table-pickupdates" class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>City</th>
|
||||
<th>Zone</th>
|
||||
<th>Waste Type</th>
|
||||
<th>Date</th>
|
||||
<th>X</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="picupdates-tablebody">
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>City</th>
|
||||
<th>Zone</th>
|
||||
<th>Waste Type</th>
|
||||
<th>Date</th>
|
||||
<th>X</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div><!-- /.card-body -->
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
@ -241,10 +262,10 @@
|
||||
Select waste type
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#">Plastic</a>
|
||||
<a class="dropdown-item" href="#">Metal</a>
|
||||
<a class="dropdown-item" href="#">Residual waste</a>
|
||||
<a class="dropdown-item" href="#">Biowaste</a>
|
||||
<a class="wastetype-citynew-item dropdown-item" href="#">Plastic</a>
|
||||
<a class="wastetype-citynew-item dropdown-item" href="#">Metal</a>
|
||||
<a class="wastetype-citynew-item dropdown-item" href="#">Residual waste</a>
|
||||
<a class="wastetype-citynew-item dropdown-item" href="#">Biowaste</a>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.card-body -->
|
||||
@ -258,9 +279,6 @@
|
||||
<i class="fas fa-chart-pie mr-1"></i>
|
||||
New Pick up date
|
||||
</h3>
|
||||
<button id="btn-savelist" type="button" class="btn btn-success"
|
||||
style="float:right;">Save
|
||||
</button>
|
||||
</div><!-- /.card-header -->
|
||||
<div class="card-body">
|
||||
<form>
|
||||
@ -288,7 +306,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group-prepend">
|
||||
<button id="dropdown-type-data1" type="button"
|
||||
<button id="dropdown-type-data" type="button"
|
||||
class="btn btn-outline-dark dropdown-toggle"
|
||||
data-toggle="dropdown">
|
||||
Select waste type
|
||||
@ -302,24 +320,10 @@
|
||||
</div>
|
||||
<input id="input-wastetime" style="width: 50px;" class="form-control" id="date"
|
||||
name="date" placeholder="MM/DD/YYY" type="text"/>
|
||||
<button type="button" class="btn-addtolist btn btn-success"
|
||||
<button type="button" class="btn-savelist btn btn-success"
|
||||
style="float:right;">Save
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h4>Your Data:</h4>
|
||||
<table class="table table-dark table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Waste type</th>
|
||||
<th>Date</th>
|
||||
<th>Region</th>
|
||||
<th>Zone</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="addtable-body">
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div><!-- /.card-body -->
|
||||
</div>
|
||||
|
@ -12,10 +12,14 @@ $(document).ready(function () {
|
||||
}
|
||||
}, 'json');
|
||||
|
||||
var table;
|
||||
var citytable;
|
||||
|
||||
function reloadtable() {
|
||||
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
||||
if (citytable != null) {
|
||||
citytable.destroy(); //delete table if already created
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
if (data.query == "ok") {
|
||||
$('#location-table-data').html("");
|
||||
@ -35,32 +39,33 @@ $(document).ready(function () {
|
||||
console.log("clicked btn data " + id);
|
||||
$.post('/senddata/wastedata', 'action=deletecity&id=' + id, function (data) {
|
||||
console.log(data);
|
||||
Swal.fire({
|
||||
type: "success",
|
||||
title: 'Successfully deleted city!',
|
||||
html: 'This alert closes automatically.',
|
||||
timer: 1000,
|
||||
}).then((result) => {
|
||||
console.log('Popup closed. ')
|
||||
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. ')
|
||||
|
||||
});
|
||||
table.destroy(); //todo in reloadtable maybe
|
||||
reloadtable();
|
||||
});
|
||||
});
|
||||
reloadtable();
|
||||
} 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");
|
||||
});
|
||||
|
||||
//todo entweda 1 od 2
|
||||
// $("#example2").reload();
|
||||
table = $("#example2").DataTable();
|
||||
|
||||
// $('#example1').DataTable({
|
||||
// "paging": true,
|
||||
// "lengthChange": false,
|
||||
// "searching": false,
|
||||
// "ordering": true,
|
||||
// "info": true,
|
||||
// "autoWidth": false,
|
||||
// });
|
||||
citytable = $("#example2").DataTable();
|
||||
} else if (data.query == "nodbconn") {
|
||||
Swal.fire({
|
||||
type: "error",
|
||||
@ -74,11 +79,23 @@ $(document).ready(function () {
|
||||
console.log("Error: " + data.query);
|
||||
}
|
||||
|
||||
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
|
||||
var DataTable;
|
||||
function reloadDateTable() {
|
||||
$.post('/senddata/wastedata', 'action=getAllDates', function (data) {
|
||||
if (DataTable != null) {
|
||||
DataTable.destroy(); //delete table if already created
|
||||
}
|
||||
|
||||
//todo
|
||||
},"json");
|
||||
}
|
||||
|
||||
reloadtable();
|
||||
reloadDateTable();
|
||||
|
||||
|
||||
//btn listeners
|
||||
@ -88,7 +105,8 @@ $(document).ready(function () {
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
$('.dropdown-item').click(function () {
|
||||
$('.wastetype-citynew-item').click(function (event) {
|
||||
event.preventDefault();
|
||||
$('#dropdown-wastetype').html($(this).html());
|
||||
});
|
||||
|
||||
@ -110,7 +128,6 @@ $(document).ready(function () {
|
||||
console.log('Popup closed. ')
|
||||
|
||||
});
|
||||
table.destroy();
|
||||
reloadtable();
|
||||
} else if (data.status == "exists") {
|
||||
Swal.fire({
|
||||
@ -122,18 +139,12 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}, 'json');
|
||||
|
||||
//clear form data
|
||||
$("#new_city_cityname").val("");
|
||||
$("#new_city_zonename").val("");
|
||||
$("#dropdown-wastetype").html("select waste type");
|
||||
|
||||
|
||||
//todo reload table.
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -142,6 +153,7 @@ $(document).ready(function () {
|
||||
event.preventDefault();
|
||||
var dropdata = $("#dropdown-city-data");
|
||||
dropdata.html("");
|
||||
console.log("loading city names")
|
||||
|
||||
$.post('/senddata/newdate', 'action=getCitynames', function (data) {
|
||||
console.log(data);
|
||||
@ -159,7 +171,7 @@ $(document).ready(function () {
|
||||
$("#dropdown-city").html($(this).html());
|
||||
});
|
||||
}
|
||||
});
|
||||
}, "json");
|
||||
});
|
||||
|
||||
$("#dropdown-zone").click(function (event) {
|
||||
@ -167,7 +179,7 @@ $(document).ready(function () {
|
||||
var dropdata = $("#dropdown-zone-data");
|
||||
dropdata.html("");
|
||||
|
||||
$.post('/senddata/newdate', 'action=getzones&cityname='+$("#dropdown-city").html(), function (data) {
|
||||
$.post('/senddata/newdate', 'action=getzones&cityname=' + $("#dropdown-city").html(), function (data) {
|
||||
console.log(data);
|
||||
if (data.query == "ok") {
|
||||
var prev = "";
|
||||
@ -188,24 +200,47 @@ $(document).ready(function () {
|
||||
|
||||
$(".dropdown-item-wastetype").click(function (event) {
|
||||
event.preventDefault();
|
||||
$("#dropdown-type-data1").html($(this).html());
|
||||
$("#dropdown-type-data").html($(this).html());
|
||||
});
|
||||
|
||||
|
||||
$('#btn-savelist').click(function () {
|
||||
console.log("saving list");
|
||||
var wastetypearr = $('.td-dropdown-wastetype');
|
||||
var wastetime = $('.td-input-wastetime');
|
||||
var wasteregionarr = $('.td-input-wasteregion');
|
||||
var wastezonearr = $('.td-input-wastezone');
|
||||
$('.btn-savelist').click(function () {
|
||||
console.log("saving date");
|
||||
|
||||
for (var i = 0; i < wastetypearr.length; i++) {
|
||||
console.log(wastetypearr[i].innerHTML);
|
||||
$.post('/senddata/wastedata', 'action=senddata&wastetype=' + wastetypearr[i].innerHTML + "&wastetime=" + wastetime[i].innerHTML + "&wasteregion=" + wasteregionarr[i].innerHTML + "&wastezone=" + wastezonearr[i].innerHTML, function (data) {
|
||||
console.log(data);
|
||||
}, 'text');
|
||||
}
|
||||
var cityname = $("#dropdown-city");
|
||||
var zone = $("#dropdown-zone");
|
||||
var wastetype = $("#dropdown-type-data");
|
||||
var date = $("#input-wastetime");
|
||||
|
||||
$.post('/senddata/newdate', 'action=newdate&cityname=' + cityname.html() + "&zone=" + zone.html() + "&wastetype=" + wastetype.html() + "&date=" + date.val(), function (data) {
|
||||
if (data.status == "success") {
|
||||
Swal.fire({
|
||||
type: "success",
|
||||
title: 'Successfully created Date!',
|
||||
html: 'This alert closes automatically.',
|
||||
timer: 1000,
|
||||
}).then((result) => {
|
||||
console.log('Popup closed. ')
|
||||
|
||||
});
|
||||
|
||||
cityname.html("Select City");
|
||||
zone.html("Select Zone");
|
||||
wastetype.html("Select waste type");
|
||||
date.val("");
|
||||
} else if (data.status == "citydoesntexist") {
|
||||
Swal.fire({
|
||||
type: "warning",
|
||||
title: 'city name doesnt exist',
|
||||
html: 'Close popup.',
|
||||
}).then((result) => {
|
||||
console.log('Popup closed. ')
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
console.log(data)
|
||||
}, "json");
|
||||
});
|
||||
|
||||
|
||||
@ -213,7 +248,7 @@ $(document).ready(function () {
|
||||
var date_input = $('input[name="date"]'); //our date input has the name "date"
|
||||
var container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
|
||||
var options = {
|
||||
format: 'mm/dd/yyyy',
|
||||
format: 'yyyy-mm-dd',
|
||||
container: container,
|
||||
todayHighlight: true,
|
||||
autoclose: true,
|
||||
|
Loading…
Reference in New Issue
Block a user