0

i have a form which fills a database with an issue , the issue is either 'resolved' or 'notresolved'. I have to make a counter which starts as soon as the form is submitted in the database and the issue status is 'notresolved' yet and when i resolve the issue , i can check the time taken to solve the issue.

how can i implement it ?

here is my code for the form

<html>
<head>
<title> CREATE ISSUE </title>
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}
//-->
</SCRIPT>

</head>
<body>
<br /><br /><br />
<div align="center">
<A HREF="case_id.php" onClick="return popup(this, 'notes')">CaseID Generator</A>
</div>

<div align="center">
<br /><br />

<fieldset><legend>
<h2>IT HELP DESK SYSTEM</h2></legend>
<form action="update.php" method="post">
<table border="0" cellpadding="5" cellspacing="5">
<tr>
<td>Issue : </td> 
<td><input type="text" name="issue" size="20" /></td>
</tr>
<?php date_default_timezone_set('Asia/Kolkata'); ?>
<tr>
<td>Date :</td>
<td>&nbsp;<?php echo date("d/m/y"); ?></td>
</tr>

<tr>
<td>Time :</td>
<td>&nbsp;<?php echo date("h:i:s A"); ?> </td>
</tr>

<tr>
<td>Estimated Time :</td>
<td><input type="text" name="estimate" size="20" /></td>
</tr>


<tr>
<td>Status :</td>
<td><input type="radio" name="status" value="resolved" /> Resolved</td>
<td><input type="radio" name="status" value="notresolved" /> Not Resolved</td>
</tr>

<tr id='Rstatus'>
<td>Escalated To</td>
<td><input type="text" name="escalatedto" size="20" /></td>
</tr>


<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$("input[name='status']").change(function() {
$("#Rstatus").toggle(this.value == "notresolved");
});
$("input[name='status']:checked").change();
</script>

<tr>
<td>CaseID</td>
<td><input type="text" name="caseid" size="20" /></td>
</tr>


<tr>
<td>Call Types </td>
<td><select name="types" >
<option value="">-</option>
<option value="servers">Servers</option>
<option value="desktop">Desktop</option>
<option value="peripherals" >Peripherals </option>
<option value="networking">Networking</option>
</select> 
</td>
</tr>

</table>
<br />
<div align=”center”><input type="submit" name="submit" value="LogIssue" /></div>
</fieldset>
</div>
</form>
</body>
</html>
2
  • 1
    when insert issue in db, add a starttime value in a datetime col. when you update the row with resolved add a endtime value in a second datetime col. difference of the two cols is the time needed to resolve the issue Commented Jun 14, 2011 at 13:15
  • thanks, let me try that out :) Commented Jun 14, 2011 at 13:21

2 Answers 2

1

Well, thinking fast, that is what came to my mind:

$start = date('m/d/Y', $issue['start_date']);
$end = date("m/d/Y");
$days = round((strtotime($end) - strtotime($start)) / (24 * 60 * 60), 0);

Is that what you need?

You can also do this: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_datediff on your MySQL dates, following Rufinus solution.

Sign up to request clarification or add additional context in comments.

1 Comment

actually i have to keep track of the time lapsed while the issue is still not resolved,,,,i have to impliment something like this issueburner.com
0

You can have a column of type TIMESTAMP in your database table and have its default value set as CURRENT_TIMESTAMP.

See the following thread on Stackoverflow:

How do you set a default value for a MySQL Datetime column?

You should also go through Timestamp properties in MySQL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.