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');
58$mobilepage =
GETPOST(
'mobilepage',
'alphanohtml');
60if ($setterminal > 0) {
61 $_SESSION[
"takeposterminal"] = $setterminal;
64$langs->loadLangs(array(
"bills",
"orders",
"commercial",
"cashdesk",
"receiptprinter"));
66if (!$user->hasRight(
'takepos',
'run') && !defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
75$title =
'TakePOS - Dolibarr '.DOL_VERSION;
81if (empty($mobilepage) && (empty($action) || ((
getDolGlobalString(
'TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->layout ==
'phone') || defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')))) {
82 $head =
'<meta name="apple-mobile-web-app-title" content="TakePOS"/>
83 <meta name="apple-mobile-web-app-capable" content="yes">
84 <meta name="mobile-web-app-capable" content="yes">
85 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
87 '/takepos/css/phone.css',
89 $arrayofjs = array(
'/takepos/js/jquery.colorbox-min.js');
92 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
94 print
'<body style="background-color:#D1D1D1;">'.
"\n";
102if ($action ==
"productinfo" && $user->hasRight(
'takepos',
'run')) {
104 $prod->fetch($idproduct);
105 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="AddProductConfirm(place, '.$idproduct.
')">'.$langs->trans(
'Add').
'</button>';
106 print
"<br><b>".$prod->label.
"</b><br>";
107 print
'<img class="imgwrapper" width="60%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$idproduct.
'">';
108 print
"<br>".$prod->description;
109 print
"<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).
"</b>";
111} elseif ($action ==
"publicpreorder" && $user->hasRight(
'takepos',
'run')) {
112 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="TakeposPrintingOrder();">'.$langs->trans(
'Confirm').
'</button>';
114 print
'<div class="comment">
115 <textarea class="textinput " placeholder="'.$langs->trans(
'Note').
'"></textarea>
118} elseif ($action ==
"publicpayment" && $user->hasRight(
'takepos',
'run')) {
119 $langs->loadLangs(array(
"orders"));
120 print
'<h1>'.$langs->trans(
'Ordered').
'</h1>';
121 print
'<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans(
'Payment').
'</button>';
123} elseif ($action ==
"checkplease" && $user->hasRight(
'takepos',
'run')) {
124 if (GETPOSTISSET(
"payment")) {
125 print
'<h1>'.$langs->trans(
'Ordered').
'</h1>';
126 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
127 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
129 $printer->initPrinter(
getDolGlobalString(
'TAKEPOS_PRINTER_TO_USE'.$_SESSION[
"takeposterminal"]));
130 if ($printer->getPrintConnector()) {
131 if (!is_null($printer->printer)) {
132 $printer->printer->feed();
133 $printer->printer->feed();
134 $printer->printer->text($langs->trans(
'IM'));
135 $printer->printer->feed();
136 $printer->printer->text($langs->trans(
'Place').
": ".$place);
137 $printer->printer->feed();
138 $printer->printer->text($langs->trans(
'Payment').
": ".$langs->trans(
GETPOST(
'payment',
'alpha')));
139 $printer->printer->feed();
140 $printer->printer->feed();
141 $printer->printer->feed();
142 $printer->printer->feed();
143 $printer->printer->feed();
148 print
'<button type="button" class="publicphonebutton2 phoneblue total marginbottomonly" onclick="CheckPlease(\'Cash\')">'.$langs->trans(
'Cash').
'</button>';
149 print
'<button type="button" class="publicphonebutton2 phoneblue total marginbottomonly" onclick="CheckPlease(\'CreditCard\')">'.$langs->trans(
'CreditCard').
'</button>';
152} elseif ($action ==
"editline" && $user->hasRight(
'takepos',
'run')) {
156 $invoice->fetch($placeid);
157 foreach ($invoice->lines as $line) {
158 if ($line->id == $selectedline) {
160 $prod->fetch($line->fk_product);
161 print
"<b>".$prod->label.
"</b><br>";
162 print
'<img class="imgwrapper" width="60%" src="'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$line->fk_product.
'">';
163 print
"<br>".$prod->description;
164 print
"<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).
"</b>";
166 print
'<button type="button" class="publicphonebutton2 phonered width24" onclick="SetQty(place, '.$selectedline.
', '.($line->qty - 1).
')">-</button>';
167 print
'<button type="button" class="publicphonebutton2 phonegreen width24" onclick="SetQty(place, '.$selectedline.
', '.($line->qty + 1).
')">+</button>';
168 print
'<button type="button" class="publicphonebutton2 phoneblue width24" onclick="SetNote(place, '.$selectedline.
')">'.$langs->trans(
'Note').
'</button>';
173 <div
class=
"container">
174 <div
class=
"phonebuttonsrow center">
176 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
177 print
'<button type="button" class="phonebutton uppercase" onclick="LoadPlacesList();">'.dol_trunc($langs->trans(
'Floors'), 5,
'right',
'UTF-8').
'</button>';
178 print
'<button type="button" class="phonebutton uppercase" onclick="LoadCats();">'.dol_trunc($langs->trans(
'Categories'), 5,
'right',
'UTF-8').
'</button>';
179 print
'<button type="button" class="phonebutton uppercase" onclick="TakeposPrintingOrder();">'.dol_trunc($langs->trans(
'Order'), 5,
'right',
'UTF-8').
'</button>';
180 print
'<button type="button" class="phonebutton uppercase" onclick="CheckPlease();">'.dol_trunc($langs->trans(
'Payment'), 5,
'right',
'UTF-8').
'</button>';
181 print
'<button type="button" class="phonebutton uppercase" onclick="Exit();">'.dol_trunc($langs->trans(
'Logout'), 5,
'right',
'UTF-8').
'</button>';
183 print
'<button type="button" class="publicphonebutton phoneblue uppercase" onclick="LoadCats();">'.dol_trunc($langs->trans(
'Categories'), 8,
'right',
'UTF-8').
'</button>';
184 print
'<button type="button" class="publicphonebutton phoneorange uppercase" onclick="PublicPreOrder();">'.dol_trunc($langs->trans(
'Order'), 8,
'right',
'UTF-8').
'</button>';
190 <div
class=
"phonerow2">
191 <div
id=
"phonediv2" class=
"phonediv2"></div>
193 <div
class=
"phonerow1">
194 <div
id=
"phonediv1" class=
"phonediv1"></div>
198 <script
type=
"text/javascript">
201 $categories = $categorie->get_full_arbo(
'product', ((
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID') > 0) ? $conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1);
205 $levelofrootcategory = 0;
207 foreach ($categories as $key => $categorycursor) {
208 if ($categorycursor[
'id'] ==
getDolGlobalInt(
'TAKEPOS_ROOT_CATEGORY_ID')) {
209 $levelofrootcategory = $categorycursor[
'level'];
214 $levelofmaincategories = $levelofrootcategory + 1;
216 $maincategories = array();
217 $subcategories = array();
218 foreach ($categories as $key => $categorycursor) {
219 if ($categorycursor[
'level'] == $levelofmaincategories) {
220 $maincategories[$key] = $categorycursor;
222 $subcategories[$key] = $categorycursor;
226 sort($maincategories);
227 sort($subcategories);
230 var categories = <?php echo json_encode($maincategories); ?>;
231 var subcategories = <?php echo json_encode($subcategories); ?>;
235 var pagecategories=0;
237 var place=
"<?php echo $place; ?>";
238 var editaction=
"qty";
242 $( document ).ready(
function() {
243 console.log(
"Refresh");
247 function LoadPlace(placeid){
250 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
251 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?mobilepage=invoice&place="+place+" #tablelines", function() {
254 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=invoice&place="+place+" #tablelines", function() {
261 function AddProduct(placeid, productid){
264 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
265 print
'place=placeid;
266 $("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=productinfo&token='.
newToken().
'&place="+place+"&idproduct="+productid, function() {
269 print
'AddProductConfirm(placeid, productid);';
273 function PublicPreOrder(){
274 $(
"#phonediv1").load(
"'.DOL_URL_ROOT.'/takepos/public/auto_order.php?action=publicpreorder&token=<?php echo newToken(); ?>&place="+place,
function() {
278 function AddProductConfirm(placeid, productid){
281 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
282 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?mobilepage=invoice&action=addline&token='.
newToken().
'&place="+place+"&idproduct="+productid, function() {
285 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=invoice&action=addline&token='.
newToken().
'&place="+place+"&idproduct="+productid, function() {
292 function SetQty(place, selectedline, qty){
293 console.log(
"We click on SetQty()");
295 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
298 $(
"#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() {
302 $(
"#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() {
309 $(
"#phonediv2").load(
"<?php echo DOL_URL_ROOT ?>/takepos/invoice.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+
"&idline="+selectedline,
function() {
313 $(
"#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() {
323 function SetNote(place, selectedline){
324 console.log(
"We click on SetNote()");
325 var note = prompt(
"<?php dol_escape_js($langs->trans('Note')); ?>",
"");
326 $(
"#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() {
332 console.log(
"We click on LoadCats()");
334 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
336 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?format=div&mobilepage=cats&place="+place+" #tablelines", function() {
339 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=cats&place="+place+"", function() {
345 function LoadProducts(idcat) {
346 console.log(
"We click on LoadProducts()");
348 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
349 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?format=div&mobilepage=products&catid="+idcat+"&place="+place+"", function() {
352 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?mobilepage=products&catid="+idcat+"&place="+place+"", function() {
357 function LoadPlacesList(){
358 $(
"#phonediv1").load(
"invoice.php?mobilepage=places",
function() {
362 function TakeposPrintingOrder(){
363 console.log(
"TakeposPrintingOrder");
365 if (defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
366 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=order&token='.
newToken().
'&mobilepage=order&place="+place, function() {
368 echo
'$("#phonediv1").load("'.DOL_URL_ROOT.
'/takepos/public/auto_order.php?action=publicpayment&token='.
newToken().
'&place="+place, function() {
371 echo
'$("#phonediv2").load("'.DOL_URL_ROOT.
'/takepos/invoice.php?action=order&token='.
newToken().
'&place="+place, function() {
377 console.log(
"Click on Exit");
378 window.location.href=
'<?php echo DOL_URL_ROOT ?>/user/logout.php?token=<?php echo newToken(); ?>';
381 function CheckPlease(payment){
382 console.log(
"Click on CheckPlease");
383 if (payment==undefined){
384 $(
"#phonediv1").load(
"<?php echo DOL_URL_ROOT ?>/takepos/public/auto_order.php?action=checkplease&token=<?php echo newToken(); ?>&place="+place,
function() {
388 console.log(
"Request the check to the waiter");
389 $(
"#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() {
398 if (
getDolGlobalString(
'TAKEPOS_NUM_TERMINALS') !=
"1" && $_SESSION[
"takeposterminal"] ==
"") {
399 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.
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.