This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathzones.php
178 lines (147 loc) · 9.01 KB
/
zones.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
$action = $_GET['action'] ?? '';
$OSCOM_Hooks->call('zones', 'preAction');
if (tep_not_null($action)) {
switch ($action) {
case 'insert':
$zone_country_id = tep_db_prepare_input($_POST['zone_country_id']);
$zone_code = tep_db_prepare_input($_POST['zone_code']);
$zone_name = tep_db_prepare_input($_POST['zone_name']);
tep_db_query("insert into zones (zone_country_id, zone_code, zone_name) values ('" . (int)$zone_country_id . "', '" . tep_db_input($zone_code) . "', '" . tep_db_input($zone_name) . "')");
$OSCOM_Hooks->call('zones', 'insertAction');
tep_redirect(tep_href_link('zones.php'));
break;
case 'save':
$zone_id = tep_db_prepare_input($_GET['cID']);
$zone_country_id = tep_db_prepare_input($_POST['zone_country_id']);
$zone_code = tep_db_prepare_input($_POST['zone_code']);
$zone_name = tep_db_prepare_input($_POST['zone_name']);
tep_db_query("update zones set zone_country_id = '" . (int)$zone_country_id . "', zone_code = '" . tep_db_input($zone_code) . "', zone_name = '" . tep_db_input($zone_name) . "' where zone_id = '" . (int)$zone_id . "'");
$OSCOM_Hooks->call('zones', 'saveAction');
tep_redirect(tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $zone_id));
break;
case 'deleteconfirm':
$zone_id = tep_db_prepare_input($_GET['cID']);
tep_db_query("delete from zones where zone_id = '" . (int)$zone_id . "'");
$OSCOM_Hooks->call('zones', 'deleteConfirmAction');
tep_redirect(tep_href_link('zones.php', 'page=' . (int)$_GET['page']));
break;
}
}
$OSCOM_Hooks->call('zones', 'postAction');
require('includes/template_top.php');
?>
<div class="row">
<div class="col"><h1 class="display-4 mb-2"><?php echo HEADING_TITLE; ?></h1></div>
<div class="col text-right align-self-center">
<?php
if (empty($action)) {
echo tep_draw_bootstrap_button(IMAGE_NEW_ZONE, 'fas fa-map-marker-alt', tep_href_link('zones.php', 'action=new'), null, null, 'btn-danger');
}
else {
echo tep_draw_bootstrap_button(IMAGE_CANCEL, 'fas fa-angle-left', tep_href_link('zones.php'), null, null, 'btn-light mt-2');
}
?>
</div>
</div>
<div class="row no-gutters">
<div class="col-12 col-sm-8">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th><?php echo TABLE_HEADING_COUNTRY_NAME; ?></th>
<th><?php echo TABLE_HEADING_ZONE_NAME; ?></th>
<th class="text-right"><?php echo TABLE_HEADING_ZONE_CODE; ?></th>
<th class="text-right"><?php echo TABLE_HEADING_ACTION; ?></th>
</tr>
</thead>
<tbody>
<?php
$zones_query_raw = "select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from zones z, countries c where z.zone_country_id = c.countries_id order by c.countries_name, z.zone_name";
$zones_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $zones_query_raw, $zones_query_numrows);
$zones_query = tep_db_query($zones_query_raw);
while ($zones = tep_db_fetch_array($zones_query)) {
if ((!isset($_GET['cID']) || (isset($_GET['cID']) && ($_GET['cID'] == $zones['zone_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
$cInfo = new objectInfo($zones);
}
if (isset($cInfo) && is_object($cInfo) && ($zones['zone_id'] == $cInfo->zone_id)) {
echo '<tr class="table-active" onclick="document.location.href=\'' . tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=edit') . '\'">';
} else {
echo '<tr onclick="document.location.href=\'' . tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $zones['zone_id']) . '\'">';
}
?>
<td><?php echo $zones['countries_name']; ?></td>
<td><?php echo $zones['zone_name']; ?></td>
<td class="text-right"><?php echo $zones['zone_code']; ?></td>
<td class="text-right"><?php if (isset($cInfo) && is_object($cInfo) && ($zones['zone_id'] == $cInfo->zone_id) ) { echo '<i class="fas fa-chevron-circle-right text-info"></i>'; } else { echo '<a href="' . tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $zones['zone_id']) . '"><i class="fas fa-info-circle text-muted"></i></a>'; } ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="row my-1">
<div class="col"><?php echo $zones_split->display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_ZONES); ?></div>
<div class="col text-right mr-2"><?php echo $zones_split->display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></div>
</div>
</div>
<?php
$heading = [];
$contents = [];
switch ($action) {
case 'new':
$heading[] = ['text' => TEXT_INFO_HEADING_NEW_ZONE];
$contents = ['form' => tep_draw_form('zones', 'zones.php', 'page=' . (int)$_GET['page'] . '&action=insert')];
$contents[] = ['text' => TEXT_INFO_INSERT_INTRO];
$contents[] = ['text' => TEXT_INFO_ZONES_NAME . '<br>' . tep_draw_input_field('zone_name')];
$contents[] = ['text' => TEXT_INFO_ZONES_CODE . '<br>' . tep_draw_input_field('zone_code')];
$contents[] = ['text' => TEXT_INFO_COUNTRY_NAME . '<br>' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries())];
$contents[] = ['class' => 'text-center', 'text' => tep_draw_bootstrap_button(IMAGE_SAVE, 'fas fa-save', null, 'primary', null, 'btn-success mr-2') . tep_draw_bootstrap_button(IMAGE_CANCEL, 'fas fa-times', tep_href_link('zones.php', 'page=' . (int)$_GET['page']), null, null, 'btn-light')];
break;
case 'edit':
$heading[] = ['text' => TEXT_INFO_HEADING_EDIT_ZONE];
$contents = ['form' => tep_draw_form('zones', 'zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=save')];
$contents[] = ['text' => TEXT_INFO_EDIT_INTRO];
$contents[] = ['text' => TEXT_INFO_ZONES_NAME . '<br>' . tep_draw_input_field('zone_name', $cInfo->zone_name)];
$contents[] = ['text' => TEXT_INFO_ZONES_CODE . '<br>' . tep_draw_input_field('zone_code', $cInfo->zone_code)];
$contents[] = ['text' => TEXT_INFO_COUNTRY_NAME . '<br>' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(), $cInfo->countries_id)];
$contents[] = ['class' => 'text-center', 'text' => tep_draw_bootstrap_button(IMAGE_SAVE, 'fas fa-save', null, 'primary', null, 'btn-success mr-2') . tep_draw_bootstrap_button(IMAGE_CANCEL, 'fas fa-times', tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $cInfo->zone_id), null, null, 'btn-light')];
break;
case 'delete':
$heading[] = ['text' => TEXT_INFO_HEADING_DELETE_ZONE];
$contents = ['form' => tep_draw_form('zones', 'zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=deleteconfirm')];
$contents[] = ['text' => TEXT_INFO_DELETE_INTRO];
$contents[] = ['text' => '<strong>' . $cInfo->zone_name . '</strong>'];
$contents[] = ['class' => 'text-center', 'text' => tep_draw_bootstrap_button(IMAGE_DELETE, 'fas fa-trash', null, 'primary', null, 'btn-danger mr-2') . tep_draw_bootstrap_button(IMAGE_CANCEL, 'fas fa-times', tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $cInfo->zone_id), null, null, 'btn-light')];
break;
default:
if (isset($cInfo) && is_object($cInfo)) {
$heading[] = ['text' => $cInfo->zone_name];
$contents[] = ['class' => 'text-center', 'text' => tep_draw_bootstrap_button(IMAGE_EDIT, 'fas fa-cogs', tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=edit'), null, null, 'btn-warning mr-2') . tep_draw_bootstrap_button(IMAGE_DELETE, 'fas fa-trash', tep_href_link('zones.php', 'page=' . (int)$_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=delete'), null, null, 'btn-danger')];
$contents[] = ['text' => TEXT_INFO_ZONES_NAME . '<br>' . $cInfo->zone_name . ' (' . $cInfo->zone_code . ')'];
$contents[] = ['text' => TEXT_INFO_COUNTRY_NAME . ' ' . $cInfo->countries_name];
}
break;
}
if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo '<div class="col-12 col-sm-4">';
$box = new box;
echo $box->infoBox($heading, $contents);
echo '</div>';
}
?>
</div>
<?php
require('includes/template_bottom.php');
require('includes/application_bottom.php');
?>