| 1 |
<?php /* $Id: page.bosssecretary.php $ */ |
|---|
| 2 |
// Developed by Maikel Salazar (maikelsalazar at gmail dot com) |
|---|
| 3 |
// Sponsored by TI Soluciones, http://www.solucionesit.com.ve |
|---|
| 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 |
|
|---|
| 16 |
if (isset($_GET["extensions"], $_GET["ajax"])) |
|---|
| 17 |
{ |
|---|
| 18 |
$result = bosssecretary_search($_GET["extensions"]); |
|---|
| 19 |
if (isset($result)) |
|---|
| 20 |
{ |
|---|
| 21 |
if (!empty($result)) |
|---|
| 22 |
{ |
|---|
| 23 |
foreach ($result as $extension) |
|---|
| 24 |
{ |
|---|
| 25 |
echo $extension["extension"] . " extension is " . $extension["type"] . " at '" . $extension["label"] ."' group <br />"; |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
} |
|---|
| 29 |
else |
|---|
| 30 |
{ |
|---|
| 31 |
echo "Not matches"; |
|---|
| 32 |
} |
|---|
| 33 |
} |
|---|
| 34 |
else |
|---|
| 35 |
{ |
|---|
| 36 |
echo "Critery invalid!"; |
|---|
| 37 |
} |
|---|
| 38 |
exit(1); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
$dispnum = 'bosssecretary'; //used for switch on config.php |
|---|
| 42 |
$extensionsCleaned = array(); |
|---|
| 43 |
$title = _("Boss Secretary"); |
|---|
| 44 |
$messages = ""; |
|---|
| 45 |
$params = array(); |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
if (isset($_POST["cleanAdd"]) || (isset($_POST["cleanEdit"])) || isset($_POST["submitAdd"]) || isset($_POST["submitEdit"])) |
|---|
| 49 |
{ |
|---|
| 50 |
if (isset($_POST["submitAdd"])) $_POST["group_number"] = null; |
|---|
| 51 |
$extensionsCleaned = bosssecretary_clean_remove_duplicates($_POST["bosses_extensions"], $_POST["secretaries_extensions"], $_POST["group_number"]); |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
if (isset($_POST["submitAdd"])) |
|---|
| 56 |
{ |
|---|
| 57 |
$group_number = bosssecretary_get_group_number_free(); |
|---|
| 58 |
$chiefs = bosssecretary_str_extensions_to_array($_POST["chiefs_extensions"]); |
|---|
| 59 |
$errors = bosssecretary_group_add($group_number, $_POST["group_label"], $extensionsCleaned["bosses"],$extensionsCleaned["secretaries"], $chiefs); |
|---|
| 60 |
$params["message_title"] = ""; |
|---|
| 61 |
$params["message_details"] = array(); |
|---|
| 62 |
if (empty($errors)) |
|---|
| 63 |
{ |
|---|
| 64 |
$_GET["bsgroupdisplay"] = ""; |
|---|
| 65 |
$params["message_title"] = "Group Added"; |
|---|
| 66 |
$params["message_details"] = array("Group was added successfully"); |
|---|
| 67 |
needreload(); |
|---|
| 68 |
} |
|---|
| 69 |
else |
|---|
| 70 |
{ |
|---|
| 71 |
//$params["group_number"] = $_POST["group_number"]; |
|---|
| 72 |
$params["group_label"] = $_POST["group_label"]; |
|---|
| 73 |
$params["chiefs"] = $_POST["chiefs"]; |
|---|
| 74 |
$params["bosses"] = $extensionsCleaned["bosses"]; |
|---|
| 75 |
$params["secretaries"] = $extensionsCleaned["secretaries"]; |
|---|
| 76 |
$params["message_title"] = "Errors were encountered, details"; |
|---|
| 77 |
$params["message_details"] = $errors; |
|---|
| 78 |
} |
|---|
| 79 |
$content = bosssecretary_get_form_add( $params); |
|---|
| 80 |
} |
|---|
| 81 |
elseif( isset($_POST["cleanAdd"])) |
|---|
| 82 |
{ |
|---|
| 83 |
$params = $_POST; |
|---|
| 84 |
$params["bosses"] = $extensionsCleaned["bosses"]; |
|---|
| 85 |
$params["secretaries"] = $extensionsCleaned["secretaries"]; |
|---|
| 86 |
$content = bosssecretary_get_form_add( $params); |
|---|
| 87 |
} |
|---|
| 88 |
elseif( isset($_POST["cleanEdit"])) |
|---|
| 89 |
{ |
|---|
| 90 |
$params = $_POST; |
|---|
| 91 |
$params["bosses"] = $extensionsCleaned["bosses"]; |
|---|
| 92 |
$params["secretaries"] = $extensionsCleaned["secretaries"]; |
|---|
| 93 |
$content = bosssecretary_get_form_edit( $params); |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
elseif(isset($_POST["submitEdit"])) |
|---|
| 97 |
{ |
|---|
| 98 |
|
|---|
| 99 |
$chiefs = bosssecretary_str_extensions_to_array($_POST["chiefs_extensions"]); |
|---|
| 100 |
$errors = bosssecretary_group_edit($_POST["group_number"], $_POST["group_label"], $extensionsCleaned["bosses"],$extensionsCleaned["secretaries"], $chiefs); |
|---|
| 101 |
if (empty($errors)) |
|---|
| 102 |
{ |
|---|
| 103 |
$params["message_title"] = "Group Edited"; |
|---|
| 104 |
$params["message_details"] = array("Group " . $_POST["group_number"] . " (" . $_POST["group_label"] . ") was edited successfully"); |
|---|
| 105 |
needreload(); |
|---|
| 106 |
} |
|---|
| 107 |
else |
|---|
| 108 |
{ |
|---|
| 109 |
$params["message_title"] = "Errors were encountered, details"; |
|---|
| 110 |
$params["message_details"] = $errors; |
|---|
| 111 |
} |
|---|
| 112 |
$params["group_number"] = $_POST["group_number"]; |
|---|
| 113 |
$params["group_label"] = $_POST["group_label"]; |
|---|
| 114 |
$params["chiefs"] = $chiefs; |
|---|
| 115 |
$params["bosses"] = $extensionsCleaned["bosses"]; |
|---|
| 116 |
$params["secretaries"] = $extensionsCleaned["secretaries"]; |
|---|
| 117 |
$content = bosssecretary_get_form_edit( $params); |
|---|
| 118 |
} |
|---|
| 119 |
elseif (isset($_GET["bsgroupdisplay"])) |
|---|
| 120 |
{ |
|---|
| 121 |
$group = bosssecretary_extract_group_from_request($_GET["bsgroupdisplay"]); |
|---|
| 122 |
if ($group == "add") |
|---|
| 123 |
{ |
|---|
| 124 |
$content = bosssecretary_get_form_add($params); |
|---|
| 125 |
} |
|---|
| 126 |
else |
|---|
| 127 |
{ |
|---|
| 128 |
$params = bosssecretary_set_params_to_edit(bosssecretary_get_data_of_group($group)); |
|---|
| 129 |
$content = bosssecretary_get_form_edit($params); |
|---|
| 130 |
} |
|---|
| 131 |
} |
|---|
| 132 |
elseif (isset($_GET["bsgroupdelete"])) |
|---|
| 133 |
{ |
|---|
| 134 |
$group = bosssecretary_extract_group_from_request($_GET["bsgroupdelete"]); |
|---|
| 135 |
if (bosssecretary_group_exists($group)) |
|---|
| 136 |
{ |
|---|
| 137 |
if (bosssecretary_group_delete($group)) |
|---|
| 138 |
{ |
|---|
| 139 |
$content = "<br /> Group was deleted successfully <br /> <br /> <br /> <h3>Choose a group or add one:</h3> "; |
|---|
| 140 |
needreload(); |
|---|
| 141 |
} |
|---|
| 142 |
else |
|---|
| 143 |
{ |
|---|
| 144 |
$content = "<br /> Group was not deleted, please try it again <br /> <br /> <br /><h3>Choose a group or add one:</h3>"; |
|---|
| 145 |
} |
|---|
| 146 |
} |
|---|
| 147 |
} |
|---|
| 148 |
else |
|---|
| 149 |
{ |
|---|
| 150 |
$content = "<br /> <br /> <br /> <h3>Choose a group or add one:</h3>"; |
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
$groups = bosssecretary_get_groups(); |
|---|
| 155 |
$linksGroups = bosssecretary_create_nav_groups_links($groups, $dispnum); |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
bosssecretary_show_nav_users($linksGroups); |
|---|
| 159 |
bosssecretary_content($title, $content, $messages); |
|---|
| 160 |
?> |
|---|