Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 7cead7a

Browse files
committed
add Employee module messaging
1 parent ebaffb6 commit 7cead7a

File tree

25 files changed

+492
-103
lines changed

25 files changed

+492
-103
lines changed

SuiteModules/Extension/modules/Administration/Ext/Administration/administration.ext.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
'LBL_SEVEN_ACCOUNT_CONFIGURATION_DESC',
2727
'./index.php?module=seven&action=account',
2828
];
29+
$admin_options_defs['Administration']['Configuration5'] = [
30+
'PANELSETTINGS',
31+
'LBL_SEVEN_EMPLOYEE_CONFIGURATION_TITLE',
32+
'LBL_SEVEN_EMPLOYEE_CONFIGURATION_DESC',
33+
'./index.php?module=seven&action=employee',
34+
];
2935

3036
$admin_group_header[] = [
3137
'LBL_SEVEN_TITLE',

SuiteModules/Extension/modules/Administration/Ext/Language/de_de.lang.ext.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
$mod_strings['LBL_SEVEN_ACCOUNT_CONFIGURATION_TITLE'] = 'Account Vorlagen-Konfiguration';
1919
$mod_strings['LBL_SEVEN_ACCOUNT_CONFIGURATION_DESC'] = 'Account Vorlagen-Konfiguration';
2020

21+
$mod_strings['LBL_SEVEN_EMPLOYEE_CONFIGURATION_TITLE'] = 'Employee Vorlagen-Konfiguration';
22+
$mod_strings['LBL_SEVEN_EMPLOYEE_CONFIGURATION_DESC'] = 'Employee Vorlagen-Konfiguration';
23+
2124
$mod_strings['LBL_SEVEN_PANEL_HEADING'] = 'SMS via seven';
2225
?>

SuiteModules/Extension/modules/Administration/Ext/Language/en_us.lang.ext.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
$mod_strings['LBL_SEVEN_ACCOUNT_CONFIGURATION_TITLE'] = 'Account Template Configuration';
1919
$mod_strings['LBL_SEVEN_ACCOUNT_CONFIGURATION_DESC'] = 'Account Template Configuration';
2020

21+
$mod_strings['LBL_SEVEN_EMPLOYEE_CONFIGURATION_TITLE'] = 'Employee Template Configuration';
22+
$mod_strings['LBL_SEVEN_EMPLOYEE_CONFIGURATION_DESC'] = 'Employee Template Configuration';
23+
2124
$mod_strings['LBL_SEVEN_PANEL_HEADING'] = 'SMS by seven';
2225
?>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$mod_strings['LBL_SEVEN_FROM'] = 'Absendekennung';
3+
$mod_strings['LBL_SEVEN_MESSAGES'] = 'Nachrichten';
4+
$mod_strings['LBL_SEVEN_MISSING_TEXT'] = 'Bitte Nachrichtentext eingeben';
5+
$mod_strings['LBL_SEVEN_PANEL_HEADING'] = 'SMS-Verlauf';
6+
$mod_strings['LBL_SEVEN_SEND_SMS_VIA'] = 'SMS-Versand via seven';
7+
$mod_strings['LBL_SEVEN_SEND_SMS'] = 'SMS versenden';
8+
$mod_strings['LBL_SEVEN_TEXT'] = 'Text';
9+
$mod_strings['LBL_SEVEN_TO'] = 'Anrufziel';
10+
$mod_strings['LBL_SEVEN_TO_HELP'] = 'Mehrere Anrufziele per Komma getrennt angeben';
11+
$mod_strings['LBL_SEVEN_WRITE_SMS'] = 'SMS schreiben';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$mod_strings['LBL_SEVEN_FROM'] = 'From';
3+
$mod_strings['LBL_SEVEN_MESSAGES'] = 'Messages';
4+
$mod_strings['LBL_SEVEN_MISSING_TEXT'] = 'Please enter a message';
5+
$mod_strings['LBL_SEVEN_PANEL_HEADING'] = 'SMS History';
6+
$mod_strings['LBL_SEVEN_SEND_SMS_VIA'] = 'Send SMS via seven';
7+
$mod_strings['LBL_SEVEN_SEND_SMS'] = 'Send SMS';
8+
$mod_strings['LBL_SEVEN_TEXT'] = 'Text';
9+
$mod_strings['LBL_SEVEN_TO'] = 'To';
10+
$mod_strings['LBL_SEVEN_TO_HELP'] = 'Add more recipients separated by comma';
11+
$mod_strings['LBL_SEVEN_WRITE_SMS'] = 'Write SMS';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
// created: 2022-04-26 10:39:04
3+
$dictionary['Contact']['fields']['seven_compose_sms']['inline_edit'] = '0';
4+
$dictionary['Contact']['fields']['seven_compose_sms']['labelValue'] = 'Write SMS';
5+
6+
?>

SuiteModules/Extension/modules/Users/Ext/Language/en_us.lang.ext.php

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3+
4+
require_once 'modules/Employees/views/view.detail.php';
5+
require_once 'modules/seven/seven_util.php';
6+
7+
class CustomEmployeesViewDetail extends EmployeesViewDetail {
8+
public function display() {
9+
global $sugar_config;
10+
11+
$history = array_merge($this->getOutboundSms(), $this->getInboundSms());
12+
13+
usort($history, function (SugarBean $a, SugarBean $b) {
14+
return strcmp($a->date_entered, $b->date_entered);
15+
});
16+
17+
/** @var Employee $employee */
18+
$employee = $this->bean;
19+
$this->ss->assign('SEVEN_BEAN_ID', $this->bean->id);
20+
$this->ss->assign('SEVEN_FROM', $sugar_config['seven_sender'] ?? '');
21+
$this->ss->assign('SEVEN_MODULE', $this->module);
22+
$this->ss->assign('SEVEN_SMS_HISTORY', $history);
23+
$this->ss->assign('SEVEN_TO', $employee->phone_mobile);
24+
25+
echo $this->ss->fetch('modules/seven/tpls/sms_compose.tpl');
26+
27+
parent::display();
28+
}
29+
30+
private function getInboundSms(): array {
31+
return seven_util::getSMS('seven_sms_inbound', $this->bean);
32+
}
33+
34+
private function getOutboundSms(): array {
35+
return seven_util::getSMS('seven_sms', $this->bean);
36+
}
37+
}

SuiteModules/modules/seven/FeedPusher.php

Lines changed: 108 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
require_once 'modules/SugarFeed/feedLogicBase.php';
55
require_once 'modules/seven/seven_util.php';
66

7+
/** @noinspection PhpUnused */
8+
79
class FeedPusher extends FeedLogicBase {
810
public $module = 'Contacts';
911

@@ -31,6 +33,7 @@ protected function init($bean): array {
3133
return [$template, $templateActive];
3234
}
3335

36+
/** @noinspection PhpUnused */
3437
public function pushFeed($bean, $event, $arguments) {
3538
global $locale, $sms;
3639

@@ -46,48 +49,54 @@ public function pushFeed($bean, $event, $arguments) {
4649
$fullName = trim($fullName);
4750
[$firstName, $lastName] = explode(' ', $fullName);
4851
[$template, $templateActive] = $this->init($bean);
49-
50-
if ($templateActive) {
51-
$numbers = seven_util::getValidPhoneNumbers([$mobilePhone, $officePhone]);
52-
53-
$accountPlaceholders = [
54-
'{account_type}' => $bean->account_type,
55-
'{annual_revenue}' => $bean->annual_revenue,
56-
'{assigned_user_id}' => $bean->assigned_user_id,
57-
'{billing_address_city}' => $bean->billing_address_city,
58-
'{billing_address_country}' => $bean->billing_address_country,
59-
'{billing_address_postalcode}' => $bean->billing_address_postalcode,
60-
'{billing_address_state}' => $bean->billing_address_state,
61-
'{billing_address_street}' => $bean->billing_address_street,
62-
'{campaign_id}' => $bean->campaign_id,
63-
'{created_by}' => $bean->created_by,
64-
'{date_entered}' => $bean->date_entered,
65-
'{date_modified}' => $bean->date_modified,
66-
'{deleted}' => $bean->deleted,
67-
'{description}' => $bean->description,
68-
'{employees}' => $bean->employees,
69-
'{id}' => $bean->id,
70-
'{industry}' => $bean->industry,
71-
'{modified_user_id}' => $bean->modified_user_id,
72-
'{name}' => $bean->name,
73-
'{ownership}' => $bean->ownership,
74-
'{parent_id}' => $bean->parent_id,
75-
'{phone_alternate}' => $bean->phone_alternate,
76-
'{phone_fax}' => $bean->phone_fax,
77-
'{phone_office}' => $bean->phone_office,
78-
'{rating}' => $bean->rating,
79-
'{shipping_address_city}' => $bean->shipping_address_city,
80-
'{shipping_address_country}' => $bean->shipping_address_country,
81-
'{shipping_address_postalcode}' => $bean->shipping_address_postalcode,
82-
'{shipping_address_state}' => $bean->shipping_address_state,
83-
'{shipping_address_street}' => $bean->shipping_address_street,
84-
'{sic_code}' => $bean->sic_code,
85-
'{ticker_symbol}' => $bean->ticker_symbol,
86-
'{website}' => $bean->website,
87-
];
88-
89-
if (count($numbers)) {
90-
$search = $this->module === 'Accounts' ? array_keys($accountPlaceholders) : [
52+
if (!$templateActive) return;
53+
54+
$numbers = seven_util::getValidPhoneNumbers([$mobilePhone, $officePhone]);
55+
if (!count($numbers)) return;
56+
57+
switch ($this->module) {
58+
case 'Accounts':
59+
$placeholders = [
60+
'{account_type}' => $bean->account_type,
61+
'{annual_revenue}' => $bean->annual_revenue,
62+
'{assigned_user_id}' => $bean->assigned_user_id,
63+
'{billing_address_city}' => $bean->billing_address_city,
64+
'{billing_address_country}' => $bean->billing_address_country,
65+
'{billing_address_postalcode}' => $bean->billing_address_postalcode,
66+
'{billing_address_state}' => $bean->billing_address_state,
67+
'{billing_address_street}' => $bean->billing_address_street,
68+
'{campaign_id}' => $bean->campaign_id,
69+
'{created_by}' => $bean->created_by,
70+
'{date_entered}' => $bean->date_entered,
71+
'{date_modified}' => $bean->date_modified,
72+
'{deleted}' => $bean->deleted,
73+
'{description}' => $bean->description,
74+
'{employees}' => $bean->employees,
75+
'{id}' => $bean->id,
76+
'{industry}' => $bean->industry,
77+
'{modified_user_id}' => $bean->modified_user_id,
78+
'{name}' => $bean->name,
79+
'{ownership}' => $bean->ownership,
80+
'{parent_id}' => $bean->parent_id,
81+
'{phone_alternate}' => $bean->phone_alternate,
82+
'{phone_fax}' => $bean->phone_fax,
83+
'{phone_office}' => $bean->phone_office,
84+
'{rating}' => $bean->rating,
85+
'{shipping_address_city}' => $bean->shipping_address_city,
86+
'{shipping_address_country}' => $bean->shipping_address_country,
87+
'{shipping_address_postalcode}' => $bean->shipping_address_postalcode,
88+
'{shipping_address_state}' => $bean->shipping_address_state,
89+
'{shipping_address_street}' => $bean->shipping_address_street,
90+
'{sic_code}' => $bean->sic_code,
91+
'{ticker_symbol}' => $bean->ticker_symbol,
92+
'{website}' => $bean->website,
93+
];
94+
$search = array_keys($placeholders);
95+
$replace = array_values($placeholders);
96+
break;
97+
case 'Contacts':
98+
case 'Leads':
99+
$search = [
91100
'{first-name}',
92101
'{last-name}',
93102
'{full-name}',
@@ -110,7 +119,7 @@ public function pushFeed($bean, $event, $arguments) {
110119
'{description}',
111120
'{date}',
112121
];
113-
$replace = $this->module === 'Accounts' ? array_values($accountPlaceholders) : [
122+
$replace = [
114123
$firstName,
115124
$lastName,
116125
$bean->first_name . ' ' . $bean->last_name,
@@ -133,12 +142,64 @@ public function pushFeed($bean, $event, $arguments) {
133142
$bean->description,
134143
date('d/m/Y'),
135144
];
136-
$msg = str_replace($search, $replace, trim($template));
137-
138-
$sms->apiCall($sms->getSender(), $msg, implode(',', $numbers));
139-
}
145+
break;
146+
case 'Employees':
147+
$placeholders = [
148+
'{address_city}' => $bean->address_city,
149+
'{address_country}' => $bean->address_country,
150+
'{address_postalcode}' => $bean->address_postalcode,
151+
'{address_state}' => $bean->address_state,
152+
'{address_street}' => $bean->address_street,
153+
'{authenticate_id}' => $bean->authenticate_id,
154+
'{created_by}' => $bean->created_by,
155+
'{date_entered}' => $bean->date_entered,
156+
'{date_modified}' => $bean->date_modified,
157+
'{deleted}' => $bean->deleted,
158+
'{department}' => $bean->department,
159+
'{description}' => $bean->description,
160+
'{employee_status}' => $bean->employee_status,
161+
'{external_auth_only}' => $bean->external_auth_only,
162+
'{factor_auth_interface}' => $bean->factor_auth_interface,
163+
'{factor_auth}' => $bean->factor_auth,
164+
'{first_name}' => $bean->first_name,
165+
'{id}' => $bean->id,
166+
'{is_admin}' => $bean->is_admin,
167+
'{is_group}' => $bean->is_group,
168+
'{last_name}' => $bean->last_name,
169+
'{messenger_id}' => $bean->messenger_id,
170+
'{messenger_type}' => $bean->messenger_type,
171+
'{modified_user_id}' => $bean->modified_user_id,
172+
'{phone_fax}' => $bean->phone_fax,
173+
'{phone_home}' => $bean->phone_home,
174+
'{phone_mobile}' => $bean->phone_mobile,
175+
'{phone_other}' => $bean->phone_other,
176+
'{phone_work}' => $bean->phone_work,
177+
'{photo}' => $bean->photo,
178+
'{portal_only}' => $bean->portal_only,
179+
'{pwd_last_changed}' => $bean->pwd_last_changed,
180+
'{receive_notifications}' => $bean->receive_notifications,
181+
'{reports_to_id}' => $bean->reports_to_id,
182+
'{show_on_employees}' => $bean->show_on_employees,
183+
'{status}' => $bean->status,
184+
'{sugar_login}' => $bean->sugar_login,
185+
'{system_generated_password}' => $bean->system_generated_password,
186+
'{title}' => $bean->title,
187+
'{user_hash}' => $bean->user_hash,
188+
'{user_name}' => $bean->user_name,
189+
];
190+
$search = array_keys($placeholders);
191+
$replace = array_values($placeholders);
192+
break;
193+
default:
194+
return;
140195
}
141196

197+
$sms->apiCall(
198+
$sms->getSender(),
199+
str_replace($search, $replace, trim($template)),
200+
implode(',', $numbers)
201+
);
202+
142203
SugarFeed::pushFeed2('{SugarFeed.CREATED_' . substr(strtoupper($this->module), 0, -1)
143204
. '} [' . $bean->module_dir . ':' . $bean->id . ':' . $fullName . ']', $bean);
144205
}

0 commit comments

Comments
 (0)