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

Revision 2816, 10.4 kB (checked in by diego_iastrubni, 7 years ago)

updated modules to reflect the new change in policy. i did not bump up the versions, since the modules should still work, i will let the developers of each module nump up versions on their free time, in order to reduce the updates sent to the users.

  • 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 require_once 'common/php-asmanager.php';
38
39 extract($_REQUEST);
40
41 $dispnum='customerdb';
42
43 if(!isset($action))
44   $action='';
45 switch($action) {
46   case "add":
47     customerdb_add($name, $addr1, $addr2, $city, $state, $zip, $sip, $did, $device, $ip, $serial, $account, $email, $username, $password);
48     $name='';
49     $addr1='';
50     $addr2='';
51     $city='';
52     $state='';
53     $zip='';
54     $sip='';
55     $did='';
56     $ip='';
57     $serial='';
58     $account='';
59     $email='';
60     $device='';
61     $username='';
62     $password='';
63     //needreload();
64     //right now... not writing config files... don't need to reload
65   break;
66   case "del":
67     customerdb_del($extdisplay);
68     //needreload();
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   break;
74  
75 }
76 ?>
77 </div>
78 <div class="rnav">
79 <?php
80 $customers=customerdb_list();
81 drawListMenu($customers, $skip, $type, $dispnum, $extdisplay, _("Customer"));
82 ?>
83 </div>
84
85
86 <div class="content">
87 <?php
88 if($action=='del'){
89   echo "<br><h3>ID ".$extdisplay." "._("deleted")."!</h3><br><Br><br><br><br><br><br>";
90 }
91 else if(!isset($extdisplay)) {
92
93    
94   echo "<h2>Add a user</h2>";
95 //  echo "<li><a href=\"".$_SERVER['PHP_SELF']."?$action=add\";>Add</a><br>";
96
97 }
98 else {
99   $delURL = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&action=del&extdisplay=$extdisplay";
100
101   //If we have some data, load it up... this means we are editing.
102   if($extdisplay!=""){
103     $customerInfo=customerdb_get($extdisplay);
104     $name=$customerInfo['name'];
105     $addr1=$customerInfo['addr1'];
106     $addr2=$customerInfo['addr2'];
107     $city=$customerInfo['city'];
108     $state=$customerInfo['state'];
109     $zip=$customerInfo['zip'];
110     $sip=$customerInfo['sip'];
111     $did=$customerInfo['did'];
112     $device=$customerInfo['device'];
113     $serial=$customerInfo['serial'];
114     $ip=$customerInfo['ip'];
115     $account=$customerInfo['account'];
116     $email=$customerInfo['email'];
117     $username=$customerInfo['username'];
118     $password=$customerInfo['password'];
119   }
120    
121  
122   if(isset($customerInfo) && is_array($customerInfo)){
123     $action="edit";
124     echo "<h2> ".$extdisplay." ".$name."</h2>";
125     echo "<p><a href=\"".$delURL."\">Delete Customer</a></p>";
126   }
127   else {
128     echo "<h2>Add Customer</h2>";
129   }
130
131 }
132
133 echo "<form name=\"addNew\" action=\"".$_SERVER['PHP_SELF']."\" method=\"post\" onsubmit=\"return addNew_onsubmit();\">";
134 echo "<input type=hidden name=type value='tool'>\n";
135 echo "<input type=hidden name=extdisplay value=$extdisplay>\n";
136 echo "<input type=hidden name=action value=\"";
137 echo ($action=="" ? "add" : $action);
138 echo "\">\n";
139 echo "<input type=hidden name=display value=\"customerdb\">";
140
141 echo "<table>";
142  
143 echo "<tr><td colspan=2><h5>";
144 echo ($extdisplay ? _('Edit Customer') : _('Add Customer'));
145 echo "</h5></td></tr>\n";
146
147 //Name
148 echo "<tr ";
149 echo ($extdisplay ? '' : '');
150 echo "><td>";
151 echo "<a href=\"#\" class=\"info\">Name\n";
152 echo "<span>Name of business or person (REQUIRED)</span></a>\n";
153 echo "</td>";
154 echo "<td>";
155 echo "<input type=text name=\"name\" value=\"$name\">\n";
156 echo "</td></tr>\n";
157
158 //Address Line 1
159 echo "<tr><td>\n";
160 echo "<a href=\"#\" class=\"info\">Address 1\n";
161 echo "<span>Address Line 1 (REQUIRED)</span></a>\n";
162 echo "</td><td>\n";
163 echo "<input type=text name=\"addr1\" value=\"$addr1\"\n";
164 echo "</td></tr>\n";
165
166 //Address Line 2
167 echo "<tr><td>\n";
168 echo "<a href=\"#\" class=\"info\">Address 2\n";
169 echo "<span>Address Line 2</span></a>\n";
170 echo "</td><td>\n";
171 echo "<input type=text name=\"addr2\" value=\"$addr2\">\n";
172 echo "</td><tr>\n";
173
174 //City
175 echo "<tr><td>\n";
176 echo "<a href=\"#\" class=\"info\">City\n";
177 echo "<span>City (REQUIRED)</span></a>\n";
178 echo "</td><td>\n";
179 echo "<input type=text name=\"city\" value=\"$city\">\n";
180 echo "</td></tr>\n";
181
182 //State
183 echo "<tr><td>\n";
184 echo "<a href=\"#\" class=\"info\">State\n";
185 echo "<span>State (REQUIRED)</span></a>\n";
186 echo "</td><td>\n";
187 $state=($extdisplay ? $state : "LA");
188 $states = array('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');
189 echo "&nbsp;&nbsp;<select name=\"state\">\n";
190 foreach ($states as $s){
191   echo "<option value=\"$s\"";
192   if($state==$s) echo " SELECTED";
193   echo ">$s</option>\n";
194 }
195 echo "</select>\n";
196 echo "</td></tr>\n";
197
198 //Zip
199 echo "<tr><td>\n";
200 echo "<a href=\"#\" class=\"info\">Zip/Post Code\n";
201 echo "<span>Zip (REQUIRED)</span></a>\n";
202 echo "</td><td>\n";
203 echo "<input type=text name=\"zip\" value=\"$zip\">\n";
204 echo "</td></tr>\n";
205
206 //Sip
207 echo "<tr><td align=left>\n";
208 echo "<input type=radio checked name=\"sipbtn\" onclick=\"switchit_sip();return true;\"><a
209 href=\"#\" class=\"info\">Sip Account\n";
210 echo "<span>Sip Account <font size=-1>(must have this or a did tied to the account)</font></span></a>\n";
211 echo "</td><td>\n";
212 $sips=customerdb_getsip();
213 echo "&nbsp;&nbsp;<select name=\"sip\" onchange=\"switchit_sip(); return true;\">\n";
214 echo "<option value=\"\">";
215 foreach ($sips as $sipid){
216   echo "<option value=\"$sipid[0]\"";
217   if($sip==$sipid[0]) echo " SELECTED";
218   echo ">$sipid[0]</option>\n";
219 }
220 echo "</select>\n";
221 echo "</td></tr>\n";
222
223 //Did
224 echo "<tr><td>\n";
225 echo "<input type=radio name=\"didbtn\" onclick=\"switchit_did();return true;\"><a href=\"#\" class=\"info\">DID
226 Number\n";
227 echo "<span>DID Number <font size=-1>(must have this or sip tied to the account)</font></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 <font size=-1>(example... Linksys PAP-2, Sipura)</font></span></a>\n";
244 echo "</td><td>\n";
245 echo "<input type=text name=\"device\" value=\"$device\">\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\">\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 </font></span></a>\n";
260 echo "</td><td>\n";
261 echo "<input type=text name=\"ip\" value=\"$ip\">\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\">\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\">\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\">\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\">\n";
294 echo "</td></tr>\n";
295
296 ?>
297 <tr><td></td><td><input type=submit Value="Submit Changes"></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   if(isEmpty(cform.name.value)){
323     return warnInvalid(cform.name, "Please enter a name for this customer");
324   }
325   if(isEmpty(cform.addr1.value)){
326     return warnInvalid(cform.addr1, "Please enter an address for this customer");
327   }
328   if(isEmpty(cform.city.value)){
329     return warnInvalid(cform.city, "Pleast enter a city for this customer");
330   }
331   if(isEmpty(cform.zip.value)){
332     return warnInvalid(cform.zip, "Please enter a zip for this customer");
333   }
334   if(cform.sip.selectedIndex==0 && cform.did.selectedIndex==0){
335     return warnInvalid(cform.sipbtn, "You must choose either a sip or did number for this customer.");
336   }
337 }
338
339 function switchit_sip() {
340   cform.sipbtn.checked=true;
341   cform.didbtn.checked=false;
342   cform.did[0].selected=true;
343 }
344
345 function switchit_did() {
346   cform.sipbtn.checked=false;
347   cform.didbtn.checked=true;
348   cform.sip[0].selected=true;
349 }
350
351 </script>
352
353
354
355 </form>
Note: See TracBrowser for help on using the browser.