本文整理汇总了PHP中Translate::convToOutputCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::convToOutputCharset方法的具体用法?PHP Translate::convToOutputCharset怎么用?PHP Translate::convToOutputCharset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translate
的用法示例。
在下文中一共展示了Translate::convToOutputCharset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
/**
* Output record line into file
*
* @param array $array_selected_sorted Array with list of field to export
* @param resource $objp A record from a fetch with all fields from select
* @param Translate $outputlangs Object lang to translate values
* @param array $array_types Array with types of fields
* @return int <0 if KO, >0 if OK
*/
function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
{
global $conf;
// Create a format for the column headings
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$outputlangs->charset_output = 'ISO-8859-1';
// Because Excel 5 format is ISO
}
// Define first row
$this->col = 0;
foreach ($array_selected_sorted as $code => $value) {
if (strpos($code, ' as ') == 0) {
$alias = str_replace(array('.', '-'), '_', $code);
} else {
$alias = substr($code, strpos($code, ' as ') + 4);
}
if (empty($alias)) {
dol_print_error('', 'Bad value for field with code=' . $code . '. Try to redefine export.');
}
$newvalue = $objp->{$alias};
$newvalue = $this->excel_clean($newvalue);
$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
// Traduction newvalue
if (preg_match('/^\\((.*)\\)$/i', $newvalue, $reg)) {
$newvalue = $outputlangs->transnoentities($reg[1]);
} else {
$newvalue = $outputlangs->convToOutputCharset($newvalue);
}
if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue)) {
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$formatdate = $this->workbook->addformat();
$formatdate->set_num_format('yyyy-mm-dd');
//$formatdate->set_num_format(0x0f);
$arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
$newvalue = strval($arrayvalue[0]) . '.' . strval($arrayvalue[1]);
// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
$this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
} else {
$newvalue = dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
}
} elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue)) {
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$formatdatehour = $this->workbook->addformat();
$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
//$formatdatehour->set_num_format(0x0f);
$arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
$newvalue = strval($arrayvalue[0]) . '.' . strval($arrayvalue[1]);
// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
} else {
$newvalue = dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
}
} else {
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$this->worksheet->write($this->row, $this->col, $newvalue);
} else {
if ($typefield == 'Text' || $typefield == 'TextAuto') {
//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, (string) $newvalue);
$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
} else {
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $newvalue);
}
}
}
$this->col++;
}
$this->row++;
return 0;
}
示例2: pdf_bank
/**
* Show bank informations for PDF generation
*
* @param PDF $pdf Object PDF
* @param Translate $outputlangs Object lang
* @param int $curx X
* @param int $cury Y
* @param Account $account Bank account object
* @param int $onlynumber Output only number (bank+desk+key+number according to country, but without name of bank and domiciliation)
* @param int $default_font_size Default font size
* @return float The Y PDF position
*/
function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
{
global $mysoc, $conf;
$diffsizetitle = empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE;
$diffsizecontent = empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT;
$pdf->SetXY($curx, $cury);
if (empty($onlynumber)) {
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount') . ':', 0, 'L', 0);
$cury += 4;
}
$outputlangs->load("banks");
// Use correct name of bank id according to country
$bickey = "BICNumber";
if ($account->getCountryCode() == 'IN') {
$bickey = "SWIFT";
}
// Get format of bank account according to its country
$usedetailedbban = $account->useDetailedBBAN();
//$onlynumber=0; $usedetailedbban=1; // For tests
if ($usedetailedbban) {
$savcurx = $curx;
if (empty($onlynumber)) {
$pdf->SetFont('', '', $default_font_size - $diffsizecontent);
$pdf->SetXY($curx, $cury);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank") . ': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
$cury += 3;
}
if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) {
// Note:
// bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56)
// desk = code guichet (FR), used only when $usedetailedbban = 1
// number = account number
// key = check control key used only when $usedetailedbban = 1
if (empty($onlynumber)) {
$pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
}
if ($usedetailedbban == 1) {
$fieldstoshow = array('bank', 'desk', 'number', 'key');
if ($conf->global->BANK_SHOW_ORDER_OPTION == 1) {
$fieldstoshow = array('bank', 'desk', 'key', 'number');
}
} else {
if ($usedetailedbban == 2) {
$fieldstoshow = array('bank', 'number');
} else {
dol_print_error('', 'Value returned by function useDetailedBBAN not managed');
}
}
foreach ($fieldstoshow as $val) {
if ($val == 'bank') {
// Bank code
$tmplength = 18;
$pdf->SetXY($curx, $cury + 4);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0);
$pdf->SetXY($curx, $cury + 1);
$curx += $tmplength;
$pdf->SetFont('', 'B', $default_font_size - 4);
$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0);
if (empty($onlynumber)) {
$pdf->line($curx, $cury + 1, $curx, $cury + 7);
}
}
if ($val == 'desk') {
// Desk
$tmplength = 18;
$pdf->SetXY($curx, $cury + 4);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0);
$pdf->SetXY($curx, $cury + 1);
$curx += $tmplength;
$pdf->SetFont('', 'B', $default_font_size - 4);
$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0);
if (empty($onlynumber)) {
$pdf->line($curx, $cury + 1, $curx, $cury + 7);
}
}
if ($val == 'number') {
// Number
$tmplength = 24;
$pdf->SetXY($curx, $cury + 4);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0);
$pdf->SetXY($curx, $cury + 1);
$curx += $tmplength;
$pdf->SetFont('', 'B', $default_font_size - 4);
$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0);
//.........这里部分代码省略.........
示例3: foreach
/**
* Output record line into file
*
* @param array $array_selected_sorted Array with list of field to export
* @param resource $objp A record from a fetch with all fields from select
* @param Translate $outputlangs Object lang to translate values
* @param array $array_types Array with types of fields
* @return int <0 if KO, >0 if OK
*/
function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
{
global $conf;
if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) {
$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
} else {
$outputlangs->charset_output = 'ISO-8859-1';
}
$this->col = 0;
foreach ($array_selected_sorted as $code => $value) {
if (strpos($code, ' as ') == 0) {
$alias = str_replace(array('.', '-'), '_', $code);
} else {
$alias = substr($code, strpos($code, ' as ') + 4);
}
if (empty($alias)) {
dol_print_error('', 'Bad value for field with key=' . $code . '. Try to redefine export.');
}
$newvalue = $outputlangs->convToOutputCharset($objp->{$alias});
// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
// Translation newvalue
if (preg_match('/^\\((.*)\\)$/i', $newvalue, $reg)) {
$newvalue = $outputlangs->transnoentities($reg[1]);
}
$newvalue = $this->csv_clean($newvalue, $outputlangs->charset_output);
if (preg_match('/^Select:/i', $typefield, $reg) && ($typefield = substr($typefield, 7))) {
$array = unserialize($typefield);
$array = $array['options'];
$newvalue = $array[$newvalue];
}
fwrite($this->handle, $newvalue . $this->separator);
$this->col++;
}
fwrite($this->handle, "\n");
return 0;
}
示例4: addSticker
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
*
* @param PDF $pdf PDF reference
* @param Translate $outputlangs Output langs
* @param array $param Associative array containing label content and optional parameters
* @return void
*/
function addSticker(&$pdf, $outputlangs, $param)
{
global $mysoc, $conf;
$textleft = $param['textleft'];
$header = $param['textheader'];
$footer = $param['textfooter'];
$textright = $param['textright'];
$code = $param['code'];
$encoding = $param['encoding'];
$is2d = $param['is2d'];
// We are in a new page, then we must add a page
if ($this->_COUNTX == 0 && $this->_COUNTY == 0 and !$this->_First == 1) {
$pdf->AddPage();
}
$this->_First = 0;
$_PosX = $this->_Margin_Left + $this->_COUNTX * ($this->_Width + $this->_X_Space);
$_PosY = $this->_Margin_Top + $this->_COUNTY * ($this->_Height + $this->_Y_Space);
// Define logo
$logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
if (!is_readable($logo)) {
$logo = '';
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
$logo = $conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small;
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
$logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
}
}
$xleft = 2;
$ytop = 2;
// Top
if ($header != '') {
$pdf->SetXY($_PosX + $xleft, $_PosY + 1);
// Only 1 mm and not ytop for top text
$pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
}
$ytop += empty($header) ? 0 : 1 + $this->_Line_Height;
// Define widthtouse and heighttouse
$pageMargins = $pdf->getMargins();
$maxwidthtouse = round($this->_Width - 2 * $xleft);
$maxheighttouse = round($this->_Height - 2 * $ytop);
$maxheighttouse -= empty($footer) ? 0 : 1 + $this->_Line_Height;
$defaultratio = $maxwidthtouse / $maxheighttouse;
$widthtouse = $maxwidthtouse;
$heighttouse = $maxheighttouse;
$logoHeight = $heighttouse;
$logoWidth = $heighttouse;
//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
// Center
if ($textright == '') {
// Output left area
if ($textleft == '%LOGO%' && $logo) {
$pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight);
} else {
if ($code && !empty($encoding)) {
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
} else {
$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
}
}
} else {
if ($textleft != '' && $textright != '') {
if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%')) {
if ($textleft == '%LOGO%' && $logo) {
$pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse / 2, 0);
} else {
if ($code && !empty($encoding)) {
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse / 2, $heighttouse);
}
}
$pdf->SetXY($_PosX + $widthtouse / 2, $_PosY + $ytop);
$pdf->MultiCell($widthtouse / 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
} else {
if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) {
if ($textright == '%LOGO%' && $logo) {
$pdf->Image($logo, $_PosX + $widthtouse / 2, $_PosY + $ytop, $widthtouse / 2, 0);
} else {
if ($code && !empty($encoding)) {
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $widthtouse / 2, $_PosY + $ytop, $widthtouse / 2, $heighttouse);
}
}
$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
$pdf->MultiCell($widthtouse / 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
} else {
if ($textleft == '%LOGO%') {
if ($logo) {
$pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight);
}
if ($code && !empty($encoding)) {
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft + $logoWidth + 1, $_PosY + $ytop, $widthtouse - $logoWidth - 1, $heighttouse);
} else {
$pdf->SetXY($_PosX + $xleft + $logoWidth + 1, $_PosY + $ytop);
//.........这里部分代码省略.........
示例5: elseif
/**
* On imprime une etiquette
*
* @param PDF &$pdf PDF
* @param string $textleft Textleft
* @param string $header Header
* @param string $footer Footer
* @param Translate $outputlangs Output langs
* @param string $textright Text right
* @return void
*/
function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '')
{
global $mysoc, $conf, $langs;
// We are in a new page, then we must add a page
if ($this->_COUNTX == 0 and $this->_COUNTY == 0 and !$this->_First == 1) {
$pdf->AddPage();
}
$this->_First = 0;
$_PosX = $this->_Margin_Left + $this->_COUNTX * ($this->_Width + $this->_X_Space);
$_PosY = $this->_Margin_Top + $this->_COUNTY * ($this->_Height + $this->_Y_Space);
// Define logo
$logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
if (!is_readable($logo)) {
$logo = '';
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
$logo = $conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small;
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
$logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
}
}
// Define photo
$photo = '';
// Define background image
$backgroundimage = '';
// Print lines
if ($this->code == "CARD") {
$this->Tformat = $this->_Avery_Labels["CARD"];
//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
$this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10);
}
// Background
if ($backgroundimage) {
$pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height);
}
// Top
if ($header != '') {
if ($this->code == "CARD") {
$pdf->SetDrawColor(128, 128, 128);
$pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1);
$pdf->SetDrawColor(0, 0, 0);
}
$pdf->SetXY($_PosX, $_PosY + 1);
$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
}
// Middle
if ($textright == '') {
if ($textleft == '%LOGO%' && $logo) {
$this->Image($logo, $_PosX + 2, $_PosY + 3 + $this->_Line_Height, 20);
} else {
if ($textleft == '%PHOTO%' && $photo) {
$this->Image($photo, $_PosX + 2, $_PosY + 3 + $this->_Line_Height, 20);
} else {
$pdf->SetXY($_PosX + 3, $_PosY + 3 + $this->_Line_Height);
$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
}
}
} else {
if ($textleft != '' && $textright != '') {
if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') {
if ($textleft == '%LOGO%' && $logo) {
$pdf->Image($logo, $_PosX + 2, $_PosY + 3 + $this->_Line_Height, 20);
} else {
if ($textleft == '%PHOTO%' && $photo) {
$pdf->Image($photo, $_PosX + 2, $_PosY + 3 + $this->_Line_Height, 20);
}
}
$pdf->SetXY($_PosX + 21, $_PosY + 3 + $this->_Line_Height);
$pdf->MultiCell($this->_Width - 22, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
} else {
if ($textright == '%LOGO%' || $textright == '%PHOTO%') {
if ($textright == '%LOGO%' && $logo) {
$pdf->Image($logo, $_PosX + $this->_Width - 21, $_PosY + 3 + $this->_Line_Height, 20);
} else {
if ($textright == '%PHOTO%' && $photo) {
$pdf->Image($photo, $_PosX + $this->_Width - 21, $_PosY + 3 + $this->_Line_Height, 20);
}
}
$pdf->SetXY($_PosX + 2, $_PosY + 3 + $this->_Line_Height);
$pdf->MultiCell($this->_Width - 22, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
} else {
$pdf->SetXY($_PosX + 2, $_PosY + 3 + $this->_Line_Height);
$pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
$pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + 3 + $this->_Line_Height);
$pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
}
}
} else {
if ($textright == '%LOGO%' && $logo) {
$this->Image($logo, $_PosX + $this->_Width - 21, $_PosY + 1, 20);
//.........这里部分代码省略.........
示例6: empty
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
* - %LOGO% is replace with company logo
* - %PHOTO% is replace with photo provided as parameter
*
* @param PDF $pdf PDF reference
* @param string $textleft Text left
* @param string $header Header
* @param string $footer Footer
* @param Translate $outputlangs Output langs
* @param string $textright Text right
* @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
* @return void
*/
function Add_PDF_label(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $photo = '')
{
global $mysoc, $conf, $langs;
global $forceimgscalewidth, $forceimgscaleheight;
$imgscalewidth = empty($forceimgscalewidth) ? 0.3 : $forceimgscalewidth;
// Scale of image for width (1=Full width of sticker)
$imgscaleheight = empty($forceimgscalewidth) ? 0.5 : $forceimgscalewidth;
// Scale of image for height (1=Full height of sticker)
// We are in a new page, then we must add a page
if ($this->_COUNTX == 0 && $this->_COUNTY == 0 and !$this->_First == 1) {
$pdf->AddPage();
}
$this->_First = 0;
$_PosX = $this->_Margin_Left + $this->_COUNTX * ($this->_Width + $this->_X_Space);
$_PosY = $this->_Margin_Top + $this->_COUNTY * ($this->_Height + $this->_Y_Space);
// Define logo
$logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
if (!is_readable($logo)) {
$logo = '';
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
$logo = $conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small;
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
$logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
}
}
// Define photo
if (!empty($photo)) {
if (!is_readable($photo)) {
$photo = '';
}
}
// Define background image
$backgroundimage = '';
// Print lines
if ($this->code == "CARD") {
$this->Tformat = $this->_Avery_Labels["CARD"];
//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
$this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10);
}
// Background
if ($backgroundimage) {
$pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height);
}
$xleft = 2;
$ytop = 2;
// Top
if ($header != '') {
if ($this->code == "CARD") {
$pdf->SetDrawColor(128, 128, 128);
$pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1);
// Only 1 mm and not ytop for top text
$pdf->SetDrawColor(0, 0, 0);
}
$pdf->SetXY($_PosX + $xleft, $_PosY + 1);
// Only 1 mm and not ytop for top text
$pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
}
$ytop += empty($header) ? 0 : 1 + $this->_Line_Height;
// Define widthtouse and heighttouse
$maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth);
$maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight);
$defaultratio = $maxwidthtouse / $maxheighttouse;
$widthtouse = $maxwidthtouse;
$heighttouse = 0;
// old value for image
$tmp = dol_getImageSize($photo, false);
if ($tmp['height']) {
$imgratio = $tmp['width'] / $tmp['height'];
if ($imgratio >= $defaultratio) {
$widthtouse = $maxwidthtouse;
$heighttouse = round($widthtouse / $imgratio);
} else {
$heightouse = $maxheighttouse;
$widthtouse = round($heightouse * $imgratio);
}
}
//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
// Center
if ($textright == '') {
// Output left area
if ($textleft == '%LOGO%' && $logo) {
$pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
} else {
if ($textleft == '%PHOTO%' && $photo) {
$pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
} else {
//.........这里部分代码省略.........
示例7: foreach
/**
* Output record line into file
*
* @param array $array_selected_sorted Array with list of field to export
* @param resource $objp A record from a fetch with all fields from select
* @param Translate $outputlangs Object lang to translate values
* @return int <0 if KO, >0 if OK
*/
function write_record($array_selected_sorted, $objp, $outputlangs)
{
global $conf;
if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) {
$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
} else {
$outputlangs->charset_output = 'ISO-8859-1';
}
$this->col = 0;
foreach ($array_selected_sorted as $code => $value) {
$alias = str_replace(array('.', '-'), '_', $code);
if (empty($alias)) {
dol_print_error('', 'Bad value for field with key=' . $code . '. Try to redefine export.');
}
$newvalue = $outputlangs->convToOutputCharset($objp->{$alias});
// Translation newvalue
if (preg_match('/^\\((.*)\\)$/i', $newvalue, $reg)) {
$newvalue = $outputlangs->transnoentities($reg[1]);
}
$newvalue = $this->csv_clean($newvalue, $outputlangs->charset_output);
fwrite($this->handle, $newvalue . $this->separator);
$this->col++;
}
fwrite($this->handle, "\n");
return 0;
}
示例8: pdf_bank
/**
* Show bank informations for PDF generation
*
* @param PDF &$pdf Object PDF
* @param Translate $outputlangs Object lang
* @param int $curx X
* @param int $cury Y
* @param Account $account Bank account object
* @param int $onlynumber Output only number
* @param int $default_font_size Default font size
* @return void
*/
function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
{
global $mysoc, $conf;
$pdf->SetXY($curx, $cury);
if (empty($onlynumber)) {
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount') . ':', 0, 'L', 0);
$cury += 4;
}
$outputlangs->load("banks");
// Get format of bank account according to its country
$usedetailedbban = $account->useDetailedBBAN();
//$onlynumber=0; $usedetailedbban=0; // For tests
if ($usedetailedbban) {
$savcurx = $curx;
if (empty($onlynumber)) {
$pdf->SetFont('', '', $default_font_size - 4);
$pdf->SetXY($curx, $cury);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank") . ': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
$cury += 3;
}
if (empty($onlynumber)) {
$pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 8);
}
if ($usedetailedbban == 1) {
$fieldstoshow = array('bank', 'desk', 'number', 'key');
if ($conf->global->BANK_SHOW_ORDER_OPTION == 1) {
$fieldstoshow = array('bank', 'desk', 'key', 'number');
}
} else {
if ($usedetailedbban == 2) {
$fieldstoshow = array('bank', 'number');
} else {
dol_print_error('', 'Value returned by function useDetailedBBAN not managed');
}
}
foreach ($fieldstoshow as $val) {
if ($val == 'bank') {
// Bank code
$tmplength = 18;
$pdf->SetXY($curx, $cury + 5);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0);
$pdf->SetXY($curx, $cury + 1);
$curx += $tmplength;
$pdf->SetFont('', 'B', $default_font_size - 4);
$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0);
if (empty($onlynumber)) {
$pdf->line($curx, $cury + 1, $curx, $cury + 8);
}
}
if ($val == 'desk') {
// Desk
$tmplength = 18;
$pdf->SetXY($curx, $cury + 5);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0);
$pdf->SetXY($curx, $cury + 1);
$curx += $tmplength;
$pdf->SetFont('', 'B', $default_font_size - 4);
$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0);
if (empty($onlynumber)) {
$pdf->line($curx, $cury + 1, $curx, $cury + 8);
}
}
if ($val == 'number') {
// Number
$tmplength = 24;
$pdf->SetXY($curx, $cury + 5);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0);
$pdf->SetXY($curx, $cury + 1);
$curx += $tmplength;
$pdf->SetFont('', 'B', $default_font_size - 4);
$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0);
if (empty($onlynumber)) {
$pdf->line($curx, $cury + 1, $curx, $cury + 8);
}
}
if ($val == 'key') {
// Key
$tmplength = 13;
$pdf->SetXY($curx, $cury + 5);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0);
$pdf->SetXY($curx, $cury + 1);
$curx += $tmplength;
$pdf->SetFont('', 'B', $default_font_size - 4);
//.........这里部分代码省略.........
示例9:
/**
* Show top header of page.
*
* @param PDF $pdf Object PDF
* @param Translate $outputlangs Object lang for output
* @param int $pagenb Page nb
* @return void
*/
function _pagehead(&$pdf, $outputlangs, $pagenb)
{
global $conf, $langs;
// Do not add the BACKGROUND as this is a report
//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
// New page
$pdf->AddPage();
// Show title
$pdf->SetFont('', 'B', 10);
$pdf->SetXY($this->marge_gauche, $this->marge_haute);
$pdf->MultiCell(120, 1, $outputlangs->convToOutputCharset($this->title), 0, 'L', 0);
// Show page nb only on iso languages (so default Helvetica font)
if (pdf_getPDFFont($outputlangs) == 'Helvetica') {
$pdf->SetXY($this->page_largeur - $this->marge_droite - 40, $this->marge_haute);
$pdf->MultiCell(40, 1, $pagenb . '/' . $pdf->getAliasNbPages(), 0, 'R', 0);
}
$y = $pdf->GetY() + 2;
$pdf->Rect($this->marge_gauche, $y, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->page_hauteur - $this->marge_haute - $this->marge_basse);
$y = $pdf->GetY() + 1;
return $y;
}