Menu
Hi
Sorry if is in the wrong place but was seeing if anyone knows of a script that can do the following
1) login to an admin side using admin login info
2) add tasks and assign them to employees
3) the employee can log in with their own log in info
4) the employee can then view their tasks that are just for them and not view others that are assigned to other employees
5) update the task themselves once completed
6) admin can also see the task and the update of it if it has been completed or working on
Thank you in advance
Ian
[CODE]
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
?>
<?php
include("db-connect.php");
// get the records from the database
if ($result = $mysqli->query("SELECT
e.emp_id
, t.description
FROM employee e
JOIN assignment a ON e.emp_id = a.emp_id
JOIN task t ON a.task_id = t.task_id"))
{
// display records if there are records to display
if ($result->num_rows > 0)
{
// display records in a table
echo "<table>";
// set table headers
echo "<tr>
<th>Task ID</th>
<th>Description</th>
<th>Status</th>
<th>Emp ID</th>
<th>Status</th>
<th colspan='2'>Actions</th>
</tr>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->task_id . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td>" . $row->emp_id . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td><a href='records.php?task_id=" . $row->task_id . "'>Edit</a></td>";
echo "</tr>";
}
echo "</table>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
else
{
echo "Error: " . $mysqli->error;
}
// close database connection
$mysqli->close();
?>
[/CODE]
[CODE]
, t.status
, t.task_id
[/CODE]
<i>
</i>JOIN task t ON a.task_id = t.task_id AND t.emp_id = e.emp_id
[CODE]
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
?>
<!DOCTYPE html>
<html>
<head>
<title>View Tasks</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/login-styles.css" />
</head>
<body>
<h2>View Tasks</h2>
<?
session_start();
if($_SESSION['user']==''){
header("Location:login.php");
}else{
include("config.php");
$sql=$dbh->prepare("SELECT * FROM employee WHERE emp_id=?");
$sql->execute(array($_SESSION['user']));
while($r=$sql->fetch()){
echo "<div class='home-content'>";
echo "<center><h2>Hello, ".$r['username']."</h2>";
echo "<a href='logout.php'>Log Out</a></center>";
echo "</div>";
}
}
?>
<?php
include("db-connect.php");
// get the records from the database
if ($result = $mysqli->prepare("SELECT
e.emp_id
, t.task_id
, t.description
, t.status
FROM employee e
JOIN assignment a ON e.emp_id = a.emp_id
JOIN task t ON a.task_id = t.task_id
WHERE e.emp_id = ?"));
$sql->execute(array($_SESSION['user']));
{
// display records if there are records to display
if ($result->num_rows > 0)
{
// display records in a table
echo "<table>";
// set table headers
echo "<tr>
<th>Task ID</th>
<th>Description</th>
<th>Status</th>
<th>Emp ID</th>
<th>Status</th>
<th colspan='1'>Actions</th>
</tr>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->task_id . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td>" . $row->emp_id . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td><a href='records.php?task_id=" . $row->task_id . "'>Edit</a></td>";
echo "</tr>";
}
echo "</table>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
/*else {
echo "Error: " . $mysqli->error;
}*/
// close database connection
$mysqli->close();
?>
</body>
</html>
[/CODE]
[CODE]
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
?>
<!DOCTYPE html>
<html>
<head>
<title>View Tasks</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/login-styles.css" />
</head>
<body>
<h2>View Tasks</h2>
<?
session_start();
if($_SESSION['user']==''){
header("Location:login.php");
}else{
include("config.php");
$sql=$dbh->prepare("SELECT * FROM employee WHERE emp_id=?");
$sql->execute(array($_SESSION['user']));
while($r=$sql->fetch()){
echo "<div class='home-content'>";
echo "<center><h2>Hello, ".$r['username']."</h2>";
echo "<a href='logout.php'>Log Out</a></center>";
echo "</div>";
}
}
?>
<?php
include("config.php");
$sql=$dbh->prepare("SELECT
e.emp_id
, t.task_id
, t.description
, t.status
FROM employee e
JOIN assignment a ON e.emp_id = a.emp_id
JOIN task t ON a.task_id = t.task_id
WHERE e.emp_id = ?");
$sql->execute(array($_SESSION['user']));
{
// display records if there are records to display
//if ($sql->num_rows > 0)
if ($sql->fetchColumn() > 0)
{
// display records in a table
echo "<table>";
// set table headers
echo "<tr>
<th>Task ID</th>
<th>Description</th>
<th>Status</th>
<th>Emp ID</th>
<th>Status</th>
<th colspan='1'>Actions</th>
</tr>";
while ($row = $sql->fetchColumn())
{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->task_id . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td>" . $row->emp_id . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td><a href='records.php?task_id=" . $row->task_id . "'>Edit</a></td>";
echo "</tr>";
}
echo "</table>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
/*else {
echo "Error: " . $mysqli->error;
}*/
// close database connection
$dbh = null;
?>
</body>
</html>
[/CODE]
[code=php]
$sql=$dbh->prepare("SELECT
e.emp_id
, t.task_id
, t.description
, t.status
FROM employee e
JOIN assignment a ON e.emp_id = a.emp_id
JOIN task t ON a.task_id = t.task_id
WHERE e.emp_id = ?");
$sql->execute(array($_SESSION['user']));
// were any rows found?
if ($row = $sql->fetchObject())
{
// display records in a table
echo "<table>";
// set table headers
echo "<tr>
<th>Task ID</th>
<th>Description</th>
<th>Status</th>
<th>Emp ID</th>
<th>Status</th>
<th colspan='1'>Actions</th>
</tr>";
do {
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->task_id . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td>" . $row->emp_id . "</td>";
echo "<td>" . $row->status . "</td>";
echo "<td><a href='records.php?task_id=" . $row->task_id . "'>Edit</a></td>";
echo "</tr>";
} while ($row = $sql->fetchObject());
echo "</table>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
[/code]
0.1.9 — BETA 5.19