-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsubscriber_edit.php
165 lines (138 loc) · 6.05 KB
/
subscriber_edit.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?
require('modules/subscriber.php');
require('modules/configuration.php');
$no_title = 1;
require('include/header.php');
function print_form($post_data,$errors) {
$firstname = ($_POST['firstname'] != '') ? $_POST['firstname'] : '';
$callerid = ($_POST['callerid'] != '') ? $_POST['callerid'] : '';
$sub = new Subscriber();
try {
$msisdn = $_GET['id'];
$sub->get($_GET['id']);
$name = ($_POST['firstname'] != '') ? $_POST['firstname'] : $sub->name;
$callerid = ($_POST['callerid'] != '') ? $_POST['callerid'] : $sub->msisdn;
$location = ($_POST['location'] != '') ? $_POST['location'] : $sub->location;
$equipment = ($_POST['equipment'] != '') ? $_POST['equipment'] : $sub->equipment;
} catch (PDOException $e) {
echo "<img src='img/false.png' width='200' height='170' /><br/><br/>";
echo "<span style='font-size: 20px; color: red;'>"._("ERROR GETTING SUBSCRIBER INFO!").$e->getMessage()." </span><br/><br/><br/><br/>";
echo "<a href='provisioning.php'><button class='b1'>Go Back</button></a>";
}
try {
$loc = new Configuration();
$locations = $loc->getLocations();
} catch (ConfigurationException $e) {
echo " Error getting locations";
}
?>
<br/>
<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="subscriber_edit.php">
<h1><?= _("Edit Subscriber") ?></h1><br/>
<input type="hidden" name="sip_id" value="<?=$msisdn?>" />
<span style='color: red; font-size: 12px;'><?= $errors ?></span><br/>
<label><?= _("Name") ?>
<span class="small"><?= _("Subscriber Name") ?></span>
</label>
<input type="text" name="firstname" id="firstname" value="<?=$name?>"/>
<label><?= _("Subscriber number") ?>
<span class="small"><?= _("Subscriber number") ?></span>
</label>
<input type="text" style="color:grey" name="callerid" id="callerid" value="<?=$callerid?>" readonly/>
<label><?=_("Equipment")?>
<span class="small"><?=_("a short description of the phone and model")?>
</span>
</label>
<input type="text" name="equipment" id="equipment" value="<?=$equipment?>" />
<?php
if (count($locations) > 1) {
?>
<label><?= _("Location") ?>
<span class="small"><?= _("Subscriber location") ?></span>
</label>
<?php
echo "<select name='location' id='location'>";
foreach ($locations as $rloc) {
if ($location == $rloc->name) {
echo "<option value='".$rloc->name."' selected='selected'>".$rloc->name."</option>";
} else {
echo "<option value='".$rloc->name."'>".$rloc->name."</option>";
}
}
echo "</select>";
}
?>
<label><?= _("Subscription Paid") ?>
<span class="small"><?= _("Check for yes uncheck for no") ?></span>
</label><br/><br/>
<? $checked = ($sub->subscription_status == 0) ? '' : 'checked=checked'; ?>
<input type="checkbox" name="subscription_status" id="subscription_status" value="1" <?=$checked?>/><br/>
<label><?= _("Authorized") ?>
<span class="small"><?= _("Check for yes uncheck for no") ?></span>
</label>
<? $checked = ($sub->authorized == 0) ? '' : 'checked=checked'; ?>
<input type="checkbox" name="authorized" id="authorized" value="1" <?=$checked?>/><br/>
<label><?= _("Roaming") ?>
<span class="small"><?= _("Check for yes uncheck for no") ?></span>
</label>
<? $checked = ($sub->roaming == 0) ? '' : 'checked=checked'; ?>
<input type="checkbox" name="roaming" id="roaming" value="1" <?=$checked?>/><br/>
<button type="submit" name="edit_subscriber"><?= _("Save") ?></button>
<div class="spacer"></div>
</form>
</div>
<?
}
$error_txt = "";
// errors check
if (isset($_POST['edit_subscriber'])) {
// form pressed verify if any data is missing
$firstname = $_POST['firstname'];
$callerid = $_POST['callerid'];
$authorized = $_POST['authorized'];
$location = $_POST['location'];
$equipment = $_POST['equipment'];
$roaming = (isset($_POST['roaming'])) ? $_POST['roaming'] : '0';
if ($firstname == "") {
$error_txt .= _("Name is empty")."<br/>";
}
if ($callerid == "" || strlen($callerid) != 11) {
$error_txt .= _("Subscriber number is invalid")."<br/>";
}
}
if (isset($_POST['edit_subscriber']) && $error_txt != "") {
print_form(1,$error_txt);
} elseif (isset($_POST['edit_subscriber']) && $error_txt == "") {
echo "<center>";
$sub = new Subscriber();
try {
#$sub->get($_POST['msisdn']);
if ($_POST['authorized'] == 1) {
$sub->set("",$callerid,$firstname,1,"","","",
$location,$equipment,$roaming);
} else {
$sub->set("",$callerid,$firstname,0,"","","",
$location,$equipment,$roaming);
}
if ($_POST['subscription_status'] == 1) {
$sub->subscription_status = 1;
} else {
$sub->subscription_status = 0;
}
$sub->edit();
echo "<img src='img/true.png' width='200' height='170' /><br/><br/>";
echo "<span style='font-size: 20px;'>"._("Subscriber number").": <b>$callerid</b> "._("successfully modified")."<br/><br/>";
echo "<a href='#' onclick=\"parent.jQuery.fancybox.close()\"><button class='b1'>"._("Close")."</button></a>";
} catch (SubscriberException $e) {
echo "<img src='img/false.png' width='200' height='170' /><br/><br/>";
echo "<span style='font-size: 20px; color: red;'>"._("ERROR SAVING SUBSCRIBER!")." ".$e->getMessage()." </span><br/><br/><br/><br/>";
echo "<a href='#' onclick=\"parent.jQuery.fancybox.close()\"><button class='b1'>"._("Close")."</button></a>";
}
echo "</center>";
} else {
print_form(0,'');
}
?>
</body>
</html>