Skip to content

Commit 88ee9b6

Browse files
committed
Migrated Tax, custom link edit over to the new AJAX model function
1 parent a9e3e47 commit 88ee9b6

File tree

7 files changed

+166
-133
lines changed

7 files changed

+166
-133
lines changed

admin_custom_link.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@
105105
?>
106106
<tr>
107107
<td>
108-
<a href="#" data-toggle="modal" data-target="#editLinkModal<?php echo $custom_link_id; ?>">
109-
<i class="fa fa-fw fa-<?php echo $custom_link_icon; ?> mr-2"></i>
110-
<?php echo $custom_link_name;?>
108+
<a href="#"
109+
data-toggle="ajax-modal"
110+
data-ajax-url="ajax/ajax_custom_link_edit.php"
111+
data-ajax-id="<?php echo $custom_link_id; ?>"
112+
>
113+
<i class="fa fa-fw fa-<?php echo $custom_link_icon; ?> mr-2"></i><?php echo $custom_link_name;?>
111114
</a>
112115
</td>
113116
<td><?php echo $custom_link_order_display; ?></td>
@@ -119,7 +122,7 @@
119122
<i class="fas fa-ellipsis-h"></i>
120123
</button>
121124
<div class="dropdown-menu">
122-
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editLinkModal<?php echo $custom_link_id; ?>">
125+
<a class="dropdown-item" href="#" data-toggle="ajax-modal" data-ajax-url="ajax/ajax_custom_link_edit.php" data-ajax-id="<?php echo $custom_link_id; ?>">
123126
<i class="fas fa-fw fa-edit mr-2"></i>Edit
124127
</a>
125128
<div class="dropdown-divider"></div>
@@ -132,10 +135,6 @@
132135
</tr>
133136

134137
<?php
135-
136-
require "modals/admin_custom_link_edit_modal.php";
137-
138-
139138
}
140139

141140
?>
@@ -150,6 +149,4 @@
150149

151150
<?php
152151
require_once "modals/admin_custom_link_add_modal.php";
153-
154152
require_once "includes/footer.php";
155-

admin_tax.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,27 @@
5656

5757
?>
5858
<tr>
59-
<td><a class="text-dark text-bold" href="#" data-toggle="modal" data-target="#editTaxModal<?php echo $tax_id; ?>"><?php echo $tax_name; ?></a></td>
59+
<td>
60+
<a class="text-dark text-bold" href="#"
61+
data-toggle="ajax-modal"
62+
data-ajax-url="ajax/ajax_tax_edit.php"
63+
data-ajax-id="<?php echo $tax_id; ?>"
64+
>
65+
<?php echo $tax_name; ?>
66+
</a>
67+
</td>
6068
<td><?php echo "$tax_percent%"; ?></td>
6169
<td>
6270
<div class="dropdown dropleft text-center">
6371
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
6472
<i class="fas fa-ellipsis-h"></i>
6573
</button>
6674
<div class="dropdown-menu">
67-
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editTaxModal<?php echo $tax_id; ?>">
75+
<a class="dropdown-item" href="#"
76+
data-toggle="ajax-modal"
77+
data-ajax-url="ajax/ajax_tax_edit.php"
78+
data-ajax-id="<?php echo $tax_id; ?>"
79+
>
6880
<i class="fas fa-fw fa-edit mr-2"></i>Edit
6981
</a>
7082
<div class="dropdown-divider"></div>
@@ -78,8 +90,6 @@
7890

7991
<?php
8092

81-
require "modals/admin_tax_edit_modal.php";
82-
8393
}
8494

8595
if ($num_rows == 0) {

ajax/ajax_custom_link_edit.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
require_once '../includes/ajax_header.php';
4+
5+
$custom_link_id = intval($_GET['id']);
6+
7+
$sql = mysqli_query($mysqli, "SELECT * FROM custom_links WHERE custom_link_id = $custom_link_id");
8+
$row = mysqli_fetch_array($sql);
9+
$custom_link_name = nullable_htmlentities($row['custom_link_name']);
10+
$custom_link_uri = nullable_htmlentities($row['custom_link_uri']);
11+
$custom_link_icon = nullable_htmlentities($row['custom_link_icon']);
12+
$custom_link_new_tab = intval($row['custom_link_new_tab']);
13+
$custom_link_order = intval($row['custom_link_order']);
14+
$custom_link_location = intval($row['custom_link_location']);
15+
16+
// Generate the HTML form content using output buffering.
17+
ob_start();
18+
?>
19+
20+
<div class="modal-header">
21+
<h5 class="modal-title"><i class="fas fa-fw fa-external-link-alt mr-2"></i>Editing link: <strong><?php echo $custom_link_name; ?></strong></h5>
22+
<button type="button" class="close text-white" data-dismiss="modal">
23+
<span>&times;</span>
24+
</button>
25+
</div>
26+
<form action="post.php" method="post" autocomplete="off">
27+
28+
<input type="hidden" name="custom_link_id" value="<?php echo $custom_link_id; ?>">
29+
30+
<div class="modal-body bg-white">
31+
32+
<div class="form-group">
33+
<label>Name <strong class="text-danger">*</strong></label>
34+
<div class="input-group">
35+
<div class="input-group-prepend">
36+
<span class="input-group-text"><i class="fa fa-fw fa-list-ul"></i></span>
37+
</div>
38+
<input type="text" class="form-control" name="name" value="<?php echo $custom_link_name; ?>" maxlength="200" required>
39+
</div>
40+
</div>
41+
42+
<div class="form-group">
43+
<label>Order</label>
44+
<div class="input-group">
45+
<div class="input-group-prepend">
46+
<span class="input-group-text"><i class="fa fa-fw fa-sort-numeric-down"></i></span>
47+
</div>
48+
<input type="number" class="form-control" name="order" placeholder="Leave blank for no order" value="<?php echo $custom_link_order; ?>">
49+
</div>
50+
</div>
51+
52+
<div class="form-group">
53+
<label>URI <strong class="text-danger">*</strong></label> / <span class="text-secondary">Open New Tab</span>
54+
<div class="input-group">
55+
<div class="input-group-prepend">
56+
<span class="input-group-text"><i class="fa fa-fw fa-external-link-alt"></i></span>
57+
</div>
58+
<input type="text" class="form-control" name="uri" placeholder="Enter Link" maxlength="500" value="<?php echo $custom_link_uri; ?>" required>
59+
<div class="input-group-append">
60+
<div class="input-group-text">
61+
<input type="checkbox" name="new_tab" value="1" <?php if ($custom_link_new_tab == 1) { echo "checked"; } ?>>
62+
</div>
63+
</div>
64+
</div>
65+
</div>
66+
67+
<div class="form-group">
68+
<label>Icon</label>
69+
<div class="input-group">
70+
<div class="input-group-prepend">
71+
<span class="input-group-text"><i class="fa fa-fw fa-image"></i></span>
72+
</div>
73+
<input type="text" class="form-control" name="icon" placeholder="Icon ex handshake" maxlength="200" value="<?php echo $custom_link_icon; ?>">
74+
</div>
75+
</div>
76+
77+
<div class="form-group">
78+
<label>Location <strong class="text-danger">*</strong></label>
79+
<div class="input-group">
80+
<div class="input-group-prepend">
81+
<span class="input-group-text"><i class="fa fa-fw fa-home"></i></span>
82+
</div>
83+
<select class="form-control select2" name="location" required>
84+
<option value="1" <?php if ($custom_link_location == 1) { echo "selected"; } ?> >Main Side Nav</option>
85+
<option value="2" <?php if ($custom_link_location == 2) { echo "selected"; } ?> >Top Nav (Icon Required)</option>
86+
<option value="3" <?php if ($custom_link_location == 3) { echo "selected"; } ?> >Client Portal Nav</option>
87+
</select>
88+
</div>
89+
</div>
90+
91+
</div>
92+
<div class="modal-footer bg-white">
93+
<button type="submit" name="edit_custom_link" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
94+
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
95+
</div>
96+
</form>
97+
98+
<?php
99+
require_once "../includes/ajax_footer.php";

ajax/ajax_tax_edit.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
require_once '../includes/ajax_header.php';
4+
5+
$tax_id = intval($_GET['id']);
6+
7+
$sql = mysqli_query($mysqli, "SELECT * FROM taxes WHERE tax_id = $tax_id");
8+
$row = mysqli_fetch_array($sql);
9+
$tax_name = nullable_htmlentities($row['tax_name']);
10+
$tax_percent = floatval($row['tax_percent']);
11+
12+
// Generate the HTML form content using output buffering.
13+
ob_start();
14+
?>
15+
16+
<div class="modal-header">
17+
<h5 class="modal-title"><i class="fas fa-fw fa-balance-scale mr-2"></i>Editing tax: <strong><?php echo $tax_name; ?></strong></h5>
18+
<button type="button" class="close text-white" data-dismiss="modal">
19+
<span>&times;</span>
20+
</button>
21+
</div>
22+
<form action="post.php" method="post" autocomplete="off">
23+
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
24+
<input type="hidden" name="tax_id" value="<?php echo $tax_id; ?>">
25+
26+
<div class="modal-body bg-white">
27+
28+
<div class="form-group">
29+
<label>Name <strong class="text-danger">*</strong></label>
30+
<input type="text" class="form-control" name="name" maxlength="200" value="<?php echo $tax_name; ?>" required>
31+
</div>
32+
33+
<div class="form-group">
34+
<label>Percent <strong class="text-danger">*</strong></label>
35+
<input type="number" min="0" step="any" class="form-control col-md-4" name="percent" value="<?php echo $tax_percent; ?>">
36+
</div>
37+
38+
</div>
39+
<div class="modal-footer bg-white">
40+
<button type="submit" name="edit_tax" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
41+
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
42+
</div>
43+
</form>
44+
45+
<?php
46+
require_once "../includes/ajax_footer.php";

includes/filter_footer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<option <?php if ($user_config_records_per_page == 50) { echo "selected"; } ?> >50</option>
2828
<option <?php if ($user_config_records_per_page == 100) { echo "selected"; } ?> >100</option>
2929
<option <?php if ($user_config_records_per_page == 500) { echo "selected"; } ?> >500</option>
30-
<option <?php if ($user_config_records_per_page == 1000) { echo "selected"; } ?> >1000</option>
3130
</select>
3231
</form>
3332
</div>

modals/admin_custom_link_edit_modal.php

Lines changed: 0 additions & 83 deletions
This file was deleted.

modals/admin_tax_edit_modal.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)