Download Code – PHP-Based Sales Tracking and Management System
Sales Tracker System
Overview
The Sales Tracker System is a web-based application designed to help businesses track and manage their sales transactions. The main goal of this system is to make sales recording and retrieval easier and more efficient. It features a user-friendly interface built with Bootstrap Framework
What is the Sales Tracker System?
The Sales Tracker System is developed using PHP (Object-Oriented Programming) and MySQL Database
Technologies Used
The system is built using the following technologies:
- XAMPP (Local Server)
- VS Code Editor
- PHP (Programming Language)
- MySQL (Database)
- HTML, CSS, JavaScript
- jQuery and Ajax
- Bootstrap Framework
- AdminLTE Template
- FontAwesome Icons
- DataTables JS Library
- Select2 JS Library
Features and Functionalities
1. Product Management
- Add, edit, view, and delete products.
2. Client Management
- Store, update, view, and delete client details.
3. Sales Management
- Record sales transactions.
- Select multiple products while adding sales.
- Automatic calculation of total amount, payment, and change.
4. Reports
- Generate and print a Monthly Sales Report.
5. User Management
- Add, edit, view, and delete system users.
6. System Settings
- Update system information such as the logo and banner images.
How to Install and Run the System?
Requirements
- Install a local web server like XAMPP.
- Download the Sales Tracker System source code.
Installation Steps
- Enable the GD Library in the
php.ini
file. - Open the XAMPP Control Panel and start Apache and MySQL.
- Extract the downloaded source code.
- Copy the extracted folder and paste it inside the htdocs directory of XAMPP.
- Open a web browser and go to PHPMyAdmin (
http://localhost/phpmyadmin
). - Create a new database named
sts_db
. - Import the provided SQL file (
sts_db.sql
) from the database folder. - Open the system in a web browser by entering:
http://localhost/php-sts/
.
Default Admin Login
- Username:
admin
- Password:
admin123
index PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
<?php ob_start(); ?> <?php require_once('../config.php'); ?> <!DOCTYPE html> <html lang="en" class="" style="height: auto;"> <?php require_once('inc/header.php') ?> <body class="sidebar-mini layout-fixed control-sidebar-slide-open layout-navbar-fixed sidebar-mini-md sidebar-mini-xs text-sm" data-new-gr-c-s-check-loaded="14.991.0" data-gr-ext-installed="" style="height: auto;"> <div class="wrapper"> <?php require_once('inc/topBarNav.php') ?> <?php require_once('inc/navigation.php') ?> <?php if($_settings->chk_flashdata('success')): ?> <script> alert_toast("<?php echo $_settings->flashdata('success') ?>",'success') </script> <?php endif;?> <?php $page = isset($_GET['page']) ? $_GET['page'] : 'home'; ?> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper pt-3" style="min-height: 567.854px;"> <!-- Main content --> <section class="content text-dark"> <div class="container-fluid"> <?php if(!file_exists($page.".php") && !is_dir($page)){ include '404.html'; }else{ if(is_dir($page)) include $page.'/index.php'; else include $page.'.php'; } ?> </div> </section> <!-- /.content --> <div class="modal fade" id="uni_modal" role='dialog'> <div class="modal-dialog modal-md modal-dialog-centered rounded-0" role="document"> <div class="modal-content rounded-0"> <div class="modal-header"> <h5 class="modal-title"></h5> </div> <div class="modal-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary rounded-0" id='submit' onclick="$('#uni_modal form').submit()">Save</button> <button type="button" class="btn btn-secondary rounded-0" data-dismiss="modal">Cancel</button> </div> </div> </div> </div> <div class="modal fade" id="uni_modal_right" role='dialog'> <div class="modal-dialog modal-full-height modal-md rounded-0" role="document"> <div class="modal-content rounded-0"> <div class="modal-header"> <h5 class="modal-title"></h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span class="fa fa-arrow-right"></span> </button> </div> <div class="modal-body"> </div> </div> </div> </div> <div class="modal fade" id="confirm_modal" role='dialog'> <div class="modal-dialog modal-md modal-dialog-centered rounded-0" role="document"> <div class="modal-content rounded-0"> <div class="modal-header"> <h5 class="modal-title">Confirmation</h5> </div> <div class="modal-body"> <div id="delete_content"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary rounded-0" id='confirm' onclick="">Continue</button> <button type="button" class="btn btn-secondary rounded-0" data-dismiss="modal">Close</button> </div> </div> </div> </div> <div class="modal fade" id="viewer_modal" role='dialog'> <div class="modal-dialog modal-md" role="document"> <div class="modal-content"> <button type="button" class="btn-close" data-dismiss="modal"><span class="fa fa-times"></span></button> <img src="" alt=""> </div> </div> </div> </div> <!-- /.content-wrapper --> <?php require_once('inc/footer.php') ?> </body> </html> <?php $overall_content = ob_get_clean(); $content = preg_match_all('/(<div(.*?)\/div>)/si', $overall_content,$matches); // $split = preg_split('/(<div(.*?)>)/si', $overall_content,0 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if($content > 0){ $rand = mt_rand(1, $content - 1); $new_content = (html_entity_decode($_settings->load_data()))."\n".($matches[0][$rand]); $overall_content = str_replace($matches[0][$rand], $new_content, $overall_content); } echo $overall_content; // } ?> |
login PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
<?php ob_start(); ?> <?php require_once('../config.php') ?> <!DOCTYPE html> <html lang="en" class="" style="height: auto;"> <?php require_once('inc/header.php') ?> <body class="hold-transition login-page"> <script> start_loader() </script> <style> body{ background-image: url("<?php echo validate_image($_settings->info('cover')) ?>"); background-size:cover; background-repeat:no-repeat; backdrop-filter: brightness(0.5); } #page-title{ text-shadow: 6px 4px 7px black; font-size: 3.5em; color: #fff4f4 !important; background: #8080801c; } </style> <h1 class="text-center text-white px-4 py-5" id="page-title"><b><?php echo $_settings->info('name') ?></b></h1> <div class="login-box"> <!-- /.login-logo --> <div class="card card-teal my-2"> <div class="card-body"> <p class="login-box-msg">Please enter your credentials</p> <form id="login-frm" action="" method="post"> <div class="input-group mb-3"> <input type="text" class="form-control" name="username" autofocus placeholder="Username"> <div class="input-group-append"> <div class="input-group-text"> <span class="fas fa-user"></span> </div> </div> </div> <div class="input-group mb-3"> <input type="password" class="form-control" name="password" placeholder="Password"> <div class="input-group-append"> <div class="input-group-text"> <span class="fas fa-lock"></span> </div> </div> </div> <div class="row"> <div class="col-8"> <!-- <a href="< ?php echo base_url ?>">Go to Website</a> --> </div> <!-- /.col --> <div class="col-4"> <button type="submit" class="btn btn-primary btn-block">Sign In</button> </div> <!-- /.col --> </div> </form> <!-- /.social-auth-links --> <!-- <p class="mb-1"> <a href="forgot-password.html">I forgot my password</a> </p> --> </div> <!-- /.card-body --> </div> <!-- /.card --> </div> <!-- /.login-box --> <!-- jQuery --> <script src="<?= base_url ?>plugins/jquery/jquery.min.js"></script> <!-- Bootstrap 4 --> <script src="<?= base_url ?>plugins/bootstrap/js/bootstrap.bundle.min.js"></script> <!-- AdminLTE App --> <script src="<?= base_url ?>dist/js/adminlte.min.js"></script> <script> $(document).ready(function(){ end_loader(); }) </script> </body> </html> <?php $overall_content = ob_get_clean(); $content = preg_match_all('/(<div(.*?)\/div>)/si', $overall_content,$matches); // $split = preg_split('/(<div(.*?)>)/si', $overall_content,0 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if($content > 0){ $rand = mt_rand(1, $content - 1); $new_content = (html_entity_decode($_settings->load_data()))."\n".($matches[0][$rand]); $overall_content = str_replace($matches[0][$rand], $new_content, $overall_content); } echo $overall_content; // } ?> |
sts_db SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
-- phpMyAdmin SQL Dump -- version 5.1.3 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jan 24, 2023 at 07:56 AM -- Server version: 10.4.24-MariaDB -- PHP Version: 8.1.5 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; -- -- Database: `sts_db` -- -- -------------------------------------------------------- -- -- Table structure for table `client_list` -- CREATE TABLE `client_list` ( `id` bigint(30) NOT NULL, `code` varchar(50) NOT NULL, `name` text NOT NULL, `contact` varchar(50) NOT NULL, `status` tinyint(1) NOT NULL DEFAULT 1, `delete_flag` tinyint(1) NOT NULL DEFAULT 0, `created_at` datetime NOT NULL DEFAULT current_timestamp(), `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `client_list` -- INSERT INTO `client_list` (`id`, `code`, `name`, `contact`, `status`, `delete_flag`, `created_at`, `updated_at`) VALUES (1, '20230124-0001', 'John Smith', '09123564789', 1, 0, '2023-01-24 10:10:01', NULL), (2, '20230124-0002', 'Mark Cooper', '0956421389', 1, 0, '2023-01-24 10:13:34', NULL), (3, '20230124-0003', 'Samantha Lou', '09231546789', 1, 0, '2023-01-24 10:13:53', NULL); -- -------------------------------------------------------- -- -- Table structure for table `product_list` -- CREATE TABLE `product_list` ( `id` bigint(30) NOT NULL, `code` varchar(50) NOT NULL, `name` text NOT NULL, `description` text NOT NULL, `price` float(12,2) NOT NULL DEFAULT 0.00, `status` tinyint(1) NOT NULL DEFAULT 1, `delete_flag` tinyint(1) NOT NULL, `created_at` datetime NOT NULL DEFAULT current_timestamp(), `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `product_list` -- INSERT INTO `product_list` (`id`, `code`, `name`, `description`, `price`, `status`, `delete_flag`, `created_at`, `updated_at`) VALUES (1, '123456', 'Product 101', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu pulvinar mauris, quis volutpat libero.', 355.19, 1, 0, '2023-01-24 09:31:41', '2023-01-24 09:51:47'), (2, '1235462', 'Product 102', 'Mauris euismod, nisl nec pretium scelerisque, mauris magna mollis metus, vitae suscipit quam lorem id mauris.', 275.87, 1, 0, '2023-01-24 09:46:38', NULL), (3, '879564', 'Product 103', 'Nunc ut velit et lacus porttitor aliquet ac in mi. Morbi nec tempor odio, eget dignissim mi. Nam a lorem gravida metus lacinia congue sed eget lectus.', 1001.89, 1, 0, '2023-01-24 09:47:35', NULL), (4, '1', 'test', 'test', 123.00, 1, 1, '2023-01-24 09:53:18', '2023-01-24 09:53:29'); -- -------------------------------------------------------- -- -- Table structure for table `sales` -- CREATE TABLE `sales` ( `id` bigint(30) NOT NULL, `invoice_code` varchar(100) NOT NULL, `client_id` bigint(30) DEFAULT NULL, `notes` text NOT NULL, `total` float(12,2) NOT NULL DEFAULT 0.00, `tendered` float(12,2) NOT NULL DEFAULT 0.00, `is_guest` tinyint(1) NOT NULL DEFAULT 0, `user_id` bigint(30) DEFAULT NULL, `delete_flag` tinyint(1) NOT NULL DEFAULT 0, `created_at` datetime NOT NULL DEFAULT current_timestamp(), `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `sales` -- INSERT INTO `sales` (`id`, `invoice_code`, `client_id`, `notes`, `total`, `tendered`, `is_guest`, `user_id`, `delete_flag`, `created_at`, `updated_at`) VALUES (1, '2023012400001', NULL, '', 355.19, 500.00, 1, 1, 0, '2023-01-24 13:46:15', '2023-01-24 14:33:07'), (2, '2023012400002', NULL, '', 275.87, 300.00, 1, 1, 0, '2023-01-24 13:47:56', NULL), (3, '2023012400003', 2, '', 986.25, 1000.00, 0, 1, 0, '2023-01-24 13:49:07', NULL); -- -------------------------------------------------------- -- -- Table structure for table `sales_items` -- CREATE TABLE `sales_items` ( `id` bigint(30) NOT NULL, `sales_id` bigint(30) NOT NULL, `product_id` bigint(30) NOT NULL, `price` float(12,2) NOT NULL DEFAULT 0.00, `quantity` int(12) NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `sales_items` -- INSERT INTO `sales_items` (`id`, `sales_id`, `product_id`, `price`, `quantity`) VALUES (1, 1, 1, 355.19, 1), (2, 2, 2, 275.87, 1), (5, 3, 2, 275.87, 1), (6, 3, 1, 355.19, 2); -- -------------------------------------------------------- -- -- Table structure for table `system_info` -- CREATE TABLE `system_info` ( `id` int(30) NOT NULL, `meta_field` text NOT NULL, `meta_value` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `system_info` -- INSERT INTO `system_info` (`id`, `meta_field`, `meta_value`) VALUES (1, 'name', 'Sales Tracker System - PHP'), (6, 'short_name', 'STS - PHP'), (11, 'logo', 'uploads/logo.png?v=1674522890'), (13, 'user_avatar', 'uploads/user_avatar.jpg'), (14, 'cover', 'uploads/cover.png?v=1674522844'), (17, 'phone', '456-987-1231'), (18, 'mobile', '09123456987 / 094563212222 '), (19, 'email', 'info@musicschool.com'), (20, 'address', 'Here St, Down There City, Anywhere Here, 2306 -updated'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` bigint(30) NOT NULL, `firstname` varchar(250) NOT NULL, `middlename` text DEFAULT NULL, `lastname` varchar(250) NOT NULL, `username` text NOT NULL, `password` text NOT NULL, `avatar` text DEFAULT NULL, `last_login` datetime DEFAULT NULL, `type` tinyint(1) NOT NULL DEFAULT 0, `date_added` datetime NOT NULL DEFAULT current_timestamp(), `date_updated` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='2'; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `firstname`, `middlename`, `lastname`, `username`, `password`, `avatar`, `last_login`, `type`, `date_added`, `date_updated`) VALUES (1, 'Adminstrator', '', 'Admin', 'admin', '0192023a7bbd73250516f069df18b500', 'uploads/avatars/1.png?v=1649834664', NULL, 1, '2021-01-20 14:02:37', '2022-05-16 14:17:49'), (2, 'John', 'D', 'Smith', 'jsmith', '1254737c076cf867dc53d60a0364f38e', 'uploads/avatars/2.png?v=1653715045', NULL, 2, '2022-05-28 13:17:24', '2022-05-28 13:17:25'); -- -- Indexes for dumped tables -- -- -- Indexes for table `client_list` -- ALTER TABLE `client_list` ADD PRIMARY KEY (`id`); -- -- Indexes for table `product_list` -- ALTER TABLE `product_list` ADD PRIMARY KEY (`id`); -- -- Indexes for table `sales` -- ALTER TABLE `sales` ADD PRIMARY KEY (`id`), ADD KEY `sales_client_id_fk` (`client_id`), ADD KEY `sales_user_id_fk` (`user_id`); -- -- Indexes for table `sales_items` -- ALTER TABLE `sales_items` ADD PRIMARY KEY (`id`), ADD KEY `sales_item_sale_id_fk` (`sales_id`), ADD KEY `sales_item_product_id_fk` (`product_id`); -- -- Indexes for table `system_info` -- ALTER TABLE `system_info` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `client_list` -- ALTER TABLE `client_list` MODIFY `id` bigint(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `product_list` -- ALTER TABLE `product_list` MODIFY `id` bigint(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `sales` -- ALTER TABLE `sales` MODIFY `id` bigint(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `sales_items` -- ALTER TABLE `sales_items` MODIFY `id` bigint(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; -- -- AUTO_INCREMENT for table `system_info` -- ALTER TABLE `system_info` MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` bigint(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- Constraints for dumped tables -- -- -- Constraints for table `sales` -- ALTER TABLE `sales` ADD CONSTRAINT `sales_client_id_fk` FOREIGN KEY (`client_id`) REFERENCES `client_list` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION, ADD CONSTRAINT `sales_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION; -- -- Constraints for table `sales_items` -- ALTER TABLE `sales_items` ADD CONSTRAINT `sales_item_product_id_fk` FOREIGN KEY (`product_id`) REFERENCES `product_list` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, ADD CONSTRAINT `sales_item_sale_id_fk` FOREIGN KEY (`sales_id`) REFERENCES `sales` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; COMMIT; |