28 if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL',
'1');
31 if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34 if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37 if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
41 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
42 require
'../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
49 if (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');
59 if ($setterminal > 0) {
60 $_SESSION[
"takeposterminal"] = $setterminal;
63 $langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter"));
65 if (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');
91 if ($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") {
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);
192 var categories = <?php echo json_encode($maincategories); ?>;
193 var subcategories = <?php echo json_encode($subcategories); ?>;
197 var pagecategories=0;
199 var place=
"<?php echo $place; ?>";
200 var editaction=
"qty";
204 $( document ).ready(
function() {
205 console.log(
"Refresh");
209 function 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() {
223 function 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);';
236 function PublicPreOrder(){
237 $(
"#phonediv1").load(
"auto_order.php?action=publicpreorder&token=<?php echo newToken(); ?>&place="+place,
function() {
241 function 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() {
254 function SetQty(place, selectedline, qty){
256 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
259 $(
"#phonediv2").load(
"auto_order.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
263 $(
"#phonediv2").load(
"auto_order.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
270 $(
"#phonediv2").load(
"invoice.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
274 $(
"#phonediv2").load(
"invoice.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
283 function SetNote(place, selectedline){
284 var note = prompt(
"<?php $langs->trans('Note'); ?>",
"");
285 $(
"#phonediv2").load(
"auto_order.php?mobilepage=invoice&action=updateqty&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline+
"&number="+qty,
function() {
292 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
293 echo
'$("#phonediv1").load("auto_order.php?mobilepage=cats&place="+place, function() {
296 echo
'$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() {
302 function LoadProducts(idcat){
305 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
306 echo
'$("#phonediv1").load("auto_order.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
309 echo
'$("#phonediv1").load("invoice.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
315 function LoadPlacesList(){
316 $(
"#phonediv1").load(
"invoice.php?mobilepage=places",
function() {
320 function TakeposPrintingOrder(){
321 console.log(
"TakeposPrintingOrder");
323 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
324 echo
'$("#phonediv2").load("auto_order.php?action=order&token='.newToken().
'&mobilepage=order&place="+place, function() {
326 echo
'$("#phonediv1").load("auto_order.php?action=publicpayment&token='.newToken().
'&place="+place, function() {
329 echo
'$("#phonediv2").load("invoice.php?action=order&token='.newToken().
'&place="+place, function() {
336 window.location.href=
'../user/logout.php?token=<?php echo newToken(); ?>';
339 function CheckPlease(payment){
340 if (payment==undefined){
341 $(
"#phonediv1").load(
"auto_order.php?action=checkplease&token=<?php echo newToken(); ?>&place="+place,
function() {
345 console.log(
"Request the check to the waiter");
346 $(
"#phonediv1").load(
"auto_order.php?action=checkplease&token=<?php echo newToken(); ?>&place=<?php echo $place; ?>&payment="+payment,
function() {
353 <body style=
"background-color:#D1D1D1;">
355 if ($conf->global->TAKEPOS_NUM_TERMINALS !=
"1" && $_SESSION[
"takeposterminal"] ==
"") {
356 print
'<div class="dialog-info-takepos-terminal" id="dialog-info" title="TakePOS">'.$langs->trans(
'TerminalSelect').
'</div>';
359 <div
class=
"container">
360 <div
class=
"phonebuttonsrow">
362 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
363 print
'<button type="button" class="phonebutton" onclick="LoadPlacesList();">'.strtoupper(substr($langs->trans(
'Floors'), 0, 3)).
'</button>';
364 print
'<button type="button" class="phonebutton" onclick="LoadCats();">'.strtoupper(substr($langs->trans(
'Categories'), 0, 3)).
'</button>';
365 print
'<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();">'.strtoupper(substr($langs->trans(
'Order'), 0, 3)).
'</button>';
366 print
'<button type="button" class="phonebutton" onclick="Exit();">'.strtoupper(substr($langs->trans(
'Logout'), 0, 3)).
'</button>';
368 print
'<button type="button" class="publicphonebutton phoneblue" onclick="LoadCats();">'.strtoupper(substr($langs->trans(
'Categories'), 0, 5)).
'</button>';
369 print
'<button type="button" class="publicphonebutton phoneorange" onclick="PublicPreOrder();">'.strtoupper(substr($langs->trans(
'Order'), 0, 5)).
'</button>';
370 print
'<button type="button" class="publicphonebutton phonegreen" onclick="CheckPlease();">'.strtoupper(substr($langs->trans(
'Payment'), 0, 5)).
'</button>';
374 <div
class=
"phonerow2">
375 <div
id=
"phonediv2" class=
"phonediv2"></div>
377 <div
class=
"phonerow1">
378 <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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
if(!defined('NOREQUIREMENU')) 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.