dolibarr  16.0.5
menu.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) - 2020 Andreu Bisquerra Gaya <jove@bisquerra.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
24 if (!defined("NOLOGIN")) {
25  define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
26 }
27 if (!defined('NOIPCHECK')) {
28  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
29 }
30 if (!defined('NOBROWSERNOTIF')) {
31  define('NOBROWSERNOTIF', '1');
32 }
33 
34 require '../../main.inc.php';
35 
36 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37 
38 if (!$conf->global->TAKEPOS_QR_MENU) {
39  accessforbidden(); // If Restaurant Menu is disabled never allow NO LOGIN access
40 }
41 ?>
42 <!DOCTYPE html>
43 <html>
44 <head>
45  <meta charset="UTF-8">
46  <title><?php echo $mysoc->name; ?></title>
47  <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/foundation-sites@6.6.3/dist/css/foundation.min.css'>
48 <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Khand:400,300,500,600,700'><link rel="stylesheet" href="css/style.css">
49 <meta name="viewport" content="width=device-width, initial-scale=1">
50 </head>
51 <body>
52 <!-- partial:index.partial.html -->
53 <body>
54  <div class="grid-container">
55  <div class="grid-x grid-padding-x menu2">
56  <div class="cell small-12">
57  <h1><?php print $mysoc->name; ?> - <small><?php print $langs->trans('RestaurantMenu'); ?></small></h1>
58 
59 <?php
60 $categorie = new Categorie($db);
61 $categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) ? $conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1);
62 $levelofrootcategory = 0;
63 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
64  foreach ($categories as $key => $categorycursor) {
65  if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
66  $levelofrootcategory = $categorycursor['level'];
67  break;
68  }
69  }
70 }
71 $levelofmaincategories = $levelofrootcategory + 1;
72 
73 $maincategories = array();
74 $subcategories = array();
75 foreach ($categories as $key => $categorycursor) {
76  if ($categorycursor['level'] == $levelofmaincategories) {
77  $maincategories[$key] = $categorycursor;
78  } else {
79  $subcategories[$key] = $categorycursor;
80  }
81 }
82 
83 $maincategories = dol_sort_array($maincategories, 'label');
84 
85 foreach ($maincategories as $cat) {
86  print '<div class="text-center">
87  <a id="'.$cat['id'].'"></a><h3>'.$cat['label'].'</h3>
88  </div>
89  <div class="grid-x grid-padding-x">';
90 
91  $object = new Categorie($db);
92  $result = $object->fetch($cat['id']);
93  $prods = $object->getObjectsInCateg("product", 0, 0, 0, $conf->global->TAKEPOS_SORTPRODUCTFIELD, 'ASC');
94  foreach ($prods as $pro) {
95  print '
96  <div class="cell small-6 medium-4">
97  <div class="item">
98  <h4>'.$pro->label.'</h4>
99  <span class="dots"></span>
100  <span class="price">'.price($pro->price_ttc, 1).'</span>
101  </div>
102  </div>';
103  }
104  print '</div>';
105 }
106 ?>
107  </div>
108  </div>
109  </div>
110  <footer class="footer">
111  <div class="container">
112  <p class="text-muted"><?php print $mysoc->name; ?></p>
113  </div>
114  </footer>
115  </body>
116 <!-- partial -->
117  <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
118 <script src='https://cdn.jsdelivr.net/npm/foundation-sites@6.6.3/dist/js/foundation.min.js'></script><script src="js/script.js"></script>
119 
120 </body>
121 </html>
dol_sort_array
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
Definition: functions.lib.php:8385
name
$conf db name
Definition: repair.php:122
Categorie
Class to manage categories.
Definition: categorie.class.php:47
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5541
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933