create new Date entry
correct pop ups on create. added some city delete warnings
This commit is contained in:
parent
f132ca9602
commit
7748aa58bd
@ -4,7 +4,7 @@
|
|||||||
<component name="JavaScriptSettings">
|
<component name="JavaScriptSettings">
|
||||||
<option name="languageLevel" value="ES6" />
|
<option name="languageLevel" value="ES6" />
|
||||||
</component>
|
</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" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</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 com.wasteinformationserver.basicutils.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Connection;
|
import java.sql.*;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class JDCB {
|
public class JDCB {
|
||||||
static Connection conn;
|
static Connection conn;
|
||||||
@ -68,14 +65,9 @@ public class JDCB {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int executeUpdate(String sql) {
|
public int executeUpdate(String sql) throws SQLException {
|
||||||
try {
|
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||||
|
|
||||||
return stmt.executeUpdate();
|
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.io.IOException;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.SQLIntegrityConstraintViolationException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class DataRequest extends PostRequest {
|
public class DataRequest extends PostRequest {
|
||||||
@ -42,7 +43,12 @@ public class DataRequest extends PostRequest {
|
|||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
//doesnt exist
|
//doesnt exist
|
||||||
System.out.println("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);
|
System.out.println(status);
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
sb.append("\"status\" : \"inserted\"");
|
sb.append("\"status\" : \"inserted\"");
|
||||||
@ -95,19 +101,26 @@ public class DataRequest extends PostRequest {
|
|||||||
//DELETE FROM `cities` WHERE `id`=0
|
//DELETE FROM `cities` WHERE `id`=0
|
||||||
|
|
||||||
StringBuilder sbb = new StringBuilder(); // TODO: 06.12.19 better naming and sb for all
|
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("{");
|
sbb.append("{");
|
||||||
|
Log.debug(params.get("id"));
|
||||||
|
int status = 0;
|
||||||
|
try{
|
||||||
|
status= jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id")+"'");
|
||||||
if (status == 1){
|
if (status == 1){
|
||||||
//success
|
//success
|
||||||
sbb.append("\"status\" : \"success\"");
|
sbb.append("\"status\" : \"success\"");
|
||||||
}else {
|
}else {
|
||||||
sbb.append("\"status\" : \"error\"");
|
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(",\"query\":\"ok\"");
|
||||||
sbb.append("}");
|
sbb.append("}");
|
||||||
|
@ -31,10 +31,10 @@ public class NewDateRequest extends PostRequest {
|
|||||||
if (prev.equals(sett.getString("name"))) {
|
if (prev.equals(sett.getString("name"))) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"}");
|
if (!sett.isFirst()) {
|
||||||
if (!sett.isLast()) {
|
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
}
|
}
|
||||||
|
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"}");
|
||||||
}
|
}
|
||||||
prev = sett.getString("name");
|
prev = sett.getString("name");
|
||||||
}
|
}
|
||||||
@ -44,6 +44,7 @@ public class NewDateRequest extends PostRequest {
|
|||||||
sb.append("]");
|
sb.append("]");
|
||||||
sb.append(",\"query\":\"ok\"");
|
sb.append(",\"query\":\"ok\"");
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
|
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");
|
ResultSet set = jdcb.executeQuery("select * from cities WHERE `name`='" + params.get("cityname") + "' ORDER BY zone ASC");
|
||||||
@ -61,7 +62,6 @@ public class NewDateRequest extends PostRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev = set.getInt("zone");
|
prev = set.getInt("zone");
|
||||||
System.out.println(prev);
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -70,6 +70,32 @@ public class NewDateRequest extends PostRequest {
|
|||||||
sb.append(",\"query\":\"ok\"");
|
sb.append(",\"query\":\"ok\"");
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
break;
|
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();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.wasteinformationserver.website.HttpTools;
|
|||||||
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class RegisterRequest extends PostRequest {
|
public class RegisterRequest extends PostRequest {
|
||||||
@ -22,7 +23,11 @@ public class RegisterRequest extends PostRequest {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
//new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation");
|
//new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation");
|
||||||
|
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());");
|
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
|
// TODO: 27.09.19 detect if register process was successful and reply right json
|
||||||
return "{\"accept\": true}";
|
return "{\"accept\": true}";
|
||||||
|
@ -203,7 +203,28 @@
|
|||||||
</h3>
|
</h3>
|
||||||
</div><!-- /.card-header -->
|
</div><!-- /.card-header -->
|
||||||
<div class="card-body">
|
<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-body -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.card -->
|
<!-- /.card -->
|
||||||
@ -241,10 +262,10 @@
|
|||||||
Select waste type
|
Select waste type
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#">Plastic</a>
|
<a class="wastetype-citynew-item dropdown-item" href="#">Plastic</a>
|
||||||
<a class="dropdown-item" href="#">Metal</a>
|
<a class="wastetype-citynew-item dropdown-item" href="#">Metal</a>
|
||||||
<a class="dropdown-item" href="#">Residual waste</a>
|
<a class="wastetype-citynew-item dropdown-item" href="#">Residual waste</a>
|
||||||
<a class="dropdown-item" href="#">Biowaste</a>
|
<a class="wastetype-citynew-item dropdown-item" href="#">Biowaste</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.card-body -->
|
</div><!-- /.card-body -->
|
||||||
@ -258,9 +279,6 @@
|
|||||||
<i class="fas fa-chart-pie mr-1"></i>
|
<i class="fas fa-chart-pie mr-1"></i>
|
||||||
New Pick up date
|
New Pick up date
|
||||||
</h3>
|
</h3>
|
||||||
<button id="btn-savelist" type="button" class="btn btn-success"
|
|
||||||
style="float:right;">Save
|
|
||||||
</button>
|
|
||||||
</div><!-- /.card-header -->
|
</div><!-- /.card-header -->
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form>
|
<form>
|
||||||
@ -288,7 +306,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group-prepend">
|
<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"
|
class="btn btn-outline-dark dropdown-toggle"
|
||||||
data-toggle="dropdown">
|
data-toggle="dropdown">
|
||||||
Select waste type
|
Select waste type
|
||||||
@ -302,24 +320,10 @@
|
|||||||
</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"
|
||||||
name="date" placeholder="MM/DD/YYY" type="text"/>
|
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
|
style="float:right;">Save
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
</form>
|
||||||
</div><!-- /.card-body -->
|
</div><!-- /.card-body -->
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,10 +12,14 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
}, 'json');
|
}, 'json');
|
||||||
|
|
||||||
var table;
|
var citytable;
|
||||||
|
|
||||||
function reloadtable() {
|
function reloadtable() {
|
||||||
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
||||||
|
if (citytable != null) {
|
||||||
|
citytable.destroy(); //delete table if already created
|
||||||
|
}
|
||||||
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (data.query == "ok") {
|
if (data.query == "ok") {
|
||||||
$('#location-table-data').html("");
|
$('#location-table-data').html("");
|
||||||
@ -35,6 +39,7 @@ $(document).ready(function () {
|
|||||||
console.log("clicked btn data " + id);
|
console.log("clicked btn data " + id);
|
||||||
$.post('/senddata/wastedata', 'action=deletecity&id=' + id, function (data) {
|
$.post('/senddata/wastedata', 'action=deletecity&id=' + id, function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
if (data.status == "success") {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
type: "success",
|
type: "success",
|
||||||
title: 'Successfully deleted city!',
|
title: 'Successfully deleted city!',
|
||||||
@ -44,23 +49,23 @@ $(document).ready(function () {
|
|||||||
console.log('Popup closed. ')
|
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
|
citytable = $("#example2").DataTable();
|
||||||
// $("#example2").reload();
|
|
||||||
table = $("#example2").DataTable();
|
|
||||||
|
|
||||||
// $('#example1').DataTable({
|
|
||||||
// "paging": true,
|
|
||||||
// "lengthChange": false,
|
|
||||||
// "searching": false,
|
|
||||||
// "ordering": true,
|
|
||||||
// "info": true,
|
|
||||||
// "autoWidth": false,
|
|
||||||
// });
|
|
||||||
} else if (data.query == "nodbconn") {
|
} else if (data.query == "nodbconn") {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
type: "error",
|
type: "error",
|
||||||
@ -74,11 +79,23 @@ $(document).ready(function () {
|
|||||||
console.log("Error: " + data.query);
|
console.log("Error: " + data.query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}, 'json');
|
}, '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();
|
reloadtable();
|
||||||
|
reloadDateTable();
|
||||||
|
|
||||||
|
|
||||||
//btn listeners
|
//btn listeners
|
||||||
@ -88,7 +105,8 @@ $(document).ready(function () {
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.dropdown-item').click(function () {
|
$('.wastetype-citynew-item').click(function (event) {
|
||||||
|
event.preventDefault();
|
||||||
$('#dropdown-wastetype').html($(this).html());
|
$('#dropdown-wastetype').html($(this).html());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -110,7 +128,6 @@ $(document).ready(function () {
|
|||||||
console.log('Popup closed. ')
|
console.log('Popup closed. ')
|
||||||
|
|
||||||
});
|
});
|
||||||
table.destroy();
|
|
||||||
reloadtable();
|
reloadtable();
|
||||||
} else if (data.status == "exists") {
|
} else if (data.status == "exists") {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
@ -122,18 +139,12 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}, 'json');
|
}, 'json');
|
||||||
|
|
||||||
//clear form data
|
//clear form data
|
||||||
$("#new_city_cityname").val("");
|
$("#new_city_cityname").val("");
|
||||||
$("#new_city_zonename").val("");
|
$("#new_city_zonename").val("");
|
||||||
$("#dropdown-wastetype").html("select waste type");
|
$("#dropdown-wastetype").html("select waste type");
|
||||||
|
|
||||||
|
|
||||||
//todo reload table.
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -142,6 +153,7 @@ $(document).ready(function () {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var dropdata = $("#dropdown-city-data");
|
var dropdata = $("#dropdown-city-data");
|
||||||
dropdata.html("");
|
dropdata.html("");
|
||||||
|
console.log("loading city names")
|
||||||
|
|
||||||
$.post('/senddata/newdate', 'action=getCitynames', function (data) {
|
$.post('/senddata/newdate', 'action=getCitynames', function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@ -159,7 +171,7 @@ $(document).ready(function () {
|
|||||||
$("#dropdown-city").html($(this).html());
|
$("#dropdown-city").html($(this).html());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}, "json");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#dropdown-zone").click(function (event) {
|
$("#dropdown-zone").click(function (event) {
|
||||||
@ -188,24 +200,47 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
$(".dropdown-item-wastetype").click(function (event) {
|
$(".dropdown-item-wastetype").click(function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#dropdown-type-data1").html($(this).html());
|
$("#dropdown-type-data").html($(this).html());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#btn-savelist').click(function () {
|
$('.btn-savelist').click(function () {
|
||||||
console.log("saving list");
|
console.log("saving date");
|
||||||
var wastetypearr = $('.td-dropdown-wastetype');
|
|
||||||
var wastetime = $('.td-input-wastetime');
|
|
||||||
var wasteregionarr = $('.td-input-wasteregion');
|
|
||||||
var wastezonearr = $('.td-input-wastezone');
|
|
||||||
|
|
||||||
for (var i = 0; i < wastetypearr.length; i++) {
|
var cityname = $("#dropdown-city");
|
||||||
console.log(wastetypearr[i].innerHTML);
|
var zone = $("#dropdown-zone");
|
||||||
$.post('/senddata/wastedata', 'action=senddata&wastetype=' + wastetypearr[i].innerHTML + "&wastetime=" + wastetime[i].innerHTML + "&wasteregion=" + wasteregionarr[i].innerHTML + "&wastezone=" + wastezonearr[i].innerHTML, function (data) {
|
var wastetype = $("#dropdown-type-data");
|
||||||
console.log(data);
|
var date = $("#input-wastetime");
|
||||||
}, 'text');
|
|
||||||
|
$.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 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 container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
|
||||||
var options = {
|
var options = {
|
||||||
format: 'mm/dd/yyyy',
|
format: 'yyyy-mm-dd',
|
||||||
container: container,
|
container: container,
|
||||||
todayHighlight: true,
|
todayHighlight: true,
|
||||||
autoclose: true,
|
autoclose: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user