time Problem
Moderator: General Moderators
time Problem
hi,
i used 2 time fields name von and bis when i submit the form i get time like this according to system time let say
Datum Von Bis Save --on click submit in same form
Th 17.07.03 10:59 10:59---new time i get once form submits
Th 17.07.03 10:59 23:40
if you see the above result its wrong for Von time fiels as it shows .is it possible to get Bis time in Von field when form submits and get new field
<td >
<input size="7" type="text" name="datum" value="<?=$D?> <?= date("d.m.y") ?>">
</td>
<td>
<select name="von">
<option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>// due to this echo function i get system time is it possible to get selected time from bis in new field of von
<? fillDD(0, 0, -1); ?>
</select>
</td>
<td>
<select name="bis" onchange="calculateIst()">
<option value="<?=date('H:i')?>"><? echo (date('H:i'));> </option>
<? fillDD(0, 0, -1); ?>
</select>
</td>
<td>
<input type="submit" value="S" name="Save" border="1" >
</td>
</tr>
still any problem to understood http://server2.vitodesign.com/scripts/diff.phtml
or any other way of script will welcome
if anybody sort out this problem will be appreciable
thanks
i used 2 time fields name von and bis when i submit the form i get time like this according to system time let say
Datum Von Bis Save --on click submit in same form
Th 17.07.03 10:59 10:59---new time i get once form submits
Th 17.07.03 10:59 23:40
if you see the above result its wrong for Von time fiels as it shows .is it possible to get Bis time in Von field when form submits and get new field
<td >
<input size="7" type="text" name="datum" value="<?=$D?> <?= date("d.m.y") ?>">
</td>
<td>
<select name="von">
<option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>// due to this echo function i get system time is it possible to get selected time from bis in new field of von
<? fillDD(0, 0, -1); ?>
</select>
</td>
<td>
<select name="bis" onchange="calculateIst()">
<option value="<?=date('H:i')?>"><? echo (date('H:i'));> </option>
<? fillDD(0, 0, -1); ?>
</select>
</td>
<td>
<input type="submit" value="S" name="Save" border="1" >
</td>
</tr>
still any problem to understood http://server2.vitodesign.com/scripts/diff.phtml
or any other way of script will welcome
if anybody sort out this problem will be appreciable
thanks
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
Here: http://www.pscript.de/forum/showboard.php?id=11 is a nice german php board, might be interesting for you ...
concerning your question, i don't really understand what you want ...
either explain it a bit better or post it in the other forum with all of your code (please use code tags), then I'll see you there ... ;o)
concerning your question, i don't really understand what you want ...
either explain it a bit better or post it in the other forum with all of your code (please use code tags), then I'll see you there ... ;o)
how i can get time which i selected from bis field on von field on the very next time when i clcik on save button
for eg
Von Bis
12:20 23:40 u can see from the url which i already posted
if u clearly notice this link u will see the new line VOn showing time 13:03
instead of 23:40 as i used echo (date('H:i')) thats why im getting always system time
thats why i asked any modification in php so that i can ge something like
13:25 15
23:40 13:25
12:20 23:40
hope this is clear for u[/url]
for eg
Von Bis
12:20 23:40 u can see from the url which i already posted
if u clearly notice this link u will see the new line VOn showing time 13:03
instead of 23:40 as i used echo (date('H:i')) thats why im getting always system time
thats why i asked any modification in php so that i can ge something like
13:25 15
23:40 13:25
12:20 23:40
hope this is clear for u[/url]
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
okay i think i got it, you need to print <option selected ... after the form is submittet where $_POST['bis_datum']==$(the value "fillDD(0, 0, -1);" prints)
so this comparison must take place in the function fillDD(). If $_POST['bis_datum'] is not set (first call of the script), then print this line before calling the function: <option value="<?=date('H:i')?>"><? echo (date('H:i'));> </option>
so this comparison must take place in the function fillDD(). If $_POST['bis_datum'] is not set (first call of the script), then print this line before calling the function: <option value="<?=date('H:i')?>"><? echo (date('H:i'));> </option>
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
Code: Select all
<?
include("../settings.php");
/* Connecting, selecting database */
$link = mysql_connect("$dbhost", "$dbuser", "$dbpw")
or die("Could not connect");
mysql_select_db("$dbuser") or die("Could not select database");
$query = "SELECT kunde,projektnr from emp_kunde";
$result = mysql_query($query) or die("Query failed: $query");
$kunden = array();
$projekt = array();
while ($row = mysql_fetch_assoc($result))
{
array_push($kunden, $rowї"kunde"]);
array_push($projekt, $rowї"projektnr"]);
}
$query = "SELECT hvorgang,uvorgang,status,soll from emp_details ";
$result = mysql_query($query) or die("Query failed: $query");
$getrow= mysql_fetch_array($result);
$hvorgang = array();
$uvorgang = array();
$status = array();
while ($row = mysql_fetch_assoc($result))
{
array_push($hvorgang, $rowї"hvorgang"]);
array_push($uvorgang, $rowї"uvorgang"]);
array_push($status, $rowї"status"]);
}
$kunden = array_unique($kunden);
$hprojekt = array_unique($projekt);
$haupt = array_unique($hvorgang);
$unter = array_unique($uvorgang);
$hstatus = array_unique($status);
if (isset($HTTP_POST_VARSї"datum"]))
{
$nr = $HTTP_POST_VARSї"nr"];
$datum = $HTTP_POST_VARSї"datum"];
$von = $HTTP_POST_VARSї"von"];
$bis = $HTTP_POST_VARSї"bis"];
$kunde = $HTTP_POST_VARSї"kunde"];
$projekt = $HTTP_POST_VARSї"projekt"];
$hVorgang = $HTTP_POST_VARSї"hvorgang"];
$uVorgang = $HTTP_POST_VARSї"uvorgang"];
$text = $HTTP_POST_VARSї"text"];
$ist = $HTTP_POST_VARSї"ist"];
$soll = $HTTP_POST_VARSї"soll"];
$status = $HTTP_POST_VARSї"status"];
$query = "INSERT INTO t_emp";
$query.="(nr,datum,von,bis,kunde,projekt,hvorgang,uvorgang,text,ist,soll,status) values ";
$query.="('$nr','$datum','$von','$bis','$kunde','$projekt','$hVorgang','$uVorgang','$text','$ist','$soll','$status')";
mysql_query($query) or die("Query failed: Insert new row");
$updatePK = "UPDATE key_generator set id = $nr where name = 't_emp'";
mysql_query($updatePK) or die("Query failed: Update field 'nr' (PK)");
}
/// this is the place to get soll value but problem is nr. filed always incremented by 2
$query = "SELECT * FROM t_emp order by nr DESC";
$result = mysql_query($query) or die("Query failed: Fetch all rows");
$query = "SELECT id from key_generator where name = 't_emp'";
$pkResult = mysql_query($query) or die("Query failed: Get last Id");
$row = mysql_fetch_assoc($pkResult);
$pk = $rowїid];
$pk++;
function fillDD($min, $max, $selected)
{
for($i=$min; $i<24; $i++) {
//$i = sprintf('%02d', $i); # set $i to be padded with a 0's up to 2 characters
for($j=$max; $j<60; $j+=5) {
$j = sprintf('%02d', $j); # set $j to be padded with a 0's up to 2 characters
if($i == $selected && $j == $selected) {
print("<option SELECTED value='$i:$j'>$i:$j</option>\n");
}
else {
print("<option value='$i:$j'>$i:$j</option>\n");
}
}//for($j)
} //for($i)
}
$arrDay = array ("So", "Mo", "Di", "Mi", "Do", "Fr","Sa");
$D=$arrDayїdate(w)];
?>
<html>
<head>
<title>Log-Zeiterfassung</title>
<link rel="stylesheet" type="text/css" href="../styles/styles.css" />
<script language="JavaScript" src="date-picker.js"></script>
<SCRIPT LANGUAGE="JavaScript" src="log.js"></script>
<SCRIPT language="JavaScript">
function calculateIst()
{
var time =document.formsї"tstest"].elementsї"von"].value.split(":");
vontime=parseInt(timeї0]*60)+parseInt(timeї1]);
var time1 =document.formsї"tstest"].elementsї"bis"].value.split(":");
bistime=parseInt(time1ї0]*60) +parseInt(time1ї1])
diff=(bistime-vontime)
if(diff<0){
alert("assure that bis is greater than von")
return false
}
min=(diff%60)
hrs=(diff-min)/60
if (hrs<=9)
hrs="0"+hrs
if(min<=9)
min="0"+min
document.formsї"tstest"].elementsї"ist"].value =hrs + ":" + min;
}
</script>
</head>
<form name="tstest" action="log.phtml" method="post">
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="mybar" onload="createArray()">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 width=100% name="rsTable" id=rsTable cols=12>
<tr bgcolor="#cccccc">
<!--<th> </th> -->
<!--<th nowrap>Nr.</th>-->
<th nowrap>Datum</th>
<th nowrap>Von</th>
<th nowrap>Bis</th>
<th nowrap>Kunde</th>
<th nowrap>Projekt</th>
<th nowrap>H-Vorgang</th>
<th nowrap>U-Vorgang</th>
<th nowrap>Text</th>
<th nowrap>IST</th>
<th nowrap>Soll</th>
<th nowrap>Status</th>
<th nowrap> </th>
</tr>
<? if (!isset($HTTP_POST_VARSї"Save"])) { ?>
<tr>
<!--<td><a href="edit.phtml"><img src="../img/edit.gif" border="1"></a></td> -->
<input size="1" type="hidden" name="nr" value="<?= $pk ?>">
<td nowrap align="center">
<input size="7" type="text" name="datum" value="<?=$D?> <?= date("d.m.y") ?>">
<a href="javascript:show_calendar('tstest.datum');"><img src="../img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
</td>
<td nowrap align="center">
<select name="von">
<option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>
<? fillDD(0, 0, -1); ?>
</select>
</td>
<td nowrap align="center">
<!--<input type="text" size="1" class="button" name="clock">-->
<select name="bis" onchange="calculateIst()">
<option value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>
<? fillDD(0, 0, -1); ?>
</select>
<input type="button" name="now" size="1" value=">" onclick="insertTime();calculateIst()">
</td>
<td nowrap align="center">
<select name="kunde" onchange="redirect(this.options.selectedIndex)">
<? foreach($kunden as $value) { ?>
<option value="<?= $value ?>"><?= $value ?></option>
<? } ?>
</select>
</td>
<td nowrap align="center">
<select name="projekt">
<? foreach($hprojekt as $value) { ?>
<option value="<?= $value ?>"><?= $value ?></option>
<? } ?>
</select>
</td>
<td nowrap align="center">
<select name="hvorgang" onchange="redirect1(this.options.selectedIndex)">
<? foreach($haupt as $value) { ?>
<option value="<?= $value ?>"><?= $value ?></option>
<? } ?>
</select>
</td>
<td nowrap align="center">
<select name="uvorgang">
<? foreach($unter as $value) { ?>
<option value="<?= $value ?>"><?= $value ?></option>
<? } ?>
</select>
</td>
<td nowrap align="center">
<textarea name="text" class="mybar" id="tar" cols="15" rows="1" onfocus="tarea();" onblur="tarea();" title=""></textarea>
<input type="hidden" size="1" name="remLen" value="20">
<img src="../img/edit.gif" onclick="window.open('thewindow.html','newWin','width=150,height=130,top=525,left=800,dependent=yes,alwaysRaised=yes,resizable=1')" width="16" height="16" border="0" alt="Edit Text"></a>
</td>
<td bgcolor="#cccccc" align="center"><input size="1" type="text" value="00:00" name="ist" readonly></td>
<td bgcolor="#cccccc" align="center"><input size="1" type="text" name="soll" value="<?= $getrowї"soll"] ?>" readonly></td>
<td nowrap align="center">
<select name="status">
<? foreach($hstatus as $value) { ?>
<option selected value="<?= $value ?>"><?= $value ?></option>
<? } ?>
</select>
</td>
<td nowrap align="center">
<input type="button" value="S" name="Save" border="1" onclick="go();">
</td>
</tr>
<? } ?>
<? while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
<!--<? $date = explode(' ', $lineї"datum"]); ?>-->
<tr bgcolor="#FACB84">
<!--<td> </td>-->
<!-- <td><?= $lineї"nr"] ?></td> -->
<td nowrap align="center"><?= $lineї"datum"] ?></td>
<td nowrap align="center"><?= $lineї"von"] ?></td>
<td nowrap align="center"><?= $lineї"bis"] ?></td>
<td nowrap align="center"><?= $lineї"kunde"] ?></td>
<td nowrap align="center"><?= $lineї"projekt"] ?></td>
<td nowrap align="center"><?= $lineї"hvorgang"] ?></td>
<td nowrap align="center"><?= $lineї"uvorgang"] ?></td>
<td nowrap align="center"><?= $lineї"text"] ?></td>
<td nowrap align="center"><?= $lineї"ist"] ?></td>
<td nowrap align="center"><?= $lineї"soll"] ?></td>
<td nowrap align="center"><?= $lineї"status"] ?></td>
</tr>
<? } ?>
</table>
<!--<table border=0 cellpadding=2 cellspacing=0>
<tr><td align=center valign=bottom colspan=2>
<!--<input type="button" class="button" value="Close" name="Close" border="1" onClick="window.close();"> -->
<!--<input type="reset" class="button" value="Reset" name="Reset" border="1" onclick="tstest.reset();return false;"> -->
<!--<input type="button" class="button" value="Print" name="Print" border="1" onClick="window.print();"></td></tr>
</table> -->
</body>
<script language="javascript" src="triplecombo.js"></script>
</form>
<script language="JavaScript">
function go(){
var myindex=document.formsї"tstest"].bis.selectedIndex;
if (myindex==0) {
alert("\nPlease be sure that time from bis drop-down menu is selected.");
}
else {
document.tstest.submit(); }
}//submit go()
var times = new Array ();
function createArray() {
for (i=0; i<document.tstest.bis.length; i++) {
timesїtimes.length] = new Option(document.tstest.bisїi].value, document.tstest.bisїi].value);
}
}
var x = 0;
function insertTime() {
time = new Date();
hour = time.getHours();
minute = time.getMinutes();
hour = time.getHours().toString().length < 2 ? "0"+hour : hour;
minute = minute.toString().length < 2 ? "0"+minute : minute;
if (x==1) {
document.tstest.bis.optionsїdocument.tstest.bis.length-1] = null;
}
var anOption = new Option(hour+":"+minute, hour+":"+minute);
document.tstest.bis.optionsїdocument.tstest.bis.options.length] = anOption
x = 1;
document.tstest.bis.options.selectedIndex = document.tstest.bis.options.length-1;
}
function tarea()
{
if(document.getElementById)
{
if(document.getElementById("tar").rows == 5)
{
document.getElementById("tar").rows = 1
a = document.getElementById("tar").value
//a = a.substring(10)
if(a)
{
document.getElementById("tar").title = a
}
else
{
document.getElementById("tar").title = ''
}
}
else
{
document.getElementById("tar").rows = 5
document.getElementById("tar").title = ''
}
}
}
</script>
</html>
<?
mysql_free_result($result);
mysql_close($link);
?>-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
okay, when calling the function to fill up the from-elements, just type this:
if ($_POST['bis_datum']!="") {
fillDD(0, 0, $_POST['bis-datum']);
} else {
<option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>// due to this echo function i get system time is it possible to get selected time from bis in new field of von
<? fillDD(0, 0, -1); ?>
}
if ($_POST['bis_datum']!="") {
fillDD(0, 0, $_POST['bis-datum']);
} else {
<option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>// due to this echo function i get system time is it possible to get selected time from bis in new field of von
<? fillDD(0, 0, -1); ?>
}
sorry its still not working----but below code works 
<td nowrap align="center">
<select name="von">
<? fillDD(0, 0, $bis); ?>
</select>
</td>
function fillDD($min, $max, $selected)
{
$sel_bits = explode(":", $selected);
for($i=$min; $i<24; $i++) {
for($j=$max; $j<60; $j+=5) {
$j = sprintf('%02d', $j);
if($i == $sel_bits[0] && $j == $sel_bits[1]) {
print("<option SELECTED value='$i:$j'>$i:$j</option>\n");
}
else {
print("<option value='$i:$j'>$i:$j</option>\n");
}
}//for($j)
} //for($i)
}
when i use this piece of code then it works fine let say when select time from Von field Bis
12:55 23:55
10:05 12:55
it works fine but when i login every time instead of getting Von time as 23:55 i get 0:00
but if wont login or refresh then it works smoothely
hope u will figure it out what the falw in this code and where shall i have to put----
thanks in advance
<td nowrap align="center">
<select name="von">
<? fillDD(0, 0, $bis); ?>
</select>
</td>
function fillDD($min, $max, $selected)
{
$sel_bits = explode(":", $selected);
for($i=$min; $i<24; $i++) {
for($j=$max; $j<60; $j+=5) {
$j = sprintf('%02d', $j);
if($i == $sel_bits[0] && $j == $sel_bits[1]) {
print("<option SELECTED value='$i:$j'>$i:$j</option>\n");
}
else {
print("<option value='$i:$j'>$i:$j</option>\n");
}
}//for($j)
} //for($i)
}
when i use this piece of code then it works fine let say when select time from Von field Bis
12:55 23:55
10:05 12:55
it works fine but when i login every time instead of getting Von time as 23:55 i get 0:00
but if wont login or refresh then it works smoothely
hope u will figure it out what the falw in this code and where shall i have to put----
thanks in advance
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
<td nowrap align="center">
<select name="von">
<?if( isset($bis) ){
fillDD(0, 0, $bis);
}else{
//Lets try & select the closest time to now.
$mins = date('i');
$mins -= ($mins % 5); //subtracts the remainder when divided by 5, from the original number
fillDD(0, 0, date('H') . ":" . $mins);
} ?>
</select>
</td>
above code works fine but when i close the browser and login as second time i get von time as system time instead of 11:00 in bis field
hope it will be clear for u the result in form show like this when i login second time in same date,for more clear
sys time 10:45 instead of systime it must be 11:00 //login second time or 10:55 11:00 refresh
10:30 10:55
thanks for understanding
<select name="von">
<?if( isset($bis) ){
fillDD(0, 0, $bis);
}else{
//Lets try & select the closest time to now.
$mins = date('i');
$mins -= ($mins % 5); //subtracts the remainder when divided by 5, from the original number
fillDD(0, 0, date('H') . ":" . $mins);
} ?>
</select>
</td>
above code works fine but when i close the browser and login as second time i get von time as system time instead of 11:00 in bis field
hope it will be clear for u the result in form show like this when i login second time in same date,for more clear
sys time 10:45 instead of systime it must be 11:00 //login second time or 10:55 11:00 refresh
10:30 10:55
thanks for understanding