Files
crm.clientright.ru/modules/Workflow2/tasks/WfTaskConverttoInvoice.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

119 lines
3.7 KiB
PHP

<?php
/**
This File was developed by Stefan Warnat <vtiger@stefanwarnat.de>
It belongs to the Workflow Designer and must not be distributed without complete extension
**/
require_once(realpath(dirname(__FILE__).'/../autoload_wf.php'));
/**
* vt6 ready 2014/04/27
*/
class WfTaskConverttoInvoice extends \Workflow\Task {
protected $_javascriptFile = "WfTaskSetter.js";
protected $_envSettings = array("new_record_id");
/**
* @var \Workflow\Preset\FieldSetter
*/
private $fieldSetter = false;
public function init() {
$this->fieldSetter = $this->addPreset("FieldSetter", "setter", array(
'fromModule' => $this->getModuleName(),
'toModule' => 'Invoice',
'refFields' => false
));
}
/**
* @param $context \Workflow\VTEntity|\Workflow\VTInventoryEntity
*/
public function handleTask(&$context) {
$referenceId = $context->getId();
Workflow2::$enableError = true;
$parentRecordModel = Inventory_Record_Model::getInstanceById($referenceId);
$currencyInfo = $parentRecordModel->getCurrencyInfo();
$taxes = $parentRecordModel->getProductTaxes();
$shippingTaxes = $parentRecordModel->getShippingTaxes();
$relatedProducts = $parentRecordModel->getProducts();
$recordModel = Vtiger_Record_Model::getCleanInstance('Invoice');
$recordModel->setRecordFieldValues($parentRecordModel);
$recordModel->save();
$newId = $recordModel->getId();
$contextRecord = $context;
/**
* @var $newObj \Workflow\VTEntity|\Workflow\VTInventoryEntity
*/
$newObj = \Workflow\VTEntity::getForId($newId);
$newObj->set('hdnTaxType', $parentRecordModel->get('hdnTaxType'));
$newObj->importProductsFromRecord($relatedProducts, true);
$setterMap = $this->get("setter");
$this->fieldSetter->apply($newObj, $setterMap, $contextRecord, $this);
$newObj->save();
$context->setEnvironment("new_record_id", $newObj->getId(), $this);
if($this->get("redirectAfter") == "1") {
$this->getWorkflow()->setSuccessRedirection("index.php?module=".$newObj->getModuleName()."&view=Detail&record=".$newObj->getId(), 'same');
}
if($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
$newContext = VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
$newContext->loadEnvironment($context->getEnvironment());
$objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
$objWorkflow->isSubWorkflow(true);
$objWorkflow->setContext($newContext);
$objWorkflow->start();
}
Workflow2::$enableError = true;
return 'yes';
}
public function beforeGetTaskform($viewer) {
global $adb;
$new_module = "Invoice";
$viewer->assign("new_module", $new_module);
$workflows = Workflow2::getWorkflowsForModule($new_module, 1);
$viewer->assign("extern_workflows", $workflows);
$sql = "SELECT * FROM vtiger_tab WHERE presence = 0 AND isentitytype = 1 ORDER BY name";
$result = $adb->query($sql);
$module = array();
while($row = $adb->fetch_array($result)) {
if($row["name"] == "Calendar")
continue;
$module[$row["name"]] = getTranslatedString($row["tablabel"],$row["name"]);
}
asort($module);
$viewer->assign("avail_module", $module);
}
public function beforeSave(&$data) {
}
}