Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into 12.0

This commit is contained in:
Laurent Destailleur 2020-05-14 16:34:53 +02:00
commit c1fb712c86
6 changed files with 226 additions and 84 deletions

View File

@ -248,11 +248,8 @@ class Dolistore
// phpcs:enable
global $langs, $conf;
$html = "";
$parity = "pair";
$last_month = time() - (30 * 24 * 60 * 60);
foreach ($this->products as $product) {
$parity = ($parity == "impair") ? 'pair' : 'impair';
// check new product ?
$newapp = '';
if ($last_month < strtotime($product->date_add)) {
@ -267,7 +264,7 @@ class Dolistore
// add image or default ?
if ($product->id_default_image != '') {
$image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.$product->id.'&id_image='.$product->id_default_image;
$images = '<a href="'.$image_url.'" class="fancybox" rel="gallery'.$product->id.'" title="'.$product->name->language[$this->lang - 1].', '.$langs->trans('Version').' '.$product->module_version.'">';
$images = '<a href="'.$image_url.'" class="documentpreview" target="_blank" mime="image/png" title="'.$product->name->language[$this->lang - 1].', '.$langs->trans('Version').' '.$product->module_version.'">';
$images .= '<img src="'.$image_url.'&quality=home_default" style="max-height:250px;max-width: 210px;" alt="" /></a>';
} else {
$images = '<img src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />';
@ -306,16 +303,16 @@ class Dolistore
//.'<br><a class="inline-block valignmiddle" target="_blank" href="'.$this->shop_url.$product->id.'"><span class="details button">'.$langs->trans("SeeInMarkerPlace").'</span></a>
//output template
$html .= '<tr class="app '.$parity.' '.$compatible.'">
$html .= '<tr class="app oddeven '.$compatible.'">
<td class="center" width="210"><div class="newAppParent">'.$newapp.$images.'</div></td>
<td class="margeCote"><h2 class="appTitle">'.$product->name->language[$this->lang - 1]
.'<br/><small>'.$version.'</small></h2>
<small> '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'</small><br><br>'.$product->description_short->language[$this->lang - 1].'</td>
<td style="display:none;" class="long_description">'.$product->description->language[$this->lang - 1].'</td>
<td class="margeCote center">'.$price.'
</td>
<td class="margeCote">'.$download_link.'</td>
</tr>';
<small> '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'</small><br><br>'.$product->description_short->language[$this->lang - 1].'</td>';
// do not load if display none
//$html .= '<td style="display:none;" class="long_description">'.$product->description->language[$this->lang - 1].'</td>';
$html .= '<td class="margeCote center">'.$price.'</td>';
$html .= '<td class="margeCote">'.$download_link.'</td>';
$html .= '</tr>';
}
return $html;
}

View File

@ -79,3 +79,31 @@ button.phonebutton {
height:90%;
font-weight: bold;
}
button.publicphonebutton {
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:33%;
height:90%;
font-weight: bold;
}
button.publicphonebutton2 {
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:33%;
font-weight: bold;
padding: 8px 16px;
}

View File

@ -29,5 +29,8 @@ require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php';
$key = GETPOST('key');
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$module = new modTcpdfbarcode();
$result = $module->buildBarCode("http://www.takepos.com", 'QRCODE', 'Y');
$result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".dol_encode($key), 'QRCODE', 'Y');

View File

@ -32,7 +32,7 @@ if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); }
require '../main.inc.php';
if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@ -47,16 +47,11 @@ $idproduct = GETPOST('idproduct', 'int');
$place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant
$placeid = 0; // $placeid is ID of invoice
if ($_SESSION["publicterminal"]) {
$_SESSION["takeposterminal"] = 1; // Use Terminal 1 for public customers
}
elseif (empty($user->rights->takepos->run)) {
if (empty($user->rights->takepos->run) && !defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
accessforbidden();
}
if (($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone') || $_SESSION["publicterminal"])
if (($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))
{
// DIRECT LINK TO THIS PAGE FROM MOBILE AND NO TERMINAL SELECTED
if ($_SESSION["takeposterminal"] == "")
@ -629,6 +624,12 @@ $(document).ready(function() {
if (selectedline==this.id) return; // If is already selected
else selectedline=this.id;
selectedtext=$('#'+selectedline).find("td:first").html();
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
print '$("#phonediv1").load("auto_order.php?action=editline&placeid="+placeid+"&selectedline="+selectedline, function() {
});';
}
?>
});
/* Autoselect the line */
@ -913,7 +914,7 @@ if ($_SESSION["basiclayout"] == 1)
$htmlforlines .= '" onclick="AddProduct(\''.$place.'\', '.$row->id.')">';
$htmlforlines .= '<td class="left">';
$htmlforlines .= $row->label;
$htmlforlines .= '</td>';
$htmlforlines .= '<div class="right">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
$htmlforlines .= '</tr>'."\n";
}
$htmlforlines .= '</table>';
@ -990,6 +991,7 @@ if ($placeid > 0)
}
$htmlforlines .= '" id="'.$line->id.'">';
$htmlforlines .= '<td class="left">';
if ($_SESSION["basiclayout"] == 1) $htmlforlines .= $line->qty." x ";
//if ($line->product_label) $htmlforlines.= '<b>'.$line->product_label.'</b>';
if (isset($line->product_type))
{

View File

@ -45,6 +45,7 @@ if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
else $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Ba or Restaurant
$action = GETPOST('action', 'alpha');
$setterminal = GETPOST('setterminal', 'int');
$idproduct = GETPOST('idproduct', 'int');
if ($setterminal > 0)
{
@ -53,14 +54,10 @@ if ($setterminal > 0)
$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter"));
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
$_SESSION["takeposterminal"] = 1; // Use Terminal 1 for public customers
}
elseif (empty($user->rights->takepos->run)) {
if (empty($user->rights->takepos->run) && !defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
accessforbidden();
}
/*
* View
*/
@ -74,48 +71,82 @@ $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
<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);
print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/takepos/css/phone.css">';
// 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 ($action=="productinfo"){
$prod = new Product($db);
$prod->fetch($idproduct);
print "<b>".$prod->label."</b><br>";
print '<img class="imgwrapper" width="60%" src="'.DOL_URL_ROOT.'/takepos/genimg/index.php?query=pro&id='.$idproduct.'">';
print "<br>".$prod->description;
print "<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1, $conf->currency)."</b>";
print '<br>';
print '<button type="button" class="publicphonebutton2" onclick="AddProductConfirm(place, '.$idproduct.');">'.$langs->trans('Add').'</button>';
}
elseif ($action=="editline"){
$placeid = GETPOST('placeid', 'int');
$selectedline = GETPOST('selectedline', 'int');
$invoice = new Facture($db);
$invoice->fetch($placeid);
foreach ($invoice->lines as $line)
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
$levelofrootcategory = $categorycursor['level'];
break;
if ($line->id == $selectedline)
{
$prod = new Product($db);
$prod->fetch($line->fk_product);
print "<b>".$prod->label."</b><br>";
print '<img class="imgwrapper" width="60%" src="genimg/index.php?query=pro&id='.$line->fk_product.'">';
print "<br>".$prod->description;
print "<br><b>".price($prod->price_ttc, 1, $langs, 1, -1, -1, $conf->currency)."</b>";
print '<br>';
print '<button type="button" class="publicphonebutton2" onclick="SetQty(place, '.$selectedline.', '.($line->qty-1).');">-</button>';
print '<button type="button" class="publicphonebutton2" onclick="SetQty(place, '.$selectedline.', '.($line->qty+1).');">+</button>';
print '<button type="button" class="publicphonebutton2" onclick="SetNote(place, '.$selectedline.');">'.$langs->trans('Note').'</button>';
}
}
}
$levelofmaincategories = $levelofrootcategory + 1;
else {
?>
<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);
$maincategories = array();
$subcategories = array();
foreach ($categories as $key => $categorycursor)
{
if ($categorycursor['level'] == $levelofmaincategories)
{
$maincategories[$key] = $categorycursor;
}
else
{
$subcategories[$key] = $categorycursor;
}
}
// 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;
sort($maincategories);
sort($subcategories);
$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); ?>;
@ -131,33 +162,96 @@ var editnumber="";
$( document ).ready(function() {
console.log("Refresh");
$("#phonediv1").load("invoice.php?mobilepage=places", function() {
});
$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() {
});
LoadPlace(place);
});
function LoadPlace(placeid){
place=placeid;
$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() {
});
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
echo '$("#phonediv2").load("auto_order.php?mobilepage=invoice&place="+place, function() {
});';
}
else{
echo '$("#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() {
<?php
// If is a public terminal first show product information
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
print 'place=placeid;
$("#phonediv1").load("auto_order.php?action=productinfo&place="+place+"&idproduct="+productid, function() {
});';
}
else{
print 'AddProductConfirm(placeid, productid);';
}
?>
}
function AddProductConfirm(placeid, productid){
place=placeid;
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
echo '$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=addline&place="+place+"&idproduct="+productid, function() {
});';
}
else{
echo '$("#phonediv2").load("invoice.php?mobilepage=invoice&action=addline&place="+place+"&idproduct="+productid, function() {
});';
}
?>
}
function SetQty(place, selectedline, qty){
if (qty==0){
$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=deleteline&place="+place+"&idline="+selectedline, function() {
});
}
else{
$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() {
});
}
LoadCats();
}
function SetNote(place, selectedline){
var note = prompt("<?php $langs->trans('Note'); ?>", "Harry Potter");
$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() {
});
LoadCats();
}
function LoadCats(){
$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() {
});
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
echo '$("#phonediv1").load("auto_order.php?mobilepage=cats&place="+place, function() {
});';
}
else{
echo '$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() {
});';
}
?>
}
function LoadProducts(idcat){
$("#phonediv1").load("invoice.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
});
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
echo '$("#phonediv1").load("auto_order.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
});';
}
else{
echo '$("#phonediv1").load("invoice.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
});';
}
?>
}
function LoadPlacesList(){
@ -167,8 +261,16 @@ function LoadPlacesList(){
function TakeposPrintingOrder(){
console.log("TakeposPrintingOrder");
$("#phonediv2").load("invoice.php?action=order&place="+place, function() {
});
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
echo '$("#phonediv2").load("auto_order.php?action=order&place="+place, function() {
});';
}
else{
echo '$("#phonediv2").load("invoice.php?action=order&place="+place, function() {
});';
}
?>
}
function Exit(){
@ -186,17 +288,23 @@ function CheckPlease(){
</script>
<body style="overflow: hidden; background-color:#D1D1D1;">
<?php
if ($conf->global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") print '<div class="dialog-info-takepos-terminal" id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>';
?>
<?php
if ($conf->global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") print '<div class="dialog-info-takepos-terminal" id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>';
?>
<div class="container">
<div class="phonebuttonsrow">
<?php
if (!$_SESSION["publicterminal"]) print '<button type="button" class="phonebutton" onclick="LoadPlacesList();">'.strtoupper(substr($langs->trans('Floors'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="LoadCats();">'.strtoupper(substr($langs->trans('Categories'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();">'.strtoupper(substr($langs->trans('Order'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="Exit();">'.strtoupper(substr($langs->trans('Logout'), 0, 3)).'</button>';
if ($_SESSION["publicterminal"]) print '<button type="button" class="phonebutton" onclick="CheckPlease();">'.strtoupper(substr($langs->trans('Payment'), 0, 3)).'</button>';
if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')){
print '<button type="button" class="phonebutton" onclick="LoadPlacesList();">'.strtoupper(substr($langs->trans('Floors'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="LoadCats();">'.strtoupper(substr($langs->trans('Categories'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();">'.strtoupper(substr($langs->trans('Order'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="Exit();">'.strtoupper(substr($langs->trans('Logout'), 0, 3)).'</button>';
}
else{
print '<button type="button" class="publicphonebutton" onclick="LoadCats();">'.strtoupper(substr($langs->trans('Categories'), 0, 5)).'</button>';
print '<button type="button" class="publicphonebutton" onclick="TakeposPrintingOrder();">'.strtoupper(substr($langs->trans('Order'), 0, 5)).'</button>';
print '<button type="button" class="publicphonebutton" onclick="CheckPlease();">'.strtoupper(substr($langs->trans('Payment'), 0, 5)).'</button>';
}
?>
</div>
<div class="row1">
@ -207,7 +315,8 @@ if ($conf->global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"]
</div>
</div>
</body>
<?php
<?php
}
llxFooter();

View File

@ -26,8 +26,11 @@ if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defin
require '../../main.inc.php';
if (!$conf->global->TAKEPOS_AUTO_ORDER) accessforbidden(); // If Auto Order is disabled never allow NO LOGIN access
$_SESSION["basiclayout"] = 1;
$_SESSION["publicterminal"] = true; // Is a public customer
$_SESSION["takeposterminal"] = 1;
define('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE', 1);
include '../phone.php';
if (GETPOSTISSET("mobilepage")) require '../invoice.php';
else require '../phone.php';