Ejemplo n.º 1
0
 /**
  * Functional point that deletes a document fax of the database, and deletes also the PDF document associated to the fax if exist
  *
  * @param   integer      $id        ID of the fax to be deleted
  * @return  boolean      true if the document fax was deleted, false if an error exists
  */
 function delFaxDoc($id)
 {
     if (!$this->_checkUserAuthorized('faxviewer')) {
         return false;
     }
     // Verificar presencia de ID del fax
     if (!isset($id) || !preg_match('/^\\d+$/', $id)) {
         $this->errMsg["fc"] = 'PARAMERROR';
         $this->errMsg["fm"] = 'Invalid ID';
         $this->errMsg["fd"] = 'Fax ID must be nonnegative integer';
         $this->errMsg["cn"] = get_class($this);
         return false;
     }
     $id = (int) $id;
     //obtenemos las credenciales del usuario
     $arrCredentials = getUserCredentials();
     // Borrar el registro y el documento de fax, dado su ID
     $oFax = new paloFaxVisor();
     $bExito = $oFax->deleteInfoFax($id, $arrCredentials["id_organization"]);
     if (!$bExito) {
         $this->errMsg["fm"] = 'Database operation failed';
         $this->errMsg["cn"] = get_class($oFax);
         if ($oFax->errMsg != '') {
             $this->errMsg["fc"] = 'DBERROR';
             $this->errMsg["fd"] = 'Unable to delete fax information - ' . $oFax->errMsg;
         } else {
             $this->errMsg["fc"] = 'INTERNALERROR';
             $this->errMsg["fd"] = 'Unable to delete fax document';
         }
     }
     return $bExito;
 }
Ejemplo n.º 2
0
function listarFaxes(&$smarty, $module_name, $local_templates_dir)
{
    $smarty->assign(array('SEARCH' => _tr('Search')));
    $oFax = new paloFaxVisor();
    // Generación del filtro
    $oFilterForm = new paloForm($smarty, getFormElements());
    // 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'));
    $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;
        unset($_POST['faxes_delete']);
        // Se aborta el intento de borrar faxes, si había uno.
    }
    $url = array_merge($url, $paramFiltro);
    // Ejecutar el borrado, si se ha validado.
    if (isset($_POST['faxes_delete']) && isset($_POST['faxes']) && is_array($_POST['faxes']) && count($_POST['faxes']) > 0) {
        $msgError = NULL;
        foreach ($_POST['faxes'] as $idFax) {
            if (!$oFax->deleteInfoFax($idFax)) {
                if ($oFax->errMsg = '') {
                    $msgError = _tr('Unable to eliminate pdf file from the path.');
                } else {
                    $msgError = _tr('Unable to eliminate pdf file from the database.') . ' - ' . $oFax->errMsg;
                }
            }
        }
        if (!is_null($msgError)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
        }
    }
    $oGrid->setTitle(_tr("Fax Viewer"));
    $oGrid->setIcon("modules/{$module_name}/images/kfaxview.png");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->setURL($url);
    $arrData = NULL;
    $total = $oFax->obtener_cantidad_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']);
    $limit = 20;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $arrResult = $oFax->obtener_faxes($paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']);
    $oGrid->setColumns(array("", _tr('Type'), _tr('File'), _tr('Company Name'), _tr('Company Fax'), _tr('Fax Destiny'), _tr('Fax Date'), _tr('Status'), _tr('Options')));
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $fax) {
            foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax', 'errormsg') as $k) {
                $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8');
            }
            if (empty($fax['status']) && !empty($fax['errormsg'])) {
                $fax['status'] = 'failed';
            }
            $arrData[] = array('<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />', _tr($fax['type']), 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'], $fax['company_name'], $fax['company_fax'], $fax['destiny_name'] . " - " . $fax['destiny_fax'], $fax['date'], _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']), "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>");
        }
    }
    if (!is_array($arrResult)) {
        $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
    }
    $oGrid->setData($arrData);
    $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete"));
    $oGrid->showFilter($htmlFilter);
    return $oGrid->fetchGrid();
}
Ejemplo n.º 3
0
function delete_faxFile($smarty, $module_name, $local_templates_dir, $pDB, $credentials)
{
    $oFax = new paloFaxVisor($pDB);
    $id_organization = null;
    if ($credentials['userlevel'] != 'superadmin') {
        $id_organization = $credentials['id_organization'];
    }
    // Ejecutar el borrado, si se ha validado.
    if (is_array($_POST['faxes']) && count($_POST['faxes']) > 0) {
        $msgError = NULL;
        foreach ($_POST['faxes'] as $idFax) {
            if (!$oFax->deleteInfoFax($idFax, $id_organization)) {
                if ($oFax->errMsg = '') {
                    $msgError = _tr('Unable to eliminate pdf file from the path.');
                } else {
                    $msgError = _tr('Unable to eliminate pdf file from the database.') . ' - ' . $oFax->errMsg;
                }
            }
        }
        if (!is_null($msgError)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
        }
    } else {
        $smarty->assign("mb_title", _tr('ERROR'));
        $smarty->assign("mb_message", _tr('You must select at least one fax'));
    }
    return listarFaxes($smarty, $module_name, $local_templates_dir, $pDB, $credentials);
}