Jump to content

flemingmike

Members
  • Posts

    472
  • Joined

  • Last visited

Everything posted by flemingmike

  1. im starting to think this cant be done.
  2. here it is: $result9 = mysql_query("SELECT * FROM staff ORDER BY name"); while($row9 = mysql_fetch_array($result9)) { $peid=$row9['eid']; $pname=$row9['name']; $result4 = mysql_query("SELECT * FROM schedule WHERE eid = '$peid' ORDER BY id DESC LIMIT 1"); while($row4 = mysql_fetch_array($result4)) { $sstatus=$row4['status']; if("$sstatus" == "1") { $sstatusout="<font color='#0000FF' size='4'>Waiting For Arrival</font>"; } if("$sstatus" == "2") { $sstatusout="<font color='#00FF00' size='4'>Signed In</font>"; } if("$sstatus" == "3") { $sstatusout="<font color='#FF0000' size='4'>Signed Out</font>"; } } echo "<tr>"; echo "<td align='center'>" . $pname . "</td>"; echo "<td align='center'>"; if(empty($sstatusout) ) { } else { echo "" . $sstatusout . ""; } echo "</td>"; echo "</tr>"; } echo "</table>";
  3. i am currently trying this, but no luck: echo "<td align='center'>"; if( empty($sstatus) ) { } else { echo "" . $sstatusout . ""; } echo "</td>";
  4. hello, i am having an issue with tables using incorrect data. i have 2 columns, first is employee name, second is location if the employee doesnt have a location for the current day, it is telling me he is at the same location as the guy in the row above him. i need this to be blank. is this possible?
  5. hello all, is there a way to say if there is a row that is the same as another row, delete it?
  6. hello, how would i write if $dollars is greater than 5 or less than -5? thanks!
  7. i figured it out. i just had to turn my whole page into a form.
  8. for every returned row from mysql, it produces echo "<td align='center' nowrap>" . $tmechanic . "</td>"; echo "<td align='center' nowrap>" . $tdate1 . "</td>"; echo "<td align='center' nowrap>" . $tjobnumber . "</td>"; echo "<td align='center'>" . $tdescription . "</td>"; echo "<td align='center'>" . $tsignin1 . "</td>"; echo "<td align='center'>" . $tfinish2 . "</td>"; echo "<td align='center'><input type='checkbox' name='approve[$tid]' value='ON'></td>"; and im hoping to have this on the last line: <form name="approve" method="POST" action="approve.php"> *** Find All My Checkboxes that are Checked And Submit *** <input type="submit" value="Approve" name="update"> </form>
  9. hello all, im wondering if it is possible to have multiple check boxes that get created based on the number of rows in a table (one representing each row) <input type='checkbox' name='approve[$tid]' value='ON'> and then have a submit button at the bottom of the page that will find all of the checkboxes (it could be 1, or 100) and submit it to my form handling page. thanks
  10. cool.. i had to modify slightly, but thanks for that! <?php foreach ($_POST['staff'] AS $key => $val) { echo 'Staff: '.$_POST['staff'][$key].'<br />'; echo 'Description: '.$_POST['staffd'][$key].'<br />'; } ?>
  11. if i do it this way, it gives me the wrong output <?php foreach($_POST['staff'] as $value) { foreach($_POST['staffd'] as $value1) { echo "$value - $value1<br />"; } } ?>
  12. it is displaying each result for $_POST['staff'], i just cant figure out how to get it to also give me output for $_POST['descr']
  13. hello all, i am having a for each problem. im trying to get two post fields using the foreach function. here is what i have in my form.php: <?php foreach($_POST['staff'] as $value) { echo "$value - <br />"; } ?> the name of the the fields coming in are name='staff[]' and the second one is name='descr[]' fields += 1;
  14. hello, newbie here. i am struggling with the way my table is displayed. as you can see if you goto http://durhamit.ca/citycore/2/tsreview.php and goto october 20th, Rui Zhang has 3 entries and im trying to make it display one at a time. here is my code if anyone can point me in the right direction. <?php include 'config.php'; include 'javascript.php'; $d = date("d"); $m = date("m"); $y = date("Y"); ?> <center> <form method="POST"> Month: <select size="1" name="m"> <option selected="selected" value="<?php echo $m; ?>"><?php echo $m; ?></option> <?php $mlist = range( 1,12 ); foreach ($mlist as $v ) { echo "<option value=\"$v\">$v</option>\n"; } ?> </select> Day: <select size="1" name="d"> <option selected="selected" value="<?php echo $d; ?>"><?php echo $d; ?></option> <?php $dlist = range( 1,31 ); foreach( $dlist as $v ) { echo "<option value=\"$v\">$v</option>\n"; } ?> </select> Year: <select size="1" name="y"> <option selected="selected" value="<?php echo $y; ?>"><?php echo $y; ?></option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> </select> <input type="submit" value="View" name="view"> </form> <?php if(isset($_POST['view'])) { $y3=$_POST['y']; $m3=$_POST['m']; $d3=$_POST['d']; $pdate=$y3."-".$m3. "-".$d3; $pdate1 = date( 'D M j', strtotime($pdate) ); } else { $pdate = date('Y-m-d', strtotime("-1 day") ); $pdate1 = date( 'D M j', strtotime($pdate) ); } $pdate2 = date('Y-m-d', strtotime("-1 day, $pdate") ); $y4 = date('Y', strtotime("$pdate2") ); $m4 = date('m', strtotime("$pdate2") ); $d4 = date('d', strtotime("$pdate2") ); $pdate3 = date('Y-m-d', strtotime("+1 day, $pdate") ); $y5 = date('Y', strtotime("$pdate3") ); $m5 = date('m', strtotime("$pdate3") ); $d5 = date('d', strtotime("$pdate3") ); echo "<table border='1' style='border-collapse: collapse' bordercolorlight='#000000' bordercolordark='#000000' width='98%' align='center'>"; echo "<tr>"; echo "<td width='100%' colspan='9' align='center'>"; ?> <table border='0' cellpadding='0' width='100%'> <tr> <td width='10%' align="center"> <form name="back" method="POST"> <input type="submit" value="<<<" name="view"> <input type="hidden" name="y" value="<?php echo "$y4"; ?>"> <input type="hidden" name="m" value="<?php echo "$m4"; ?>"> <input type="hidden" name="d" value="<?php echo "$d4"; ?>"> </form> </td> <td align="center"><b>Timesheets For <?php echo "$pdate1"; ?></b></td> <td width='10%' align="center"> <form name="forward" method="POST"> <input type="hidden" name="y" value="<?php echo "$y5"; ?>"> <input type="hidden" name="m" value="<?php echo "$m5"; ?>"> <input type="hidden" name="d" value="<?php echo "$d5"; ?>"> <input type="submit" value=">>>" name="view"> </form> </td> </tr> </table> <?php echo "</td>"; echo "</tr>"; $result5 = mysql_query("SELECT * FROM staff ORDER BY name"); while($row = mysql_fetch_array($result5)) { $eid=$row['eid']; $mname=$row['name']; $result3 = mysql_query("SELECT * FROM timesheet WHERE date = '$pdate' AND eid = '$eid'"); $talltime = 0; while($row3 = mysql_fetch_array($result3)) { $tid=$row3['id']; $tdate=$row3['date']; $tjobnumber=$row3['jobnumber']; $teid=$row3['eid']; $tdescription=$row3['description']; $tsignin=$row3['start']; $tfinish=$row3['finish']; $tlunch=$row3['lunch']; $tkms=$row3['kms']; $tschednum=$row3['schednum']; $tapproval=$row3['approval']; if("$tapproval" == "1") { $tapproval1="<font color='#00FF00'>In Progress</font>"; } if("$tapproval" == "2") { $tapproval1="<a target='_blank' href='approve.php?id=$tid'><font color='#FF0000'>Approve</font></a><br /> <a href='edittimesheet.php?id=" . $tschednum . "'>Edit</a>"; } if("$tapproval" == "3") { $tapproval1="Approved"; } $tdate1 = date( 'M j, Y', strtotime($tdate) ); $tsignin1 = date( 'g:i a', strtotime($tsignin) ); $tfinish1 = date( 'g:i a', strtotime($tfinish) ); if( empty($tfinish) ) { $tfinish2="<i>In Progress"; } else { $tfinish2="$tfinish1"; } $shortid=substr($tjobnumber, 5, -1); //remove the first 5 characters and minus the last character $result = mysql_query("SELECT * FROM jobs WHERE id = '$shortid'"); while($row = mysql_fetch_array($result)) { $jstatus=$row['status']; } $result4 = mysql_query("SELECT * FROM schedule WHERE id = '$tschednum'"); while($row4 = mysql_fetch_array($result4)) { $sid=$row4['id']; $sdate=$row4['date']; $seid=$row4['eid']; $sjobnumber=$row4['jobnumber']; $sstarttime=$row4['starttime']; $sstatus=$row4['status']; $setime=$row4['etime']; } $log_in_time_string = strtotime($tsignin); $log_out_time_string = strtotime($tfinish); $difference_in_seconds = ($log_out_time_string - $log_in_time_string); $tbilled = ($difference_in_seconds / 3600); if($tbilled < 0) { $tbilled1 = $tbilled + 24; } else { $tbilled1=$tbilled; } $tbilled2 = number_format(round($tbilled1*4)/4,2); $tbilled3 = $tbilled2 - $tlunch ; $talltime += $tbilled3; if ($talltime == '0' ) { echo "nothing"; } else { echo "<tr>"; echo "<td align='left' colspan='10'><b>&nbsp" . $mname . "</b></td>"; echo "</tr>"; echo "<tr> <th align='center'>Date</th> <th align='center'>Job Number</th> <th align='center' width='30%'>Service Report</th> <th align='center'>Sign In Time</th> <th align='center'>Sign Out Time</th> <th align='center'>Lunch</th> <th align='center'>Time Billed</th> <th align='center'>Estimated</th> <th align='center'>Status</th> </tr>"; echo "<tr>"; echo "<td align='center'>" . $tdate1 . "</td>"; echo "<td align='center'>" . $tjobnumber . "</td>"; echo "<td align='center'>" . $tdescription . "</td>"; echo "<td align='center'>" . $tsignin1 . "</td>"; echo "<td align='center'>" . $tfinish2 . "</td>"; echo "<td align='center'>" . $tlunch . " hour</td>"; echo "<td align='center'>"; if ($tbilled3 > $setime ) { echo "<font color='red'><b>*** " . $tbilled3 . " hours ***</b></font>"; } else { echo "" . $tbilled3 . " hours"; } echo "</td>"; echo "<td align='center'>" . $setime . " hours</td>"; echo "<td align='center' nowrap>" . $tapproval1 . "</td>"; echo "</tr>"; } echo "<tr>"; echo "<td colspan='6' align='right'><b>Totals :</td>"; echo "<td align='center' colspan='3'>"; if ($talltime > "8" ) { echo "<font color='red'><b>*** " . $talltime . " hours ***</b></font>"; } elseif ($talltime < "0" ) { echo "<font color='red'><b>Still signed into a job</b></font>"; } else { echo "" . $talltime . " hours"; } echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='10' bgcolor='#D9FFD9'>&nbsp</td>"; echo "</tr>"; } } echo "</table>"; include 'close.php'; ?>
  15. hello, anybody able to help me with why this is only returning the first staff member's hours? <?php if(isset($_POST['view'])) { $y3=$_POST['y']; $m3=$_POST['m']; $d3=$_POST['d']; $pdate=$y3."-".$m3. "-".$d3; $pdate1 = date( 'D M j', strtotime($pdate) ); } else { $pdate = date('Y-m-d', strtotime("-1 day") ); $pdate1 = date( 'D M j', strtotime($pdate) ); } echo "<table border='1' style='border-collapse: collapse' bordercolorlight='#000000' bordercolordark='#000000' width='98%' align='center'>"; echo "<tr><td width='100%' colspan='9' align='center'><b>Timesheets For $pdate1</b></td></tr>"; $result = mysql_query("SELECT * FROM staff ORDER BY name"); while($row = mysql_fetch_array($result)) { $eid=$row['eid']; $name=$row['name']; echo "<tr>"; echo "<td align='left' colspan='9'><b>" . $name . "</b></td>"; echo "</tr>"; echo "<tr> <th align='center'>Date</th> <th align='center'>Job Number</th> <th align='center' width='30%'>Service Report</th> <th align='center'>Sign In Time</th> <th align='center'>Sign Out Time</th> <th align='center'>Lunch</th> <th align='center'>Time Billed</th> <th align='center'>Estimated</th> </tr>"; $result3 = mysql_query("SELECT * FROM timesheet WHERE date = '$pdate' AND eid = '$eid'"); $talltime = 0; while($row3 = mysql_fetch_array($result3)) { $tid=$row3['id']; $tdate=$row3['date']; $tjobnumber=$row3['jobnumber']; $teid=$row3['eid']; $tdescription=$row3['description']; $tsignin=$row3['start']; $tfinish=$row3['finish']; $tlunch=$row3['lunch']; $tkms=$row3['kms']; $tschednum=$row3['schednum']; $tdate1 = date( 'M j, Y', strtotime($tdate) ); $tsignin1 = date( 'g:i a', strtotime($tsignin) ); $tfinish1 = date( 'g:i a', strtotime($tfinish) ); if( empty($tfinish) ) { $tfinish2="<i>In Progress"; } else { $tfinish2="$tfinish1"; } $shortid=substr($tjobnumber, 5, -1); //remove the first 5 characters and minus the last character $result = mysql_query("SELECT * FROM jobs WHERE id = '$shortid'"); while($row = mysql_fetch_array($result)) { $jstatus=$row['status']; } $result4 = mysql_query("SELECT * FROM schedule WHERE id = '$tschednum'"); while($row4 = mysql_fetch_array($result4)) { $sid=$row4['id']; $sdate=$row4['date']; $seid=$row4['eid']; $sjobnumber=$row4['jobnumber']; $sstarttime=$row4['starttime']; $sstatus=$row4['status']; $setime=$row4['etime']; } $log_in_time_string = strtotime($tsignin); $log_out_time_string = strtotime($tfinish); $difference_in_seconds = ($log_out_time_string - $log_in_time_string); $tbilled = ($difference_in_seconds / 3600); if($tbilled < 0) { $tbilled1 = $tbilled + 24; } else { $tbilled1=$tbilled; } $tbilled2 = number_format(round($tbilled*4)/4,2); $tbilled3 = $tbilled2 - $tlunch ; $talltime += $tbilled3; echo "<tr>"; echo "<td align='center'>" . $tdate1 . "</td>"; echo "<td align='center'>" . $tjobnumber . "</td>"; echo "<td align='center'>" . $tdescription . "</td>"; echo "<td align='center'>" . $tsignin1 . "</td>"; echo "<td align='center'>" . $tfinish2 . "</td>"; echo "<td align='center'>" . $tlunch . " hour</td>"; echo "<td align='center'>"; if ($tbilled3 > $setime ) { echo "<font color='red'><b>*** " . $tbilled3 . " hours ***</b></font>"; } else { echo "" . $tbilled3 . " hours"; } echo "</td>"; echo "<td align='center'>" . $setime . " hours</td>"; echo "</tr>"; } echo "<tr>"; echo "<td colspan='6' align='right'><b>Totals :</td>"; echo "<td align='center' colspan='2'>"; if ($talltime > "8" ) { echo "<font color='red'><b>*** " . $talltime . " hours ***</b></font>"; } elseif ($talltime < "0" ) { echo "<font color='red'><b>Not Signed Out</b></font>"; } else { echo "" . $talltime . " hours"; } echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='8' bgcolor='#D9FFD9'><hr></td>"; echo "</tr>"; } echo "</table>"; include 'close.php'; ?>
  16. this would help me also: what is the propper way to write this: $mechanic1 = mysql_query("SELECT * FROM staff ORDER BY name"); while($row44 = mysql_fetch_array($mechanic1)) { $meid=$row44['eid']; } $result3 = mysql_query("SELECT * FROM timesheet WHERE date >= '$payperiodstart' AND date < '$payperiodend' ORDER BY '$meid' "); while($row3 = mysql_fetch_array($result3)) { reason being is that inside timesheets, i have an employeeid field (eid). im hoping that with result3 i can have it ordered by the mechanic name even though i dont have a field in timesheets for name.
  17. hi, i have a field for price that gets returned. is there a way to do ORDER BY 'category' so that i can have tally at the bottom of each category that adds all the prices together?
  18. here is what i came up with: <?php $payrollstart="2010-10-02"; $payrollend="2010-10-15"; $payrollnum="0"; echo date('Y-m-d', strtotime($payrollstart) ), "<br />"; echo date('Y-m-d', strtotime($payrollend) ), "<br />"; echo $payrollnum; echo "<br /><br /><br />"; function round_nearest($no,$near) { return ceil($no/$near)*$near; } $date=date('Y-m-d'); $startdatestring = strtotime($payrollend); $nowstring = strtotime($date); $diffsecs=($nowstring - $startdatestring); $days = round($diffsecs / 86400); echo $days; echo "<br />"; $days1 = round_nearest($days, 14); echo $days1; echo "<br />"; $weeks=($days1 / 7); echo $weeks; echo "<br /><br /><br />"; $payrollweek=$weeks; $payrollweekstart = date('Y-m-d', strtotime("+$payrollweek week $payrollstart") ); $payrollweekstart1 = date('l F j, Y', strtotime("$payrollweekstart") ); $payrollweekend = date('Y-m-d', strtotime("+$payrollweek week $payrollend") ); $payrollweekend2 = date('l F j, Y', strtotime("$payrollweekend") ); echo $payrollweek, "<br />"; echo $payrollweekstart1, "<br />"; echo $payrollweekend2, "<br />"; echo "<br /><br /><br />"; $payrollweek2=($payrollweek - 2); $payrollweek3=($payrollweek - 4); $payrollweek4=($payrollweek - 6); $payrollweek5=($payrollweek - ; $payperiod = date('Y-m-d', strtotime("+$payrollweek week $payrollend") ); $payperiod2 = date('Y-m-d', strtotime("+$payrollweek2 week $payrollend") ); $payperiod3 = date('Y-m-d', strtotime("+$payrollweek3 week $payrollend") ); $payperiod4 = date('Y-m-d', strtotime("+$payrollweek4 week $payrollend") ); $payperiod5 = date('Y-m-d', strtotime("+$payrollweek5 week $payrollend") ); ?> <form method="POST"> Pay Period Ending: <select size="1" name="payperiod"> <option selected value="<?php echo $payperiod; ?>"><?php echo date('F j, Y', strtotime("$payperiod") ); ?></option> <option value="<?php echo $payperiod2; ?>"><?php echo date('F j, Y', strtotime("$payperiod2") ); ?></option> <option value="<?php echo $payperiod3; ?>"><?php echo date('F j, Y', strtotime("$payperiod3") ); ?></option> <option value="<?php echo $payperiod4; ?>"><?php echo date('F j, Y', strtotime("$payperiod4") ); ?></option> <option value="<?php echo $payperiod5; ?>"><?php echo date('F j, Y', strtotime("$payperiod5") ); ?></option> </select> <input type="submit" value="View" name="view"> </form>
  19. what is the propper way to write $payrollweek="10"; date('Y-m-d', strtotime("+($payrollweek - 2) week $payrollend") ), "<br />"; its the ("+($payrollweek - 2) that isnt working i think
  20. here is what i was talking about: <?php $payrollstart="2010-10-16"; $payrollend="2010-10-29"; $payrollnum="0"; echo date('Y-m-d', strtotime($payrollstart) ), "<br />"; echo date('Y-m-d', strtotime($payrollend) ), "<br />"; echo $payrollnum; echo "<br /><br /><br />"; function round_nearest($no,$near) { return ceil($no/$near)*$near; } $date=date('Y-m-d'); $startdatestring = strtotime($payrollend); $nowstring = strtotime($date); $diffsecs=($nowstring - $startdatestring); $days = round($diffsecs / 86400); echo $days; echo "<br />"; $days1 = round_nearest($days, 14); echo $days1; echo "<br />"; $weeks=($days1 / 7); echo $weeks; echo "<br /><br /><br />"; $payrollweek=$weeks; echo date('Y-m-d', strtotime("+$payrollweek week $payrollstart") ), "<br />"; echo date('Y-m-d', strtotime("+$payrollweek week $payrollend") ), "<br />"; echo $payrollweek; ?> now i just need to figure out how to make a drop down list that shows date('Y-m-d', strtotime("+$payrollweek week $payrollend") ) as the first date and an array of the last 5 pay periods(the friday date)
  21. ultimately when i get this page finished, there will be a drop down box full of dates of payroll ending days. from that, it will show all timesheetes between payroll start and finish dates for that period.
  22. so, i have these set: $payrollstart="2010-10-16"; $payrollend="2010-10-29"; i cant wrap my head around how to start this thing off.
  23. hello, is there a way to have php code determine what payroll week it is, or is it best to have a start date and end date in a table?
×
×
  • 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.