phone.php improvements

This commit is contained in:
andreubisquerra 2020-05-24 16:31:22 +02:00 committed by GitHub
parent 221e8d8ce1
commit c80989d74f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,8 +39,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
// Decode place if it is an order from customer phone // Decode place if it is an order from customer phone
$key = GETPOST('key'); if (GETPOSTISSET("key")) $place = dol_decode(GETPOST('key'));
$place = dol_decode($key); else $place = GETPOST('place', 'aZ09');
} }
else $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Ba or Restaurant else $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Ba or Restaurant
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
@ -87,9 +87,31 @@ elseif ($action == "publicpayment") {
print '<br>'; print '<br>';
} }
elseif ($action == "checkplease") { elseif ($action == "checkplease") {
print '<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans('Cash').'</button>'; if (GETPOSTISSET("payment")){
print '<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans('CreditCard').'</button>'; print '<h1>'.$langs->trans('StatusOrderDelivered').'</h1>';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$printer = new dolReceiptPrinter($db);
$printer->initPrinter($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"]});
$printer->printer->feed();
$printer->printer->feed();
$printer->printer->text($langs->trans('IM'));
$printer->printer->feed();
$printer->printer->text($langs->trans('Place').": ".$place);
$printer->printer->feed();
$printer->printer->text($langs->trans('Payment').": ".$langs->trans(GETPOST('payment', 'alpha')));
$printer->printer->feed();
$printer->printer->feed();
$printer->printer->feed();
$printer->printer->feed();
$printer->printer->feed();
$printer->close();
}
else{
print '<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease(\'Cash\');">'.$langs->trans('Cash').'</button>';
print '<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease(\'CreditCard\');">'.$langs->trans('CreditCard').'</button>';
print '<br>'; print '<br>';
}
} }
elseif ($action == "editline") { elseif ($action == "editline") {
$placeid = GETPOST('placeid', 'int'); $placeid = GETPOST('placeid', 'int');
@ -114,15 +136,15 @@ elseif ($action == "editline") {
} }
} }
else { else {
// Title // Title
$title = 'TakePOS - Dolibarr '.DOL_VERSION; $title = 'TakePOS - Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/> $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>'; <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
$arrayofcss = array('/takepos/css/phone.css'); $arrayofcss = array('/takepos/css/phone.css');
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
?> ?>
<script language="javascript"> <script language="javascript">
<?php <?php
@ -231,6 +253,9 @@ function AddProductConfirm(placeid, productid){
} }
function SetQty(place, selectedline, qty){ function SetQty(place, selectedline, qty){
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
?>
if (qty==0){ if (qty==0){
$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=deleteline&place="+place+"&idline="+selectedline, function() { $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=deleteline&place="+place+"&idline="+selectedline, function() {
}); });
@ -239,6 +264,21 @@ function SetQty(place, selectedline, qty){
$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() { $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() {
}); });
} }
<?php
}
else {
?>
if (qty==0){
$("#phonediv2").load("invoice.php?mobilepage=invoice&action=deleteline&place="+place+"&idline="+selectedline, function() {
});
}
else{
$("#phonediv2").load("invoice.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() {
});
}
<?php
}
?>
LoadCats(); LoadCats();
} }
@ -301,14 +341,16 @@ function Exit(){
window.location.href='../user/logout.php'; window.location.href='../user/logout.php';
} }
function CheckPlease(){ function CheckPlease(payment){
if (payment==undefined){
$("#phonediv1").load("auto_order.php?action=checkplease&place="+place, function() { $("#phonediv1").load("auto_order.php?action=checkplease&place="+place, function() {
}); });
}
else{
console.log("Request the check to the waiter"); console.log("Request the check to the waiter");
$.ajax({ $("#phonediv1").load("auto_order.php?action=checkplease&place=<?php echo $place;?>&payment="+payment, function() {
type: "GET",
url: "<?php print dol_buildpath('/takepos/ajax/ajax.php', 1).'?action=thecheck&=place='.$place; ?>",
}); });
}
} }
</script> </script>