Beispiel #1
0
function transferCALL($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk)
{
    $padress_book = new paloAdressBook($pDB);
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    if ($id_user != FALSE) {
        $user = $pACL->getUsers($id_user);
        if ($user != FALSE) {
            $extension = $user[0][3];
            if ($extension != "") {
                $id = isset($_GET['id']) ? $_GET['id'] : (isset($_POST['id']) ? $_POST['id'] : "");
                $phone2tranfer = '';
                if (isset($_GET['type']) && $_GET['type'] == 'external') {
                    $contactData = $padress_book->contactData($id, $id_user, "external", false, null);
                    $phone2tranfer = $contactData['telefono'];
                } else {
                    $phone2tranfer = $id;
                }
                $result = $padress_book->Obtain_Protocol_from_Ext($dsnAsterisk, $extension);
                if ($result != FALSE) {
                    $result = $padress_book->TranferCall($dsn_agi_manager, $extension, $phone2tranfer, $result['dial'], $result['description']);
                    if (!$result) {
                        $smarty->assign("mb_title", $arrLang['ERROR'] . ":");
                        $smarty->assign("mb_message", $arrLang["The transfer couldn't be realized, maybe you don't have any conversation now."]);
                    }
                } else {
                    $smarty->assign("mb_title", $arrLang["Validation Error"]);
                    $smarty->assign("mb_message", $padress_book->errMsg);
                }
            }
        } else {
            $smarty->assign("mb_title", $arrLang["Validation Error"]);
            $smarty->assign("mb_message", $padress_book->errMsg);
        }
    } else {
        $smarty->assign("mb_title", $arrLang["Validation Error"]);
        $smarty->assign("mb_message", $padress_book->errMsg);
    }
    $content = report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk);
    return $content;
}
Beispiel #2
0
function updateRow_TicketDelivery($pDB, $pDB_2, $module_name)
{
    $sTicketId = trim(getParameter('ticket_id'));
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $pACL = new paloACL($pDB_2);
    $arrResult = $pTicket_Delivery->getTicket_DeliveryById($sTicketId);
    $img_dir = "modules/{$module_name}/images/";
    $value = $arrResult[0];
    $ticket = '';
    $name = $pACL->getUsers($value['accounting_id']);
    $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
    // show files
    $download = '';
    foreach ($value['ticket_attachment'] as $row) {
        $url = "/modules/agent_console/ajax-attachments-handler.php?download=" . $row['filepath'] . "&name=" . $row['filename'];
        $filename = $row['filename'];
        $download .= "*<a href='{$url}' target='_blank' title='{$filename}'>" . shorten($filename) . "</a><br/>";
    }
    $print = '<a href="javascript:void(0)" onclick="print(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'print.png" title="In phiếu"></a>';
    $enable = $value['isActive'] == '1' ? '<a href="javascript:void(0)" onclick="disable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'disable.png" title="Hủy yêu cầu giao vé"></a>&nbsp;' : '<a href="javascript:void(0)" onclick="enable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'enable.png" title="Tạo lại yêu cầu giao vé"></a>';
    $print .= '&nbsp;&nbsp;' . $enable;
    if ($value['isActive'] == '0') {
        $value['status'] = 'Đã hủy';
    }
    // function show base on status
    switch ($value['status']) {
        case 'Mới':
            $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
            break;
        case 'Đang giao':
            $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Đổi phân công"></a>&nbsp;
                        <a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'result.png" title="Kết quả"></a>';
            break;
        case 'Đã nhận tiền':
            $function = '<a href="javascript:void(1)" onclick="uncollect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'unpaid.png" title="Hủy nhận tiền"></a>';
            break;
        case 'Chờ xử lý':
            $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
            break;
        default:
            $function = '';
    }
    // show ticket code
    foreach ($value['ticket_code'] as $row) {
        $ticket .= $row . '<br>';
    }
    // append html
    $html = '';
    $html .= '<td class="table_data">' . $value['id'] . '</td>';
    $html .= '<td class="table_data">' . $value['customer_name'] . '</td>';
    $html .= '<td class="table_data">' . $value['customer_phone'] . '</td>';
    $html .= '<td class="table_data"><span title="Chi nhánh: ' . $value['office'] . '">' . $value['agent_name'] . '</span></td>';
    $html .= '<td class="table_data">' . '<a href="javascript:void(1)" title="' . $value['deliver_address'] . '"
			                onclick="view_address(\'' . $value['deliver_address'] . '\')">' . shorten($value['deliver_address']) . '
			              </a></td>';
    $html .= '<td class="table_data">' . $value['pay_amount'] . '</td>';
    $html .= '<td class="table_data">' . $ticket . '</td>';
    $html .= '<td class="table_data">' . showStatus($value['status']) . '</td>';
    $html .= '<td class="table_data">' . $value['delivery_name'] . '</td>';
    $html .= '<td class="table_data">' . (is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']))) . '</td>';
    $html .= '<td class="table_data">' . $download . '</td>';
    $html .= '<td class="table_data">' . (is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']))) . '</td>';
    $html .= '<td class="table_data">' . $function . '</td>';
    $html .= '<td class="table_data"><a href="javascript:void(1)" onclick="view_log(\'' . $value['id'] . '\')">
			            <img src="' . $img_dir . 'extra.png" title="Xem chi tiết"></a></td>';
    $html .= '<td class="table_data">' . $print . '</td>';
    return $html;
}
 function deleteUserOrganization($idUser)
 {
     $pACL = new paloACL($this->_DB);
     $pEmail = new paloEmail($this->_DB);
     $pFax = new paloFax($this->_DB);
     $Exito = false;
     //1)se comprueba de que el ID de USUARIO se un numero
     //2)se verifica que exista dicho usuario
     //3)se recompila los datos del usuario de las tablas acl_user y user_properties
     //4)se elimina al usuario de la base
     //5)se elimina la extension de uso del usuario y la extension de fax
     //6)se trata de eliminar la cuenta de fax
     //7)se elimina el buzon de correo
     if (!preg_match('/^[[:digit:]]+$/', "{$idUser}")) {
         $this->errMsg = _tr("User ID is not numeric");
         return false;
     } else {
         $arrUser = $pACL->getUsers($idUser);
         if ($arrUser === false || count($arrUser) == 0) {
             $this->errMsg = _tr("User dosen't exist");
             return false;
         }
     }
     $idDomain = $arrUser[0][4];
     $query = "Select domain from organization where id=?";
     $getDomain = $this->_DB->getFirstRowQuery($query, false, array($idDomain));
     if ($getDomain == false) {
         $this->errMsg = $this->_DB->errMsg;
         return false;
     }
     $pDevice = new paloDevice($getDomain[0], "sip", $this->_DB);
     $arrExten = $pDevice->getExtension($arrUser[0][5]);
     $faxList = $pFax->getFaxList($arrUser[0][6], $getDomain[0]);
     $arrFaxExten = $faxList[0];
     $this->_DB->beginTransaction();
     //tomamos un backup de las extensiones que se van a eliminar de la base astDB por si algo sale mal
     //y ahi que restaurar la extension
     $arrExt = $pDevice->backupAstDBEXT($arrUser[0][5]);
     if ($pDevice->deleteExtension($arrUser[0][5])) {
         if ($pFax->deleteFaxByUser($idUser)) {
             if ($pACL->deleteUser($idUser)) {
                 if ($pEmail->deleteAccount($arrUser[0][1])) {
                     $Exito = true;
                     $this->_DB->commit();
                     $pDevice->tecnologia->prunePeer($arrExten["device"], $arrExten["tech"]);
                     $pDevice->tecnologia->prunePeer($arrFaxExten["device"], $arrFaxExten["tech"]);
                     $pFax->restartService();
                 } else {
                     $this->errMsg = _tr("Email Account cannot be deleted") . $pEmail->errMsg;
                     $this->_DB->rollBack();
                     $pDevice->restoreBackupAstDBEXT($arrExt);
                     $pFax->createFaxFileConfig($arrFaxExten['dev_id'], $getDomain[0]);
                 }
             } else {
                 $this->errMsg = $pACL->errMsg;
                 $this->_DB->rollBack();
                 $pDevice->restoreBackupAstDBEXT($arrExt);
                 $pFax->createFaxFileConfig($arrFaxExten['dev_id'], $getDomain[0]);
             }
         } else {
             $this->errMsg = _tr("Fax cannot be deleted") . $pFax->errMsg;
             $this->_DB->rollBack();
             $pDevice->restoreBackupAstDBEXT($arrExt);
         }
     } else {
         $this->errMsg = _tr("User Extension can't be deleted") . $pDevice->errMsg;
         $this->_DB->rollBack();
         $pDevice->restoreBackupAstDBEXT($arrExt);
     }
     return $Exito;
 }
Beispiel #4
0
function addRemovePortsUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf)
{
    // Listar los usuarios y preparar el combo de usuarios disponibles
    $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
    $id_user = getParameter('id_user');
    $userlist = $pACL->getUsers();
    $cbo_users = array();
    foreach ($userlist as $userinfo) {
        $cbo_users[$userinfo[0]] = $userinfo[1] . ' - ' . $userinfo[2];
    }
    // Verificar si el usuario existe
    if (!is_null($id_user)) {
        if (!isset($cbo_users[$id_user])) {
            Header("Location: ?menu={$module_name}");
            return NULL;
        }
    } else {
        $id_user = $userlist[0][0];
    }
    $ps = new paloSantoPortService($pDB);
    $pk = new paloSantoPortKnockUsers($pDB);
    // Construir lista de puertos autorizados
    $userauth = $pk->listAuthorizationsForUser($id_user);
    $portauths = array();
    if (is_array($userauth)) {
        foreach ($userauth as $auth) {
            $portauths[$auth['id_port']] = $auth['id'];
        }
    }
    $portlist = $ps->ObtainPuertos($ps->ObtainNumPuertos('', ''), 0, '', '');
    $listaIdPuertos = array();
    foreach ($portlist as $portinfo) {
        $listaIdPuertos[] = $portinfo['id'];
    }
    if (isset($_POST['apply']) && is_array($_POST['auth_port'])) {
        // Se requiere aplicar lista de cambios
        $listaNuevosPuertos = array_keys($_POST['auth_port']);
        $bReglasBorradas = FALSE;
        // Borrar la autorización de todos los puertos que ya no aparecen
        $bExito = TRUE;
        foreach ($portauths as $id_port => $id_auth) {
            if (!in_array($id_port, $listaNuevosPuertos)) {
                if (!$pk->deleteAuthorization($id_auth)) {
                    $smarty->assign("mb_title", _tr("ERROR"));
                    $smarty->assign("mb_message", $pk->errMsg);
                    $bExito = FALSE;
                    break;
                } else {
                    unset($portauths[$id_port]);
                    $bReglasBorradas = TRUE;
                }
            }
        }
        if (!$bExito) {
            break;
        }
        // Ingresar la autorización de los puertos nuevos
        foreach ($listaNuevosPuertos as $id_port) {
            if (in_array($id_port, $listaIdPuertos) && !isset($portauths[$id_port])) {
                $id_nueva_auth = $pk->insertAuthorization($id_user, $id_port);
                if (is_null($id_nueva_auth)) {
                    $smarty->assign("mb_title", _tr("ERROR"));
                    $smarty->assign("mb_message", $pk->errMsg);
                    $bExito = FALSE;
                    break;
                } else {
                    $portauths[$id_port] = $id_nueva_auth;
                }
            }
        }
        if ($bExito) {
            if ($bReglasBorradas) {
                // Ejecutar iptables para revocar las reglas del usuario
                require_once "modules/sec_rules/libs/paloSantoRules.class.php";
                $pr = new paloSantoRules($pDB);
                $pr->activateRules();
            }
            Header("Location: ?menu={$module_name}");
            return NULL;
        }
    }
    $data = array();
    if (is_array($portlist)) {
        foreach ($portlist as $portinfo) {
            $id_port = $portinfo['id'];
            $protocol_details = '';
            switch ($portinfo['protocol']) {
                case 'TCP':
                case 'UDP':
                    $protocol_details = (stripos($portinfo['details'], ':') === false ? _tr('Port') : _tr('Ports')) . ' ' . $portinfo['details'];
                    break;
                case 'ICMP':
                    $arr = explode(':', $portinfo['details']);
                    if (isset($arr[1])) {
                        $protocol_details = _tr('Type') . ": " . $arr[0] . " " . _tr('Code') . ": " . $arr[1];
                    }
                    break;
                default:
                    $protocol_details = _tr('Protocol Number') . ': ' . $portinfo['details'];
                    break;
            }
            $data[] = array("<input type=\"checkbox\" name=\"auth_port[{$id_port}]\" " . (isset($portauths[$id_port]) ? 'checked="checked"' : '') . ' />', htmlentities($portinfo['name'], ENT_COMPAT, 'UTF-8'), htmlentities($portinfo['protocol'], ENT_COMPAT, 'UTF-8'), $protocol_details);
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr('Add/remove ports for user'));
    $oGrid->setColumns(array('', _tr('Port'), _tr('Protocol'), _tr('Details')));
    $oGrid->addSubmitAction('apply', _tr('Apply changes'), "modules/{$module_name}/images/Check.png");
    $oGrid->addComboAction('id_user', _tr('User'), $cbo_users, $id_user, 'refresh', 'submit();');
    // Construcción de la vista de puertos autorizados
    $oGrid->pagingShow(false);
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $oGrid->setData($data);
    return $oGrid->fetchGrid();
}
Beispiel #5
0
            // not exists user?
            writeLOG("audit.log", "LOGIN {$user}: Authentication Failure to Web Interface login. Invalid user {$user} from {$_SERVER['REMOTE_ADDR']}.");
        } else {
            writeLOG("audit.log", "LOGIN {$user}: Authentication Failure to Web Interface login. Failed password for {$user} from {$_SERVER['REMOTE_ADDR']}.");
        }
        // Debo hacer algo aquí?
    }
}
// 2) Autentico usuario
if (isset($_SESSION['elastix_user']) && isset($_SESSION['elastix_pass']) && $pACL->authenticateUser($_SESSION['elastix_user'], $_SESSION['elastix_pass'])) {
    if ($pACL->isUserSuperAdmin($_SESSION['elastix_user'])) {
        header("Location: admin/index.php");
    }
    $idUser = $pACL->getIdUser($_SESSION['elastix_user']);
    $pMenu = new paloMenu($arrConf['elastix_dsn']['elastix']);
    $arrUser = $pACL->getUsers($idUser);
    foreach ($arrUser as $value) {
        $arrFill["username"] = $value[1];
        $arrFill["name"] = $value[2];
        $arrFill["extension"] = $value[5];
    }
    $smarty->assign("ID_ELX_USER", $idUser);
    $smarty->assign("USER_NAME", $arrFill["name"]);
    $smarty->assign("USER_ESTENSION", $arrFill["extension"]);
    //obtenemos los menu a los que el usuario tiene acceso
    $arrMenuFiltered = $pMenu->filterAuthorizedMenus($idUser);
    $id_organization = $pACL->getIdOrganizationUser($idUser);
    $_SESSION['elastix_organization'] = $id_organization;
    if (!is_array($arrMenuFiltered)) {
        $arrMenuFiltered = array();
    }
Beispiel #6
0
function manejarLogin_HTML($module_name, &$smarty, $sDirLocalPlantillas)
{
    global $arrConf;
    // Acciones para mostrar el formulario, fuera de cualquier acción AJAX
    $smarty->assign(array('FRAMEWORK_TIENE_TITULO_MODULO' => existeSoporteTituloFramework(), 'icon' => 'modules/' . $module_name . '/images/call_center.png', 'title' => "Màn hình chính dành cho tổng đài viên", 'WELCOME_AGENT' => _tr('Welcome to Agent Console'), 'ENTER_USER_PASSWORD' => _tr('Please select your agent number and your extension'), 'USERNAME' => _tr('Agent Number'), 'EXTENSION' => _tr('Extension'), 'CALLBACK_LOGIN' => _tr('Callback Login'), 'PASSWORD' => _tr('Password'), 'CALLBACK_EXTENSION' => _tr('Callback Extension'), 'LABEL_SUBMIT' => _tr('Enter'), 'LABEL_NOEXTENSIONS' => _tr('There are no extensions available. At least one extension is required for agent login.'), 'LABEL_NOAGENTS' => _tr('There are no agents available. At least one agent is required for agent login.'), 'ESTILO_FILA_ESTADO_LOGIN' => 'style="visibility: hidden; position: absolute;"', 'REANUDAR_VERIFICACION' => 0));
    $oPaloConsola = new PaloSantoConsola();
    $listaExtensiones = $oPaloConsola->listarExtensiones();
    $listaAgentes = $oPaloConsola->listarAgentes('static');
    $listaExtensionesCallback = $oPaloConsola->listarAgentes('dynamic');
    $oPaloConsola->desconectarTodo();
    $oPaloConsola = NULL;
    $bNoHayAgentes = count($listaAgentes) == 0 && count($listaExtensionesCallback) == 0;
    if (count($listaAgentes) == 0) {
        $listaAgentes[] = _tr('(no agents)');
    }
    if (count($listaExtensionesCallback) == 0) {
        $listaExtensionesCallback[] = _tr('(no agents)');
    }
    $smarty->assign(array('LISTA_EXTENSIONES' => $listaExtensiones, 'LISTA_AGENTES' => $listaAgentes, 'LISTA_EXTENSIONES_CALLBACK' => $listaExtensionesCallback, 'NO_EXTENSIONS' => count($listaExtensiones) == 0, 'NO_AGENTS' => $bNoHayAgentes));
    // Restaurar el estado de espera en caso de que se refresque la página
    if (!is_null($_SESSION['callcenter']['agente']) && !is_null($_SESSION['callcenter']['extension'])) {
        $smarty->assign(array('ID_AGENT' => $_SESSION['callcenter']['agente'], 'ID_EXTENSION' => $_SESSION['callcenter']['extension'], 'ID_EXTENSION_CALLBACK' => $_SESSION['callcenter']['agente'], 'ESTILO_FILA_ESTADO_LOGIN' => 'style="visibility: visible; position: none;"', 'MSG_ESPERA' => _tr('Logging agent in. Please wait...'), 'REANUDAR_VERIFICACION' => 1));
    } else {
        /* Si el usuario Elastix logoneado coincide con el número de agente de
         * la lista, se coloca este agente como opción por omisión para login.
         */
        if (isset($listaAgentes['Agent/' . $_SESSION['elastix_user']])) {
            $smarty->assign('ID_AGENT', 'Agent/' . $_SESSION['elastix_user']);
        }
        /* Si el usuario Elastix logoneado tiene una extensión y aparece en la
         * lista, se sugiere esta extension como la extensión a usar para 
         * marcar. */
        $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
        $idUser = $pACL->getIdUser($_SESSION['elastix_user']);
        if ($idUser !== FALSE) {
            $tupla = $pACL->getUsers($idUser);
            if (is_array($tupla) && count($tupla) > 0) {
                $sExtension = $tupla[0][3];
                if (isset($listaExtensiones[$sExtension])) {
                    $smarty->assign('ID_EXTENSION', $sExtension);
                }
                foreach (array_keys($listaExtensionesCallback) as $k) {
                    $regs = NULL;
                    if (preg_match('|^(\\w+)/(\\d+)$|', $k, $regs) && $regs[2] == $sExtension) {
                        $smarty->assign('ID_EXTENSION_CALLBACK', $k);
                    }
                }
            }
        }
    }
    $sContenido = $smarty->fetch("{$sDirLocalPlantillas}/hnh_login_agent.tpl");
    return $sContenido;
}
Beispiel #7
0
function refreshRate()
{
    global $arrConf;
    //conexion resource
    $pDB = new paloDB($arrConf['cadena_dsn']);
    $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
    include_once "/var/www/html/modules/overall_setting/libs/paloSantoOverall_setting.class.php";
    $pOverall_setting = new paloSantoOverall_setting($pDB);
    $result = $pOverall_setting->getRate();
    // return json
    if (!$result) {
        $response['action'] = 'error';
        $response['message'] = 'Lỗi: ' . $pOverall_setting->errMsg;
        $json = new Services_JSON();
        Header('Content-Type: application/json');
        return $json->encode($response);
    } else {
        $user = $pACL->getUsers($result[0]['elastix_user_id']);
        //var_dump($pACL->getUsers($result[0]['elastix_user_id']));
        $result[0]['username'] = $user[0][1] . ' (' . $user[0][2] . ')';
        $result[0]['created'] = date('h:i d/m/Y', strtotime($result[0]['created']));
        $json = new Services_JSON();
        Header('Content-Type: application/json');
        return $json->encode($result[0]);
    }
}
function listPortKnockCurrentAuths(&$smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $eth_in = getParameter('eth_in');
    if (is_null($eth_in)) {
        Header("Location: ?menu={$module_name}");
        return NULL;
    }
    include_once "libs/paloSantoACL.class.php";
    $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
    $pk = new paloSantoPortKnockInterfaces($pDB);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr('PortKnock Interface Authorizations'));
    $oGrid->setColumns(array('', _tr('IP'), _tr('User'), _tr('Ports'), _tr('Since')));
    $oGrid->deleteList(_tr('Are you sure you wish to revoke this authorization?'), 'delete', _tr('Revoke authorization'));
    if (isset($_POST['delete']) && isset($_POST['id_user_ip'])) {
        $l = explode('-', $_POST['id_user_ip']);
        if (count($l) >= 2) {
            $bExito = $pk->removeAuthorizationsUserInterface($l[0], $l[1]);
            if (!$bExito) {
                $smarty->assign("mb_title", _tr("Error"));
                $smarty->assign("mb_message", $pk->errMsg);
            } else {
                Header("Location: ?menu={$module_name}");
                return NULL;
            }
        }
    }
    $recordset = $pk->listAuthorizationsInterface($eth_in);
    $data = array();
    if (is_array($recordset)) {
        foreach ($recordset as $id_user => $auth_user) {
            $userinfo = $pACL->getUsers($id_user);
            foreach ($auth_user as $ip_source => $auth_ips) {
                $listaProto = array();
                $ruleStart = NULL;
                foreach ($auth_ips as $id_auth => $info_auth) {
                    $listaProto[] = $info_auth['name'];
                    $ruleStart = $info_auth['rule_start'];
                }
                $data[] = array('<input type="radio" name="id_user_ip" value="' . $id_user . '-' . $ip_source . '" />', $ip_source, $userinfo[0][1], implode(' ', $listaProto), $ruleStart);
            }
        }
    }
    $oGrid->pagingShow(false);
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $oGrid->setData($data);
    return $oGrid->fetchGrid();
}
Beispiel #9
0
function saveEditUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $exito = false;
    $idUser = getParameter("id");
    $errorImg = "";
    $renameFile = "";
    $reAsterisk = false;
    //obtenemos la informacion del usuario por el id dado, sino existe el usuario mostramos un mensaje de error
    if (!isset($idUser)) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Invalid User"));
        return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    } else {
        if ($arrCredentiasls['userlevel'] == "superadmin") {
            $arrUsers = $pACL->getUsers($idUser);
        } else {
            $arrUsers = $pACL->getUsers($idUser, $arrCredentiasls['id_organization']);
        }
    }
    if ($arrUsers === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr($pACL->errMsg));
        return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
    } else {
        if (count($arrUsers) == 0) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("User doesn't exist"));
            return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
        } else {
            $idOrgz = $arrUsers[0][4];
            //una vez creado un usuario este no se puede cambiar de organizacion
            $arrOrgz = array();
            $temp = $pACL->getGroupsPaging(null, null, $idOrgz);
            if ($temp === false) {
                $smarty->assign("mb_title", _tr("ERROR"));
                $smarty->assign("mb_message", _tr($pACL->errMsg));
                return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
            }
            foreach ($temp as $value) {
                $arrGrupos[$value[0]] = $value[1];
            }
            $arrFormOrgz = createFieldForm($arrGrupos, $arrOrgz);
            $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");
                $quota = getParameter("email_quota");
                $countryCode = getParameter("country_code");
                $areaCode = getParameter("area_code");
                $idGrupo = getParameter("group");
                $extension = getParameter("extension");
                $fax_extension = getParameter("fax_extension");
                $name = getParameter("name");
                $md5password = md5($password1);
                $clidNumber = getParameter("clid_number");
                $cldiName = getParameter("clid_name");
                if ($pACL->isUserSuperAdmin($arrUsers[0][1])) {
                    $idGrupo = $arrUsers[0][7];
                    $email_contact = getParameter("email_contact");
                    $exito = $pORGZ->updateUserSuperAdmin($idUser, $name, $md5password, $password1, $email_contact, $arrCredentiasls['userlevel']);
                    $error = $pORGZ->errMsg;
                } else {
                    if ($password1 != $password2) {
                        $error = _tr("Passwords don't match");
                    } elseif ($password1 != "" && !isStrongPassword($password1)) {
                        $error = _tr("Secret can not be empty, must be at least 10 characters, contain digits, uppers and little case letters");
                    } elseif (!isset($quota) || $quota == "") {
                        $error = _tr("Qouta must not be empty");
                    } elseif (!isset($countryCode) || $countryCode == "") {
                        $error = _tr("Country Code must not be empty");
                    } elseif (!isset($areaCode) || $areaCode == "") {
                        $error = _tr("Area Code must not be empty");
                    } elseif (!isset($clidNumber) || $clidNumber == "") {
                        $error = _tr("C er Id Number must not be empty");
                    } elseif (!isset($cldiName) || $cldiName == "") {
                        $error = _tr("Caller Id Name must not be empty");
                    } else {
                        $exito = $pORGZ->updateUserOrganization($idUser, $name, $md5password, $password1, $extension, $fax_extension, $countryCode, $areaCode, $clidNumber, $cldiName, $idGrupo, $quota, $arrCredentiasls['userlevel'], $reAsterisk);
                        $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($idUser, $pDB, $errorImg);
        }
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("User has been edited successfully") . "<br>{$errorImg}");
        if ($reAsterisk) {
            //mostramos el mensaje para crear los archivos de ocnfiguracion
            $pAstConf = new paloSantoASteriskConfig($pDB);
            $orgTmp2 = $pORGZ->getOrganization(array("id" => $idOrgz));
            $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;
}
Beispiel #10
0
function report_CashCollection($smarty, $module_name, $local_templates_dir, &$pDB, $pDB_2)
{
    $pCashCollection = new Cash_Collection($pDB);
    $pACL = new paloACL($pDB_2);
    // get filter parameters
    $filter = array('date_start' => trim($_POST['date_start']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_start'])), 'date_end' => trim($_POST['date_end']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_end'])), 'customer_name' => trim($_POST['customer_name']), 'customer_phone' => trim($_POST['customer_number']), 'ticket_code' => trim($_POST['ticket_code']), 'status' => trim($_POST['status']));
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle("Thu tiền giao vé");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export("Cash_Collection");
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $arrColumns = array("ID", "Tên Khách Hàng", "Số điện thoại", "Ngày mua vé", "Booker", "Địa chỉ", "Tiền trả", "Mã số vé", "Tình trạng", "Nhân viên giao", "Ngày phân công", "Nhân viên nhận tiền", "Ngày nhận tiền", "   ");
    $oGrid->setColumns($arrColumns);
    $total = $pCashCollection->getNumCash_Collection($filter);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pCashCollection->getCash_Collection($limit, $offset, $filter);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $ticket = '';
            $name = $pACL->getUsers($value['accounting_id']);
            $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
            foreach ($value['ticket_code'] as $row) {
                $ticket .= $row . '<br>';
            }
            $arrTmp[0] = $value['id'];
            $arrTmp[1] = $value['customer_name'];
            $arrTmp[2] = $value['customer_phone'];
            $arrTmp[3] = is_null($value['purchase_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['purchase_date']));
            $arrTmp[4] = $value['agent_name'];
            $arrTmp[5] = '<a href="javascript:void(1)" onclick="alert(\'' . $value['deliver_address'] . '\')">Xem</a>';
            $arrTmp[6] = $value['pay_amount'];
            $arrTmp[7] = $ticket;
            $arrTmp[8] = showStatus($value['status']);
            $arrTmp[9] = $value['delivery_name'];
            $arrTmp[10] = is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']));
            $arrTmp[11] = $elastix_user;
            $arrTmp[12] = is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']));
            $arrTmp[13] = $value['status'] == 'Đang giao' ? '<a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\')">Nhận tiền</a>' : '';
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    // get delivery man list
    $delivery_man_list = $pCashCollection->getDeliveryMan();
    $smarty->assign("DELIVERY_MAN_LIST", $delivery_man_list);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Beispiel #11
0
function editUser($userAccount, $pACL, $pDB, $arrFormElements, $smarty, $local_templates_dir, $arrLang, $idUserAccount, $userLevel1)
{
    if (getParameter("id_user")) {
        $id_user = getParameter("id_user");
        if (!$pACL->isUserAdministratorGroup($userAccount)) {
            if ($pACL->getIdUser($userAccount) != $id_user) {
                $smarty->assign("mb_title", $arrLang["ERROR"]);
                $smarty->assign("mb_message", $arrLang["You are not authorized to access to information of that user"]);
                return reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount);
            }
        }
    } else {
        $id_user = $pACL->getIdUser($userAccount);
    }
    // Tengo que recuperar la data del usuario
    $pACL = new paloACL($pDB);
    $arrUser = $pACL->getUsers($id_user);
    $arrFillUser['name'] = $arrUser[0][1];
    $arrFillUser['description'] = $arrUser[0][2];
    // Lleno el grupo
    $arrMembership = $pACL->getMembership($id_user);
    $id_group = "";
    if (is_array($arrMembership)) {
        foreach ($arrMembership as $groupName => $groupId) {
            $id_group = $groupId;
            // Asumo que cada usuario solo puede pertenecer a un grupo
            break;
        }
    }
    $arrFillUser['group'] = $id_group;
    $arrFillUser['extension'] = $arrUser[0][3];
    // Implementar
    include_once "libs/paloSantoForm.class.php";
    $arrFormElements['password1']['REQUIRED'] = 'no';
    $arrFormElements['password2']['REQUIRED'] = 'no';
    $oForm = new paloForm($smarty, $arrFormElements);
    $arrFillUser['password1'] = '********';
    $arrFillUser['password2'] = '********';
    $listaPropiedades = leerPropiedadesWebmail($pDB, $smarty, $id_user);
    if (isset($listaPropiedades['login'])) {
        $arrFillUser['webmailuser'] = $listaPropiedades['login'];
    }
    if (isset($listaPropiedades['domain'])) {
        $arrFillUser['webmaildomain'] = $listaPropiedades['domain'];
    }
    if (isset($listaPropiedades['password'])) {
        $arrFillUser['webmailpassword1'] = '********';
    }
    //if (isset($listaPropiedades['imapsvr'])) $arrFillUser['webmailimapsvr'] = $listaPropiedades['imapsvr'];
    $oForm->setEditMode();
    $smarty->assign("id_user", $id_user);
    return $oForm->fetchForm("{$local_templates_dir}/new.tpl", "{$arrLang['Edit User']} \"" . $arrFillUser['name'] . "\"", $arrFillUser);
}