Exemplo n.º 1
0
/**
 *	Return array with format properties of default PDF format
 *
 *	@param		Translate	$outputlangs		Output lang to use to autodetect output format if setup not done
 *  @return     array							Array('width'=>w,'height'=>h,'unit'=>u);
 */
function pdf_getFormat($outputlangs = '')
{
    global $conf, $db;
    // Default value if setup was not done and/or entry into c_paper_format not defined
    $width = 210;
    $height = 297;
    $unit = 'mm';
    if (empty($conf->global->MAIN_PDF_FORMAT)) {
        include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
        $pdfformat = dol_getDefaultFormat($outputlangs);
    } else {
        $pdfformat = $conf->global->MAIN_PDF_FORMAT;
    }
    $sql = "SELECT code, label, width, height, unit FROM " . MAIN_DB_PREFIX . "c_paper_format";
    $sql .= " WHERE code = '" . $pdfformat . "'";
    $resql = $db->query($sql);
    if ($resql) {
        $obj = $db->fetch_object($resql);
        if ($obj) {
            $width = (int) $obj->width;
            $height = (int) $obj->height;
            $unit = $obj->unit;
        }
    }
    //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit;
    return array('width' => $width, 'height' => $height, 'unit' => $unit);
}
Exemplo n.º 2
0
    print '</form>';
    print '<br>';
} else {
    $var = true;
    // Misc options
    print_fiche_titre($langs->trans("DictionaryPaperFormat"), '', '') . '<br>';
    $var = true;
    print '<table summary="more" class="noborder" width="100%">';
    print '<tr class="liste_titre"><td>' . $langs->trans("Parameter") . '</td><td width="200px">' . $langs->trans("Value") . '</td></tr>';
    // Show pdf format
    $var = !$var;
    print '<tr ' . $bc[$var] . '><td>' . $langs->trans("DictionaryPaperFormat") . '</td><td>';
    $pdfformatlabel = '';
    if (empty($conf->global->MAIN_PDF_FORMAT)) {
        include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
        $pdfformatlabel = dol_getDefaultFormat();
    } else {
        $pdfformatlabel = $conf->global->MAIN_PDF_FORMAT;
    }
    if (!empty($pdfformatlabel)) {
        $sql = "SELECT code, label, width, height, unit FROM " . MAIN_DB_PREFIX . "c_paper_format";
        $sql .= " WHERE code LIKE '%" . $db->escape($pdfformatlabel) . "%'";
        $resql = $db->query($sql);
        if ($resql) {
            $obj = $db->fetch_object($resql);
            $paperKey = $langs->trans('PaperFormat' . $obj->code);
            $unitKey = $langs->trans('SizeUnit' . $obj->unit);
            $pdfformatlabel = ($paperKey == 'PaperFormat' . $obj->code ? $obj->label : $paperKey) . ' - ' . round($obj->width) . 'x' . round($obj->height) . ' ' . ($unitKey == 'SizeUnit' . $obj->unit ? $obj->unit : $unitKey);
        }
    }
    print $pdfformatlabel;