From 32303bbe4827cba26e8b57b5d17844766a1fc2c9 Mon Sep 17 00:00:00 2001 From: David Beniamine Date: Mon, 25 Mar 2019 16:49:33 +0100 Subject: [PATCH] SQL modifications for multicompany compatibility Thanks to hregis --- htdocs/takepos/admin/setup.php | 5 ++++- htdocs/takepos/invoice.php | 8 +++----- htdocs/takepos/pay.php | 5 ++++- htdocs/takepos/takepos.php | 5 ++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 0de0793176b..b25212ea5db 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -43,7 +43,10 @@ $langs->loadLangs(array("admin", "cashdesk")); global $db; -$sql="SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement WHERE active=1 ORDER BY libelle"; +$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){ diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 69c9a83cae2..3e8d6327f1a 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -40,10 +40,6 @@ $number = GETPOST('number'); $idline = GETPOST('idline'); $desc = GETPOST('desc', 'alpha'); $pay = GETPOST('pay'); -$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]; $placeid = 0; // $placeid is id of invoice @@ -53,7 +49,9 @@ if ($ret > 0) $placeid = $invoice->id; // Retrieve paiementid -$sql="SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE code='$pay'"; +$sql = "SELECT id FROM ".MAIN_DB_PREFIX."c_paiement"; +$sql.= " WHERE entity IN (".getEntity('c_paiement').")"; +$sql.= " AND code = '$pay'"; $resql = $db->query($sql); $codes = $db->fetch_array($resql); $paiementid=$codes[0]; diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 1ae6a5af7d8..9672a97cd8d 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -51,7 +51,10 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); $langs->loadLangs(array("main", "bills", "cashdesk")); -$sql="SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement WHERE active=1 ORDER BY libelle"; +$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){ diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index d8120579a7d..422db40ad0a 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -451,7 +451,10 @@ $( document ).ready(function() { query($sql); $paiementsModes = array(); if($resql){