diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php
new file mode 100644
index 00000000000..896a46c8189
--- /dev/null
+++ b/htdocs/core/lib/takepos.lib.php
@@ -0,0 +1,52 @@
+
+ *
+ * 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 .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/lib/takepos.lib.php
+ * \brief Library file with function for TakePOS module
+ */
+
+/**
+ * Prepare array with list of tabs
+ *
+ * @return array Array of tabs
+ */
+function takepos_prepare_head()
+{
+ global $langs, $conf;
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/setup.php';
+ $head[$h][1] = $langs->trans("Parameters");
+ $head[$h][2] = 'setup';
+ $h++;
+
+ for ($i = 2; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++)
+ {
+ $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i;
+ $head[$h][1] = $langs->trans("Terminal"). " ".$i;
+ $head[$h][2] = 'terminal'.$i;
+ $h++;
+ }
+
+ complete_head_from_modules($conf, $langs, null, $head, $h, 'takepos');
+
+ return $head;
+}
diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang
index 8dfc4dcd015..629416df6ed 100644
--- a/htdocs/langs/en_US/cashdesk.lang
+++ b/htdocs/langs/en_US/cashdesk.lang
@@ -63,4 +63,6 @@ AutoPrintTickets=Automatically print tickets
EnableBarOrRestaurantFeatures=Enable features for Bar or Restaurant
ConfirmDeletionOfThisPOSSale=Do your confirm the deletion of this current sale ?
History=History
-ValidateAndClose=Validate and close
\ No newline at end of file
+ValidateAndClose=Validate and close
+Terminals=Terminals
+TerminalSelect=Select terminal you want to use:
\ No newline at end of file
diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php
index e17ea0ee036..7f51508dfc5 100644
--- a/htdocs/takepos/admin/setup.php
+++ b/htdocs/takepos/admin/setup.php
@@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
// If socid provided by ajax company selector
if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id']))
@@ -88,6 +89,7 @@ if (GETPOST('action', 'alpha') == 'set')
$res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity);
if ($conf->global->TAKEPOS_ORDER_NOTES==1)
{
@@ -122,6 +124,8 @@ llxHeader('', $langs->trans("CashDeskSetup"));
$linkback=''.$langs->trans("BackToModuleList").'';
print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
+$head = takepos_prepare_head();
+dol_fiche_head($head, 'setup', 'TakePOS', -1);
print '
';
@@ -249,6 +253,14 @@ else
}
print "\n";
+// Terminals
+print '
| ';
+print $langs->trans("Terminals");
+print ' | ';
+$array=array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5");
+print $form->selectarray('TAKEPOS_NUM_TERMINALS', $array, (empty($conf->global->TAKEPOS_NUM_TERMINALS)?'0':$conf->global->TAKEPOS_NUM_TERMINALS), 0);
+print " |
\n";
+
print '';
print '
';
@@ -256,7 +268,8 @@ print '
';
print '';
print '';
-print '| '.$langs->trans("Terminal").' 0 | '.$langs->trans("Value").' | ';
+if (!$conf->global->TAKEPOS_NUM_TERMINALS || $conf->global->TAKEPOS_NUM_TERMINALS=="1") print ''.$langs->trans("Parameters").' | '.$langs->trans("Value").' | ';
+else print ''.$langs->trans("Terminal").' 1 | '.$langs->trans("Value").' | ';
print "
\n";
print '| '.$langs->trans("CashDeskThirdPartyForSell").' | ';
diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php
new file mode 100644
index 00000000000..fadf5b971f9
--- /dev/null
+++ b/htdocs/takepos/admin/terminal.php
@@ -0,0 +1,198 @@
+
+ * Copyright (C) 2011-2017 Juanjo Menent
+ *
+ * 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/admin/setup.php
+ * \ingroup takepos
+ * \brief Setup page for TakePos module
+ */
+
+require '../../main.inc.php'; // Load $user and permissions
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
+
+$terminal=GETPOST('terminal', 'int');
+// If socid provided by ajax company selector
+if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id']))
+{
+ $_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
+ $_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
+ $_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
+}
+
+// Security check
+if (!$user->admin) accessforbidden();
+
+$langs->loadLangs(array("admin", "cashdesk"));
+
+global $db;
+
+$sql = "SELECT code, libelle 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)){
+ array_push($paiements, $obj);
+ }
+}
+
+/*
+ * Actions
+ */
+if (GETPOST('action', 'alpha') == 'set')
+{
+ $db->begin();
+ if (GETPOST('socid', 'int') < 0) $_POST["socid"]='';
+
+ $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminal, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
+
+ $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminal, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminal, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminal, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminal, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminal, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminal, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminal, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminal, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminal, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
+ foreach($paiements as $modep) {
+ if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue;
+ $name="CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminal;
+ $res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
+ }
+ $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE".$terminal, (GETPOST('CASHDESK_ID_WAREHOUSE'.$terminal, 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE'.$terminal, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminal, GETPOST('CASHDESK_NO_DECREASE_STOCK'.$terminal, 'alpha'), 'chaine', 0, '', $conf->entity);
+
+ dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
+
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $db->commit();
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ }
+ else
+ {
+ $db->rollback();
+ setEventMessages($langs->trans("Error"), null, 'errors');
+ }
+}
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$formproduct=new FormProduct($db);
+
+llxHeader('', $langs->trans("CashDeskSetup"));
+
+$linkback=''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
+$head = takepos_prepare_head();
+dol_fiche_head($head, 'terminal'.$terminal, 'TakePOS', -1);
+print '
';
+
+
+// Mode
+print '\n";
+
+print '
';
+
+llxFooter();
+$db->close();
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 2fc99b1a587..7645ef176c5 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -90,7 +90,7 @@ if ($invoiceid > 0)
}
else
{
- $ret = $invoice->fetch('', '(PROV-POS-'.$place.')');
+ $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takepostermvar"].'-'.$place.')');
}
if ($ret > 0)
{
@@ -104,12 +104,12 @@ if ($ret > 0)
if ($action == 'valid' && $user->rights->facture->creer)
{
- if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; // For backward compatibility
- elseif ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; // For backward compatibility
- elseif ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; // For backward compatibility
+ if ($pay == "cash") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takepostermvar"]}; // For backward compatibility
+ elseif ($pay == "card") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION["takepostermvar"]}; // For backward compatibility
+ elseif ($pay == "cheque") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takepostermvar"]}; // For backward compatibility
else
{
- $accountname="CASHDESK_ID_BANKACCOUNT_".$pay;
+ $accountname="CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takepostermvar"];
$bankaccount=$conf->global->$accountname;
}
$now=dol_now();
@@ -137,9 +137,9 @@ if ($action == 'valid' && $user->rights->facture->creer)
$invoice->update($user);
}
- if (! empty($conf->stock->enabled) && $conf->global->CASHDESK_NO_DECREASE_STOCK != "1")
+ if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takepostermvar"]} != "1")
{
- $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE);
+ $invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takepostermvar"]});
}
else
{
@@ -180,13 +180,13 @@ if ($action == 'history')
if (($action=="addline" || $action=="freezone") && $placeid == 0)
{
- $invoice->socid = $conf->global->CASHDESK_ID_THIRDPARTY;
+ $invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takepostermvar"]};
$invoice->date = dol_now();
$invoice->module_source = 'takepos';
$invoice->pos_source = (string) $posnb;
$placeid = $invoice->create($user);
- $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS-".$place.")' where rowid=".$placeid;
+ $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takepostermvar"]."-".$place.")' where rowid=".$placeid;
$db->query($sql);
}
@@ -559,11 +559,11 @@ else { // No invoice generated yet
print '
';
-if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY)
+if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takepostermvar"]})
{
$soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
- else $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY);
+ else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takepostermvar"]});
print '';
print $langs->trans("Customer").': '.$soc->name;
print '
';
diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php
index 1fe325dfdeb..74af8f62ae9 100644
--- a/htdocs/takepos/pay.php
+++ b/htdocs/takepos/pay.php
@@ -51,7 +51,7 @@ if ($invoiceid > 0)
}
else
{
- $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'";
+ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takepostermvar"]."-".$place.")'";
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php
index 7f3d5bdc0cc..c80b3b5b932 100644
--- a/htdocs/takepos/receipt.php
+++ b/htdocs/takepos/receipt.php
@@ -44,7 +44,7 @@ top_httphead('text/html');
if ($place > 0)
{
- $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'";
+ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takepostermvar"]."-".$place.")'";
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php
index d5d81880a4e..0db03a20080 100644
--- a/htdocs/takepos/takepos.php
+++ b/htdocs/takepos/takepos.php
@@ -40,8 +40,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$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');
+$setterminal = GETPOST('setterminal', 'int');
+
+if ($setterminal>0)
+{
+ $_SESSION["takeposterminal"]=$setterminal;
+ if ($setterminal==1) $_SESSION["takepostermvar"]="";
+ else $_SESSION["takepostermvar"]=$setterminal;
+}
$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter"));
@@ -538,15 +545,47 @@ function MoreActions(totalactions){
}
}
+function TerminalsDialog()
+{
+ jQuery("#dialog-info").dialog({
+ resizable: false,
+ height:200,
+ width:400,
+ modal: true,
+ buttons: {
+ Terminal1: function() {
+ location.href='takepos.php?setterminal=1';
+ }
+ global->TAKEPOS_NUM_TERMINALS; $i++)
+ {
+ print "
+ ,
+ Terminal".$i.": function() {
+ location.href='takepos.php?setterminal=".$i."';
+ }
+ ";
+ }
+ ?>
+ }
+ });
+}
+
$( document ).ready(function() {
PrintCategories(0);
LoadProducts(0);
Refresh();
+ global->TAKEPOS_NUM_TERMINALS!="1" && $_SESSION["takeposterminal"]=="") print "TerminalsDialog();";
+ ?>
});
-
+global->TAKEPOS_NUM_TERMINALS!="1" && $_SESSION["takeposterminal"]=="") print ''.$langs->trans('TerminalSelect').'
';
+?>