Jump to content

ianhaney50

Members
  • Posts

    261
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ianhaney50

  1. Hi Thank you for the reply, appreciate it Sorry yeah I realised that shortly after posting my question, so sorry, is perfect now
  2. Hi I just found another little issue, not sure why it is outputting all the records as before it just outputted the id record I click on The code for the specific id record is below <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>IT Done Right Admin View Repair Tracking</title> <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" /> <link rel="stylesheet" href="css/print.css" type="text/css" media="print"> </head> <body> <script> var t; window.onload=resetTimer; document.onkeypress=resetTimer; function logout() { alert("You are now logged out.") location.href='../logout.php' } function resetTimer() { clearTimeout(t); t=setTimeout(logout,1800000) //logs out in 30 minutes } </script> <? 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>"; echo "<br><br>"; echo "<a href='../home.php'>Home</a></center>"; echo "</div>"; } } ?> <div class="print"> <div id="logo"> <img src="images/logo/it-done-right.jpg" alt="" title=""> </div> <div style="clear: both;"> <?php // connect to the database include('connect-db.php'); // get the records from the database if ($result = $mysqli->query("SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, DATE_FORMAT(exrdate,'%d/%m/%Y') AS exrdate, exrtime, DATE_FORMAT(exstdate,'%d/%m/%Y') AS exstdate, exstime, deltype, comments, cost FROM repairs ORDER BY id")) { // display records if there are records to display if ($result->num_rows > 0) { // display records in a table while ($row = $result->fetch_object()) { echo "<strong>Repair ID</strong>: " . $row->id; echo "<br><br>"; echo "<strong>Customer Name</strong>: " . $row->customer_name; echo "<br><br>"; echo "<strong>Customer Email</strong>: " . $row->customer_email; echo "<br><br>"; echo "<strong>Customer Phone</strong>: " . $row->customer_phone; echo "<br><br>"; echo "<strong>Computer Make</strong>: " . $row->computer_make; echo "<br><br>"; echo "<strong>Computer Model</strong>: " . $row->computer_model; echo "<br><br>"; echo "<strong>Assigned to Technician</strong>: " . $row->technician; echo "<br><br>"; echo "<strong>Repair Status</strong>: " . $row->status; echo "<br><br>"; echo "<strong>Expected Repair Date</strong>: " . $row->exrdate; echo "<br><br>"; echo "<strong>Expected Repair Time</strong>: " . $row->exrtime; echo "<br><br>"; echo "<strong>Expected Start Date</strong>: " . $row->exstdate; echo "<br><br>"; echo "<strong>Expected Start Time</strong>: " . $row->exstime; echo "<br><br>"; echo "<strong>Delivery Type</strong>: " . $row->deltype; echo "<br><br>"; echo "<strong>Comments</strong>: " . $row->comments; echo "<br><br>"; echo "<strong>Repair Cost</strong>: " . '£' . $row->cost; echo "</div>"; echo "</div>"; echo "<br><br>"; echo "<td><a href='repairs-tracking.php?id=" . $row->id . "'>Edit</a></td>"; echo "<br><br>"; } } // 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(); ?> <a href="view-repairs-tracking.php">Back to view all repairs tracking</a> | <a href="#" onclick="window.print();return false;">Print this page</a> | <a href="repairs-tracking.php">Add New Repair For Tracking</a> </body> </html>
  3. So sorry, I thought the easier way would be to make the datepicker be in standard format of yy/mm/dd code and tested it and works perfect now and now displays on the page as 28/11/2015 so is perfect now, so sorry for being a pain
  4. Hi Barand I just added that to the INSERT query so now looks like the following if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, (STR_TO_DATE($exstdate, '%d/%m/%y') ), exstime, deltype, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) I selected 8/11/2015 within the datepicker but has outputted it as 10/4/2015
  5. I renamed the $date to the name of $exrdate and it worked but it outputted the date as 10/4/2015 instead of 4/10/2015 and also it should be 4/11/2015 not 4/10/2015 also how do I get that to work for a second date as well as I have exrdate and exstdate
  6. I just tried that and didn't work still, I added it directly above the insert query
  7. Thank you so much, works perfect I just found another little issue when testing, the record date is being inserted into the mysql table as 00/00/0000 instead of the actual date, I am using datepicker, the INSERT query is below if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) The datepicker coding is below <script> $(function() { $( "#exrdate" ).datepicker({ showButtonPanel: true, dateFormat: "dd/mm/yy", showOn:"both" }); }); $(function() { $( "#exstdate" ).datepicker({ showButtonPanel: true, dateFormat: "dd/mm/yy", showOn:"both" }); }); </script> It was working before but not now for some reason the data type in the mysql table is date and has no NULL or default
  8. Thank you so much, works perfect I just found another little issue when testing, the record date is being inserted into the mysql table as 00/00/0000 instead of the actual date, I am using datepicker, the INSERT query is below // 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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))
  9. Hi I am trying to work out how to display a specific number of characters in a echo row, the line looks like the following echo "<td>" . $row->comments . "</td>"; Thank you in advance Sorry I did look on Google but couldn't see a way to do it with the similar coding I have above
  10. I did notice the form on the edit page has the method post instead of get so am guessing is best to replace $_GET with $_POST
  11. Below is the view page that calls the edit page <?php $host = ''; $user = ''; $password = ''; $dname = ''; $db = new mysqli($host, $user, $password, $dname); if ($db->connect_errno) { echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error; } $sql = "SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments FROM repairs"; $result_db = $db->query($sql) or die('Error perform query!'); ?> <table border="1"> <tr> <th>Repair ID</th> <th>Customer Name</th> <th>Customer Email</th> <th>Customer Phone</th> <th>Computer Make</th> <th>Computer Model</th> <th>Technician</th> <th>Status</th> <th>Expected Repair Date</th> <th>Expected Repair Time</th> <th>Expected Start Date</th> <th>Expected Start Time</th> <th>Delivery Type</th> <th>Comments</th> <th>Update</th> </tr> <?php while ($r = $result_db->fetch_object()) { $update = "admin/repairs-tracking/edit-repair-tracking.php?id={$r->id}"; echo '<tr>'; echo '<td>' . $r->id . '</td>'; echo '<td>' . $r->customer_name . '</td>'; echo '<td>' . $r->customer_email . '</td>'; echo '<td>' . $r->customer_phone . '</td>'; echo '<td>' . $r->computer_make . '</td>'; echo '<td>' . $r->computer_model . '</td>'; echo '<td>' . $r->technician . '</td>'; echo '<td>' . $r->status . '</td>'; echo '<td>' . $r->exrdate . '</td>'; echo '<td>' . $r->exrtime . '</td>'; echo '<td>' . $r->exstdate . '</td>'; echo '<td>' . $r->exstime . '</td>'; echo '<td>' . $r->deltype . '</td>'; echo '<td>' . $r->comments . '</td>'; echo "<td><a href='/{$update}'>Update</a></td>"; echo '</tr>'; } $db->close(); ?> </table>
  12. Hi I have added in the var dump line and that outputs the following array(1) { ["id"]=> string(2) "20" } So $_POST is better then, that right? If so do I just change $_GET to $_POST
  13. Hi I am trying to populate a form ready to update the data and have managed to get the id number displaying in the input field but for every other input field, it displays the following <br /><b>Notice</b>: Undefined index: customer_name in <b>/home/sites/it-doneright.co.uk/public_html/admin/repairs-tracking/edit-repair-tracking.php</b> on line <b>40</b><br /> I really don't get it or see where I am going wrong with it, below is the whole code on the edit-repair-tracking.php page <form action="update-admin-repair-tracking.php" method="post"> Repair ID: <input value="<?= $_GET['id'] ?>" name="id"/> Customer Name: <input type="text" name="customer_name" value="<?= $_GET['customer_name'] ?>"> Customer Email: <input type="text" name="customer_email" value="<?= $_GET['customer_email'] ?>"> Customer Phone: <input type="text" name="customer_phone" value="<?= $_GET['customer_phone'] ?>"> Computer Make: <input type="text" name="computer_make" value="<?= $_GET['computer_make'] ?>"> Computer Model: <input type="text" name="computer_model" value="<?= $_GET['computer_model'] ?>"> Technician: <select name="technician" id="technician"> <option value="Not Assigned">Not Assigned</option> <option value="Phil Roskams">Phil Roskams</option> <option value="Ian Haney">Ian Haney</option> </select> Status: <select name="status" id="status"> <option value="Not Started">Not Started</option> <option value="In Queue">In Queue</option> <option value="On Bench / Working">On Bench / Working</option> <option value="Awaiting Parts">Awaiting Parts</option> <option value="Awaiting Customer">Awaiting Customer</option> <option value="Completed">Completed</option> </select> Expected Repair Date: <input type="date" name="exrdate" value="<?= $_GET['exrdate'] ?>"> Expected Repair Time: <input type="time" name="exrtime" value="<?= $_GET['exrtime'] ?>"> Expected Start Date<input type="date" name="exstdate" value="<?= $_GET['exstdate'] ?>"> Expected Start Time: <input type="time" name="exstime" value="<?= $_GET['exstime'] ?>"> Delivery Type: <select name="deltype" id="deltype"> <option value="Self Pickup">Self Pickup</option> <option value="Deliver to Customer">Delivery to Customer</option> </select> Comments: <br> <textarea name="comments" cols="50" rows="3" id="comments"><?= $_GET['comments'] ?></textarea> <input type="submit" name="submit"> </form> </body> </html> Can someone help me please as been trying to work out what I am missing for a good hour now Thank you in advance would the issue be with this page or the view tracking php page where the records are displayed?
  14. So sorry it is my fault, I am so stupid, there was no data for id 17 but was sure there was, so sorry, let me just slap myself, so sorry
  15. Very strange isn't it I altered the coding to what you provided and now outputs the following id 17 name email phone SELECT id, customer_name, customer_email, customer_phone FROM repairs ORDER BY id DESC LIMIT 1 is very weird that it outputs the id number but not the customer name, email and phone
  16. Thank you for the reply, appreciate it Below is the code with the LIMIT in the query <?php $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //run the query $sql = "SELECT id, customer_name, customer_email, customer_phone FROM repairs ORDER BY id DESC LIMIT 1"; $result = $conn->query($sql); if ($result->num_rows > 0) { //fetch the results while($row = $result->fetch_assoc()) { echo $row['id'] . " " . $row['customer_name'] . " " . $row['customer_email'] . " " . $row['customer_phone']; } } else { echo "0 results"; } echo $sql; $conn->close(); ?> All that code does is output the following 17 SELECT id, customer_name, customer_email, customer_phone FROM repairs ORDER BY id DESC LIMIT 1 It seems to stop at the id number and not output the name, email and phone
  17. I could not get the last repair_id outputting so am tackling this issue from another angle, I am going to do away with repair_id and just use id which is AI and primary key I am going to display the whole row instead but limit it to 1 and order by ID DESC so shows the highest id number but the issue I got is it shows all records but the second I put LIMIT 1 in it only shows the id number and no other data, am getting bit fed up with to be honest but want to get it done I have the following coding at the moment <?php $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //run the query $sql = "SELECT * FROM repairs ORDER BY id DESC"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { //fetch the results while($row = mysqli_fetch_assoc($result)) { echo $row['id'] . $row['repair_id'] . " " . $row['customer_name'] . " " . $row['customer_email'] . " " . $row['customer_phone']; } } else { echo "0 results"; } echo $sql; mysqli_close($conn); ?> This is outputting the following 17 16 15 14 13 12004 Ian Haney ianhaney@broadwaymediadesigns.co.uk 01268 92843011004 Ian Haney ianhaney@broadwaymediadesigns.co.uk 01268 92843010 9 8003 Ian Haney ianhaney@broadwaymediadesigns.co.uk 01268 9284307003 Ian Haney ianhaney@broadwaymediadesigns.co.uk 01268 9284306003 Ian Haney ianhaney@broadwaymediadesigns.co.uk 01268 9284305002 Ian Haney ianhaney@broadwaymediadesigns.co.uk 01268 9284304001 Ian Haney ianhaney@broadwaymediadesigns.co.uk 01268 9284303 2 SELECT * FROM repairs ORDER BY id DESC Please help me and see where I am going wrong with it
  18. Yeah is defiantly data in that column, I changed it to just id and that worked perfect but for some reason it don't like repair_id
  19. Sorry just a update I have the following now $sql = "SELECT repair_id FROM repairs LIMIT 1"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "Last Repair ID: " . $row["repair_id"]. "<br>"; } } else { echo "0 results"; } $conn->close(); It's just returning blank and just says Last Repair ID: I am not getting any errors as have php error reporting in
  20. Hi I have decided to build my own repair tracking system which thought would be better and also learn as well at the same time and is all working perfect I just can't seem to get the value of the last repair_id number, it is not AI or anything I have the following code $sql = "SELECT repair_id FROM repairs"; then where I want it to echo, I have the following <?php echo $repair_id; ?> I know I am missing something like return to retrieve the column value or something but not 100% Sorry
  21. The script does already check if it already exists which is good, I figured a way around it which seems to work I created a new line of code called last repair ID used and then echoed the $invid and then under that got the input field to enter the next repair ID number seems to work Just want to say thank you for all the help and replies, really do appreciate it
  22. I have now added the sql query and connection to the DB above that coding you mentioned above The invid is set up as INT(11), it is not an auto increment field I set the database up but got all the coding/script from Google from the following link https://github.com/azchrisf/StatusScript/
  23. Think I have got that right and put in, how does the field get pre filled, below is the coding I have <!doctype html> <html> <head> <meta charset="utf-8"> <title>Status System Administration</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> <script src="jquery.ui.timepicker.js"></script> <script src="repairstatus-funcs.js"></script> <link rel="stylesheet"href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css"/> <link rel="stylesheet"href="jquery.ui.timepicker.css"/> </head> <? // check php version if (strnatcmp(phpversion(),'5.2.0') >= 0) { } else { die("This script requires PHP version 5.2 or higher to run."); } if(isset($_GET['debug'])) { error_reporting(E_ALL ^ E_NOTICE); } if(isset($_GET['phpinfo'])) { phpinfo(); die; } if(isset($_POST['btnSubmit'])) { switch ($_POST['btnSubmit']) { case "Delete Invoice": delInvoice(); break; case "Add Invoice"; addInvoice(); break; case "Change Invoice"; chgInvoice(); break; case "Delete All Invoices"; delallInvoices(); break; case "Delete Range"; delrange(); break; case "Delete Date Range"; deldaterange(); break; } } ?> <!-- DIV hide/show code --> <script type="text/javascript"> $(function TimeShow () { $('#delivertype').change(function () { $('#DTTime').hide(); if (this.options[this.selectedIndex].value == 'DELIVER TO CUSTOMER') { $('#DTTime').show(); } }); }); $(function TimeShow2 () { $('#delivertype2').change(function () { $('#DTTime2').hide(); if (this.options[this.selectedIndex].value == 'DELIVER TO CUSTOMER') { $('#DTTime2').show(); } }); }); </script> <!-- Settings for Google Calendar widget --> <script type="text/javascript"> $(function() { $( "#rpdate" ).datepicker({ showButtonPanel: true, dateFormat:"dd-mm-yy", showOn:"both", buttonImage:"cal.gif" }); }); $(function() { $( "#rpdate2" ).datepicker({ showButtonPanel: true, dateFormat:"dd-mm-yy", showOn:"both", buttonImage:"cal.gif" }); }); $(function() { $( "#exdate" ).datepicker({ showButtonPanel: true, dateFormat:"dd-mm-yy", showOn:"both", buttonImage:"cal.gif" }); }); $(function() { $( "#exdate2" ).datepicker({ showButtonPanel: true, dateFormat:"dd-mm-yy", showOn:"both", buttonImage:"cal.gif" }); $(function() { $( "#range3" ).datepicker({ showButtonPanel: true, dateFormat:"dd-mm-yy", showOn:"both", buttonImage:"cal.gif" }); }); $(function() { $( "#range4" ).datepicker({ showButtonPanel: true, dateFormat:"dd-mm-yy", showOn:"both", buttonImage:"cal.gif" }); }); $(function() { $( "#invdate" ).datepicker({ showButtonPanel: true, dateFormat:"dd-mm-yy", showOn:"both", buttonImage:"cal.gif" }); }); }); </script> <!-- Settings for Tab Widget --> <script type="text/javascript"> $(function() { $( "#Tabs1" ).tabs(); }); </script> <!-- Settings for Time Picker --> <script type="text/javascript"> $(document).ready(function() { $('#rptime').timepicker({ defaultTime: '12:00', showLeadingZero: false, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', button: '.rptime_button' }); $('#extime').timepicker({ defaultTime: '12:00', showLeadingZero: false, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', button: '.extime_button' }); $('#rptime2').timepicker({ defaultTime: '12:00', showLeadingZero: false, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', button: '.rptime2_button' }); $('#extime2').timepicker({ defaultTime: '12:00', showLeadingZero: false, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', button: '.extime2_button' }); $('#delivertime').timepicker({ defaultTime: '12:00', showLeadingZero: false, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', button: '.delivertime_button' }); $('#delivertime2').timepicker({ defaultTime: '12:00', showLeadingZero: false, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', button: '.delivertime2_button' }); }); </script> <!-- Script for Tooltips --> <script type="text/javascript"> $(function() { $( document ).tooltip(); }); </script> <body> <? 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></center>"; echo "</div>"; } } ?> <h1><center><strong><font face="Tahoma, Verdana, Arial, Helvetica, sans-serif">Repair Status Administration</font></strong></center></h1> <div id="Tabs1"> <ul> <li><a href="#tabs-1">Add Invoice</a></li> <li><a href="#tabs-2">Edit Invoice</a></li> <li><a href="#tabs-3">Delete Invoice</a></li> <li><a href="#tabs-4">Mass Actions</a></li> <li><a href="#tabs-5">About...</a></li> </ul> <div id="tabs-1"> <form id="add" name="add" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <p> <label for="textfield">Repair ID Number:</label> <input name="invid" type="text" id="invid" size="3" onKeyDown="limitText(this.form.invid,this.form.countdown,3);" onKeyUp="limitText(this.form.invid,this.form.countdown,3);"; /> </p> <? require "repairadmin-config.php"; if($allowdatechange == 1) { echo "<p>"; echo "<label for=\"textfield\">Date Created:</label>"; echo "<input name=\"invdate\" type=\"text\" id=\"invdate\" size=\"10\" value=\"". DATE('d-m-Y'). "\"". "/ >"; echo "</p>"; } require("repairstatus-config.php"); if($enablesecurity == 1) { echo "<p>"; echo "<label for=\"pincode\">4 Digit PIN Code <b>(REQUIRED)</b>:</label>"; echo "<input type=\"text\" size=\"4\" name=\"pincode\" id=\"pincode\" title=\"Numbers only\" onKeyDown=\"limitText(this.form.pincode,this.form.countdown,4);\" onKeyUp=\"limitText(this.form.pincode,this.form.countdown,4);\"; />"; echo "</p>"; } ?> <p> <label for="customer_name">Customer Name</label> <input name="customer_name" type="text" id="customer_name"> </p> <p> <label for="customer_email">Customer Email</label> <input name="customer_email" type="email" id="customer_email" size="40"> </p> <p> <label for="customer_phone">Customer Phone Number</label> <input name="customer_phone" type="tel" id="customer_phone"> </p> <p> <label for="textfield">Assigned to Tech:</label> <? require "repairadmin-config.php"; echo "<select name=\"tech\">"; foreach($techslist as $item){ echo "<option value='". $item . "'>". $item ."</option>"; } echo "</select>"; ?> </p> <p> <label for="select">Status:</label> <? require "repairadmin-config.php"; echo "<select name=\"status\">"; foreach($statustypes as $item){ echo "<option value='". $item . "'>". $item ."</option>"; } echo "</select>"; ?> </p> <p> <label for="rpdate">Expected Repair Date:</label> <input type="text" name="rpdate" id="rpdate"> </p> <p> <label for="rptime">Expected Repair Time:</label> <input name="rptime" type="time" id="rptime" style="width: 70px;" title="Must be in 24 hour format - example: 23:30"> <input type="button" class="rptime_button" value="..." title="Must be in 24 hour format - example: 23:30"> </p> <p> <label for="exdate">Expected Start Date </label> <label for="exdate"> (applicable if In Queue or Delayed):</label> <input type="text" name="exdate" id="exdate" > </p> <p> <label for="extime">Expected Start Time (applicable if In Queue or Delayed):</label> <input name="extime" type="extime" id="extime" title="Must be in 24 hour format - example: 23:30"> <input type="button" class="extime_button" value="..." title="Must be in 24 hour format - example: 23:30"> </p> <p> <label for="deliverytype">Delivery Type:</label> <select name="delivertype" id="delivertype" onChange="TimeShow();"> <? require "repairadmin-config.php"; foreach($delivertypes as $item){ echo "<option value='". $item . "'>". $item ."</option>"; } ?> </select> </p> <div id="DTTime" style="display:none"> <p> <label for="delivertime">Estimated Delivery Time:</label> <input name="delivertime" type="text" id="delivertime" title="Must be in 24 hour format - example: 23:30" > <input type="button" class="delivertime_button" value="..." title="Must be in 24 hour format - example: 23:30"> </p> </div> <p> <label for="comments">Comments:</label> <br> <textarea name="comments" cols="50" rows="3" id="comments"></textarea> </p> <input type="submit" name="btnSubmit" id="btnSubmit" value="Add Invoice"> </form> </div> <div id="tabs-2"> <p><b>NOTE: Leave field(s) blank to preserve existing data</b></p> <form id="change" name="change" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <p> Repair ID Number: <? // Create connection require "repairadmin-config.php"; $cn=mysqli_connect($servername, $username, $password, $dbname) or die($cn->connect_error); $sql = "SELECT invid, datecreated FROM repairs"; $rs = $cn->query($sql) or die(mysqli_error($cn)); echo "<select name=\"invid2\">"; while($row = mysqli_fetch_array($rs)){ echo "<option value='".$row["invid"]."'>".$row["invid"]. " (Created on ".$row['datecreated'].")</option>"; } $rs->free_result(); $rs->close(); echo "</select>"; ?> </p> <? require("repairstatus-config.php"); if($enablesecurity == 1) { echo "<p>"; echo "<label for=\"pincode2\">4 Digit PIN Code <b>(Leave blank for no change)</b>:</label>"; echo "<input type=\"text\" size=\"4\" name=\"pincode2\" id=\"pincode2\" >"; echo "</p>"; } ?> <p> <label for="customer_name">Customer Name</label> <input name="customer_name" type="text" id="customer_name"> </p> <p> <label for="customer_email">Customer Email</label> <input name="customer_email" type="email" id="customer_email" size="40"> </p> <p> <label for="customer_phone">Customer Phone Number</label> <input name="customer_phone" type="tel" id="customer_phone"> </p> <p> <label for="textfield">Assigned to Tech:</label> <? // Create connection require "repairadmin-config.php"; echo "<select name=\"tech2\">"; echo "<option value=\"\"></option>"; foreach($techslist as $item){ echo "<option value='". $item . "'>". $item ."</option>"; } echo "</select>"; ?> </p> <p> <label for="status2">Status:</label> <? require "repairadmin-config.php"; echo "<select name=\"status2\">"; echo "<option value=\"\"></option>"; foreach($statustypes as $item){ echo "<option value='". $item . "'>". $item ."</option>"; } echo "</select>"; ?> </p> <p> <label for="datetime">Expected Repair Date:</label> <input type="text" name="rpdate2" id="rpdate2"> </p> <p> <label for="time">Expected Repair Time:</label> <input type="time" name="rptime2" id="rptime2" title="Must be in 24-hour format - example: 23:30"> <input type="button" class="rptime2_button" value="..." title="Must be in 24-hour format - example: 23:30"> </p> <p> <label for="datetime2">Expected Start Date </label> <label for="time6"> (applicable if In Queue or Delayed):</label> <input type="text" name="exdate2" id="exdate2"> </p> <p> <label for="time2">Expected Start Time </label> <label for="time7"> (applicable if In Queue or Delayed):</label> <input type="time" name="extime2" id="extime2" title="Must be in 24-hour format - example: 23:30"> <input type="button" class="extime2_button" value="..." title="Must be in 24-hour format - example: 23:30"> </p> <p> <label for="delivertype2">Delivery Type:</label> <select name="delivertype2" id="delivertype2" onChange="TimeShow2();"> <? require "repairadmin-config.php"; echo "<option value=\"\"></option>"; foreach($delivertypes as $item){ echo "<option value='". $item . "'>". $item ."</option>"; } ?> </select> </p> <div id="DTTime2" style="display:none"> <p> <label for="delivertime">Estimated Delivery Time:</label> <input type="text" name="delivertime2" id="delivertime2" title="Must be in 24 hour format - example: 23:30" > <input type="button" class="delivertime2_button" value="..." title="Must be in 24 hour format - example: 23:30"> </p> </div> <p> <label for="comments2">Comments:</label> <textarea name="comments2" cols="50" rows="3" id="comments2"></textarea> </p> <p> <input type="submit" name="btnSubmit" id="btnSubmit" value="Change Invoice"> </p> </form> </div> <div id="tabs-3"> <form id="delete" name="delete" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <p> <label for="textfield">Invoice ID: </label> <? // Create connection require "repairadmin-config.php"; $cn=mysqli_connect($servername, $username, $password, $dbname) or die($cn->connect_error); $sql = "SELECT MAX(invid) as last_inserted FROM repairs"; $data = mysqli_fetch_row($query); $last_inserted = $data["last_inserted"]; $invid = $last_inserted + 1; $rs = $cn->query($sql) or die(mysqli_error($cn)); echo "<select name=\"inviddel\">"; while($row = mysqli_fetch_array($rs)){ echo "<option value='".$row["invid"]."'>".$row["invid"]."</option>"; } $rs->free_result(); $rs->close(); echo "</select>"; ?> </p> <p> <input type="submit" name="btnSubmit" id="btnSubmit" value="Delete Invoice"> </p> </form> </div> <div id="tabs-4"> <p><strong>Database Administration</strong></p> <form id="dbadmin" name="dbadmin" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <p>Purge Invoice Numbers in Range: <input name="range1" type="text" id="range1" size="5"> to <input name="range2" type="text" id="range2" size="5"> <br> <input name="btnSubmit" type="submit" id="btnSubmit" value="Delete Range"> </p> <p>Purge Invoice Numbers in Date Range: <input name="range3" type="text" id="range3" size="10"> to <input type="text" name="range4" id="range4" size="10"> <br> <input name="btnSubmit" type="submit" id="btnSubmit" value="Delete Date Range"> </p> <p> <strong><font color="red">WARNING: This action will delete ALL Invoices in the Database. Once you click the button, you cannot recover the Invoices.</font></strong><br> <input name="btnSubmit" type="submit" id="btnSubmit" title="WARNING: WILL DELETE ALL INVOICES!" value="Delete All Invoices"> </p> </form> </div> <!--<div id="tabs-5"> <center> <p><b>Repair Status Script for PC Repair Shops Version 1.5 (branch-1.5_gold) </b></p> <p>Copyright © 2014, Chris Formeister. All Rights Reserved. </p> <p>Download latest version from <a href="https://github.com/azchrisf/StatusScript/">https://github.com/azchrisf/StatusScript/</a></p> <p>Post bugs and questions to GitHub</p> <p>Email the author at <a href="mailto:azchrisf@gmail.com">azchrisf@gmail.com</a></p> <p><strong>CREDITS:</strong></p> <p>Thanks to Eduardo Mendez for additional code<br> </p> <p>Uses JQuery UI Time Picker, © François Gélinas.<br> Licensed & Distributed under MIT/GPL License </p> </center> </div>--> </div> </body> </html> <?php function addInvoice() { require "repairadmin-config.php"; if(empty($invid)) { echo "<b><font color=\"red\">You must enter a Invoice ID to add!</b></font><hr>"; return; } if (!is_numeric($invid)) { echo "<b><font color=\"red\">The Invoice ID must be numeric only!</b></font><hr>"; return; } if (strlen($invid) < 3) { echo(strlen($invid)); echo "<b><font color=\"red\">The Invoice ID must be 5 digits!</b></font><hr>"; return; } require "repairstatus-config.php"; if($enablesecurity == 1) { if(empty($pincode)) { echo "<b><font color=\"red\">You must enter a PIN ID to add!</b></font><hr>"; return; } if (!is_numeric($pincode)) { echo "<b><font color=\"red\">The PIN ID must be numeric only!</b></font><hr>"; return; } if (strlen($pincode) < 4) { echo "<b><font color=\"red\">The PIN ID must be 5 digits!</b></font><hr>"; return; } } $cn=mysqli_connect($servername, $username, $password, $dbname) or die($cn->connect_error); $sql = "SELECT invid FROM repairs"; $rs = $cn->query($sql) or die(mysqli_error($cn)); while($row = mysqli_fetch_array($rs)){ if ($row[invid] == $invid) { echo "<b><font color=\"red\">Invoice ID already exists - choose a new ID!</b></font><hr>"; return; } } $cn->close(); // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("<b><font color=\"red\">Connection failed: " . $conn->connect_error . "</b></font><hr>"); } // sql to add a record if($allowdatechange == 1) { $datecreated = $invdate; } else { $datecreated = DATE('d-m-Y'); } $sql = "INSERT INTO repairs (invid, customer_name, customer_email, customer_phone, status, tech, rpdate, rptime, exdate, extime, comments, delivertype, delivertime, pincode, datecreated) VALUES ('$invid', '$customer_name', '$customer_email', '$customer_phone', '$status', '$tech', '$rpdate', '$rptime', '$exdate', '$extime', '$comments', '$delivertype', '$delivertime', '$pincode', '$datecreated')"; if ($conn->query($sql) === TRUE) { echo "<b><font color=\"green\">Invoice added successfully!</b></font><hr>"; } else { echo "<b><font color=\"red\">Error adding Invoice: " . $conn->error . "</b></font><hr>"; } $conn->close(); } function chgInvoice() { require "repairadmin-config.php"; if(empty($invid2)) { echo "<b><font color=\"red\">You must select a non-empty Invoice ID to change!</b></font><hr>"; return; } // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("<b><font color=\"red\">Connection failed: " . $conn->connect_error . "</b></font><hr>"); } // sql to change a record if(!empty($invid2)){ if(!empty($status2)){ $update_fields[] = "status='$status2'"; } if(!empty($customer_name)){ $update_fields[] = "customer_name='$customer_name'"; } if(!empty($customer_email)){ $update_fields[] = "customer_email='$customer_email'"; } if(!empty($customer_phone)){ $update_fields[] = "customer_phone='$customer_phone'"; } if(!empty($tech2)){ $update_fields[] = "tech='$tech2'"; } if(!empty($rpdate2)){ $update_fields[] = "rpdate='$rpdate2'"; } if(!empty($rptime2)){ $update_fields[] = "rptime='$rptime2'"; } if(!empty($exdate2)){ $update_fields[] = "exdate='$exdate2'"; } if(!empty($extime2)){ $update_fields[] = "extime='$extime2'"; } if(!empty($comments2)){ $update_fields[] = "comments='$comments2'"; } if(!empty($delivertype2)){ $update_fields[] = "delivertype='$delivertype2'"; } if(!empty($delivertime2)){ $update_fields[] = "delivertime='$delivertime2'"; } if(!empty($pincode2)){ $update_fields[] = "pincode='$pincode2'"; } if(count($update_fields) > 0){ $nonempty_fields = implode(", ", $update_fields); $sql = "UPDATE repairs SET $nonempty_fields WHERE invid='$invid2'"; } else{ echo "<b><font color=\"red\">Cannot update the Invoice because all fields are empty!</b></font><hr>"; return; } } if ($conn->query($sql) === TRUE) { echo "<b><font color=\"green\">Invoice changed successfully</b></font><hr>"; } else { echo "<b><font color=\"red\">Error changing Invoice: " . $conn->error . "</b></font><hr>"; } $conn->close(); } function delInvoice() { require "repairadmin-config.php"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("<b><font color=\"red\">Connection failed: " . mysqli_connect_error(). "</b></font><hr>"); } // sql to delete a record $sql = "DELETE FROM repairs WHERE invid = '$inviddel'"; if (mysqli_query($conn, $sql)) { echo "<b><font color=\"green\">Invoice deleted successfully</b></font><hr>"; } else { echo "<b><font color=\"red\">Error deleting Invoice: " . mysqli_error($conn) . "</b></font><hr>"; } $conn->close(); } function delallInvoices() { require "repairadmin-config.php"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("<b><font color=\"red\">Connection failed: " . mysqli_connect_error(). "</b></font><hr>"); } // sql to delete a record $sql = "TRUNCATE TABLE repairs"; if (mysqli_query($conn, $sql)) { echo "<b><font color=\"green\">All Records deleted successfully</b></font><hr>"; } else { echo "<b><font color=\"red\">Error deleting all records: " . mysqli_error($conn) . "</b></font><hr>"; } $conn->close(); } function delrange() { require "repairadmin-config.php"; if(empty($range1)) { echo "<b><font color=\"red\">You must enter a starting Invoice range</b></font><hr>"; return; } if(empty($range2)) { echo "<b><font color=\"red\">You must enter a ending Invoice range</b></font><hr>"; return; } // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("<b><font color=\"red\">Connection failed: " . mysqli_connect_error(). "</b></font><hr>"); } // sql to delete a record $sql = "DELETE FROM repairs WHERE invid BETWEEN ". $range1 ." AND ". $range2; if (mysqli_query($conn, $sql)) { echo "<b><font color=\"green\">Selected Range deleted successfully</b></font><hr>"; } else { echo "<b><font color=\"red\">Error deleting record range: " . mysqli_error($conn) . "</b></font><hr>"; } $conn->close(); } function deldaterange() { require "repairadmin-config.php"; if(empty($range3)) { echo "<b><font color=\"red\">You must enter a starting date range</b></font><hr>"; return; } if(empty($range4)) { echo "<b><font color=\"red\">You must enter a ending date range</b></font><hr>"; return; } // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("<b><font color=\"red\">Connection failed: " . mysqli_connect_error(). "</b></font><hr>"); } // sql to delete a record $sql = "DELETE FROM repairs WHERE datecreated BETWEEN '". $range3 ."' AND '". $range4 . "'"; if (mysqli_query($conn, $sql)) { echo "<b><font color=\"green\">Selected Range deleted successfully</b></font><hr>"; } else { echo "<b><font color=\"red\">Error deleting record date range: " . mysqli_error($conn) . "</b></font><hr>"; } $conn->close(); } ?>
  24. I have got the column invid column created so I just need bit of php to add +1 to the invid column each time just unsure how to pre fill the repair number from the database
×
×
  • 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.