834438eeec26f4a8bf8760fe5abe5c4b9b025fc9
[atutor.git] / mods / ecomm / index_admin.php
1 <?php\r
2 /************************************************************************/\r
3 /* ATutor                                                                                                                               */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2002-2010                                              */\r
6 /* Inclusive Design Institute                                           */\r
7 /* http://atutor.ca                                                     */\r
8 /* This program is free software. You can redistribute it and/or        */\r
9 /* modify it under the terms of the GNU General Public License          */\r
10 /* as published by the Free Software Foundation.                        */\r
11 /************************************************************************/\r
12 define('AT_INCLUDE_PATH', '../../include/');\r
13 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
14 admin_authenticate(AT_ADMIN_PRIV_ECOMM);\r
15 \r
16 if (isset($_POST['cancel'])) {\r
17         $msg->addFeedback('CANCELLED');\r
18         header('Location: payments_admin.php');\r
19         exit;\r
20 } else if (isset($_POST['submit'])) {\r
21 \r
22         $_POST['ec_uri']               = trim($_POST['ec_uri']);\r
23         $_POST['ec_vendor_id']         = trim($_POST['ec_vendor_id']);\r
24         $_POST['ec_password']          = trim($_POST['ec_password']);\r
25         $_POST['ec_contact_email']     = trim($_POST['ec_contact_email']);\r
26         $_POST['ec_contact_address']   = trim($_POST['ec_contact_address']);\r
27         $_POST['ec_allow_instructors'] = intval($_POST['ec_allow_instructors']);\r
28         $_POST['ec_email_admin']       = intval($_POST['ec_email_admin']);\r
29         $_POST['ec_email_admin']       = intval($_POST['ec_email_admin']);\r
30         $_POST['ec_log_file']       = $addslashes($_POST['ec_log_file']);\r
31         $_POST['ec_store_log']       = intval($_POST['ec_store_log']);\r
32 \r
33 \r
34         if (!$_POST['ec_uri']){\r
35                 $msg->addError('EC_URL_EMPTY');\r
36         }\r
37         if (!$_POST['ec_vendor_id']){\r
38                 $msg->addError('EC_ID_EMPTY');\r
39         }\r
40         //if (!$_POST['ec_password']){\r
41                 //$msg->addError('EC_PASSWORD_EMPTY');\r
42         //}             \r
43         if (!$msg->containsErrors()) {\r
44                 $_POST['ec_gateway'] = $addslashes($_POST['ec_gateway']);\r
45                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_gateway', '$_POST[ec_gateway]')";\r
46                 mysql_query($sql, $db);\r
47 \r
48                 $_POST['ec_uri'] = $addslashes($_POST['ec_uri']);\r
49                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_uri', '$_POST[ec_uri]')";\r
50                 mysql_query($sql, $db);\r
51 \r
52                 $_POST['ec_vendor_id'] = $addslashes($_POST['ec_vendor_id']);\r
53                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_vendor_id', '$_POST[ec_vendor_id]')";\r
54                 mysql_query($sql, $db);\r
55 \r
56                 $_POST['ec_password'] = $addslashes($_POST['ec_password']);\r
57                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_password', '$_POST[ec_password]')";\r
58                 mysql_query($sql, $db);\r
59 \r
60                 $_POST['ec_currency'] = $addslashes($_POST['ec_currency']);\r
61                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency', '$_POST[ec_currency]')";\r
62                 mysql_query($sql, $db);\r
63 \r
64                 $_POST['ec_currency_other'] = $addslashes($_POST['ec_currency_other']);\r
65                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency_other', '$_POST[ec_currency_other]')";\r
66                 mysql_query($sql, $db);\r
67 \r
68                 if($_POST['ec_currency_other']){\r
69                         $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency', '')";\r
70                         mysql_query($sql, $db);\r
71                 }\r
72 \r
73                 $_POST['ec_currency_symbol'] = $_POST['ec_currency_symbol'];\r
74                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency_symbol', '$_POST[ec_currency_symbol]')";\r
75                 mysql_query($sql, $db);\r
76 \r
77                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_allow_instructors', '{$_POST['ec_allow_instructors']}')";\r
78                 mysql_query($sql, $db);\r
79 \r
80                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_email_admin', '{$_POST['ec_email_admin']}')";\r
81                 mysql_query($sql, $db);\r
82 \r
83                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_store_log', '{$_POST['ec_store_log']}')";\r
84                 mysql_query($sql, $db);\r
85 \r
86                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_log_file', '{$_POST['ec_log_file']}')";\r
87                 mysql_query($sql, $db);\r
88 \r
89                 $_POST['ec_contact_email'] = $addslashes($_POST['ec_contact_email']);\r
90                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_contact_email', '$_POST[ec_contact_email]')";\r
91                 mysql_query($sql, $db);\r
92 \r
93                 $_POST['ec_contact_address'] = $addslashes($_POST['ec_contact_address']);\r
94                 $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_contact_address', '$_POST[ec_contact_address]')";\r
95                 mysql_query($sql, $db);\r
96 \r
97                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');\r
98 \r
99                 header('Location: '.$_SERVER['PHP_SELF']);\r
100                 exit;\r
101         }\r
102 }\r
103 \r
104 $_config['ec_allow_instructors'] = isset($_config['ec_allow_instructors']) ? $_config['ec_allow_instructors'] : 0;\r
105 $_config['ec_email_admin']       = isset($_config['ec_email_admin'])       ? $_config['ec_email_admin']       : 0;\r
106 $_config['ec_uri']               = isset($_config['ec_uri'])               ? $_config['ec_uri']               : '';\r
107 $_config['ec_currency']          = isset($_config['ec_currency'])          ? $_config['ec_currency']          : 'USD';\r
108 $_config['ec_currency_symbol']   = isset($_config['ec_currency_symbol'])   ? $_config['ec_currency_symbol']   : '$';\r
109 \r
110 require (AT_INCLUDE_PATH.'header.inc.php');\r
111 \r
112 ?>\r
113 \r
114 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">\r
115         <div class="input-form">\r
116 \r
117                 <div class="row">\r
118                         <p><?php echo _AT('ec_location_text'); ?></p>\r
119                 </div>\r
120                 <div class="row">\r
121                         <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="uri"><?php echo _AT('ec_gateway'); ?></label><br/>\r
122                         <select name="ec_gateway">\r
123                                 <option value="BeanStream"<?php if($_config['ec_gateway']  == "BeanStream"){ echo ' selected="selected"';} ?>>BeanStream</option>\r
124                                 <option value="PayPal" <?php if($_config['ec_gateway']  == "PayPal"){ echo ' selected="selected"';} ?>>PayPal</option>\r
125                                 <option value="MiraPay"<?php if($_config['ec_gateway']  == "MiraPay"){ echo ' selected="selected"';} ?>>MiraPay</option>\r
126                         </select>\r
127                 </div>\r
128 \r
129                 <div class="row">\r
130                         <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="uri"><?php echo _AT('ec_location'); ?></label><br/>\r
131                         <input type="text" name="ec_uri" value="<?php echo htmlspecialchars($_config['ec_uri']); ?>" id="uri" size="80"  />\r
132                 </div>\r
133                 <div class="row">\r
134                         <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="ec_vendor_id"><?php echo _AT('ec_vendor_id'); ?></label><br/>\r
135                         <input type="text" name="ec_vendor_id" value="<?php echo htmlspecialchars($_config['ec_vendor_id']); ?>" id="ec_vendor_id" size="40"/>\r
136                 </div>\r
137                 <div class="row">\r
138                         <label for="ec_password"><?php echo _AT('ec_password'); ?></label><br/>\r
139                                 <input type="password" name="ec_password" value="<?php echo htmlspecialchars($_config['ec_password']); ?>" id="ec_password" size="20" />\r
140                 </div>\r
141                 <div class="row">\r
142                         <?php echo _AT('ec_currency'); ?><br/>\r
143                         <input type="radio" name="ec_currency" value="USD" id="currusd" <?php if ($_config['ec_currency'] == 'USD') { echo 'checked="checked"'; } ?>><label for="currusd">USD</label>\r
144                         <input type="radio" name="ec_currency" value="CAD" id="currcad" <?php if ($_config['ec_currency'] == 'CAD') { echo 'checked="checked"'; } ?>><label for="currcad">CAD</label>\r
145                         <input type="radio" name="ec_currency" value="EUR" id="curreur" <?php if ($_config['ec_currency'] == 'EUR') { echo 'checked="checked"'; } ?>><label for="curreur">EUR</label>&nbsp;&nbsp;\r
146 \r
147                         <?php echo _AT('or'); ?>\r
148 \r
149                         <label for="ec_currency_other"><?php echo _AT('ec_currency_other'); ?></label>\r
150                         <input type="text" name="ec_currency_other" size="3" value="<?php echo $_config['ec_currency_other']; ?>" id="ec_currency_other" size="3" />\r
151                 </div>\r
152                 <div class="row">\r
153                         <label for="ec_currency_symbol"><?php echo _AT('ec_currency_symbol'); ?></label><br/>\r
154                         <input type="text" name="ec_currency_symbol" size="3" value="<?php echo $_config['ec_currency_symbol']; ?>" id="ec_currency_symbol" size="3" />\r
155                 </div>\r
156                 <div class="row">\r
157                         <label for="ec_contact_email"><?php echo _AT('ec_contact_email'); ?></label><br/>\r
158                         <input type="text" name="ec_contact_email" size="50" value="<?php echo htmlspecialchars($_config['ec_contact_email']); ?>" id="ec_contact_email" size="20" />\r
159                 </div>\r
160 \r
161                 <div class="row">\r
162                         <label for="ec_contact_address"><?php echo _AT('ec_contact_address'); ?></label><br/>\r
163                         <textarea  name="ec_contact_address" id="ec_contact_address"  cols="20" rows="5" class="input"/><?php echo htmlspecialchars($_config['ec_contact_address']); ?></textarea>\r
164                 </div>\r
165 \r
166                 <div class="row">\r
167                         <?php echo _AT('ec_allow_instructors'); ?><br/>\r
168                         <input type="radio" name="ec_allow_instructors" value="1" id="allow1" <?php if ($_config['ec_allow_instructors']){ echo 'checked="checked"'; } ?>/><label for="allow1"><?php echo _AT('enable'); ?></label>\r
169 \r
170                         <input type="radio" name="ec_allow_instructors" value="0" id="allow0" <?php if (!$_config['ec_allow_instructors']){ echo 'checked="checked"'; } ?>/><label for="allow0"><?php echo _AT('disable'); ?></label>\r
171                 </div> \r
172                 <div class="row">\r
173                         <?php echo _AT('ec_email_admin'); ?><br/>\r
174                         <input type="radio" name="ec_email_admin" value="1" id="email1" <?php if ($_config['ec_email_admin']){ echo 'checked="checked"'; } ?>/><label for="email1"><?php echo _AT('enable'); ?></label>\r
175 \r
176                         <input type="radio" name="ec_email_admin" value="0" id="email0" <?php if (!$_config['ec_email_admin']){ echo 'checked="checked"'; } ?>/><label for="email0"><?php echo _AT('disable'); ?></label>\r
177                 </div>\r
178                 <div class="row">\r
179                         <?php echo _AT('ec_store_log'); ?><br/>\r
180                         <input type="radio" name="ec_store_log" value="1" id="ipn1" <?php if ($_config['ec_store_log']){ echo 'checked="checked"'; } ?>/><label for="ipn1"><?php echo _AT('enable'); ?></label>\r
181 \r
182                         <input type="radio" name="ec_store_log" value="0" id="ipn0" <?php if (!$_config['ec_store_log']){ echo 'checked="checked"'; } ?>/><label for="ipn0"><?php echo _AT('disable'); ?></label>\r
183                 </div> \r
184                 <div class="row">\r
185                         <label for="ec_log_file"><?php echo _AT('ec_log_file'); ?></label><br/>\r
186                         <input type="text" name="ec_log_file" value="<?php echo htmlspecialchars($_config['ec_log_file']); ?>" id="ec_log_file" size="60"/>\r
187                 </div>\r
188                 <div class="row buttons">\r
189                         <input type="submit" name="submit" value="<?php echo _AT('save'); ?>"  class="button" accesskey="s" />\r
190                         <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>"  class="button" />\r
191                 </div>\r
192         </div>\r
193 </form>\r
194 \r
195 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>