--- /tmp/dsg/dolibarr/htdocs/takepos/github_floors.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_floors.php @@ -23,23 +23,22 @@ //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('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'); +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.'/compta/facture/class/facture.class.php'; $langs->loadLangs(array("bills", "orders", "commercial", "cashdesk")); $floor = GETPOST('floor', 'int'); if ($floor == "") $floor = 1; $id = GETPOST('id', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $left = GETPOST('left', 'alpha'); $top = GETPOST('top', 'alpha'); @@ -59,39 +58,36 @@ if ($action == "getTables") { - $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor; - $resql = $db->query($sql); - $rows = array(); - while ($row = $db->fetch_array($resql)) { - $invoice = new Facture($db); - $result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')'); - if ($result > 0) $row['occupied'] = "red"; - $rows[] = $row; - } - echo json_encode($rows); - exit; + $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor; + $resql = $db->query($sql); + $rows = array(); + while ($row = $db->fetch_array($resql)) { + $rows[] = $row; + } + echo json_encode($rows); + exit; } if ($action == "update") { - if ($left > 95) $left = 95; - if ($top > 95) $top = 95; - if ($left > 3 or $top > 4) $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=".$left.", toppos=".$top." WHERE rowid='".$place."'"); - else $db->query("DELETE from ".MAIN_DB_PREFIX."takepos_floor_tables where rowid='".$place."'"); + if ($left > 95) $left = 95; + if ($top > 95) $top = 95; + if ($left > 3 or $top > 4) $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=".$left.", toppos=".$top." WHERE rowid='".$place."'"); + else $db->query("DELETE from ".MAIN_DB_PREFIX."takepos_floor_tables where rowid='".$place."'"); } if ($action == "updatename") { - $newname = preg_replace("/[^a-zA-Z0-9\s]/", "", $newname); // Only English chars - if (strlen($newname) > 3) $newname = substr($newname, 0, 3); // Only 3 chars - $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'"); + $newname = preg_replace("/[^a-zA-Z0-9\s]/", "", $newname); // Only English chars + if (strlen($newname) > 3) $newname = substr($newname, 0, 3); // Only 3 chars + $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'"); } if ($action == "add") { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."takepos_floor_tables(entity, label, leftpos, toppos, floor) VALUES (".$conf->entity.", '', '45', '45', ".$floor.")"; - $asdf = $db->query($sql); - $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names + $sql = "INSERT INTO ".MAIN_DB_PREFIX."takepos_floor_tables(entity, label, leftpos, toppos, floor) VALUES (".$conf->entity.", '', '45', '45', ".$floor.")"; + $asdf = $db->query($sql); + $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names } @@ -116,9 +112,6 @@ text-align: center; font-size:300%; color:white; -} -div.red{ -color:red; } html, body { @@ -179,7 +172,7 @@ $(this).focus(); }) - $('body').append('
'+val.label+'
'); + $('body').append('
'+val.label+'
'); }); }); --- /tmp/dsg/dolibarr/htdocs/takepos/github_freezone.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_freezone.php @@ -1,6 +1,5 @@ - * Copyright (C) 2020 Laurent Destailleur +/* Copyright (C) 2018 Andreu Bisquerra * * 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 @@ -24,13 +23,13 @@ //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('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'); +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/lib/functions.lib.php'; @@ -44,7 +43,7 @@ $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant $idline = GETPOST('idline', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); if (empty($user->rights->takepos->run)) { accessforbidden(); --- /tmp/dsg/dolibarr/htdocs/takepos/github_index.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_index.php @@ -1,7 +1,6 @@ * Copyright (C) 2019 Josep LluĂ­s Amador - * Copyright (C) 2020 Thibault FOUCART * * 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 @@ -25,13 +24,13 @@ //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('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'); +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.form.class.php'; @@ -40,28 +39,14 @@ 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'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant or multiple sales -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $setterminal = GETPOST('setterminal', 'int'); -$setcurrency = GETPOST('setcurrency', 'aZ09'); - -if ($_SESSION["takeposterminal"] == "") -{ - if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal - elseif (!empty($_COOKIE["takeposterminal"])) $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session -} if ($setterminal > 0) { $_SESSION["takeposterminal"] = $setterminal; - setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie -} - -if ($setcurrency != "") -{ - $_SESSION["takeposcustomercurrency"] = $setcurrency; } $_SESSION["urlfrom"] = '/takepos/index.php'; @@ -74,8 +59,8 @@ $maxproductbydefaultforthisdevice = 24; if ($conf->browser->layout == 'phone') { - $maxcategbydefaultforthisdevice = 8; - $maxproductbydefaultforthisdevice = 16; + $maxcategbydefaultforthisdevice = 8; + $maxproductbydefaultforthisdevice = 16; //REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT ENABLED if ($_SESSION["takeposterminal"] != "" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) { @@ -131,28 +116,29 @@ $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; - } - } -} - + 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; - } + if ($categorycursor['level'] == $levelofmaincategories) + { + $maincategories[$key] = $categorycursor; + } + else + { + $subcategories[$key] = $categorycursor; + } } $maincategories = dol_sort_array($maincategories, 'label'); @@ -169,7 +155,6 @@ var place=""; var editaction="qty"; var editnumber=""; -var invoiceid=0; /* var app = this; @@ -300,18 +285,12 @@ //console.log("ishow"+ishow+" idata="+idata); console.log(data[idata]); if (typeof (data[idata]) == "undefined") { - global->TAKEPOS_HIDE_PRODUCT_IMAGES) - { - echo '$("#prodivdesc"+ishow).hide();'; - echo '$("#prodesc"+ishow).text("");'; - echo '$("#proimg"+ishow).attr("title","");'; - echo '$("#proimg"+ishow).attr("src","genimg/empty.png");'; - } else { - echo '$("#probutton"+ishow).hide();'; - echo '$("#probutton"+ishow).text("");'; - }?> + $("#prodivdesc"+ishow).hide(); + $("#prodesc"+ishow).text(""); $("#proprice"+ishow).attr("class", "hidden"); $("#proprice"+ishow).html(""); + $("#proimg"+ishow).attr("title",""); + $("#proimg"+ishow).attr("src","genimg/empty.png"); $("#prodiv"+ishow).data("rowid",""); $("#prodiv"+ishow).attr("class","wrapper2 divempty"); $("#prowatermark"+ishow).hide(); @@ -323,22 +302,14 @@ $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']"; ?> var titlestring = ; - global->TAKEPOS_HIDE_PRODUCT_IMAGES) - { - echo '$("#prodivdesc"+ishow).show();'; - echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; - echo '$("#proimg"+ishow).attr("title", titlestring);'; - echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; - } - else { - echo '$("#probutton"+ishow).show();'; - echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);'; - } - ?> + $("#prodivdesc"+ishow).show(); + $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); if (data[parseInt(idata)]['price_formated']) { $("#proprice"+ishow).attr("class", "productprice"); $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); } + $("#proimg"+ishow).attr("title", titlestring); + $("#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); $("#prodiv"+ishow).attr("class","wrapper2"); @@ -430,18 +401,9 @@ ClearSearch(); } -function ChangeThirdparty(idcustomer) { - console.log("ChangeThirdparty"); - // Call page list.php to change customer - $("#poslines").load("../societe/list.php?action=change&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() { - }); - - ClearSearch(); -} - function deleteline() { console.log("Delete line"); - $("#poslines").load("invoice.php?action=deleteline&token=&place="+place+"&idline="+selectedline, function() { + $("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); ClearSearch(); @@ -449,7 +411,7 @@ function Customer() { console.log("Open box to select the thirdparty place="+place); - $.colorbox({href:"../societe/list.php?type=t&contextpage=poslist&nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("Customer"); ?>"}); + $.colorbox({href:"../societe/list.php?contextpage=poslist&nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("Customer"); ?>"}); } function History() @@ -486,18 +448,17 @@ } function Refresh() { - console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid); - $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() { + console.log("Refresh"); + $("#poslines").load("invoice.php?place="+place, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } function New() { // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined + console.log("New with place = , js place="+place); + invoiceid = $("#invoiceid").val(); - - console.log("New with place = , js place="+place+", invoiceid="+invoiceid); - $.getJSON('/takepos/ajax/ajax.php?action=getInvoice&id='+invoiceid, function(data) { var r; @@ -508,8 +469,7 @@ } if (r == true) { - // Reload section with invoice lines - $("#poslines").load("invoice.php?action=delete&token=&place=" + place, function () { + $("#poslines").load("invoice.php?action=delete&place=" + place, function () { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); ClearSearch(); @@ -565,28 +525,13 @@ // If there is only 1 answer if ($('#search').val().length > 0 && data.length == 1) { console.log($('#search').val()+' - '+data[0]['barcode']); - if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) { - console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']); - ChangeThirdparty(data[0]['rowid']); - } - else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) { + if ($('#search').val() == data[0]['barcode']) { console.log("There is only 1 answer with barcode matching the search, so we add the product in basket"); ClickProduct(0); } } - if (eventKeyCode == keyCodeForEnter){ - if (data.length == 0) { - $('#search').val('load('errors'); - echo dol_escape_js($langs->trans("ErrorRecordNotFound")); - ?>'); - $('#search').select(); - } - else ClearSearch(); - } }); } - } function Edit(number) { @@ -687,19 +632,16 @@ } function OpenDrawer(){ - console.log("OpenDrawer call ajax url http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print"); + console.log("OpenDrawer"); $.ajax({ type: "POST", - global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',"; - else echo "url: 'http://".$conf->global->TAKEPOS_PRINT_SERVER.":8111/print',"; - ?> + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', data: "opendrawer" }); } function DolibarrOpenDrawer() { - console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&term="); + console.log("DolibarrOpenDrawer"); $.ajax({ type: "GET", url: "", @@ -738,11 +680,30 @@ $.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"trans("CashReport"); ?>"}); } -// TakePOS Popup -function ModalBox(ModalID) -{ - var modal = document.getElementById(ModalID); - modal.style.display = "block"; +// Popup to select the terminal to use +function TerminalsDialog() +{ + jQuery("#dialog-info").dialog({ + resizable: false, + height: global->TAKEPOS_NUM_TERMINALS / 3 * 20); ?>, + width: dol_optimize_smallscreen ? 316 : 400); ?>, + modal: true, + buttons: { + 'trans("Terminal")) ?> 1': function() { + location.href='index.php?setterminal=1'; + } + global->TAKEPOS_NUM_TERMINALS; $i++) + { + print ", + '".dol_escape_js($langs->trans("Terminal"))." ".$i."': function() { + location.href='index.php?setterminal=".$i."'; + } + "; + } + ?> + } + }); } function DirectPayment(){ @@ -753,19 +714,6 @@ function FullScreen() { document.documentElement.requestFullscreen(); -} - -function WeighingScale(){ - console.log("Weighing Scale"); - $.ajax({ - type: "POST", - url: 'global->TAKEPOS_PRINT_SERVER; ?>/scale/index.php', - }) - .done(function( editnumber ) { - $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { - editnumber=""; - }); - }); } $( document ).ready(function() { @@ -776,12 +724,14 @@ //IF NO TERMINAL SELECTED if ($_SESSION["takeposterminal"] == "") { - print "ModalBox('ModalTerminal');"; - } - if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { - $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; - $sql .= " entity = ".$conf->entity." AND "; - $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; + if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; + else print "TerminalsDialog();"; + } + if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) + { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE "; + $sql .= "date(date_creation) = CURDATE() "; + $sql .= ""; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -795,6 +745,7 @@ '.$langs->trans('TerminalSelect').''; $keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : ''; ?>
@@ -806,7 +757,7 @@
@@ -1106,17 +983,20 @@ $count = 0; while ($count < $MAXCATEG) { - ?> + ?>
id="catdiv"> '; - echo ''; - } elseif ($count == ($MAXCATEG - 1)) { - //echo ''; - echo ''; - } else { - if (!$conf->global->TAKEPOS_HIDE_CATEGORY_IMAGES) echo ''; + //echo ''; + echo ''; + } + elseif ($count == ($MAXCATEG - 1)) { + //echo ''; + echo ''; + } + else + { + echo ''; } ?> @@ -1127,7 +1007,7 @@
...
@@ -1135,27 +1015,27 @@
+ $count = 0; + while ($count < $MAXPRODUCT) + { + ?>
onclick="MoreProducts('less');" onclick="MoreProducts('more');" > '; - print ''; - } elseif ($count == ($MAXPRODUCT - 1)) { - //echo ''; - print ''; - } else { - if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) echo ''; - else { - print '
'; - print ''; - } - } - ?> - global->TAKEPOS_HIDE_PRODUCT_IMAGES) { ?> + if ($count == ($MAXPRODUCT - 2)) { + //echo ''; + print ''; + } + elseif ($count == ($MAXPRODUCT - 1)) { + //echo ''; + print ''; + } + else + { + print '
'; + print ''; + } + ?> +
@@ -1163,9 +1043,9 @@
...
+ $count++; + } + ?>
--- /tmp/dsg/dolibarr/htdocs/takepos/github_invoice.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_invoice.php @@ -39,23 +39,17 @@ global $mysoc; -$langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks", "banks")); +$langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks")); $id = GETPOST('id', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $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 -// Terminal is stored into $_SESSION["takeposterminal"]; if (empty($user->rights->takepos->run) && !defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { accessforbidden(); } - - -/* - * View - */ if (($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { @@ -63,7 +57,8 @@ if ($_SESSION["takeposterminal"] == "") { if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; - else { + else + { header("Location: ".DOL_URL_ROOT."/takepos/index.php"); exit; } @@ -100,8 +95,8 @@ $number = GETPOST('number', 'alpha'); $idline = GETPOST('idline', 'int'); $selectedline = GETPOST('selectedline', 'int'); -$desc = GETPOST('desc', 'alphanohtml'); -$pay = GETPOST('pay', 'aZ09'); +$desc = GETPOST('desc', 'alpha'); +$pay = GETPOST('pay', 'alpha'); $amountofpayment = price2num(GETPOST('amount', 'alpha')); $invoiceid = GETPOST('invoiceid', 'int'); @@ -116,19 +111,22 @@ $sql .= " WHERE entity IN (".getEntity('c_paiement').")"; $sql .= " AND code = '".$db->escape($paycode)."'"; $resql = $db->query($sql); -$obj = $db->fetch_object($resql); -$paiementid = $obj->id; +$codes = $db->fetch_array($resql); +$paiementid = $codes[0]; + $invoice = new Facture($db); if ($invoiceid > 0) { - $ret = $invoice->fetch($invoiceid); -} else { - $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); + $ret = $invoice->fetch($invoiceid); +} +else +{ + $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); } if ($ret > 0) { - $placeid = $invoice->id; + $placeid = $invoice->id; } $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; @@ -142,44 +140,28 @@ * Actions */ -// Action to record a payment on a TakePOS invoice if ($action == 'valid' && $user->rights->facture->creer) { - $bankaccount = 0; - $error = 0; - - if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { - $bankaccount = GETPOST('accountid', 'int'); - } else { - if ($pay == "cash") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility - elseif ($pay == "card") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION["takeposterminal"]}; // For backward compatibility - elseif ($pay == "cheque") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility - else { - $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; - $bankaccount = $conf->global->$accountname; - } - } - - if ($bankaccount <= 0 && $pay != "delayed") { - $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); - $error++; - } - + if ($pay == "cash") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility + elseif ($pay == "card") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION["takeposterminal"]}; // For backward compatibility + elseif ($pay == "cheque") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility + else + { + $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; + $bankaccount = $conf->global->$accountname; + } $now = dol_now(); $res = 0; $invoice = new Facture($db); $invoice->fetch($placeid); - if ($invoice->total_ttc < 0) { $invoice->type = $invoice::TYPE_CREDIT_NOTE; - - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; - $sql .= " fk_soc = ".((int) $invoice->socid); - $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; - $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; - $sql .= " ORDER BY rowid DESC"; - + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE "; + $sql .= "fk_soc = '".$invoice->socid."' "; + $sql .= "AND type <> ".Facture::TYPE_CREDIT_NOTE." "; + $sql .= "AND fk_statut >= ".$invoice::STATUS_VALIDATED." "; + $sql .= "ORDER BY rowid DESC"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -202,21 +184,21 @@ //} $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if ($error) { - dol_htmloutput_errors($errormsg, null, 1); - } elseif ($invoice->statut != Facture::STATUS_DRAFT) { + if ($invoice->statut != Facture::STATUS_DRAFT) { //If invoice is validated but it is not fully paid is not error and make the payment - if ($invoice->getRemainToPay() > 0) { - $res = 1; - } else { + if ($invoice->getRemainToPay() > 0) $res = 1; + else { dol_syslog("Sale already validated"); dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); } - } elseif (count($invoice->lines) == 0) { - $error++; - dol_syslog('Sale without lines'); + } + elseif (count($invoice->lines) == 0) + { + dol_syslog("Sale without lines"); dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); - } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + } + elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") + { $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; $conf->global->STOCK_CALCULATE_ON_BILL = 1; @@ -230,12 +212,10 @@ $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $invoice->validate($user); - if ($res < 0) { - $error++; - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } + } + else + { + $res = $invoice->validate($user); } // Restore save values @@ -244,30 +224,26 @@ // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; //} + $remaintopay = $invoice->getRemainToPay(); + // Add the payment - if (!$error && $res >= 0) { - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) { - $payment = new Paiement($db); - $payment->datepaye = $now; - $payment->fk_account = $bankaccount; - $payment->amounts[$invoice->id] = $amountofpayment; - if ($pay == 'cash') $payment->pos_change = price2num(GETPOST('excess', 'alpha')); - - // If user has not used change control, add total invoice payment - // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay - if ($amountofpayment == 0 || $amountofpayment > $remaintopay) $payment->amounts[$invoice->id] = $remaintopay; - - $payment->paiementid = $paiementid; - $payment->num_payment = $invoice->ref; - - if ($pay != "delayed") { - $payment->create($user); - $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded - } - } - + if ($res >= 0 && $remaintopay > 0) { + $payment = new Paiement($db); + $payment->datepaye = $now; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; + + // If user has not used change control, add total invoice payment + // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay + if ($amountofpayment == 0 || $amountofpayment > $remaintopay) $payment->amounts[$invoice->id] = $remaintopay; + + $payment->paiementid = $paiementid; + $payment->num_payment = $invoice->ref; + + $payment->create($user); + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + + $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded if ($remaintopay == 0) { dol_syslog("Invoice is paid, so we set it to status Paid"); $result = $invoice->set_paid($user); @@ -279,167 +255,14 @@ } } else { dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } -} - -if ($action == 'creditnote') -{ - $creditnote = new Facture($db); - $creditnote->socid = $invoice->socid; - $creditnote->date = dol_now(); - $creditnote->type = Facture::TYPE_CREDIT_NOTE; - $creditnote->fk_facture_source = $placeid; - $creditnote->remise_absolue = $invoice->remise_absolue; - $creditnote->remise_percent = $invoice->remise_percent; - $creditnote->create($user); - - foreach ($invoice->lines as $line) - { - // Extrafields - if (method_exists($line, 'fetch_optionals')) { - // load extrafields - $line->fetch_optionals(); - } - // Reset fk_parent_line for no child products and special product - if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { - $fk_parent_line = 0; - } - if ($invoice->type == Facture::TYPE_SITUATION) - { - $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id - $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($invoice->tab_previous_situation_invoice)) - { - // search the last standard invoice in cycle and the possible credit note between this last and invoice - // TODO Move this out of loop of $invoice->lines - $tab_jumped_credit_notes = array(); - $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { - $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; - } - $lineIndex--; // go to previous invoice in cycle - } - } - - $maxPrevSituationPercent = 0; - foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $source_fk_prev_id) - { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - - //$line->subprice = $line->subprice - $prevLine->subprice; - $line->total_ht = $line->total_ht - $prevLine->total_ht; - $line->total_tva = $line->total_tva - $prevLine->total_tva; - $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; - $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; - $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - } - } - - // prorata - $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - - // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) - $maxPrevSituationPercent = 0; - foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) - { - if ($prevLine->fk_prev_id == $source_fk_prev_id) - { - $maxPrevSituationPercent = $prevLine->situation_percent; - - $line->total_ht -= $prevLine->total_ht; - $line->total_tva -= $prevLine->total_tva; - $line->total_ttc -= $prevLine->total_ttc; - $line->total_localtax1 -= $prevLine->total_localtax1; - $line->total_localtax2 -= $prevLine->total_localtax2; - - $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; - } - } - } - - // prorata - $line->situation_percent += $maxPrevSituationPercent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - } - } - - $line->fk_facture = $creditnote->id; - $line->fk_parent_line = $fk_parent_line; - - $line->subprice = -$line->subprice; // invert price for object - $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here - $line->total_ht = -$line->total_ht; - $line->total_tva = -$line->total_tva; - $line->total_ttc = -$line->total_ttc; - $line->total_localtax1 = -$line->total_localtax1; - $line->total_localtax2 = -$line->total_localtax2; - - $line->multicurrency_subprice = -$line->multicurrency_subprice; - $line->multicurrency_total_ht = -$line->multicurrency_total_ht; - $line->multicurrency_total_tva = -$line->multicurrency_total_tva; - $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; - - $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked - - $creditnote->lines[] = $line; // insert new line in current object - - // Defined the new fk_parent_line - if ($result > 0 && $line->product_type == 9) { - $fk_parent_line = $result; - } - } - $creditnote->update_price(1); - - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { - $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; - $conf->global->STOCK_CALCULATE_ON_BILL = 1; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $batch_rule = 0; - if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; - $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; - } - $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); - $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $creditnote->validate($user); - } -} - -if ($action == 'history' || $action == 'creditnote') -{ - if ($action == 'creditnote') $placeid = $creditnote->id; - else $placeid = (int) GETPOST('placeid', 'int'); - $invoice = new Facture($db); - $invoice->fetch($placeid); -} - -if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "") { - $invoice->setMulticurrencyCode($_SESSION["takeposcustomercurrency"]); + } +} + +if ($action == 'history') +{ + $placeid = (int) GETPOST('placeid', 'int'); + $invoice = new Facture($db); + $invoice->fetch($placeid); } if (($action == "addline" || $action == "freezone") && $placeid == 0) @@ -448,13 +271,14 @@ $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; - $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; if ($invoice->socid <= 0) { $langs->load('errors'); dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); - } else { + } + else + { $placeid = $invoice->create($user); if ($placeid < 0) { @@ -468,7 +292,7 @@ if ($action == "addline") { $prod = new Product($db); - $prod->fetch($idproduct); + $prod->fetch($idproduct); $customer = new Societe($db); $customer->fetch($invoice->socid); @@ -517,7 +341,6 @@ } } if ($idoflineadded <= 0) { - $invoice->fetch_thirdparty(); $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, '', '', 0, 100, '', null, 0); } @@ -525,112 +348,109 @@ } if ($action == "freezone") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); + $customer = new Societe($db); + $customer->fetch($invoice->socid); $tva_tx = GETPOST('tva_tx', 'alpha'); if ($tva_tx != '') { - if (!preg_match('/\((.*)\)/', $tva_tx)) { - $tva_tx = price2num($tva_tx); - } + $tva_tx = price2num($tva_tx); } else { $tva_tx = get_default_tva($mysoc, $customer); } - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - - $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); - $invoice->fetch($placeid); + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $invoice->fetch($placeid); } if ($action == "addnote") { - foreach ($invoice->lines as $line) - { - if ($line->id == $number) + foreach ($invoice->lines as $line) + { + if ($line->id == $number) { $line->array_options['order_notes'] = $desc; $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } - } - $invoice->fetch($placeid); + } + } + $invoice->fetch($placeid); } if ($action == "deleteline") { - if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. - $invoice->deleteline($idline); - $invoice->fetch($placeid); - } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - $deletelineid = $row[0]; - $invoice->deleteline($deletelineid); - $invoice->fetch($placeid); - } - if (count($invoice->lines) == 0) { - $invoice->delete($user); - header("Location: ".DOL_URL_ROOT."/takepos/invoice.php"); - exit; - } -} - -// Action to delete or discard an invoice + if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. + $invoice->deleteline($idline); + $invoice->fetch($placeid); + } + elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='".$placeid."' order by rowid DESC"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + $deletelineid = $row[0]; + $invoice->deleteline($deletelineid); + $invoice->fetch($placeid); + } +} + if ($action == "delete") { // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. + + /*$reg = array(); + if (preg_match('/^(\d+)-(\d+)$/', $place, $reg)) { + + $place = $reg[1]; + var_dump($place); + }*/ + if ($placeid > 0) { - $result = $invoice->fetch($placeid); - - if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) - { - $db->begin(); - - // We delete the lines - $resdeletelines = 1; - foreach ($invoice->lines as $line) { - $tmpres = $invoice->deleteline($line->id); - if ($tmpres < 0) { - $resdeletelines = 0; - break; - } - } - - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql .= " SET fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}.", "; - $sql .= " datec = '".$db->idate(dol_now())."'"; - $sql .= " WHERE ref='(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; - $resql1 = $db->query($sql); - - if ($resdeletelines && $resql1) { + $result = $invoice->fetch($placeid); + + if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) + { + $db->begin(); + + // We delete the lines + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_extrafields where fk_object = ".$placeid; + $resql1 = $db->query($sql); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".$placeid; + $resql2 = $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; + $sql .= " WHERE ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql3 = $db->query($sql); + + if ($resql1 && $resql2 && $resql3) + { $db->commit(); - } else { + } + else + { $db->rollback(); } - $invoice->fetch($placeid); - } - } + $invoice->fetch($placeid); + } + } } if ($action == "updateqty") { - foreach ($invoice->lines as $line) - { - if ($line->id == $idline) - { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } - } - - $invoice->fetch($placeid); + foreach ($invoice->lines as $line) + { + if ($line->id == $idline) + { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + } + + $invoice->fetch($placeid); } if ($action == "updateprice") { - foreach ($invoice->lines as $line) - { - if ($line->id == $idline) + foreach ($invoice->lines as $line) + { + if ($line->id == $idline) { $prod = new Product($db); $prod->fetch($line->fk_product); @@ -644,16 +464,17 @@ if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { echo $langs->trans("CantBeLessThanMinPrice"); - } else $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } - } - $invoice->fetch($placeid); + } + else $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + } + $invoice->fetch($placeid); } if ($action == "updatereduction") { - foreach ($invoice->lines as $line) - { + foreach ($invoice->lines as $line) + { if ($line->id == $idline) { $prod = new Product($db); @@ -668,9 +489,10 @@ if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->multicurrency_subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { echo $langs->trans("CantBeLessThanMinPrice"); - } else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } - } + } + else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + } $invoice->fetch($placeid); } elseif ($action == 'update_reduction_global') { foreach ($invoice->lines as $line) { @@ -682,152 +504,105 @@ if ($action == "order" and $placeid != 0) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; $printer = new dolReceiptPrinter($db); } - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); - $resql = $db->query($sql); - $row = $db->fetch_object($resql); - $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'; - $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; - $order_receipt_printer1 = ""; - $order_receipt_printer2 = ""; - $order_receipt_printer3 = ""; - $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); - $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); - $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); - foreach ($invoice->lines as $line) - { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter1, $existing); - $count = count($result); - if (!$line->fk_product) $count++; // Print Free-text item (Unassigned printer) to Printer 1 - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 - $db->query($sql); - $order_receipt_printer1 .= ''; - if ($line->fk_product) $order_receipt_printer1 .= $line->product_label; - else $order_receipt_printer1 .= $line->description; - $order_receipt_printer1 .= ''.$line->qty; + $headerorder = '
'.$langs->trans('Place').' '.$place.'
'; + $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; + $order_receipt_printer1 = ""; + $order_receipt_printer2 = ""; + $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); + $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); + foreach ($invoice->lines as $line) + { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter1, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 + $db->query($sql); + $order_receipt_printer1 .= ''.$line->product_label.''.$line->qty; if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "
(".$line->array_options['options_order_notes'].")"; $order_receipt_printer1 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + } + } + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 1; - echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); $invoice->fetch($placeid); //Reload object after set lines as printed $linestoprint = 0; - foreach ($invoice->lines as $line) - { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter2, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 - $db->query($sql); - $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; + foreach ($invoice->lines as $line) + { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter2, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 + $db->query($sql); + $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2 .= "
(".$line->array_options['options_order_notes'].")"; $order_receipt_printer2 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + } + } + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 2; - echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint = 0; - - foreach ($invoice->lines as $line) - { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter3, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 - $db->query($sql); - $order_receipt_printer3 .= ''.$line->product_label.''.$line->qty; - if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; - $order_receipt_printer3 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 3; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed } $sectionwithinvoicelink = ''; -if ($action == "valid" || $action == "history" || $action == 'creditnote') -{ - $sectionwithinvoicelink .= ''."\n"; - $sectionwithinvoicelink .= ''; - $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) - { - $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; - } else { - if ($invoice->paye) $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; - else $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); - } - $sectionwithinvoicelink .= '
'; - if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { +if ($action == "valid" || $action == "history") +{ + $sectionwithinvoicelink .= ''."\n"; + $sectionwithinvoicelink .= ''; + $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay > 0) + { + $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; + } + else + { + if ($invoice->paye) $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; + else $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); + } + $sectionwithinvoicelink .= ''; + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) $sectionwithinvoicelink .= ' '; else $sectionwithinvoicelink .= ' '; - } elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { - $sectionwithinvoicelink .= ' '; - } else { - $sectionwithinvoicelink .= ' '; - if ($conf->global->TAKEPOS_GIFT_RECEIPT) { - $sectionwithinvoicelink .= ' '; - } - } - if ($conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) - { - $sectionwithinvoicelink .= ' '; - } - - if ($remaintopay <= 0 && $conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= ''; + } elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { + $sectionwithinvoicelink .= ' '; + } else { + $sectionwithinvoicelink .= ' '; + } + if ($conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) + { + $sectionwithinvoicelink .= ' '; + } + + if ($remaintopay <= 0 && $conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= ''; } /* @@ -852,7 +627,7 @@ else selectedline=this.id; selectedtext=$('#'+selectedline).find("td:first").html(); global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { - ?> - $.ajax({ - type: "POST", - url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php', - data: 'invoice='+orderprinter1esc - }); - - $.ajax({ - type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', - data: '' - }); - global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { - ?> - $.ajax({ - type: "POST", - url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2', - data: 'invoice='+orderprinter2esc - }); - - $.ajax({ - type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print2', - data: '' - }); - global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { - ?> - $.ajax({ - type: "POST", - url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3', - data: 'invoice='+orderprinter3esc - }); - - parent.setFocusOnSearchField(); - + ?> $.ajax({ type: "POST", url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', data: '' + print $headerorder.$order_receipt_printer1.$footerorder; ?>' }); + $.ajax({ + type: "POST", + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print2', + data: '' + }); + + parent.setFocusOnSearchField(); + + $.ajax({ + type: "POST", + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', + data: '' + }); + + ?> $('#search').focus(); trans("SendTicket"); ?>"}); } -function Print(id, gift){ - $.colorbox({href:"receipt.php?facid="+id+"&gift="+gift, width:"40%", height:"90%", transition:"none", iframe:"true", title:"trans("PrintTicket"); ?>"}); +function Print(id){ + $.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"trans("PrintTicket"); ?>"}); } function TakeposPrinting(id){ var receipt; - console.log("TakeposPrinting" + id); $.get("receipt.php?facid="+id, function(data, status){ receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, ''); $.ajax({ @@ -977,92 +717,78 @@ } function TakeposConnector(id){ - console.log("TakeposConnector" + id); - $.get("ajax/ajax.php?action=printinvoiceticket&term=&id="+id, function(data, status){ - $.ajax({ - type: "POST", - url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php', - data: 'invoice='+data - }); + var invoice=''; + $.ajax({ + type: "POST", + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print.php', + data: 'invoice='+invoice }); } function DolibarrTakeposPrinting(id) { - console.log("DolibarrTakeposPrinting Printing invoice ticket " + id) + console.log('Printing invoice ticket ' + id) $.ajax({ type: "GET", url: "" + id, }); } -function CreditNote() { - $("#poslines").load("invoice.php?action=creditnote&invoiceid="+placeid, function() { - }); -} - $( document ).ready(function() { - console.log("Set customer info and sales in header placeid= status=statut; ?>"); + console.log("Set customer info and sales in header"); trans("Customer"); - if ($invoice->id > 0 && ($invoice->socid != $conf->global->$constforcompanyid)) { - $s = $soc->name; - } - ?> + $s = $langs->trans("Customer"); + if ($invoice->id > 0 && ($invoice->socid != $conf->global->$constforcompanyid)) { + $s = $soc->name; + } + ?> $("#customerandsales").html(''); - $("#customerandsales").append(''); + $("#customerandsales").append(''); global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) { - // By default, only invoices with a ref not already defined can in list of open invoice we can edit. - $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape($_SESSION["takeposterminal"])."-0%' AND entity IN (".getEntity('invoice').")"; - } else { - // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined - $sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'"; - $sql .= " AND module_source = 'takepos'"; - $sql .= " AND entity IN (".getEntity('invoice').")"; - } - + $sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%'"; $sql .= $db->order('datec', 'ASC'); $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { echo '$("#customerandsales").append(\''; - echo 'jdate($obj->datec), '%H:%M', 'tzuser'))).'" onclick="place=\\\''; + echo 'ref)); echo $num_sale; if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale); - echo '\\\'; invoiceid=\\\''; - echo $obj->rowid; - echo '\\\'; Refresh();">'; + echo '\\\';Refresh();">'; if ($placeid == $obj->rowid) echo ""; - echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'); + echo date('H:i', strtotime($obj->datec)); if ($placeid == $obj->rowid) echo ""; echo '\');'; } echo '$("#customerandsales").append(\'\');'; + echo '\\\';Refresh();">\');'; } else { dol_print_error($db); } $s = ''; - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") - { - $s = ''; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - $warehouse = new Entrepot($db); - $warehouse->fetch($conf->global->$constantforkey); - $s .= $langs->trans("Warehouse").'
'.$warehouse->ref; - $s .= '
'; - } + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") + { + $s = ''; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + $warehouse = new Entrepot($db); + $warehouse->fetch($conf->global->$constantforkey); + $s .= $langs->trans("Warehouse").'
'.$warehouse->ref; + $s .= '
'; + } ?> $("#infowarehouse").html(''); @@ -1081,7 +807,6 @@ if ($result > 0) { $adh->ref = $adh->getFullName($langs); - if (empty($adh->statut)) { $s .= ""; } $s .= $adh->getFullName($langs); $s .= ' - '.$adh->type; if ($adh->datefin) @@ -1090,12 +815,15 @@ if ($adh->hasDelay()) { $s .= " ".img_warning($langs->trans("Late")); } - } else { + } + else + { $s .= '
'.$langs->trans("SubscriptionNotReceived"); if ($adh->statut > 0) $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated } - if (empty($adh->statut)) { $s .= "
"; } - } else { + } + else + { $s .= '
'.$langs->trans("ThirdpartyNotLinkedToMember"); } $s .= '
'; @@ -1112,63 +840,47 @@ // for tooltip and other js beautifiers must be reexecuted too. if (!empty($conf->use_javascript_ajax)) { - print "\n".''."\n"; - print ''."\n"; + print "\n".''."\n"; + print ''."\n"; } print ''."\n"; print '
'; print ''; -if ($sectionwithinvoicelink && ($mobilepage == "invoice" || $mobilepage == "")) { - print ''; -} print ''; print ''; +} +// In phone version only show when is invoice page +if ($mobilepage == "invoice" || $mobilepage == "") { + print $langs->trans('TotalTTC'); + print ' : '.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).''; + print '
'.$sectionwithinvoicelink; + print ''; +} if ($_SESSION["basiclayout"] != 1) { print ''; print ''; - print ''; - } - print ''; + print ''; } elseif ($mobilepage == "invoice") print ''; print "\n"; @@ -1180,9 +892,9 @@ { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $categorie = new Categorie($db); - $categories = $categorie->get_full_arbo('product'); + $categories = $categorie->get_full_arbo('product'); $htmlforlines = ''; - foreach ($categories as $row) { + foreach ($categories as $row) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .= '
'; @@ -1250,12 +962,12 @@ //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)) - { - print ''."\n"; - $tmplines = array_reverse($invoice->lines); - foreach ($tmplines as $line) - { + if (is_array($invoice->lines) && count($invoice->lines)) + { + print ''."\n"; + $tmplines = array_reverse($invoice->lines); + foreach ($tmplines as $line) + { if ($line->fk_parent_line != false) { $htmlsupplements[$line->fk_parent_line] .= '
special_code == "4") { - $htmlforlines .= ' order'; - } - $htmlforlines .= '" id="'.$line->id.'">'; - $htmlforlines .= 'id.'">'; + $htmlforlines .= ''; $htmlforlines .= ''; - $htmlforlines .= ''; - $htmlforlines .= ''; + $htmlforlines .= ''; + $htmlforlines .= ''; } $htmlforlines .= ''."\n"; $htmlforlines .= $htmlsupplements[$line->id]; - print $htmlforlines; - } - } else { - print ''; - } -} else { // No invoice generated yet - print ''; + print $htmlforlines; + } + } + else + { + print ''; + } +} +else { // No invoice generated yet + print ''; } print '
'.$sectionwithinvoicelink.'
'; -// In phone version only show when it is invoice page -if ($mobilepage == "invoice" || $mobilepage == "") { - print ''; -} +print ''; if ($conf->global->TAKEPOS_BAR_RESTAURANT) { - $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); - $resql = $db->query($sql); - $obj = $db->fetch_object($resql); - if ($obj) - { - $label = $obj->label; - $floor = $obj->floor; - } + $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $label = $obj->label; + $floor = $obj->floor; + } // In phone version only show when is invoice page if ($mobilepage == "invoice" || $mobilepage == "") { - print ''.$langs->trans('Place')." ".$label."
"; - print ''.$langs->trans('Floor')." ".$floor.""; + print $langs->trans('Place')." ".$label." - "; + print $langs->trans('Floor')." ".$floor." - "; } elseif (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) print $mysoc->name; elseif ($mobilepage == "cats") print $langs->trans('Category'); elseif ($mobilepage == "products") print $langs->trans('Label'); -} else { - print $langs->trans("Products"); -} -print '
'.$langs->trans('ReductionShort').''.$langs->trans('Qty').''; - print ''.$langs->trans('TotalTTCShort').'
'; - // In phone version only show when it is invoice page - if ($mobilepage == "invoice" || $mobilepage == "") { - print ''.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).''; - if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) { - //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency - include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; - $multicurrency = new MultiCurrency($db); - $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]); - print '
('.price($invoice->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')'; - } - print '
'.$langs->trans('TotalTTCShort').''.$langs->trans('Qty').'
'; + $htmlforlines = ''; + + $htmlforlines .= '
'; if ($_SESSION["basiclayout"] == 1) $htmlforlines .= ''.$line->qty." x "; - if (isset($line->product_type)) - { - if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; - else $htmlforlines .= img_object('', 'service').' '; - } - if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) { - $tooltiptext = ''; - if ($line->product_ref) { - $tooltiptext .= ''.$langs->trans("Ref").' : '.$line->product_ref.'
'; - $tooltiptext .= ''.$langs->trans("Label").' : '.$line->product_label.'
'; - if ($line->product_label != $line->desc) { - if ($line->desc) $tooltiptext .= '
'; - $tooltiptext .= $line->desc; - } - } - $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); - } else { - if ($line->product_label) $htmlforlines .= $line->product_label; - if ($line->product_label != $line->desc) - { - if ($line->product_label && $line->desc) $htmlforlines .= '
'; - $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES); - if ($firstline != $line->desc) - { - $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); - } else { - $htmlforlines .= $line->desc; - } - } - } - if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
(".$line->array_options['options_order_notes'].")"; - if ($_SESSION["basiclayout"] == 1) { - $htmlforlines .= '
  '; - } + //if ($line->product_label) $htmlforlines.= ''.$line->product_label.''; + if (isset($line->product_type)) + { + if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; + else $htmlforlines .= img_object('', 'service').' '; + } + if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) { + $tooltiptext = ''; + if ($line->product_ref) { + $tooltiptext .= ''.$langs->trans("Ref").' : '.$line->product_ref.'
'; + $tooltiptext .= ''.$langs->trans("Label").' : '.$line->product_label.'
'; + if ($line->product_label != $line->desc) { + if ($line->desc) $tooltiptext .= '
'; + $tooltiptext .= $line->desc; + } + } + $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); + } else { + if ($line->product_label) $htmlforlines .= $line->product_label; + if ($line->product_label != $line->desc) + { + if ($line->product_label && $line->desc) $htmlforlines .= '
'; + $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES); + if ($firstline != $line->desc) + { + $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + } + else + { + $htmlforlines .= $line->desc; + } + } + } + if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
(".$line->array_options['options_order_notes'].")"; + if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '
  '; if ($_SESSION["basiclayout"] != 1) { $moreinfo = ''; @@ -1338,74 +1053,33 @@ $moreinfo .= '
'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2); $moreinfo .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht; - if ($line->date_start || $line->date_end) $htmlforlines .= '
'.get_date_range($line->date_start, $line->date_end).'
'; + $htmlforlines .= '
'.vatrate($line->remise_percent, true).''; - if (!empty($conf->stock->enabled) && !empty($user->rights->stock->mouvement->lire)) - { - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - if (!empty($conf->global->$constantforkey) && $line->fk_product > 0) { - $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; - $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; - $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; - $sql .= " WHERE ps.reel != 0"; - $sql .= " AND ps.fk_entrepot = ".$conf->global->$constantforkey; - $sql .= " AND e.entity IN (".getEntity('stock').")"; - $sql .= " AND ps.fk_product = ".$line->fk_product; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $stock_real = price2num($obj->reel, 'MS'); - $htmlforlines .= $line->qty; - if ($line->qty && $line->qty > $stock_real) $htmlforlines .= ''; - $htmlforlines .= ' ('.$langs->trans("Stock").' '.$stock_real.')'; - if ($line->qty && $line->qty > $stock_real) $htmlforlines .= ""; - } else { - dol_print_error($db); - } - } else { - $htmlforlines .= $line->qty; - } - } else { - $htmlforlines .= $line->qty; - } - - $htmlforlines .= ''; - $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency); - if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) { - //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency - include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; - $multicurrency = new MultiCurrency($db); - $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]); - $htmlforlines .= '
('.price($line->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')'; - } - $htmlforlines .= '
'.$line->qty.''.price($line->total_ttc).'
'.$langs->trans("Empty").'
'.$langs->trans("Empty").'
'.$langs->trans("Empty").'
'.$langs->trans("Empty").'
'; -if (($action == "valid" || $action == "history") && $invoice->type != Facture::TYPE_CREDIT_NOTE) { - print ''; -} - if ($action == "search") { - print '
+ print '
'; } --- /tmp/dsg/dolibarr/htdocs/takepos/github_pay.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_pay.php @@ -34,8 +34,6 @@ require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -$langs->loadLangs(array("main", "bills", "cashdesk", "banks")); - $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant $invoiceid = GETPOST('invoiceid', 'int'); @@ -52,55 +50,49 @@ $invoice = new Facture($db); if ($invoiceid > 0) { - $invoice->fetch($invoiceid); -} else { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; - $resql = $db->query($sql); - $obj = $db->fetch_object($resql); - if ($obj) - { - $invoiceid = $obj->rowid; - } - if (!$invoiceid) - { - $invoiceid = 0; // Invoice does not exist yet - } else { - $invoice->fetch($invoiceid); - } + $invoice->fetch($invoiceid); +} +else +{ + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $invoiceid = $obj->rowid; + } + if (!$invoiceid) + { + $invoiceid = 0; // Invoice does not exist yet + } + else + { + $invoice->fetch($invoiceid); + } } $arrayofcss = array('/takepos/css/pos.css.php'); $arrayofjs = array(); -$head = ''; -$title = ''; -$disablejs = 0; -$disablehead = 0; - top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); -// Define list of possible payments -$arrayOfValidPaymentModes = array(); -$arrayOfValidBankAccount = array(); +$langs->loadLangs(array("main", "bills", "cashdesk")); $sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement"; $sql .= " WHERE entity IN (".getEntity('c_paiement').")"; $sql .= " AND active = 1"; $sql .= " ORDER BY libelle"; $resql = $db->query($sql); - +$paiements = array(); if ($resql) { while ($obj = $db->fetch_object($resql)) { - $paycode = $obj->code; - if ($paycode == 'LIQ') $paycode = 'CASH'; - if ($paycode == 'CB') $paycode = 'CB'; - if ($paycode == 'CHQ') $paycode = 'CHEQUE'; - - $accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; - if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) { - $arrayOfValidBankAccount[$conf->global->$accountname] = $conf->global->$accountname; - $arrayOfValidPaymentModes[] = $obj; - } + $paycode = $obj->code; + if ($paycode == 'LIQ') $paycode = 'CASH'; + if ($paycode == 'CB') $paycode = 'CB'; + if ($paycode == 'CHQ') $paycode = 'CHEQUE'; + + $accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; + if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) array_push($paiements, $obj); } } ?> @@ -116,7 +108,7 @@ $remaintopay = 0; if ($invoice->id > 0) { - $remaintopay = $invoice->getRemainToPay(); + $remaintopay = $invoice->getRemainToPay(); } $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0); @@ -129,9 +121,9 @@ function addreceived(price) { global->TAKEPOS_NUMPAD)) print 'received+=String(price);'."\n"; - else print 'received+=parseFloat(price);'."\n"; - ?> + if (empty($conf->global->TAKEPOS_NUMPAD)) print 'received+=String(price);'."\n"; + else print 'received+=parseFloat(price);'."\n"; + ?> $('.change1').html(pricejs(parseFloat(received), 'MT')); $('.change1').val(parseFloat(received)); alreadypaydplusreceived=price2numjs(alreadypayed + parseFloat(received)); @@ -184,22 +176,14 @@ function Validate(payment) { var invoiceid = 0 ? $invoiceid : 0); ?>; - var accountid = $("#selectaccountid").val(); var amountpayed = $("#change1").val(); - var excess = $("#change2").val(); if (amountpayed > total_ttc; ?>) { amountpayed = total_ttc; ?>; } console.log("We click on the payment mode to pay amount = "+amountpayed); - parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { - if (amountpayed > || amountpayed == || amountpayed==0 ) { - console.log("Close popup"); - parent.$.colorbox.close(); - } - else { - console.log("Amount is not comple, so we do NOT close popup and reload it."); - location.reload(); - } + parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() { + if (amountpayed > || amountpayed == || amountpayed==0 ) parent.$.colorbox.close(); + else location.reload(); }); } @@ -216,7 +200,7 @@ window.open('sumupmerchant://pay/1.0?affiliate-key=global->TAKEPOS_SUMUP_AFFILIATE ?>&app-id=global->TAKEPOS_SUMUP_APPID ?>&total=' + amountpayed + '¤cy=EUR&title=' + invoiceid + '&callback=/takepos/smpcb.php'); var loop = window.setInterval(function () { - $.ajax('/takepos/smpcb.php?status').done(function (data) { + $.ajax('/takepos/smpcb.php?status').done(function (data) { console.log(data); if (data === "SUCCESS") { parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () { @@ -234,53 +218,39 @@ } -
- +
+
-
trans('TotalTTC'); ?>: total_ttc, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?>
+
trans('TotalTTC'); ?>: total_ttc, 1, '', 1, -1, -1) ?>
total_ttc) { ?>
-
trans('RemainToPay'); ?>: multicurrency_code); ?>
+
trans('RemainToPay'); ?>:
-
trans("Received"); ?>: multicurrency_code); ?>
+
trans("Received"); ?>:
-
trans("Change"); ?>: multicurrency_code); ?>
-
-global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { - print '
-
'; - $filter = ''; - $form = new Form($db); - print ''.$langs->trans("BankAccount").': '; - $form->select_comptes(0, 'accountid', 0, $filter, 1, ''); - print ajax_combobox('selectaccountid'); - print '
-
'; -} -?> - -
- - -
+
trans("Change"); ?>:
+
+
+
+ +
"reset()", "span" => "style='font-size: 150%;'", "text" => "C", - "class" => "poscolorblue" + "class" => "poscolorblue" ), array( "function" => "parent.$.colorbox.close();", "span" => "id='printtext' style='font-weight: bold; font-size: 18pt;'", "text" => "X", - "class" => "poscolordelete" + "class" => "poscolordelete" ), ); $numpad = $conf->global->TAKEPOS_NUMPAD; @@ -289,21 +259,21 @@ print ''; print ''; ?> - 0) { - $paycode = $arrayOfValidPaymentModes[0]->code; + 0) { + $paycode = $paiements[0]->code; $payIcon = ''; if ($paycode == 'LIQ') { $paycode = 'cash'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; } elseif ($paycode == 'CB') { $paycode = 'card'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; } elseif ($paycode == 'CHQ') { $paycode = 'cheque'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; - } - - print ''; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; + } + + print ''; } else { print ''; } @@ -312,21 +282,21 @@ print ''; print ''; ?> - 1) { - $paycode = $arrayOfValidPaymentModes[1]->code; + 1) { + $paycode = $paiements[1]->code; $payIcon = ''; if ($paycode == 'LIQ') { $paycode = 'cash'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; } elseif ($paycode == 'CB') { $paycode = 'card'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; } elseif ($paycode == 'CHQ') { $paycode = 'cheque'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; - } - - print ''; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; + } + + print ''; } else { $button = array_pop($action_buttons); print ''; @@ -336,23 +306,23 @@ print ''; print ''; ?> - 2) { - $paycode = $arrayOfValidPaymentModes[2]->code; + 2) { + $paycode = $paiements[2]->code; $payIcon = ''; if ($paycode == 'LIQ') { $paycode = 'cash'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; } elseif ($paycode == 'CB') { $paycode = 'card'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; } elseif ($paycode == 'CHQ') { $paycode = 'cheque'; - if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; - } - - print ''; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; + } + + print ''; } else { - $button = array_pop($action_buttons); + $button = array_pop($action_buttons); print ''; } @@ -361,8 +331,8 @@ print ''; $i = 3; -while ($i < count($arrayOfValidPaymentModes)) { - print ''; +while ($i < count($paiements)) { + print ''; $i = $i + 1; } @@ -371,19 +341,16 @@ if (!empty($conf->global->$keyforsumupbank)) { print ''; } else { - $langs->loadLangs(array("errors", "admin")); + $langs->load("errors"); + $langs->load("admin"); print ''; } } $class = ($i == 3) ? "calcbutton3" : "calcbutton2"; foreach ($action_buttons as $button) { - $newclass = $class.($button["class"] ? " ".$button["class"] : ""); + $newclass = $class.($button["class"] ? " ".$button["class"] : ""); print ''; -} - -if ($conf->global->TAKEPOS_DELAYED_PAYMENT) { - print ''; } ?>
--- /tmp/dsg/dolibarr/htdocs/takepos/github_phone.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_phone.php @@ -43,7 +43,7 @@ } else { $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Ba or Restaurant } -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $setterminal = GETPOST('setterminal', 'int'); $idproduct = GETPOST('idproduct', 'int'); @@ -64,7 +64,7 @@ if ($action == "productinfo") { $prod = new Product($db); - $prod->fetch($idproduct); + $prod->fetch($idproduct); print ''; print "
".$prod->label."
"; print ''; @@ -104,7 +104,7 @@ $printer->printer->feed(); $printer->printer->feed(); $printer->close(); - } else { + } else { print ''; print ''; print '
'; @@ -115,8 +115,8 @@ $invoice = new Facture($db); $invoice->fetch($placeid); foreach ($invoice->lines as $line) - { - if ($line->id == $selectedline) + { + if ($line->id == $selectedline) { $prod = new Product($db); $prod->fetch($line->fk_product); @@ -128,8 +128,8 @@ print ''; print ''; print ''; - } - } + } + } } else { // Title $title = 'TakePOS - Dolibarr '.DOL_VERSION; @@ -151,14 +151,14 @@ $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; - } - } + foreach ($categories as $key => $categorycursor) + { + if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) + { + $levelofrootcategory = $categorycursor['level']; + break; + } + } } $levelofmaincategories = $levelofrootcategory + 1; @@ -166,12 +166,14 @@ $subcategories = array(); foreach ($categories as $key => $categorycursor) { - if ($categorycursor['level'] == $levelofmaincategories) - { - $maincategories[$key] = $categorycursor; - } else { - $subcategories[$key] = $categorycursor; - } + if ($categorycursor['level'] == $levelofmaincategories) + { + $maincategories[$key] = $categorycursor; + } + else + { + $subcategories[$key] = $categorycursor; + } } sort($maincategories); @@ -200,11 +202,11 @@ function LoadPlace(placeid){ place=placeid; @@ -234,11 +236,11 @@ function AddProductConfirm(placeid, productid){ place=placeid; if (qty==0){ - $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=deleteline&token=&place="+place+"&idline="+selectedline, function() { + $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=deleteline&place="+place+"&idline="+selectedline, function() { }); } else{ @@ -262,7 +264,7 @@ else { ?> if (qty==0){ - $("#phonediv2").load("invoice.php?mobilepage=invoice&action=deleteline&token=&place="+place+"&idline="+selectedline, function() { + $("#phonediv2").load("invoice.php?mobilepage=invoice&action=deleteline&place="+place+"&idline="+selectedline, function() { }); } else{ @@ -271,7 +273,7 @@ } + ?> LoadCats(); } @@ -284,11 +286,11 @@ function LoadCats(){ &payment="+payment, function() { + $("#phonediv1").load("auto_order.php?action=checkplease&place=&payment="+payment, function() { }); } } @@ -355,7 +357,7 @@
'.strtoupper(substr($langs->trans('Floors'), 0, 3)).''; print ''; print ''; --- /tmp/dsg/dolibarr/htdocs/takepos/github_receipt.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_receipt.php @@ -20,23 +20,12 @@ */ /** - * \file htdocs/takepos/receipt.php + * \file htdocs/takepos/floors.php * \ingroup takepos * \brief Page to show a receipt. */ -if (!isset($action)) { - //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('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'; // If this file is called from send.php avoid load again -} +if (!isset($action)) require '../main.inc.php'; // If this file is called from send.php avoid load again include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $langs->loadLangs(array("main", "cashdesk", "companies")); @@ -44,8 +33,6 @@ $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Ba or Restaurant $facid = GETPOST('facid', 'int'); - -$gift = GETPOST('gift', 'int'); if (empty($user->rights->takepos->run)) { accessforbidden(); @@ -60,13 +47,13 @@ if ($place > 0) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; - $resql = $db->query($sql); - $obj = $db->fetch_object($resql); - if ($obj) - { - $facid = $obj->rowid; - } + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $facid = $obj->rowid; + } } $object = new Facture($db); $object->fetch($facid); @@ -75,7 +62,7 @@ $hookmanager->initHooks(array('takeposfrontend'), $facid); $reshook = $hookmanager->executeHooks('TakeposReceipt', $parameters, $object); if (!empty($hookmanager->resPrint)) { - print $hookmanager->resPrint; + print $hookmanager->resPrint; exit; } @@ -102,14 +89,12 @@

global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeText})) +if (!empty($conf->global->TAKEPOS_HEADER)) { - $newfreetext = ''; $substitutionarray = getCommonSubstitutionArray($langs); - if (!empty($conf->global->TAKEPOS_HEADER)) $newfreetext .= make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); - if (!empty($conf->global->{$constFreeText})) $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray); - print $newfreetext; + if (!empty($conf->global->TAKEPOS_HEADER)) + $newfreetext = make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); + echo $newfreetext; } ?>

@@ -138,34 +123,34 @@ trans("Label"); ?> trans("Qty"); ?> - trans("Price"); ?> - trans("TotalTTC"); ?> + trans("Price"); ?> + trans("TotalTTC"); ?> lines as $line) - { - ?> + foreach ($object->lines as $line) + { + ?> product_label)) echo $line->product_label; - else echo $line->description; ?> + else echo $line->description; ?> qty; ?> - total_ttc / $line->qty, 'MT'), 1); ?> - total_ttc, 1); ?> + total_ttc / $line->qty, 'MT'), 1); ?> + total_ttc, 1); ?> + } + ?>
- - + + global->TAKEPOS_TICKET_VAT_GROUPPED) { $vat_groups = array(); @@ -177,86 +162,32 @@ $vat_groups[$line->tva_tx] += $line->total_tva; } foreach ($vat_groups as $key => $val) { - ?> + ?> - - + + - + - + -multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) { - //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency - include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; - $multicurrency = new MultiCurrency($db); - $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]); - echo ''; -} - -if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) { - $sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; - $sql .= " cp.code"; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid; - $sql .= " ORDER BY p.datep"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $row = $db->fetch_object($resql); - echo ''; - echo ''; - echo ''; - echo ''; - if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments - { - echo ''; - echo ''; - echo ''; - echo ''; - } - $i++; - } - } -} -?>
trans("TotalHT"); ?>total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>trans("TotalHT"); ?>total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
trans("VAT").' '.vatrate($key, 1); ?>currency)."\n"; ?>trans("VAT").' '.vatrate($key, 1); ?>currency)."\n"; ?>
trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
'; - if ($gift != 1) echo ''.$langs->trans("TotalTTC").' '.$_SESSION["takeposcustomercurrency"].''.price($object->total_ttc * $multicurrency->rate->rate, 1, '', 1, - 1, - 1, $_SESSION["takeposcustomercurrency"])."\n"; - echo '
'; - echo $langs->transnoentitiesnoconv("PaymentTypeShort".$row->code); - echo ''; - $amount_payment = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; - if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment - echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency); - echo '
'; - echo $langs->trans("Change"); - echo ''; - echo price($row->pos_change, 1, '', 1, - 1, - 1, $conf->currency); - echo '



global->TAKEPOS_FOOTER) || !empty($conf->global->{$constFreeText})) +if (!empty($conf->global->TAKEPOS_FOOTER)) { - $newfreetext = ''; $substitutionarray = getCommonSubstitutionArray($langs); - if (!empty($conf->global->{$constFreeText})) $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray); - if (!empty($conf->global->TAKEPOS_FOOTER)) $newfreetext .= make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray); - print $newfreetext; + $newfreetext = make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray); + echo $newfreetext; } ?> --- /tmp/dsg/dolibarr/htdocs/takepos/github_reduction.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_reduction.php @@ -50,21 +50,25 @@ $invoice = new Facture($db); if ($invoiceid > 0) { - $invoice->fetch($invoiceid); -} else { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; - $resql = $db->query($sql); - $obj = $db->fetch_object($resql); - if ($obj) - { - $invoiceid = $obj->rowid; - } - if (!$invoiceid) - { - $invoiceid = 0; // Invoice does not exist yet - } else { - $invoice->fetch($invoiceid); - } + $invoice->fetch($invoiceid); +} +else +{ + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $invoiceid = $obj->rowid; + } + if (!$invoiceid) + { + $invoiceid = 0; // Invoice does not exist yet + } + else + { + $invoice->fetch($invoiceid); + } } $arrayofcss = array('/takepos/css/pos.css.php'); @@ -74,9 +78,9 @@ $langs->loadLangs(array('main', 'bills', 'cashdesk')); -if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { +if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { $htmlReductionPercent = ''; - $htmlReductionAmount = '
'.$langs->trans('Amount'); + $htmlReductionAmount = ''; } else { $htmlReductionPercent = $langs->trans('ReductionShort').'
%'; $htmlReductionAmount = $langs->trans('ReductionShort').'
'.$langs->trans('Amount'); @@ -198,7 +202,7 @@
trans('Reduction').'">'; + print ''; ?>
--- /tmp/dsg/dolibarr/htdocs/takepos/github_send.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_send.php @@ -24,20 +24,20 @@ //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('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'); +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/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facid = GETPOST('facid', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $email = GETPOST('email', 'alpha'); if (empty($user->rights->takepos->run)) { @@ -51,31 +51,29 @@ $customer = new Societe($db); $customer->fetch($invoice->socid); -if ($action == "send") +if ($action=="send") { - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $outputlangs = new Translate('', $conf); - $model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE; - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id); - $subject = $arraydefaultmessage->topic; - - ob_start(); // turn on output receipt - include 'receipt.php'; - $receipt = ob_get_contents(); // get the contents of the output buffer - ob_end_clean(); - - $msg = "".$arraydefaultmessage->content."
".$receipt.""; - $sendto = $email; - $from = $mysoc->email; - $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1); - if ($mail->error || $mail->errors) { - setEventMessages($mail->error, $mail->errors, 'errors'); - } else { - $result = $mail->sendfile(); - } - exit; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $outputlangs = new Translate('', $conf); + $model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE; + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id); + $subject = $arraydefaultmessage->topic; + ob_start(); // turn on output receipt + include 'receipt.php'; + $receipt = ob_get_contents(); // get the contents of the output buffer + ob_end_clean(); + $msg="".$arraydefaultmessage->content."
".$receipt.""; + $sendto=$email; + $from=$mysoc->email; + $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1); + if ($mail->error || $mail->errors) { + setEventMessages($mail->error, $mail->errors, 'errors'); + } else { + $result = $mail->sendfile(); + } + exit; } $arrayofcss = array('/takepos/css/pos.css.php'); $arrayofjs = array(); --- /tmp/dsg/dolibarr/htdocs/takepos/github_smpcb.php +++ /tmp/dsg/dolibarr/htdocs/takepos/client_smpcb.php @@ -1,26 +1,4 @@ - * - * 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 . - */ - -/** - * \file htdocs/takepos/smpcb.php - * \ingroup takepos - * \brief Page with the content for smpcb payment - */ - if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); @@ -33,25 +11,25 @@ accessforbidden(); } -if (GETPOSTISSET('status')) { +if (isset($_GET['status'])) { die(strtoupper($_SESSION['SMP_CURRENT_PAYMENT'])); } -if (GETPOST('smp-status')) { - print ''; - print ''; - print ' +if ($_GET['smp-status']) { + print ' + + The HTML5 Herald - '; + - print ''; + - print ''; - $_SESSION['SMP_CURRENT_PAYMENT'] = GETPOST('smp-status'); +'; + $_SESSION['SMP_CURRENT_PAYMENT'] = $_GET['smp-status']; print '