Finally fixed #192

This commit is contained in:
Pinga 2024-12-06 15:50:20 +02:00
parent ea88b14234
commit 0e2041edd6
2 changed files with 115 additions and 15 deletions

View file

@ -110,6 +110,14 @@ class DapiController extends Controller
} }
} }
// Check admin status and apply registrar filter if needed
$registrarCondition = '';
if ($_SESSION['auth_roles'] !== 0) { // not admin
$registrarId = $_SESSION['auth_registrar_id'];
$registrarCondition = "d.clid = :registrarId";
$bindParams["registrarId"] = $registrarId;
}
// Base SQL // Base SQL
$sqlBase = " $sqlBase = "
FROM domain d FROM domain d
@ -117,9 +125,27 @@ class DapiController extends Controller
LEFT JOIN domain_status ds ON d.id = ds.domain_id LEFT JOIN domain_status ds ON d.id = ds.domain_id
"; ";
$sqlWhere = ''; // Combine registrar condition and search filters
if (!empty($whereClauses)) { if (!empty($whereClauses)) {
$sqlWhere = "WHERE " . implode(" OR ", $whereClauses); // We have search conditions
$filtersCombined = "(" . implode(" OR ", $whereClauses) . ")";
if ($registrarCondition) {
// If registrarCondition exists and we have filters
// we do registrarCondition AND (filters OR...)
$sqlWhere = "WHERE $registrarCondition AND $filtersCombined";
} else {
// No registrar restriction, just the filters
$sqlWhere = "WHERE $filtersCombined";
}
} else {
// No search filters
if ($registrarCondition) {
// Only registrar condition
$sqlWhere = "WHERE $registrarCondition";
} else {
// No filters, no registrar condition
$sqlWhere = '';
}
} }
// Count total results // Count total results
@ -290,6 +316,14 @@ class DapiController extends Controller
} }
} }
// Check admin status and apply registrar filter if needed
$registrarCondition = '';
if ($_SESSION['auth_roles'] !== 0) { // not admin
$registrarId = $_SESSION['auth_registrar_id'];
$registrarCondition = "d.clid = :registrarId";
$bindParams["registrarId"] = $registrarId;
}
// Base SQL // Base SQL
$sqlBase = " $sqlBase = "
FROM application d FROM application d
@ -297,9 +331,27 @@ class DapiController extends Controller
LEFT JOIN application_status ds ON d.id = ds.domain_id LEFT JOIN application_status ds ON d.id = ds.domain_id
"; ";
$sqlWhere = ''; // Combine registrar condition and search filters
if (!empty($whereClauses)) { if (!empty($whereClauses)) {
$sqlWhere = "WHERE " . implode(" OR ", $whereClauses); // We have search conditions
$filtersCombined = "(" . implode(" OR ", $whereClauses) . ")";
if ($registrarCondition) {
// If registrarCondition exists and we have filters
// we do registrarCondition AND (filters OR...)
$sqlWhere = "WHERE $registrarCondition AND $filtersCombined";
} else {
// No registrar restriction, just the filters
$sqlWhere = "WHERE $filtersCombined";
}
} else {
// No search filters
if ($registrarCondition) {
// Only registrar condition
$sqlWhere = "WHERE $registrarCondition";
} else {
// No filters, no registrar condition
$sqlWhere = '';
}
} }
// Count total results // Count total results
@ -454,17 +506,41 @@ class DapiController extends Controller
} }
} }
// Check admin status and apply registrar filter if needed
$registrarCondition = '';
if ($_SESSION['auth_roles'] !== 0) { // not admin
$registrarId = $_SESSION['auth_registrar_id'];
$registrarCondition = "ph.registrar_id = :registrarId";
$bindParams["registrarId"] = $registrarId;
}
// Base SQL // Base SQL
$sqlBase = " $sqlBase = "
FROM payment_history ph FROM payment_history ph
LEFT JOIN registrar r ON ph.registrar_id = r.id LEFT JOIN registrar r ON ph.registrar_id = r.id
"; ";
// If you want all filters combined with OR, keep " OR ". // Combine registrar condition and search filters
// If you want AND logic for multiple filters, change to "AND".
$sqlWhere = '';
if (!empty($whereClauses)) { if (!empty($whereClauses)) {
$sqlWhere = "WHERE " . implode(" OR ", $whereClauses); // We have search conditions
$filtersCombined = "(" . implode(" OR ", $whereClauses) . ")";
if ($registrarCondition) {
// If registrarCondition exists and we have filters
// we do registrarCondition AND (filters OR...)
$sqlWhere = "WHERE $registrarCondition AND $filtersCombined";
} else {
// No registrar restriction, just the filters
$sqlWhere = "WHERE $filtersCombined";
}
} else {
// No search filters
if ($registrarCondition) {
// Only registrar condition
$sqlWhere = "WHERE $registrarCondition";
} else {
// No filters, no registrar condition
$sqlWhere = '';
}
} }
// Count total results // Count total results
@ -596,16 +672,41 @@ class DapiController extends Controller
} }
} }
// Check admin status and apply registrar filter if needed
$registrarCondition = '';
if ($_SESSION['auth_roles'] !== 0) { // not admin
$registrarId = $_SESSION['auth_registrar_id'];
$registrarCondition = "st.registrar_id = :registrarId";
$bindParams["registrarId"] = $registrarId;
}
// Base SQL // Base SQL
$sqlBase = " $sqlBase = "
FROM statement st FROM statement st
LEFT JOIN registrar r ON st.registrar_id = r.id LEFT JOIN registrar r ON st.registrar_id = r.id
"; ";
// Combine filters with OR (common approach) // Combine registrar condition and search filters
$sqlWhere = '';
if (!empty($whereClauses)) { if (!empty($whereClauses)) {
$sqlWhere = "WHERE " . implode(" OR ", $whereClauses); // We have search conditions
$filtersCombined = "(" . implode(" OR ", $whereClauses) . ")";
if ($registrarCondition) {
// If registrarCondition exists and we have filters
// we do registrarCondition AND (filters OR...)
$sqlWhere = "WHERE $registrarCondition AND $filtersCombined";
} else {
// No registrar restriction, just the filters
$sqlWhere = "WHERE $filtersCombined";
}
} else {
// No search filters
if ($registrarCondition) {
// Only registrar condition
$sqlWhere = "WHERE $registrarCondition";
} else {
// No filters, no registrar condition
$sqlWhere = '';
}
} }
// Count total results // Count total results
@ -651,5 +752,4 @@ class DapiController extends Controller
return $response; return $response;
} }
} }

View file

@ -25,9 +25,9 @@
placeholder: "{{ __('No Data') }}", placeholder: "{{ __('No Data') }}",
columns:[ columns:[
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0}, {formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"{{ __('Registrar') }}", field:"registrar_id.name", resizable:false, headerSort:true, responsive:0}, {title:"{{ __('Registrar') }}", field:"registrar_id.name", minWidth:200, resizable:false, headerSort:true, responsive:0},
{title:"{{ __('Date') }}", field:"date", resizable:false, headerSort:true, responsive:0}, {title:"{{ __('Date') }}", field:"date", resizable:false, minWidth:300, headerSort:true, responsive:0},
{title:"{{ __('Log') }}", field:"log", resizable:false, headerSort:true, responsive:2}, {title:"{{ __('Log') }}", field:"log", resizable:false, minWidth:600, headerSort:true, responsive:2},
] ]
}); });
var searchInput = document.getElementById("search-input"); var searchInput = document.getElementById("search-input");