28if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL',
'1');
31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
41if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
42 require
'../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
49if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
53 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') : 0);
55$action =
GETPOST(
'action',
'aZ09');
56$setterminal =
GETPOST(
'setterminal',
'int');
57$idproduct =
GETPOST(
'idproduct',
'int');
59if ($setterminal > 0) {
60 $_SESSION[
"takeposterminal"] = $setterminal;
63$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter"));
65if (empty($user->rights->takepos->run) && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
76 $title =
'TakePOS - Dolibarr '.DOL_VERSION;
77 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
78 $title =
'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
80 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
81 <meta name="apple-mobile-web-app-capable" content="yes">
82 <meta name="mobile-web-app-capable" content="yes">
83 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
84 $arrayofcss = array(
'/takepos/css/phone.css');
91if ($action ==
"productinfo") {
93 $prod->fetch($idproduct);
94 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="AddProductConfirm(place, '.$idproduct.
')">'.$langs->trans(
'Add').
'</button>';
95 print
"<br><b>".$prod->label.
"</b><br>";
96 print
'<img class="imgwrapper" width="60%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$idproduct.
'">';
97 print
"<br>".$prod->description;
98 print
"<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).
"</b>";
100} elseif ($action ==
"publicpreorder") {
101 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="TakeposPrintingOrder();">'.$langs->trans(
'Confirm').
'</button>';
103 print
'<div class="comment">
104 <textarea class="textinput" placeholder="'.$langs->trans(
'Note').
'"></textarea>
107} elseif ($action ==
"publicpayment") {
108 $langs->loadLangs(array(
"orders"));
109 print
'<h1>'.$langs->trans(
'StatusOrderDelivered').
'</h1>';
110 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans(
'Payment').
'</button>';
112} elseif ($action ==
"checkplease") {
113 if (GETPOSTISSET(
"payment")) {
114 print
'<h1>'.$langs->trans(
'StatusOrderDelivered').
'</h1>';
115 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
116 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
118 $printer->initPrinter($conf->global->{
'TAKEPOS_PRINTER_TO_USE'.$_SESSION[
"takeposterminal"]});
119 $printer->printer->feed();
120 $printer->printer->feed();
121 $printer->printer->text($langs->trans(
'IM'));
122 $printer->printer->feed();
123 $printer->printer->text($langs->trans(
'Place').
": ".$place);
124 $printer->printer->feed();
125 $printer->printer->text($langs->trans(
'Payment').
": ".$langs->trans(
GETPOST(
'payment',
'alpha')));
126 $printer->printer->feed();
127 $printer->printer->feed();
128 $printer->printer->feed();
129 $printer->printer->feed();
130 $printer->printer->feed();
133 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease(\'Cash\')">'.$langs->trans(
'Cash').
'</button>';
134 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease(\'CreditCard\')">'.$langs->trans(
'CreditCard').
'</button>';
137} elseif ($action ==
"editline") {
138 $placeid =
GETPOST(
'placeid',
'int');
139 $selectedline =
GETPOST(
'selectedline',
'int');
141 $invoice->fetch($placeid);
142 foreach ($invoice->lines as $line) {
143 if ($line->id == $selectedline) {
145 $prod->fetch($line->fk_product);
146 print
"<b>".$prod->label.
"</b><br>";
147 print
'<img class="imgwrapper" width="60%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$line->fk_product.
'">';
148 print
"<br>".$prod->description;
149 print
"<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).
"</b>";
151 print
'<button type="button" class="publicphonebutton2 phonered width24" onclick="SetQty(place, '.$selectedline.
', '.($line->qty - 1).
')">-</button>';
152 print
'<button type="button" class="publicphonebutton2 phonegreen width24" onclick="SetQty(place, '.$selectedline.
', '.($line->qty + 1).
')">+</button>';
153 print
'<button type="button" class="publicphonebutton2 phoneblue width24" onclick="SetNote(place, '.$selectedline.
')">'.$langs->trans(
'Note').
'</button>';
158<script
type=
"text/javascript">
161 $categories = $categorie->get_full_arbo(
'product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) ? $conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1);
165 $levelofrootcategory = 0;
166 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
167 foreach ($categories as $key => $categorycursor) {
168 if ($categorycursor[
'id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
169 $levelofrootcategory = $categorycursor[
'level'];
174 $levelofmaincategories = $levelofrootcategory + 1;
176 $maincategories = array();
177 $subcategories = array();
178 foreach ($categories as $key => $categorycursor) {
179 if ($categorycursor[
'level'] == $levelofmaincategories) {
180 $maincategories[$key] = $categorycursor;
182 $subcategories[$key] = $categorycursor;
186 sort($maincategories);
187 sort($subcategories);
192var categories = <?php echo json_encode($maincategories); ?>;
193var subcategories = <?php echo json_encode($subcategories); ?>;
199var place=
"<?php echo $place; ?>";
204$( document ).ready(
function() {
205 console.log(
"Refresh");
209function LoadPlace(placeid){
212 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
213 echo
'$("#phonediv2").load("auto_order.php?mobilepage=invoice&place="+place, function() {
216 echo
'$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() {
223function AddProduct(placeid, productid){
226 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
227 print
'place=placeid;
228 $("#phonediv1").load("auto_order.php?action=productinfo&token='.newToken().
'&place="+place+"&idproduct="+productid, function() {
231 print
'AddProductConfirm(placeid, productid);';
236function PublicPreOrder(){
237 $(
"#phonediv1").load(
"auto_order.php?action=publicpreorder&token=<?php echo newToken(); ?>&place="+place,
function() {
241function AddProductConfirm(placeid, productid){
244 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
245 echo
'$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=addline&token='.newToken().
'&place="+place+"&idproduct="+productid, function() {
248 echo
'$("#phonediv2").load("invoice.php?mobilepage=invoice&action=addline&token='.newToken().
'&place="+place+"&idproduct="+productid, function() {
256function SetQty(place, selectedline, qty){
258 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
261 $(
"#phonediv2").load(
"auto_order.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
265 $(
"#phonediv2").load(
"auto_order.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
272 $(
"#phonediv2").load(
"invoice.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
276 $(
"#phonediv2").load(
"invoice.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
287function SetNote(place, selectedline){
288 var note = prompt(
"<?php $langs->trans('Note'); ?>",
"");
289 $(
"#phonediv2").load(
"auto_order.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
296 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
297 echo
'$("#phonediv1").load("auto_order.php?mobilepage=cats&place="+place, function() {
300 echo
'$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() {
306function LoadProducts(idcat){
309 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
310 echo
'$("#phonediv1").load("auto_order.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
313 echo
'$("#phonediv1").load("invoice.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
319function LoadPlacesList(){
320 $(
"#phonediv1").load(
"invoice.php?mobilepage=places",
function() {
324function TakeposPrintingOrder(){
325 console.log(
"TakeposPrintingOrder");
327 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
328 echo
'$("#phonediv2").load("auto_order.php?action=order&token='.newToken().
'&mobilepage=order&place="+place, function() {
330 echo
'$("#phonediv1").load("auto_order.php?action=publicpayment&token='.newToken().
'&place="+place, function() {
333 echo
'$("#phonediv2").load("invoice.php?action=order&token='.newToken().
'&place="+place, function() {
340 window.location.href=
'../user/logout.php?token=<?php echo newToken(); ?>';
343function CheckPlease(payment){
344 if (payment==undefined){
345 $(
"#phonediv1").load(
"auto_order.php?action=checkplease&token=<?php echo newToken(); ?>&place="+place,
function() {
349 console.log(
"Request the check to the waiter");
350 $(
"#phonediv1").load(
"auto_order.php?action=checkplease&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&payment="+payment,
function() {
357<body style=
"background-color:#D1D1D1;">
359 if ($conf->global->TAKEPOS_NUM_TERMINALS !=
"1" && $_SESSION[
"takeposterminal"] ==
"") {
360 print
'<div class="dialog-info-takepos-terminal" id="dialog-info" title="TakePOS">'.$langs->trans(
'TerminalSelect').
'</div>';
363<div
class=
"container">
364 <div
class=
"phonebuttonsrow">
366 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
367 print
'<button type="button" class="phonebutton" onclick="LoadPlacesList();">'.strtoupper(substr($langs->trans(
'Floors'), 0, 3)).
'</button>';
368 print
'<button type="button" class="phonebutton" onclick="LoadCats();">'.strtoupper(substr($langs->trans(
'Categories'), 0, 3)).
'</button>';
369 print
'<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();">'.strtoupper(substr($langs->trans(
'Order'), 0, 3)).
'</button>';
370 print
'<button type="button" class="phonebutton" onclick="Exit();">'.strtoupper(substr($langs->trans(
'Logout'), 0, 3)).
'</button>';
372 print
'<button type="button" class="publicphonebutton phoneblue" onclick="LoadCats();">'.strtoupper(substr($langs->trans(
'Categories'), 0, 5)).
'</button>';
373 print
'<button type="button" class="publicphonebutton phoneorange" onclick="PublicPreOrder();">'.strtoupper(substr($langs->trans(
'Order'), 0, 5)).
'</button>';
374 print
'<button type="button" class="publicphonebutton phonegreen" onclick="CheckPlease();">'.strtoupper(substr($langs->trans(
'Payment'), 0, 5)).
'</button>';
378 <div
class=
"phonerow2">
379 <div
id=
"phonediv2" class=
"phonediv2"></div>
381 <div
class=
"phonerow1">
382 <div
id=
"phonediv1" class=
"phonediv1"></div>
Class to manage categories.
Class to manage invoices.
Class to manage products or services.
Class to manage Receipt Printers.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
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.