Files
crm.clientright.ru/modules/ITS4YouReports/actions/GeneratePDF.php
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

139 lines
6.0 KiB
PHP

<?php
/*+********************************************************************************
* The content of this file is subject to the Reports 4 You license.
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is IT-Solutions4You s.r.o.
* Portions created by IT-Solutions4You s.r.o. are Copyright(C) IT-Solutions4You s.r.o.
* All Rights Reserved.
********************************************************************************/
require_once('modules/ITS4YouReports/GenerateObj.php');
class ITS4YouReports_GeneratePDF_Action extends Vtiger_Action_Controller
{
public function checkPermission(Vtiger_Request $request)
{
}
function preProcess(Vtiger_Request $request)
{
return true;
}
function postProcess(Vtiger_Request $request)
{
return true;
}
public function process(Vtiger_Request $request)
{
$layout = Vtiger_Viewer::getDefaultLayoutName();
$response = new Vtiger_Response();
$debug_fs = $report_chartpdf = '';
@ob_clean();
if (true === vtlib_isModuleActive('PDFMaker') && file_exists('modules/PDFMaker/resources/mpdf/mpdf.php')) {
if (file_exists('modules/ITS4YouReports/classes/Reports4YouDefault.css')) {
$report_html_style = file_get_contents('modules/ITS4YouReports/classes/Reports4YouDefault.css');
}
$report_html = $request->get('form_report_html');
$report_head = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
</head>
<body>";
if ($request->has('form_chart_canvas') && '' !== $request->get('form_chart_canvas')) {
$chart_image = 'data:image/png;base64,' . $request->get('form_chart_canvas');
$report_chartpdf = "
<div style='height:21cm;text-align:center;'><img src='" . $chart_image . "'></div>";
}
$report_foot = '</body>
</html>';
require_once 'modules/PDFMaker/resources/mpdf/mpdf.php';
// $mpdf = new mPDF('', // mode - default ''
// 2 '', // format - A4, for example, default ''
// 3 0, // font size - default 0
// 4 '', // default font family
// 5 15, // margin_left
// 6 15, // margin right
// 7 16, // margin top
// 8 16, // margin bottom
// 9 9, // margin header
// 10 9, // margin footer
// 11 'L'); // L - landscape, P - portrait
$report_filename = $request->get('form_filename') . '.pdf';
$export_pdf_format = $request->get('form_export_pdf_format');
// class mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]])
$mpdf = new mPDF('utf-8', '$export_pdf_format', '', '', '5', '5', '0', '5', '5', '5');
// Portrait = $mpdf=new mPDF('utf-8', 'A4');
// Landscape = $mpdf=new mPDF('utf-8', 'A4-L');
$mpdf->keep_table_proportions = true;
if (number_format(mPDF_VERSION) < 6) {
$mpdf->SetAutoFont();
}
if ('v7' !== $layout) {
$mpdf->WriteHTML($report_html_style, 1);
}
if ($request->has('type') && in_array($request->get('type'), ['all', 'base'])) {
$record = $request->get('record');
// set reload to generate query by defined Filter criteria
$_REQUEST['reload'] = 1;
$ITS4YouReports = new ITS4YouReports(true, $record);
$generate = new GenerateObj($ITS4YouReports,"",false,true);
$reportData = $generate->generateReport($record);
$report_html = $reportData[0];
}
//--start report
$mpdf->WriteHTML($report_head);
if ($request->has('form_report_name') && !empty($request->get('form_report_name'))) {
$form_report_name = $request->get('form_report_name');
$mpdf->WriteHTML(GenerateObj::placeReportNameToPDF($form_report_name));
$form_report_name .= '.pdf';
}
if ('tabular' === $generate->report_obj->reportinformations['reporttype']
&& false !== strpos($report_html, '<!--LIMIT_INF-->')) {
$report_totals_arr = explode('<!--LIMIT_INF-->', $report_html);
if (ITS4YouReports_Functions_Helper::count($report_totals_arr) > 1) {
$report_html = $report_totals_arr[0] . $report_totals_arr[2];
}
}
$mpdf->WriteHTML($report_html);
//--end
if ('tabular' !== $generate->report_obj->reportinformations['reporttype']) {
$report_totals = '<br />' . $request->get('form_report_totals');
$report_totals_arr = explode('<!--LIMIT_INF-->', $report_totals);
if (ITS4YouReports_Functions_Helper::count($report_totals_arr) > 1) {
$report_totals = $report_totals_arr[0] . $report_totals_arr[2];
}
$mpdf->WriteHTML($report_totals);
}
if (!empty($report_chartpdf)) {
$mpdf->AddPage('L');
$mpdf->WriteHTML($report_chartpdf);
}
$mpdf->WriteHTML($report_foot);
$mpdf->Output($form_report_name, 'D');
exit;
}
}
}