| 1 |
<?php |
|---|
| 2 |
/** $Id |
|---|
| 3 |
* Copyright 2008 Philippe Lindheimer - Astrogen LLC |
|---|
| 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; version 2 |
|---|
| 7 |
* of the License |
|---|
| 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 |
*/ |
|---|
| 15 |
|
|---|
| 16 |
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'setup'; |
|---|
| 17 |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|---|
| 18 |
if (isset($_REQUEST['delete'])) $action = 'delete'; |
|---|
| 19 |
|
|---|
| 20 |
$cidpopup_id = isset($_REQUEST['cidpopup_id']) ? $_REQUEST['cidpopup_id'] : false; |
|---|
| 21 |
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : ''; |
|---|
| 22 |
$ipaddr = isset($_REQUEST['ipaddr']) ? $_REQUEST['ipaddr'] : ''; |
|---|
| 23 |
$popup_script = isset($_REQUEST['popup_script']) ? $_REQUEST['popup_script'] : ''; |
|---|
| 24 |
$extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : ''; |
|---|
| 25 |
|
|---|
| 26 |
switch ($action) { |
|---|
| 27 |
case 'add': |
|---|
| 28 |
cidpopup_instance_add($description, $popup_script, $ipaddr); |
|---|
| 29 |
needreload(); |
|---|
| 30 |
redirect_standard(); |
|---|
| 31 |
break; |
|---|
| 32 |
case 'edit': |
|---|
| 33 |
cidpopup_instance_edit($cidpopup_id, $description, $popup_script, $ipaddr); |
|---|
| 34 |
needreload(); |
|---|
| 35 |
redirect_standard('extdisplay'); |
|---|
| 36 |
break; |
|---|
| 37 |
case 'delete': |
|---|
| 38 |
cidpopup_instance_delete($cidpopup_id); |
|---|
| 39 |
needreload(); |
|---|
| 40 |
redirect_standard(); |
|---|
| 41 |
break; |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
?> |
|---|
| 45 |
</div> |
|---|
| 46 |
|
|---|
| 47 |
<div class="rnav"><ul> |
|---|
| 48 |
<?php |
|---|
| 49 |
|
|---|
| 50 |
echo '<li><a href="config.php?display=cidpopup&type='.$type.'">'._('Add CID Popup').'</a></li>'; |
|---|
| 51 |
|
|---|
| 52 |
foreach (cidpopup_instance_list() as $row) { |
|---|
| 53 |
echo '<li><a href="config.php?display=cidpopup&type='.$type.'&extdisplay='.$row['cidpopup_id'].'" class="">'.$row['description'].'</a></li>'; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
?> |
|---|
| 57 |
</ul></div> |
|---|
| 58 |
|
|---|
| 59 |
<div class="content"> |
|---|
| 60 |
|
|---|
| 61 |
<?php |
|---|
| 62 |
|
|---|
| 63 |
if ($extdisplay) { |
|---|
| 64 |
// load |
|---|
| 65 |
$row = cidpopup_instance_get($extdisplay); |
|---|
| 66 |
|
|---|
| 67 |
$description = $row['description']; |
|---|
| 68 |
$ipaddr = $row['ipaddr']; |
|---|
| 69 |
$popup_script = $row['popup_script']; |
|---|
| 70 |
|
|---|
| 71 |
echo "<h2>"._("Edit: ")."$description ($popup_script/$ipaddr)"."</h2>"; |
|---|
| 72 |
} else { |
|---|
| 73 |
echo "<h2>"._("Add CID Popup")."</h2>"; |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
$helptext = _("This specialized module allows you to specify a destination IP Address of FQDN to be associated with various AGI Scripts that can be launched as part of a post answer action in a ringgroup. The scripts are specialized to deal with various destination CRM systems such as SugarCRM and other future system to provide push based CID PoPup and other CRM data to the agent who answers the call. Once you make an entry including the relevant information, these instances will be available within ringgroups to optionally associated a ringgroup with one of the configured servers so that such CRM data can be displayed to its agents."); |
|---|
| 77 |
echo $helptext; |
|---|
| 78 |
|
|---|
| 79 |
$dir = opendir(dirname(__FILE__).'/agi-bin'); |
|---|
| 80 |
$files = Array(); |
|---|
| 81 |
while ($fn = readdir($dir)) { |
|---|
| 82 |
if ($fn == '.' || $fn == '..') { |
|---|
| 83 |
continue; |
|---|
| 84 |
} else { |
|---|
| 85 |
$files[] = $fn; |
|---|
| 86 |
} |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
?> |
|---|
| 90 |
|
|---|
| 91 |
<form name="editCidPopup" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkCidPopup(editCidPopup);"> |
|---|
| 92 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>"> |
|---|
| 93 |
<input type="hidden" name="cidpopup_id" value="<?php echo $extdisplay; ?>"> |
|---|
| 94 |
<input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>"> |
|---|
| 95 |
<table> |
|---|
| 96 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit CID Popup Instance") : _("Add CID Popup Instance")) ?><hr></h5></td></tr> |
|---|
| 97 |
<tr> |
|---|
| 98 |
<td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The descriptive name of this CID Popup instance.")?></span></a></td> |
|---|
| 99 |
<td><input size="30" type="text" name="description" value="<?php echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 100 |
</tr> |
|---|
| 101 |
<tr> |
|---|
| 102 |
<tr> |
|---|
| 103 |
<td><a href="#" class="info"><?php echo _("IP Address")?>:<span><?php echo _("The IP Address of FQDN of the destination server where PopUp messages will be attempted")?></span></a></td> |
|---|
| 104 |
<td><input size="30" type="text" name="ipaddr" value="<?php echo $ipaddr; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 105 |
</tr> |
|---|
| 106 |
<tr> |
|---|
| 107 |
<td><a href="#" class="info"><?php echo _("Script to Run")?>:<span><?php echo _("The AGI Script that will be run and passed this IP address")?></span></a></td> |
|---|
| 108 |
<td> |
|---|
| 109 |
<select name="popup_script" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 110 |
<?php |
|---|
| 111 |
$default = (isset($popup_script) ? $popup_script : ''); |
|---|
| 112 |
foreach ($files as $script) { |
|---|
| 113 |
echo '<option value="'.$script.'" '.($script == $default ? 'SELECTED' : '').'>'.$script.'</option>'; |
|---|
| 114 |
} |
|---|
| 115 |
?> |
|---|
| 116 |
</select> |
|---|
| 117 |
</td> |
|---|
| 118 |
<tr> |
|---|
| 119 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 120 |
<?php if ($extdisplay) { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 121 |
</td> |
|---|
| 122 |
</tr> |
|---|
| 123 |
</table> |
|---|
| 124 |
</form> |
|---|
| 125 |
|
|---|
| 126 |
<script cidpopup="javascript"> |
|---|
| 127 |
<!-- |
|---|
| 128 |
|
|---|
| 129 |
function checkCidPopup(theForm) { |
|---|
| 130 |
var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>"; |
|---|
| 131 |
|
|---|
| 132 |
// set up the Destination stuff |
|---|
| 133 |
setDestinations(theForm, '_post_dest'); |
|---|
| 134 |
|
|---|
| 135 |
// form validation |
|---|
| 136 |
defaultEmptyOK = false; |
|---|
| 137 |
if (isEmpty(theForm.description.value)) |
|---|
| 138 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 139 |
|
|---|
| 140 |
if (!validateDestinations(theForm, 1, true)) |
|---|
| 141 |
return false; |
|---|
| 142 |
|
|---|
| 143 |
return true; |
|---|
| 144 |
} |
|---|
| 145 |
//--> |
|---|
| 146 |
</script> |
|---|