root/modules/branches/2.5/customerdb/page.customerdb.php

Revision 6872, 11.3 kB (checked in by mickecarlsson, 5 years ago)

Enclosed text strings in customerdb for localizaton, added Swedish language

  • Property svn:mime-type set to text/plain
  • Property svn:eol-style set to native
Line 
1 <?php
2 //CustomerDB 1.00 written by Keith Dowell 2006-04-07
3 //Copyright (C) 2006 Keith Dowell (snowolfex@yahoo.com)
4 //
5 //This program is free software; you can redistribute it and/or
6 //modify it under the terms of the GNU General Public License
7 //as published by the Free Software Foundation; either version 2
8 //of the License, or (at your option) any later version.
9 //
10 //This program is distributed in the hope that it will be useful,
11 //but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //GNU General Public License for more details.
14
15 //Set all the vars so there arent a ton of errors in the httpd error_log
16
17 $display = isset($_REQUEST['display'])?$_REQUEST['display']:'customerdb';
18 $type = isset($_REQUEST['type'])?$_REQUEST['type']:'tool';
19
20 $action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
21 $name = isset($_REQUEST['name'])?$_REQUEST['name']:'';
22 $addr1 = isset($_REQUEST['addr1'])?$_REQUEST['addr1']:'';
23 $addr2 = isset($_REQUEST['addr2'])?$_REQUEST['addr2']:'';
24 $city = isset($_REQUEST['city'])?$_REQUEST['city']:'';
25 $state = isset($_REQUEST['state'])?$_REQUEST['state']:'LA';
26 $zip = isset($_REQUEST['zip'])?$_REQUEST['zip']:'';
27 $sip = isset($_REQUEST['sip'])?$_REQUEST['sip']:'';
28 $did = isset($_REQUEST['did'])?$_REQUEST['did']:'';
29 $device = isset($_REQUEST['device'])?$_REQUEST['device']:'';
30 $ip = isset($_REQUEST['ip'])?$_REQUEST['ip']:'';
31 $serial = isset($_REQUEST['serial'])?$_REQUEST['serial']:'';
32 $account = isset($_REQUEST['account'])?$_REQUEST['account']:'';
33 $email = isset($_REQUEST['email'])?$_REQUEST['email']:'';
34 $username = isset($_REQUEST['username'])?$_REQUEST['username']:'';
35 $password = isset($_REQUEST['password'])?$_REQUEST['password']:'';
36
37 extract($_REQUEST);
38
39 $dispnum='customerdb';
40
41 if(!isset($action))
42   $action='';
43 switch($action) {
44   case "add":
45     customerdb_add($name, $addr1, $addr2, $city, $state, $zip, $sip, $did, $device, $ip, $serial, $account, $email, $username, $password);
46     $name='';
47     $addr1='';
48     $addr2='';
49     $city='';
50     $state='';
51     $zip='';
52     $sip='';
53     $did='';
54     $ip='';
55     $serial='';
56     $account='';
57     $email='';
58     $device='';
59     $username='';
60     $password='';
61     //needreload();
62     //right now... not writing config files... don't need to reload
63     redirect_standard();
64   break;
65   case "del":
66     customerdb_del($extdisplay);
67     //needreload();
68     redirect_standard();
69   break;
70   case "edit":
71     customerdb_edit($extdisplay, $name, $addr1, $addr2, $city, $state, $zip, $sip, $did, $device, $ip, $serial, $account, $email, $username, $password);
72     //needreload();
73     redirect_standard('extdisplay');
74   break;
75  
76 }
77 ?>
78 </div>
79 <div class="rnav">
80 <?php
81 $customers=customerdb_list();
82 drawListMenu($customers, $skip, $type, $dispnum, $extdisplay, _("Customer"));
83 ?>
84 </div>
85
86
87 <div class="content">
88 <?php
89 if($action=='del'){
90   echo "<br><h3>ID ".$extdisplay." "._("deleted")."!</h3><br><Br><br><br><br><br><br>";
91 }
92 else if(!isset($extdisplay)) {
93
94    
95   echo "<h2>"._("Add a user")."</h2>";
96 //  echo "<li><a href=\"".$_SERVER['PHP_SELF']."?$action=add\";>Add</a><br>";
97
98 }
99 else {
100   $delURL = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&action=del&extdisplay=$extdisplay";
101
102   //If we have some data, load it up... this means we are editing.
103   if($extdisplay!=""){
104     $customerInfo=customerdb_get($extdisplay);
105     $name=$customerInfo['name'];
106     $addr1=$customerInfo['addr1'];
107     $addr2=$customerInfo['addr2'];
108     $city=$customerInfo['city'];
109     $state=$customerInfo['state'];
110     $zip=$customerInfo['zip'];
111     $sip=$customerInfo['sip'];
112     $did=$customerInfo['did'];
113     $device=$customerInfo['device'];
114     $serial=$customerInfo['serial'];
115     $ip=$customerInfo['ip'];
116     $account=$customerInfo['account'];
117     $email=$customerInfo['email'];
118     $username=$customerInfo['username'];
119     $password=$customerInfo['password'];
120   }
121    
122  
123   if(isset($customerInfo) && is_array($customerInfo)){
124     $action="edit";
125     echo "<h2> ".$extdisplay." ".$name."</h2>";
126     echo "<p><a href=\"".$delURL."\">"._("Delete Customer")."</a></p>";
127   }
128   else {
129     echo "<h2>"._("Add Customer")."</h2>";
130   }
131
132 }
133
134 echo "<form name=\"addNew\" action=\"".$_SERVER['PHP_SELF']."\" method=\"post\" onsubmit=\"return addNew_onsubmit();\">";
135 echo "<input type=hidden name=type value='tool'>\n";
136 echo "<input type=hidden name=extdisplay value=$extdisplay>\n";
137 echo "<input type=hidden name=action value=\"";
138 echo ($action=="" ? "add" : $action);
139 echo "\">\n";
140 echo "<input type=hidden name=display value=\"customerdb\">";
141
142 echo "<table>";
143  
144 echo "<tr><td colspan=2><h5>";
145 echo ($extdisplay ? _('Edit Customer') : _('Add Customer'));
146 echo "</h5></td></tr>\n";
147
148 //Name
149 echo "<tr ";
150 echo ($extdisplay ? '' : '');
151 echo "><td>";
152 echo "<a href=\"#\" class=\"info\" >"._("Name")."\n";
153 echo "<span>"._("Name of business or person (REQUIRED)")."</span></a>\n";
154 echo "</td>";
155 echo "<td>";
156 echo "<input type=text name=\"name\" value=\"$name\" tabindex=".++$tabindex.">\n";
157 echo "</td></tr>\n";
158
159 //Address Line 1
160 echo "<tr><td>\n";
161 echo "<a href=\"#\" class=\"info\">"._("Address 1")."\n";
162 echo "<span>"._("Address Line 1 (REQUIRED)")."</span></a>\n";
163 echo "</td><td>\n";
164 echo "<input type=text tabindex=".++$tabindex." name=\"addr1\" value=\"$addr1\"\n";
165 echo "</td></tr>\n";
166
167 //Address Line 2
168 echo "<tr><td>\n";
169 echo "<a href=\"#\" class=\"info\">"._("Address 2")."\n";
170 echo "<span>"._("Address Line 2")."</span></a>\n";
171 echo "</td><td>\n";
172 echo "<input type=text tabindex=".++$tabindex." name=\"addr2\" value=\"$addr2\">\n";
173 echo "</td><tr>\n";
174
175 //City
176 echo "<tr><td>\n";
177 echo "<a href=\"#\" class=\"info\">"._("City")."\n";
178 echo "<span>"._("City (REQUIRED)")."</span></a>\n";
179 echo "</td><td>\n";
180 echo "<input type=text name=\"city\" value=\"$city\" tabindex=".++$tabindex.">\n";
181 echo "</td></tr>\n";
182
183 //State
184 echo "<tr><td>\n";
185 echo "<a href=\"#\" class=\"info\">"._("State")."\n";
186 echo "<span>"._("State (REQUIRED)")."</span></a>\n";
187 echo "</td><td>\n";
188 $state=($extdisplay ? $state : "N/A");
189 $states = array('N/A','AL', 'AK', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA','MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WV', 'WI', 'WY', 'TAS', 'VIC', 'NSW', 'ACT', 'QLD', 'NT', 'SA');
190 echo "&nbsp;&nbsp;<select name=\"state\" tabindex=".++$tabindex.">\n";
191 foreach ($states as $s){
192   echo "<option value=\"$s\"";
193   if($state==$s) echo " SELECTED";
194   echo ">$s</option>\n";
195 }
196 echo "</select>\n";
197 echo "</td></tr>\n";
198
199 //Zip
200 echo "<tr><td>\n";
201 echo "<a href=\"#\" class=\"info\">"._("Zip/Post Code")."\n";
202 echo "<span>"._("Zip (REQUIRED)")."</span></a>\n";
203 echo "</td><td>\n";
204 echo "<input type=text name=\"zip\" value=\"$zip\" tabindex=".++$tabindex.">\n";
205 echo "</td></tr>\n";
206
207 //Sip
208 echo "<tr><td align=left>\n";
209 echo "<input type=radio checked name=\"sipbtn\" onclick=\"switchit_sip();return true;\" tabindex=".++$tabindex."><a
210 href=\"#\" class=\"info\">"._("Sip Account")."\n";
211 echo "<span>"._("Sip Account (must have this or a DID tied to the account)")."</span></a>\n";
212 echo "</td><td>\n";
213 $sips=customerdb_getsip();
214 echo "&nbsp;&nbsp;<select name=\"sip\" onchange=\"switchit_sip(); return true;\">\n";
215 echo "<option value=\"\">";
216 foreach ($sips as $sipid){
217   echo "<option value=\"$sipid[0]\"";
218   if($sip==$sipid[0]) echo " SELECTED";
219   echo ">$sipid[0]</option>\n";
220 }
221 echo "</select>\n";
222 echo "</td></tr>\n";
223
224 //Did
225 echo "<tr><td>\n";
226 echo "<input type=radio name=\"didbtn\" onclick=\"switchit_did();return true;\"><a href=\"#\" class=\"info\">"._("DID Number")."\n";
227 echo "<span>"._("DID Number (must have this or sip tied to the account)")."</span></a>\n";
228 echo "</td><td>\n";
229 $dids=customerdb_getdid();
230 echo "&nbsp;&nbsp;<select name=\"did\" onchange=\"switchit_did(); return true;\">\n";
231 echo "<option value=\"\">";
232 foreach ($dids as $didnum){
233   echo "<option value=\"$didnum[0]\"";
234   if($did==$didnum[0]) echo " SELECTED";
235   echo ">$didnum[0]</option>\n";
236 }
237 echo "</select>\n";
238 echo "</td></tr>\n";
239
240 //Device
241 echo "<tr><td>\n";
242 echo "<a href=\"#\" class=\"info\">"._("Device")."\n";
243 echo "<span>"._("Device (example... Linksys PAP-2, Sipura)")."</span></a>\n";
244 echo "</td><td>\n";
245 echo "<input type=text name=\"device\" value=\"$device\" tabindex=".++$tabindex.">\n";
246 echo "</td></tr>\n";
247
248 //Serial
249 echo "<tr><td>\n";
250 echo "<a href=\"#\" class=\"info\">"._("Serial")."\n";
251 echo "<span>"._("Serial Number")."</span></a>\n";
252 echo "</td><td>\n";
253 echo "<input name=\"serial\" value=\"$serial\" tabindex=".++$tabindex.">\n";
254 echo "</td></tr>\n";
255
256 //IP
257 echo "<tr><td>\n";
258 echo "<a href=\"#\" class=\"info\">"._("IP Address")."\n";
259 echo "<span>"._("IP Address")."</span></a>\n";
260 echo "</td><td>\n";
261 echo "<input type=text name=\"ip\" value=\"$ip\" tabindex=".++$tabindex.">\n";
262 echo "</td></tr>\n";
263
264 //Account
265 echo "<tr><td>\n";
266 echo "<a href=\"#\" class=\"info\">"._("Account")."\n";
267 echo "<span>"._("Account Number (internal use)")."</span></a>\n";
268 echo "</td><td>\n";
269 echo "<input name=\"account\" value=\"$account\" tabindex=".++$tabindex.">\n";
270 echo "</td></tr>\n";
271
272 //Email
273 echo "<tr><td>\n";
274 echo "<a href=\"#\" class=\"info\">"._("Email")."\n";
275 echo "<span>"._("Email Address")."</span></a>\n";
276 echo "</td><td>\n";
277 echo "<input name=\"email\" value=\"$email\" tabindex=".++$tabindex.">\n";
278 echo "</td></tr>\n";
279
280 //Username
281 echo "<tr><td>\n";
282 echo "<a href=\"#\" class=\"info\">"._("Username")."\n";
283 echo "<span>"._("Username for the device")."</span></a>\n";
284 echo "</td><td>\n";
285 echo "<input name=\"username\" value=\"$username\" tabindex=".++$tabindex.">\n";
286 echo "</td></tr>\n";
287
288 //Password
289 echo "<tr><td>\n";
290 echo "<a href=\"#\" class=\"info\">"._("Password")."\n";
291 echo "<span>"._("Password for device")."</span></a>\n";
292 echo "</td><td>\n";
293 echo "<input name=\"password\" value=\"$password\" tabindex=".++$tabindex.">\n";
294 echo "</td></tr>\n";
295
296 ?>
297 <tr><td></td><td><input type=submit Value="Submit Changes" tabindex="<?php echo ++$tabindex;?>"></td></tr></table>
298
299 <script language="javascript">
300 var cform = document.addNew;
301 if(cform.name.value == ""){
302   cform.name.focus();
303 }
304
305 if(cform.did.selectedIndex>0){
306   cform.sipbtn.checked=false;
307   cform.didbtn.checked=true;
308 }
309 else{
310   if(cform.sip.selectedIndex>0){
311     cform.sipbtn.checked=true;
312     cform.didbtn.checked=false;
313   }
314   else{
315     cform.sipbtn.checked=false;
316     cform.didbtn.selected=false;
317   }
318 }
319
320
321 function addNew_onsubmit() {
322
323   var msgInvalidName = "<?php echo _("Please enter a name for this customer");?>";
324   var msgInvalidAddr1 = "<?php echo  _("Please enter an address for this customer");?>";
325   var msgInvalidCity = "<?php echo _("Pleast enter a city for this customer");?>";
326   var msgInvalidZip = "<?php echo _("Please enter a zip for this customer");?>";
327   var msgInvalidSipDid = "<?php echo _("You must choose either a sip or did number for this customer.");?>";
328
329   if(isEmpty(cform.name.value)){
330     return warnInvalid(cform.name, msgInvalidName);
331   }
332   if(isEmpty(cform.addr1.value)){
333     return warnInvalid(cform.addr1, msgInvalidAddr1);
334   }
335   if(isEmpty(cform.city.value)){
336     return warnInvalid(cform.city, msgInvalidCity);
337   }
338   if(isEmpty(cform.zip.value)){
339     return warnInvalid(cform.zip, msgInvalidZip);
340   }
341   if(cform.sip.selectedIndex==0 && cform.did.selectedIndex==0){
342     return warnInvalid(cform.sipbtn, msgInvalidSipDid);
343   }
344 }
345
346 function switchit_sip() {
347   cform.sipbtn.checked=true;
348   cform.didbtn.checked=false;
349   cform.did[0].selected=true;
350 }
351
352 function switchit_did() {
353   cform.sipbtn.checked=false;
354   cform.didbtn.checked=true;
355   cform.sip[0].selected=true;
356 }
357
358 </script>
359
360
361
362 </form>
Note: See TracBrowser for help on using the browser.