Web Analytics Made Easy -
StatCounter How to make a payroll report out of an attendance records - CodingForum

Announcement

Collapse
No announcement yet.

How to make a payroll report out of an attendance records

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make a payroll report out of an attendance records

    I have database named: timesheets which has the following:

    employee_id
    employee_name
    year
    month
    day
    timein
    timeout
    city
    department
    1 dave 2016 10 1 8 4 ciaro finance
    1 dave 2016 09 30 8 4 ciaro finance
    1 dave 2016 09 29 8 4 ciaro finance
    2 frank 2016 10 1 8 4 ciaro purchase
    which records the daily attendance of employees as you can see above

    What I want is to make payroll report that shows the total number of working days for each employee and each department in a separate html table.

    finance department payroll

    employee id
    employee name
    total working days
    1 dave 3
    purchase department payroll

    employee id
    employee name
    total working days
    2 frank 1
    How to do that using mysql_or PDO
    Last edited by samiraljohani; Oct 1, 2016, 03:26 PM.

  • #2
    Define: 'working days'. Do you actually want to consider the amount of time, or only get a COUNT of the number of records for each employee?

    To just get a COUNT of the number of records, you would use SELECT COUNT(*) as days and GROUP BY employee_id in the sql query statement.

    To output the data by organized by department, you can use either of these two methods -

    1) Use ORDER BY department in the sql query statement, then as you are looping over the results to display them, each time the department value changes, including the first change from having no value to having the first value, you would output the heading, then just output the data under each heading.

    2) Pre-process (loop over) the rows of data that the query returns, and store them to an array of array of rows, using the department value as the main array key. Then, just loop over the resulting main array and each sub-array of rows.
    Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

    Comment


    • #3
      Yes I wan to consider the amount of time and not just get a COUNT of the number of records.

      I tried the SQL query you suggested and I received the following array

      PHP Code:
       Array ( [0] => [COUNT(*)] => ) Array ( [0] => [COUNT(*)] => 
      which is the working days of one of the employees but how to get the other counts, I want all employees to be listed along with their working days

      Comment

      Working...
      X