Database Transactions PHP 8.1 changes

This commit is contained in:
markjcrane
2023-05-26 13:48:39 -06:00
parent 3112c9ae18
commit 711ca64ad3
2 changed files with 40 additions and 26 deletions

View File

@@ -46,13 +46,22 @@
$language = new text;
$text = $language->get();
//set default values
$search = '';
//get variables used to control the order
$order_by = $_GET["order_by"];
$order = $_GET["order"];
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$button_icon_view = !empty($_SESSION['theme']['button_icon_view']) ? $_SESSION['theme']['button_icon_view'] : '';
//add the user filter and search term
$user_uuid = $_GET['user_uuid'];
if (isset($_GET["search"]) && $_GET["search"] != '') {
if (!empty($_GET["user_uuid"])) {
$user_uuid = $_GET['user_uuid'];
}
if (!empty($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
@@ -62,11 +71,11 @@
$sql .= "left outer join v_domains as d using (domain_uuid) ";
$sql .= "left outer join v_users as u using (user_uuid) ";
$sql .= "where t.domain_uuid = :domain_uuid ";
if (is_uuid($user_uuid)) {
if (!empty($user_uuid)) {
$sql .= "and t.user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
if (isset($search)) {
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(t.app_name) like :search ";
$sql .= " or lower(t.transaction_code) like :search ";
@@ -85,10 +94,9 @@
unset($parameters);
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "search=".$search;
$page = $_GET['page'];
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$page = empty($_GET['page']) ? $page = 0 : $page = $_GET['page'];
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
@@ -101,11 +109,11 @@
$sql .= "left outer join v_domains as d using (domain_uuid) ";
$sql .= "left outer join v_users as u using (user_uuid) ";
$sql .= "where t.domain_uuid = :domain_uuid ";
if (is_uuid($user_uuid)) {
if (!empty($user_uuid)) {
$sql .= "and t.user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
if (isset($search)) {
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(t.app_name) like :search ";
$sql .= " or lower(t.transaction_code) like :search ";
@@ -122,7 +130,7 @@
$sql .= order_by($order_by, $order, 't.transaction_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$result = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//get users
@@ -161,7 +169,7 @@
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']);
//echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','onclick'=>"document.getElementById('search').value = ''; document.getElementById('form_search').submit();",'style'=>(!$search ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
echo " </form>\n";
@@ -184,7 +192,7 @@
//echo th_order_by('transaction_old', $text['label-transaction_old'], $order_by, $order);
//echo th_order_by('transaction_new', $text['label-transaction_new'], $order_by, $order);
//echo th_order_by('transaction_result', $text['label-transaction_result'], $order_by, $order);
if (permission_exists('database_transaction_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('database_transaction_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -193,7 +201,7 @@
$x = 0;
foreach($result as $row) {
if (permission_exists('database_transaction_edit')) {
$list_row_url = "database_transaction_edit.php?id=".urlencode($row['database_transaction_uuid']).($page != '' ? "&page=".urlencode($page) : null).($search != '' ? "&search=".urlencode($search) : null);
$list_row_url = "database_transaction_edit.php?id=".urlencode($row['database_transaction_uuid']).(!empty($page) ? "&page=".urlencode($page) : null).(!empty($search) ? "&search=".urlencode($search) : null);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo " <td>".escape($row['domain_name'])."&nbsp;</td>\n";
@@ -208,7 +216,7 @@
//echo " <td>".escape($row['transaction_result']."&nbsp;</td>\n";
if (permission_exists('database_transaction_edit')) {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]);
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$button_icon_view,'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";