Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach committed Apr 25, 2019
1 parent a6f39d4 commit 0f2e5d6
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 37 deletions.
3 changes: 0 additions & 3 deletions AddNewItem/addNewItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
require '../database-info.php';
require '../databaseFunctions.php';




$name = $_POST['name'];
$description = $_POST['description'];
$dueDate = $_POST['duedate'] . " " . date("H:i:s");
Expand Down
19 changes: 14 additions & 5 deletions AddNewItem/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
require('../header.php');
require '../database-info.php';
require '../databaseFunctions.php';
require ('../header.php');
require ('../database-info.php');
require ('../databaseFunctions.php');
?>
<div class="container mb-5">
<div class="row bg-primary text-white">
Expand All @@ -16,8 +16,7 @@
session_start();
if(isset($_SESSION['ResultMessage1'])){
echo $_SESSION['ResultMessage1'];
exit();
}
}
?>
</div>
<form class="text-center" style="font-size:18px;" action="addNewItem.php" method="POST">
Expand All @@ -42,6 +41,16 @@

</div>
</div>
<script>
document.location.reload(true)(){
//Clear Sessions (Error Messages) on Page Reload
<?php
session_start();
session_unset();
session_destroy();
?>
}
</script>
<?php
include ('../footer.php');
?>
53 changes: 31 additions & 22 deletions ToDoList/editTask.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
<?php
require('../header.php');
require '../database-info.php';
require '../databaseFunctions.php';
/*
if(isset($_GET['editTaskItem'])){
$id = $_GET['editTaskItem'];
$sql = editTaskItem($id);
$stmt = $pdo-prepare ($sql);
$stmt->execute ();
}
*/
if(isset($_GET['editTaskItem'])){
$id = $_GET['editTaskItem'];
require ('../header.php');
require ('../database-info.php');
require ('../databaseFunctions.php');

$id = $_GET['id'];
$sql = selectToDoListItem($id);
$stmt = $pdo-prepare ($sql);
$stmt = $pdo->prepare ($sql);
$stmt->execute ();
}
?>
$row = $stmt -> fetch();

<form class="form">
<label>Name:</label>
<input type="text" value="<?=$row['ToDoName'];?>"/>
?>
<div class="container">
<form action="editTaskHandling.php" method="POST" class="form-inline justify-content-center">
<input type="hidden" value="<?=$id;?>" name="toDoID" />
<div class="form-group col-12">
<label class="text-center">Name:</label>
<input type="text" class="form-control" name="itemName" value="<?=$row['ToDoName'];?>"/>
</div>
<div class="form-group col-12">
<label>Description:</label>
<input type="text" value="<?=$row['ToDoName'];?>"/>
<input type="text" class="form-control" name="itemDescription" value="<?=$row['ToDoDescription'];?>"/>
</div>
<div class="form-group col-12">
<label>Due Date:</label>
<input type="date" class="form-control" name="itemDueDate" value="<?=$row['ToDoDueDate'];?>"/>
</div>
<input type="submit" class="col bg-success btn text-white mt-2" value="Update Changes"/>
</form>
<a href="#" onclick="closeWindow()" class="btn col bg-primary text-white mb-3">Cancel Changes</a>

<input type="submit" value="Update"/>
</form>
</div>
<script>
function closeWindow(){
window.close();
}
</script>
21 changes: 21 additions & 0 deletions ToDoList/editTaskHandling.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
require ('../database-info.php');
require ('../databaseFunctions.php');
try {
$id = $_POST['toDoID'];
$name = $_POST['itemName'];
$description = $_POST['itemDescription'];
$dueDate = $_POST['itemDueDate'];
$sql = editTaskItem($id);
$stmt = $pdo->prepare($sql);
$stmt->bindValue (':name', $name);
$stmt->bindValue (':description', $description);
$stmt->bindValue (':date', $dueDate);
$stmt->execute ();
} catch(Exception $e){
echo "Error while updating data " . $e->getMessage() , "\n";
}
echo "Successfully updated item! <script>window.close();</script>";


?>
12 changes: 6 additions & 6 deletions ToDoList/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
$stmt = $pdo->prepare ($sql);
$stmt->execute ();
}
if(isset($_GET['editTaskItem'])){
/*if(isset($_GET['editTaskItem'])){
$id = $_GET['editTaskItem'];
$sql = editTaskItem($id);
$stmt = $pdo->prepare ($sql);
$stmt->execute ();
}
}*/
?>
<head>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
Expand All @@ -38,7 +38,7 @@
$result->execute();
?>
</div>
<a href="#" onclick="addNewItem();" class="fa fa-plus fa-3x m-2"></a>
<a href="#" onclick="addNewItem();" class="fa fa-plus fa-3x m-2 p-1"></a>
<table class="table table-bordered table-striped text-center" id="myTable">
<thead class="bg-primary">
<th>Edit</th>
Expand All @@ -53,7 +53,7 @@
<tbody>
<?php foreach($result as $row): ?>
<tr style="background-color:white; text-align:center;">
<td><a class="far fa-edit fa-2x" href="index.php?editTaskItem=<?=$row['ToDoID'];?>"></a></td>
<td><a class="far fa-edit fa-2x" href="#" onclick="editItem()" ></a></td>
<!--<td><?=$row['ToDoID'];?></td>-->
<input type="hidden" value="<?=$row['ToDoID'];?>"/>
<td><?=$row['ToDoName'];?></td>
Expand All @@ -77,14 +77,14 @@ function editItem(){
let params = `scrollbars=yes,resizable=no,status=no,location=no,toolbar=no,menubar=no,
width=500,height=500,left=0,top=0`;

open("/PHP-ToDo/ToDoList/editTask.php?id=<?echo $row['ToDoID']?>", 'test', params);
open("/PHPToDo/ToDoList/editTask.php?id=<?=$row['ToDoID'];?>", 'test', params);
}

function addNewItem(){
let params = `scrollbars=yes,resizable=yes,status=no,location=no,toolbar=no,menubar=no,
width=500,height=650,left=0,top=0`;

open('/PHP-ToDo/AddNewItem', 'test', params);
open('/PHPToDo/AddNewItem', 'test', params);
}
</script>
</div>
2 changes: 1 addition & 1 deletion databaseFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function selectToDoList(){
}

function selectToDoListItem($id){
$sqlQuery = "SELECT * FROM todolist WHERE ToListID = $id;";
$sqlQuery = "SELECT * FROM todolist WHERE ToDoID = $id;";
return $sqlQuery;
}

Expand Down

0 comments on commit 0f2e5d6

Please sign in to comment.