From 6002cad14a42b330ec6a8fdd5da11ee833af2eee Mon Sep 17 00:00:00 2001 From: MatteoPistorello Date: Thu, 30 Dec 2021 10:59:21 +0100 Subject: [PATCH] Aggiunta gestione dinamica template sms --- editor.php | 9 ++++++- modules/anagrafiche/variables.php | 1 + src/HTMLBuilder/Manager/ButtonManager.php | 32 ++++++++++++++++------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/editor.php b/editor.php index 4c76c38f8..4b38c90cf 100755 --- a/editor.php +++ b/editor.php @@ -166,7 +166,14 @@ if (empty($record) || !$has_access) {
{( "name": "button", "type": "print", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "id_record": "'.$id_record.'" )} - {( "name": "button", "type": "email", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "id_record": "'.$id_record.'" )} + {( "name": "button", "type": "email", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "id_record": "'.$id_record.'" )}'; + + if (Modules::get('Account SMS')) { + echo ' + {( "name": "button", "type": "sms", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "id_record": "'.$id_record.'" )}'; + } + + echo '
diff --git a/modules/anagrafiche/variables.php b/modules/anagrafiche/variables.php index 4029d6206..5d1f3ce1e 100755 --- a/modules/anagrafiche/variables.php +++ b/modules/anagrafiche/variables.php @@ -25,4 +25,5 @@ $anagrafica = Anagrafica::find($id_record); return [ 'ragione_sociale' => $anagrafica->ragione_sociale, 'codice' => $anagrafica->codice, + 'id_anagrafica' => $anagrafica->idanagrafica, ]; diff --git a/src/HTMLBuilder/Manager/ButtonManager.php b/src/HTMLBuilder/Manager/ButtonManager.php index 14751347e..43b2fc686 100755 --- a/src/HTMLBuilder/Manager/ButtonManager.php +++ b/src/HTMLBuilder/Manager/ButtonManager.php @@ -19,7 +19,8 @@ namespace HTMLBuilder\Manager; -use Modules\Emails\Template; +use Modules\Emails\Template AS TemplateEmail; +use Modules\SMS\Template AS TemplateSMS; /** * @since 2.4 @@ -32,7 +33,7 @@ class ButtonManager implements ManagerInterface // Impostazione id HTML automatico if (empty($options['html_id'])) { - $options['html_id'] = ($options['type'] == 'print') ? 'print-button' : 'email-button'; + $options['html_id'] = ($options['type'] == 'print') ? 'print-button' : (($options['type'] == 'email') ? 'email-button' : (($options['type'] == 'sms') ? 'sms' : '')); } if (isset($options['id'])) { @@ -54,13 +55,22 @@ class ButtonManager implements ManagerInterface 'title' => tr('Stampa').' '.((strtoupper($print['title']) == $print['title']) ? $print['title'] : lcfirst($print['title'])), 'icon' => $print['icon'], ]; - } else { - $template = Template::find($options['id']); + } elseif ($options['type'] == 'email') { + $template_email = TemplateEmail::find($options['id']); $result = [ 'link' => base_path().'/mail.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].'&id='.$options['id'].$options['parameters'], - 'title' => tr('Invia').' '.((strtoupper($template['name']) == $template['name']) ? $template['name'] : lcfirst($template['name'])), - 'icon' => $template['icon'], + 'title' => tr('Invia').' '.((strtoupper($template_email['name']) == $template_email['name']) ? $template_email['name'] : lcfirst($template_email['name'])), + 'icon' => $template_email['icon'], + 'type' => 'modal', + ]; + } elseif ($options['type'] == 'sms') { + $template_sms = TemplateSMS::find($options['id']); + + $result = [ + 'link' => base_path().'/modules/sms/sms.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].'&id='.$options['id'].$options['parameters'], + 'title' => tr('Invia').' '.((strtoupper($template_sms['name']) == $template_sms['name']) ? $template_sms['name'] : lcfirst($template_sms['name'])), + 'icon' => $template_sms['icon'], 'type' => 'modal', ]; } @@ -107,8 +117,10 @@ class ButtonManager implements ManagerInterface if ($options['type'] == 'print') { $results = \Prints::getModulePrints($options['id_module']); - } else { - $results = Template::where('id_module', $options['id_module'])->get()->toArray(); + } elseif ($options['type'] == 'email') { + $results = TemplateEmail::where('id_module', $options['id_module'])->get()->toArray(); + } elseif ($options['type'] == 'sms') { + $results = TemplateSMS::where('id_module', $options['id_module'])->get()->toArray(); } return $results; @@ -186,8 +198,10 @@ class ButtonManager implements ManagerInterface { if ($options['type'] == 'print') { $result = ' '.tr('Stampa'); - } else { + } elseif ($options['type'] == 'email') { $result = ' '.tr('Invia'); + } elseif ($options['type'] == 'sms') { + $result = ' '.tr('Invia'); } return $result;