Merge remote-tracking branch 'Dolibarr/develop' into develop

This commit is contained in:
Nicolas ZABOURI 2019-03-27 21:23:27 +01:00
commit ecba09e19c
13 changed files with 269 additions and 180 deletions

View File

@ -53,6 +53,7 @@ if (empty($conf->dol_no_mouse_hover))
hide: { delay: 50 },
tooltipClass: "mytooltip",
content: function () {
console.log("Return title for popup");
return $(this).prop(\'title\'); /* To force to get title as is */
}
});'."\n";

View File

@ -50,13 +50,14 @@ TheoricalAmount=Theorical amount
RealAmount=Real amount
CashFenceDone=Cash fence done for the period
NbOfInvoices=Nb of invoices
Paymentnumpad=Payment Num Pad
Paymentnumpad=Type of Pad to enter payment
Numberspad=Numbers Pad
BillsCoinsPad=Bills and Coins Pad
BillsCoinsPad=Coins and banknotes Pad
DolistorePosCategory=TakePOS modules and other POS solutions for Dolibarr
TakeposNeedsCategories=TakePOS needs product categories to work
OrderNotes=Order Notes
CashDeskBankAccountFor=Default account to use for payments in
NoPaimementModesDefined=No paiment mode defined in TakePOS configuration
TicketVatGrouped=Group VAT by rate in tickets
AutoPrintTickets=Automatically print tickets
AutoPrintTickets=Automatically print tickets
EnableBarOrRestaurantFeatures=Enable features for Bar or Restaurant

View File

@ -64,7 +64,7 @@ if (GETPOST('action', 'alpha') == 'set')
if (GETPOST('socid', 'int') < 0) $_POST["socid"]='';
$res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE", (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB", (GETPOST('CASHDESK_ID_BANKACCOUNT_CB', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
@ -177,7 +177,8 @@ if ($conf->global->TAKEPOSCONNECTOR){
// Bar Restaurant mode
print '<tr class="oddeven"><td>';
print 'Bar Restaurant';
print $langs->trans("EnableBarOrRestaurantFeatures");
print '</td>';
print '<td colspan="2">';
print $form->selectyesno("TAKEPOS_BAR_RESTAURANT", $conf->global->TAKEPOS_BAR_RESTAURANT, 1);
print "</td></tr>\n";
@ -276,7 +277,7 @@ if (! empty($conf->banque->enabled))
print '<td colspan="2">';
$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB, 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", 1);
print '</td></tr>';
foreach($paiements as $modep) {
if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue;
$name="CASHDESK_ID_BANKACCOUNT_".$modep->code;

View File

@ -48,12 +48,11 @@ if ($action=="getProducts") {
$prods = $object->getObjectsInCateg("product");
echo json_encode($prods);
}
elseif ($action=="search") {
elseif ($action=="search" && $term != '') {
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'product';
$sql .= ' WHERE entity IN ('.getEntity('product').')';
$sql .= ' AND tosell = 1';
$sql .= natural_search(array('label','barcode'), $term);
$sql.= ' WHERE entity IN ('.getEntity('product').')';
$sql.= ' AND tosell = 1';
$sql.= natural_search(array('label','barcode'), $term);
$resql = $db->query($sql);
$rows = array();
while ($row = $db->fetch_array($resql)) {

View File

@ -46,7 +46,7 @@ button.calcbutton3 {
text-align: center;
font-size:120%;
overflow: visible; /* removes extra width in IE */
width:12%;
width:24%;
height:24%;
}
@ -60,7 +60,7 @@ button.actionbutton {
text-align: center;
overflow: visible; /* removes extra width in IE */
width:33%;
height:33%;
height:24%;
}
div.wrapper{
@ -208,6 +208,13 @@ div.catwatermark{
padding-left: 5px;
}
.selected {
font-weight: bold;
}
.order {
color: limegreen;
}
.colorwhite {
color: white;
}

View File

@ -45,7 +45,8 @@ $show_files=GETPOST('show_files', 'int');
$confirm=GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$idcustomer = GETPOST('idcustomer', 'int');
$place = (GETPOSTISSET('place')?GETPOST('place', 'int'):0);
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS
$_GET['optioncss'] = 'print';
@ -60,7 +61,7 @@ if ($action=="change") {
?>
<script>
parent.$("#poslines").load("invoice.php?place="+<?php print $place;?>, function() {
parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
//parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
parent.$.colorbox.close();
});
</script>

View File

@ -25,24 +25,26 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
$_GET['theme']="md"; // Force theme. MD theme provides better look and feel to TakePOS
require '../main.inc.php'; // Load $user and permissions
$langs->loadLangs(array("bills","orders","commercial","cashdesk"));
$floor=GETPOST('floor', 'alpha');
$floor=GETPOST('floor', 'int');
if ($floor=="") $floor=1;
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$left = GETPOST('left', 'alpha');
$top = GETPOST('top', 'alpha');
$place = GETPOST('place', 'int');
$newname = GETPOST('newname');
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS
$newname = GETPOST('newname', 'alpha');
$mode = GETPOST('mode', 'alpha');
if ($action=="getTables"){
$sql="SELECT * from ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor;
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)){
@ -56,20 +58,21 @@ 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 label='$place'");
else $db->query("delete from ".MAIN_DB_PREFIX."takepos_floor_tables where label='$place'");
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='$newname' where label='$place'");
$db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'");
}
if ($action=="add")
{
$asdf=$db->query("insert into ".MAIN_DB_PREFIX."takepos_floor_tables values ('', '', '', '45', '45', $floor)");
$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
}
@ -101,6 +104,7 @@ height: 100%;
var DragDrop='<?php echo $langs->trans("DragDrop"); ?>';
function updateplace(idplace, left, top) {
console.log("updateplace idplace="+idplace+" left="+left+" top="+top);
$.ajax({
type: "POST",
url: "floors.php",
@ -110,12 +114,13 @@ function updateplace(idplace, left, top) {
});
}
function updatename(before) {
var after=$("#"+before).text();
function updatename(rowid) {
var after=$("#tablename"+rowid).text();
console.log("updatename rowid="+rowid+" after="+after);
$.ajax({
type: "POST",
url: "floors.php",
data: { action: "updatename", place: before, newname: after }
data: { action: "updatename", place: rowid, newname: after }
}).done(function( msg ) {
window.location.href='floors.php?mode=edit&floor=<?php echo $floor;?>';
});
@ -130,8 +135,8 @@ $( document ).ready(function() {
$.getJSON('./floors.php?action=getTables&floor=<?php echo $floor; ?>', function(data) {
$.each(data, function(key, val) {
<?php if ($mode=="edit"){?>
$('body').append('<div class="tablediv" contenteditable onblur="updatename('+val.label+');" style="position: absolute; left: '+val.leftpos+'%; top: '+val.toppos+'%;" id="'+val.label+'">'+val.label+'</div>');
$( "#"+val.label ).draggable(
$('body').append('<div class="tablediv" contenteditable onblur="updatename('+val.rowid+');" style="position: absolute; left: '+val.leftpos+'%; top: '+val.toppos+'%;" id="tablename'+val.rowid+'">'+val.label+'</div>');
$( "#tablename"+val.rowid ).draggable(
{
start: function() {
$("#add").html("<?php echo $langs->trans("Delete"); ?>");
@ -139,7 +144,7 @@ $( document ).ready(function() {
stop: function() {
var left=$(this).offset().left*100/$(window).width();
var top=$(this).offset().top*100/$(window).height();
updateplace($(this).attr('id'), left, top);
updateplace($(this).attr('id').substr(9), left, top);
}
}
);
@ -149,7 +154,7 @@ $( document ).ready(function() {
})
<?php }
else {?>
$('body').append('<div class="tablediv" onclick="LoadPlace('+val.label+');" style="position: absolute; left: '+val.leftpos+'%; top: '+val.toppos+'%;" id="'+val.label+'">'+val.label+'</div>');
$('body').append('<div class="tablediv" onclick="LoadPlace('+val.rowid+');" style="position: absolute; left: '+val.leftpos+'%; top: '+val.toppos+'%;" id="tablename'+val.rowid+'">'+val.label+'</div>');
<?php } ?>
});
});
@ -171,7 +176,13 @@ $( document ).ready(function() {
<div style="position: absolute; left: 25%; bottom: 8%; width:50%; height:3%;">
<center>
<h1><img src="./img/arrow-prev.png" width="5%" onclick="location.href='floors.php?floor=<?php if ($floor>1) { $floor--; echo $floor; $floor++;} else echo "1"; ?>';"><?php echo $langs->trans("Floor")." ".$floor; ?><img src="./img/arrow-next.png" width="5%" onclick="location.href='floors.php?floor=<?php $floor++; echo $floor; ?>';"></h1>
<h1>
<?php if ($floor>1) { ?>
<img class="valignmiddle" src="./img/arrow-prev.png" width="5%" onclick="location.href='floors.php?floor=<?php if ($floor>1) { $floor--; echo $floor; $floor++;} else echo "1"; ?>';">
<?php } ?>
<span class="valignmiddle"><?php echo $langs->trans("Floor")." ".$floor; ?></span>
<img src="./img/arrow-next.png" class="valignmiddle" width="5%" onclick="location.href='floors.php?floor=<?php $floor++; echo $floor; ?>';">
</h1>
</center>
</div>
</body>

View File

@ -29,7 +29,9 @@ require '../main.inc.php'; // Load $user and permissions
$langs->loadLangs(array("bills", "cashdesk"));
$place = GETPOST('place', 'int');
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS
$idline = GETPOST('idline', 'int');
$action = GETPOST('action');
@ -60,7 +62,7 @@ if ($action=="freezone") echo '<input type="text" id="number" name="number" styl
if ($action=="addnote") echo '<input type="hidden" id="number" name="number" value="'.$idline.'">';
?>
<input type="hidden" name="place" value="<?php echo $place;?>">
<input type="button" style="width:15%;font-size: 200%;" value="OK" onclick="Save();">
<input type="button" class="button" style="width:15%; font-size: 200%;" value="OK" onclick="Save();">
</center>
</body>

View File

@ -35,7 +35,10 @@ $langs->loadLangs(array("bills", "cashdesk"));
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$idproduct = GETPOST('idproduct', 'int');
$place = (GETPOSTISSET('place')?GETPOST('place', 'int'):0); // $place is id of POS
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS
$number = GETPOST('number', 'alpha');
$idline = GETPOST('idline', 'int');
$desc = GETPOST('desc', 'alpha');
@ -113,9 +116,16 @@ if ($action == 'valid' && $user->rights->facture->creer)
$payment->create($user);
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
if ($invoice->getRemainToPay() == 0)
$remaintopay = $invoice->getRemainToPay();
if ($remaintopay == 0)
{
dol_syslog("Invoice is paid, so we set it to pay");
$result = $invoice->set_paid($user);
if ($result > 0) $invoice->paye = 1;
}
else
{
dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay);
}
}
@ -124,15 +134,15 @@ if (($action=="addline" || $action=="freezone") && $placeid == 0)
$invoice->socid = $conf->global->CASHDESK_ID_THIRDPARTY;
$invoice->date = dol_now();
$invoice->module_source = 'takepos';
$invoice->pos_source = (string) $place;
$invoice->pos_source = (string) $posnb;
$placeid = $invoice->create($user);
$sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS-".$place.")' where rowid=".$placeid;
$db->query($sql);
}
if ($action == "addline") {
if ($action == "addline")
{
$prod = new Product($db);
$prod->fetch($idproduct);
@ -178,8 +188,8 @@ if ($action == "deleteline") {
$invoice->deleteline($idline);
$invoice->fetch($placeid);
}
elseif ($placeid > 0) { //If exist invoice, but no line selected, proced to delete last line
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='$placeid' order by rowid DESC";
elseif ($placeid > 0) { //If exist invoice, 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];
@ -264,25 +274,41 @@ if ($action == "order" and $placeid != 0) {
$invoice->fetch($placeid);
}
$sectionwithinvoicelink='';
if ($action=="valid")
{
$sectionwithinvoicelink.='<!-- Section with invoice link -->'."\n";
$sectionwithinvoicelink.='<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">';
$sectionwithinvoicelink.='<span style="font-size:120%;" class="center"><b>';
$sectionwithinvoicelink.=$invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
if ($invoice->getRemainToPay() > 0)
{
$sectionwithinvoicelink.=$langs->trans('Generated');
}
else
{
if ($invoice->paye) $sectionwithinvoicelink.=$langs->trans("Payed");
else $sectionwithinvoicelink.=$langs->trans('BillShortStatusValidated');
}
$sectionwithinvoicelink.='</b></span>';
if ($conf->global->TAKEPOSCONNECTOR) $sectionwithinvoicelink.=' <button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
else $sectionwithinvoicelink.=' <button id="buttonprint" type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink.='<script language="javascript">$("#buttonprint").click();</script>';
}
/*
* View
*/
$form = new Form($db);
?>
<style>
.selected {
font-weight: bold;
}
.order {
color: limegreen;
}
</style>
<script language="javascript">
var selectedline=0;
var selectedtext="";
var placeid=<?php echo $placeid;?>;
$(document).ready(function(){
$(document).ready(function() {
$('table tbody tr').click(function(){
$('table tbody tr').removeClass("selected");
$(this).addClass("selected");
@ -321,10 +347,9 @@ if ($action == "search") {
}
?>
});
$(document).ready(function(){
$('table tbody tr').click(function(){
$('table tbody tr').click(function(){
console.log("We click on a line");
$('table tbody tr').removeClass("selected");
$(this).addClass("selected");
if (selectedline==this.id) return; // If is already selected
@ -352,6 +377,7 @@ if ($action == "search") {
}
?>
});
function Print(id){
@ -371,40 +397,92 @@ function TakeposPrinting(id){
});
}
</script>
<?php
// Add again js for footer because this content is injected into takepos.php page so all init
// for tooltip and other js beautifiers must be reexecuted too.
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext?'&'.$ext:'').'"></script>'."\n";
}
print '<div class="div-table-responsive-no-min invoice">';
print '<table id="tablelines" class="noborder noshadow" width="100%">';
print '<tr class="liste_titre nodrag nodrop">';
print '<td class="linecoldescription">' . $langs->trans('Description') . '</td>';
print '<td class="linecoldescription">';
print '<span style="font-size:120%;" class="right">';
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;
}
print $langs->trans('Place')." <b>".$label."</b> - ";
print $langs->trans('Floor')." <b>".$floor."</b> - ";
}
print $langs->trans('TotalTTC');
print ' : <b>'.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</b></span>';
print '<br>'.$sectionwithinvoicelink;
print '</td>';
print '<td class="linecolqty right">' . $langs->trans('ReductionShort') . '</td>';
print '<td class="linecolqty right">' . $langs->trans('Qty') . '</td>';
print '<td class="linecolht right">' . $langs->trans('TotalHTShort') . '</td>';
print "</tr>\n";
if ($placeid > 0) {
foreach($invoice->lines as $line)
if ($placeid > 0)
{
if (is_array($invoice->lines) && count($invoice->lines))
{
print '<tr class="drag drop oddeven';
if ($line->special_code == "3") {
print ' order';
$tmplines = array_reverse($invoice->lines);
foreach($tmplines as $line)
{
$htmlforlines = '';
$htmlforlines.= '<tr class="drag drop oddeven';
if ($line->special_code == "3") {
$htmlforlines.= ' order';
}
$htmlforlines.= '" id="' . $line->id . '">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $line->product_label;
if ($line->product_label && $line->desc) $htmlforlines.= '<br>';
if ($line->product_label != $line->desc)
{
$firstline = dolGetFirstLineOfText($line->desc);
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.= "<br>(".$line->array_options['options_order_notes'].")";
$htmlforlines.= '</td>';
$htmlforlines.= '<td class="right">' . vatrate($line->remise_percent, true) . '</td>';
$htmlforlines.= '<td class="right">' . $line->qty . '</td>';
$htmlforlines.= '<td class="right">' . price($line->total_ttc) . '</td>';
$htmlforlines.= '</tr>'."\n";
print $htmlforlines;
}
print '" id="' . $line->rowid . '">';
print '<td class="left">' . $line->product_label . $line->desc;
if (!empty($line->array_options['options_order_notes'])) echo "<br>(".$line->array_options['options_order_notes'].")";
print '</td>';
print '<td class="right">' . $line->qty . '</td>';
print '<td class="right">' . price($line->total_ttc) . '</td>';
print '</tr>';
}
else
{
print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td></tr>';
}
}
print '</table>';
print '<p style="font-size:120%;" class="right"><b>'.$langs->trans('TotalTTC');
if ($conf->global->TAKEPOS_BAR_RESTAURANT) print " ".$langs->trans('Place')." ".$place;
print ': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'&nbsp;</b></p>';
if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY)
{
$soc = new Societe($db);
@ -415,27 +493,6 @@ if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY)
print '</p>';
}
if ($action=="valid")
{
print '<!-- Area with validated invoice -->'."\n";
print '<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">';
print '<p style="font-size:120%;" class="center"><b>';
print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
if ($invoice->getRemainToPay() > 0)
{
print $langs->trans('Generated');
}
else
{
if ($invoice->paye) print $langs->trans("Payed");
else print $langs->trans('BillShortStatusValidated');
}
print '</b></p>';
if ($conf->global->TAKEPOSCONNECTOR) print '<center><button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>';
else print '<center><button id="buttonprint" type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>';
if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) print '<script language="javascript">$("#buttonprint").click();</script>';
}
if ($action == "search")
{
print '<center>

View File

@ -1,15 +0,0 @@
/* Copyright (C) 2018 Charles-FR BENKE <jove@bisquerra.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@ -31,12 +31,12 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
//$_GET['theme']="md"; // Force theme. MD theme provides better look and feel to TakePOS
require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
$place = GETPOST('place', 'int');
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS
$invoiceid = GETPOST('invoiceid', 'int');
@ -53,15 +53,18 @@ else
{
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'";
$resql = $db->query($sql);
$row = $db->fetch_array($resql);
$placeid=$row[0];
if (! $placeid)
$obj = $db->fetch_object($resql);
if ($obj)
{
$placeid=0; // Invoice does not exist yet
$invoiceid = $obj->rowid;
}
if (! $invoiceid)
{
$invoiceid=0; // Invoice does not exist yet
}
else
{
$invoice->fetch($placeid);
$invoice->fetch($invoiceid);
}
}
@ -167,7 +170,7 @@ else print "var received=0;";
}
console.log("We click on the payment mode to pay amount = "+amountpayed);
parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() {
parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
//parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
parent.$.colorbox.close();
});
}

View File

@ -24,19 +24,27 @@ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$langs->loadLangs(array("main", "cashdesk"));
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS
$facid=GETPOST('facid', 'int');
/*
* View
*/
top_httphead('text/html');
$facid=GETPOST('facid', 'int');
$place=GETPOST('place', 'int');
if ($place>0){
if ($place > 0)
{
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'";
$resql = $db->query($sql);
$row = $db->fetch_array($resql);
$facid=$row[0];
$obj = $db->fetch_object($resql);
if ($obj)
{
$facid=$obj->rowid;
}
}
$object=new Facture($db);
$object->fetch($facid);

View File

@ -26,24 +26,23 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
$_GET['theme']="md"; // Force theme. MD theme provides better look and feel to TakePOS
require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$place = GETPOST('place', 'int');
if ($place=="") $place="0";
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS
$action = GETPOST('action', 'alpha');
$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter"));
$categorie = new Categorie($db);
$MAXCATEG = 16;
$MAXPRODUCT = 32;
$MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG)?16:$conf->global->TAKEPOS_NB_MAXCATEG);
$MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT)?32:$conf->global->TAKEPOS_NB_MAXPRODUCT);;
/*
@ -61,16 +60,15 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
?>
<link rel="stylesheet" href="css/pos.css">
<script type="text/javascript" src="js/takepos.js" ></script>
<link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script> <!-- TODO It seems we don't need this -->
<script language="javascript">
<?php
$categories = $categorie->get_full_arbo('product', 0, (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0));
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
// Search root category to know its level
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
$levelofrootcategory=0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
{
@ -114,7 +112,7 @@ var place="<?php echo $place;?>";
var editaction="qty";
var editnumber="";
function PrintCategories(first) {
for (i = 0; i < 14; i++) {
for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined") break;
$("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
@ -124,37 +122,40 @@ function PrintCategories(first) {
}
function MoreCategories(moreorless) {
if (moreorless=="more"){
console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories);
if (moreorless=="more") {
$('#catimg15').animate({opacity: '0.5'}, 1);
$('#catimg15').animate({opacity: '1'}, 100);
pagecategories=pagecategories+1;
}
if (moreorless=="less"){
if (moreorless=="less") {
$('#catimg14').animate({opacity: '0.5'}, 1);
$('#catimg14').animate({opacity: '1'}, 100);
if (pagecategories==0) return; //Return if no less pages
pagecategories=pagecategories-1;
}
if (typeof (categories[14*pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages
if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages
pagecategories=pagecategories-1;
return;
}
for (i = 0; i < 14; i++) {
if (typeof (categories[i+(14*pagecategories)]) == "undefined"){
$("#catdesc"+i).text("");
$("#catimg"+i).attr("src","genimg/empty.png");
$("#catwatermark"+i).hide();
continue;
}
$("#catdesc"+i).text(categories[i+(14*pagecategories)]['label']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(14*pagecategories)]['rowid']);
$("#catdiv"+i).data("rowid",categories[i+(14*pagecategories)]['rowid']);
for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) == "undefined") {
$("#catdesc"+i).text("");
$("#catimg"+i).attr("src","genimg/empty.png");
$("#catwatermark"+i).hide();
continue;
}
$("#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catdiv"+i).data("rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catwatermark"+i).show();
}
}
function LoadProducts(position, issubcat=false) {
$('#catimg'+position).animate({opacity: '0.5'}, 1);
var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
$('#catimg'+position).animate({opacity: '0.5'}, 1);
$('#catimg'+position).animate({opacity: '1'}, 100);
if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
else currentcat=$('#catdiv'+position).data('rowid');
@ -163,7 +164,7 @@ function LoadProducts(position, issubcat=false) {
ishow=0; //product to show counter
jQuery.each(subcategories, function(i, val) {
if (currentcat==val.fk_parent){
if (currentcat==val.fk_parent) {
$("#prodesc"+ishow).text(val.label);
$("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid);
$("#prodiv"+ishow).data("rowid",val.rowid);
@ -175,28 +176,35 @@ function LoadProducts(position, issubcat=false) {
idata=0; //product data counter
$.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
while (ishow < 30) {
console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat);
while (ishow < maxproduct) {
//console.log("ishow"+ishow+" idata="+idata);
//console.log(data[idata]);
if (typeof (data[idata]) == "undefined") {
$("#prodesc"+ishow).text("");
$("#proimg"+ishow).attr("src","genimg/empty.png");
$("#prodiv"+ishow).data("rowid","");
$("#prowatermark"+ishow).hide();
ishow++; //Next product to show after print data product
}
else if ((data[idata]['status']) == "1") {
//Only show products with status=1 (for sell)
else if ((data[idata]['status']) == "1") { // Only show products with status=1 (for sell)
$("#prodesc"+ishow).text(data[parseInt(idata)]['label']);
$("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']);
$("#prodiv"+ishow).data("rowid",data[idata]['id']);
$("#prodiv"+ishow).data("iscat",0);
$("#prowatermark"+ishow).hide();
ishow++; //Next product to show after print data product
}
$("#prowatermark"+ishow).hide();
//console.log("Hide the prowatermark for ishow="+ishow);
idata++; //Next data everytime
}
});
}
function MoreProducts(moreorless){
function MoreProducts(moreorless) {
var maxproduct = <?php echo ($MAXPRODUCT - 2); ?>;
if (moreorless=="more"){
$('#proimg31').animate({opacity: '0.5'}, 1);
$('#proimg31').animate({opacity: '1'}, 100);
@ -209,13 +217,16 @@ function MoreProducts(moreorless){
pageproducts=pageproducts-1;
}
$.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
if (typeof (data[(30*pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages
console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
if (typeof (data[(maxproduct * pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages
pageproducts=pageproducts-1;
return;
}
idata=30*pageproducts; //product data counter
idata=<?php echo ($MAXPRODUCT - 2); ?> * pageproducts; //product data counter
ishow=0; //product to show counter
while (ishow < 30) {
while (ishow < maxproduct) {
if (typeof (data[idata]) == "undefined") {
$("#prodesc"+ishow).text("");
$("#proimg"+ishow).attr("src","genimg/empty.png");
@ -236,62 +247,65 @@ function MoreProducts(moreorless){
});
}
function ClickProduct(position){
function ClickProduct(position) {
$('#proimg'+position).animate({opacity: '0.5'}, 1);
$('#proimg'+position).animate({opacity: '1'}, 100);
if ($('#prodiv'+position).data('iscat')==1){
console.log("Click on a category at position "+position);
LoadProducts(position, true);
}
else{
idproduct=$('#prodiv'+position).data('rowid');
console.log("Click on product at position "+position+" for idproduct "+idproduct);
if (idproduct=="") return;
// Call page invoice.php to generate the section with product lines
$("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
}
function deleteline(){
function deleteline() {
$("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
function Customer(){
function Customer() {
$.colorbox({href:"customers.php?nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Customer");?>"});
}
function CloseBill(){
function CloseBill() {
invoiceid = $("#invoiceid").val();
console.log("Open popup to enter payment on invoiceid="+invoiceid);
$.colorbox({href:"pay.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""});
}
function Floors(){
function Floors() {
$.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors");?>"});
}
function FreeZone(){
function FreeZone() {
$.colorbox({href:"freezone.php?action=freezone&place="+place, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone");?>"});
}
function TakeposOrderNotes(){
function TakeposOrderNotes() {
$.colorbox({href:"freezone.php?action=addnote&place="+place+"&idline="+selectedline, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("OrderNotes");?>"});
}
function Refresh(){
function Refresh() {
$("#poslines").load("invoice.php?place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
function Search(){
function Search() {
$("#poslines").load("invoice.php?action=search&place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
function Search2(){
function Search2() {
pageproducts=0;
$.getJSON('./ajax.php?action=search&term='+$('#search').val(), function(data) {
for (i = 0; i < 30; i++) {
@ -320,7 +334,7 @@ function Edit(number){
if (editaction=='qty' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#qty").html("<?php echo $langs->trans("Qty"); ?>");
});
return;
@ -333,7 +347,7 @@ function Edit(number){
if (editaction=='p' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#price").html("<?php echo $langs->trans("Price"); ?>");
});
return;
@ -346,7 +360,7 @@ function Edit(number){
if (editaction=='r' && editnumber!=""){
$("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
});
return;
@ -381,13 +395,13 @@ function Edit(number){
function TakeposPrintingOrder(){
$("#poslines").load("invoice.php?action=order&place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
function TakeposPrintingTemp(){
$("#poslines").load("invoice.php?action=temp&place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
@ -492,10 +506,9 @@ $menus[$r++]=array('title'=>$langs->trans("DoPayment"),
$menus[$r++]=array('title'=>$langs->trans("Logout"),
'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';');
//BAR RESTAURANT specified menu
// BAR RESTAURANT specific menu
if($conf->global->TAKEPOS_BAR_RESTAURANT){
$menus[$r++]=array('title'=>$langs->trans("Floors"),
'action'=>'Floors();');
$menus[$r++]=array('title'=>$langs->trans("Floors"), 'action'=>'Floors();');
if ($conf->global->TAKEPOS_ORDER_PRINTERS){
$menus[$r++]=array('title'=>$langs->trans("Order"),
'action'=>'TakeposPrintingOrder();');