function reportContact($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { global $arrCredentials; $coreContact = new coreContact($pDB); $jsonObject = new PaloSantoJSON(); //obtener los parametros del filtro $filters['ftype_contacto'] = getParameter('ftype_contacto'); $filters['filter'] = getParameter('filter'); $filters['filter_value'] = getParameter('filter_value'); $validatedfilters = $coreContact->validatedFilters($filters); $total = $coreContact->getTotalContactsByFilter($validatedfilters); if ($total === false) { $total = 0; $smarty->assign("MSG_ERROR_FIELD", _tr("Error en database")); $jsonObject->set_error($coreContact->sqlContact->getErrorMsg()); return $jsonObject->createJSON(); } $limit = 7; $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); $currentPage = $oGrid->calculateCurrentPage(); $numPage = $oGrid->calculateNumPage(); $url['menu'] = $module_name; $url['ftype_contacto'] = $filters['ftype_contacto']; $url['filter'] = $filters['filter']; $url['filter_value'] = $filters['filter_value']; $oGrid->setTitle(_tr('Contacts List')); $oGrid->setURL($url); $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("ContactsExport")); $arrColumn = array(); if ($oGrid->isExportAction()) { // arreglo de columnas para mostrar en los archivos de exportacion $arrColumn[] = 'Name'; //if($validatedfilters['table']=="internal"){ if ($validatedfilters['table'] == "internal") { $arrColumn[] = 'Ext'; } else { $arrColumn[] = 'Phone'; } $arrColumn[] = 'Email'; $arrColumn[] = 'Type Contact'; } else { //arreglo de columnas para mostrar en la grilla $arrColumn[] = "<span class='glyphicon glyphicon-check'></span>"; $arrColumn[] = _tr('Picture'); $arrColumn[] = _tr('Name'); //if($validatedfilters['table']=="internal"){ $arrColumn[] = _tr('Ext / Phone'); $arrColumn[] = _tr('Email'); $arrColumn[] = _tr('Call'); $arrColumn[] = _tr('Transfer'); $arrColumn[] = _tr('Type Contact'); } $oGrid->setColumns($arrColumn); $validatedfilters = $coreContact->validatedFilters($filters); //enviamos como parametros limit, offset y los filtros validados $contacts = $coreContact->getContacts($limit, $offset, $validatedfilters); $arrDatosGrid = array(); if ($contacts === false) { $smarty->assign("MSG_ERROR_FIELD", $coreContact->getErrorMsg()); $jsonObject->set_error($coreContact->getErrorMsg()); return $jsonObject->createJSON(); } else { if ($oGrid->isExportAction()) { // data para exportar en los archivos foreach ($contacts as $value) { $tmp = array(); $tmp[] = $value['name']; if (empty($value['work_phone'])) { $tmp[] = "N/A"; } else { $tmp[] = $value['work_phone']; } if (!empty($value['username'])) { $tmp[] = $value['username']; } else { $tmp[] = "N/A"; } if ($validatedfilters['table'] != "internal") { if ($value['status'] == "isPrivate") { $tmp[] = _tr('Private'); } else { $tmp[] = _tr('Public'); } } else { $tmp[] = _tr('Public'); } $arrDatosGrid[] = $tmp; } } else { //data para mostrar en las grillas foreach ($contacts as $value) { $tmp = array(); if ($validatedfilters['table'] == "internal") { $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}' disabled >"; } else { if ($arrCredentials['idUser'] == $value['iduser']) { $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}'>"; } else { $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}' disabled >"; } } if ($validatedfilters['table'] == "internal") { $tmp[] = "<img id='img-users' width='16' height='16' alt='image' src='index.php?menu=_elastixutils&action=getImage&ID={$value['id']}&rawmode=yes'/>"; } else { $tmp[] = "<img id='img-users' width='16' height='16' alt='image' src='index.php?menu={$module_name}&action=getImageExtContact&image={$value['picture']}&rawmode=yes'/>"; } if ($validatedfilters['table'] == "internal") { $tmp[] = htmlentities($value['name'], ENT_QUOTES, "UTF-8"); } else { if ($arrCredentials['idUser'] == $value['iduser']) { $tmp[] = "<a href='#' onclick='editContact({$value['id']})'>" . htmlentities($value['name'], ENT_QUOTES, "UTF-8") . "</a>"; } else { $tmp[] = htmlentities($value['name'], ENT_QUOTES, "UTF-8"); } } if ($validatedfilters['table'] == "internal") { $tmp[] = htmlentities($value['extension'], ENT_QUOTES, "UTF-8"); } else { if (empty($value['work_phone'])) { $tmp[] = "N/A"; } else { $tmp[] = htmlentities($value['work_phone'], ENT_QUOTES, "UTF-8"); } } if (!empty($value['username'])) { $tmp[] = htmlentities($value['username'], ENT_QUOTES, "UTF-8"); } else { $tmp[] = "N/A"; } //$tmp[]="<span class='glyphicon glyphicon-earphone'></span>"; $tmp[] = "<a href='#' onclick='callContact({$value['id']})'><span class='glyphicon glyphicon-earphone'></span></a>"; if ($validatedfilters['table'] == "internal") { //$tmp[]=_tr('Transfer'); $tmp[] = "<a href='#' onclick='transferCall({$value['id']})'>" . _tr('Transfer') . "</a>"; } else { $tmp[] = "N/A"; } if ($validatedfilters['table'] != "internal") { if ($value['status'] == "isPrivate") { $tmp[] = _tr('Private'); } else { $tmp[] = _tr('Public'); } } else { $tmp[] = _tr('Public'); } $arrDatosGrid[] = $tmp; } } } $action = getParameter('action'); if ($action == 'search') { $arrData['url'] = $oGrid->getURL(); $arrData['url'] = str_replace('&', '&', $arrData['url']); $arrData['numPage'] = $numPage; $arrData['currentPage'] = $currentPage; $arrData['content'] = $arrDatosGrid; $jsonObject->set_message($arrData); return $jsonObject->createJSON(); } $oGrid->addButtonAction("new_contact", "<span class='glyphicon glyphicon-user'></span> New Contact", "", "newContact()"); $oGrid->addButtonAction("remove_contact", "<span class='glyphicon glyphicon-remove'></span> Delete Contacts", "", "deleteContacts('" . _tr("Are you sure you wish to delete the contact.") . "')"); $oGrid->addButtonAction("elx_upload_file", "<span class='glyphicon glyphicon-upload'></span> Upload from CSV", "", ""); $oGrid->addButtonAction("elx_export_data", "<span class='glyphicon glyphicon-download'></span>", "", ""); $oGrid->addButtonAction("elx_show_filter", "<span class='glyphicon glyphicon-filter'></span> Show filter", "", ""); $arrayData = array(); $arrFormFilter = createFilterForm(); $oFilterForm = new paloForm($smarty, $arrFormFilter); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", _tr('extension'), $arrayData); $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = actionsReport($arrDatosGrid, $oGrid); return $contenidoModulo; }
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[] = " <a href='?menu={$module_name}&action=reportDIDs&domain=" . $value['domain'] . "'>" . _tr("Assign DIDs") . "</a>"; //did } $arrTmp[] = " <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; }