keropok lekor sales and stock forecast system using … · 2020. 7. 16. · this is to confirm that...
TRANSCRIPT
i
KEROPOK LEKOR SALES AND STOCK FORECAST SYSTEM USING
WEIGHTED MOVING AVERAGE METHOD
NUR ATHIRAH BINTI FAZILAH
BACHELOR OF COMPUTER SCIENCE
(SOFTWARE DEVELOPMENT) WITH HONOURS
FACULTY OF INFORMATIC AND COMPUTING
UNIVERSITI SULTAN ZAINAL ABIDIN
JULY 2020
ii
DECLARATION
This dissertation submits as a partial fulfilment for the award of a Bachelor of
Computer Science (Software Development) with Honours at the University Sultan
Zainal Abidin (UniSZA), Terengganu, Malaysia. This work is a result of my
investigation. All section of the text and results, which have been obtaining from
other sources are fully referenced.
___________________________
Name : Nur Athirah Binti Fazilah
Date : …………………………...
iii
CONFIRMATION
This is to confirm that this final year project entitled Keropok Lekor Sales and
Stock Forecast System using Weighted Moving Average Method has been prepared
and submitted by Nur Athirah Binti Fazilah with matric number BTAL17046179
and has found satisfactory in terms of scope, quality, and presentation as a part of
the requirement for the Bachelor of Computer Science in Software Development in
University Of Sultan Zainal Abidin (UniSZA). The research conducted and the
writing of this report was under my supervision.
____________________________
Name : Mr. Abd Rasid Bin Mamat
Date : …………………………….
iv
DEDICATION
I would like to express my deepest appreciation to all who provided me the
possibility to completing my final year project Keropok Lekor Sales and Stock
Forecast System using Weighted Moving Average Method successfully. A special
gratitude goes to my supervisor, Mr. Abd Rasid Bin Mamat for guiding me in the
development of this project. My warmest gratitude for my Final Year Project panels
for aiding my system and giving the feedback and valuable guidance.
I take this opportunity to thank my parents and my family for giving moral support
and encouragement. Special thanks to all lectures under Faculty of Informatics and
Computing for their attentions, guidance and advice in developing this project. I,
sincere thanks to my fellow friends for their help in finishing this project.
v
ABSTRACT
D’no Corner Keropok Lekor is a small industrial company produce, sells and
supplies keropok lekor that located in Kuala Terengganu. D’no Corner Keropok
Lekor manages its business manually like most other small businesses. In order to
help this company expands their business, this system is created to meet the
demands of today’s market as technology advances towards Industrial Revolution
4.0.
Due to the fact that this business process is being run manually, it is difficult for
the company to run the data recording process. Businesses need to record every
stock inventory that has been produced and also record the sales and orders from
customers. It is difficult for the company to estimate the quantity of each product
produced each month. The estimation of product is very crucial to avoid excessive
production and ensure the supply is always sufficient in meeting customers' needs.
To overcome the problems faced, methods and techniques that can be used to solve
the problem are by using Weighted Moving Average Method. By using this
technique, sequence of data points measured and analysed in intervals of weekly,
monthly, quarterly or yearly. This analysis of time series in past can be used to
make decisions and predict future trends. It will predict the amount of production
vi
that must be produced by the company with the appropriate amount and be able to
avoid excess or deficiency in production.
vii
ABSTRAK
D'no Corner Keropok Lekor adalah syarikat perindustrian kecil yang
menghasilkan, menjual dan membekalkan keropok lekor yang terletak di Kuala
Terengganu. D'no Corner Keropok Lekor mengurus perniagaannya secara manual
seperti kebanyakan perniagaan kecil lain. Untuk membantu syarikat ini
mengembangkan perniagaan mereka, sistem ini diwujudkan untuk memenuhi
permintaan pasaran hari ini sebagai kemajuan teknologi ke arah Revolusi Industri
4.0.
Oleh kerana proses perniagaan ini dijalankan secara manual, sukar bagi syarikat
untuk menjalankan proses merekod data. Perniagaan perlu merekodkan setiap
inventori stok yang telah dihasilkan dan juga merekodkan jualan dan pesanan dari
pelanggan. Adalah sukar untuk syarikat menganggarkan kuantiti setiap produk
yang dihasilkan setiap bulan untuk mengelakkan pengeluaran yang berlebihan dan
memastikan bekalan sentiasa mencukupi untuk memenuhi keperluan pelanggan.
viii
Untuk mengatasi masalah yang dihadapi, kaedah dan teknik yang boleh digunakan
ialah “Weighted Moving Average Method”. Dengan menggunakan teknik ini,
urutan titik data diukur dan dianalisa dalam selang mingguan, bulanan, suku
tahunan atau tahunan. Analisis masa ini boleh digunakan untuk membuat
keputusan dan meramalkan trend masa depan. Ia akan meramalkan jumlah
pengeluaran yang mesti dihasilkan oleh syarikat dengan jumlah yang sesuai dan
dapat menghindari kelebihan atau kekurangan dalam pengeluaran.
ix
TABLE OF CONTENTS
DECLARATION ......................................................................ii
CONFIRMATION ...................................................................iii
DEDICATION ......................................................................... iv
ABSTRACT.............................................................................. v
ABSTRAK.............................................................................. vii
LIST OF FIGURES ................................................................ xii
LIST OF TABLES .................................................................. xv
CHAPTER 1 ............................................................................. 1
INTRODUCTION..................................................................... 1
1.1 Introduction......................................................................................... 1
1.2 Problem Statement ................................................................................ 2
1.3 Objective .............................................................................................. 3
1.4 Scope .................................................................................................... 3
1.4.1 Admin ............................................................................................. 4
1.4.2 Employee ........................................................................................ 4
1.4.3 Customer ........................................................................................ 5
1.5 Implementing and Planning ................................................................... 6
1.6 Limitation of Works .............................................................................. 8
1.7 Expected Result ....................................................................................... 8
CHAPTER 2.................................................................................................... 9
LITERATURE REVIEW................................................................................ 9
2.1 Introduction .......................................................................................... 9
2.2 Related Research Techniques and Tools ................................................10
2.3 Weighted Moving Average Method ......................................................13
2.4 Summary .............................................................................................14
CHAPTER 3.................................................................................................. 15
METHODOLOGY ........................................................................................ 15
3.1 Introduction .........................................................................................15
3.2 Iterative Model.....................................................................................15
3.3 Methodology Phase ..............................................................................16
3.3.1 Initial P lanning Phase.......................................................................17
x
3.3.2 Planning Phase ................................................................................17
3.3.3 Analysis and Design Phase ...............................................................17
3.3.4 Implementation Phase .......................................................................18
3.3.5 Testing Phase....................................................................................18
3.3.6 Deployment and Evaluation Phase....................................................19
3.4 Hardware and Software Requirement ....................................................19
3.4.1 Software Requirement.......................................................................19
3.4.2 Hardware Requirement .....................................................................21
3.5 Example of Implementation on Data and Calculation for Forecasting by
Using Weighted Moving Average Method .....................................................22
3.6 Context Diagram ..................................................................................24
3.7 Data Flow Diagram ..............................................................................25
Data Flow Diagram Level 0 ..........................................................................25
Data Flow Diagram Level 1 ..........................................................................28
3.8 Entity Relationship Diagram .................................................................31
3.9 Data Dictionary.......................................................................................32
Table Employee............................................................................................33
Table Product ...............................................................................................34
Table Purchase .............................................................................................34
Table Order ..................................................................................................36
Table Payment ..............................................................................................36
Table Product Detail .....................................................................................37
Table Position Detail.....................................................................................38
CHAPTER 4.................................................................................................. 39
IMPLEMENTATION ................................................................................... 39
4.1 Introduction........................................................................................39
4.2 Implementation of System ...................................................................39
4.3 Programming Language ......................................................................40
4.4 Interface Design ................................................................................40
CHAPTER 5.................................................................................................. 69
TESTING AND RESULT ............................................................................. 69
5.1 Introduction ............................................................................................69
5.2 Testing Analysis .....................................................................................70
5.3 Test Case ................................................................................................70
5.4 Chapter Summary ...................................................................................77
xi
CHAPTER 6.................................................................................................. 78
RESULT AND CONCLUSION .................................................................... 78
6.1 Introduction .........................................................................................78
6.2 Project Contribution ............................................................................78
6.3 Result Discussion ................................................................................79
6.4 Project Constraints And Limitation .......................................................79
6.5 Future Work........................................................................................79
6.6 Conclusion ..........................................................................................80
REFERENCES.............................................................................................. 81
APPENDIX A ................................................................................................ 83
SOURCE CODE : IMPLEMENTATION OF WEIGHTED MOVING
AVERAGE METHOD .................................................................................83
xii
LIST OF FIGURES
NO FIGURE TITLE PAGE
3.1 Iterative Model 16
3.2 Context Diagram 24
3.3 Data Flow Diagram Level 0 for Admin 25
3.4 Data Flow Diagram Level 0 For Employee 26
3.5 Data Flow Diagram Level 0 for Customer 27
3.6 Data Flow Diagram Level 1 For Manage Product 28
3.7 Data Flow Diagram Level 1 For Manage Employee 29
3.8 Data Flow Diagram Level 1 For Manage Order 30
3.9 Entity Relationship Diagram 31
4.1 Login Interface 41
4.2 Home Interface 42
4.3 Walk in Purchase 43
4.4 Point of Sale 44
4.5 Confirm Payment 44
4.6 New Online Order 45
4.7 Verify Payment 46
4.8 Transaction Details 47
4.9 Print Transaction Details 47
xiii
4.10 Manage Employee 48
4.11 Add New Employee 49
4.12 Edit Employee Details 49
4.13 Manage Product 50
4.14 Add New Product 51
4.15 Edit Product Details 52
4.16 Daily Sales and Stock Report 52
4.17 Sales and Stock Report 53
4.18 Forecasting Sales 53
4.19 Edit Account Info 54
4.20 Walk in Purchase 55
4.21 Point of Sale 56
4.22 Confirm Payment 56
4.23 Print Transaction Details 57
4.24 Manage Product Details 58
4.25 Manage Details 59
4.26 Customer Homepage 60
4.27 Customer Register 60
4.28 Customer Login Page 61
4.29 Home 62
4.30 Profile Details 62
4.31 Edit Profile Details 63
4.32 View Product 64
4.33 Add To Cart 64
4.34 Payment Process 65
xiv
4.35 Upload Receipt 66
4.36 Current Status 66
4.37 Purchase History 67
4.38 About 67
xv
LIST OF TABLES
NO TABLE TITLE PAGE
1.1 Gannt Chart 6
3.4.1 Software Requirement 19
3.4.2 Hardware Requirement 21
3.5.1 Demand for Defence Machinery 22
3.9.1 Table Employee 33
3.9.2 Table Customer 33
3.9.3 Table Product 34
3.9.4 Table Purchase 35
3.9.5 Table Order 36
3.9.6 Table Payment 37
3.9.7 Product Detail 37
3.9.8 Position Detail 38
5.1 Test Case Fail Login 71
5.2 Test Case Admin Success Login 72
5.3 Test Case Employee Success Login 72
5.4 Test Case Customer Success Login 73
xvi
5.5 Test Case Add New Employee 73
5.6 Test Case Update Employee Details 74
5.7 Test Case Add New Product 74
5.8 Test Case Update Product Details 74
5.9 Test Case Delete Product 75
5.10 Test Case Walk in Purchase 75
5.11 Test Case Customer Purchase 76
xvii
LIST OF APPENDIX
APPENDIX TITLE PAGE
A SOURCE CODE : IMPLEMENTATION OF 91
WEIGHTED MOVING AVERAGE METHOD
xviii
ABBREVIATION
CD Context Diagram
DFD Data Flow Diagram
ERD Entity Relationship Diagram
SDLC Software development Life
Cycle
1
CHAPTER 1
INTRODUCTION
1.1 Introduction
Keropok lekor is one of the well-known traditional Malay snacks originated
from east coast Malaysia which is Terengganu. Keropok lekor are made of fish
usually wolf herring or mackerel with a combination of salt and sago flour. This
mixture will be hand rolled into shape of long tubes similar to sausage or cut into
thin slices and immediately cooked in deep fried or boiled.
Numerous of keropok lekor stalls can be easily found along the road in
Terengganu and most of the business have been run traditionally or manually. D’no
Corner Keropok Lekor is a small industrial company produce, sells and supplies
keropok lekor that located in Kuala Terengganu. In order to help this company
expands their business, this system is created to meet the demands of today’s
market as technology advances towards Industrial Revolution 4.0.
2
D’no Corner Keropok Lekor runs it business manually like most other small
businesses. The process involved in this business is the sales of keropok lekor and
record the inventory of keropok lekor. In this system, it proposed to use weighted
moving average method technique to predict the amount of sales and production
that needs to be produced based on current trends.
1.2 Problem Statement
From investigation, there are a few problems that encountered by D’no
Corner Keropok Lekor: -
1.2.1 Difficulties for the customer to place an order
D’no Corner Keropok Lekor only runs direct selling and it make it harder for
customer if they want to place an order or do reservation. Customer need to directly
contact the owner by telephone that will cause miscommunication or loss
information with the employee during the process. This company manually record
the booking information in their booklet. This manual way can cause company’s
manager to be misled and misinformed by the customer.
1.2.2 Difficulties in estimating sales and production of keropok lekor.
The increase in orders monthly will affect keropok lekor productions. The
higher the orders, the higher sales they will earn. So, this company need a method
to estimate how much keropok lekor they need to produce every month to make
3
sure that they don’t produce excessive or lack of production based on product sales
data of previous months.
1.3 Objective
The objectives of this projects are as following: -
1.2.3 To design a process flow, structure of user interface and database for
Keropok Lekor Sales and Stock Forecast System.
1.2.4 To develop a system that can manage users order and a system that can
estimates sales and stock of keropok lekor.
1.2.5 To test the capabilities of the Keropok Lekor Sales and Stock Forecast
System and generate the report to the user.
1.4 Scope
Scope can describe as the functionality of a system that relates to activities
between system user and system, which is the information that flows between
system and actors outside of the system. The scope of Keropok Lekor Sales and
Stock Forecast System is Admin, Employee and Customer of D’no Corner Keropok
Lekor.
4
1.4.1 Admin
i. Login
ii. Manage profile
iii. Manage stock
iv. Manage stock prediction
v. Manage sales prediction
vi. Manage cash purchase
vii. View report
viii. Logout
1.4.2 Employee
i. Login
ii. Manage profile
iii. Manage stock
iv. Manage order
v. Verify transaction
vi. Manage cash purchase
vii. View report
viii. Logout
5
1.4.3 Customer
i. Login
ii. Manage profile
iii. View keropok lekor detail
iv. Make order
v. Make payment
vi. Logout
6
1.5 Implementing and Planning
Gannt chart are used to describe activities and timescale that involve in
implementing this project as shown in Table 1.1.
Table 1.1: Gannt Chart
No Task Week
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 FYP Briefing and
discuss project title
2 Project Title Proposal and
Registration
3 Proposal Writing –
Introduction (Chapter 1)
4 Proposal Writing -
Literature Review (Chapter 2)
5 Proposal Writing Progress
6 Proposal Progress Presentation and Panel’s Evaluation
7 Methodology Workshop
8 Proposal Writing – Methodology
Proof Of Concept (Chapter 3)
7
9 Final Year Project
Format Writing Workshop
10 Drafting Report of
Proposal
11 Submit draft
proposal report to supervisor
12 Preparation for Final Presentation
13 Final Presentation
and Panel’s Evaluation
14 Final Report
Submission and Supervisor’s Evaluation
8
1.6 Limitation of Works
This system only allow admin to view and manage the stock and sales
prediction. Place an order on system only can be done by user and only employee
can manage order and verify transaction.
1.7 Expected Result
The expected results of this project are to facilitate three parties which is
user, admin and employee in manage the keropok lekor order and view the keropok
lekor sales, forecast stock and stock production. This project has been designed to
keep in view the present and future necessities in mind to make it adaptable.
The goals that are achieved by the system are:
i. Be user friendly and flexible by allowing customers to view and place order
online.
ii. Improved productivity by allow employee to manage customers order, verify
transaction and view sales and stock forecast.
iii. Ease admin to manage stock and manage sales and stock forecast to avoid
excessive or lack of keropok lekor production.
9
CHAPTER 2
LITERATURE REVIEW
2.1 Introduction
Forecasting can be viewed as a systematic approach used to analyse the trend
of historical sales data on future demand for projects as a framework for long-term
strategic preparation and as a consideration for several capacity-related decisions.
In this chapter, there are a few ideas of previous research that related to the method
on forecasting compared to make clear description of weighted average square
method as an added value in this system. There are so many techniques used to
make precise forecasts, but each method is different for different market strategies.
10
2.2 Related Research Techniques and Tools
A review of the research paper has been conducted to study on how others
implemented the weighted moving average method and other similar forecasting
techniques into their system. As a result, a few research papers have been found.
The first article is conduct by author [1], the research stated that in retail stage
of food supply chain, food waste and stock-outs occur mainly due to inaccurate
forecasting of sales which leads to incorrect ordering of products. The time series
sales in food retail industry are characterized by high volatility and skewness,
which vary by time. So, the interval forecasts are required by the retail companies
to set appropriate inventory policy (reorder point or safety stock level). This paper
attempts to develop a seasonal autoregressive integrated moving average with
external variables (SARIMAX) model to forecast daily sales of a perishable food.
The process of fitting a SARIMAX model in this study involves: (i) the
development of Seasonal Autoregressive Integrated Moving Average (SARIMA)
model and (ii) combining the SARIMA model and the demand influencing factors
using linear regression.
In study of retail unit in the city of João Pessoa by [2] state that it is known
that inventories are one of the key points in retail, in view of their management
directly impacts the level of service that the companies provide. While author [3]
also experiences same problems in predicting the number of products that must be
11
bought to suppliers every month to make sure that is no excessive or less in number
of stock in the Gajah Bintang Company. The importance of inventory management
is to balance the supply and demand of items, in order to reduce the capital retained
in items that do not present demand for their consumption. Both of this works was
assisted by Weighted Moving Average Method that is essential, given that past data
show future sales projections.
The next author [4] applied that there are methods and techniques that can be
used to solve the problem are by using time series modelling that is data with a
pattern or trend. There are two stages in time series modelling that is Univariate
Forecasting for one variable and Multivariate Forecasting for many variables. This
project will use Univariate Forecasting because it will forecast one variable from
trend alone in forecasting techniques. The study conducted by [5] implied that
methodologies that have been used in sales forecasting are typically time series
algorithms that can be classified as linear or nonlinear, depending on the nature of
the model they are based on. Linear models, like autoregressive moving average
(ARMA) and autoregressive integrated moving average are the most popular
methodologies, but their forecasting ability is limited by their assumption of a linear
behaviour and thus, it is not always satisfactory. The author [6] reveal that
exponential smoothing method which results to least forecast error is the best
method to determine accurate demand forecasts using 12 monthly sales figures of
a moderate busy pharmacy. Author concluded that the exponential weighted
moving average was preferred compared to the simple and linear weighted moving
average [7].
12
Even though the performance of the EWMA method significantly decreases
when applying to forecast data, it is most suitable for short-range forecasting.
Exponentially Weighted Moving Average (EWMA) method to forecast lime prices
during January 2016 to September 2016 gives the smallest forecasting error
measured by the Mean Absolute Percentage Error (MAPE) [8]. Forecasting has
always been an attractive research area since it plays an important role in business
planning. To achieve competitive advantage in an environment subject to constant
fluctuations, organizations have to make correct and timely decisions based on
accurate information-forecast [6].
13
2.3 Weighted Moving Average Method
A time series is a sequence of data points usually measured and analysed in
intervals of weekly, monthly, quarterly or yearly. This analysis of time series in past
can be used to make decisions and predict future trends.
One method that can be used to predict the time series is (WMA). Weighted
Moving Average Method gives you a weighted average of the last n prices by putting
more weight on recent data and less on past data.
The WMA is calculated by multiplying each bar’s price by its associated
weighting factors and totalling the values.
The formula for the WMA is as follows:
WMAs can have different weights assigned based on the number periods
used in the calculation. Because of its unique calculation, WMA will follow prices
more closely than a corresponding Simple Moving Average.
WMA = (Price * weighting factor) + (Price previous period * weighting factor-1) + … (1)
14
2.4 Summary
In conclusion, it is very crucial in choosing the correct method to ensure that
the system has successfully implemented and accomplished the purpose. The
technique selected is the Weighted Moving Average Method that can correctly
forecast the keropok lekor sales and stock since it has more accurate measure of
recent price action.
15
CHAPTER 3
METHODOLOGY
3.1 Introduction
Methodology is the set of the complete guideline that includes the Software
Development Life Cycle (SDLC) tool models for carrying out activities. That splits
the work into the phases of the operation for improved system development
planning and management.
3.2 Iterative Model
The methodology that will be used in developing Keropok Lekor Sales and
Forecasting System Using Weighted Moving Average Method is Iterative Model.
This model is driven by the risk analysis and evaluation requirements and keeps on
iterating, covering each phase of the model repeatedly,
16
until the final products produced satisfy all the requirements that were evolved
before and during the development process.
There are six phases involved in the iterative model which is initial planning
phase, planning phase, analysis and design phase, implementation phase, testing
phase, deployment and evaluation phase.
Figure 3.1: Iterative Model
3.3 Methodology Phase
The explanation of each phase involves for developing Keropok Lekor Sales
and Forecasting System Using Weighted Moving Average Method as below: -
17
3.3.1 Initial Planning Phase
This phase involves brainstorming the project idea and proposed the title of
project. Keropok Lekor Sales and Forecasting System Using Weighted Moving
Average Method has been decided as the project title.
3.3.2 Planning Phase
Planning phase is the most crucial phase as a guideline to develop the system.
In this phase, requirement is gathered through consistent interaction with D’no
Corner Keropok Lekor owner. All resources like product information, sales details
and business income are collected by interview the owner to make sure this system
meet the system requirement and functionality requirement. Clear project has been
sort out during this phase. To make sure this system follows the timeline, schedule
has been made which is Gantt chart to make sure that this project still on track and
can be done on estimate time.
3.3.3 Analysis and Design Phase
In analysis phase, review on few research paper and journal has been
conducted to study on how others implemented the Weighted Moving Average
Method and other similar forecasting techniques into their system. This will give
better understanding on selected forecasting technique compare to technique that
has been used by other researchers. Weighted Moving Average Method was
18
decided to be the approach in this project. Methodology, technique, software and
hardware requirement are also decided during this phase to ensure that every
requirement are compatible with the system.
Design phase of this system is done based on output of analysis phase. The
Context Diagram (CD), Data Flow Diagram (DFD), and Entity Relationship
Diagram (ERD) are designed at this phase to interpret the process flow of Keropok
Lekor Sales and Forecasting System. System interface and database are design
based on requirement.
3.3.4 Implementation Phase
This is a phase where activities that have been planned during previous phase
are executed. This system is developed by using XAMPP, MySQL and Notepad++.
During this phase, database and interface that has been designed are started to be
developed. The process of writing coding is started during this phase.
3.3.5 Testing Phase
After system has fully developed, testing is being done on the system. for this
system, white box and white box testing has been used which this system is
repeatedly tested to ensure that it is working correctly and there is no bug in that
module. In this phase, code and programming are analyse to make sure it works
according to customer requirements. And while it's not possible to solve all the
19
failures that might find during the testing phase, it is possible to use the results from
this phase to reduce the number of errors within the software program.
3.3.6 Deployment and Evaluation Phase
In this phase, the system is ready to be tested by user. The users will evaluate
this system and give their feedback based on their experienced. The evaluation will
be use to improve the system whether changes are needed to make sure that it
fulfills all the requirements.
3.4 Hardware and Software Requirement
Hardware and software play a major role in the development of a system as
a standard requirement that determines the system's achievement. To build a
successful system, this standard requirement relates to one another.
3.4.1 Software Requirement
Table 3.4.1: Software Requirement
Software Description / Purpose
Microsoft Office Word 2016
Use to prepare documentation of the report
Draw.io An online software use to draw Context
Diagram and Data Flow Diagram
20
PHPMyAdmin A database system to create Entity
Relationship Diagram
Google Drive Storage system use to backup all project
document
Microsoft Powerpoint 2016 Use to prepare slide presentation
21
3.4.2 Hardware Requirement
Table 3.4.2: Hardware Requirement
Hardware Type
HP Laptop Windows edition: Windows 10 Home
Single Language
Processor: AMD A6-9220 RADEON
R4, 5 COMPUTE CORES 2C+3G
2.5GHz
Installed memory (RAM): 4.00GB
System type: 64-bit Operating System
22
3.5 Example of Implementation on Data and Calculation for
Forecasting by Using Weighted Moving Average Method
Table 3.5.1 shows the demand for defence machinery for a certain project for
month 1 to 5. The implementation of Weighted Moving Average Method on
forecasting are as following: -
Table 3.5.1: Demand for Defence Machinery
Determine the weighted moving average equation.
To simplify the calculations, as shown in Table 3.5.1, each year will have its
own weightage, which is more weight on recent data and less on past data. WMA are
calculated by multiplying each bar’s price by its associated weighting factors
and totalling the values.
Implementation of the WMA method can be shown as below: -
Month Demand Weightage
1 120 5/15
2 110 4/15
3 90 3/15
4 115 2/15
5 125 1/15
23
From this example, demand of defence machinery for month 6 is 142.
WMA = (Price * weighting factor) + (Price previous period * weighting factor-1) + … (1)
WMA = (120× 5
15 ) + (110×
4
15) + (90×
3
15) + (115×
2
15) + (125×
1
15)
= 142
24
3.6 Context Diagram
Figure 3.2 shows context diagram for Keropok Lekor Sales and Stock
Forecast System using Weighted Moving Average Method. There are 3 entities
involve in this context diagram which is ADMIN, EMPLOYEE and CUSTOMER.
Employee
Figure 3.2 : Context Diagram
25
3.7 Data Flow Diagram
Data Flow Diagram Level 0
Based on Figure 3.3 below, there are six processes involve in Admin module,
where Admin can log in as a first step to get into the system. After login, Admin
can Manage Profile, Manage Stock, Manage Stock Prediction, Manage Sales,
Manage Cash Purchase and Generate Report from the system. At the end of
process, Admin can log out from the system.
Figure 3.3 : Data Flow Diagram Level 0 for Admin
Employee
26
Based on Figure 3.4 below, there are six processes involve in Employee
module, where Employee can log in as a first step to get into the system. After
login, Employee can Manage Profile, Manage Stock, Manage Order, Verify
Transaction, Manage Cash Purchase and Generate Report from the system. At the
end of process, Employee can log out from the system.
Figure 3.4 : Data Flow Diagram Level 0 For Employee
Employee
Employee
27
Based on Figure 3.5 below, there are three processes involve in Customer
module, where Customer can log in as a first step to get into the system. After login,
Customer can Manage Profile, Make Order and Make Payment. At the end of
process, Customer can log out from the system.
Figure 3.5 : Data Flow Diagram Level 0 for Customer
28
Data Flow Diagram Level 1
Based on Figure 3.6 below, there are four processes involve in Manage
Product. Admin can register new product, update products details, remove product.
Admin and Employee share the role to update or add the new quantity of product.
Figure 3.6 : Data Flow Diagram Level 1 For Manage Product
Employee
29
Based on Figure 3.7 above, there are three processes involve in Manage
Employee. Admin can register new employee, update employee profile and remove
employee.
Figure 3.7 : Data Flow Diagram Level 1 For Manage Employee
Employee data Employee information
Employee detail Employee data
New employee info
Employee details
Employee data
Employee
30
Based on Figure 3.8 below, there are three processes involve in Manage
Order. Customer can make a new order, update order and cancel order.
Figure 3.8 : Data Flow Diagram Level 1 For Manage Order
Employee
31
3.8 Entity Relationship Diagram
An entity relationship diagram (ERD) illustrates an information system’s entities
and the relationship between those entities. ERD composed of three things such as
identifying and defining the entities, determine entities interaction and the
cardinality of the relationship. Figure 3.9 below shows the relationship between
entities that exist in this develop system database.
Figure 3.9: Entity Relationship Diagram
Employee
32
3.9 Data Dictionary
Data dictionary is a file or a set of files that contains a database's metadata.
The data dictionary contains records about other objects in the database, other data,
data relationships to other objects, and such as data ownership. The data dictionary
is important component a relational database. For most relational database
management systems (RDBMS), the database management system software needs
the data dictionary to access the data within a database.
1. TABLE employee
2. TABLE customer
3. TABLE product
4. TABLE purchase
5. TABLE order
6. TABLE payment
7. TABLE product detail
8. TABLE position detail
33
Table Employee
Table 3.9.1 shows table for employee. Primary key for this table is
EmployeeID.
Table 3.9.1 : Table Employee
No Column Type Length Null Key
1 EmployeeID varchar 10 No PK
2 employeeName varchar 50 No
3 password varchar 50 No
4 position varchar 12 No
5 phoneNo varchar 12 No
Table Customer
Table 3.9.2 shows table for customer. Primary key for this table is CustID.
Table 3.9.2 : Table Customer
No Column Type Length Null Key
1 custID varchar 10 No PK
34
2 custName varchar 50 No
3 custAddress varchar 100 No
4 phoneNo varchar 12 No
5 password varchar 50 No
Table Product
Table 3.9.3 shows table for product. Primary key for this table is
productID and the foreign key is EmployeeID.
Table 3.9.3 : Table Product
No Column Type Length Null Key
1 productID varchar 10 No PK
2 productname varchar 50 No
3 priceperKg int 5 No
4 image varchar 50 No
5 EmployeeID varchar 10 No FK
Table Purchase
Table 3.9.4 shows table for purchase. Primary key for this table is
purchaseID and the foreign key is EmployeeID, paymentID and custID.
35
Table 3.9.4 : Table Purchase
No Column Type Length Null Key
1 purchaseID varchar 10 No PK
2 EmployeeID varchar 10 No FK
3 paymentID varchar 10 No FK
4 datePurchase date 8 No
5 totalPurchase int 11 No
6 custID varchar 10 No FK
36
Table Order
Table 3.9.5 shows table for order. Primary key for this table is orderID
and the foreign key is EmployeeID, productID and custID.
Table 3.9.5 : Table Order
No Column Type Length Null Key
1 orderID varchar 10 No PK
2 custID varchar 10 No FK
3 productID varchar 10 No FK
4 dateorder date 10 No
5 quantity varchar 11 No
6 EmployeeID varchar 10 No FK
Table Payment
Table 3.9.6 shows table for payment. Primary key for this table is
paymentID and the foreign key is custID.
37
Table 3.9.6 : Table Payment
No Column Type Length Null Key
1 paymentID varchar 10 No PK
2 datepayment date 8 No
3 custID varchar 10 No FK
Table Product Detail
Table 3.9.7 shows table for product detail. Primary key for this table is
productname.
Table 3.9.7 : Product Detail
No Column Type Length Null Key
1 productname varchar 10 No FK
38
Table Position Detail
Table 3.9.8 shows table for position detail. Primary key for this table is
position.
Table 3.9.8 : Position Detail
No Column Type Length Null Key
1 position varchar 10 No FK
39
CHAPTER 4
IMPLEMENTATION
4.1 Introduction
Implementation is the process of executing, performing, or practicing the
method, design or model according to the specification given by the user requirement
in previous chapter. The main aim of this chapter is to show on the flow of the system
during the development process.
4.2 Implementation of System
A few of programming languages has been used in order of developing Keropok
Lekor Sales and Stock Forecast System. Notepad++ version 7.8.1 is a programming
platform that are used for writing the code and Xampp version 1.8.3-5 (v 3.2.2) with
Apache version 2.4.10 are used to run the localhost server.
40
The system interface design is using the bootstrap template from Start Bootsrap.
The serverside programming language is using the Hypertext Preprocessor (PHP) which
is one of widely used programming language by developer. PHP is a tool for making
dynamic and interactive Web Pages and have general purpose scripting language which
can be embedded into HTML.
4.3 Programming Language
PHP – use for form processes
HTML5 – use to design interfaces
4.4 Interface Design
The interface design which will be used for developing the system is shown as
below. The interface is developed from the data decomposition and the system
requirements. This system can be divided into 3 users which us Admin, Employee and
Customer.
4.4.1 Admin
Admin must login to the system before they can access to their module. The
interface for Admin to login into the system as shown in Figure 4.1.
41
4.4.1.1 Login Interface
The security of login interface for admin applied to the double security. This
technique increases the security of the system and avoids the unauthorized user login to
the system. It also ensures the system protects the user information. The first login asks
the employee id and password; the admin page will be fetched. If the employee id and
password are wrong, the system will display an error message such as “Employee ID or
Password Not Registered!”.
Figure 4.1 : Login Interface
42
4.4.1.2 Home
In this module, admin have access to this page. This page display tabs that
show the number of customers, employees and products registered in the system
database.
Figure 4.2 : Home Interface
4.4.1.3 Walk in Purchase
Figure 4.3 below shows walk in purchase page that admin has access to it. This
page allows admin to input number of product that customer buy during walk in
43
purchase. After entering number of products that customer buy, admin will proceed the
process like in Figure 4.4. Figure 4.4 is point of sale, which system will list of the
product that purchased by customer and admin need to input how much customer pay.
The transaction will conclude as success when admin click proceed to payment button
at Figure 4.5 below. In Figure 4.5 need admin to input amount that paid by customer
during walk-in purchase.
Figure 4.3 : Walk in Purchase
44
Figure 4.4 : Point of Sale
Figure 4.5 : Confirm Payment
4.4.1.4 New Order
Figure 4.6 below shows lists of new online order that made by customer. This
interface displays details of new order that made such as, transaction id, product,
45
quantity of product, status whether have been paid or not, customer id, phone number
and customer address. This interface also let admin to verify customer payment that
shows in Figure 4.7. Figure 4.7 shows interface where admin can update order status.
Admin need to change status from “Paid” to “Done” means that the order has been
settled.
Figure 4.6 : New Online Order
46
Figure 4.7 : Verify Payment
4.4.1.5 Transaction
Figure 4.8 below shows lists of transaction that has been made by customer.
This interface displays transaction number, customers name and number of items that
they bought and action that can be made on the list. Admin can print transaction details
when clicking print button. Transaction details will be transform to pdf and can be print
out in Figure 4.9.
47
Figure 4.8 : Transaction Details
Figure 4.9 : Print Transaction Details
48
4.4.1.6 Manage Employee
Figure 4.10 shows the employee details on this system database. Admin have
grant to edit and delete employees account. This interface displays employee first name,
employee email, and phone number. This interface also allows admin to add new
employee to the system database as shown in Figure 4.11. In Figure 4.11 admin need to
enter new employee details to complete the process. When admin click edit button,
admin can edit employee details such as first name, last name, email, gender, phone
number and others as shown in Figure 4.12.
Figure 4.10 : Manage Employee
49
Figure 4.11 : Add New Employee
Figure 4.12 : Edit Employee Details
50
4.4.1.7 Product Details
One of admin scope is manage product. In Figure 4.13 shows the product details.
This interface displays product code, product name, image of product, price of product
per kilogram action that can be made on products. Admin are allowed to add new
product to system database by clicking add new product as shown in Figure 4.14. Admin
need to enter product details to add new product to system database. When click update
button, admin is allowed to update existed product details as shown in Figure 4.15. On
this interface, admin also allowed to delete product that exited in the database.
Figure 4.13 : Manage Product
51
Figure 4.14 : Add New Product
Figure 4.15 : Edit Product Details
52
4.4.1.8 Report
In report function, there are three interfaces which are daily sales and stock
forecast, sales and stock report and forecasting sales interface. Figure 4.16 shows daily
sales report interface. This interface display date, list of product, total in kilogram that
has been sold and total sales. This interface allows admin to search daily total sales
based on product. Admin also can print out the report. On Figure 4.17 shows sales and
stock forecast. In this interface, admin can search total sales and total product sold based
on two intervals of time such as week, month or year. Admin also can print out the
report. While on Figure 4.18, shows forecasting sales interface. This interface is where
this system method was applied. This interface display total current sales based on
selected date and will output forecast sales for next date. Admin can print out this
forecasting table by clicking “Print” button.
Figure 4.16 : Daily Sales and Stock Report
53
Figure 4.17 : Sales and Stock Report
Figure 4.18 : Forecasting Sales
54
4.4.1.9 Manage Profile
Figure 4.19 shows interface for admin to edit own account information. Admin
can edit first name, last name, gender, employee ID, password, email, phone number,
hired date and address.
Figure 4.19 : Edit Account Info
4.4.2 Employee
Admin and employee has similar interface with difference of scope which are
employee cannot access manage employee interface and report interface. Employee are
restricted to the interfaces. Employee need to log in first to the system before access
employee interface as shown in Figure 4.1.
55
4.4.2.1 Home
Employee is permitted to access this interface. The interface involved such as
Figure 4.2. This page display tabs that show the number of customers, employees and
products registered in the system database.
4.4.2.2 Walk in Purchase
Figure 4.20 below shows walk in purchase page that admin has access to it. This
page allows employee to input number of product that customer buy during walk in
purchase. After entering number of products that customer buy, employee will proceed
the process like in Figure 4.21. Figure 4.21 is point of sale, which system will list of the
product that purchased by customer and employee need to input how much customer
pay. The transaction will conclude as success when employee click proceed to payment
button at Figure 4.22 below.
Figure 4.20 : Walk in Purchase
56
Figure 4.21 : Point of Sale
Figure 4.22 : Confirm Payment
57
4.4.2.3 Print Transaction Details
Employee are allowed to manage transaction details which they can view and
print out transaction details that have been made by customers before. Figure involved
such as Figure 4.8 and when employee click on button print it will display like in Figure
4.23.
Figure 4.23 : Print Transaction Details
4.4.2.4 Manage Product Details
One of employee scope is manage product. In Figure 4.13 shows the product
details. This interface displays product code, product name, image of product, price of
58
product per kilogram and action that can be made on products. Employee can update
product details and delete products from this system database in Figure 4.24.
Figure 4.24 : Manage Product Details
4.4.2.5 Manage Details
Figure 4.25 shows interface for employee to edit own account information.
employee can edit first name, last name, gender, employee ID, password, email, phone
number, hired date and address.
59
Figure 4.25 : Manage Details
4.4.3 Customer
Customer can view homepage of this system without need to log in. This
interface display like in Figure 4.26.
4.4.3.1 Customer Homepage
Figure 4.26 below shows customer homepage, where this interface is accessible
to anyone without need to register on log in first. This interface will display Keropok
Lekor Sales and Stock Forecasting System updates, any news or promotions promoted
by system admin.
60
Figure 4.26 : Customer Homepage
4.4.3.2 Customer Register
Figure 4.27 shows register interface for new customer. Customer need to
registered first their account before allowed to log in. Customer have to register their
first name, last name, email, password and others.
Figure 4.27: Customer Register
61
4.4.3.3 Customer Login
In Figure 4.28 below shows login interface for customer that already have
registered account. Customer need to enter email and password and click log in button.
Figure 4.28 : Customer Login Page
4.4.3.4 Home
After log in to the system, customer is allowed to go to home interface like in
Figure 4.29.
62
Figure 4.29 : Home
4.4.3.5 View Profile Details
Figure 4.30 shows profile interface. This interface displays customer id,
password, first name, last name phone number and address. Customer are allowed to
manage their profile details by clicking “Save” button on Figure 4.31.
Figure 4.30 : Profile Details
63
Figure 4.31 : Edit Profile Details
4.4.3.6 Make Online Order
Figure 4.31 shows product that registered by admin. To order the product,
customer need to click button “View Product”, and then Figure 4.32 will be shown. On
Figure 4.32, product code, name and product price are displayed. Customer need to
enter quantity product that they want before proceed to next step.
64
Figure 4.32 : View Product
Figure 4.33 : Add To Cart
65
4.4.3.7 Proceed With Payment
Figure 4.33 shows product that has been added to the cart from previous process.
At this interface, customer can delete product form cart by clicking “Cancel” button.
This interface will display amount that needed to be paid by customer. After that,
customer need to upload receipt payment as shown in Figure 4.34. To upload the receipt,
customer has to click “Pay” button and the receipt will be accepted. If same receipt
uploaded by customer, the system will display message “Sorry the receipt already
exist!” . If receipt are accepted, system will display message “Receipt Accepted” and
current status will be like in Figure 4.35.
Figure 4.34 : Payment Process
66
Figure 4.35 : Upload Receipt
Figure 4.36 : Current Status
4.4.3.8 Purchase History
Figure 4.35 shows all purchase history that have been made by customer. This
interface display purchase id, product name, quantity, price and status of the order.
67
Figure 4.37 : Purchase History
4.4.3.9 About
Figure 4.36 shows information about D’No Corner Keropok Lekor. This
interface displays phone number, address, operation hours and account number of the
company.
Figure 4.38 : About
68
4.5 Chapter Summary
This chapter ensures system develops according to the requirement, the
framework (system modelling) and design are the important factors. Each module
involves in Keropok Lekor Sales and Stock Forecast System Using Weighted Moving
Average Method are described as the data flow. The system builds must be able to be
translated from the DFD and ERD created.
69
CHAPTER 5
TESTING AND RESULT
5.1 Introduction
After this system have been developed, this system will go through testing
process to make sure this system developed according to the functional requirement
state by the user and fulfilled the main objective. Testing process is the process of
executing system with the intends of finding errors. The process involve system testing
are unit testing and environmental testing. This chapter outlines the steps necessary to
verify the system is correctly done and performs to the required specifications. The
system also being tested using black box and white box testing.
70
5.2 Testing Analysis
This system is tested by using two techniques which are a black box testing and
white box testing after the complete implementation. Testing process need to be done
in order to get correct output based on input.
5.2.1 Black Box Testing
The module involves in this testing are :
Login
Manage Employee
Manage Product
Walk in Purchase
5.2.2 White Box Testing
The module involves in this testing are :
Forecast Product
5.3 Test Case
Test case is a process where a system will be test whether it satisfies requirement
and well function. It is also can be said as a set of step-by-step instructions to verify
something behaves as it is required to behave. The process of developing test cases also
71
helps find the problems in the requirement or design of an application. The table below
shows the test cases for several processes of the Keropok Lekor Sales and Stock
Forecast System Using Weighted Moving Average Method.
5.3.1 Login
Table 5.1 : Test Case Fail Login
Step Procedure Expected Result Pass/Fail
1 Go to login page Preview page
loaded
Pass
2 Enter the following details
Username : aaaaa
Password : aaaa1111
Pass
3 Click login button
Message “Invalid
Username and
Password”
Pass
4 Re-enter the correct
username and password
Login page Pass
72
Table 5.2 : Test Case Admin Success Login
Step Procedure Expected Result Pass/Fail
1 Go to login page Preview page
loaded
Pass
2 Enter the following details
Employee ID : admin1
Password : admin
Pass
3 Click login button
Login successful
Display admin
interface
Pass
Table 5.3 : Test Case Employee Success Login
Step Procedure Expected Result Pass/Fail
1 Go to login page Preview page
loaded
Pass
2 Enter the following details
Employee ID : afiqah33
Password : test
Pass
3 Click login button
Login successful
Display employee
interface
Pass
73
Table 5.4 : Test Case Customer Success Login
Step Procedure Expected Result Pass/Fail
1 Go to login page Preview page
loaded
Pass
2 Enter the following details
CustID : ahmad09
Password : password
Pass
3 Click login button
Login successful
Display customer
interface
Pass
5.3.2 Manage Profile
Table 5.5 : Test Case Add New Employee
Step Procedure Expected Result Pass/Fail
1 Click “Add New Employee” Form to add new
employee
Pass
2 Enter new employee details Pass
3 Click “save” button Display success or
fail message
Pass
74
Table 5.6 : Test Case Update Employee Details
Step Procedure Expected Result Pass/Fail
1 Click “Add New Employee” Form to add new
employee
Pass
2 Enter new employee details Pass
3 Click “save” button
Display success or
fail message
Pass
5.3.3 Manage Product
Table 5.7 : Test Case Add New Product
Step Procedure Expected Result Pass/Fail
1 Click “Add New Product” Form to add new
product
Pass
2 Enter new product details Pass
3 Click “save” button
Display success or
fail message
Pass
Table 5.8 : Test Case Update Product Details
Step Procedure Expected Result Pass/Fail
1 Click “Update” button Display list of
registered product
Pass
75
2 Choose product that want to
be update
Form to update
product details
3 Enter new product details Pass
4 Click “Save” button
Display success or
fail message
Pass
Table 5.9 : Test Case Delete Product
Step Procedure Expected Result Pass/Fail
1 Click “Delete” button Display list of
registered product
Pass
2 Choose product that want to
be delete
Display success or
fail message
Pass
5.3.4 Walk in Purchase
Table 5.10 : Test Case Walk in Purchase
Step Procedure Expected Result Pass/Fail
1 Click “Walk in Purchase”
from side bar
Display list of
registered product
Pass
2 Choose product customer
purchase, enter quantity and
click button “Add to Cart”
Pass
76
3 Click “Submit” button once
customer finish buying
Display Purchase
Summary
Pass
4 Click “Proceed To
Payment” when customer
have paid
Display success or
fail message
Pass
5.3.5 Customer Purchase
Table 5.11 : Test Case Customer Purchase
Step Procedure Expected Result Pass/Fail
1 Click “Our Product” from
top bar
Display list of
registered product
Pass
2 Enter quantity of product that
want to purchase and click
“Add to Cart”
Pass
3 After that click “Item in
Cart”
Display Purchase
Summary
Pass
4 Click “Proceed To
Payment” button
Display success or
fail message
Pass
77
5.4 Chapter Summary
The implementation of coding and testing of the system is discussed in this
chapter. For creating the robust and well function system, all test cases must be tested
carefully to ensure the intended result. The main process and the flow of module are
discussed. The system functionally had been tested and evaluated.
78
CHAPTER 6
RESULT AND CONCLUSION
6.1 Introduction
For this chapter, the outcome from the project are discussed and concluded. This
chapter summarized the result of the project contribution, the limitation of this project
and the suggestion for the future work.
6.2 Project Contribution
Keropok Lekor Sales and Stock Forecasting System Using Weighted Moving
Average Method is developed to eases the workload of D’No Corner Keropok Lekor
make a prediction on the upcoming stock production. In addition, it also helps customer
to make an online product order. This system has been achieved the objectives and all
scopes had been fulfilled.
79
The achievement of this project is :
• This system will keep sales transaction details to the database for every purchase
made ease the company to make forecasting.
• It helps company in make a prediction on the upcoming stock to be produce.
• The easier system for ordering products for customer.
6.3 Result Discussion
This project objective is to make sure that it is easier for customer to place order
on product they want. The product number will reduce automatically from the system
database. This system will keep sales transaction details to the database for every purchase
made ease the company to make forecasting. It helps company in make a prediction on the
upcoming stock to be produce.
6.4 Project Constraints And Limitation
There are several problems and limitation while developing this project. These
are the problems and limitations in conducting the study are :
• This system only can allow order and purchase but not contain inventory to know
how many stock available.
6.5 Future Work
80
There a few suggestions that can be made to upgrade the system to be more
efficient in future work. The suggestions that need to be considered are :
• Add functionality on inventory of the product to know how much stock available.
• The product can be group into a few type
6.6 Conclusion
Keropok Lekor Sales and Stock Forecasting System Using Weighted Moving
Average Method is a system of stock prediction as the objectives based on previous
sales record. Based on previous studies and discussion, the suitable approach will be
implemented in this system which is Least Square Method. This system provide an
automated calculation on the next month production that help companies to avoid
exceed of production. Hopefully tis system can help to overcome the problem in order
to make a new production.
81
REFERENCES
[1] Arunraj, N. S., & Ahrens, D. (2015). A hybrid seasonal autoregressive integrated
moving average and quantile regression for daily food sales forecasting. International
Journal of Production Economics, 170, 321-335.
[2] Mendonca, L. K. D. (2019). ANÁLISE DA FORMAÇÃO EXCESSIVA DE
ESTOQUE EM UMA UNIDADE VAREJISTA DA CIDADE DE JOÃO PESSOA.
[3] Yudianto, A. (2019). Sales Forecasting System with Weighted Moving Average On
Gajah Bintang Company (Doctoral dissertation, UNIKA SOEGIJAPRANATA
SEMARANG).
[4] Muhammad Hafizzuddin Bin Nasruddin (2018) , ‘Crisp Stock Forecast System
(CSFoS) Using Least Square Method’ . Universiti Sultan Zainal Abidin, Terengganu,
Malaysia.
[5] Doganis, P., Alexandridis, A., Patrinos, P., & Sarimveis, H. (2006). Time series
sales forecasting for short shelf-life food products based on artificial neural networks
and evolutionary computing. Journal of Food Engineering, 75(2), 196-204.
[6] Obamiro, J. K. (2019). Demand Forecasting and Measuring Forecast Accuracy in a
Pharmacy. Acta Universitatis Danubius. Œconomica, 15(3).
[7] Wagner, J. E., Rahn, J., & Cavo, M. (2019). A Pragmatic Method to Forecast
Stumpage Prices. Forest Science.
82
[8] Booranawong, T., & Booranawong, A. (2017). An exponentially weighted moving
average method with designed input data assignments for forecasting lime prices in
Thailand. Jurnal Teknologi, 79(6).
83
APPENDIX A
SOURCE CODE : IMPLEMENTATION OF WEIGHTED MOVING
AVERAGE METHOD
<?php
include'../includes/connection.php';
include'../includes/sidebar.php';
$query = 'SELECT ID, t.TYPE
FROM users u
JOIN type t ON t.TYPE_ID=u.TYPE_ID WHERE ID =
'.$_SESSION['MEMBER_ID'].'';
$result = mysqli_query($db, $query) or die (mysqli_error($db));
while ($row = mysqli_fetch_assoc($result)) {
$Aa = $row['TYPE'];
if ($Aa=='User'){
?>
<script type="text/javascript">
//then it will be redirected
alert("Restricted Page! You will be redirected to POS");
window.location = "pos.php";
</script>
84
<?php
}
}
?>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h4 class="m-2 font-weight-bold text-primary">Forecasting
Sales </a></h4>
</div>
</br>
<!doctype html>
<html>
<body >
<!-- CSS -->
<link href='jquery-ui.min.css' rel='stylesheet' type='text/css'>
<!-- Script -->
<script src='jquery-3.3.1.js' type='text/javascript'></script>
<script src='jquery-ui.min.js' type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('.dateFilter').datepicker({
dateFormat: "mm-yy"
});
});
</script>
85
<!-- Search filter -->
<form method='post' action=''>
<div class="col-sm-6" style="padding-top: 5px;">
  Start Date <input type='date' class='dateFilter' name='fromDate'
value='<?php if(isset($_POST['fromDate'])) echo $_POST['fromDate']; ?>'>
End Date <input type='date' class='dateFilter' name='endDate'
value='<?php if(isset($_POST['endDate'])) echo $_POST['endDate']; ?>'>
<br><br>
  Time Interval:
<div class="col-sm-9">
<select class="form-control" id="month" name="month">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<br>
<input type='submit' method="POST" name='but_search' class="btn btn-
sm btn-success shadow-sm" class="fas fa-fw fa-graph" value='Show Report'>
<a type="button" class="btn btn-sm btn-warning shadow-sm"
onclick="window.print()"><i class="fas fa-fw fa-download"></i>Print</a>
</div>
86
</div>
</form>
<br><bt>
<!-- Employees List -->
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%"
cellspacing="0">
<thead> <tr>
<th>TOTAL CURRENT SALES (RM)</th>
<th>FORECAST FOR NEXT SALES (RM)</th>
</thead>
</tr>
</div>
</div>
<?php
$month = $_POST['month'];
$emp_query = "SELECT MONTH(transaction.DATE),
transaction.TRANS_D_ID, SUM(transaction.GRANDTOTAL) ,
transaction_details.TRANS_D_ID, transaction_details.PRODUCTS,
SUM(transaction_details.QTY) , transaction_details.PRICE
FROM transaction
INNER JOIN transaction_details
ON transaction.TRANS_D_ID=transaction_details.TRANS_D_ID WHERE 1 ";
87
// Date filter
if(isset($_POST['but_search'])){
$fromDate = $_POST['fromDate'];
$endDate = $_POST['endDate'];
if(!empty($fromDate) && !empty($endDate)){
$emp_query .= " and DATE
between '".$fromDate."' and '".$endDate."' ";
}
}
// Sort
//$emp_query .= " GROUP BY MONTH(DATE)";
$employeesRecords = mysqli_query($db,$emp_query);
// Check records found or not
if(mysqli_num_rows($employeesRecords) > 0){
while($empRecord = mysqli_fetch_assoc($employeesRecords)){
//$TRANS_D_ID = $empRecord['TRANS_D_ID'];
//$DATE = $empRecord['MONTH(transaction.DATE)'];
//$WEIGHT =
$empRecord['1/MONTH(transaction.DATE)'];
//$PRODUCTS = $empRecord['PRODUCTS'];
//$PRICE = $empRecord['PRICE'];
//$QTY = $empRecord['SUM(transaction_details.QTY)'];
$GRANDTOTAL =
$empRecord['SUM(transaction.GRANDTOTAL)'];
//$WMA =
$empRecord['1/MONTH(transaction.DATE)*SUM(transaction.GRANDTOTAL)'
];
//$MONTH =
$empRecord['COUNT(MONTH(transaction.DATE))'];
88
$weight = 1 / $month;
$wma = $weight * $GRANDTOTAL;
echo "<tr>";
echo "<td>". $GRANDTOTAL ."</td>";
echo "<td>". $wma ."</td>";
echo "</tr>";
}
}else{
echo "<tr>";
echo "<td colspan='4'>No record found.</td>";
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
<?php
include'../includes/footer.php';
?>