Clean code and debug TakePOS module
This commit is contained in:
parent
e064a954d2
commit
3930464b84
@ -53,6 +53,7 @@ if (empty($conf->dol_no_mouse_hover))
|
||||
hide: { delay: 50 },
|
||||
tooltipClass: "mytooltip",
|
||||
content: function () {
|
||||
console.log("Return title for popup");
|
||||
return $(this).prop(\'title\'); /* To force to get title as is */
|
||||
}
|
||||
});'."\n";
|
||||
|
||||
@ -208,6 +208,13 @@ div.catwatermark{
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.selected {
|
||||
font-weight: bold;
|
||||
}
|
||||
.order {
|
||||
color: limegreen;
|
||||
}
|
||||
|
||||
.colorwhite {
|
||||
color: white;
|
||||
}
|
||||
|
||||
@ -131,8 +131,8 @@ if (($action=="addline" || $action=="freezone") && $placeid == 0)
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
if ($action == "addline") {
|
||||
|
||||
if ($action == "addline")
|
||||
{
|
||||
$prod = new Product($db);
|
||||
$prod->fetch($idproduct);
|
||||
|
||||
@ -269,20 +269,14 @@ if ($action == "order" and $placeid != 0) {
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
?>
|
||||
<style>
|
||||
.selected {
|
||||
font-weight: bold;
|
||||
}
|
||||
.order {
|
||||
color: limegreen;
|
||||
}
|
||||
</style>
|
||||
<script language="javascript">
|
||||
var selectedline=0;
|
||||
var selectedtext="";
|
||||
var placeid=<?php echo $placeid;?>;
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function() {
|
||||
$('table tbody tr').click(function(){
|
||||
$('table tbody tr').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
@ -321,10 +315,9 @@ if ($action == "search") {
|
||||
}
|
||||
|
||||
?>
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$('table tbody tr').click(function(){
|
||||
$('table tbody tr').click(function(){
|
||||
console.log("We click on a line");
|
||||
$('table tbody tr').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
if (selectedline==this.id) return; // If is already selected
|
||||
@ -352,6 +345,7 @@ if ($action == "search") {
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
});
|
||||
|
||||
function Print(id){
|
||||
@ -371,7 +365,16 @@ function TakeposPrinting(id){
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
// Add again js for footer because this content is injected into takepos.php page so all init
|
||||
// for tooltip and other js beautifiers must be reexecuted too.
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
|
||||
print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext?'&'.$ext:'').'"></script>'."\n";
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive-no-min invoice">';
|
||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||
print '<tr class="liste_titre nodrag nodrop">';
|
||||
@ -387,8 +390,22 @@ if ($placeid > 0) {
|
||||
if ($line->special_code == "3") {
|
||||
print ' order';
|
||||
}
|
||||
print '" id="' . $line->rowid . '">';
|
||||
print '<td class="left">' . $line->product_label . $line->desc;
|
||||
print '" id="' . $line->id . '">';
|
||||
print '<td class="left">';
|
||||
print $line->product_label;
|
||||
if ($line->product_label && $line->desc) print '<br>';
|
||||
if ($line->product_label != $line->desc)
|
||||
{
|
||||
$firstline = dolGetFirstLineOfText($line->desc);
|
||||
if ($firstline != $line->desc)
|
||||
{
|
||||
print $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $line->desc;
|
||||
}
|
||||
}
|
||||
if (!empty($line->array_options['options_order_notes'])) echo "<br>(".$line->array_options['options_order_notes'].")";
|
||||
print '</td>';
|
||||
print '<td class="right">' . $line->qty . '</td>';
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
/* Copyright (C) 2018 Charles-FR BENKE <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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@ -31,7 +31,7 @@ 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.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
|
||||
$place = GETPOST('place', 'int');
|
||||
@ -61,9 +61,8 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
|
||||
|
||||
?>
|
||||
<link rel="stylesheet" href="css/pos.css">
|
||||
<script type="text/javascript" src="js/takepos.js" ></script>
|
||||
<link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" />
|
||||
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script> <!-- TODO It seems we don't need this -->
|
||||
<script language="javascript">
|
||||
<?php
|
||||
$categories = $categorie->get_full_arbo('product', 0, (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0));
|
||||
@ -154,7 +153,9 @@ function MoreCategories(moreorless) {
|
||||
}
|
||||
|
||||
function LoadProducts(position, issubcat=false) {
|
||||
$('#catimg'+position).animate({opacity: '0.5'}, 1);
|
||||
var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
|
||||
|
||||
$('#catimg'+position).animate({opacity: '0.5'}, 1);
|
||||
$('#catimg'+position).animate({opacity: '1'}, 100);
|
||||
if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
|
||||
else currentcat=$('#catdiv'+position).data('rowid');
|
||||
@ -163,7 +164,7 @@ function LoadProducts(position, issubcat=false) {
|
||||
ishow=0; //product to show counter
|
||||
|
||||
jQuery.each(subcategories, function(i, val) {
|
||||
if (currentcat==val.fk_parent){
|
||||
if (currentcat==val.fk_parent) {
|
||||
$("#prodesc"+ishow).text(val.label);
|
||||
$("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid);
|
||||
$("#prodiv"+ishow).data("rowid",val.rowid);
|
||||
@ -175,28 +176,35 @@ function LoadProducts(position, issubcat=false) {
|
||||
|
||||
idata=0; //product data counter
|
||||
$.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
|
||||
while (ishow < 30) {
|
||||
console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat);
|
||||
|
||||
while (ishow < maxproduct) {
|
||||
console.log("ishow"+ishow+" idata="+idata);
|
||||
console.log(data[idata]);
|
||||
if (typeof (data[idata]) == "undefined") {
|
||||
$("#prodesc"+ishow).text("");
|
||||
$("#proimg"+ishow).attr("src","genimg/empty.png");
|
||||
$("#prodiv"+ishow).data("rowid","");
|
||||
$("#prowatermark"+ishow).hide();
|
||||
ishow++; //Next product to show after print data product
|
||||
}
|
||||
else if ((data[idata]['status']) == "1") {
|
||||
//Only show products with status=1 (for sell)
|
||||
else if ((data[idata]['status']) == "1") { // Only show products with status=1 (for sell)
|
||||
$("#prodesc"+ishow).text(data[parseInt(idata)]['label']);
|
||||
$("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']);
|
||||
$("#prodiv"+ishow).data("rowid",data[idata]['id']);
|
||||
$("#prodiv"+ishow).data("iscat",0);
|
||||
$("#prowatermark"+ishow).hide();
|
||||
ishow++; //Next product to show after print data product
|
||||
}
|
||||
$("#prowatermark"+ishow).hide();
|
||||
//console.log("Hide the prowatermark for ishow="+ishow);
|
||||
idata++; //Next data everytime
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function MoreProducts(moreorless){
|
||||
function MoreProducts(moreorless) {
|
||||
var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
|
||||
|
||||
if (moreorless=="more"){
|
||||
$('#proimg31').animate({opacity: '0.5'}, 1);
|
||||
$('#proimg31').animate({opacity: '1'}, 100);
|
||||
@ -209,13 +217,16 @@ function MoreProducts(moreorless){
|
||||
pageproducts=pageproducts-1;
|
||||
}
|
||||
$.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
|
||||
if (typeof (data[(30*pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages
|
||||
console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
|
||||
|
||||
if (typeof (data[(maxproduct * pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages
|
||||
pageproducts=pageproducts-1;
|
||||
return;
|
||||
}
|
||||
idata=30*pageproducts; //product data counter
|
||||
ishow=0; //product to show counter
|
||||
while (ishow < 30) {
|
||||
|
||||
while (ishow < maxproduct) {
|
||||
if (typeof (data[idata]) == "undefined") {
|
||||
$("#prodesc"+ishow).text("");
|
||||
$("#proimg"+ishow).attr("src","genimg/empty.png");
|
||||
@ -236,62 +247,65 @@ function MoreProducts(moreorless){
|
||||
});
|
||||
}
|
||||
|
||||
function ClickProduct(position){
|
||||
function ClickProduct(position) {
|
||||
$('#proimg'+position).animate({opacity: '0.5'}, 1);
|
||||
$('#proimg'+position).animate({opacity: '1'}, 100);
|
||||
if ($('#prodiv'+position).data('iscat')==1){
|
||||
console.log("Click on a category at position "+position);
|
||||
LoadProducts(position, true);
|
||||
}
|
||||
else{
|
||||
idproduct=$('#prodiv'+position).data('rowid');
|
||||
console.log("Click on product at position "+position+" for idproduct "+idproduct);
|
||||
if (idproduct=="") return;
|
||||
// Call page invoice.php to generate the section with product lines
|
||||
$("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct, function() {
|
||||
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteline(){
|
||||
function deleteline() {
|
||||
$("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() {
|
||||
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
|
||||
});
|
||||
}
|
||||
|
||||
function Customer(){
|
||||
function Customer() {
|
||||
$.colorbox({href:"customers.php?nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Customer");?>"});
|
||||
}
|
||||
|
||||
function CloseBill(){
|
||||
function CloseBill() {
|
||||
invoiceid = $("#invoiceid").val();
|
||||
console.log("Open popup to enter payment on invoiceid="+invoiceid);
|
||||
$.colorbox({href:"pay.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
|
||||
}
|
||||
|
||||
function Floors(){
|
||||
function Floors() {
|
||||
$.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors");?>"});
|
||||
}
|
||||
|
||||
function FreeZone(){
|
||||
function FreeZone() {
|
||||
$.colorbox({href:"freezone.php?action=freezone&place="+place, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone");?>"});
|
||||
}
|
||||
|
||||
function TakeposOrderNotes(){
|
||||
function TakeposOrderNotes() {
|
||||
$.colorbox({href:"freezone.php?action=addnote&place="+place+"&idline="+selectedline, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("OrderNotes");?>"});
|
||||
}
|
||||
|
||||
function Refresh(){
|
||||
function Refresh() {
|
||||
$("#poslines").load("invoice.php?place="+place, function() {
|
||||
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
|
||||
});
|
||||
}
|
||||
|
||||
function Search(){
|
||||
function Search() {
|
||||
$("#poslines").load("invoice.php?action=search&place="+place, function() {
|
||||
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
|
||||
});
|
||||
}
|
||||
|
||||
function Search2(){
|
||||
function Search2() {
|
||||
pageproducts=0;
|
||||
$.getJSON('./ajax.php?action=search&term='+$('#search').val(), function(data) {
|
||||
for (i = 0; i < 30; i++) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user