예제 #1
0
파일: index.php 프로젝트: hardikk/HNH
function call2phone()
{
    include_once "libs/paloSantoConfig.class.php";
    require_once '/var/www/html/modules/address_book/libs/paloSantoAdressBook.class.php';
    global $arrConf;
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrConfig = $pConfig->leer_configuracion(false);
    $dsn_agi_manager['password'] = $arrConfig['AMPMGRPASS']['valor'];
    $dsn_agi_manager['host'] = $arrConfig['AMPDBHOST']['valor'];
    $dsn_agi_manager['user'] = '******';
    $pDB = new paloDB($arrConf['dsn_conn_database']);
    // address_book
    $padress_book = new paloAdressBook($pDB);
    $sNumber = getParameter('call_number');
    if (strpos($sNumber, '|') !== false) {
        $arrExt = explode(" | ", $sNumber);
        $sNumber = trim($arrExt[1]);
    }
    $response = array('action' => 'call2phone', 'message' => $sNumber);
    $extension = $_SESSION['callcenter']['agente'];
    $name = $sNumber;
    //$_SESSION['callcenter']['agente_nombre'];
    //var_dump($arrConf);
    if (is_null($sNumber) || !ctype_digit($sNumber)) {
        $response['action'] = 'error';
        $response['message'] = 'Invalid or missing number to call';
    } else {
        $prefix = prefixNumber($sNumber);
        $phone2call = $prefix . $sNumber;
        $result = $padress_book->Call2Phone($dsn_agi_manager, $extension, $phone2call, $extension, $name);
        if (!$result) {
            $response['action'] = 'error';
            $response['message'] = 'Cuộc gọi không thực hiện được. Kiểm tra máy nhánh ' + $extension;
        }
    }
    $json = new Services_JSON();
    Header('Content-Type: application/json');
    return $json->encode($response);
}
예제 #2
0
파일: index.php 프로젝트: hardikk/HNH
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;
}
예제 #3
0
    $query = substr($query, 1, strlen($query));
}
// limit search
if ($query == '' || is_null($query) || strlen($query) <= 4) {
    $total = 0;
    $entry = array('id' => 0, 'cell' => array('customer_code' => 'ERROR', 'firstname' => 'Nhập mục cần tìm!', 'lastname' => '>= 3 ký tự', 'phone' => $query, 'email' => '', 'agent_id' => '', 'sale' => '', 'accountant' => '', 'type' => '', 'membership' => '', 'payment_type' => '', 'view' => ''));
    $jsonData['rows'][] = $entry;
} elseif ($qtype == 'phone' && strlen($query) <= 7) {
    $total = 0;
    $entry = array('id' => 0, 'cell' => array('customer_code' => 'ERROR', 'firstname' => 'Số điện thoại >= 6 số', 'lastname' => '', 'phone' => $query, 'email' => '', 'agent_id' => '', 'sale' => '', 'accountant' => '', 'type' => '', 'membership' => '', 'payment_type' => '', 'view' => ''));
    $jsonData['rows'][] = $entry;
} else {
    /* new code using customer class */
    $pDB = new paloDB($arrConf['cadena_dsn']);
    // address_book
    $padress_book = new paloAdressBook($pDB);
    $total = $padress_book->getAddressBook(NULL, NULL, $qtype, $query, TRUE, $sort, $letter);
    $total = $total[0]["total"];
    $arrResult = $padress_book->getAddressBook($rp, $page - 1, $qtype, $query, FALSE, $sort, $letter);
}
$arrPayment_type = array(0 => 'Khách lẻ không thường xuyên', 1 => 'Khách lẻ thường xuyên', 2 => 'Khách hàng công ty', 3 => 'Khách hàng đại lý');
if (is_array($arrResult) && $total > 0) {
    $typeContact = "";
    foreach ($arrResult as $key => $adress_book) {
        switch ($adress_book['type']) {
            case '0':
                $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/nor-customer.png" title="Khách hàng lẽ"/>KLE';
                break;
            case '1':
                $typeContact = '<img border=0 src="/modules/' . $module_name . '/images/fre-customer.png" title="Khách hàng lẽ thường xuyên"/>KLE-TX';
                break;
예제 #4
0
파일: index.php 프로젝트: hardikk/HNH
function backup_contacts($pDB, $pDB_2, $arrLang)
{
    $Messages = "";
    $csv = "";
    $pAdressBook = new paloAdressBook($pDB);
    $fields = "name, last_name, telefono, email";
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    $arrResult = $pAdressBook->getAddressBookByCsv(null, null, $fields, null, null, $id_user);
    if (!$arrResult) {
        $Messages .= $arrLang["There aren't contacts"] . ". " . $pAdressBook->errMsg;
        echo $Messages;
    } else {
        //cabecera
        $csv .= "\"Name\",\"Last Name\",\"Phone Number\",\"Email\",\"Address\",\"Company\"\n";
        foreach ($arrResult as $key => $contact) {
            $csv .= "\"{$contact['name']}\",\"{$contact['last_name']}\"," . "\"{$contact['telefono']}\",\"{$contact['email']}\"," . "\"{$contact['address']}\",\"{$contact['company']}\"" . "\n";
        }
    }
    return $csv;
}
예제 #5
0
파일: index.php 프로젝트: hardikk/HNH
function call2phone($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk)
{
    $padress_book = new paloAdressBook($pDB);
    //echo '<pre>'.print_r($_SESSION,1).'</pre>';die;
    $extension = $_SESSION['callcenter']['agente'];
    $name = $_SESSION['callcenter']['agente_nombre'];
    if ($extension != "") {
        $id = isset($_GET['id']) ? $_GET['id'] : (isset($_POST['id']) ? $_POST['id'] : "");
        $prefix = prefixNumber($id);
        $phone2call = $prefix . $id;
        $result = $padress_book->Call2Phone($dsn_agi_manager, $extension, $phone2call, $extension, $name);
        if (!$result) {
            $smarty->assign("mb_title", "Lỗi: ");
            $smarty->assign("mb_message", "Không nhận diện được số điện thoại!");
        } else {
            $smarty->assign("mb_title", "Gọi thành công: ");
            $smarty->assign("mb_message", "Số điện thoại " . $id);
        }
    } else {
        $smarty->assign("mb_title", "Lỗi: ");
        $smarty->assign("mb_message", "Phải đăng nhập màn hình chính để lấy thông tin máy nhánh!");
    }
    $content = report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk);
    return $content;
}
예제 #6
0
<?php

require_once dirname(__FILE__) . "/libs/JSON.php";
$json = new Services_JSON();
$module_name = 'agent_console';
header("Content-type: application/json");
/* get booker list */
if (isset($_REQUEST['booker_list'])) {
    $module_name = 'customer';
    $arrConf['cadena_dsn'] = "mysql://*****:*****@localhost/call_center";
    include_once "/var/www/html/modules/{$module_name}/libs/paloSantoAdressBook.class.php";
    include_once "/var/www/html/libs/paloSantoDB.class.php";
    $pDB = new paloDB($arrConf['cadena_dsn']);
    // address_book
    $padress_book = new paloAdressBook($pDB);
    $arrBooker = $padress_book->getAgentList();
    echo $json->encode($arrBooker);
    return;
}
/* end of get booker list */
/* get delivery man */
if (isset($_REQUEST['delivery_man_list'])) {
    $module_name = 'ticket_delivery';
    $arrConf['cadena_dsn'] = "mysql://*****:*****@localhost/call_center";
    include_once "/var/www/html/modules/{$module_name}/libs/Ticket_Delivery.class.php";
    include_once "/var/www/html/libs/paloSantoDB.class.php";
    $pDB = new paloDB($arrConf['cadena_dsn']);
    // address_book
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $delivery_man_list = $pTicket_Delivery->getDeliveryMan();
    echo $json->encode($delivery_man_list);
예제 #7
0
파일: core.class.php 프로젝트: hardikk/HNH
 public function getContactImage($id, $thumbnail, $directory)
 {
     global $arrConf;
     if (!$this->_checkUserAuthorized('address_book')) {
         return false;
     }
     $dbAddressBook = $this->_getDB($arrConf['dsn_conn_database']);
     $addressBook = new paloAdressBook($dbAddressBook);
     // Obtener el ID del usuario logoneado
     $id_user = $this->_leerIdUser();
     if (is_null($id_user)) {
         return false;
     }
     // Validar que el ID está presente y es numérico
     if (!isset($id) || !preg_match('/^\\d+$/', $id)) {
         $this->errMsg["fc"] = 'PARAMERROR';
         $this->errMsg["fm"] = 'Invalid format';
         $this->errMsg["fd"] = 'Invalid ID, must be positive integer';
         $this->errMsg["cn"] = get_class($this);
         return false;
     }
     // Verificar si el contacto existe y pertenece al usuario logoneado
     $tupla = $addressBook->contactData($id, $id_user, $directory, true, $this->_astDSN);
     if (!is_array($tupla)) {
         $this->errMsg["fc"] = 'DBERROR';
         $this->errMsg["fm"] = 'Database operation failed';
         $this->errMsg["fd"] = 'Unable to read data from external phonebook - ' . $addressBook->_DB->errMsg;
         $this->errMsg["cn"] = get_class($addressBook);
         return false;
     }
     $ruta_destino = "/var/www/address_book_images";
     $arrIm = explode(".", $tupla['picture']);
     $typeImage = $arrIm[count($arrIm) - 1];
     $idt = $directory == "external" ? $tupla['id'] : $tupla['id_on_address_book_db'];
     if ($thumbnail == "yes") {
         $imgDefault = $_SERVER['DOCUMENT_ROOT'] . "/modules/address_book/images/Icon-user_Thumbnail.png";
         $image = $ruta_destino . "/" . $idt . "_Thumbnail.{$typeImage}";
     } else {
         $imgDefault = $_SERVER['DOCUMENT_ROOT'] . "/modules/address_book/images/Icon-user.png";
         $image = $ruta_destino . "/" . $tupla['picture'];
     }
     if (is_file($image)) {
         if (strtolower($typeImage) == "png") {
             Header("Content-type: image/png");
             $im = imagecreatefromPng($image);
             ImagePng($im);
             // Mostramos la imagen
             ImageDestroy($im);
             // Liberamos la memoria que ocupaba la imagen
         } else {
             Header("Content-type: image/jpeg");
             $im = imagecreatefromJpeg($image);
             ImageJpeg($im);
             // Mostramos la imagen
             ImageDestroy($im);
             // Liberamos la memoria que ocupaba la imagen
         }
     } else {
         Header("Content-type: image/png");
         $image = file_get_contents($imgDefault);
         return $image;
     }
 }
예제 #8
0
<?php

require_once dirname(__FILE__) . "/libs/JSON.php";
$json = new Services_JSON();
$module_name = 'agent_console';
header("Content-type: application/json");
/* get booker list */
if (isset($_REQUEST['booker_list'])) {
    $module_name = 'customer';
    $arrConf['cadena_dsn'] = "mysql://*****:*****@localhost/call_center";
    include_once "/var/www/html/modules/{$module_name}/libs/paloSantoAdressBook.class.php";
    include_once "/var/www/html/libs/paloSantoDB.class.php";
    $pDB = new paloDB($arrConf['cadena_dsn']);
    // address_book
    $padress_book = new paloAdressBook($pDB);
    $arrBooker = $padress_book->getBookerList();
    echo $json->encode($arrBooker);
    return;
}
/* end of get booker list */
/* get delivery man */
if (isset($_REQUEST['delivery_man_list'])) {
    $module_name = 'ticket_delivery';
    $arrConf['cadena_dsn'] = "mysql://*****:*****@localhost/call_center";
    include_once "/var/www/html/modules/{$module_name}/libs/Ticket_Delivery.class.php";
    include_once "/var/www/html/libs/paloSantoDB.class.php";
    $pDB = new paloDB($arrConf['cadena_dsn']);
    // address_book
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $delivery_man_list = $pTicket_Delivery->getDeliveryMan();
    echo $json->encode($delivery_man_list);
예제 #9
0
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $dsnAsterisk)
{
    include_once "modules/address_book/libs/paloSantoAdressBook.class.php";
    $padress_book = new paloAdressBook($pDB);
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    if (isset($_POST['select_directory_type']) && $_POST['select_directory_type'] == 'External') {
        $smarty->assign("external_sel", 'selected=selected');
        $directory_type = 'external';
    } else {
        $smarty->assign("internal_sel", 'selected=selected');
        $directory_type = 'internal';
    }
    $_POST['select_directory_type'] = $directory_type;
    $arrComboElements = array("name" => $arrLang["Name"], "telefono" => $arrLang["Phone Number"]);
    if ($directory_type == 'external') {
        $arrComboElements["last_name"] = $arrLang["Last Name"];
    }
    $arrFormElements = array("field" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => ""));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SHOW", $arrLang["Show"]);
    $smarty->assign("CSV", $arrLang["CSV"]);
    $smarty->assign("module_name", $module_name);
    $smarty->assign("Phone_Directory", $arrLang["Phone Directory"]);
    $smarty->assign("Internal", $arrLang["Internal"]);
    $smarty->assign("External", $arrLang["External"]);
    $field = NULL;
    $pattern = NULL;
    $namePattern = NULL;
    $allowSelection = array("name", "telefono", "last_name");
    if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") {
        $field = $_POST['field'];
        if (!in_array($field, $allowSelection)) {
            $field = "name";
        }
        $pattern = '%' . $_POST['pattern'] . '%';
        $namePattern = $_POST['pattern'];
        $nameField = $arrComboElements[$field];
    }
    $startDate = $endDate = date("Y-m-d H:i:s");
    $arrFilter = array("select_directory_type" => $directory_type, "field" => $field, "pattern" => $namePattern);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Phone Directory") . " =  {$directory_type} ", $arrFilter, array("select_directory_type" => "internal"), true);
    $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter);
    if ($directory_type == 'external') {
        $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE, $id_user);
    } else {
        $total = $padress_book->getDeviceFreePBX($dsnAsterisk, NULL, NULL, $field, $pattern, TRUE);
    }
    $total_datos = $total[0]["total"];
    //Paginacion
    $limit = 20;
    $total = $total_datos;
    $oGrid->setLimit($limit);
    $offset = $oGrid->getOffSet($limit, $total, isset($_GET['nav']) ? $_GET['nav'] : NULL, isset($_GET['start']) ? $_GET['start'] : NULL);
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    //Fin Paginacion
    if ($directory_type == 'external') {
        $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE, $id_user);
    } else {
        $arrResult = $padress_book->getDeviceFreePBX($dsnAsterisk, $limit, $offset, $field, $pattern);
    }
    $arrData = null;
    if (is_array($arrResult) && $total > 0) {
        $arrMails = array();
        if ($directory_type == 'internal') {
            $arrMails = $padress_book->getMailsFromVoicemail();
        }
        foreach ($arrResult as $key => $adress_book) {
            if ($directory_type == 'external') {
                $email = $adress_book['email'];
            } else {
                if (isset($arrMails[$adress_book['id']])) {
                    $email = $arrMails[$adress_book['id']];
                } else {
                    $email = '';
                }
            }
            $arrTmp[0] = $directory_type == 'external' ? htmlspecialchars($adress_book['last_name'], ENT_QUOTES, "UTF-8") . " " . htmlspecialchars($adress_book['name'], ENT_QUOTES, "UTF-8") : $adress_book['description'];
            $number = $directory_type == 'external' ? htmlspecialchars($adress_book['telefono'], ENT_QUOTES, "UTF-8") : $adress_book['id'];
            $arrTmp[1] = "<a href='javascript:return_phone_number(\"{$number}\", \"{$directory_type}\", \"{$adress_book['id']}\")'>{$number}</a>";
            $arrTmp[2] = htmlspecialchars($email, ENT_QUOTES, "UTF-8");
            $arrData[] = $arrTmp;
        }
    }
    if ($directory_type == 'external') {
        $name = "<input type='submit' name='delete' value='{$arrLang["Delete"]}' class='button' onclick=\" return confirmSubmit('{$arrLang["Are you sure you wish to delete the contact."]}');\" />";
    } else {
        $name = "";
    }
    $arrGrid = array("title" => $arrLang["Address Book"], "url" => array('menu' => $module_name, 'action' => 'phone_numbers', 'rawmode' => 'yes', 'filter' => $pattern), "icon" => "images/list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => $arrLang["Name"], "property1" => ""), 1 => array("name" => $arrLang["Phone Number"], "property1" => ""), 2 => array("name" => $arrLang["Email"], "property1" => "")));
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    return $contenidoModulo;
}