Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Count Up Script?

    How do you count up the number of safe working hours a number of employees has worked safely, without getting injured?

    For example,

    There are 10 employees working on site. There has not been an injury since Mar 3, 1999.

    I want to take the number of hours these 10 employees worked safely, without getting injured and make it into something like a hit counter.

    I was wondering if I could modify the count up script to do it. Instead of counting up days i would count up hours times the number of employees.
    Last edited by HWilson08018; 10-21-2005 at 04:25 PM.

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could you be more specific. What do you need to do?
    rm -f /

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,014
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Do please read the posting guidelines. Your query is far too vague. In a day? a week? a year? How is "safely" measured or recorded? Or do you mean the hours worked since he last had an accident? Or what?

    And please avoid the expression "Thank you in advance". As a newcomer you should not take other people's interest in your problem and their assistance for granted. The time to offer thanks is after - not before.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,014
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    What you want to achieve is perfectly feasible, but your specification is still too vague.

    Are there always 10 (no more, no fewer) employees?
    Do they always work 5/6/7 days a week? (how many days?)
    Do they always work 7/8/9/10 hours each day? (how many hours?)

    I envisage that you want a textbox saying something like
    "150654 hours worked since the last accident".

    I suppose that if another accident happens you go back to zero!

  • #5
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    35 employees.

    Lets assume 2080 hrs./yr = 40hrs per week X 52 weeks

    This probably will not remain constant, but I can change it manually in the future.

    you are correct.

    I want a text box that says 9999999 Exposure Hours worked Safely since 2/14/2000.

    When someone gets hurt I would reset it to zero.

  • #6
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    How do you count up the number of safe working hours a number of employees has worked safely, without getting injured?
    Well, I wouldn't suggest leaning back too far in your chair. An ergonomically correct keyboard might also help. If you have any sharp objects on or near you computer, you might want to place them elsewhere.

    Seriously though, this seems something that could be better, and more accuratley tracked using a server side language. That way you could log the actual working hours by documenting it in a database. Otherwise if \ when you change the number of hours in the javascript solution, it would skew results that had been accumulated under the old formula.

    Basscyst
    Last edited by Basscyst; 10-22-2005 at 12:23 AM.
    Helping to build a bigger box. - Adam Matthews

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,014
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    I agree with basscyst - you really need a server side language to do this properly, although I take it that the value to be shown is "propaganda" and does not need to be very accurate.

    The difficulty with using javascript is that the total hours worked does not go up steadily - only during working hours but not in the middle of the night, or at weekends. Also, what if some employees are sick, or absent, on a certain day? In other words, anything that simply adds 35 hours each hour, or 35 X 8 hours each day, to some starting value is not very useful or reliable. It would be far better if the number was read from an accurate database.
    Last edited by Philip M; 10-22-2005 at 12:49 PM.

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,014
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    The following will give a value which is reasonably accurate (assuming 35 men, 8 hours a day, 5 days a week - but no holidays or absentees). You can if you wish apply a factor to allow for these. In the short term the calculation *5/7 to give hours per week will cause a small inaccuracy (as it does not cover fractions of a week).

    <BODY onload="daysNoAccident()">

    <SCRIPT>
    var date1 = "Feb 14, 2000"
    var mons = new Array("Jan", "Feb", "March", "April", "May", "June", "July", "August", "Sept", "Oct", "Nov", "Dec")
    var now = new Date();
    var mm = now.getMonth();
    mm = mons[mm];
    var dd = now.getDate();
    var yy = now.getYear();
    var date2 = mm + " " + dd +", "+ yy;

    function daysNoAccident() {
    date1 = date1.toString();
    date2 = date2.toString();
    date1 = Date.parse(date1);
    date2 = Date.parse(date2);
    date1 /= 1000; date1 /= 60; // minutes
    date2 /= 1000; date2 /= 60;
    var result = Math.abs(date1 - date2);
    result = result/60; // = hours
    result = result * 8/24; //hours worked per day
    result = result * 5/7; // working days in week
    result = result * 35 // number of employees
    result = parseInt(result);
    document.write ("You have worked " + result + " hours since 14th February 2000 without an accident");
    }
    </SCRIPT>
    Last edited by Philip M; 10-22-2005 at 04:03 PM.

  • #9
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://javascript.internet.com/calcu...ifference.html

    calculates time difference between 2 dates/times

    the result is in something like:
    52 weeks, 1 days, 0 hours, 0 minutes, and 21 seconds

    based on your description:
    t1 = lastAccident
    t2 = now
    //totalSafeHours
    var tSH = 0;
    tSH += weeks * noEmp * 40; //40 hours per empoyee per week

    // 40 hours per week out of 24*7 people lose at work
    tmpHours = (24 * days + hours);
    tmpHours *= 40/(24*7) * noEmp;

    tSH += tmpHours;
    Last edited by rm-f; 10-22-2005 at 01:05 PM.
    rm -f /

  • #10
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Philip M,
    Where in the script can I change the text properties?
    I got a brain block.
    The script works! Thank you.


  •  

    Posting Permissions

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