set remarks from manually sent order or user messages
This commit is contained in:
parent
eb5ece8fef
commit
b4ead1d4af
@ -89,7 +89,7 @@ class AdminOrder extends AdminController
|
||||
try {
|
||||
$sms = oxNew( Sms::class );
|
||||
if ( $sms->sendOrderMessage( $order, $messageBody ) ) {
|
||||
$this->setRemark( $messageBody );
|
||||
$this->setRemark( $sms->getRecipientsList(), $messageBody );
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
oxNew(successfullySentException::class, $sms->getResponse()->getSmsCount() )
|
||||
);
|
||||
@ -106,13 +106,13 @@ class AdminOrder extends AdminController
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setRemark( $messageBody )
|
||||
protected function setRemark( $recipients, $messageBody )
|
||||
{
|
||||
$remark = oxNew( Remark::class );
|
||||
$remark->assign( [
|
||||
'oxtype' => 'LMSMS',
|
||||
'oxparentid' => $this->getEditObjectId(),
|
||||
'oxtext' => $messageBody
|
||||
'oxtype' => AdminUser::REMARK_IDENT,
|
||||
'oxparentid' => $this->order->getUser()->getId(),
|
||||
'oxtext' => $recipients.PHP_EOL.$messageBody
|
||||
] );
|
||||
$remark->save();
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class AdminUser extends AdminController
|
||||
{
|
||||
const REMARK_IDENT = 'LMSMS';
|
||||
|
||||
protected $_sThisTemplate = 'd3adminuser.tpl';
|
||||
|
||||
/**
|
||||
@ -85,7 +87,7 @@ class AdminUser extends AdminController
|
||||
|
||||
$sms = oxNew(Sms::class);
|
||||
if ($sms->sendUserAccountMessage($user, $messageBody)) {
|
||||
$this->setRemark( $messageBody );
|
||||
$this->setRemark( $sms->getRecipientsList(), $messageBody );
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
sprintf(
|
||||
Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT'),
|
||||
@ -104,13 +106,13 @@ class AdminUser extends AdminController
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setRemark( $messageBody )
|
||||
protected function setRemark( $recipients, $messageBody )
|
||||
{
|
||||
$remark = oxNew( Remark::class );
|
||||
$remark->assign( [
|
||||
'oxtype' => 'LMSMS',
|
||||
'oxtype' => AdminUser::REMARK_IDENT,
|
||||
'oxparentid' => $this->getEditObjectId(),
|
||||
'oxtext' => $messageBody
|
||||
'oxtext' => $recipients.PHP_EOL.$messageBody
|
||||
] );
|
||||
$remark->save();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ use D3\Linkmobility4OXID\Application\Model\RequestFactory;
|
||||
use D3\LinkmobilityClient\Exceptions\ApiException;
|
||||
use D3\LinkmobilityClient\Request\RequestInterface;
|
||||
use D3\LinkmobilityClient\Response\ResponseInterface;
|
||||
use D3\LinkmobilityClient\ValueObject\Recipient;
|
||||
use D3\LinkmobilityClient\ValueObject\Sender;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
@ -30,6 +31,7 @@ use OxidEsales\Eshop\Core\Registry;
|
||||
class Sms
|
||||
{
|
||||
private $response;
|
||||
private $recipients = [];
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
@ -90,6 +92,7 @@ class Sms
|
||||
public function sendCustomRecipientMessage(array $recipientsArray, $message): bool
|
||||
{
|
||||
try {
|
||||
$this->setRecipients($recipientsArray);
|
||||
$configuration = oxNew( Configuration::class );
|
||||
$client = oxNew( MessageClient::class )->getClient();
|
||||
|
||||
@ -130,4 +133,20 @@ class Sms
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
protected function setRecipients(array $recipients)
|
||||
{
|
||||
$this->recipients = $recipients;
|
||||
}
|
||||
|
||||
public function getRecipientsList() : string
|
||||
{
|
||||
$list = [];
|
||||
/** @var Recipient $recipient */
|
||||
foreach ($this->recipients as $recipient) {
|
||||
$list[] = $recipient->get();
|
||||
}
|
||||
|
||||
return implode(', ', $list);
|
||||
}
|
||||
}
|
@ -35,6 +35,8 @@ $aLang = [
|
||||
'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' => 'Beim Versenden der Nachricht(en) ist ein unerwarteter Fehler aufgetreten.',
|
||||
'D3LM_EXC_NO_RECIPIENT_SET' => 'Kein (verwendbarer) Empfänger gesetzt.',
|
||||
|
||||
'D3LM_REMARK_SMS' => 'SMS-Nachr.',
|
||||
|
||||
'tbcluser_linkmobility' => 'SMS-Versand',
|
||||
'tbclorder_linkmobility' => 'SMS-Versand'
|
||||
];
|
||||
|
@ -0,0 +1,5 @@
|
||||
[{if $allitem->oxremark__oxtype->value == "LMSMS"}]
|
||||
[{oxmultilang ident="D3LM_REMARK_SMS"}]
|
||||
[{else}]
|
||||
[{$smarty.block.parent}]
|
||||
[{/if}]
|
@ -44,6 +44,18 @@ $aModule = [
|
||||
'd3sms_ordercanceled.tpl' => 'd3/linkmobility/Application/views/tpl/SMS/ordercanceled.tpl',
|
||||
],
|
||||
'events' => [],
|
||||
'blocks' => [
|
||||
[
|
||||
'template' => 'order_remark.tpl',
|
||||
'block' => 'admin_order_remark_type',
|
||||
'file' => 'Application/views/blocks/admin/admin_user_remark_type.tpl',
|
||||
],
|
||||
[
|
||||
'template' => 'user_remark.tpl',
|
||||
'block' => 'admin_user_remark_type',
|
||||
'file' => 'Application/views/blocks/admin/admin_user_remark_type.tpl',
|
||||
]
|
||||
],
|
||||
'settings' => [
|
||||
[
|
||||
'group' => $sModuleId.'_general',
|
||||
|
Loading…
Reference in New Issue
Block a user