Example #1
0
 /**
  * Export record to PDF file
  * @param int $recordId - id of a record
  * @param string $moduleName - name of records module
  * @param int $templateId - id of pdf template
  * @param string $filePath - path name for saving pdf file
  * @param string $saveFlag - save option flag
  */
 public function export($recordId, $moduleName, $templateId, $filePath = '', $saveFlag = '')
 {
     $template = Vtiger_PDF_Model::getInstanceById($templateId, $moduleName);
     $template->setMainRecordId($recordId);
     $pageOrientation = $template->get('page_orientation') == 'PLL_PORTRAIT' ? 'P' : 'L';
     $pdf = new self('c', $template->get('page_format'), 0, '', $template->get('margin_left'), $template->get('margin_right'), $template->get('margin_top'), $template->get('margin_bottom'), $template->get('margin_top'), $template->get('margin_bottom'), $pageOrientation);
     $pdf->setTemplateId($templateId);
     $pdf->setRecordId($recordId);
     $pdf->setModuleName($moduleName);
     $pdf->setLanguage($template->get('language'));
     $pdf->setFileName($template->get('filename'));
     $origLanguage = vglobal('default_language');
     vglobal('default_language', $template->get('language'));
     $pdf->parseParams($template->getParameters());
     $pdf->setHeader('Header', $template->getHeader());
     $pdf->setFooter('Footer', $template->getFooter());
     $html = $template->getBody();
     $pdf->loadHTML($html);
     vglobal('default_language', $origLanguage);
     $pdf->output($filePath, $saveFlag);
 }
Example #2
0
	/**
	 * Export record to PDF file
	 * @param int $recordId - id of a record
	 * @param string $moduleName - name of records module
	 * @param int $templateId - id of pdf template
	 * @param string $filePath - path name for saving pdf file
	 * @param string $saveFlag - save option flag
	 */
	public function export($recordId, $moduleName, $templateId, $filePath = '', $saveFlag = '')
	{
		$pdf = new self();
		$pdf->setTemplateId($templateId);
		$pdf->setRecordId($recordId);
		$pdf->setModuleName($moduleName);

		$template = Vtiger_PDF_Model::getInstanceById($templateId, $moduleName);
		$template->setMainRecordId($recordId);

		$pdf->setLanguage($template->get('language'));
		$pdf->setFileName($template->get('filename'));

		$origLanguage = vglobal('default_language');
		vglobal('default_language', $template->get('language'));

		$pdf->parseParams($template->getParameters());

		$html = '';

		$pdf->setHeader('Header', $template->getHeader());
		$pdf->setFooter('Footer', $template->getFooter());
		$html = $template->getBody();

		$pdf->loadHTML($html);

		vglobal('default_language', $origLanguage);

		$pdf->output($filePath, $saveFlag);
	}