Jump to content

ianhaney

Members
  • Posts

    330
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ianhaney

  1. How do I make it so that the employee logged in sees just their tasks and not everyones tasks?
  2. Sorry think I sussed it I added the following to the select query , t.status , t.task_id
  3. Just a update, I have built the register and login php scripts and that works perfect and now working on the view page but got stuck with it a bit I got the following 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(); ?> I get the following errors Notice: Undefined property: stdClass::$task_id in /home/sites/it-doneright.co.uk/public_html/admin/staff-tasks/view-employee-tasks.php on line 40 Notice: Undefined property: stdClass::$status in /home/sites/it-doneright.co.uk/public_html/admin/staff-tasks/view-employee-tasks.php on line 42 Notice: Undefined property: stdClass::$status in /home/sites/it-doneright.co.uk/public_html/admin/staff-tasks/view-employee-tasks.php on line 44 Notice: Undefined property: stdClass::$task_id in /home/sites/it-doneright.co.uk/public_html/admin/staff-tasks/view-employee-tasks.php on line 45 It is pulling the following info from the database Description and the emp_id but not the task_id or the status
  4. Hi Barand Thank you for the reply, I have created the database with the three tables and created the db connect php file which is the easy part and now just created a view page, at the mo I have not done the login etc for it as that is quite straight forward but thinking about it, I need to do that first to make sure when logging in that that specific employee can only see their tasks and no one elses So far I have the following, does the SELECT line look ok as always get bit confused on the JOINS part $sql = "SELECT emp_id, emp_name FROM employee JOIN task ON employee.emp_id = task.task_id JOIN assignment on employee.assign_id = assignment.task_id";
  5. 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
  6. Yeah sorry I figured that out after I posted, so sorry, it is working perfect now
  7. Hi I have finally got the HTML email all working ok but got stuck on a few lines which I have added below, I can't work out how to output the date format to dd/mm/yyyy and also output the last id number inserted <p>Expected Start Date: date('d/m/Y', strtotime($exstdate))</p> <p>Expected Repair Date: date('d/m/Y', strtotime($exrdate))</p> <p>Repair Job ID: . mysqli_insert_id($mysqli) . <strong>(Enter this ID number into link below)</strong></p> The whole code is below $to = "$customer_email"; $subject = "Booked Repair Information"; $message = " <html> Hello <strong>$customer_name</strong> <h2>Below is your repair details to track the repair status</h2> <p>Your Name: $customer_name</p> <p>Your Email: $customer_email</p> <p>Your Phone Number: $customer_phone</p> <p>PC/Laptop Make: $computer_make</p> <p>PC/Laptop Make: $computer_model</p> <p>Assigned to Technician: $technician</p> <p>Current Repair Status: $status</p> <p>Expected Start Date: date('d/m/Y', strtotime($exstdate))</p> <p>Expected Start Time: $exstime</p> <p>Expected Repair Date: date('d/m/Y', strtotime($exrdate))</p> <p>Expected Repair Time: $exrtime</p> <p>Dropoff or Pickup: $deltype</p> <p>Comments: $comments</p> <p>Repair Cost: '\243' $exstime . </p> <p>Repair Job ID: . mysqli_insert_id($mysqli) . <strong>(Enter this ID number into link below)</strong></p> <p>http://www.it-doneright.co.uk/track-my-repair.php</p> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $headers .= 'From: <[email protected]>' . "\r\n"; mail($to,$subject,$message,$headers);
  8. Sorry got bit lost, below is the whole coding that does the php email header('Content-Type: text/html;charset=utf-8'); $header = "From: [email protected]\n" . "Reply-To: [email protected]\n"; $subject = "Booked Repair Information"; $email_to = "$customer_email"; $message .= "Below is your repair details to track the repair status\n\n"; $message .= "Your Name: $customer_name\n"; $message .= "Your Email: $customer_email\n"; $message .= "Your Phone Number: $customer_phone\n"; $message .= "PC/Laptop Make: $computer_make\n"; $message .= "PC/Laptop Model: $computer_model\n"; $message .= "Assigned to Technician: $technician\n"; $message .= "Current Repair Status: $status\n"; $message .= "Expected Start Date: " . date("d/m/Y", strtotime($exstdate)) . "\n"; $message .= "Expected Start Time: $exstime\n"; $message .= "Expected Repair Date: " . date("d/m/Y", strtotime($exrdate)) . "\n"; $message .= "Expected Repair Time: $exrtime\n"; $message .= "Dropoff or Pickup: $deltype\n"; $message .= "Comments: $comments\n"; $message .= "Repair Cost: " . "\243" . $cost . "\n\n"; $message .= "Repair Job ID: " . mysqli_insert_id($mysqli) . " (Enter this ID number into link below)" . "\n\n"; $message .= "http://www.it-doneright.co.uk/track-my-repair.php"; mail($email_to, $subject ,$message ,$header ) ; I am testing it and having them sent to myself
  9. Hi Sorry I have tried all different ways to get part of the following line of code in bold $message .= "Repair Job ID: " . mysqli_insert_id($mysqli) . " (Enter this ID number into link below)" . "\n\n"; I want the (Enter this ID number into link below) to be in bold but when I added <strong> just before it, it outputted the html tag so made the line like the following but didn't work as just outputs the html tag as well as am guessing it is because I have wrapped it in " " but then would be wrong if I took the " " out, is that right? $message .= "Repair Job ID: " . mysqli_insert_id($mysqli) . "<strong>" . " (Enter this ID number into link below)" . "</strong> . "\n\n"; Sorry, I have tried myself first before posting and have looked all over for the solution and tried different ways
  10. Hi Sorted it, thank you so much Barand for the replies and advice etc. I managed to do it using the mysqli_insert_id as you mentioned Thank you again so so much
  11. Hi Barand I thought about using the mysqli_insert_id and tried to add it to the php email content but didn't display, I will try it again and try and work it out Sorry there is just one ID column in the repairs table, sorry was my fault not being clear, it is just called id in the repairs table and is auto_inc
  12. Hi Barand Thank you for the reply Yeah the ID is unique, below is the whole coding I have <?php /* Allows the user to both create new records and edit existing records */ // connect to the database include("connect-db.php"); // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($customer_name = '', $customer_email = '', $customer_phone = '', $computer_make = '', $computer_model = '', $technician = '', $status = '', $exrdate = '', $exrtime = '', $exstdate = '', $exstime = '', $deltype = '', $comments = '', $cost = '', $error = '', $id = '') { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> <?php if ($id != '') { echo "Edit Repair Tracking"; } else { echo "New Repair Tracking"; } ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet"href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/blitzer/jquery-ui.css"/> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css/styles.css" /> <script src="js/jquery.ui.timepicker.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css/jquery.ui.timepicker.css" /> <script> $(function() { $("#exrdate").datepicker({ showButtonPanel: true, dateFormat: "yy/mm/dd", showOn:"both" }); }); $(function() { $("#exstdate").datepicker({ showButtonPanel: true, dateFormat: "yy/mm/dd", showOn:"both" }); }); </script> <script> $(document).ready(function() { $('#exrtime').timepicker({ defaultTime: '12:00', showLeadingZero: true, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', }); $('#exstime').timepicker({ defaultTime: '12:00', showLeadingZero: true, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', }); }); </script> <script src="//cdn.ckeditor.com/4.5.5/full/ckeditor.js"></script> </head> <body> <div id="logo"> <img src="images/logo/it-done-right.jpg" alt="" title=""> </div> <? session_start(); if($_SESSION['user']==''){ header("Location:../index.php"); }else{ include("../config.php"); $sql=$dbh->prepare("SELECT * FROM users WHERE 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> <br><br> <a href='../index.php'>Home</a></center>"; echo "</div>"; } } ?> <h1><?php if ($id != '') { echo "Edit Record"; } else { echo "New Record"; } ?></h1> <?php if ($error != '') { echo "<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>"; } ?> <form action="" method="post" class="basic-grey"> <div> <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>Repair ID: <?php echo $id; ?></p> <?php } ?> <br> <strong>Customer Name:</strong> <input type="text" name="customer_name" value="<?php echo $customer_name; ?>"/> <br/> <strong>Customer Email:</strong> <input type="text" name="customer_email" value="<?php echo $customer_email; ?>"/> <br> <strong>Customer Phone:</strong> <input type="text" name="customer_phone" value="<?php echo $customer_phone; ?>"/> <br> <strong>Computer Make:</strong> <input type="text" name="computer_make" value="<?php echo $computer_make; ?>"/> <br> <strong>Computer Model:</strong> <input type="text" name="computer_model" value="<?php echo $computer_model; ?>"/> <br> <strong>Assigned to Technician:</strong> <select name="technician"> <option value="Phil Roskams">Phil Roskams</option> <option value="Ian Haney">Ian Haney</option> </select> <br> <strong>Repair Status:</strong> <select name="status"> <option value="In Queue">In Queue</option> <option value="Working on">Working on</option> <option value="Awaiting Parts">Awaiting Parts</option> <option value="Ready for Collection/Delivery">Ready for Collection/Delivery</option> <option value="Complete">Complete</option> </select> <br> <strong>Expected Start Date:</strong> <input type="text" name="exstdate" value="<?php echo $exstdate; ?>" id="exstdate" /> <br><br> <strong>Expected Start Time:</strong> <input type="time" name="exstime" value="<?php echo $exstime; ?>" id="exstime"/> <br><br> <strong>Expected Repair Date:</strong> <input type="text" name="exrdate" value="<?php echo $exrdate; ?>" id="exrdate"/> <br><br> <strong>Expected Repair Time:</strong> <input type="time" name="exrtime" value="<?php echo $exrtime; ?>" id="exrtime"/> <br><br> <strong>Delivery Type:</strong> <select name="deltype"> <option value="Customer Pickup">Customer Pickup</option> <option value="Delivery">Delivery</option> </select> <br> <strong>Comments:</strong> <br> <textarea name="comments" class="ckeditor"><?php echo $comments; ?></textarea> <br> <strong>Repair Cost:</strong> <input type="text" name="cost" value="<?php echo $cost; ?>"/> <br> <input type="submit" name="submit" value="Add/Update Repair Tracking" /> </div> </form> </body> </html> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $cost = htmlentities($_POST['cost'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $customer_phone == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $customer_phone, $computer_make, $computer_model, $comments, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE repairs SET customer_name = ?, customer_email = ?, customer_phone = ?, computer_make = ?, computer_model = ?, technician = ?, status = ?, exrdate = ?, exrtime = ?, exstdate = ?, exstime = ?, deltype = ?, comments = ?, cost = ? WHERE id=?")) { $stmt->bind_param("ssssssssssssssi", $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $cost, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-repairs-tracking.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the recod from the database if($stmt = $mysqli->prepare("SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, cost FROM repairs WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $cost); $stmt->fetch(); // show the form renderForm($customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $cost, NULL, $id); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view-repairs-tracking.php"); } } } /* NEW RECORD */ // if the 'id' variable is not set in the URL, we must be creating a new record else { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // get the form data $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $cost = htmlentities($_POST['cost'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $computer_make, $computer_model, $comments, $error); } else { // insert the new record into the database if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, cost) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("ssssssssssssss", $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $cost); $stmt->execute(); $stmt->close(); } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement."; } if($stmt) $header = "From: [email protected]\n" . "Reply-To: [email protected]\n"; $subject = "Booked Repair Information"; $email_to = "$customer_email"; $message = "Below is your repair details to track the repair status\n\n" . "Your Name: $customer_name\n" . "Your Email: $customer_email\n" . "Your Phone Number: $customer_phone\n" . "PC/Laptop Make: $computer_make\n" . "PC/Laptop Model: $computer_model\n" . "Assigned to Technician: $technician\n" . "Current Repair Status: $status\n" . "Expected Start Date: $exstdate\n" . "Expected Start Time: $exstime\n" . "Expected Repair Date: $exrdate\n" . "Expected Repair Time: $exrtime\n" . "Dropoff or Pickup: $deltype\n" . "Comments: $comments\n" . "Repair Cost: $cost\n\n" . "Repair ID: $id\n\n" . "<a href='http://www.it-doneright.co.uk/track-my-repair.php'>Track your repair</a>"; mail($email_to, $subject ,$message ,$header ) ; // redirec the user header("Location: view-repairs-tracking.php"); } } // if the form hasn't been submitted yet, show the form else { renderForm(); } } // close the mysqli connection $mysqli->close(); ?> Sorry to post the whole code but thought would all be important and related
  13. Hi I have added in a email script so that after the data is stored in the mysql database, a email is sent out to the customer, it all works perfect apart from one little bit hopefully I can't seem to get the $id number from the database to display within the email, it just returns Repair ID: the coding I have is below if($stmt) $header = "From: [email protected]\n" . "Reply-To: [email protected]\n"; $subject = "Booked Repair Information"; $email_to = "$customer_email"; $message = "Below is your repair details to track the repair status\n\n" . "Your Name: $customer_name\n" . "Your Email: $customer_email\n" . "Your Phone Number: $customer_phone\n" . "PC/Laptop Make: $computer_make\n" . "PC/Laptop Model: $computer_model\n" . "Assigned to Technician: $technician\n" . "Current Repair Status: $status\n" . "Expected Start Date: $exstdate\n" . "Expected Start Time: $exstime\n" . "Expected Repair Date: $exrdate\n" . "Expected Repair Time: $exrtime\n" . "Dropoff or Pickup: $deltype\n" . "Comments: $comments\n" . "Repair Cost: $cost\n\n" . "Repair ID: $id\n\n" . "<a href='http://www.it-doneright.co.uk/track-my-repair.php'>Track your repair</a>"; mail($email_to, $subject ,$message ,$header ) ; I guess I need to add $_GET or $_POST somewhere before the email part to retrieve the $id and display in the email, is that right?
  14. Hi Barand and Ch0cu3r I have altered the coding to what you both said and is perfect now, thank you so much
  15. Hi Each time I go to insert or edit a textarea, I seem to have big blank space before typing so can't start typing from the left and always seems to start way over to the left on the first line and I keep having to delete the blank spaces so is over to the left before I can start typing, the coding I have is below <strong>Comments:</strong> <br> <textarea name="comments"> <?php echo $comments; ?> </textarea> Just seeing if anyone can see if I have done anything wrong somewhere? Thank you in advance Ian
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.