Exemple #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;
}
Exemple #2
0
function getImageContact($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk)
{
    $contact_id = getParameter('idPhoto');
    $thumbnail = getParameter("thumbnail");
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    $ruta_destino = "/var/www/address_book_images";
    $imgDefault = $_SERVER['DOCUMENT_ROOT'] . "/modules/{$module_name}/images/Icon-user.png";
    $padress_book = new paloAdressBook($pDB);
    $contactData = $padress_book->contactData($contact_id, $id_user);
    $arrIm = explode(".", $contactData['picture']);
    $typeImage = $arrIm[count($arrIm) - 1];
    if ($thumbnail == "yes") {
        $image = $ruta_destino . "/" . $contact_id . "_Thumbnail.{$typeImage}";
    } else {
        $image = $ruta_destino . "/" . $contactData['picture'];
    }
    // Creamos la imagen a partir de un fichero existente
    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);
        echo $image;
    }
    return;
}
Exemple #3
0
function view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, $update = FALSE)
{
    $arrFormadress_book = createFieldForm($pDB);
    $padress_book = new paloAdressBook($pDB);
    $oForm = new paloForm($smarty, $arrFormadress_book);
    $id = getParameter('id');
    if (isset($_POST["edit"]) || $update == TRUE) {
        $oForm->setEditMode();
        $smarty->assign("Commit", 1);
        $smarty->assign("SAVE", "Sửa");
    } else {
        $oForm->setViewMode();
        $smarty->assign("Edit", 1);
    }
    $smarty->assign("icon", "modules/{$module_name}/images/address_book.png");
    $smarty->assign("EDIT", "Sửa");
    $smarty->assign("title", "Thông tin khách hàng");
    $smarty->assign("SAVE", "Lưu");
    $smarty->assign("CANCEL", "Đóng");
    $smarty->assign("REQUIRED_FIELD", "Bắt buộc");
    $contactData = $padress_book->contactData($id);
    if ($contactData) {
        $smarty->assign("ID", $id);
    } else {
        $smarty->assign("mb_title", "Lỗi");
        $smarty->assign("mb_message", 'Không cho phép xem');
        return report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk);
    }
    if ($contactData['type'] == '0') {
        $smarty->assign("check_0", "checked");
    } elseif ($contactData['type'] == '1') {
        $smarty->assign("check_1", "checked");
    } elseif ($contactData['type'] == '2') {
        $smarty->assign("check_2", "checked");
    } else {
        $smarty->assign("check_3", "checked");
    }
    // get contact list to show in smarty
    $smarty->assign("CONTACT", $contactData['contact']);
    $arrData['customer_name'] = $contactData['customer_name'];
    $arrData['email'] = $contactData['email'];
    $arrData['cmnd'] = $contactData['cmnd'];
    $arrData['passport'] = $contactData['passport'];
    $arrData['birthday'] = date("d-m-Y", strtotime($contactData['birthday']));
    $arrData['birthplace'] = $contactData['birthplace'];
    $arrData['address'] = $contactData['address'];
    $arrData['membership'] = $contactData['membership'];
    $arrData['sale_view'] = $contactData['sale_id'];
    $arrData['province_view'] = $contactData['province_id'];
    $arrData['district_view'] = $contactData['district_id'];
    $arrData['booker_view'] = $contactData['booker_id'];
    $arrData['accountant_view'] = $contactData['accountant_id'];
    $arrData['customer_code'] = $contactData['customer_code'];
    $arrData['contact'] = $contactData['contact'];
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new_adress_book.tpl", "Thông tin khách hàng", $arrData);
    $contenidoModulo = "<form  method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $contenidoModulo;
}
Exemple #4
0
function view_customer()
{
    global $arrConf;
    $customer_id = getParameter('customer_id');
    // get history log
    include_once "modules/customer/libs/paloSantoAdressBook.class.php";
    $pDB = new paloDB($arrConf['cadena_dsn']);
    $padress_book = new paloAdressBook($pDB);
    $result = $padress_book->contactData($customer_id);
    $json = new Services_JSON();
    Header('Content-Type: application/json');
    return $json->encode($result);
}
Exemple #5
0
 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;
     }
 }