Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix - Importación - Evitar uso de variable no definida #470

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions custom/modules/Contacts/SticLogicHooksCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
class ContactsLogicHooks {
public function before_save(&$bean, $event, $arguments) {
// Calculate age
if ($bean->birthdate != $bean->fetched_row['birthdate']) {
if (empty($bean->fetched_row) || $bean->birthdate != $bean->fetched_row['birthdate']) {
include_once 'custom/modules/Contacts/SticUtils.php';
$bean->stic_age_c = ContactsUtils::getAge($bean->birthdate);
}

// Bring Incorpora location data, if there is any
if ($bean->fetched_row['stic_incorpora_locations_id_c'] != $bean->stic_incorpora_locations_id_c) {
if (empty($bean->fetched_row) || $bean->fetched_row['stic_incorpora_locations_id_c'] != $bean->stic_incorpora_locations_id_c) {
include_once 'modules/stic_Incorpora_Locations/Utils.php';
stic_Incorpora_LocationsUtils::transferLocationData($bean);
}
Expand All @@ -49,7 +49,7 @@ public function after_save(&$bean, $event, $arguments) {
// End of Patch issue

// Generate automatic Call
if ($bean->stic_postal_mail_return_reason_c != $bean->fetched_row['stic_postal_mail_return_reason_c']) {
if (empty($bean->fetched_row) || $bean->stic_postal_mail_return_reason_c != $bean->fetched_row['stic_postal_mail_return_reason_c']) {
include_once 'custom/modules/Contacts/SticUtils.php';
ContactsUtils::generateCallFromReturnMailReason($bean);
}
Expand Down
2 changes: 1 addition & 1 deletion custom/modules/Contacts/SticUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function getAge($birthday)
public static function generateCallFromReturnMailReason($contactBean)
{
$reasons = array('wrong_address', 'unknown', 'rejected');
if (in_array($contactBean->stic_postal_mail_return_reason_c, $reasons)) {
if (!empty($contactBean->stic_postal_mail_return_reason_c) && in_array($contactBean->stic_postal_mail_return_reason_c, $reasons)) {
global $current_user, $timedate, $app_strings;

// Create the new call
Expand Down
6 changes: 5 additions & 1 deletion data/SugarBean.php
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,11 @@ public function cleanBean()
// STIC Custom - 20221213 - JCH - Trim name & varchar type values on save when the value is not null
// STIC#902
// STIC#982
if (isset($def['type']) && in_array($def['type'], ['name', 'varchar']) && !is_null($this->$key)) {
// STIC-Custom 20241218 EPS - Avoid using property "key" if it is not setted
// https://github.com/SinergiaTIC/SinergiaCRM/pull/470
// if (isset($def['type']) && in_array($def['type'], ['name', 'varchar']) && !is_null($this->$key)) {
if (isset($def['type']) && in_array($def['type'], ['name', 'varchar']) && property_exists($this, $key) && !empty($this->$key)) {
// END STIC-Custom (EPS 20241218)
$this->$key = trim($this->$key);
}
// END STIC
Expand Down
24 changes: 17 additions & 7 deletions modules/stic_Incorpora_Locations/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ public static function transferLocationData($recordBean) {
$inc_state = 'inc_state' .$sufix;
$stic_incorpora_locations_id = 'stic_incorpora_locations_id' .$sufix;

$location_bean = BeanFactory::getBean('stic_Incorpora_Locations', $recordBean->$stic_incorpora_locations_id);
$recordBean->$inc_town_code = $location_bean->town_code;
$recordBean->$inc_town = $location_bean->town;
$recordBean->$inc_municipality_code = $location_bean->municipality_code;
$recordBean->$inc_municipality = $location_bean->municipality;
$recordBean->$inc_state_code = $location_bean->state_code;
$recordBean->$inc_state = $location_bean->state;
if(!empty($recordBean->$stic_incorpora_locations_id)) {
$location_bean = BeanFactory::getBean('stic_Incorpora_Locations', $recordBean->$stic_incorpora_locations_id);
$recordBean->$inc_town_code = $location_bean->town_code;
$recordBean->$inc_town = $location_bean->town;
$recordBean->$inc_municipality_code = $location_bean->municipality_code;
$recordBean->$inc_municipality = $location_bean->municipality;
$recordBean->$inc_state_code = $location_bean->state_code;
$recordBean->$inc_state = $location_bean->state;
}
else {
$recordBean->$inc_town_code = '';
$recordBean->$inc_town = '';
$recordBean->$inc_municipality_code = '';
$recordBean->$inc_municipality = '';
$recordBean->$inc_state_code = '';
$recordBean->$inc_state = '';
}
}
}
Loading