diff --git a/htdocs/takepos/customers.php b/htdocs/takepos/customers.php index 6c526a97ea3..46e06365a93 100644 --- a/htdocs/takepos/customers.php +++ b/htdocs/takepos/customers.php @@ -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'; diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 6392bf56d6e..0206fe1a8e0 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -35,7 +35,10 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $left = GETPOST('left', 'alpha'); $top = GETPOST('top', 'alpha'); -$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 + $newname = GETPOST('newname', 'alpha'); $mode = GETPOST('mode', 'alpha'); @@ -63,7 +66,7 @@ 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."'"); + $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'"); } if ($action=="add") diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index 4bf96470219..f9a270b247c 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -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'); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index aff4f066ba1..4b6aebbe80c 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -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'); @@ -124,7 +127,7 @@ 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; @@ -178,8 +181,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]; @@ -375,55 +378,73 @@ if (! empty($conf->use_javascript_ajax)) print ''."\n"; } + print '
'; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; print "\n"; -if ($placeid > 0) { - foreach($invoice->lines as $line) +if ($placeid > 0) +{ + $tmplines = array_reverse($invoice->lines); + foreach($tmplines as $line) { - print 'special_code == "3") { - print ' order'; + $htmlforlines.= ' order'; } - print '" id="' . $line->id . '">'; - print ''; - print ''; - print ''; - print ''; - print ''; + if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
(".$line->array_options['options_order_notes'].")"; + $htmlforlines.= ''; + $htmlforlines.= ''; + $htmlforlines.= ''; + $htmlforlines.= ''; + $htmlforlines.= ''."\n"; + + print $htmlforlines; } } print '
' . $langs->trans('Description') . ''; +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; + } + print $langs->trans('Place')." ".$label." - "; + print $langs->trans('Floor')." ".$floor." - "; +} +print $langs->trans('TotalTTC'); +print ' : '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; +print '' . $langs->trans('ReductionShort') . '' . $langs->trans('Qty') . '' . $langs->trans('TotalHTShort') . '
'; - print $line->product_label; - if ($line->product_label && $line->desc) print '
'; + $htmlforlines.= '" id="' . $line->id . '">'; + $htmlforlines.= '
'; + $htmlforlines.= $line->product_label; + if ($line->product_label && $line->desc) $htmlforlines.= '
'; if ($line->product_label != $line->desc) { $firstline = dolGetFirstLineOfText($line->desc); if ($firstline != $line->desc) { - print $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); } else { - print $line->desc; + $htmlforlines.= $line->desc; } } - if (!empty($line->array_options['options_order_notes'])) echo "
(".$line->array_options['options_order_notes'].")"; - print '
' . vatrate($line->remise_percent, true) . '' . $line->qty . '' . price($line->total_ttc) . '
' . vatrate($line->remise_percent, true) . '' . $line->qty . '' . price($line->total_ttc) . '
'; -print '

'.$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).' 

'; - if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY) { $soc = new Societe($db); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 6dd80bed342..fed57dcf068 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -34,7 +34,9 @@ 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'; -$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'); @@ -51,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); } } diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index fb23120623a..7e560a0d40f 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -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); diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index fb0b0073510..bb57baaf04d 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$place = GETPOST('place', 'int'); -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")); @@ -259,7 +260,7 @@ function ClickProduct(position) { 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); }); } }