0
0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2024-11-21 23:47:57 +00:00
salesagility_SuiteCRM/modules/Cases/CasesJjwg_MapsLogicHook.php
2023-07-18 15:53:09 +01:00

70 lines
2.2 KiB
PHP

<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
#[\AllowDynamicProperties]
class CasesJjwg_MapsLogicHook
{
public $jjwg_Maps;
public function __construct()
{
$this->jjwg_Maps = get_module_info('jjwg_Maps');
}
public function updateGeocodeInfo(&$bean, $event, $arguments)
{
// before_save
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
$this->jjwg_Maps->updateGeocodeInfo($bean);
}
}
public function updateRelatedMeetingsGeocodeInfo(&$bean, $event, $arguments)
{
// after_save
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
$this->jjwg_Maps->updateRelatedMeetingsGeocodeInfo($bean);
}
}
public function addRelationship(&$bean, $event, $arguments)
{
// after_relationship_add
// $arguments['module'], $arguments['related_module'], $arguments['id'] and $arguments['related_id']
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
$focus = get_module_info($arguments['module']);
if (!empty($arguments['id'])) {
$focus->retrieve($arguments['id']);
$focus->custom_fields->retrieve();
$this->jjwg_Maps->updateGeocodeInfo($focus, true);
if ($focus->jjwg_maps_address_c != $focus->fetched_row['jjwg_maps_address_c']) {
$focus->save(false);
}
}
}
}
public function deleteRelationship(&$bean, $event, $arguments)
{
// after_relationship_delete
// $arguments['module'], $arguments['related_module'], $arguments['id'] and $arguments['related_id']
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
$focus = get_module_info($arguments['module']);
if (!empty($arguments['id'])) {
$focus->retrieve($arguments['id']);
$focus->custom_fields->retrieve();
$this->jjwg_Maps->updateGeocodeInfo($focus, true);
if ($focus->jjwg_maps_address_c != $focus->fetched_row['jjwg_maps_address_c']) {
$focus->save(false);
}
}
}
}
}