mysql管理应用

by Richard

理查德(Richard)

如何在PHP和MySQL中制作出色的库存管理应用程序 (How to Make an Awesome Inventory Management Application in PHP and MySQL)

You do not need bloated enterprise software to effectively track your inventory. This tutorial will help you develop your own custom inventory tracking application so you can make smart inventory decisions based on timely and accurate inventory data.

您不需要庞大的企业软件即可有效地跟踪库存。 本教程将帮助您开发自己的自定义库存跟踪应用程序,以便您可以基于及时准确的库存数据做出明智的库存决策。

系统要求 (System Requirements)

Our Inventory System requires the standard commercial phpGrid and phpChart license. It needs a few advanced features from both components.

我们的库存系统需要标准的商业phpGrid和phpChart许可证。 它需要这两个组件的一些高级功能。

  • PHP 5.6+(PHP 7.x is now highly recommended!)

    PHP 5.6+( 现在强烈建议使用PHP 7.x! )

  • MySQL / MariaDBMySQL的/ MariaDB的
  • phpGrid Lite (subgrid) -or- phpGrid Enterprise (Master detail, Grouping)phpGrid Lite(子网格)-或-phpGrid Enterprise(主详细信息,分组)
  • phpChart (for reports)phpChart(用于报告)

库存管理系统中的内容 (What is in an Inventory Management System)

An inventory management system has several critical components. At its core, inventory control works by tracking the two main functions of a warehouse: receiving (incoming) and shipping (outgoing). Other activities such as the movement or relocation of inventory also take place. Raw materials are decremented and finished goods are incremented.

库存管理系统具有几个关键组件。 从根本上讲,库存控制通过跟踪仓库的两个主要功能进行工作:收货(进货)和运输(进货)。 还发生了其他活动,例如库存的移动或迁移。 原材料减少,成品增加。

  • Incoming shipments收货
  • Outgoing orders待发订单
  • Inventory库存
  • Suppliers供应商
  • Barcode scanner (1/2019 New!)

    条形码扫描仪 (1/2019新增功能!)

库存系统数据库设计 (Inventory System Database Design)

Typically, an inventory system has four basic elements: products, purchases, orders, and suppliers. Each element must be tracked based on its location, SKU, and quantity. Current inventory, or products on hand, is updated by tracking incoming shipments and outgoing orders. Order alerts can be set to trigger when inventory levels fall below custom-defined minimum levels.

通常,库存系统具有四个基本元素:产品,购买,订单和供应商。 必须根据其位置,SKU和数量来跟踪每个元素。 当前库存或手头产品通过跟踪进货和出库订单进行更新。 可以将订单警报设置为在库存水平降至自定义的最低水平以下时触发。

设置库存管理器数据库 (Setting up the Inventory Manager Database)

Download the InventoryManager.sql SQL script from this tutorial’s GitHub repo, and then execute the script using a MySQL tool such as MySQL Workbench. This will create a new database named InventoryManager as well as the tables needed for this tutorial.

从本教程的GitHub存储库下载InventoryManager.sql SQL脚本,然后使用MySQL工具(如MySQL Workbench)执行脚本。 这将创建一个名为InventoryManager的新数据库以及本教程所需的表。

ZenBase的附带说明 (A Side Note on ZenBase)

The Inventory Management System is also one of the many application templates readily available at ZenBase (built on the top of phpGrid) for anyone — with or without coding skills — to use and customize for their own needs.

设置phpGrid (Set up phpGrid)

Let’s move on.

让我们继续。

We will use a datagrid component by phpGrid to handle all internal database CRUD (Create, Remove, Update, and Delete) operations.

我们将使用phpGrid的datagrid组件来处理所有内部数据库CRUD(创建,删除,更新和删除)操作。

Be sure to download a copy of phpGrid before you proceed.

在继续之前,请确保下载phpGrid的副本 。

To install phpGrid, follow these steps:

要安装phpGrid,请按照以下步骤操作:

  1. Unzip the phpGrid download file.解压phpGrid下载文件。
  2. Upload the phpGrid folder to the phpGrid folder.

    phpGrid文件夹上载到phpGrid文件夹。

  3. Complete the installation by configuring the conf.php file.

    通过配置conf.php文件来完成安装。

Before we begin coding, we must include the following information in conf.php, the phpGrid configuration file.

在开始编码之前,必须在phpGrid配置文件conf.php包含以下信息。

创建用户界面(UI) (Creating the User Interface (UI))

Our inventory system comprises four pages:

我们的库存系统包括四个页面:

  • Current Inventory当前库存
  • Incoming Purchases进货
  • Orders to Ship订单出货
  • Reports报告书

选单 (Menus)

The include file for the menu is stored in an inc folder named menu.php. The code for the menu is straightforward. For the sake of focus, we will not go into great detail. Feel free to look at the code inside the inc folder.

菜单的包含文件存储在名为menu.phpinc文件夹中。 菜单的代码很简单。 为了专注,我们将不做详细介绍。 随时查看inc文件夹中的代码。

We have also added a menu item named Reports.

我们还添加了一个名为Reports的菜单项。

页数 (Pages)

We will use the same page template we used for the CRM and Project Management tutorials.

我们将使用与CRM和Project Management教程相同的页面模板。

当前库存 (Current Inventory)

Let’s start with the Current Inventory page.

让我们从“当前库存”页面开始。

Incoming purchases increase the inventory while outgoing orders decrease it. From a master-detail perspective, the Current Inventory has not one, but two detail datagrids — the Purchases (incoming purchases) and the Orders (outgoing orders).

进货增加库存,而外发订单减少库存。 从主从角度看,“当前库存”没有一个,而是两个明细数据网格-“ 采购” (进货)和“ 订单” (外发订单)。

So the Current Inventory page is composed of one master grid (the Current Inventory in stock) and two detail grids (Incoming Purchases and Outgoing Orders). We can easily present these relationships using the phpGrid one master and multiple detail datagrids feature.

因此,“当前库存”页面由一个主网格(库存中的当前库存)和两个明细网格(收货和外发订单)组成。 我们可以使用phpGrid一个主控件和多个详细信息datagrids功能轻松呈现这些关系。

phpGrid Lite与专业版和企业版 (phpGrid Lite vs. Professional and Enterprise)

Master detail and Grouping features require phpGrid Professional or Enterprise edition. If you are on the free Lite version, you can still use subgrid in place of Master detail albeit less advanced. Professional or Enterprise versions are highly recommended.

主要细节和分组功能需要phpGrid Professional或Enterprise版本。 如果您使用的是免费的Lite版本,则尽管高级程度较低,仍然可以使用subgrid代替Master细节。 强烈建议使用专业版或企业版。

If you have read the last tutorial Building a Donation Manager from Scratch, you will have no problem following the code below.

如果您已阅读了最后的教程Scratch的《构建捐赠管理器》 ,那么遵循以下代码将没有问题。

Note the use of the set_col_format() function used to format the integers.

请注意使用set_col_format()函数来格式化整数。

That’s it for the Current Inventory datagrid. Here’s what it looks like so far:

对于“当前库存”数据网格就是这样。 到目前为止的样子:

Now, let’s make a few changes to enhance our Product datagrid.

现在,让我们进行一些更改以增强我们的产品数据网格。

First of all, we will add some conditional formatting: whenever the InventoryOnHand is set to zero or a negative value, it is displayed using a different background color. We will use the set_conditional_format() function for this purpose.

首先,我们将添加一些条件格式:每当InventoryOnHand设置为零或负值时,它将使用不同的背景色显示。 为此,我们将使用set_conditional_format()函数。

The above code adds a display condition so that whenever the InventoryOnHand field has a value that is less than (lt) one, the text color changes to red and the background color to dark gray (#DCDCDC).

上面的代码添加了显示条件,以便每当InventoryOnHand字段的值小于( lt )时,文本颜色将变为red ,背景颜色将变为深灰色( #DCDCDC )。

Secondly, whenever the InventoryOnHand is less than the value shown in MinimumRequired, we would like to alert the user by displaying it in a prominent background color such as gold. To compare values between two fields, we must switch to Javascript because the set_conditional_format() function only works with a single field.

其次,每当InventoryOnHand小于MinimumRequired显示的值时,我们都希望通过以突出的背景色(例如金色)显示它来提醒用户。 要比较两个字段之间的值,我们必须切换到Javascript,因为set_conditional_format()函数仅适用于单个字段。

The code below uses a for loop to iterate through each row in the Products datagrid. It compares the inventoryOnHand with theminimumRequired and, when the condition is met, it will use thesetCell function to change the background color.

下面的代码使用for循环遍历Products数据网格中的每一行。 它的比较inventoryOnHandminimumRequired ,当满足条件时,它会使用setCell功能来改变背景颜色。

You can learn more about comparing multiple cell values on the phpGrid support website.

您可以在phpGrid支持网站上了解有关比较多个单元格值的更多信息。

Next, on the same page, we need to see the purchases coming in (Incoming) and orders going out (Outgoing) for a specific product.

接下来,在同一页上,我们需要看到的采购量( 来电 )来和订单出去( 离开 )的特定产品。

购买明细表(传入) (Purchases Detail Grid (Incoming))

订单明细表(发送) (Orders Detail Grid (Outgoing))

Both detail grids use the same foreign key ProductId to link to the master datagrid (Products).

两个详细信息网格都使用相同的外键ProductId链接到主数据网格( Products )。

Finally, our complete code to manage the Current Inventory page is:

最后,用于管理“ 当前库存”页面的完整代码是:

Here’s the a snapshot of the inventory page:

这是库存页面的快照:

进货 (Incoming Purchases)

The next page is the Incoming Purchase page. It is similar to the Purchase Detail Grid we saw when setting up the Current Inventory page. We group the purchases by ProductId and display the sum inNumberReceived. Any incoming purchases will increase the inventory.

下一页是“ 收货”页面。 它类似于我们在设置“ 当前库存”页面时看到的“ 采购明细表格” 。 我们按ProductId将采购分组,并在NumberReceived显示总和。 任何进货都会增加库存。

Note: Grouping feature is only available in the phpGrid Professional and Enterprise edition. To filter without the grouping, use the integration search.

注意:分组功能仅在phpGrid专业版和企业版中可用。 要不进行分组过滤,请使用集成搜索 。

The complete code:

完整的代码:

Here’s a screenshot of our Incoming Purchases page with grouping enabled:

这是启用了分组功能的“ 收货”页面的屏幕截图:

待发订单 (Outgoing Orders)

The next page is the Outgoing Orders page. It is similar to the Orders Detail Grid from the Current Inventory page. Here, we will introduce an advanced function called set_grid_method().

下一页是“外发订单”页面。 它类似于“ 当前库存”页面中的“ 订单详细信息网格 ”。 在这里,我们将介绍一个名为set_grid_method()的高级函数。

摘要 (Summary)

This tutorial builds a simple and extendable inventory system in less than 50 lines of code. The progressive style of these tutorials also helps the reader to ultimately become more familar and comfortable with phpGrid by introducing a limited number of new phpGrid features in each one.

本教程用不到50行代码构建了一个简单且可扩展的清单系统。 这些教程的渐进式风格还通过在每个教程中引入数量有限的新phpGrid功能,帮助读者最终变得更加熟悉和熟悉phpGrid。

即将发生什么 (What’s Coming Up)

This marks the end of the code needed to create the datagrids required for this tutorial. However, we are not done yet. There is still one more page we need to create — Reports. We will cover that after the jump.

这标志着创建本教程所需的数据网格所需的代码的结尾。 但是,我们还没有完成。 我们还需要创建一个页面-报告。 我们将在跳转后进行介绍。

What’s the use of an inventory system without some of type of report? In this section, you will learn how to use phpChart — which seamlessly integrates with phpGrid — to create visually pleasing and useful reports for your Inventory Manager application.

没有某种报告类型的库存系统有什么用? 在本部分中,您将学习如何使用phpChart (与phpGrid无缝集成)来为库存管理器应用程序创建视觉上令人愉悦的有用报告。

Here’s what our page will look like when it’s done:

这是完成后的页面外观:

Before we start, we need to install phpChart. It is recommended that you obtain the full version of phpChart since the free version (phpChart Lite) supports only the line chart.

在开始之前,我们需要安装phpChart。 由于免费版本(phpChart Lite)仅支持折线图,因此建议您获取完整版本的phpChart 。

设置phpChart (Setup phpChart)

It’s important that we keep phpGrid and phpChart in separate folders. Below is the recommended folder hierarchy.

重要的是,将phpGrid和phpChart放在单独的文件夹中。 下面是推荐的文件夹层次结构。

www    +-- Donation_Manager    |   |-- phpGrid    |   |   +-- conf.php    |   |-- phpChart    |   |   +-- conf.php    |   +-- ...

报告设计 (Report Design)

We will place a pie chart next to an inventory summary grid. The datagrid provides the series data to plot the pie chart.

我们将在饼图摘要网格旁边放置一个饼图。 数据网格提供系列数据以绘制饼图。

phpGrid和phpChart集成 (phpGrid and phpChart Integration)

First of all, include calls to both conf.php files at the beginning of the code.

首先,在代码开头包含对两个conf.php文件的调用。

require_once("phpGrid/conf.php"); require_once("phpChart/conf.php");

饼形图 (Pie Chart)

Below is the complete code to create our pie chart:

以下是创建饼图的完整代码:

Let’s walk through the code.

让我们来看一下代码。

The first line is the constructor. We pass array(null) as the series data because we don’t wish to have any data displayed in the pie chart initially. The inventory data used to plot the chart is not yet available when it is first initialized. The data is fed from the datagrid later in JSON.

第一行是构造函数。 我们将array(null)作为系列数据传递,因为我们不希望最初在饼图中显示任何数据。 首次初始化时,用于绘制图表的库存数据尚不可用。 稍后从JSON中从datagrid馈送数据。

We also give our chart a unique name, PieChart.

我们还为图表提供了唯一的名称PieChart

Next, we give it a title. Nothing fancy here.

接下来,给它一个标题。 这里没什么好看的。

Once we have the title, we call the series default function to set the renderer to PieRenderer. Unlike a bar chart, a pie chart does not have a Y axis.

获得标题后,我们将调用series默认函数以将renderer设置为PieRenderer 。 与条形图不同,饼形图没有Y轴。

We can also set the rendererOptions property. We will not go into each option in detail here, but you can find more information in the online documentation.

我们还可以设置rendererOptions属性。 我们不会在这里详细介绍每个选项,但是您可以在在线文档中找到更多信息。

We also want to show a legend. The set_legend command below shows the legend to the west (noted byw) or to the left of the pie chart.

我们也想展示一个传奇。 下面的set_legend命令在图例的西边(用w )或饼图的左侧显示图例。

We will also remove the border and the background.

我们还将删除边框和背景。

Finally, we draw our chart by giving it a height and width in pixels.

最后,我们通过以像素为单位指定高度和宽度来绘制图表。

However, if you execute the code now, you will not see the chart because the data used to render it isn’t available yet.

但是,如果现在执行代码,则将看不到图表,因为用于渲染它的数据尚不可用。

库存摘要数据网格 (Inventory Summary Datagrid)

Here, we will use the same the inventory datagrid as we did in the Products page. We just need to add one more thing — an event handler.

在这里,我们将使用与“ 产品”页面中相同的库存数据网格。 我们只需要添加一件事-事件处理程序。

In phpGrid, we can add an event handler with the add_event() function. add_event() binds an event handler, which is essentially a JavaScript function, to a specific phpGrid event. A list of possible events can be found here.

在phpGrid中,我们可以使用add_event()函数添加事件处理程序。 add_event()将事件处理程序(实际上是JavaScript函数)绑定到特定的phpGrid事件。 可在此处找到可能发生的事件的列表。

Since we must wait for the datagrid to finish loading before it can send the data to plot the chart, we use the event jqGridLoadComplete.

由于我们必须等待数据网格完成加载之后才能发送数据以绘制图表,因此我们使用事件jqGridLoadComplete

phpGrid 101 — jqGridLoadComplete Event

phpGrid 101 — jqGridLoadComplete事件

jqGridLoadComplete is last event that occurs once the whole datagrid body has finished loading. Note that the grid body will be reloaded if the user changes the sort order of a column or sets a filter.

jqGridLoadComplete是在整个datagrid主体完成加载后发生的最后一个事件。 请注意,如果用户更改列的排序顺序或设置过滤器,则将重新加载网格主体。

用Javascript发送数据 (Sending Data with Javascript)

The following is the Javascript event handler for jqGridLoadComplete.

以下是jqGridLoadComplete的Javascript事件处理程序。

The complete code:

完整的代码:

Now there you have it. Your just built your very first inventory management system from scratch using PHP and MySQL!

现在那里了。 您刚刚使用PHP和MySQL从头构建了您的第一个库存管理系统!

Thank you for reading! If you enjoyed this post, please give me some claps so more people see it.

感谢您的阅读! 如果您喜欢这篇文章,请给我一些鼓掌,以便更多人看到。

编程新手? 不要怕! (New to Programming? Fear Not!)

If you are new to programming and are not yet comfortable with coding, you may want to check out ZenBase that is built on the top of the phpGrid. The Inventory Management System is but one of the many application templates readily available at ZenBase for anyone — with or without coding skills — to use and customize for their own needs.

如果您是编程新手,但对编码还不满意,则可能需要查看phpGrid顶部构建的ZenBase。 库存管理系统只是ZenBase上随时可用的众多应用程序模板之一,无论具有或没有编码技能的任何人都可以使用和定制他们自己的需求。

在线演示 (Online Demo)

  • Current Inventory

    当前库存

  • Incoming Purchases

    进货

  • Outgoing orders

    待发订单

  • Reports (with datagrid side-by-side)

    报告 (与datagrid并排)

下一步:添加条形码扫描仪 (Next: Add the barcode scanner)

Add the barcode scanner to our inventory management system

将条形码扫描仪添加到我们的库存管理系统

在Github上下载源代码 (Download Source Code on Github)

phpcontrols/inventory-managerSource code of inventory-manager the awesome Inventory Management Application in PHP and MySQL from Start to Finishgithub.com

phpcontrols / inventory-manager清单管理器的 源代码, 从头到尾 都是PHP和MySQL中很棒的清单管理应用程序 github.com

常见问题: (Common Issue:)

Fatal error: Uncaught Error: Class ‘phpGrid\C_DataGrid’ not found

致命错误 :未捕获的错误:找不到类'phpGrid \ C_DataGrid'

How to fix:If you are using the free Lite version, you can either comment out the first line

解决方法:如果您使用的是免费的Lite版本,则可以在第一行中注释掉

// use phpGrid\C_DataGrid;

— OR —

- 要么 -

Add a global namespace symbol — single backslash — BEFORE the constructor

在构造函数之前添加一个全局名称空间符号-单反斜杠

$dg = new \C_DataGrid(“SELECT * FROM orders”, “orderNumber”, “orders”);

您可能也对那些教程感兴趣: (You may be also interested in those tutorials:)

Build a Project Management Application From ScratchWhat is a Project Management Application?Build a Simple CRM from Start to Finish Customer Relationship Management (CRM) is a system that manages customer interactions and data throughout the customer…Building a Donation Manager from Scratch in PHP

从头开始构建项目管理应用程序 什么是项目管理应用程序? 从头到尾构建简单的CRM 客户关系管理(CRM)是一个系统,可管理整个客户之间的客户交互和数据… 使用PHP从头开始构建捐赠管理器

谢谢阅读。 如果您喜欢这篇文章,请点击那个拍手按钮? 帮助其他人找到它,并在Twitter上关注我。 (Thanks for reading. If you enjoyed this article, please hit that clap button ? to help others find it and follow me on Twitter.)

您想看更多类似的教程吗? 发送请求到我的Twitter或在下面发表评论! (Would you like to see more tutorials like this? Send a request to my Twitter or leave a comment below!)

翻译自: https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/

mysql管理应用

mysql管理应用_如何在PHP和MySQL中制作出色的库存管理应用程序相关推荐

  1. 如何在 Adob​e Photoshop 中制作拉伸的风景?

    原标题:Adobe认证指南|如何在 Adob​e Photoshop 中制作拉伸的风景?(来源:Adobe国际认证中文网站_Adobe认证专家官网) 第1步:扩展天空. 选择扩展菜单中的顶部的内容. ...

  2. 2008 mysql 本地安全_如何在Linux系统中建立mysql的本地安全机制?

    如何在Linux系统中对MySQL进行本地的安全机制?今天我们将给大家介绍下具体的操作方法. local-infile=0#关闭远程连接,即3306端口.这是LinuxMySQL的默认监听端口.由于此 ...

  3. hibernate mysql 外键_如何在hibernate中设置关联会在数据库中生成外键

    hibernate学习笔记(三) hibernate的一些杂记:1.sessionFactory的用法:SessionFactory是线程安全的,构造 SessionFactory 很消耗资源sess ...

  4. mysql路径查找_如何在MySQL的具有文件路径的列中查找和替换?

    为此,请使用MySQL REPLACE().让我们首先创建一个表-mysql> create table DemoTable ( FolderLocation text ); 使用插入命令在表中 ...

  5. mysql计算秒_如何在MySQL中基于秒计算时间?

    让我们首先创建一个表-mysql> create table DemoTable ( Logouttime time ); 使用插入命令在表中插入一些记录-mysql> insert in ...

  6. docker mysql数据库初始化_如何在Mysql的Docker容器启动时初始化数据库

    1.前言 Docker在开发中使用的越来越多了,最近搞了一个Spring Boot应用,为了方便部署将Mysql也放在Docker中运行.那么怎么初始化 SQL脚本以及数据呢? 我这里有两个传统方案. ...

  7. 注册mysql确认邮件_如何在MySQL中使用电子邮件ID选择@之前的所有内容?

    使用SUBSTRING_INDEX选择电子邮件ID中@之前的所有内容-select substring_index(yourColumnName,'@',1) from yourTableName; ...

  8. 谷歌play更新_如何在Google Play音乐中管理播客

    谷歌play更新 Hey, did you know that the Google Play Music app that comes with your Android phone can sub ...

  9. 符号在excel中的引用_如何在Excel工作表中添加表情符号

    &符号在excel中的引用 In the old days, we typed emoticons in our messages, to show a grin, or wink, etc. ...

最新文章

  1. 百度站长工具进击site结果页面[SITE特型]
  2. java question_Core Java Question List No3
  3. Linux操作系统Ubuntu部署Oracle篇
  4. 如何当好PM?请求大家积极讨论
  5. hdu-3015 Disharmony Trees---离散化+两个树状数组
  6. Idea 设置Eclipse快捷键(常用)
  7. 别人家的工程师:阿里巴巴工程师有了新帮手,AI可帮助修Bug
  8. C++新特性探究(十二):static_assert(提前判误)
  9. T-SQL查询进阶—理解SQL Server中的锁
  10. JB的Python之旅-爬虫篇--requestsScrapy
  11. 【数学建模】相关软件
  12. CDA LEVEL I分数占比解读,看懂这些,考试更容易拿分
  13. PowerShell路转粉之造轮子(01)------B站离线缓存简单合并blvm4s
  14. CKEditor5系列二:创建简单插件
  15. Drupal独到的编程思想
  16. HTML5七夕情人节表白网页(蓝色背景3D相册) HTML+CSS+JS 求婚 html生日快乐祝福代码网页 520情人节告白代码 程序员表白源码 3D旋转相册 js烟花代码 css爱心
  17. 【机器学习】基于生成对抗网络的黑白图片上色
  18. 第一章:你的编程入门了吗?养成良好的编程思维
  19. 免疫系统与冠状病毒之争:抗体水平下降时,T细胞会支持你
  20. linux pdf 加水印,将动态水印添加到PDF

热门文章

  1. 异常的捕获 try...catch java
  2. 访问修饰符 c# 1613703072
  3. PHP设计模式之抽象工厂模式
  4. 生成子集——位向量法
  5. zabbix 启动报cannot connect to Service Manager: [0x00000005]解决方法
  6. css3 之表格隔行分色显示
  7. WPF依赖属性(续)(1)
  8. IronPython 与C#交互
  9. SpringBoot调用RESTful Web服务
  10. Tomcat8史上最全优化实践