Application of employee attendance report module developed using PHP in enterprise resource planning (ERP) system

王林
Release: 2023-07-01 17:42:01
Original
1136 people have browsed it

The application of employee attendance report module developed using PHP in the enterprise resource planning (ERP) system

With the expansion of enterprise scale and the complexity of business, the enterprise resource planning (ERP) system has become more and more important in enterprise management. plays a vital role. Among them, employee attendance management is one of the important links in enterprise human resources management. In order to better manage employee attendance and provide real-time attendance reports, we can use PHP to develop an employee attendance report module and integrate it into the ERP system.

First, we need to design the database structure of the employee attendance report module. The attendance report needs to contain the basic information of the employee (such as name, work number, etc.), attendance date, clock-in time, clock-in time and other fields. A MySQL database can be used to store this information.

The SQL statement to create a database table is as follows:

CREATE TABLE employee (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50),
  employee_number VARCHAR(20)
);

CREATE TABLE attendance (
  id INT AUTO_INCREMENT PRIMARY KEY,
  employee_id INT,
  date DATE,
  start_time TIME,
  end_time TIME,
  FOREIGN KEY (employee_id) REFERENCES employee(id)
);
Copy after login

Next, we can use PHP to write a class for the employee attendance report module to facilitate our operation of employee attendance data.

class AttendanceReport {
  private $db; // 数据库连接

  public function __construct($db) {
    $this->db = $db;
  }

  /**
   * 查询指定日期的考勤数据
   *
   * @param string $date 日期
   * @return array
   */
  public function getAttendanceByDate($date) {
    $query = "SELECT 
                employee.name, 
                attendance.start_time, 
                attendance.end_time 
              FROM 
                attendance 
              INNER JOIN 
                employee ON attendance.employee_id = employee.id 
              WHERE 
                attendance.date = :date";
    $stmt = $this->db->prepare($query);
    $stmt->bindParam(':date', $date);
    $stmt->execute();
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
  }

  /**
   * 添加员工考勤记录
   *
   * @param int $employeeId 员工ID
   * @param string $date 日期
   * @param string $startTime 上班打卡时间
   * @param string $endTime 下班打卡时间
   * @return bool
   */
  public function addAttendance($employeeId, $date, $startTime, $endTime) {
    $query = "INSERT INTO attendance (employee_id, date, start_time, end_time) VALUES (:employeeId, :date, :startTime, :endTime)";
    $stmt = $this->db->prepare($query);
    $stmt->bindParam(':employeeId', $employeeId);
    $stmt->bindParam(':date', $date);
    $stmt->bindParam(':startTime', $startTime);
    $stmt->bindParam(':endTime', $endTime);
    return $stmt->execute();
  }
}
Copy after login

Next, we can use the employee attendance report module in the relevant pages of the ERP system. For example, we can display employee attendance data for a specified date on the employee attendance report page.

// 创建一个数据库连接
$db = new PDO("mysql:host=localhost;dbname=erp", "username", "password");

// 创建一个员工考勤报表实例
$attendanceReport = new AttendanceReport($db);

// 获取指定日期的员工考勤数据
$date = '2022-01-01';
$attendanceData = $attendanceReport->getAttendanceByDate($date);

// 输出员工考勤表格
echo "<table>";
echo "<tr><th>姓名</th><th>上班打卡时间</th><th>下班打卡时间</th></tr>";
foreach ($attendanceData as $row) {
  echo "<tr>";
  echo "<td>".$row['name']."</td>";
  echo "<td>".$row['start_time']."</td>";
  echo "<td>".$row['end_time']."</td>";
  echo "</tr>";
}
echo "</table>";
Copy after login

The above code example demonstrates how to use the employee attendance report module developed in PHP to display employee attendance data on a specified date in the ERP system.

In summary, the employee attendance report module developed using PHP can easily manage and display employee attendance data. We can expand this module according to actual needs and add more functions, such as exporting reports, statistical analysis, etc. As long as we use PHP development technology flexibly, we can provide more efficient and convenient solutions for corporate human resources management.

The above is the detailed content of Application of employee attendance report module developed using PHP in enterprise resource planning (ERP) system. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!