SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    0 Post(s)
    0 Thread(s)

    I'm desparate!!!

    I work for a lighting company and accidentally told my boss that I know how to write programs. We have 5 employees that make light fixtures in the warehouse. The program is to track the time it takes them to make each batch of fixtures so we can accurately bill our clients for labour. I've made ID cards for each worker with their name encoded in a barcode on it. Also, each work order for the fixtures has a unique barcode. The program interface is a simple HTML form. The logic is as follows.

    1) worker scans his name => name textbox fills in and switches focus to work order ID textbox
    2) worker then scans work order barcode => this submits the form
    3) I premade textfiles for each worker, PHP checks if there's already a time in it. Lets assume we're starting the job.
    4) PHP adds the hours and minutes collected in hidden input fields in the form
    5) Writes those times to his name file
    6) when the worker scans again, it adds the current hour and minute reading to what was in the file, and writes that data to a line in the jobfile for that particular work order
    7) it then outputs the data from that jobfile to a HTML table. There will be a job submit button (when job is finished) that prints out the table and changes the extension of the file from .txt to .tx_ for archival purposes.

    The form can be seen at:
    Timetrax Program

    This is what I have so far for the submit script (please keep in mind that this is my first PHP program and first attempt at programming in the last 10 years)
    It's all messed up as I have been going nuts.

    <LINK REL="stylesheet" HREF="css/mainstyle.css">
    <META HTTP-EQUIV="Refresh" CONTENT="200; URL=">
    <TITLE>Premier Lighting Ltd. - Timetrax&copy;</TITLE>

    $nameopen = $_POST['namecode'].".txt";
    $namefile = fopen($nameopen, "r+");
    $namea = $_POST['namecode'];
    $timea = $_POST['timecodeA'];
    $timeb = $_POST['timecodeB'];
    $joba = $_POST['jobcode'];
    $job = "jobfile.txt";
    $jobfile = fopen($job, "a");

    while (!feof($namefile))
    $buffer = fscanf($namefile, "%d %d", $time1, $time2);
    if ($time2 != 0)
    $time1 = $_POST['timecodeA'] - $time1;
    $time2 = $_POST['timecodeB'] - $time2;
    if ($time2 > 60)
    $time1 = $time1 + 1;
    $time2 = $time2 - 60;

    $timeadjust = $time1-8;
    fwrite($jobfile, "\n$namea $timeadjust $time2");

    $job = "jobfile.txt";
    $jobfile = fopen($job, "a");

    print "<CENTER><BR><BR><BR><BR><table border=\"1\" cellpadding=\"10\" cellspacing=\"0\" BGCOLOR=\"#333333\" onClick=\"javascript:window.print()\">\n";
    print "<tr>\n<td COLSPAN=\"4\">Report for Job: <FONT SIZE=\"3\" COLOR=\"#FFFF99\"><B>" . $joba . "</B></FONT></td></tr>\n";
    print "<tr>\n<td>Worker</td><td>Hours on Job</td><td>Minutes on Job</td><td>Job Code</td></tr>\n";
    $x = 0;
    $y = 0;
    while (!feof($jobfile)){
    $buffer = fscanf($jobfile, "%s %d %d", $namecode, $timecodea, $timecodeb);
    if ($buffer == 3){
    print "<tr>\n";
    print "<td>".$namecode."</td><td>$timecodea</td><TD>$timecodeb</TD>\n";
    print "</tr>\n";

    $x = $x++;
    $y = $y++;
    $totalhours = $totalhours + $timecodea;
    $totalminutes = $totalminutes + $timecodeb;
    if ($totalminutes > 60){
    $totalminutes = $totalminutes - 60;
    $totalhours = $totalhours + 1;
    print "<tr>\n";
    print "<td COLSPAN=\"4\">Total Time for Project = ".$totalhours."hrs ".$totalminutes."mins</td>\n";
    print "</tr>\n";
    print "</table></CENTER>\n";
    print "<CENTER><FORM METHOD=\"POST\" ACTION=\"rename.php\">";
    print "<INPUT TYPE=\"submit\" VALUE=\"Close and Print\">";
    print "</FORM></CENTER>";


    Click <A HREF="">HERE</A> for homepage.

  2. #2
    SitePoint Enthusiast crazylegswilson's Avatar
    Join Date
    Nov 2004
    0 Post(s)
    0 Thread(s)
    So what exactly is your question? Is there something that doesnt work very well? I checked your link, but as i don't have your barcode scanner here at my house, i couldnt get very far. What do you want help with?

  3. #3
    If it aint Dutch it aint much Kilroy's Avatar
    Join Date
    Oct 2003
    The Netherlands
    0 Post(s)
    0 Thread(s)
    Suggestion: next time don't lie to your boss about what you can and cannot do.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts