| 1 |
<?php |
|---|
| 2 |
//Copyright (C) 2008 ATL Telecom Ltd |
|---|
| 3 |
// |
|---|
| 4 |
//This program is free software; you can redistribute it and/or |
|---|
| 5 |
//modify it under the terms of the GNU General Public License |
|---|
| 6 |
//as published by the Free Software Foundation; either version 2 |
|---|
| 7 |
//of the License, or (at your option) any later version. |
|---|
| 8 |
// |
|---|
| 9 |
//This program is distributed in the hope that it will be useful, |
|---|
| 10 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
//GNU General Public License for more details. |
|---|
| 13 |
|
|---|
| 14 |
$numbuttonsx = 4; |
|---|
| 15 |
$numbuttonsy = 20; |
|---|
| 16 |
|
|---|
| 17 |
$itemnames = array(legend,startpos,stoppos,color1,color2); |
|---|
| 18 |
$buttontypes = array(extension,trunk,queue,conference,parking); |
|---|
| 19 |
|
|---|
| 20 |
foreach ($_REQUEST as $key => $value) {${$key} = $value;} |
|---|
| 21 |
|
|---|
| 22 |
//if submitting form, update database |
|---|
| 23 |
|
|---|
| 24 |
if (isset($Add)) { |
|---|
| 25 |
list($action,$id) = explode(" ",$Add); |
|---|
| 26 |
$legend = ucfirst($id); |
|---|
| 27 |
$sql="INSERT INTO `panel` ( `id` , `legend` , `startpos` , `stoppos` , `color1` , `color2` ) VALUES ('$id', '$legend' , 29, 52, '777777', '777777');"; |
|---|
| 28 |
sql($sql); |
|---|
| 29 |
} |
|---|
| 30 |
if (isset($Delete)) { |
|---|
| 31 |
list($action,$id) = explode(" ",$Delete); |
|---|
| 32 |
$sql="DELETE FROM `panel` WHERE id = '$id';"; |
|---|
| 33 |
sql($sql); |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
if (isset($Submit)) { |
|---|
| 37 |
|
|---|
| 38 |
$sql = "SELECT id FROM panel"; |
|---|
| 39 |
$panelids = $db->getAll($sql); |
|---|
| 40 |
if(DB::IsError($panelrows)) { |
|---|
| 41 |
die($panelrows->getMessage()); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
foreach ($panelids as $panelid) { |
|---|
| 45 |
$startpos = ${$panelid[0]."-startpos"}; |
|---|
| 46 |
$stoppos = ${$panelid[0]."-stoppos"}; |
|---|
| 47 |
if (($startpos > $numbuttonsx*$numbuttonsy) || ($startpos <= 0)) {die("ERROR: Start-Position out of range in '{$panelid[0]}' ");} |
|---|
| 48 |
if (($stoppos > $numbuttonsx*$numbuttonsy) || ($stoppos <= 0)) {die("ERROR: Stop-Position out of range in '{$panelid[0]}' ");} |
|---|
| 49 |
if ( ($startpos-1)%$numbuttonsy > ($stoppos-1)%$numbuttonsy ) {die("ERROR: Negative vertical size in '{$panelid[0]}' ");} |
|---|
| 50 |
if ( $startpos > $stoppos ) {die("ERROR: Negative horizontal size in '{$panelid[0]}' ");} |
|---|
| 51 |
$sql = "UPDATE panel SET "; |
|---|
| 52 |
foreach ($itemnames as $itemname) { $key = $panelid[0]."-".$itemname; $sql .= " $itemname = '${$key}',";} |
|---|
| 53 |
$sql = substr($sql,0,-1); |
|---|
| 54 |
$sql .= " WHERE id = '$panelid[0]'"; |
|---|
| 55 |
sql($sql); |
|---|
| 56 |
} |
|---|
| 57 |
//indicate 'need reload' link in header.php |
|---|
| 58 |
needreload(); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
//get all rows relating to selected account |
|---|
| 62 |
$sql = "SELECT * FROM panel ORDER BY startpos"; |
|---|
| 63 |
$panelrows = $db->getAll($sql); |
|---|
| 64 |
if(DB::IsError($panelrows)) { |
|---|
| 65 |
die($panelrows->getMessage()); |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
?> |
|---|
| 70 |
|
|---|
| 71 |
<form name="panel" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
<h2><?php echo _("Operator Panel Layout")?></h2> |
|---|
| 75 |
<p> |
|---|
| 76 |
<?php |
|---|
| 77 |
foreach ($buttontypes as $buttontype) { |
|---|
| 78 |
$action = "Add"; |
|---|
| 79 |
foreach ($panelrows as $panelrow) { |
|---|
| 80 |
if ($panelrow[0] == $buttontype) {$action = "Delete";} |
|---|
| 81 |
} |
|---|
| 82 |
echo "<input name='$action' type='submit' value='$action $buttontype area'/>\n"; |
|---|
| 83 |
} |
|---|
| 84 |
?> |
|---|
| 85 |
</p> |
|---|
| 86 |
<table> |
|---|
| 87 |
<tr><td> </td><td>Legend</td><td>Start Position</td><td>Stop Position</td><td>Main Color</td><td>Gradient Color</td></tr> |
|---|
| 88 |
<?php |
|---|
| 89 |
foreach ($panelrows as $panelrow) { |
|---|
| 90 |
$rowheading = array_shift($panelrow); |
|---|
| 91 |
echo "<tr><td>". ucfirst($rowheading) . "</td>"; |
|---|
| 92 |
$i=0; |
|---|
| 93 |
foreach ($panelrow as $panelitem) { |
|---|
| 94 |
echo "<td><input name='$rowheading-${itemnames[$i++]}' type='text' value='$panelitem'/></td>\n"; |
|---|
| 95 |
} |
|---|
| 96 |
} |
|---|
| 97 |
?> |
|---|
| 98 |
</table> |
|---|
| 99 |
<h6> |
|---|
| 100 |
<input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"> |
|---|
| 101 |
</h6> |
|---|
| 102 |
<h5><?php echo _("Layout Preview")?></h5> |
|---|
| 103 |
<table border='1'> |
|---|
| 104 |
<?php |
|---|
| 105 |
for($i=0;$i<$numbuttonsy;$i++) { |
|---|
| 106 |
echo "<tr>"; |
|---|
| 107 |
for($j=0;$j<$numbuttonsx;$j++) { |
|---|
| 108 |
$num = 1 + $i + $numbuttonsy*$j; |
|---|
| 109 |
$allocation = ""; |
|---|
| 110 |
foreach ($panelrows as $panelrow) { |
|---|
| 111 |
$legend = $panelrow[1]; |
|---|
| 112 |
$startpos = $panelrow[2]; |
|---|
| 113 |
$stoppos = $panelrow[3]; |
|---|
| 114 |
$button = ucfirst($panelrow[0]) . " button"; |
|---|
| 115 |
$startx = ($startpos-1)%$numbuttonsy; |
|---|
| 116 |
$stopx = ($stoppos-1)%$numbuttonsy; |
|---|
| 117 |
$starty = floor(($startpos-1)/$numbuttonsy); |
|---|
| 118 |
$stopy = floor(($stoppos-1)/$numbuttonsy); |
|---|
| 119 |
if ($num == $startpos) {$allocation .= "<br /><strong>\"$legend\"</strong>";} |
|---|
| 120 |
elseif (($startx <= $i) && ($stopx >= $i) && ($starty <= $j) && ($stopy >= $j)) {$allocation.= "<br /><strong>$button</strong>";} |
|---|
| 121 |
|
|---|
| 122 |
} |
|---|
| 123 |
if ($allocation == "") {$allocation = "<br />Unused";} |
|---|
| 124 |
echo "<td align='center' width='200'>Position $num $allocation</td>"; |
|---|
| 125 |
} |
|---|
| 126 |
echo "</tr>"; |
|---|
| 127 |
} |
|---|
| 128 |
?> |
|---|
| 129 |
|
|---|
| 130 |
</table> |
|---|
| 131 |
|
|---|
| 132 |
</form> |
|---|