Add the translation framework to devices and add ability to show which extensions are assigned to a device.

This commit is contained in:
Mark Crane 2013-05-23 08:18:12 +00:00
parent 92e048b405
commit df48067467
4 changed files with 439 additions and 170 deletions

View File

@ -0,0 +1,130 @@
<?php
//Devices
$text['title-devices']['en-us'] = 'Devices';
$text['title-devices']['pt-pt'] = '';
$text['header-devices']['en-us'] = 'Devices';
$text['header-devices']['pt-pt'] = '';
$text['description-devices']['en-us'] = 'Devices are endpoints that register to one or more extensions. They are added to the list manually or automatically when the device requests the provisioning information over HTTP/HTTPS.';
$text['description-devices']['pt-pt'] = '';
$text['header-device']['en-us'] = 'Device';
$text['header-device']['pt-pt'] = '';
$text['description-device']['en-us'] = 'The following information is used to provision endpoints.';
$text['description-device']['pt-pt'] = '';
$text['label-device_mac_address']['en-us'] = 'MAC Address';
$text['label-device_mac_address']['pt-pt'] = '';
$text['description-device_mac_address']['en-us'] = 'Enter the MAC address.';
$text['description-device_mac_address']['pt-pt'] = '';
$text['label-extension']['en-us'] = 'Extensions';
$text['label-extension']['pt-pt'] = '';
$text['description-extension']['en-us'] = 'Assign the extension and line numbers to the device.';
$text['description-extension']['pt-pt'] = '';
$text['label-device_label']['en-us'] = 'Label';
$text['label-device_label']['pt-pt'] = '';
$text['description-device_label']['en-us'] = 'Enter the device label.';
$text['description-device_label']['pt-pt'] = '';
$text['label-device_vendor']['en-us'] = 'Vendor';
$text['label-device_vendor']['pt-pt'] = '';
$text['description-device_vendor']['en-us'] = 'Enter the venodr name.';
$text['description-device_vendor']['pt-pt'] = '';
$text['label-device_model']['en-us'] = 'Model';
$text['label-device_model']['pt-pt'] = '';
$text['description-device_model']['en-us'] = 'Enter the model name or number.';
$text['description-device_model']['pt-pt'] = '';
$text['label-device_firmware_version']['en-us'] = 'Firmware Version';
$text['label-device_firmware_version']['pt-pt'] = '';
$text['description-device_firmware_version']['en-us'] = 'Enter the firmware version.';
$text['description-device_firmware_version']['pt-pt'] = '';
$text['label-device_provision_enable']['en-us'] = 'Enabled';
$text['label-device_provision_enable']['pt-pt'] = '';
$text['description-device_provision_enable']['en-us'] = 'Enable or disable provisioning for this device.';
$text['description-device_provision_enable']['pt-pt'] = '';
$text['label-device_template']['en-us'] = 'Template';
$text['label-device_template']['pt-pt'] = '';
$text['description-device_template']['en-us'] = 'Select a template.';
$text['description-device_template']['pt-pt'] = '';
//$text['label-device_username']['en-us'] = 'Username';
//$text['label-device_username']['pt-pt'] = '';
//$text['description-device_username']['en-us'] = 'Username';
//$text['description-device_username']['pt-pt'] = '';
//$text['label-device_password']['en-us'] = 'Password';
//$text['label-device_password']['pt-pt'] = '';
//$text['description-device_password']['en-us'] = 'Password';
//$text['description-device_password']['pt-pt'] = '';
$text['label-device_time_zone']['en-us'] = 'Time Zone';
$text['label-device_time_zone']['pt-pt'] = '';
$text['description-device_time_zone']['en-us'] = 'Enter the time zone.';
$text['description-device_time_zone']['pt-pt'] = '';
$text['label-device_description']['en-us'] = 'Description';
$text['label-device_description']['pt-pt'] = '';
$text['description-device_description']['en-us'] = 'Enter the description.';
$text['description-device_description']['pt-pt'] = '';
$text['label-true']['en-us'] = 'true';
$text['label-true']['pt-pt'] = '';
$text['label-false']['en-us'] = 'false';
$text['label-false']['pt-pt'] = 'falso';
$text['button-add']['en-us'] = 'Add';
$text['button-add']['pt-pt'] = '';
$text['button-edit']['en-us'] = 'Edit';
$text['button-edit']['pt-pt'] = '';
$text['button-delete']['en-us'] = 'Delete';
$text['button-delete']['pt-pt'] = '';
$text['button-save']['en-us'] = 'Save';
$text['button-save']['pt-pt'] = 'Guardar';
$text['button-view']['en-us'] = 'View';
$text['button-view']['pt-pt'] = '';
$text['button-back']['en-us'] = 'Back';
$text['button-back']['pt-pt'] = 'Voltar';
$text['confirm-delete']['en-us'] = 'Do you really want to delete this?';
$text['confirm-delete']['pt-pt'] = '';
$text['message-add']['en-us'] = 'Add Completed';
$text['message-add']['pt-pt'] = '';
$text['message-update']['en-us'] = 'Update Completed';
$text['message-update']['pt-pt'] = '';
$text['message-delete']['en-us'] = 'Delete Completed';
$text['message-delete']['pt-pt'] = '';
$text['message-required']['en-us'] = 'Please provide: ';
$text['message-required']['pt-pt'] = '';
?>

View File

@ -33,9 +33,16 @@ else {
exit; exit;
} }
if (count($_GET)>0) { //add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//get the id
if (count($_GET)>0) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
} }
//delete the data //delete the data
if (strlen($id)>0) { if (strlen($id)>0) {
@ -54,7 +61,7 @@ if (count($_GET)>0) {
require_once "includes/header.php"; require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=devices.php\">\n"; echo "<meta http-equiv=\"refresh\" content=\"2;url=devices.php\">\n";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "Delete Complete\n"; echo $text['message-delete']."\n";
echo "</div>\n"; echo "</div>\n";
require_once "includes/footer.php"; require_once "includes/footer.php";
return; return;

View File

@ -35,6 +35,12 @@ require_once "includes/require.php";
exit; exit;
} }
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (isset($_REQUEST["id"])) {
$action = "update"; $action = "update";
@ -44,7 +50,7 @@ require_once "includes/require.php";
$action = "add"; $action = "add";
} }
//get the http post values and set them to php variables //get http post variables and set them to php variables
if (count($_POST) > 0) { if (count($_POST) > 0) {
$device_mac_address = check_str($_POST["device_mac_address"]); $device_mac_address = check_str($_POST["device_mac_address"]);
$device_mac_address = strtolower($device_mac_address); $device_mac_address = strtolower($device_mac_address);
@ -104,7 +110,7 @@ require_once "includes/require.php";
} }
//check for all required data //check for all required data
if (strlen($device_mac_address) == 0) { $msg .= "Please provide: MAC Address<br>\n"; } if (strlen($device_mac_address) == 0) { $msg .= $text['message-required'].$text['label-extension']."<br>\n"; }
//if (strlen($device_label) == 0) { $msg .= "Please provide: Label<br>\n"; } //if (strlen($device_label) == 0) { $msg .= "Please provide: Label<br>\n"; }
//if (strlen($device_vendor) == 0) { $msg .= "Please provide: Vendor<br>\n"; } //if (strlen($device_vendor) == 0) { $msg .= "Please provide: Vendor<br>\n"; }
//if (strlen($device_model) == 0) { $msg .= "Please provide: Model<br>\n"; } //if (strlen($device_model) == 0) { $msg .= "Please provide: Model<br>\n"; }
@ -175,7 +181,7 @@ require_once "includes/require.php";
require_once "includes/header.php"; require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=devices.php\">\n"; echo "<meta http-equiv=\"refresh\" content=\"2;url=devices.php\">\n";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "Add Complete\n"; echo $text['message-add']."\n";
echo "</div>\n"; echo "</div>\n";
require_once "includes/footer.php"; require_once "includes/footer.php";
return; return;
@ -207,7 +213,7 @@ require_once "includes/require.php";
require_once "includes/header.php"; require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=devices.php\">\n"; echo "<meta http-equiv=\"refresh\" content=\"2;url=devices.php\">\n";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "Update Complete\n"; echo $text['message-update']."\n";
echo "</div>\n"; echo "</div>\n";
require_once "includes/footer.php"; require_once "includes/footer.php";
return; return;
@ -217,7 +223,7 @@ require_once "includes/require.php";
//pre-populate the form //pre-populate the form
if (count($_GET)>0 && $_POST["persistformvar"] != "true") { if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
$device_uuid = $_GET["id"]; $device_uuid = check_str($_GET["id"]);
$sql = "select * from v_devices "; $sql = "select * from v_devices ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and device_uuid = '$device_uuid' "; $sql .= "and device_uuid = '$device_uuid' ";
@ -241,9 +247,10 @@ require_once "includes/require.php";
unset ($prep_statement); unset ($prep_statement);
} }
//begin the content //show the header
require_once "includes/header.php"; require_once "includes/header.php";
//show the content
echo "<div align='center'>"; echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
echo "<tr class='border'>\n"; echo "<tr class='border'>\n";
@ -253,45 +260,143 @@ require_once "includes/require.php";
echo "<form method='post' name='frm' action=''>\n"; echo "<form method='post' name='frm' action=''>\n";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap'><b>".$text['header-device']."</b></td>\n";
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Device</b></td>\n";
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='devices.php'\" value='Back'></td>\n";
echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='2' align='left'>\n"; echo "<td colspan='2' align='left'>\n";
echo "The following information is used to provision endpoints.<br /><br />\n"; echo $text['description-device']."<br /><br />\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " MAC Address:\n"; echo " ".$text['label-device_mac_address'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_mac_address' maxlength='255' value=\"$device_mac_address\">\n"; echo " <input class='formfld' type='text' name='device_mac_address' maxlength='255' value=\"$device_mac_address\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the MAC address.\n"; echo $text['description-device_mac_address']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Label:\n"; echo " ".$text['label-device_label'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_label' maxlength='255' value=\"$device_label\">\n"; echo " <input class='formfld' type='text' name='device_label' maxlength='255' value=\"$device_label\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the device label.\n"; echo $text['description-device_label']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <table width='52%'>\n";
$sql = "SELECT e.extension, e.description, d.extension_uuid, d.device_uuid, d.device_line \n";
$sql .= "FROM v_device_extensions as d, v_extensions as e \n";
$sql .= "WHERE e.extension_uuid = d.extension_uuid \n";
$sql .= "AND d.device_uuid = '".$device_uuid."' \n";
$sql .= "AND d.domain_uuid = '".$_SESSION['domain_uuid']."' \n";
$sql .= "ORDER BY e.extension asc\n";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
foreach($result as $row) {
echo " <tr>\n";
echo " <td class='vtable'>".$row['extension']."</td>\n";
echo " <td class='vtable'>".$row['device_line']."</td>\n";
echo " <td class='vtable'>".$row['description']."&nbsp;</td>\n";
//echo " <td>\n";
//echo " <a href='extension_edit.php?id=".$extension_uuid."&domain_uuid=".$_SESSION['domain_uuid']."&device_extension_uuid=".$row['device_extension_uuid']."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
//echo " </td>\n";
echo " </tr>\n";
}
echo " </table>\n";
echo " <br />\n";
/*
$sql = "SELECT * FROM v_devices ";
$sql .= "WHERE domain_uuid = '".$domain_uuid."' ";
$sql .= "ORDER BY device_mac_address asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
unset ($prep_statement, $sql);
echo "<select name=\"device_uuid\" id=\"select_mac_address\" class=\"formfld\" style=\"width:37%;\">\n";
echo "<option value=''></option>\n";
foreach($result as $row) {
$device_mac_address = $row['device_mac_address'];
$device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2);
if ($row['device_uuid'] == $device_uuid) {
echo "<option value='".$row['device_uuid']."' selected='selected'>".$device_mac_address." ".$row['device_model']." ".$row['device_description']."</option>\n";
}
else {
echo "<option value='".$row['device_uuid']."'>".$device_mac_address." ".$row['device_model']." ".$row['device_description']."</option>\n";
}
} //end foreach
unset($sql, $result, $row_count);
echo "</select>\n";
echo " <select id='device_line' name='device_line' style='width: 50;' onchange=\"$onchange\" class='formfld'>\n";
echo " <option value=''></option>\n";
echo " <option value='1'>1</option>\n";
echo " <option value='2'>2</option>\n";
echo " <option value='3'>3</option>\n";
echo " <option value='4'>4</option>\n";
echo " <option value='5'>5</option>\n";
echo " <option value='6'>6</option>\n";
echo " <option value='7'>7</option>\n";
echo " <option value='8'>8</option>\n";
echo " <option value='9'>9</option>\n";
echo " <option value='10'>10</option>\n";
echo " <option value='11'>11</option>\n";
echo " <option value='12'>12</option>\n";
echo " <option value='13'>13</option>\n";
echo " <option value='14'>14</option>\n";
echo " <option value='15'>15</option>\n";
echo " <option value='16'>16</option>\n";
echo " <option value='17'>17</option>\n";
echo " <option value='18'>18</option>\n";
echo " <option value='19'>19</option>\n";
echo " <option value='20'>20</option>\n";
echo " <option value='21'>21</option>\n";
echo " <option value='22'>22</option>\n";
echo " <option value='23'>23</option>\n";
echo " <option value='24'>24</option>\n";
echo " <option value='25'>25</option>\n";
echo " <option value='26'>26</option>\n";
echo " <option value='27'>27</option>\n";
echo " <option value='28'>28</option>\n";
echo " <option value='29'>29</option>\n";
echo " <option value='30'>30</option>\n";
echo " <option value='31'>31</option>\n";
echo " <option value='32'>32</option>\n";
echo " <option value='50'>50</option>\n";
echo " <option value='100'>100</option>\n";
echo " <option value='120'>120</option>\n";
echo " <option value='150'>150</option>\n";
echo " </select>\n";
echo " <input type=\"submit\" class='btn' value=\"".$text['button-add']."\">\n";
echo "<br />\n";
echo $text['description-extension']."\n";
*/
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " Template:\n"; echo " ".$text['label-device_template'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo "<select id='device_template' name='device_template' class='formfld'>\n"; echo "<select id='device_template' name='device_template' class='formfld'>\n";
echo "<option value=''></option>\n"; echo "<option value=''></option>\n";
if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$_SESSION["domain_name"])) { if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$_SESSION["domain_name"])) {
@ -327,111 +432,114 @@ require_once "includes/require.php";
} }
echo "</select>\n"; echo "</select>\n";
echo "<br />\n"; echo "<br />\n";
echo "Select a template.\n"; echo $text['description-device_template']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Vendor:\n"; echo " ".$text['label-device_vendor'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_vendor' maxlength='255' value=\"$device_vendor\">\n"; echo " <input class='formfld' type='text' name='device_vendor' maxlength='255' value=\"$device_vendor\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the vendor name.\n"; echo $text['description-device_vendor']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Model:\n"; echo " ".$text['label-device_model'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_model' maxlength='255' value=\"$device_model\">\n"; echo " <input class='formfld' type='text' name='device_model' maxlength='255' value=\"$device_model\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the model number.\n"; echo $text['description-device_model']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Firmware Version:\n"; echo " ".$text['label-device_firmware_version'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_firmware_version' maxlength='255' value=\"$device_firmware_version\">\n"; echo " <input class='formfld' type='text' name='device_firmware_version' maxlength='255' value=\"$device_firmware_version\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the firmware version.\n"; echo $text['description-device_firmware_version']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
/* /*
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Username:\n"; echo " ".$text['label-device_username'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_username' maxlength='255' value=\"$device_username\">\n"; echo " <input class='formfld' type='text' name='device_username' maxlength='255' value=\"$device_username\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the username.\n"; echo $text['description-device_username']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Password:\n"; echo " ".$text['label-device_password'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_password' maxlength='255' value=\"$device_password\">\n"; echo " <input class='formfld' type='text' name='device_password' maxlength='255' value=\"$device_password\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the password.\n"; echo $text['description-device_password']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
*/ */
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Enabled:\n"; echo " ".$text['label-device_provision_enable'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='device_provision_enable'>\n"; echo " <select class='formfld' name='device_provision_enable'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if ($device_provision_enable == "true" || strlen($device_provision_enable) == 0) { if ($device_provision_enable == "true" || strlen($device_provision_enable) == 0) {
echo " <option value='true' selected >true</option>\n"; echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
} }
else { else {
echo " <option value='true'>true</option>\n"; echo " <option value='true'>".$text['label-true']."</option>\n";
} }
if ($device_provision_enable == "false") { if ($device_provision_enable == "false") {
echo " <option value='false' selected >false</option>\n"; echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
} }
else { else {
echo " <option value='false'>false</option>\n"; echo " <option value='false'>".$text['label-false']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo "Enable or disable provisioning for this device.\n"; echo $text['description-device_provision_enable']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Time Zone:\n"; echo " ".$text['label-device_time_zone'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_time_zone' maxlength='255' value=\"$device_time_zone\">\n"; echo " <input class='formfld' type='text' name='device_time_zone' maxlength='255' value=\"$device_time_zone\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the time zone.\n"; echo $text['description-device_time_zone']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Description:\n"; echo " ".$text['label-device_description'].":\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_description' maxlength='255' value=\"$device_description\">\n"; echo " <input class='formfld' type='text' name='device_description' maxlength='255' value=\"$device_description\">\n";
echo "<br />\n"; echo "<br />\n";
echo "Enter the description.\n"; echo $text['description-device_description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo " <tr>\n"; echo " <tr>\n";
@ -439,7 +547,7 @@ require_once "includes/require.php";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='device_uuid' value='$device_uuid'>\n"; echo " <input type='hidden' name='device_uuid' value='$device_uuid'>\n";
} }
echo " <input type='submit' name='submit' class='btn' value='Save'>\n"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";

View File

@ -32,130 +32,154 @@ else {
echo "access denied"; echo "access denied";
exit; exit;
} }
require_once "includes/header.php";
require_once "includes/paging.php";
$order_by = $_GET["order_by"]; //add multi-lingual support
$order = $_GET["order"]; require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
echo "<div align='center'>"; //get variables used to control the order
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n"; $order_by = $_GET["order_by"];
echo "<tr class='border'>\n"; $order = $_GET["order"];
echo " <td align=\"center\">\n";
echo " <br>";
echo "<table width='100%' border='0'>\n"; //additional includes
echo "<tr>\n"; require_once "includes/header.php";
echo "<td width='50%' nowrap='nowrap' align='left'><b>Devices</b></td>\n"; require_once "includes/paging.php";
echo "<td width='50%' align='right'>&nbsp;</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan='2' align='left'>\n";
echo "Devices in this list are added to the list when they contact the provisioning \n"; //show the content
echo "server or added manually by an administrator. \n"; echo "<br />";
echo "Items in this list are assigned from the extensions page.<br /><br />\n"; echo "<div align='center'>";
echo "</td>\n"; echo "<table width='100%' border='0'>\n";
echo "</tr>\n"; echo " <tr>\n";
echo "</tr></table>\n"; echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['header-devices']."</b></td>\n";
echo " <td width='50%' align='right'>&nbsp;</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " ".$text['description-devices']."<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
$sql = "select * from v_devices "; //prepare to page the results
$sql .= "where domain_uuid = '$domain_uuid' "; $sql = "select count(*) as num_rows from v_devices ";
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $sql .= "where domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$prep_statement->execute(); $prep_statement = $db->prepare($sql);
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); if ($prep_statement) {
$num_rows = count($result); $prep_statement->execute();
unset ($prep_statement, $result, $sql); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$rows_per_page = 150; if ($row['num_rows'] > 0) {
$param = ""; $num_rows = $row['num_rows'];
$page = $_GET['page']; }
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } else {
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); $num_rows = '0';
$offset = $rows_per_page * $page; }
}
$sql = "select * from v_devices "; //prepare to page the results
$sql .= "where domain_uuid = '$domain_uuid' "; $rows_per_page = 10;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $param = "";
$sql .= " limit $rows_per_page offset $offset "; $page = $_GET['page'];
$prep_statement = $db->prepare(check_sql($sql)); if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
$prep_statement->execute(); list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $offset = $rows_per_page * $page;
$result_count = count($result);
unset ($prep_statement, $sql);
$c = 0; //get the list
$row_style["0"] = "row_style0"; $sql = "select * from v_devices ";
$row_style["1"] = "row_style1"; $sql .= "where domain_uuid = '$domain_uuid' ";
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
unset ($prep_statement, $sql);
echo "<div align='center'>\n"; $c = 0;
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; $row_style["0"] = "row_style0";
echo "<tr>\n"; $row_style["1"] = "row_style1";
echo th_order_by('device_mac_address', 'MAC Address', $order_by, $order);
echo th_order_by('device_template', 'Template', $order_by, $order);
echo th_order_by('device_vendor', 'Vendor', $order_by, $order);
//echo th_order_by('device_model', 'Model', $order_by, $order);
echo th_order_by('device_provision_enable', 'Enabled', $order_by, $order);
echo th_order_by('device_description', 'Description', $order_by, $order);
echo "<td align='right' width='42'>\n";
if (permission_exists('device_add')) {
echo " <a href='device_edit.php' alt='add'>$v_link_label_add</a>\n";
}
echo "</td>\n";
echo "<tr>\n";
if ($result_count > 0) { //no results echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
//echo th_order_by('device_uuid', $text['label-device_uuid'], $order_by, $order);
echo th_order_by('device_mac_address', $text['label-device_mac_address'], $order_by, $order);
echo th_order_by('device_label', $text['label-device_label'], $order_by, $order);
//echo th_order_by('device_vendor', $text['label-device_vendor'], $order_by, $order);
echo th_order_by('device_model', $text['label-device_model'], $order_by, $order);
//echo th_order_by('device_firmware_version', $text['label-device_firmware_version'], $order_by, $order);
echo th_order_by('device_provision_enable', $text['label-device_provision_enable'], $order_by, $order);
echo th_order_by('device_template', $text['label-device_template'], $order_by, $order);
//echo th_order_by('device_username', $text['label-device_username'], $order_by, $order);
//echo th_order_by('device_password', $text['label-device_password'], $order_by, $order);
//echo th_order_by('device_time_zone', $text['label-device_time_zone'], $order_by, $order);
echo th_order_by('device_description', $text['label-device_description'], $order_by, $order);
echo "<td align='right' width='42'>\n";
if (permission_exists('device_add')) {
echo " <a href='device_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
}
else {
echo " &nbsp;\n";
}
echo "</td>\n";
echo "<tr>\n";
if ($result_count > 0) {
foreach($result as $row) { foreach($result as $row) {
$device_mac_address = $row[device_mac_address]; $device_mac_address = $row[device_mac_address];
$device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2); $device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2);
echo "<tr >\n"; echo "<tr >\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$device_mac_address."&nbsp;</td>\n"; //echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_uuid']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_mac_address']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_label']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_vendor']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_model']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_firmware_version']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_provision_enable']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_template']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_template']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_vendor']."&nbsp;</td>\n"; //echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_username']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_mode'l]."&nbsp;</td>\n"; //echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_password']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."' width='10px'>".$row['device_provision_enable']."&nbsp;</td>\n"; //echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_time_zone']."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['device_description']."&nbsp;</td>\n"; echo " <td valign='top' class='row_stylebg'>".$row['device_description']."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n"; echo " <td valign='top' align='right'>\n";
if (permission_exists('device_edit')) { if (permission_exists('device_edit')) {
echo " <a href='device_edit.php?id=".$row['device_uuid']."' alt='edit'>$v_link_label_edit</a>\n"; echo " <a href='device_edit.php?id=".$row['device_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
} }
if (permission_exists('device_delete')) { if (permission_exists('device_delete')) {
echo " <a href='device_delete.php?id=".$row['device_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n"; echo " <a href='device_delete.php?id=".$row['device_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
} }
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($sql, $result, $row_count);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='7' align='left'>\n"; echo "<td colspan='7' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n"; echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n"; echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n"; echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>\n"; echo " <td width='33.3%' align='right'>\n";
if (permission_exists('device_add')) { if (permission_exists('device_add')) {
echo " <a href='device_edit.php' alt='add'>$v_link_label_add</a>\n"; echo " <a href='device_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
} }
echo " </td>\n"; else {
echo " </tr>\n"; echo " &nbsp;\n";
echo " </table>\n"; }
echo "</td>\n"; echo " </td>\n";
echo "</tr>\n"; echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>";
echo "<br /><br />";
echo "</table>"; //include the footer
echo "</div>"; require_once "includes/footer.php";
echo "<br><br>";
echo "<br><br>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
echo "<br><br>";
require_once "includes/footer.php";
?> ?>