예제 #1
0
function reportEmailList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pORGZ = new paloSantoOrganization($pDB);
    $pEmailList = new paloSantoEmailList($pDB);
    $org_domain = getParameter("domain");
    $name_list = getParameter("name_list");
    $total = 0;
    if ($credentials['userlevel'] == "superadmin") {
        if (!empty($org_domain)) {
            $total = $pEmailList->getNumEmailList($name_list, $org_domain);
        } else {
            $org_domain = 0;
            //opcion default se muestran todas las listas
            $total = $pEmailList->getNumEmailList($name_list);
        }
    } else {
        $org_domain = $credentials['domain'];
        $total = $pEmailList->getNumEmailList($name_list, $org_domain);
    }
    if ($total === false) {
        $total = 0;
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr("Couldn't be retrieved Email List data"));
    }
    //url
    $url['menu'] = $module_name;
    $url['domain'] = $org_domain;
    $url['name_list'] = $name_list;
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTitle(_tr("Email List"));
    $oGrid->setIcon("web/apps/{$module_name}/images/email.png");
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $del_permission = in_array('delete_list', $arrPermission);
    $edit_permission = in_array('edit_list', $arrPermission);
    $create_permission = in_array('create_list', $arrPermission);
    if ($del_permission) {
        $arrColumns[] = "";
    }
    //checkbox to delete
    $arrColumns[] = _tr('List Name');
    $arrColumns[] = _tr('Number of Members');
    $arrColumns[] = _tr('Actions');
    $oGrid->setColumns($arrColumns);
    $arrData = null;
    if ($total > 0) {
        $arrResult = $pEmailList->getEmailListPagging($name_list, $org_domain, $limit, $offset);
        if ($arrResult === false) {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("Couldn't be retrieved Email List data"));
        } else {
            foreach ($arrResult as $list) {
                $arrTmp = array();
                if ($del_permission) {
                    $arrTmp[] = "<input type='checkbox' name='del_list' id='{$list['id']}'>";
                }
                $arrTmp[] = "<a href='?menu={$module_name}&action=view_list&id={$list['id']}'>" . htmlentities($list['listname'], ENT_QUOTES, "UTF-8") . "@" . $list['organization_domain'] . "</a>";
                $arrTmp[] = $pEmailList->getTotalMembers($list['id']);
                $arrTmp[] = "<a href='?menu={$module_name}&action=view_memberlist&id=" . $list['id'] . "'>" . _tr("View members") . "</a>";
                $arrData[] = $arrTmp;
            }
        }
    }
    //Verifico si en el archivo /etc/postfix/main.cf las variables alias_map y virtual_alias_map están apuntando a los archivos correctos, de no ser así se lo corrige
    $checkPostfixFile = $pEmailList->checkPostfixFile();
    if (!$checkPostfixFile) {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr("An error has ocurred to try config postfix file"));
    }
    //begin section filter
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input name='search_org' type='submit' class='button' value='" . _tr('Search') . "'>");
    //se comprueba que el mailman haya sido configurado por primera vez
    $MailmanListCreated = $pEmailList->isMailmanListCreated();
    if (is_null($MailmanListCreated)) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", $pEmailList->getError());
    } elseif (!$MailmanListCreated) {
        //sino ha sido configurado se muestra un mensaje
        if ($credentials['userlevel'] != 'superadmin') {
            //solo el superadmin puede hacer esta accion
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("A new List can not be added because some configurations are missed. Please contact with Elastix Admisnistrator"));
        } else {
            $smarty->assign("mb_title", _tr("Message"));
            $smarty->assign("mb_message", _tr("In order to use this module configure the Mailman Admin Settings. Click here >> ") . "<a href='?menu={$module_name}&action=mailman_settings'>" . _tr('Mailman Settings') . "</a>");
        }
    } else {
        if ($pORGZ->getNumOrganization(array()) > 0) {
            if ($create_permission) {
                $oGrid->addNew("new_emaillist", _tr("New Email list"));
            }
            /*if($del_permission)
              $oGrid->deleteList(_tr("Are you sure you wish to delete the Email List(s)."),"delete",_tr("Delete"));*/
            $arrOrgz = array(0 => "all");
            if ($credentials['userlevel'] == "superadmin") {
                foreach ($pORGZ->getOrganization(array()) as $value) {
                    $arrOrgz[$value["domain"]] = $value["domain"];
                }
                $_POST["domain"] = $org_domain;
                $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$org_domain], $_POST, array("domain" => 0), true);
                //organization
            }
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name List") . " = " . $name_list, $_POST, array("name_list" => ""));
            //name_list
            $arrFormElements = createFieldFilter($arrOrgz);
            $oFilterForm = new paloForm($smarty, $arrFormElements);
            $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
            $oGrid->showFilter(trim($htmlFilter));
        } else {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("In order to use this module must exist at least 1 organization in the Elastix Server"));
        }
    }
    $content = $oGrid->fetchGrid(array(), $arrData);
    return $content;
}
예제 #2
0
function reportOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $other_destination_name = getParameter("other_destination_name");
    $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain);
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['other_destination_name'] = $other_destination_name;
    $total = $pOtherDestinations->getNumOtherDestinations($domain, $other_destination_name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pOtherDestinations->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Other Destinations List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Other Destination Name");
    $arrColum[] = _tr("Dial Destination");
    $oGrid->setColumns($arrColum);
    $arrOtherDestinations = array();
    $arrData = array();
    if ($total != 0) {
        $arrOtherDestinations = $pOtherDestinations->getOtherDestinations($domain, $other_destination_name, $limit, $offset);
    }
    if ($arrOtherDestinations === false) {
        $error = _tr("Error to obtain Other Destinations") . $pOtherDestinations->errMsg;
        $arrOtherDestinations = array();
    }
    foreach ($arrOtherDestinations as $row) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$row["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id=" . $row['id'] . "&organization={$row['organization_domain']}'>" . htmlentities($row["description"], ENT_QUOTES, "UTF-8") . "</a>";
        $arrTmp[] = $row["destdial"];
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Other Destination"), array_slice($arrOrgz, 1), $selected = null, "create_other_destination", $onchange_select = null);
            } else {
                $oGrid->addNew("create_other_destination", _tr("ADD Other Destination"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["other_destination_name"] = $other_destination_name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Other Destination Name") . " = " . $other_destination_name, $_POST, array("other_destination_name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
예제 #3
0
function reportTG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $name = getParameter('name');
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['name'] = $name;
    //name
    $pTG = new paloSantoTG($pDB, $domain);
    $total = $pTG->getNumTG($domain, $name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => "all");
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pTG->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Time Groups List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Name");
    $oGrid->setColumns($arrColum);
    $arrTG = array();
    $arrData = array();
    if ($total != 0) {
        $arrTG = $pTG->getTGs($domain, $name, $limit, $offset);
    }
    if ($arrTG === false) {
        $error = _tr("Error to obtain Time Groups") . $pTG->errMsg;
        $arrTG = array();
    }
    $arrData = array();
    foreach ($arrTG as $tg) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$tg["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=edit&id_tg=" . $tg['id'] . "&organization={$tg['organization_domain']}'>" . $tg['name'] . "</a>";
        $arrData[] = $arrTmp;
    }
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Time Group"), array_slice($arrOrgz, 1), $selected = null, "create_tg", $onchange_select = null);
            } else {
                $oGrid->addNew("create_tg", _tr("ADD Time Group"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["name"] = $name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Time Condition Group") . " = " . $name, $_POST, array("name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
예제 #4
0
function reportANI($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $smarty->assign("SHOW_DIV_ERROR", "0");
    //FIXED: can show div error message with javascript
    $smarty->assign("mb_message", "hide");
    //FIXED: can show div error message with javascript
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $ani_prefix = getParameter("ani_prefix");
    $pANI = new paloSantoANI($pDB, $domain);
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['ani_prefix'] = $ani_prefix;
    $total = $pANI->getNumANI($domain, $ani_prefix);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pANI->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('ANI List'));
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Trunk Name");
    $arrColum[] = _tr("Prefix ANI");
    $oGrid->setColumns($arrColum);
    $arrANI = array();
    $arrData = array();
    if ($total != 0) {
        $arrANI = $pANI->getANI($domain, $ani_prefix, $limit, $offset);
    }
    if ($arrANI === false) {
        $error = _tr("Error to obtain ANI") . $pANI->errMsg;
        $arrANI = array();
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
        $smarty->assign("SHOW_DIV_ERROR", "1");
    }
    foreach ($arrANI as $row) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$row["organization_domain"]];
        }
        $arrTmp[] = $row["name"];
        $arrTmp[] = "<input type='text' style='width:60px; text-align:center;' id='text#{$row['organization_domain']}#{$row['trunkid']}' value='{$row['ani_prefix']}' />&nbsp;&nbsp;\n                     <input type='button' id='button#{$row['organization_domain']}#{$row['trunkid']}' value='" . _tr("Save") . "' />";
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) == 0) {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
        $smarty->assign("SHOW_DIV_ERROR", "1");
    }
    if ($credentials['userlevel'] == 'superadmin') {
        $_POST["organization"] = $domain;
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
    }
    $_POST["ani_prefix"] = $ani_prefix;
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("ANI Prefix") . " = " . $ani_prefix, $_POST, array("ani_prefix" => ""));
    $arrFormElements = createFieldFilter($arrOrgz);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    return $oGrid->fetchGrid(array(), $arrData);
}
예제 #5
0
function reportGroup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $userLevel1, $userAccount, $idOrganization)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $idOrgFil = getParameter("idOrganization");
    if ($userLevel1 == "superadmin") {
        if (!empty($idOrgFil)) {
            $cntGroups = $pACL->getNumGroups($idOrgFil);
        } else {
            $idOrgFil = 0;
            //opcion default se muestran todos los grupos
            $cntGroupsMO = $pACL->getNumGroups(1);
            //obtenemos en numero de grupos que pertenecen a
            //la organizacion 1 y lo restamos del total de grupos
            $cntGroups = $pACL->getNumGroups() - $cntGroupsMO;
        }
    } else {
        $idOrgFil = $idOrganization;
        $cntGroups = $pACL->getNumGroups($idOrganization);
    }
    if ($cntGroups === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr($pACL->errMsg));
        $total = 0;
    } else {
        $total = $cntGroups;
    }
    //url
    $url['menu'] = $module_name;
    $url['idOrganization'] = $idOrgFil;
    $total = $total == NULL ? 0 : $total;
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $oGrid->getEnd();
    $oGrid->setURL($url);
    $oGrid->setTitle(_tr('Group List'));
    $oGrid->setIcon("web/apps/{$module_name}/images/system_groups.png");
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    if ($userLevel1 == "superadmin") {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Group Name");
    $arrColumns[] = _tr("Group Description");
    $oGrid->setColumns($arrColumns);
    if ($idOrgFil != 0) {
        $Groups = $pACL->getGroupsPaging($limit, $offset, $idOrgFil);
    } else {
        $Groups = $pACL->getGroupsPaging($limit, $offset);
    }
    $arrData = array();
    foreach ($Groups as $group) {
        if ($group[3] != 1) {
            $arrTmp = array();
            if ($userLevel1 == "superadmin") {
                $orgz = $pORGZ->getOrganizationById($group[3]);
                $arrTmp[] = htmlentities($orgz["name"], ENT_COMPAT, 'UTF-8');
                //organization
            }
            $arrTmp[] = "&nbsp;<a href='?menu=grouplist&action=view&id=" . $group[0] . "'>" . $group[1] . "</a>";
            //id,group name
            $arrTmp[] = _tr($group[2]);
            //description
            $arrData[] = $arrTmp;
        }
    }
    if ($pORGZ->getNumOrganization(array()) > 0) {
        global $arrPermission;
        if (in_array('create_group', $arrPermission)) {
            $oGrid->addNew("create_group", _tr("Create New Group"));
        }
        if ($userLevel1 == "superadmin") {
            $arrOrgz = array(0 => _tr("all"));
            foreach ($pORGZ->getOrganization(array()) as $value) {
                if ($value["id"] != 1) {
                    $arrOrgz[$value["id"]] = $value["name"];
                }
            }
            $arrFormElements = createFieldFilter($arrOrgz);
            $oFilterForm = new paloForm($smarty, $arrFormElements);
            $_POST["idOrganization"] = $idOrgFil;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$idOrgFil], $_POST, array("idOrganization" => 0), true);
            $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
            $oGrid->showFilter(trim($htmlFilter));
        }
    } else {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("You need have created at least one organization before you can create a new group"));
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    return $contenidoModulo;
}
예제 #6
0
function reportOutbound($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $reorderRoute = false)
{
    global $arrPermission;
    $pORGZ = new paloSantoOrganization($pDB);
    $error = "";
    $arrOrgz = array();
    $domain = getParameter("organization");
    $name = getParameter("name");
    // outbound name
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['name'] = $name;
    if ($credentials['userlevel'] == "superadmin") {
        if (isset($domain) && $domain != "all") {
            $pOutbound = new paloSantoOutbound($pDB, $domain);
        } else {
            $pOutbound = new paloSantoOutbound($pDB, "");
        }
        $total = $pOutbound->getNumOutbound($domain, $name);
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    } else {
        $pOutbound = new paloSantoOutbound($pDB, $domain);
        $total = $pOutbound->getNumOutbound($domain, $name);
    }
    if ($total === false) {
        $error = $pOutbound->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $arrGrid = array("title" => _tr('Outbound Routes List'), "url" => $url, "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total);
    $arrColumns = array();
    $arrColumns[] = _tr("Order");
    $arrColumns[] = _tr("Route Name");
    if ($credentials['userlevel'] == "superadmin") {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Route CID");
    $arrColumns[] = _tr("Route Password");
    $arrColumns[] = _tr("Time Group");
    $oGrid->setColumns($arrColumns);
    $arrOutbound = array();
    $arrData = array();
    if ($total != 0) {
        $arrOutbound = $pOutbound->getOutbounds($domain, $name, $limit, $offset);
    }
    if ($arrOutbound === false) {
        $error = _tr("Error to obtain outbounds") . $pOutbound->errMsg;
        $arrOutbound = array();
    }
    $create = in_array('create', $arrPermission);
    $edit = in_array('edit', $arrPermission);
    foreach ($arrOutbound as $outbound) {
        $arrTmp = array();
        if ($edit) {
            $arrTmp[] = fieldOrden($arrOutbound, $outbound["seq"], $outbound["id"], $outbound["organization_domain"]);
        } else {
            $arrTmp[] = $outbound["seq"];
        }
        $arrTmp[] = "&nbsp;<a href='?menu=outbound_route&action=view&id_outbound=" . $outbound['id'] . "&organization={$outbound["organization_domain"]}'>" . htmlentities($outbound['routename'], ENT_QUOTES, "UTF-8") . "</a>";
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$outbound["organization_domain"]];
        }
        $arrTmp[] = $outbound["outcid"];
        $arrTmp[] = $outbound["routepass"];
        if (isset($outbound["time_group_id"])) {
            $query = "SELECT name from time_group where id=?";
            $result = $pDB->getFirstRowQuery($query, true, array($outbound["time_group_id"]));
            if ($result != false) {
                $arrTmp[] = $result["name"];
            } else {
                $arrTmp[] = "";
            }
        }
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Outbound Route"), array_slice($arrOrgz, 1), $selected = null, "create_outbound", $onchange_select = null);
            } else {
                $oGrid->addNew("create_outbound", _tr("ADD Outbound Route"));
            }
        }
        if ($credentials['userlevel'] == "superadmin") {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["name"] = $name;
        //outbound_route name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
예제 #7
0
function reportQueue($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $queue_name = getParameter("queue_name");
    $pQueue = new paloQueuePBX($pDB, $domain);
    $queue_number = getParameter("queue_number");
    if (isset($queue_number) && $queue_number != '') {
        $expression = $pQueue->getRegexPatternFromAsteriskPattern($queue_number);
        if ($expression === false) {
            $queue_number = '';
        }
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['queue_number'] = $queue_number;
    //queue_number
    $url['queue_name'] = $queue_name;
    //queue_name
    $total = $pQueue->getTotalQueues($domain, $queue_number, $queue_name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pQueue->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Queues List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    if ($credentials['userlevel'] == 'superadmin') {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Queue Number");
    $arrColumns[] = _tr("Queue Name");
    $arrColumns[] = _tr("Password");
    $arrColumns[] = _tr("Record Call");
    $arrColumns[] = _tr("Strategy");
    $arrColumns[] = _tr("Timeout Queue");
    $arrColumns[] = _tr("Timeout Agent");
    $oGrid->setColumns($arrColumns);
    $arrData = array();
    $arrQueues = array();
    if ($total != 0) {
        $arrQueues = $pQueue->getQueues($domain, $queue_number, $queue_name, $limit, $offset);
    }
    if ($arrQueues === false) {
        $error = _tr("Error getting queue data. ") . $pQueue->errMsg;
    } else {
        foreach ($arrQueues as $queue) {
            $arrTmp = array();
            if ($credentials['userlevel'] == 'superadmin') {
                $arrTmp[] = $arrOrgz[$queue['organization_domain']];
            }
            $queunumber = $queue["queue_number"];
            $arrTmp[] = "&nbsp;<a href='?menu=queues&action=view&qname=" . $queue['name'] . "&organization={$queue['organization_domain']}'>" . $queunumber . "</a>";
            $arrTmp[] = htmlentities($queue["description"], ENT_QUOTES, "UTF-8");
            $arrTmp[] = $queue["password_detail"];
            $arrTmp[] = isset($queue["monitor_format"]) ? "yes" : "no";
            $arrTmp[] = $queue["strategy"];
            $arrTmp[] = $queue["timeout_detail"] == "0" ? "unlimited" : $queue["timeout_detail"];
            $arrTmp[] = $queue["timeout"];
            /*$result=getInfoQueue();
              $arrTmp[6]=$result["logged"];
              $arrTmp[6]=$result["free"];*/
            $arrData[] = $arrTmp;
        }
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("Create New Queue"), array_slice($arrOrgz, 1), $selected = null, "create_queue", $onchange_select = null);
            } else {
                $oGrid->addNew("create_queue", _tr("Create New Queue"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["queue_number"] = $queue_number;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Number") . " = " . $queue_number, $_POST, array("queue_number" => ""));
        $_POST["queue_name"] = $queue_name;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Name") . " = " . $queue_name, $_POST, array("queue_name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
예제 #8
0
function saveNewUser($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentiasls)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $exito = false;
    $continuar = true;
    $errorImg = "";
    $renameFile = "";
    if ($pORGZ->getNumOrganization(array()) == 0) {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create a new organization so you can create user"));
        return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    }
    $arrOrgz = array(0 => "Select one Organization");
    if ($arrCredentiasls['userlevel'] == "superadmin") {
        $orgTmp = $pORGZ->getOrganization(array());
    } else {
        $orgTmp = $pORGZ->getOrganization(array("id" => $arrCredentiasls['id_organization']));
    }
    if ($orgTmp === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr($pORGZ->errMsg));
        return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    } elseif (count($orgTmp) == 0) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("You need yo have at least one organization created before you can create a user"));
        return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    } else {
        foreach ($orgTmp as $value) {
            $arrOrgz[$value["id"]] = $value["name"];
        }
    }
    $arrFormOrgz = createFieldForm(array(), array());
    $oForm = new paloForm($smarty, $arrFormOrgz);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k} [{$v['mensaje']}], ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
        return viewFormUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    } else {
        $password1 = getParameter("password1");
        $password2 = getParameter("password2");
        $organization = getParameter("organization");
        if ($password1 == "") {
            $error = _tr("Password can not be empty");
        } else {
            if ($password1 != $password2) {
                $error = _tr("Passwords don't match");
            } else {
                if (!isStrongPassword($password1)) {
                    $error = _tr("Secret can not be empty, must be at least 10 characters, contain digits, uppers and little case letters");
                    $continuar = false;
                }
                if ($arrCredentiasls['userlevel'] == "superadmin") {
                    if ($organization == 0 || $organization == 1) {
                        $error = _tr("You must select a organization");
                        $continuar = false;
                    } else {
                        $idOrganization = $organization;
                    }
                } else {
                    $idOrganization = $arrCredentiasls['id_organization'];
                }
                if ($continuar) {
                    $username = getParameter("username");
                    $name = getParameter("name");
                    $idGrupo = getParameter("group");
                    $extension = getParameter("extension");
                    $fax_extension = getParameter("fax_extension");
                    $md5password = md5($password1);
                    $countryCode = getParameter("country_code");
                    $areaCode = getParameter("area_code");
                    $clidNumber = getParameter("clid_number");
                    $cldiName = getParameter("clid_name");
                    $quota = getParameter("quota");
                    $exito = $pORGZ->createUserOrganization($idOrganization, $username, $name, $md5password, $password1, $idGrupo, $extension, $fax_extension, $countryCode, $areaCode, $clidNumber, $cldiName, $quota, $lastid);
                    $error = $pORGZ->errMsg;
                }
            }
        }
    }
    if ($exito) {
        //esta seccion es solo si el usuario quiere subir una imagen a su cuenta
        if (isset($_FILES['picture']['name']) && $_FILES['picture']['name'] != "") {
            uploadImage($lastid, $pDB, $errorImg);
        }
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("User has been created successfully") . "</br>" . $errorImg);
        //mostramos el mensaje para crear los archivos de ocnfiguracion
        $pAstConf = new paloSantoASteriskConfig($pDB);
        $orgTmp2 = $pORGZ->getOrganization(array("id" => $idOrganization));
        $pAstConf->setReloadDialplan($orgTmp2[0]["domain"], true);
        $content = reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    } else {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", $error);
        $content = viewFormUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    }
    return $content;
}
예제 #9
0
function reportExten($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pExten = new paloSantoExtensions($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $error = '';
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $extension = getParameter("extension");
    if (isset($extension) && $extension != '') {
        $pPBX = new paloAsteriskDB($pDB);
        $expression = $pPBX->getRegexPatternFromAsteriskPattern($extension);
        if ($expression === false) {
            $extension = '';
        }
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['extension'] = $extension;
    $total = $pExten->getNumExtensions($domain, $extension);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pExten->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Extensions List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Extension");
    $arrColum[] = _tr("Caller ID");
    $arrColum[] = _tr("Technology");
    $arrColum[] = _tr("Device");
    $arrColum[] = _tr("Context");
    $arrColum[] = _tr("User");
    $arrColum[] = _tr("Voicemail");
    $arrColum[] = _tr("Recording In") . " / " . _tr("Recording Out");
    $oGrid->setColumns($arrColum);
    $arrExtens = array();
    $arrData = array();
    if ($total != 0) {
        $arrExtens = $pExten->getExtensions($domain, $extension, $limit, $offset);
    }
    if ($arrExtens === false) {
        $error = _tr("Error to obtain extensions") . $pExten->errMsg;
        $arrExtens = array();
    } else {
        foreach ($arrExtens as $exten) {
            $arrTmp = array();
            if ($credentials['userlevel'] == "superadmin") {
                $arrTmp[] = $arrOrgz[$exten["organization_domain"]];
            }
            $arrTmp[] = "&nbsp;<a href='?menu=extensions&action=view&id_exten=" . $exten['id'] . "&organization={$exten['organization_domain']}'>" . $exten["exten"] . "</a>";
            $arrTmp[] = $exten['clid_name'] . " <{$exten['clid_number']}>";
            $arrTmp[] = strtoupper($exten['tech']);
            $arrTmp[] = $exten['device'];
            $arrTmp[] = $exten['context'];
            $query = "Select username from acl_user where extension=? and id_group in (select g.id from acl_group g join organization o on g.id_organization=o.id where o.domain=?)";
            $result = $pDB->getFirstRowQuery($query, false, array($exten["exten"], $exten["organization_domain"]));
            if ($result != false) {
                $arrTmp[] = $result[0];
            } else {
                $arrTmp[] = _tr("Nobody");
            }
            if (isset($exten["voicemail"])) {
                if ($exten["voicemail"] != "novm") {
                    $arrTmp[] = "yes";
                } else {
                    $arrTmp[] = "no";
                }
            } else {
                $arrTmp[] = "no";
            }
            $arrTmp[] = _tr($exten["record_in"]) . " / " . _tr($exten["record_out"]);
            $arrData[] = $arrTmp;
        }
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("Create New Extension"), array_slice($arrOrgz, 1), $selected = null, "create_exten", $onchange_select = null);
            } else {
                $oGrid->addNew("create_exten", _tr("Create New Extension"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["extension"] = $extension;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Extension") . " = " . $extension, $_POST, array("extension" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
예제 #10
0
function reportIVR($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $name = getParameter("name");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != 'superadmin') {
        $domain = $credentials['domain'];
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['name'] = $name;
    if ($credentials['userlevel'] == "superadmin") {
        if (isset($domain) && $domain != "all") {
            $pIVR = new paloIvrPBX($pDB, $domain);
        } else {
            $pIVR = new paloIvrPBX($pDB, "");
        }
        $total = $pIVR->getTotalIvr($domain, $name);
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    } else {
        $arrOrgz = array();
        $pIVR = new paloIvrPBX($pDB, $domain);
        $total = $pIVR->getTotalIvr($domain, $name);
    }
    if ($total === false) {
        $error = $pIVR->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Ivrs List'));
    $oGrid->setUrl($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    if ($credentials['userlevel'] == "superadmin") {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Ivr Name");
    $arrColumns[] = _tr("Timeout");
    $arrColumns[] = _tr("Enable Call Extensions");
    $arrColumns[] = _tr("# Loops");
    $oGrid->setColumns($arrColumns);
    $arrData = array();
    $arrIVR = array();
    if ($total != 0) {
        $arrIVR = $pIVR->getIvrs($domain, $name, $limit, $offset);
    }
    if ($arrIVR === false) {
        $error = _tr("Error getting ivr data.") . $pIVR->errMsg;
    } else {
        foreach ($arrIVR as $ivr) {
            $arrTmp = array();
            if ($credentials['userlevel'] == "superadmin") {
                $arrTmp[] = $arrOrgz[$ivr['organization_domain']];
            }
            $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id_ivr=" . $ivr['id'] . "&organization={$ivr["organization_domain"]}'>" . htmlentities($ivr["name"], ENT_QUOTES, "UTF-8") . "</a>";
            $arrTmp[] = $ivr["timeout"];
            $arrTmp[] = $ivr["directdial"];
            $arrTmp[] = $ivr["loops"];
            $arrData[] = $arrTmp;
        }
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("Create New IVR"), array_slice($arrOrgz, 1), $selected = null, "create_ivr", $onchange_select = null);
            } else {
                $oGrid->addNew("create_ivr", _tr("Create New IVR"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => _tr("all")), true);
        }
        $_POST["name"] = $name;
        //ivr name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
예제 #11
0
function reportOrganization($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pOrganization = new paloSantoOrganization($pDB);
    $pACL = new paloACL($pDB);
    $arrData = array();
    $arrOrgs = false;
    $arrProp["name"] = null;
    $arrProp["domain"] = null;
    $arrProp["state"] = 'all';
    if ($credentials["userlevel"] == "superadmin") {
        $arrProp["name"] = getParameter("fname");
        $arrProp["domain"] = getParameter("fdomain");
        $arrProp["state"] = getParameter("fstate");
        $total = $pOrganization->getNumOrganization($arrProp);
    } else {
        $arrProp["id"] = $credentials["id_organization"];
        $total = $pOrganization->getNumOrganization($arrProp);
    }
    if ($total === false) {
        $total = 0;
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr("Couldn't be retrieved organization data"));
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $url['menu'] = $module_name;
    $url['fname'] = $arrProp["name"];
    $url['fstate'] = $arrProp["state"];
    $url['fdomain'] = $arrProp["domain"];
    $oGrid->setTitle(_tr('Organization List'));
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $arrColumns = array();
    if ($credentials["userlevel"] == "superadmin") {
        $arrColumns[] = "";
        //delete
    }
    if (in_array('access_DID', $arrPermission)) {
        $arrColumns[] = "";
        //did
    }
    $arrColumns[] = _tr("Domain");
    $arrColumns[] = _tr("Name");
    $arrColumns[] = _tr("State");
    $arrColumns[] = _tr("Number of Users");
    $arrColumns[] = _tr("Country Code") . " / " . _tr("Area Code");
    $arrColumns[] = _tr("Email Qouta") . " (MB)";
    $oGrid->setColumns($arrColumns);
    $arrDatosGrid = array();
    if ($total != 0) {
        if ($credentials["userlevel"] == "superadmin") {
            $arrProp["limit"] = $limit;
            $arrProp["offset"] = $offset;
            $arrOrgs = $pOrganization->getOrganization($arrProp);
        } else {
            $arrOrgs = $pOrganization->getOrganization($arrProp);
        }
    }
    if ($arrOrgs === FALSE) {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr($pOrganization->errMsg));
    } else {
        foreach ($arrOrgs as $value) {
            $arrTmp = array();
            if ($credentials["userlevel"] == "superadmin") {
                $arrTmp[] = "<input type='checkbox' class='chk_id' value='{$value['id']}' />";
                //checkbox selet
            }
            if (in_array('access_DID', $arrPermission)) {
                $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=reportDIDs&domain=" . $value['domain'] . "'>" . _tr("Assign DIDs") . "</a>";
                //did
            }
            $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id=" . $value['id'] . "'>" . htmlentities($value['domain'], ENT_COMPAT, 'UTF-8') . "</a>";
            $arrTmp[] = htmlentities($value['name'], ENT_COMPAT, 'UTF-8');
            if ($value['state'] == 'active') {
                $arrTmp[] = "<span class='font-green'>" . _tr($value['state']) . "</span>";
            } elseif ($value['state'] == 'suspend') {
                $arrTmp[] = "<span class='font-orange'>" . _tr($value['state']) . "</span>";
            } else {
                $arrTmp[] = "<span class='font-red'>" . _tr($value['state']) . "</span>";
            }
            $arrTmp[] = $pOrganization->getNumUserByOrganization($value['id']);
            $cCode = $pOrganization->getOrganizationProp($value['id'], "country_code");
            $aCode = $pOrganization->getOrganizationProp($value['id'], "area_code");
            $eQuota = $pOrganization->getOrganizationProp($value['id'], "email_quota");
            $tmpcode = $cCode === false ? _tr("NONE") : $cCode;
            $tmpcode .= $aCode === false ? _tr("NONE") : " / " . $aCode;
            $arrTmp[] = $tmpcode;
            $arrTmp[] = $eQuota === false ? _tr("NONE") : $eQuota;
            $arrDatosGrid[] = $arrTmp;
        }
    }
    if ($credentials['userlevel'] == "superadmin") {
        $oGrid->addNew("new_organization", _tr("Create Organization"));
        $stateButton = '<select name="state_orgs" id="state_orgs">';
        $stateButton .= '<option label="' . _tr("Suspend") . '" value="suspend">' . _tr("Suspend") . '</option>';
        $stateButton .= '<option label="' . _tr("Unsuspend") . '" value="unsuspend">' . _tr("Unsuspend") . '</option>';
        $stateButton .= '<option label="' . _tr("Terminate") . '" value="terminate">' . _tr("Terminate") . '</option>';
        $stateButton .= "</select>";
        $stateButton .= '<input type="button" name="button_state" value="' . _tr("Change State") . '" onclick="change_state();" class="neo-table-action">';
        $stateButton .= '<input type="hidden" name="msg_ch_alert" id="msg_ch_alert" value="' . _tr("Are you sure you wish change the states of checked organizations to: ") . "STATE_NAME\n" . _tr("This process can take several minutes") . '">';
        $oGrid->addHTMLAction($stateButton);
        $oGrid->addButtonAction("del_orgs", _tr("Delete"), "{$arrConf['webCommon']}/images/delete5.png", "delete_orgs();");
        //filter
        $smarty->assign('USERLEVEL', $credentials['userlevel']);
        $smarty->assign('SEARCH', "<input name='search_org' type='submit' class='button' value='" . _tr('Search') . "'>");
        $arrState = array("all" => _tr("All"), "active" => _tr("Active"), "suspend" => _tr("Suspend"), "terminate" => _tr("terminate"));
        $_POST['fname'] = $arrProp['name'];
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("fname") . " = {$arrProp['name']}", $_POST, array("fname" => ''));
        $_POST['fdomain'] = $arrProp['domain'];
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("fdomain") . " = {$arrProp['domain']}", $_POST, array("fdomain" => ''));
        $_POST['fstate'] = isset($arrState[$arrProp['state']]) ? $arrProp['state'] : 'all';
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("State") . " = " . $arrState[$_POST['fstate']], $_POST, array("fstate" => 'all'), true);
        $arrFormFilter = createFilterForm($arrState);
        $oFilterForm = new paloForm($smarty, $arrFormFilter);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    }
    $content = $oGrid->fetchGrid(array(), $arrDatosGrid);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $content = $mensaje . $content;
    return $content;
}
예제 #12
0
function listarFaxes(&$smarty, $module_name, $local_templates_dir, $pDB, $credentials)
{
    global $arrPermission;
    $pORGZ = new paloSantoOrganization($pDB);
    $smarty->assign(array('SEARCH' => _tr('Search')));
    $smarty->assign('USERLEVEL', $credentials['userlevel']);
    $arrOrgz = array(0 => "all");
    $organization = getParameter('organization');
    if ($credentials['userlevel'] == 'superadmin') {
        if (empty($organization)) {
            $organization = 0;
        }
        if ($pORGZ->getNumOrganization(array()) > 0) {
            foreach ($pORGZ->getOrganization(array()) as $value) {
                $arrOrgz[$value["id"]] = $value["name"];
            }
        }
    } else {
        $tmpOrg = $pORGZ->getOrganizationById($credentials['id_organization']);
        $arrOrgz[$tmpOrg["id"]] = $tmpOrg['name'];
        $organization = $credentials['id_organization'];
    }
    $oFax = new paloFaxVisor($pDB);
    // Generación del filtro
    $oFilterForm = new paloForm($smarty, getFormElements($arrOrgz));
    // Parámetros base y validación de parámetros
    $url = array('menu' => $module_name);
    $paramFiltroBase = $paramFiltro = array('name_company' => '', 'fax_company' => '', 'date_fax' => NULL, 'filter' => 'All');
    foreach (array_keys($paramFiltro) as $k) {
        if (!is_null(getParameter($k))) {
            $paramFiltro[$k] = getParameter($k);
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    $arrType = array("All" => _tr('All'), "In" => _tr('in'), "Out" => _tr('out'));
    if ($credentials['userlevel'] == 'superadmin') {
        $_POST["organization"] = $organization;
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$organization], $_POST, array("organization" => 0), true);
        //organization
    }
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Name") . " = " . $paramFiltro['name_company'], $paramFiltro, array("name_company" => ""));
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Fax") . " = " . $paramFiltro['fax_company'], $paramFiltro, array("fax_company" => ""));
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Fax Date") . " = " . $paramFiltro['date_fax'], $paramFiltro, array("date_fax" => NULL));
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type Fax") . " = " . $arrType[$paramFiltro['filter']], $paramFiltro, array("filter" => "All"), true);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro);
    if (!$oFilterForm->validateForm($paramFiltro)) {
        $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion))));
        $paramFiltro = $paramFiltroBase;
    }
    $url = array_merge($url, $paramFiltro);
    $oGrid->setTitle(_tr("Fax Viewer"));
    $oGrid->setIcon("web/apps/{$module_name}/images/kfaxview.png");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->setURL($url);
    $arrData = NULL;
    if ($organization == 0) {
        $total = $oFax->obtener_cantidad_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']);
    } else {
        $total = $oFax->obtener_cantidad_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']);
    }
    if ($total === false) {
        $total = 0;
        $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
    }
    $delete = in_array('delete_fax', $arrPermission);
    $edit = in_array('edit_fax', $arrPermission);
    $limit = 20;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    if ($delete) {
        $columns[] = "<input type='checkbox' class='checkall'/>";
    }
    if ($credentials['userlevel'] == 'superadmin') {
        $columns[] = _tr('Organization');
    }
    $columns[] = _tr('Type');
    $columns[] = _tr('File');
    $columns[] = _tr('Fax Cid Name');
    $columns[] = _tr('Fax Cid Number');
    $columns[] = _tr('Fax Destiny');
    $columns[] = _tr('Fax Date');
    $columns[] = _tr('Status');
    if ($edit) {
        $columns[] = _tr('Options');
    }
    $oGrid->setColumns($columns);
    if ($total > 0) {
        if ($organization == 0) {
            $arrResult = $oFax->obtener_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']);
        } else {
            $arrResult = $oFax->obtener_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']);
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
        } else {
            foreach ($arrResult as $fax) {
                foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax') as $k) {
                    $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8');
                }
                $doc = explode(".", $fax['pdf_file']);
                $iddoc = $doc[0];
                $arrTmp = array();
                if ($delete) {
                    $arrTmp[] = '<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />';
                }
                if ($credentials['userlevel'] == 'superadmin') {
                    $arrTmp[] = 'ttt';
                }
                //$arrOrg[$fax['id_organization']];
                $arrTmp[] = _tr($fax['type']);
                $arrTmp[] = strtolower($fax['type']) == 'in' || strpos($fax['pdf_file'], '.pdf') !== FALSE ? "<a href='?menu={$module_name}&action=download&id=" . $fax['id'] . "&rawmode=yes'>" . $fax['pdf_file'] . "</a>" : $fax['pdf_file'];
                $arrTmp[] = $fax['company_name'];
                $arrTmp[] = $fax['company_fax'];
                $arrTmp[] = $fax['destiny_name'] . " - " . $fax['destiny_fax'];
                $arrTmp[] = $fax['date'];
                $arrTmp[] = _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']);
                if ($edit) {
                    $arrTmp[] = "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>";
                }
                $arrData[] = $arrTmp;
            }
        }
    }
    $oGrid->setData($arrData);
    if ($delete) {
        $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete"));
    }
    $oGrid->showFilter($htmlFilter);
    return $oGrid->fetchGrid();
}
예제 #13
0
function reportConference($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pORGZ = new paloSantoOrganization($pDB);
    $error = "";
    $date = date("Y-m-d H:i");
    $state_conf = getParameter("state_conf");
    $name_conf = getParameter("name_conf");
    $type_conf = getParameter("type_conf");
    if (empty($state_conf)) {
        $state_conf = "all";
    }
    if (empty($type_conf)) {
        $type_conf = "both";
    }
    if (is_null($name_conf)) {
        $name_conf = "";
    }
    if ($credentials['userlevel'] == "superadmin") {
        $domain = getParameter("organization");
        $domain = empty($domain) ? 'all' : $domain;
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    } else {
        $arrOrgz = array();
        $domain = $credentials['domain'];
    }
    $url['menu'] = $module_name;
    $url["state_conf"] = $state_conf;
    $url["name_conf"] = $name_conf;
    $url["type_conf"] = $type_conf;
    $url['date'] = $date;
    $pconference = new paloConference($pDB, $domain);
    $total = $pconference->getTotalConference($domain, $date, $state_conf, $type_conf, $name_conf);
    if ($total === false) {
        $error = $pconference->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('Conference'));
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    //permission
    $delete = in_array("delete_conf", $arrPermission);
    $create = in_array("create_conf", $arrPermission);
    $edit = in_array("edit_conf", $arrPermission);
    $invite_part = in_array("admin_conference_participant", $arrPermission);
    if ($delete) {
        $arrColum[] = _tr("");
    }
    $arrColum[] = _tr("Name");
    $arrColum[] = _tr("Room Number");
    $arrColum[] = _tr("Period");
    $arrColum[] = _tr("Participants / MaxUsers");
    $arrColum[] = _tr("Status");
    $oGrid->setColumns($arrColum);
    $arrData = array();
    $arrconference = array();
    if ($total != 0) {
        $arrconference = $pconference->getConferesPagging($domain, $date, $limit, $offset, $state_conf, $type_conf, $name_conf);
    }
    $session = getSession();
    if ($arrconference === false) {
        $error = _tr("Error getting conference data.") . $pconference->errMsg;
    } else {
        foreach ($arrconference as $conf) {
            $arrTmp = array();
            if ($delete) {
                $arrTmp[] = "<input type='checkbox' name='confdel[]' value='{$conf['bookid']}'/>";
                //delete
            }
            if ($edit) {
                $arrTmp[] = "<a href='?menu={$module_name}&action=view&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}'>" . htmlentities($conf["name"], ENT_QUOTES, "UTF-8") . "</a>";
                //name
            } else {
                $arrTmp[] = htmlentities($conf["name"], ENT_QUOTES, "UTF-8");
            }
            $arrTmp[] = $conf["ext_conf"];
            //roomnumber
            $perid = "No Set";
            if (!empty($conf["startTime"]) && $conf["startTime"] != "1900-01-01 12:00:00") {
                $perid = $conf["startTime"] . " - " . $conf["endtime"];
            }
            $arrTmp[] = $perid;
            //period
            $max = empty($conf["maxusers"]) ? "unlimited" : $conf["maxusers"];
            $participants = "<spam class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max} </spam>";
            $status = "<spam class='conf_status'></spam>";
            if ($perid != "No Set") {
                $date = time();
                if ($date >= strtotime($conf["startTime"]) && $date <= strtotime($conf["endtime"])) {
                    if ($invite_part) {
                        $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>";
                    }
                    $status = "<spam class='conf_status' style='color:green'/>" . _tr("In Progress") . "</spam>";
                } else {
                    if ($date < strtotime($conf["startTime"])) {
                        $status = "<spam class='conf_status'>" . _tr("Future") . "</spam>";
                    } else {
                        $status = "<spam class='conf_status'>" . _tr("Past") . "</spam>";
                    }
                }
            } else {
                if ($invite_part) {
                    $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>";
                }
            }
            $arrTmp[] = $participants;
            $arrTmp[] = $status;
            $arrData[] = $arrTmp;
            //se usa para comprobar si ha habido cambios en el estado de las conferencias
            $session['conference']["conf_list"][$conf['bookid']] = array($participants, $status);
        }
    }
    //se escribe en session el estado actual de las conferencias
    putSession($session);
    //filters
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if ($create) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Conference"), array_slice($arrOrgz, 1), $selected = null, "create_conference", $onchange_select = null);
            } else {
                $oGrid->addNew("create_conference", _tr("ADD Conference"));
            }
        }
        if ($delete) {
            $oGrid->deleteList(_tr("Are you sure you wish to delete conference (es)?"), "delete_conference", _tr("Delete"));
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        //arreglo usado para formar los elementos del filtro
        $arrState = array("all" => _tr("All"), "past" => _tr("Past Conference"), "current" => _tr("Current  Conference"), "future" => _tr("Future Conference"));
        $arrType = array("both" => _tr("Both"), "yes" => _tr("Schedule"), "no" => _tr("No Schedule"));
        $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("State") . " = " . $arrState[$state_conf], $state_conf, array("state_conf" => "all"), true);
        $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Name") . " = " . $name_conf, $name_conf, array("name_conf" => ""));
        $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Type") . " = " . $arrType[$type_conf], $type_conf, array("type_conf" => "both"), true);
        $smarty->assign("SHOW", _tr("Show"));
        $arrFormElements = createFieldFilter($arrState, $arrType, $arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $contenidoModulo .= "<input type='hidden' name='grid_limit' id='grid_limit' value='{$limit}'>";
    $contenidoModulo .= "<input type='hidden' name='grid_offset' id='grid_offset' value='{$offset}'>";
    $contenidoModulo .= "<input type='hidden' name='conf_action' id='conf_action' value='report'>";
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
예제 #14
0
function reportRG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $rg_name = getParameter("rg_name");
    $pRG = new paloSantoRG($pDB, $domain);
    $rg_number = getParameter("rg_number");
    if (isset($rg_number) && $rg_number != '') {
        $expression = $pRG->getRegexPatternFromAsteriskPattern($rg_number);
        if ($expression === false) {
            $rg_number = '';
        }
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['rg_number'] = $rg_number;
    //ring group number
    $url['rg_name'] = $rg_name;
    //ring group number
    $total = $pRG->getNumRG($domain, $rg_number, $rg_name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pRG->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setTitle(_tr('RG List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Number");
    $arrColum[] = _tr("Name");
    $arrColum[] = _tr("Strategy");
    $arrColum[] = _tr("Ring Time");
    $arrColum[] = _tr("Ignore CF");
    $arrColum[] = _tr("Skip Busy Extensions");
    $arrColum[] = _tr("Default Destination");
    $oGrid->setColumns($arrColum);
    $arrRG = array();
    $arrData = array();
    if ($total != 0) {
        $arrRG = $pRG->getRGs($domain, $rg_number, $rg_name, $limit, $offset);
    }
    if ($arrRG === false) {
        $error = _tr("Error to obtain Ring Groups") . $pRG->errMsg;
        $arrRG = array();
    }
    foreach ($arrRG as $rg) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$rg["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu=ring_group&action=view&id_rg=" . $rg['id'] . "&organization={$rg['organization_domain']}'>" . $rg['rg_number'] . "</a>";
        $arrTmp[] = htmlentities($rg["rg_name"], ENT_QUOTES, "UTF-8");
        $arrTmp[] = $rg["rg_strategy"];
        $arrTmp[] = $rg["rg_time"];
        $arrTmp[] = $rg["rg_cf_ignore"];
        $arrTmp[] = $rg["rg_skipbusy"];
        $arrTmp[] = $rg["destination"];
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Ring Group"), array_slice($arrOrgz, 1), $selected = null, "create_rg", $onchange_select = null);
            } else {
                $oGrid->addNew("create_rg", _tr("ADD Ring Group"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["rg_number"] = $rg_number;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Number") . " = " . $rg_number, $_POST, array("rg_number" => ""));
        $_POST["rg_name"] = $rg_name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Name") . " = " . $rg_name, $_POST, array("rg_name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
        $oGrid->showFilter(trim($htmlFilter));
    } else {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}