Phone layout and functional improvements

This commit is contained in:
andreubisquerra 2019-10-16 16:26:00 +02:00
parent 7a927a22e3
commit 8f03813aa9
4 changed files with 291 additions and 30 deletions

View File

@ -0,0 +1,81 @@
html,body {
box-sizing: border-box;
padding:3px;
margin:0;
height:100%;
width:100%;
}
.container{
width: 100%;
height: 100%;
margin: 0 auto;
overflow: visible;
box-sizing: border-box;
}
.phonerow1{
margin: 0 auto;
width: 100%;
height: 40%;
min-height: 40%;
}
.phonerow2{
margin: 0 auto;
width: 100%;
height: 40%;
}
.phonebuttonsrow{
margin: 0 auto;
width: 100%;
height: 5%;
}
.phonediv1{
height:100%;
min-height: 100%;
width: 100%;
text-align: center;
box-sizing: border-box;
overflow: auto;
padding-top: 0;
padding-bottom: 10px;
padding-right: 5px;
padding-left: 5px;
}
.phonediv2{
height: 100%;
width: 100%;
box-sizing: border-box;
padding-top: 0;
padding-bottom: 10px;
padding-right: 5px;
padding-left: 5px;
}
.phonediv3{
height: 100%;
width: 100%;
box-sizing: border-box;
padding-top: 0;
padding-bottom: 10px;
padding-right: 5px;
padding-left: 5px;
}
button.phonebutton {
display: inline-block;
position: relative;
padding: 0;
line-height: normal;
cursor: pointer;
vertical-align: middle;
text-align: center;
overflow: visible; /* removes extra width in IE */
width:24%;
height:90%;
font-weight: bold;
}

View File

@ -570,13 +570,19 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
$label = $obj->label;
$floor = $obj->floor;
}
print $langs->trans('Place')." <b>".$label."</b> - ";
print $langs->trans('Floor')." <b>".$floor."</b> - ";
// In phone version only show when is invoice page
if ($mobilepage=="invoice" || $mobilepage=="") {
print $langs->trans('Place') . " <b>" . $label . "</b> - ";
print $langs->trans('Floor') . " <b>" . $floor . "</b> - ";
}
}
// In phone version only show when is invoice page
if ($mobilepage=="invoice" || $mobilepage=="") {
print $langs->trans('TotalTTC');
print ' : <b>' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . '</b></span>';
print '<br>' . $sectionwithinvoicelink;
print '</td>';
}
print $langs->trans('TotalTTC');
print ' : <b>'.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</b></span>';
print '<br>'.$sectionwithinvoicelink;
print '</td>';
if ($_SESSION["basiclayout"]!=1)
{
print '<td class="linecolqty right">' . $langs->trans('ReductionShort') . '</td>';
@ -595,16 +601,14 @@ if ($_SESSION["basiclayout"]==1)
$htmlforlines = '';
foreach ($categories as $row){
$htmlforlines.= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines.= '" onclick="location.href=\'invoice.php?mobilepage=products&place=' . $place . '&catid=' . $row['id'] . '\'">';
$htmlforlines.= '" onclick="LoadProducts(' . $row['id'] . ');">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $row['label'];
$htmlforlines.= '</td>';
$htmlforlines.= '</tr>'."\n";
}
$htmlforlines.= '</table>';
$htmlforlines.= '<div class="tabsAction">';
$htmlforlines.= '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?mobilepage=places&place=' . $place. '">'.$langs->trans("Floors").'</a>';
$htmlforlines.= '</div>';
$htmlforlines.= '</table>';
print $htmlforlines;
}
@ -618,17 +622,13 @@ if ($_SESSION["basiclayout"]==1)
$htmlforlines = '';
foreach ($prods as $row) {
$htmlforlines.= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines.= '" onclick="location.href=\'invoice.php?mobilepage=invoice&action=addline&place=' . $place . '&idproduct=' . $row->id . '\'">';
$htmlforlines.= '" onclick="AddProduct(\'' . $place . '\', ' . $row->id . ')">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $row->label;
$htmlforlines.= '</td>';
$htmlforlines.= '</tr>'."\n";
}
$htmlforlines.= '</table>';
$htmlforlines.= '<div class="tabsAction">';
$htmlforlines.= '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?mobilepage=cats&place=' . $place. '">'.$langs->trans("Categories").'</a>';
$htmlforlines.= '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?mobilepage=places&place=' . $place. '">'.$langs->trans("Floors").'</a>';
$htmlforlines.= '</div>';
print $htmlforlines;
}
@ -641,24 +641,22 @@ if ($_SESSION["basiclayout"]==1)
while($row = $db->fetch_array($resql)){
$rows[] = $row;
$htmlforlines.= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines.= '" onclick="location.href=\'invoice.php?mobilepage=invoice&place=' . $row['label'] . '\'">';
$htmlforlines.= '" onclick="LoadPlace(\'' . $row['label'] . '\')">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $row['label'];
$htmlforlines.= '</td>';
$htmlforlines.= '</tr>'."\n";
}
$htmlforlines.= '</table>';
$htmlforlines.= '<div class="tabsAction">';
$htmlforlines.= '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?mobilepage=cats&place=' . $place. '">'.$langs->trans("Categories").'</a>';
$htmlforlines.= '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?mobilepage=places&place=' . $place. '">'.$langs->trans("Floors").'</a>';
$htmlforlines.= '</div>';
print $htmlforlines;
}
}
if ($placeid > 0)
{
if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice") return;
//In Phone basic layout hide some content depends situation
if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice" && $action!="order") return;
if (is_array($invoice->lines) && count($invoice->lines))
{
$tmplines = array_reverse($invoice->lines);
@ -716,14 +714,6 @@ else { // No invoice generated yet
print '</table>';
if ($_SESSION["basiclayout"]==1 && $mobilepage=="invoice")
{
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?mobilepage=cats&place=' . $place. '">'.$langs->trans("Categories").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?mobilepage=places&place=' . $place. '">'.$langs->trans("Floors").'</a>';
print '</div>';
}
if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]})
{
$soc = new Societe($db);

190
htdocs/takepos/phone.php Normal file
View File

@ -0,0 +1,190 @@
<?php
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/takepos/phone.php
* \ingroup takepos
* \brief TakePOS Phone screen
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$action = GETPOST('action', 'alpha');
$setterminal = GETPOST('setterminal', 'int');
if ($setterminal>0)
{
$_SESSION["takeposterminal"]=$setterminal;
}
$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter"));
/*
* View
*/
// Title
$title='TakePOS - Dolibarr '.DOL_VERSION;
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
$head='<meta name="apple-mobile-web-app-title" content="TakePOS"/>
<meta name="apple-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"/>';
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
?>
<link rel="stylesheet" href="css/phone.css">
<script language="javascript">
<?php
$categorie = new Categorie($db);
$categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0), 1);
// Search root category to know its level
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
$levelofrootcategory=0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
{
foreach($categories as $key => $categorycursor)
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
$levelofrootcategory = $categorycursor['level'];
break;
}
}
}
$levelofmaincategories = $levelofrootcategory + 1;
$maincategories = array();
$subcategories = array();
foreach($categories as $key => $categorycursor)
{
if ($categorycursor['level'] == $levelofmaincategories)
{
$maincategories[$key] = $categorycursor;
}
else
{
$subcategories[$key] = $categorycursor;
}
}
sort($maincategories);
sort($subcategories);
?>
var categories = <?php echo json_encode($maincategories); ?>;
var subcategories = <?php echo json_encode($subcategories); ?>;
var currentcat;
var pageproducts=0;
var pagecategories=0;
var pageactions=0;
var place="<?php echo $place;?>";
var editaction="qty";
var editnumber="";
$( document ).ready(function() {
console.log("Refresh");
$("#phonediv1").load("invoice.php?mobilepage=places", function() {
});
$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() {
});
});
function LoadPlace(placeid){
place=placeid;
$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() {
});
LoadCats();
}
function AddProduct(placeid, productid){
place=placeid;
$("#phonediv2").load("invoice.php?mobilepage=invoice&action=addline&place="+place+"&idproduct="+productid, function() {
});
}
function LoadCats(){
$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() {
});
}
function LoadProducts(idcat){
$("#phonediv1").load("invoice.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
});
}
function LoadPlacesList(){
$("#phonediv1").load("invoice.php?mobilepage=places", function() {
});
}
function TakeposPrintingOrder(){
console.log("TakeposPrintingOrder");
$("#phonediv2").load("invoice.php?action=order&place="+place, function() {
});
}
function Exit(){
window.location.href='../user/logout.php';
}
</script>
<body style="overflow: hidden; background-color:#D1D1D1;">
<?php
if ($conf->global->TAKEPOS_NUM_TERMINALS!="1" && $_SESSION["takeposterminal"]=="") print '<div id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>';
?>
<div class="container">
<div class="phonebuttonsrow">
<button type="button" class="phonebutton" onclick="LoadPlacesList();"><?php echo strtoupper(substr($langs->trans('Floors'), 0, 3));?></button>
<button type="button" class="phonebutton" onclick="LoadCats();"><?php echo strtoupper(substr($langs->trans('Categories'), 0, 3));?></button>
<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();"><?php echo strtoupper(substr($langs->trans('Order'), 0, 3));?></button>
<button type="button" class="phonebutton" onclick="Exit();"><?php echo strtoupper(substr($langs->trans('Logout'), 0, 3));?></button>
</div>
<div class="row1">
<div id="phonediv1" class="phonediv1"></div>
</div>
<div class="row2">
<div id="phonediv2" class="phonediv2"></div>
</div>
</div>
</body>
<?php
llxFooter();
$db->close();

View File

@ -63,7 +63,7 @@ if ($conf->browser->layout == 'phone')
if ($_SESSION["takeposterminal"]!="" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT==1)
{
$_SESSION["basiclayout"]=1;
header("Location: invoice.php?mobilepage=invoice");
header("Location: phone.php?mobilepage=invoice");
exit;
}
}