29if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL',
'1');
32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
42if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
43 require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
55if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
59 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') : 0);
61$action =
GETPOST(
'action',
'aZ09');
64$mobilepage =
GETPOST(
'mobilepage',
'alphanohtml');
66if ($setterminal > 0) {
67 $_SESSION[
"takeposterminal"] = $setterminal;
70$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter"));
72if (!$user->hasRight(
'takepos',
'run') && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
81$title =
'TakePOS - Dolibarr '.DOL_VERSION;
87if (empty($mobilepage) && (empty($action) || ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 &&
$conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')))) {
88 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
89 <meta name="apple-mobile-web-app-capable" content="yes">
90 <meta name="mobile-web-app-capable" content="yes">
91 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
93 '/takepos/css/phone.css',
95 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
98 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
100 print
'<body style="background-color:#D1D1D1;">'.
"\n";
108if ($action ==
"productinfo" && $user->hasRight(
'takepos',
'run')) {
110 $prod->fetch($idproduct);
111 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="AddProductConfirm(place, '.$idproduct.
')">'.$langs->trans(
'Add').
'</button>';
112 print
"<br><b>".$prod->label.
"</b><br>";
113 print
'<img class="imgwrapper" width="60%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$idproduct.
'">';
114 print
"<br>".$prod->description;
115 print
"<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1,
$conf->currency).
"</b>";
117} elseif ($action ==
"publicpreorder" && $user->hasRight(
'takepos',
'run')) {
118 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="TakeposPrintingOrder();">'.$langs->trans(
'Confirm').
'</button>';
120 print
'<div class="comment">
121 <textarea class="textinput " placeholder="'.$langs->trans(
'Note').
'"></textarea>
124} elseif ($action ==
"publicpayment" && $user->hasRight(
'takepos',
'run')) {
125 $langs->loadLangs(array(
"orders"));
126 print
'<h1>'.$langs->trans(
'Ordered').
'</h1>';
127 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans(
'Payment').
'</button>';
129} elseif ($action ==
"checkplease" && $user->hasRight(
'takepos',
'run')) {
130 if (GETPOSTISSET(
"payment")) {
131 print
'<h1>'.$langs->trans(
'Ordered').
'</h1>';
132 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
133 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
135 $printer->initPrinter(
getDolGlobalString(
'TAKEPOS_PRINTER_TO_USE'.$_SESSION[
"takeposterminal"]));
136 if ($printer->getPrintConnector()) {
137 if (!is_null($printer->printer)) {
138 $printer->printer->feed();
139 $printer->printer->feed();
140 $printer->printer->text($langs->trans(
'IM'));
141 $printer->printer->feed();
142 $printer->printer->text($langs->trans(
'Place').
": ".$place);
143 $printer->printer->feed();
144 $printer->printer->text($langs->trans(
'Payment').
": ".$langs->trans(
GETPOST(
'payment',
'alpha')));
145 $printer->printer->feed();
146 $printer->printer->feed();
147 $printer->printer->feed();
148 $printer->printer->feed();
149 $printer->printer->feed();
154 print
'<button type="button" class="publicphonebutton2 phoneblue total marginbottomonly" onclick="CheckPlease(\'Cash\')">'.$langs->trans(
'Cash').
'</button>';
155 print
'<button type="button" class="publicphonebutton2 phoneblue total marginbottomonly" onclick="CheckPlease(\'CreditCard\')">'.$langs->trans(
'CreditCard').
'</button>';
158} elseif ($action ==
"editline" && $user->hasRight(
'takepos',
'run')) {
162 $invoice->fetch($placeid);
163 foreach ($invoice->lines as $line) {
164 if ($line->id == $selectedline) {
166 $prod->fetch($line->fk_product);
167 print
"<b>".$prod->label.
"</b><br>";
168 print
'<img class="imgwrapper" width="60%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$line->fk_product.
'">';
169 print
"<br>".$prod->description;
170 print
"<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1,
$conf->currency).
"</b>";
172 print
'<button type="button" class="publicphonebutton2 phonered width24" onclick="SetQty(place, '.$selectedline.
', '.($line->qty - 1).
')">-</button>';
173 print
'<button type="button" class="publicphonebutton2 phonegreen width24" onclick="SetQty(place, '.$selectedline.
', '.($line->qty + 1).
')">+</button>';
174 print
'<button type="button" class="publicphonebutton2 phoneblue width24" onclick="SetNote(place, '.$selectedline.
')">'.$langs->trans(
'Note').
'</button>';
179 <div
class=
"container">
180 <div
class=
"phonebuttonsrow center">
182 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
183 print
'<button type="button" class="phonebutton uppercase" onclick="LoadPlacesList();">'.dol_trunc($langs->trans(
'Floors'), 5,
'right',
'UTF-8').
'</button>';
184 print
'<button type="button" class="phonebutton uppercase" onclick="LoadCats();">'.dol_trunc($langs->trans(
'Categories'), 5,
'right',
'UTF-8').
'</button>';
185 print
'<button type="button" class="phonebutton uppercase" onclick="TakeposPrintingOrder();">'.dol_trunc($langs->trans(
'Order'), 5,
'right',
'UTF-8').
'</button>';
186 print
'<button type="button" class="phonebutton uppercase" onclick="CheckPlease();">'.dol_trunc($langs->trans(
'Payment'), 5,
'right',
'UTF-8').
'</button>';
187 print
'<button type="button" class="phonebutton uppercase" onclick="Exit();">'.dol_trunc($langs->trans(
'Logout'), 5,
'right',
'UTF-8').
'</button>';
189 print
'<button type="button" class="publicphonebutton phoneblue uppercase" onclick="LoadCats();">'.dol_trunc($langs->trans(
'Categories'), 8,
'right',
'UTF-8').
'</button>';
190 print
'<button type="button" class="publicphonebutton phoneorange uppercase" onclick="PublicPreOrder();">'.dol_trunc($langs->trans(
'Order'), 8,
'right',
'UTF-8').
'</button>';
196 <div
class=
"phonerow2">
197 <div
id=
"phonediv2" class=
"phonediv2"></div>
199 <div
class=
"phonerow1">
200 <div
id=
"phonediv1" class=
"phonediv1"></div>
204 <script
type=
"text/javascript">
207 $categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ?
$conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1);
211 $levelofrootcategory = 0;
213 foreach ($categories as $key => $categorycursor) {
214 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
215 $levelofrootcategory = $categorycursor[
'level'];
220 $levelofmaincategories = $levelofrootcategory + 1;
222 $maincategories = array();
223 $subcategories = array();
224 foreach ($categories as $key => $categorycursor) {
225 if ($categorycursor[
'level'] == $levelofmaincategories) {
226 $maincategories[$key] = $categorycursor;
228 $subcategories[$key] = $categorycursor;
232 sort($maincategories);
233 sort($subcategories);
236 var categories = <?php echo json_encode($maincategories); ?>;
237 var subcategories = <?php echo json_encode($subcategories); ?>;
241 var pagecategories=0;
243 var place=
"<?php echo $place; ?>";
244 var editaction=
"qty";
248 $( document ).ready(
function() {
249 console.log(
"Refresh");
253 function LoadPlace(placeid){
256 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
257 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?mobilepage=invoice&place="+place+" #tablelines", function() {
260 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=invoice&place="+place+" #tablelines", function() {
267 function AddProduct(placeid, productid){
270 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
271 print
'place=placeid;
272 $("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=productinfo&token='.
newToken().
'&place="+place+"&idproduct="+productid, function() {
275 print
'AddProductConfirm(placeid, productid);';
279 function PublicPreOrder(){
280 $(
"#phonediv1").load(
"'.DOL_URL_ROOT.'/takepos/public/auto_order.php?action=publicpreorder&token=<?php echo newToken(); ?>&place="+place,
function() {
284 function AddProductConfirm(placeid, productid){
287 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
288 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?mobilepage=invoice&action=addline&token='.
newToken().
'&place="+place+"&idproduct="+productid, function() {
291 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=invoice&action=addline&token='.
newToken().
'&place="+place+"&idproduct="+productid, function() {
298 function SetQty(place, selectedline, qty){
299 console.log(
"We click on SetQty()");
301 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
304 $(
"#phonediv2").load(
"<?php echo DOL_URL_ROOT ?>/takepos/public/auto_order.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
308 $(
"#phonediv2").load(
"<?php echo DOL_URL_ROOT ?>/takepos/public/auto_order.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
315 $(
"#phonediv2").load(
"<?php echo DOL_URL_ROOT ?>/takepos/invoice.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
319 $(
"#phonediv2").load(
"<?php echo DOL_URL_ROOT ?>/takepos/invoice.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
329 function SetNote(place, selectedline){
330 console.log(
"We click on SetNote()");
331 var note = prompt(
"<?php dol_escape_js($langs->trans('Note')); ?>",
"");
332 $(
"#phonediv2").load(
"<?php echo DOL_URL_ROOT ?>/takepos/public/auto_order.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
338 console.log(
"We click on LoadCats()");
340 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
342 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?format=div&mobilepage=cats&place="+place+" #tablelines", function() {
345 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=cats&place="+place+"", function() {
351 function LoadProducts(idcat) {
352 console.log(
"We click on LoadProducts()");
354 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
355 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?format=div&mobilepage=products&catid="+idcat+"&place="+place+"", function() {
358 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=products&catid="+idcat+"&place="+place+"", function() {
363 function LoadPlacesList(){
364 $(
"#phonediv1").load(
"invoice.php?mobilepage=places",
function() {
368 function TakeposPrintingOrder(){
369 console.log(
"TakeposPrintingOrder");
371 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
372 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=order&token='.
newToken().
'&mobilepage=order&place="+place, function() {
374 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=publicpayment&token='.
newToken().
'&place="+place, function() {
377 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=order&token='.
newToken().
'&place="+place, function() {
383 console.log(
"Click on Exit");
384 window.location.href=
'<?php echo DOL_URL_ROOT ?>/user/logout.php?token=<?php echo newToken(); ?>';
387 function CheckPlease(payment){
388 console.log(
"Click on CheckPlease");
389 if (payment==undefined){
390 $(
"#phonediv1").load(
"<?php echo DOL_URL_ROOT ?>/takepos/public/auto_order.php?action=checkplease&token=<?php echo newToken(); ?>&place="+place,
function() {
394 console.log(
"Request the check to the waiter");
395 $(
"#phonediv1").load(
"<?php echo DOL_URL_ROOT ?>/takepos/public/auto_order.php?action=checkplease&token=<?php echo newToken(); ?>&place=<?php echo urlencode($place); ?>&payment="+payment,
function() {
404 if (
getDolGlobalString(
'TAKEPOS_NUM_TERMINALS') !=
"1" && $_SESSION[
"takeposterminal"] ==
"") {
405 print
'<div class="dialog-info-takepos-terminal" id="dialog-info" title="TakePOS">'.$langs->trans(
'TerminalSelect').
'</div>';
Class to manage categories.
Class to manage invoices.
Class to manage products or services.
Class to manage Receipt Printers.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.