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 pathaccount_notifications.php
151 lines (117 loc) · 5.48 KB
/
account_notifications.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
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2018 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link('login.php', '', 'SSL'));
}
// needs to be included earlier to set the success message in the messageStack
require('includes/languages/' . $language . '/account_notifications.php');
$global_query = tep_db_query("select global_product_notifications from customers_info where customers_info_id = '" . (int)$customer_id . "'");
$global = tep_db_fetch_array($global_query);
if (isset($_POST['action']) && ($_POST['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken)) {
if (isset($_POST['product_global']) && is_numeric($_POST['product_global'])) {
$product_global = tep_db_prepare_input($_POST['product_global']);
} else {
$product_global = '0';
}
(array)$products = $_POST['products'];
if ($product_global != $global['global_product_notifications']) {
$product_global = (($global['global_product_notifications'] == '1') ? '0' : '1');
tep_db_query("update customers_info set global_product_notifications = '" . (int)$product_global . "' where customers_info_id = '" . (int)$customer_id . "'");
} elseif (sizeof($products) > 0) {
$products_parsed = array();
foreach($products as $value) {
if (is_numeric($value)) {
$products_parsed[] = $value;
}
}
if (sizeof($products_parsed) > 0) {
$check_query = tep_db_query("select count(*) as total from products_notifications where customers_id = '" . (int)$customer_id . "' and products_id not in (" . implode(',', $products_parsed) . ")");
$check = tep_db_fetch_array($check_query);
if ($check['total'] > 0) {
tep_db_query("delete from products_notifications where customers_id = '" . (int)$customer_id . "' and products_id not in (" . implode(',', $products_parsed) . ")");
}
}
} else {
$check_query = tep_db_query("select count(*) as total from products_notifications where customers_id = '" . (int)$customer_id . "'");
$check = tep_db_fetch_array($check_query);
if ($check['total'] > 0) {
tep_db_query("delete from products_notifications where customers_id = '" . (int)$customer_id . "'");
}
}
$messageStack->add_session('account', SUCCESS_NOTIFICATIONS_UPDATED, 'success');
tep_redirect(tep_href_link('account.php', '', 'SSL'));
}
$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link('account.php', '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link('account_notifications.php', '', 'SSL'));
require('includes/template_top.php');
?>
<h1 class="display-4"><?php echo HEADING_TITLE; ?></h1>
<?php echo tep_draw_form('account_notifications', tep_href_link('account_notifications.php', '', 'SSL'), 'post', '', true) . tep_draw_hidden_field('action', 'process'); ?>
<div class="contentContainer">
<div class="alert alert-info" role="alert">
<?php echo MY_NOTIFICATIONS_DESCRIPTION; ?>
</div>
<div class="form-group row">
<label class="col-form-label col-sm-4 text-left text-sm-right"><?php echo GLOBAL_NOTIFICATIONS_TITLE; ?></label>
<div class="col-sm-8">
<div class="checkbox">
<label>
<?php echo tep_draw_checkbox_field('product_global', '1', (($global['global_product_notifications'] == '1') ? true : false)); ?>
<?php if (tep_not_null(GLOBAL_NOTIFICATIONS_DESCRIPTION)) echo GLOBAL_NOTIFICATIONS_DESCRIPTION; ?>
</label>
</div>
</div>
</div>
<?php
if ($global['global_product_notifications'] != '1') {
$products_check_query = tep_db_query("select count(*) as total from products_notifications where customers_id = '" . (int)$customer_id . "'");
$products_check = tep_db_fetch_array($products_check_query);
if ($products_check['total'] > 0) {
?>
<div class="clearfix"></div>
<div class="alert alert-warning" role="alert"><?php echo NOTIFICATIONS_DESCRIPTION; ?></div>
<div class="form-group row">
<label class="col-form-label col-sm-4 text-left text-sm-right"><?php echo MY_NOTIFICATIONS_TITLE; ?></label>
<div class="col-sm-8">
<?php
$products_query = tep_db_query("select pd.products_id, pd.products_name from products_description pd, products_notifications pn where pn.customers_id = '" . (int)$customer_id . "' and pn.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name");
while ($products = tep_db_fetch_array($products_query)) {
?>
<div class="checkbox">
<label>
<?php echo tep_draw_checkbox_field('products[]', $products['products_id'], true) . $products['products_name']; ?>
</label>
</div>
<?php
}
?>
</div>
</div>
<?php
} else {
?>
<div class="alert alert-warning" role="alert">
<?php echo NOTIFICATIONS_NON_EXISTING; ?>
</div>
<?php
}
}
?>
<div class="buttonSet">
<div class="text-right"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'fa fa-angle-right', null, 'primary', null, 'btn-success btn-lg btn-block'); ?></div>
<p><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'fa fa-angle-left', tep_href_link('account.php', '', 'SSL')); ?></p>
</div>
</div>
</form>
<?php
require('includes/template_bottom.php');
require('includes/application_bottom.php');
?>