function Extensions_DialTone_Modify()
{
    global $mysqli;
    $session =& $_SESSION['Extensions_SimpleConf_Modify'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    // Init message (Message)
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    if (@$_REQUEST['submit'] == 'save') {
        $Extension = formdata_from_post();
        $Errors = formdata_validate($Extension);
        if (count($Errors) == 0) {
            if ($Extension['PK_Extension'] != '') {
                $msg = 'MODIFY_DIALTONE_EXTENSION';
            } else {
                $msg = 'ADD_DIALTONE_EXTENSION';
            }
            $id = formdata_save($Extension);
            header("Location: Extensions_List.php?hilight={$id}&msg={$msg}");
            die;
        }
    } elseif (@$_REQUEST['PK_Extension'] != "") {
        $Extension = formdata_from_db($_REQUEST['PK_Extension']);
    } else {
        $Extension = formdata_from_default();
    }
    $smarty->assign('Extension', $Extension);
    $smarty->assign('Errors', $Errors);
    return $smarty->fetch('Extensions_DialTone_Modify.tpl');
}
function Extensions_Action_Modify()
{
    global $mysqli;
    $session =& $_SESSION['IVR_Action_Modify_record_digits'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    if (@$_REQUEST['submit'] == 'save') {
        $Action = formdata_from_post();
        $Errors = formdata_validate($Action);
        if (count($Errors) == 0) {
            $id = formdata_save($Action);
            header("Location: IVR_Actions.php?PK_Menu={$Action['FK_Menu']}&hilight={$id}");
            die;
        }
    } elseif (@$_REQUEST['PK_Action'] != "") {
        $Action = formdata_from_db($_REQUEST['PK_Action']);
    } else {
        $Action = formdata_from_default();
    }
    // Get available vars
    $query = "SELECT DISTINCT(Variable) FROM IVR_Action_Params";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_row()) {
        if (!empty($row[0])) {
            $Variables[] = $row[0];
        }
    }
    $smarty->assign('Action', $Action);
    $smarty->assign('Variables', $Variables);
    return $smarty->fetch('IVR_Actions_Modify.record_digits.tpl');
}
예제 #3
0
function IVR_Menus_Modify()
{
    global $mysqli;
    $session =& $_SESSION['IVR_Menus_Modify'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    if (@$_REQUEST['submit'] == 'save') {
        $Menu = formdata_from_post();
        $Errors = formdata_validate($Action);
        if (count($Errors) == 0) {
            if ($Menu['PK_Menu'] != '') {
                $msg = 'MODIFY_MENU';
            } else {
                $msg = 'ADD_MENU';
            }
            $id = formdata_save($Menu);
            header("Location: IVR_Menus.php?PK_Menu={$id}&msg={$msg}");
            die;
        }
    } elseif (@$_REQUEST['PK_Menu'] != "") {
        $Menu = formdata_from_db($_REQUEST['PK_Menu']);
    } else {
        $Menu = formdata_from_default();
    }
    $smarty->assign('Menu', $Menu);
    $smarty->assign('Errors', $Errors);
    return $smarty->fetch('IVR_Menus_Modify.tpl');
}
예제 #4
0
function MOH_Groups_Modify()
{
    global $mysqli;
    $session =& $_SESSION['MOH_Groups_Modify'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    // Init message (Message)
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    if (@$_REQUEST['submit'] == 'save') {
        $Group = formdata_from_post();
        $Errors = formdata_validate($Group);
        if (count($Errors) == 0) {
            if ($Group['PK_Group'] != '') {
                $msg = 'MODIFY_MOH_GROUP';
            } else {
                $msg = 'ADD_MOH_GROUP';
            }
            $id = formdata_save($Group);
            asterisk_UpdateConf('musiconhold.conf');
            asterisk_Reload();
            header("Location: MOH_Groups_List.php?hilight={$id}&msg={$msg}");
            die;
        }
    } elseif (@$_REQUEST['PK_Group'] != "") {
        $Group = formdata_from_db($_REQUEST['PK_Group']);
    } else {
        $Group = formdata_from_default();
    }
    $smarty->assign('Group', $Group);
    $smarty->assign('Errors', $Errors);
    return $smarty->fetch('MOH_Groups_Modify.tpl');
}
예제 #5
0
function IVR_Options_Modify()
{
    global $mysqli;
    $session =& $_SESSION['IVR_Options_Modify'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    if (@$_REQUEST['submit'] == 'save') {
        $Option = formdata_from_post();
        $Errors = formdata_validate($Action);
        if (count($Errors) == 0) {
            if ($Option['PK_Option'] != '') {
                $msg = 'MODIFY_OPTION';
            } else {
                $msg = 'ADD_OPTION';
            }
            $id = formdata_save($Option);
            header("Location: IVR_Options_List.php?PK_Menu={$Option['FK_Menu']}&hilight={$id}&msg={$msg}");
            die;
        }
    } elseif (@$_REQUEST['PK_Option'] != "") {
        $Option = formdata_from_db($_REQUEST['PK_Option']);
    } else {
        $Option = formdata_from_default();
    }
    // Get available menus
    $Menus = array();
    $query = "SELECT PK_Menu, Name FROM IVR_Menus ORDER BY Name";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $menu = $row;
        $query2 = "SELECT * FROM IVR_Actions WHERE FK_Menu = '{$menu['PK_Menu']}' ORDER BY `Order`";
        $result2 = $mysqli->query($query2) or die($mysqli->error . $query2);
        while ($row2 = $result2->fetch_assoc()) {
            $action = $row2;
            $query3 = "SELECT * FROM IVR_Action_Params WHERE FK_Action = {$action['PK_Action']}";
            $result3 = $mysqli->query($query3) or die($mysqli->error . $query3);
            while ($row3 = $result3->fetch_assoc()) {
                $action['Param'][$row3['Name']] = $row3['Value'];
                $action['Var'][$row3['Name']] = $row3['Variable'];
            }
            $menu['Actions'][] = $action;
        }
        $Menus[] = $menu;
    }
    // Get used keys
    $UsedKeys = array();
    $query = "SELECT `Key` FROM IVR_Options WHERE PK_Option != '{$Option['PK_Option']}' AND FK_Menu={$Option['FK_Menu']}";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $UsedKeys[] = $row['Key'];
    }
    $smarty->assign('Menus', $Menus);
    $smarty->assign('Option', $Option);
    $smarty->assign('UsedKeys', $UsedKeys);
    return $smarty->fetch('IVR_Options_Modify.tpl');
}
function VoipProviders_Modify()
{
    global $mysqli;
    $session =& $_SESSION['VoipProviders_Modify'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    //	myprint($_REQUEST);
    // Init message (Message)
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    // Init Available DTMF Modes (DTMFModes)
    $query = "SELECT PK_DTMFMode, Name, Description FROM DTMFModes";
    $result = $mysqli->query($query) or die($mysqli->errno());
    $DTMFModes = array();
    while ($row = $result->fetch_assoc()) {
        $DTMFModes[] = $row;
    }
    // Init available codecs (Codecs)
    $query = "SELECT PK_Codec, Name, Description, Recomended FROM Codecs";
    $result = $mysqli->query($query) or die($mysqli->error);
    $Codecs = array();
    while ($row = $result->fetch_assoc()) {
        $Codecs[] = $row;
    }
    // Init available outgoing rules (Rules)
    $query = "SELECT * FROM OutgoingRules ORDER BY Name";
    $result = $mysqli->query($query) or die($mysqli->errno());
    $Rules = array();
    while ($row = $result->fetch_assoc()) {
        $Rules[] = $row;
    }
    // Init form data (Providers)
    if ($_REQUEST['submit'] == 'save') {
        $Provider = formdata_from_post();
        $Errors = formdata_validate($Provider);
        if (count($Errors) == 0) {
            $id = formdata_save($Provider);
            asterisk_UpdateConf('sip.conf');
            asterisk_UpdateConf('extensions.conf');
            asterisk_Reload();
            header("Location: VoipProviders_List.php?msg=MODIFY_SIP_PROVIDER&hilight={$id}");
            die;
        }
    } elseif ($_REQUEST['PK_SipProvider'] != "") {
        $Provider = formdata_from_db($_REQUEST['PK_SipProvider']);
    } else {
        $Provider = formdata_from_default();
    }
    $smarty->assign('Provider', $Provider);
    $smarty->assign('DTMFModes', $DTMFModes);
    $smarty->assign('Codecs', $Codecs);
    $smarty->assign('Message', $Message);
    $smarty->assign('Errors', $Errors);
    $smarty->assign('Rules', $Rules);
    return $smarty->fetch('VoipProviders_Modify.tpl');
}
function Recordings_ModifyRule()
{
    global $mysqli;
    $session =& $_SESSION['Recordings_ModifyRule'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    // Init message (Message)
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    if (@$_REQUEST['submit'] == 'save') {
        $Rule = formdata_from_post();
        $Errors = formdata_validate($Rule);
        if (count($Errors) == 0) {
            if ($Rule['PK_Rule'] != '') {
                $msg = 'MODIFY_REC_RULE';
            } else {
                $msg = 'ADD_REC_RULE';
            }
            $id = formdata_save($Rule);
            header("Location: Recordings_List.php?hilight={$id}&msg={$msg}");
            die;
        }
    } elseif (@$_REQUEST['PK_Rule'] != "") {
        $Rule = formdata_from_db($_REQUEST['PK_Rule']);
    } else {
        $Rule = formdata_from_default();
    }
    // Geting a list of phone extension (Phones)
    $Phones = array();
    $query = "\n\t\tSELECT\n\t\t\tExtensions.PK_Extension AS PK_Extension,\n\t\t\tExtension,\n\t\t\tName\n\t\tFROM\n\t\t\tExtensions\n\t\tWHERE\n\t\t\tType IN ('Virtual','SipPhone')\n\t\tORDER BY\n\t\t\tExtension ASC\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Phones[] = $row;
    }
    // Geting a list of extension groups (Groups)
    $Groups = array();
    $query = "SELECT * FROM Groups ORDER BY Name";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Groups[] = $row;
    }
    // Geting a list of queues (Queues)
    $Queues = array();
    $query = "SELECT * FROM Ext_Queues INNER JOIN Extensions ON Ext_Queues.PK_Extension = Extensions.PK_Extension ORDER BY Extension ASC";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Queues[] = $row;
    }
    $smarty->assign('Groups', $Groups);
    $smarty->assign('Queues', $Queues);
    $smarty->assign('Phones', $Phones);
    $smarty->assign('Rule', $Rule);
    $smarty->assign('Errors', $Errors);
    return $smarty->fetch('Recordings_ModifyRule.tpl');
}
예제 #8
0
function Dongles_Modify()
{
    global $mysqli;
    $session =& $_SESSION['Dongles_Modify'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    //	myprint($_REQUEST);
    // Init message (Message)
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    // Init available outgoing rules (Rules)
    $query = "SELECT * FROM OutgoingRules ORDER BY Name";
    $result = $mysqli->query($query) or die($mysqli->errno());
    $Rules = array();
    while ($row = $result->fetch_assoc()) {
        $Rules[] = $row;
    }
    $discovery_response = explode("\n", asterisk_Cmd('dongle discovery'));
    $discovered_dongles = array();
    $discovered_i = -1;
    for ($i = 0; $i < sizeof($discovery_response); $i++) {
        if (substr($discovery_response[$i], 0, 1) == "[") {
            $discovered_i++;
            $discovered_dongles[$discovered_i] = array();
        } elseif (substr($discovery_response[$i], 0, 4) == "imsi") {
            $discovered_dongles[$discovered_i]["IMSI"] = substr($discovery_response[$i], 5);
        } elseif (substr($discovery_response[$i], 0, 4) == "imei") {
            $discovered_dongles[$discovered_i]["IMEI"] = substr($discovery_response[$i], 5);
        }
    }
    // Init form data (Providers)
    if ($_REQUEST['submit'] == 'save') {
        $Dongle = formdata_from_post();
        $Errors = formdata_validate($Dongle);
        if (count($Errors) == 0) {
            $id = formdata_save($Dongle);
            asterisk_UpdateConf('dongle.conf');
            asterisk_UpdateConf('extensions.conf');
            asterisk_Reload();
            header("Location: Dongles_List.php?msg=MODIFY_DONGLE&hilight={$id}");
            die;
        }
    } elseif ($_REQUEST['PK_Dongle'] != "") {
        $Dongle = formdata_from_db($_REQUEST['PK_Dongle']);
    } else {
        $Dongle = formdata_from_default();
    }
    $smarty->assign('Dongle', $Dongle);
    $smarty->assign('DiscoveredDongles', $discovered_dongles);
    $smarty->assign('Message', $Message);
    $smarty->assign('Errors', $Errors);
    $smarty->assign('Rules', $Rules);
    return $smarty->fetch('Dongles_Modify.tpl');
}
function Extensions_Action_Modify()
{
    global $mysqli;
    $session =& $_SESSION['IVR_Action_Modify_conditional_clause'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    if (@$_REQUEST['submit'] == 'save') {
        $Action = formdata_from_post();
        $Errors = formdata_validate($Action);
        if (count($Errors) == 0) {
            $id = formdata_save($Action);
            header("Location: IVR_Actions.php?PK_Menu={$Action['FK_Menu']}&hilight={$id}");
            die;
        }
    } elseif (@$_REQUEST['PK_Action'] != "") {
        $Action = formdata_from_db($_REQUEST['PK_Action']);
    } else {
        $Action = formdata_from_default();
    }
    // Get available vars
    $Variables = array();
    $query = "SELECT DISTINCT(Variable) FROM IVR_Action_Params";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_row()) {
        if (!empty($row[0])) {
            $Variables[] = $row[0];
        }
    }
    // Get available menus
    $Menus = array();
    $query = "SELECT PK_Menu, Name FROM IVR_Menus ORDER BY Name";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $menu = $row;
        $query2 = "SELECT * FROM IVR_Actions WHERE FK_Menu = '{$menu['PK_Menu']}' ORDER BY `Order`";
        $result2 = $mysqli->query($query2) or die($mysqli->error . $query2);
        while ($row2 = $result2->fetch_assoc()) {
            $action = $row2;
            $query3 = "SELECT * FROM IVR_Action_Params WHERE FK_Action = {$action['PK_Action']}";
            $result3 = $mysqli->query($query3) or die($mysqli->error . $query3);
            while ($row3 = $result3->fetch_assoc()) {
                $action['Param'][$row3['Name']] = $row3['Value'];
                $action['Var'][$row3['Name']] = $row3['Variable'];
            }
            $menu['Actions'][] = $action;
        }
        $Menus[] = $menu;
    }
    $smarty->assign('Menus', $Menus);
    $smarty->assign('Action', $Action);
    $smarty->assign('Variables', $Variables);
    return $smarty->fetch('IVR_Actions_Modify.conditional_clause.tpl');
}
function Extensions_Action_Modify()
{
    $session =& $_SESSION['IVR_Action_Modify_wait'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    if (@$_REQUEST['submit'] == 'save') {
        $Action = formdata_from_post();
        $Errors = formdata_validate($Action);
        if (count($Errors) == 0) {
            $id = formdata_save($Action);
            header("Location: IVR_Actions.php?PK_Menu={$Action['FK_Menu']}&hilight={$id}");
            die;
        }
    } elseif (@$_REQUEST['PK_Action'] != "") {
        $Action = formdata_from_db($_REQUEST['PK_Action']);
    } else {
        $Action = formdata_from_default();
    }
    $smarty->assign('Action', $Action);
    return $smarty->fetch('IVR_Actions_Modify.wait.tpl');
}
function Extensions_Action_Modify()
{
    global $mysqli;
    $session =& $_SESSION['IVR_Action_Modify_play_sound'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    if (@$_REQUEST['submit'] == 'save') {
        $Action = formdata_from_post();
        $Errors = formdata_validate($Action);
        if (count($Errors) == 0) {
            $id = formdata_save($Action);
            header("Location: IVR_Actions.php?PK_Menu={$Action['FK_Menu']}&hilight={$id}");
            die;
        }
    } elseif (@$_REQUEST['PK_Action'] != "") {
        $Action = formdata_from_db($_REQUEST['PK_Action']);
    } else {
        $Action = formdata_from_default();
    }
    // Init Folders (SoundFolders)
    $SoundFolders = array();
    $query = "\n\t\tSELECT\n\t\t\tPK_SoundFolder,\n\t\t\tName\n\t\tFROM\n\t\t\tSoundFolders\n\t\tORDER BY Name\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $SoundFolders[] = $row;
    }
    // Init SoundLanguages
    $SoundLanguages = array();
    $query = "\n\t\tSELECT\n\t\t\tPK_SoundLanguage,\n\t\t\t`Default`,\n\t\t\tName\n\t\tFROM\n\t\t\tSoundLanguages\n\t\tORDER BY Name\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $SoundLanguages[] = $row;
        if ($row['Default']) {
            $SoundLanguage_Default = $row;
        }
    }
    // Init SoundEntries
    $SoundEntries = array();
    foreach ($SoundLanguages as $SoundLanguage) {
        $lid = $SoundLanguage['PK_SoundLanguage'];
        $query_select .= "\n\t\t\tSoundFiles_{$lid}.Name        AS Name_{$lid}       ,\n\t\t\tSoundFiles_{$lid}.Description AS Description_{$lid},\n\t\t";
        $query_from .= "\n\t\t\tLEFT JOIN SoundFiles SoundFiles_{$lid} ON SoundFiles_{$lid}.FK_SoundEntry = PK_SoundEntry AND SoundFiles_{$lid}.FK_SoundLanguage = {$lid}\n\t\t";
    }
    $query = "\n\t\tSELECT\n\t\t\t{$query_select}\n\t\t\tPK_SoundEntry,\n\t\t\tFK_SoundFolder\n\t\tFROM\n\t\t\tSoundEntries\n\t\t\t{$query_from}\n\t\tORDER BY\n\t\t\tPK_SoundEntry\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $SoundEntry = $row;
        foreach ($SoundLanguages as $SoundLanguage) {
            $lid = $SoundLanguage['PK_SoundLanguage'];
            $SoundEntry['Name'][$lid] = $SoundEntry["Name_{$lid}"];
            $SoundEntry['Description'][$lid] = $SoundEntry["Description_{$lid}"];
            if ($SoundEntry["Name_{$lid}"] != "") {
                $SoundEntry['Name']['Default'] = "{$SoundEntry['Name'][$SoundLanguage['PK_SoundLanguage']]}";
            }
        }
        if ($SoundEntry['Name'][$SoundLanguage_Default['PK_SoundLanguage']] != "") {
            $SoundEntry['Name']['Default'] = "{$SoundEntry['Name'][$SoundLanguage_Default['PK_SoundLanguage']]}";
        }
        $SoundEntries[] = $SoundEntry;
    }
    $smarty->assign('Action', $Action);
    $smarty->assign('SoundEntries', $SoundEntries);
    $smarty->assign('SoundFolders', $SoundFolders);
    $smarty->assign('SoundLanguages', $SoundLanguages);
    $smarty->assign('SoundLanugage_Default', $SoundLanguage_Default);
    return $smarty->fetch('IVR_Actions_Modify.play_sound.tpl');
}
function Extensions_FC_DirectedPickup_Modify()
{
    global $mysqli;
    $session =& $_SESSION['Extensions_FC_DirectedPickup_Modify'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    //myprint($_REQUEST);
    if ($_REQUEST['PK_Extension']) {
        $pk_ext = $_REQUEST['PK_Extension'];
        //Preexisted Members
        $query = " SELECT\n\t\t\t\t\t\tFK_Ext_Member, ConnectionID, FK_Ext_Group\n\t\t\t\t\tFROM\n\t\t\t\t\t\tFC_DirectedPickup_Members\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tFK_Extension = '" . $mysqli->escape_string($pk_ext) . "' ORDER BY FK_Ext_Member, FK_Ext_Group";
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        $Members = array();
        while ($row = $result->fetch_assoc()) {
            $Members[] = $row;
        }
        //Preexisted Admins
        $query = " SELECT\n\t\t\t\t\t\tFK_Ext_Admin, ConnectionID, FK_Ext_Group\n\t\t\t\t\tFROM\n\t\t\t\t\t\tFC_DirectedPickup_Admins\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tFK_Extension = '" . $mysqli->escape_string($pk_ext) . "' ORDER BY FK_Ext_Admin, FK_Ext_Group";
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        $Admins = array();
        while ($row = $result->fetch_assoc()) {
            $Admins[] = $row;
        }
        //Preexisted ConnectionIDs
        $query = " SELECT DISTINCT\n\t\t\t\t\t\tConnectionID\n\t\t\t\t\tFROM\n\t\t\t\t\t\tFC_DirectedPickup_Admins\n\t\t\t\t\tORDER BY ConnectionID";
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        $IDs = array();
        while ($row = $result->fetch_assoc()) {
            $IDs[] = $row['ConnectionID'];
        }
    }
    $Rows = @data_rows($Admins, $Members, $IDs);
    // Init message (Message)
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    // Groups
    $query = "SELECT PK_Group, Name FROM Groups";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $Groups = array();
    while ($row = $result->fetch_assoc()) {
        $Groups[] = $row;
    }
    // Init Available Accounts (Accounts)
    $query = "\n\t\tSELECT\n\t\t\tExtensions.PK_Extension,\n\t\t\tExtension,\n\t\t\tCONCAT(IFNULL(Ext_SipPhones.FirstName,''),IFNULL(Ext_Virtual.FirstName,'')) AS FirstName,\n\t\t\tCONCAT(IFNULL(Ext_SipPhones.LastName ,''),IFNULL(Ext_Virtual.LastName,''))  AS LastName\n\t\tFROM\n\t\t\tExtensions\n\t\t\tLEFT JOIN Ext_SipPhones ON Ext_SipPhones.PK_Extension = Extensions.PK_Extension\n\t\t\tLEFT JOIN Ext_Virtual   ON Ext_Virtual.PK_Extension   = Extensions.PK_Extension\n\t\tWHERE\n\t\t\tExtensions.Type IN ('Virtual', 'SipPhone')\n\t\tORDER BY Extension\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $Accounts = array();
    while ($row = $result->fetch_assoc()) {
        $Accounts[] = $row;
    }
    if (@$_REQUEST['submit'] == 'save') {
        $Extension = formdata_from_post();
        $Errors = formdata_validate($Extension);
        if (count($Errors) == 0) {
            if ($Extension['PK_Extension'] != '') {
                $msg = 'MODIFY_FC_DIRECTEDPICKUP_EXTENSION';
            } else {
                $msg = 'ADD_FC_DIRECTEDPICKUP_EXTENSION';
            }
            $id = @formdata_save($Extension);
            header("Location: Extensions_List.php?hilight={$id}&msg={$msg}");
            die;
        }
    } elseif (@$_REQUEST['PK_Extension'] != "") {
        $Extension = formdata_from_db($_REQUEST['PK_Extension']);
    } else {
        $Extension = formdata_from_default();
    }
    $smarty->assign('Groups', $Groups);
    $smarty->assign('Accounts', $Accounts);
    $smarty->assign('Rows', $Rows);
    $smarty->assign('FC_DirectedPickup', $Extension);
    $smarty->assign('Errors', $Errors);
    return $smarty->fetch('Extensions_FC_DirectedPickup_Modify.tpl');
}