Home > Article > Backend Development > Application of supplier evaluation statistics module developed by PHP in enterprise resource planning (ERP) system
Application of supplier evaluation statistics module developed by PHP in enterprise resource planning (ERP) system
Introduction:
With the increasing globalization and market competition, enterprises are paying more and more attention to supply Chain management and optimization. The application of supplier evaluation statistics module in enterprise resource planning (ERP) systems has attracted more and more attention from enterprises. This article will introduce how to use PHP to develop a simple supplier evaluation statistics module, and demonstrate the application of this module in the ERP system.
First, we need to create a database table to save supplier information and evaluation records:
CREATE TABLE `supplier` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) NOT NULL, `contact` VARCHAR(50) NOT NULL, `phone` VARCHAR(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
Then, we need to create another database table to save supplier evaluation records:
CREATE TABLE `evaluation` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `supplier_id` INT(11) NOT NULL, `delivery_rate` DECIMAL(5,2) NOT NULL, `comments` TEXT NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`supplier_id`) REFERENCES `supplier` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
Next, we use PHP to create the basic functions of the supplier evaluation statistics module:
// 连接数据库 $host = 'localhost'; $db = 'erp'; $user = 'root'; $password = 'password'; $dsn = "mysql:host=$host;dbname=$db;charset=utf8"; $pdo = new PDO($dsn, $user, $password); // 添加供应商信息 function addSupplier($name, $contact, $phone) { global $pdo; $stmt = $pdo->prepare("INSERT INTO supplier (name, contact, phone) VALUES (?, ?, ?)"); $stmt->execute([$name, $contact, $phone]); return $pdo->lastInsertId(); } // 添加评价记录 function addEvaluation($supplierId, $deliveryRate, $comments) { global $pdo; $stmt = $pdo->prepare("INSERT INTO evaluation (supplier_id, delivery_rate, comments) VALUES (?, ?, ?)"); $stmt->execute([$supplierId, $deliveryRate, $comments]); return $pdo->lastInsertId(); } // 生成评价报表 function generateReport() { global $pdo; $stmt = $pdo->prepare("SELECT supplier.name, AVG(evaluation.delivery_rate) as average_rate FROM supplier INNER JOIN evaluation ON supplier.id = evaluation.supplier_id GROUP BY supplier.id"); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); }
Summary:
This article introduces the application of the supplier evaluation statistics module developed by PHP in the enterprise resource planning (ERP) system. By developing a simple supplier evaluation statistics module and demonstrating how to integrate it with an enterprise's ERP system, it can help enterprises better manage and optimize the supply chain and provide better products and services. In practical applications, the functions of the supplier evaluation statistics module can also be expanded and customized according to the needs of the enterprise to meet the needs of different enterprises.
The above is the detailed content of Application of supplier evaluation statistics module developed by PHP in enterprise resource planning (ERP) system. For more information, please follow other related articles on the PHP Chinese website!