function print_form($post_data, $errors) { $firstname = $_POST['firstname'] != '' ? $_POST['firstname'] : ''; $callerid = $_POST['callerid'] != '' ? $_POST['callerid'] : ''; $amount = $_POST['amount'] != '' ? $_POST['amount'] : '0'; $location = $_POST['location'] != '' ? $_POST['location'] : ''; ?> <div id="stylized" class="myform"> <form id="form" name="form" method="post" action="provisioning.php"> <h1><?php echo _("Provision a new subscriber"); ?> </h1><br/> <?php // get imsi $imsi = shell_exec("/var/rhizomatica/bin/get_imsi.py"); if (isset($imsi) && strlen($imsi) == 16) { echo " Got IMSI: {$imsi}"; } else { echo " Error getting IMSI please retry"; } $sub = new Subscriber(); try { $ext = $sub->get_extension($imsi); } catch (SubscriberException $e) { echo " Error getting Subscriber extension"; } try { $loc = new Configuration(); $locations = $loc->getLocations(); } catch (ConfigurationException $e) { echo " Error getting locations"; } ?> <br/> <span style='color: red; font-size: 12px;'><?php echo $errors; ?> </span><br/> <label><?php echo _("Name"); ?> <span class="small"><?php echo _("Subscriber Name"); ?> </span> </label> <input type="text" name="firstname" id="firstname" value="<?php echo $firstname; ?> "/> <label><?php echo _("Subscriber number"); ?> <span class="small"><?php echo _("Subscriber number"); ?> </span> </label> <input type="text" name="callerid" id="callerid" value="<?php echo $ext; ?> "/> <?php if (count($locations) > 1) { ?> <label><?php echo _("Location"); ?> <span class="small"><?php echo _("Subscriber location"); ?> </span> </label> <?php echo "<select name='location' id='location'>"; foreach ($locations as $rloc) { echo "<option value='" . $rloc->name . "'>" . $rloc->name . "</option>"; } echo "</select>"; } ?> <br/> <button type="submit" name="add_subscriber"><?php echo _("Add"); ?> </button> <div class="spacer"></div> </form> </div> <?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; } 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><?php echo _("Edit Subscriber"); ?> </h1><br/> <input type="hidden" name="sip_id" value="<?php echo $msisdn; ?> " /> <span style='color: red; font-size: 12px;'><?php echo $errors; ?> </span><br/> <label><?php echo _("Name"); ?> <span class="small"><?php echo _("Subscriber Name"); ?> </span> </label> <input type="text" name="firstname" id="firstname" value="<?php echo $name; ?> "/> <label><?php echo _("Subscriber number"); ?> <span class="small"><?php echo _("Subscriber number"); ?> </span> </label> <input type="text" name="callerid" id="callerid" value="<?php echo $callerid; ?> "/> <?php if (count($locations) > 1) { ?> <label><?php echo _("Location"); ?> <span class="small"><?php echo _("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><?php echo _("Subscription Paid"); ?> <span class="small"><?php echo _("Check for yes uncheck for no"); ?> </span> </label><br/><br/> <?php $checked = $sub->subscription_status == 0 ? '' : 'checked=checked'; ?> <input type="checkbox" name="subscription_status" id="subscription_status" value="1" <?php echo $checked; ?> /><br/> <label><?php echo _("Authorized"); ?> <span class="small"><?php echo _("Check for yes uncheck for no"); ?> </span> </label> <?php $checked = $sub->authorized == 0 ? '' : 'checked=checked'; ?> <input type="checkbox" name="authorized" id="authorized" value="1" <?php echo $checked; ?> /><br/> <button type="submit" name="edit_subscriber"><?php echo _("Save"); ?> </button> <div class="spacer"></div> </form> </div> <?php }