Quick Search:

View

Revision:

Diff

Diff from 477 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/oscommerce2/trunk/catalog/account_notifications.php

Annotated File View

hpdl
477
1 <?php
2 /*
3   $Id: account_notifications.php,v 1.2 2003/05/22 14:24:54 hpdl Exp $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2003 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   require('includes/application_top.php');
14
15   if (!tep_session_is_registered('customer_id')) {
16     $navigation->set_snapshot();
17     tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
18   }
19
20 // needs to be included earlier to set the success message in the messageStack
21   require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_NOTIFICATIONS);
22
23   $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
24   $global = tep_db_fetch_array($global_query);
25
26   if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) {
27     if (isset($HTTP_POST_VARS['product_global']) && is_numeric($HTTP_POST_VARS['product_global'])) {
28       $product_global = tep_db_prepare_input($HTTP_POST_VARS['product_global']);
29     } else {
30       $product_global = '0';
31     }
32
33     (array)$products = $HTTP_POST_VARS['products'];
34
35     if ($product_global != $global['global_product_notifications']) {
36       $product_global = (($global['global_product_notifications'] == '1') ? '0' : '1');
37
38       tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set global_product_notifications = '" . (int)$product_global . "' where customers_info_id = '" . (int)$customer_id . "'");
39     } elseif (sizeof($products) > 0) {
40       $products_parsed = array();
41       for ($i=0, $n=sizeof($products); $i<$n; $i++) {
42         if (is_numeric($products[$i])) {
43           $products_parsed[] = $products[$i];
44         }
45       }
46
47       if (sizeof($products_parsed) > 0) {
48         $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "' and products_id not in (" . implode(',', $products_parsed) . ")");
49         $check = tep_db_fetch_array($check_query);
50
51         if ($check['total'] > 0) {
52           tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "' and products_id not in (" . implode(',', $products_parsed) . ")");
53         }
54       }
55     } else {
56       $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "'");
57       $check = tep_db_fetch_array($check_query);
58
59       if ($check['total'] > 0) {
60         tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "'");
61       }
62     }
63
64     $messageStack->add_session('account', SUCCESS_NOTIFICATIONS_UPDATED, 'success');
65
66     tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
67   }
68
69   $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
70   $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_NOTIFICATIONS, '', 'SSL'));
71 ?>
72 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
73 <html <?php echo HTML_PARAMS; ?>>
74 <head>
75 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
76 <title><?php echo TITLE; ?></title>
77 <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
78 <link rel="stylesheet" type="text/css" href="stylesheet.css">
79 <script language="javascript"><!--
80 function rowOverEffect(object) {
81   if (object.className == 'moduleRow') object.className = 'moduleRowOver';
82 }
83
84 function rowOutEffect(object) {
85   if (object.className == 'moduleRowOver') object.className = 'moduleRow';
86 }
87
88 function checkBox(object) {
89   document.account_notifications.elements[object].checked = !document.account_notifications.elements[object].checked;
90 }
91 //--></script>
92 </head>
93 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
94 <!-- header //-->
95 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
96 <!-- header_eof //-->
97
98 <!-- body //-->
99 <table border="0" width="100%" cellspacing="3" cellpadding="3">
100   <tr>
101     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
102 <!-- left_navigation //-->
103 <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
104 <!-- left_navigation_eof //-->
105     </table></td>
106 <!-- body_text //-->
107     <td width="100%" valign="top"><?php echo tep_draw_form('account_notifications', tep_href_link(FILENAME_ACCOUNT_NOTIFICATIONS, '', 'SSL')) . tep_draw_hidden_field('action', 'process'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
108       <tr>
109         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
110           <tr>
111             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
112             <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
113           </tr>
114         </table></td>
115       </tr>
116       <tr>
117         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
118       </tr>
119       <tr>
120         <td class="main"><b><?php echo MY_NOTIFICATIONS_TITLE; ?></b></td>
121       </tr>
122       <tr>
123         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
124           <tr class="infoBoxContents">
125             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
126               <tr>
127                 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
128                 <td class="main"><?php echo MY_NOTIFICATIONS_DESCRIPTION; ?></td>
129                 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
130               </tr>
131             </table></td>
132           </tr>
133         </table></td>
134       </tr>
135       <tr>
136         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
137       </tr>
138       <tr>
139         <td class="main"><b><?php echo GLOBAL_NOTIFICATIONS_TITLE; ?></b></td>
140       </tr>
141       <tr>
142         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
143           <tr class="infoBoxContents">
144             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
145               <tr>
146                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
147                 <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
148                   <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="checkBox('product_global')">
149                     <td class="main" width="30"><?php echo tep_draw_checkbox_field('product_global', '1', (($global['global_product_notifications'] == '1') ? true : false), 'onclick="checkBox(\'product_global\')"'); ?></td>
150                     <td class="main"><b><?php echo GLOBAL_NOTIFICATIONS_TITLE; ?></b></td>
151                   </tr>
152                   <tr>
153                     <td width="30">&nbsp;</td>
154                     <td class="main"><?php echo GLOBAL_NOTIFICATIONS_DESCRIPTION; ?></td>
155                   </tr>
156                 </table></td>
157                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
158               </tr>
159             </table></td>
160           </tr>
161         </table></td>
162       </tr>
163       <tr>
164         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
165       </tr>
166 <?php
167   if ($global['global_product_notifications'] != '1') {
168 ?>
169       <tr>
170         <td class="main"><b><?php echo NOTIFICATIONS_TITLE; ?></b></td>
171       </tr>
172       <tr>
173         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
174           <tr class="infoBoxContents">
175             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
176               <tr>
177                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
178                 <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
179 <?php
180     $products_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "'");
181     $products_check = tep_db_fetch_array($products_check_query);
182     if ($products_check['total'] > 0) {
183 ?>
184                   <tr>
185                     <td class="main" colspan="2"><?php echo NOTIFICATIONS_DESCRIPTION; ?></td>
186                   </tr>
187 <?php
188       $counter = 0;
189       $products_query = tep_db_query("select pd.products_id, pd.products_name from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_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");
190       while ($products = tep_db_fetch_array($products_query)) {
191 ?>
192                   <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="checkBox('products[<?php echo $counter; ?>]')">
193                     <td class="main" width="30"><?php echo tep_draw_checkbox_field('products[' . $counter . ']', $products['products_id'], true, 'onclick="checkBox(\'products[' . $counter . ']\')"'); ?></td>
194                     <td class="main"><b><?php echo $products['products_name']; ?></b></td>
195                   </tr>
196 <?php
197         $counter++;
198       }
199     } else {
200 ?>
201                   <tr>
202                     <td class="main"><?php echo NOTIFICATIONS_NON_EXISTING; ?></td>
203                   </tr>
204 <?php
205     }
206 ?>
207                 </table></td>
208                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
209               </tr>
210             </table></td>
211           </tr>
212         </table></td>
213       </tr>
214       <tr>
215         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
216       </tr>
217 <?php
218   }
219 ?>
220       <tr>
221         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
222           <tr class="infoBoxContents">
223             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
224               <tr>
225                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
226                 <td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
227                 <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
228                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
229               </tr>
230             </table></td>
231           </tr>
232         </table></td>
233       </tr>
234     </table></form></td>
235 <!-- body_text_eof //-->
236     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
237 <!-- right_navigation //-->
238 <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
239 <!-- right_navigation_eof //-->
240     </table></td>
241   </tr>
242 </table>
243 <!-- body_eof //-->
244
245 <!-- footer //-->
246 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
247 <!-- footer_eof //-->
248 <br>
249 </body>
250 </html>
251 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>