dolibarr  13.0.2
floors.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2018 Andreu Bisquerra <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('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
25 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
26 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
27 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
28 if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
29 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
30 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
31 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
32 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
33 
34 require '../main.inc.php'; // Load $user and permissions
35 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
36 
37 $langs->loadLangs(array("bills", "orders", "commercial", "cashdesk"));
38 
39 $floor = GETPOST('floor', 'int');
40 if ($floor == "") $floor = 1;
41 $id = GETPOST('id', 'int');
42 $action = GETPOST('action', 'aZ09');
43 $left = GETPOST('left', 'alpha');
44 $top = GETPOST('top', 'alpha');
45 
46 $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Ba or Restaurant
47 
48 $newname = GETPOST('newname', 'alpha');
49 $mode = GETPOST('mode', 'alpha');
50 
51 if (empty($user->rights->takepos->run)) {
53 }
54 
55 
56 /*
57  * Actions
58  */
59 
60 if ($action == "getTables")
61 {
62  $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor;
63  $resql = $db->query($sql);
64  $rows = array();
65  while ($row = $db->fetch_array($resql)) {
66  $invoice = new Facture($db);
67  $result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')');
68  if ($result > 0) $row['occupied'] = "red";
69  $rows[] = $row;
70  }
71  echo json_encode($rows);
72  exit;
73 }
74 
75 if ($action == "update")
76 {
77  if ($left > 95) $left = 95;
78  if ($top > 95) $top = 95;
79  if ($left > 3 or $top > 4) $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=".$left.", toppos=".$top." WHERE rowid='".$place."'");
80  else $db->query("DELETE from ".MAIN_DB_PREFIX."takepos_floor_tables where rowid='".$place."'");
81 }
82 
83 if ($action == "updatename")
84 {
85  $newname = preg_replace("/[^a-zA-Z0-9\s]/", "", $newname); // Only English chars
86  if (strlen($newname) > 3) $newname = substr($newname, 0, 3); // Only 3 chars
87  $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'");
88 }
89 
90 if ($action == "add")
91 {
92  $sql = "INSERT INTO ".MAIN_DB_PREFIX."takepos_floor_tables(entity, label, leftpos, toppos, floor) VALUES (".$conf->entity.", '', '45', '45', ".$floor.")";
93  $asdf = $db->query($sql);
94  $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names
95 }
96 
97 
98 /*
99  * View
100  */
101 
102 // Title
103 $title = 'TakePOS - Dolibarr '.DOL_VERSION;
104 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
105 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
106 ?>
107 <link rel="stylesheet" href="css/pos.css.php?a=xxx">
108 <style type="text/css">
109 div.tablediv{
110 background-image:url(img/table.gif);
111 -moz-background-size:100% 100%;
112 -webkit-background-size:100% 100%;
113 background-size:100% 100%;
114 height:10%;
115 width:10%;
116 text-align: center;
117 font-size:300%;
118 color:white;
119 }
120 div.red{
121 color:red;
122 }
123 html, body
124 {
125 height: 100%;
126 }
127 </style>
128 
129 <script>
130 var DragDrop='<?php echo $langs->trans("DragDrop"); ?>';
131 
132 function updateplace(idplace, left, top) {
133  console.log("updateplace idplace="+idplace+" left="+left+" top="+top);
134  $.ajax({
135  type: "POST",
136  url: "floors.php",
137  data: { action: "update", left: left, top: top, place: idplace }
138  }).done(function( msg ) {
139  window.location.href='floors.php?mode=edit&floor=<?php echo $floor; ?>';
140  });
141 }
142 
143 function updatename(rowid) {
144  var after=$("#tablename"+rowid).text();
145  console.log("updatename rowid="+rowid+" after="+after);
146  $.ajax({
147  type: "POST",
148  url: "floors.php",
149  data: { action: "updatename", place: rowid, newname: after }
150  }).done(function( msg ) {
151  window.location.href='floors.php?mode=edit&floor=<?php echo $floor; ?>';
152  });
153  }
154 
155 function LoadPlace(place){
156  parent.location.href='index.php?place='+place;
157 }
158 
159 
160 $( document ).ready(function() {
161  $.getJSON('./floors.php?action=getTables&floor=<?php echo $floor; ?>', function(data) {
162  $.each(data, function(key, val) {
163  <?php if ($mode == "edit") {?>
164  $('body').append('<div class="tablediv" contenteditable onblur="updatename('+val.rowid+');" style="position: absolute; left: '+val.leftpos+'%; top: '+val.toppos+'%;" id="tablename'+val.rowid+'">'+val.label+'</div>');
165  $( "#tablename"+val.rowid ).draggable(
166  {
167  start: function() {
168  $("#add").html("<?php echo $langs->trans("Delete"); ?>");
169  },
170  stop: function() {
171  var left=$(this).offset().left*100/$(window).width();
172  var top=$(this).offset().top*100/$(window).height();
173  updateplace($(this).attr('id').substr(9), left, top);
174  }
175  }
176  );
177  //simultaneous draggable and contenteditable
178  $('#'+val.label).draggable().bind('click', function(){
179  $(this).focus();
180  })
181  <?php } else {?>
182  $('body').append('<div class="tablediv '+val.occupied+'" onclick="LoadPlace('+val.rowid+');" style="position: absolute; left: '+val.leftpos+'%; top: '+val.toppos+'%;" id="tablename'+val.rowid+'">'+val.label+'</div>');
183  <?php } ?>
184  });
185  });
186 });
187 
188 </script>
189 </head>
190 <body style="overflow: hidden">
191 <?php if ($user->admin) {?>
192 <div style="position: absolute; left: 0.1%; top: 0.8%; width:8%; height:11%;">
193  <?php if ($mode == "edit") {?>
194 <a id="add" onclick="window.location.href='floors.php?mode=edit&action=add&floor=<?php echo $floor; ?>';"><?php echo $langs->trans("AddTable"); ?></a>
195  <?php } else { ?>
196 <a onclick="window.location.href='floors.php?mode=edit&floor=<?php echo $floor; ?>';"><?php echo $langs->trans("Edit"); ?></a>
197  <?php } ?>
198 </div>
199 <?php }
200 ?>
201 
202 <div style="position: absolute; left: 25%; bottom: 8%; width:50%; height:3%;">
203  <center>
204  <h1>
205  <?php if ($floor > 1) { ?>
206  <img class="valignmiddle" src="./img/arrow-prev.png" width="5%" onclick="location.href='floors.php?floor=<?php if ($floor > 1) { $floor--; echo $floor; $floor++; } else echo "1"; ?>';">
207  <?php } ?>
208  <span class="valignmiddle"><?php echo $langs->trans("Floor")." ".$floor; ?></span>
209  <img src="./img/arrow-next.png" class="valignmiddle" width="5%" onclick="location.href='floors.php?floor=<?php $floor++; echo $floor; ?>';">
210  </h1>
211  </center>
212 </div>
213 </body>
214 </html>
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
top_htmlhead($head, $title= '', $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
Definition: main.inc.php:1280
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 ...
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
Class to manage invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105