• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » PHP » Dynamic Menu AdminLTE And Dashboard Page – Tutorial Build PHP Point Of Sale With PDO, MySQL And Jquery Part 2

Dynamic Menu AdminLTE And Dashboard Page – Tutorial Build PHP Point Of Sale With PDO, MySQL And Jquery Part 2

By Sigit Prasetya Nugroho ∙ April 28, 2017 ∙ PHP ∙ 3 Comments

Share : TwitterFacebookTelegramWhatsapp

After part 1 is completed, the next step is to create a dynamic menu and dashboard page on adminLTE Framework. Before I started, make sure you have read the Tutorial Build PHP Point Of Sale With PDO, MySQL And Jquery Part 1 to follow this article very well. The adminlte dashboard page look like the following picture

Tutorial Build Point Of Sale With PHP, PDO, MySQL And Jquery Part 1

In part 2, we only edit the file index.php (pos/application/main/index.php), header.php (pos/application/layout/header.php) and pos.php (pos/application/model/pos.php)

Table of Contents

  • 1 Tutorial PHP Point Of Sale System Part 2
    • 1.1 Dynamic Navigation Menu PHP And MySQL
    • 1.2 Create Dashboard in PHP
  • 2 Conclusion

Tutorial PHP Point Of Sale System Part 2

Dynamic Navigation Menu PHP And MySQL

I have discussed “how to create a dynamic menu on adminLTE” on some of my previous articles:

  • Tutorial Create Dynamic Sidebar Menu on MySQL, Node.js, Express, AdminLTE For Beginner.
  • Create Dynamic Sidebar Multilevel Menu in AdminLTE with MySQL, PHP, and PDO.
  • How To Create User Permissions View To Dynamic Sidebar Menu AdminLTE.
  • Creating dynamic sidebar menu with Mysql and AdminLTE Bootstrap Template.

I will not discuss in detail how to create this menu, but you can read some of my articles above to understand more. The primary purpose of this article is to create a PHP point of sale system that is safe and has a dynamic menu (to manage the menu navigation flexibly and efficiently).

To start making this menu, make sure you have created the m_user table in tutorial part 1. Then create 2 more tables with the name r_menu and r_sub_menu as follows.

R Menu Table To Create Dynamic Menu Adminlte

Related Articles :

  • How To Upload Image Using PHP, AdminLTE Framework And JQuery Plugin For Beginner
  • Create a Sales Form / POS – Tutorial Build Point Of Sale With PHP, PDO, MySQL And Jquery Part 5
  • Create Master Item / Product Form – Tutorial Build Point Of Sale With PHP, PDO, MySQL And Jquery Part 4.

R Sub Menu To Create Dynamic Menu Adminlte

In addition to the 2 tables above, please create a r_ref_system table to accommodate the main data of the application. r_ref_system table structure like the following picture:

R Ref System Table Structure How To Create Pos Php

Until this step, we have succeeded to create 4 tables in the pos database.

4 Tables In Pos Database Mysql

Add some of the following MySQL queries to fill the table r_menu and r_submenu :

1
2
3
4
5
6
7
insert  into 'r_menu'('id_menu','name_menu','menu_order','icon') values (1,'Master',1,'');
insert  into 'r_menu'('id_menu','name_menu','menu_order','icon') values (2,'Penjualan',2,'');
insert  into 'r_menu'('id_menu','name_menu','menu_order','icon') values (3,'Utility',7,'');
 
insert  into 'r_menu_sub'('id_sub_menu','name_sub_menu','id_menu','sub_menu_order','hak_akses','url','content_before','content_after','icon','title','target') values (1,'Master Item',1,2,'2','application/master/v_item.php',NULL,NULL,'<i class=\"fa  fa-arrow-right\"></i>','MASTER ITEMS','_self');
insert  into 'r_menu_sub'('id_sub_menu','name_sub_menu','id_menu','sub_menu_order','hak_akses','url','content_before','content_after','icon','title','target') values (2,'Point Of Sale',2,2,'2','application/sales/v_pos.php',NULL,NULL,'<i class=\"fa  fa-arrow-right\"></i>','POINT OF SALES','_self');
insert  into 'r_menu_sub'('id_sub_menu','name_sub_menu','id_menu','sub_menu_order','hak_akses','url','content_before','content_after','icon','title','target') values (3,'Master User',3,1,'4','application/utility/v_mstuser.php',NULL,NULL,'<i class=\"fa  fa-arrow-right\"></i>','MASTER USERS','_self');

Execute the MySQL query below to fill the table r_ref_system

1
insert  into 'r_ref_system'('id','name_shop','address_shop','phone_shop') values (1,'SEEGATESITE SHOP','1193 Hartway Street Rapid City, SD 57702','08777-8370-888');

Edit the header.php file (pos/application/layout/header.php) and fill in the following script:

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
</head>
<body class="hold-transition skin-black layout-top-nav">
  <!-- Site wrapper -->
  <div class="wrapper">
    <header class="main-header">
      <nav class="navbar navbar-static-top">
        <div class="container-fluid">
          <div class="navbar-header">
            <a href="<?php echo $sitename.'application/main/index.php';?>" class="navbar-brand">
             <span class="logo-mini">
              <b>Seegate</b>site
            </span>
          </a>
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
            <i class="fa fa-bars"></i>
          </button>
        </div>
        <!-- main navigation bar disini -->
        <div class="collapse navbar-collapse pull-left" id="navbar-collapse">
          <ul class="nav navbar-nav">
            <?php
            $sv = new pos();
            $data = $sv->getMenu();
            $key = $data[1];
            ?>
            <?php
            foreach($key as $menu)
            {
              $idmenux=$menu['id_menu'];
              $id_menu=$menu['id_menu'];
              $query_sub_menu =  $sv->getSubMenu($id_menu);
              $jumlah_submenu = count($query_sub_menu[1]);
              if($jumlah_submenu > 0){
                $cekmenuz=0;
                /*--------------------*/
                foreach($query_sub_menu[1] as $sub_menu)
                {  
                 $mymenu=$_SESSION['pos_h_menu'];
                 $arramymenu=explode(",", $mymenu);
                 if(in_array($sub_menu['id_sub_menu'], $arramymenu))
                 {    
                  $cekmenuz++;
                }
              }
              /*--------------------*/
            }
            if($cekmenuz >0)
            {
              ?>
              <li class="dropdown"><a  href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $menu['name_menu']; ?> <span class="caret"></span></a>
                <?php
              }
 
              if($jumlah_submenu > 0){  ?>
              <ul class="dropdown-menu" role="menu">
               <?php
               foreach($query_sub_menu[1] as $sub_menu)
               {  
                 $mymenu=$_SESSION['pos_h_menu'];
                 $arramymenu=explode(",", $mymenu);
 
                 if(in_array($sub_menu['id_sub_menu'], $arramymenu))
                 {    
                  echo $sub_menu['content_before'] ;            
                  ?>
                  <li>
                    <a class="titles" href="<?php echo $sitename.$sub_menu['url']; ?>" target="<?php echo $sub_menu['target']; ?>" title="<?php echo $sub_menu['title']; ?>" >
                     <?php echo $sub_menu['icon'].$sub_menu['name_sub_menu']; ?>
                   </a>
                 </li>
                 <?php
                 echo $sub_menu['content_after'] ;
               }
             }
             ?>
           </ul>
           <?php
         }
         ?>
       </li>
       <?php
     }
     ?>
   </ul>
</div>
<!-- /.navbar-collapse -->
<!-- ./ main navigation bar -->
 
<div class="navbar-custom-menu">
  <ul class="nav navbar-nav">
   <li class="dropdown user user-menu">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
      <img src="../../dist/img/avatar5.png" class="user-image" alt="User Image">
      <span class="hidden-xs"><?php echo $_SESSION['pos_username']; ?></span>
    </a>
    <ul class="dropdown-menu">
      <!-- User image -->
      <li class="user-header">
        <img src="../../dist/img/avatar5.png" class="img-circle" alt="User Image">
        <p>
          <?php echo $_SESSION['pos_username']; ?>
        </p>
      </li>              
      <!-- Menu Footer-->
      <li class="user-footer">
        <div class="pull-left">
          <a href="<?php echo $sitename.'application/utility/v_ubah_password.php'; ?>" title="Change Password " class="btn btn-default btn-flat">Change Password</a>
        </div>
        <div class="pull-right">
        <a href="<?php echo $sitename.'application/main/logout.php'; ?>" title="Close Application" class="btn btn-default btn-flat">Logout</a>
        </div>
      </li>
    </ul>
  </li>
  <li>
    <a class="titles" href="<?php echo $sitename.'application/main/logout.php'; ?>" ><i class="titles fa fa-sign-out" title="Close Application"  ></i></a>
  </li>
</ul>
</div><!--  /.<div class="navbar-custom-menu">-->
</div><!-- ./container -->
</nav>
</header>
 
<!-- main content -->
<div class="content-wrapper">
  <div class="container-fluid">

Brief Description : 

The PHP navigation menu code is placed here. We store user menu permissions in the h_menu field in a string format delimited by commas. For example, “1,2,3.”

Then in the header.php file, we break up the h_menu into an array. The next step is to check the submenu code in the array. If the submenu code is in an array formed from h_menu, then the submenu will be displayed

Create Dashboard in PHP

Edit the index.php file (pos/application/main/index.php) and fill in the following script:

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
<?php include "../../library/config.php"; ?>
<?php $titlepage="Dashboard"; ?>
<?php
require_ once("../model/dbconn.php");
require_ once("../model/pos.php");
include "../layout /top-header.php";
include "../../library /check_login.php";
 
include "../layout/header.php";
?>
<section style="margin-bottom:10px;" class="content-header">
<h1>
Dashboard
<small>Page</small>
</h1>
</section>
<section class="content-main">
<div class="row">
<div class="col-xs-12">
<div class="box box-solid box-danger">
<?php
$pos = new pos();
$toko = $pos->getrefsytem();
$nameshop = $toko[1]['name_shop'];
$address_shop = $toko[1]['address_shop'];
$phoneshop = $toko[1]['phone_shop'];
?>
<div class="box-header">
<h1 class="box-title"><?php echo $nameshop;?></h1>
</div> <!-- end of box-header -->
<div class="box-body">
<h4><?php echo $address_shop;?></h4>
<h5>Telp : <?php echo $phoneshop;?></h5>
</div> <!-- end of box-body -->
</div><!-- end of box box-solid bg-light-blue-gradiaent -->
</div>
</div><!-- row -->
<div class="row">
<div class="col-md-9">
<div class="box box-info">
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">Search Item</h3>
</div> <!-- end of box-header -->
 
<div class="row">
<div class=" col-xs-12" style="padding-left:25px;padding-right:25px">
<input type="text" class="form-control " id="txtsearchitem" placeholder="Search item or item id here...">
</div>
</div>
<div class="box-body">
<div class="box-body table-responsive no-padding" style="max-width:900px;">
<table id="table_search" class="table  table-bordered table-hover table-striped">
<thead>
<tr class="tableheader">
<th style="width:40px">#</th>
<th style="width:60px">Id</th>
<th style="width:300px">Items</th>
<th style="width:100px">Price</th>
<th style="width:120px">Stock</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div> <!-- end of box-body -->
 
</div>
 
</div><!-- end of div box info -->
</div><!-- end of col-md-8 -->
<div class="col-md-3">
<div class="small-box bg-green">
<div class="inner">
<h3>30</h3>
<p>Today Sales</p>
</div>
<div class="icon">
<i class="ion ion-stats-bars"></i>
</div>
<a href="#" id="lapjuals" class="small-box-footer"> More Detail <i class="fa fa-arrow-circle-right"></i></a>
</div><!-- end of small-box-green -->
 
<div class="small-box bg-aqua">
<div class="inner">
<h3>10</h3>
<p>Out of stock items</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
<a href="<?php echo $sitename;?>application/mutasi/l_barang_abis.php" target="_blank" class="small-box-footer">Info detail <i class="fa fa-arrow-circle-right"></i></a>
 
</div><!-- end of col md 4 -->
</div><!-- end of row -->
</section>
<?php include "../layout/footer.php"; //footer template ?>
<?php include "../layout/bottom-footer.php"; //footer template ?>
<script src="../../dist/js/redirect.js"></script>
<script>
$(document).on("keyup keydown","#txtsearchitem",function(){
var searchitem = $("#txtsearchitem").val();
value={
term : searchitem,
}
$.ajax(
{
url : "../master/c_search_item.php",
type: "POST",
data : value,
success: function(data, textStatus, jqXHR)
{
var data = jQuery.parseJSON(data);
$("#table_search tbody").html(data.data)
},
error: function(jqXHR, textStatus, errorThrown)
{
}
});
});
 
</script>
</body>
</html>

Edit the pos.php file (pos/application/model/pos.php) and add the following script:

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
/******************************************************************************
    START OF pos MENU CODE
*******************************************************************************/
    public function getMenu()
    {
     $db = $this->dblocal;
     try
     {
     $stmt = $db->prepare("select * from r_menu order by menu_order");
     $stmt->execute();
     $stat[0] = true;
     $stat[1] = $stmt->fetchAll(PDO::FETCH_ASSOC);
     return $stat;
     }
     catch(PDOException $ex)
     {
     $stat[0] = false;
     $stat[1] = $ex->getMessage();
     return $stat;
     }
    }
 
    
    public function getSubMenu($id)
    {
     $db = $this->dblocal;
     try
     {
     $stmt = $db->prepare("select * from r_menu_sub where id_menu = :id order by sub_menu_order asc");
     $stmt->bindParam("id",$id);
     $stmt->execute();
     $stat[0] = true;
     $stat[1] = $stmt->fetchAll(PDO::FETCH_ASSOC);
     return $stat;
     }
     catch(PDOException $ex)
     {
     $stat[0] = false;
     $stat[1] = $ex->getMessage();
     return $stat;
     }
    }
 
public function getrefsytem()
  {
    $db = $this->dblocal;
    try
    {
      $stmt = $db->prepare("select a.* from r_ref_system a where id = 1 ");
      $stmt->execute();
      $stat[0] = true;
      $stat[1] = $stmt->fetch(PDO::FETCH_ASSOC);
      return $stat;
    }
    catch(PDOException $ex)
    {
      $stat[0] = false;
      $stat[1] = $ex->getMessage();
      $stat[2] = 0;
      return $stat;
    }
  }

Brief Description :

On the dashboard page, we create a table for item search. But the item search module does not work in this chapter, we will discuss it in the next tutorial.

To tests the dynamic menu please add the value in a h_menu field in the m_user table. Change the menu to 1,2 or 1,3 and see the result.

Dashboard Page Point Of Sale Php Adminlte

you can download the entire php point of sale project in the tutorial part 5 here.

Conclusion

Creating a dynamic navigation menu and Adminlte dashboard does not require a long time. Adminlte is a free dashboard framework that is easily customized according to the goals to be achieved.

List of PHP point of sale tutorials:

  1. Create login page – Tutorial Build PHP Point Of Sale Part 1.
  2. Create Dynamic Menu and Dashboard Page -PHP Point Of Sale Tutorial Part 2.
  3. Create Master User Form – PHP Point Of Sale Tutorial Part 3
  4. Create Master Item / Product Form – PHP Point Of Sale Tutorial Part 4
  5. Create Sales Form / Point of sale – PHP Point Of Sale Tutorial Part 5

I think the 2nd part tutorial is pretty easy, so I don’t need to explain in detail. Up here Tutorial Build PHP Point Of Sale With, PDO, MySQL And Jquery Part 2 has been completed, In the next article will discuss how to create master user page in PHP point of sale tutorial.

Another PHP Related Post :

  • How To Replace String With Another String In PHP
  • Login Page – Tutorial CRUD Client and API Server Using JQuery And Lumen Part 2
  • Tutorial CRUD Client and API Server Using JQuery And Lumen Part 1
  • How To Solve Problems Illegal mix of collations (latin1_swedish_ci,IMPLICIT) In Laravel
  • How To Resolve No ‘Access-Control-Allow-Origin’ Header In Lumen
  • How To Create Custom Class In Laravel 5.5 For Beginners

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Comments

  1. Avatar for iraira says

    December 20, 2017 at 3:21 am

    Kenapa muncul Fatal error : break not in the loop or switch context in ….. di file authorization.php

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      December 20, 2017 at 5:28 am

      kode break; cuman bisa di gunakan di loop atau switch. mungkin php versinya yak yang mempengaruhi 🙂

      Reply
  2. Avatar for dwarfdwarf says

    June 8, 2018 at 5:35 pm

    I am getting this error whenever I try to run the pos.php code,
    “Parse error: syntax error, unexpected ‘public’ (T_PUBLIC), expecting end of file in C:\xampp\htdocs\pos\application\model\pos.php on line 5”.

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      June 10, 2018 at 8:26 am

      create new class pos… please read first article before

      https://seegatesite.com/tutorial-build-point-of-sale-with-php-pdo-mysql-and-jquery-part-1/

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (7) Publisher Tips (5) react (3) Reactjs (7) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) widget (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2021 Seegatesite.com