Miglioramenti per le email (#9)

This commit is contained in:
Thomas Zilio 2018-02-23 09:49:31 +01:00
parent a045fa8250
commit 0a4a9c14ea
5 changed files with 63 additions and 31 deletions

View File

@ -3,7 +3,7 @@
include_once __DIR__.'/core.php';
$pageTitle = 'Bug';
$jscript_modules[] = $js.'/ckeditor/ckeditor.js';
$jscript_modules[] = App::getPaths()['js'].'/ckeditor/ckeditor.js';
if (filter('op') == 'send') {
// Preparazione email
@ -193,10 +193,7 @@ echo '
var firstFocus = 1;
CKEDITOR.replace("body", {
toolbar: [
{ name: "document", items: [ "NewPage", "Preview", "-", "Templates" ] }, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups
["Bold","Italic","Underline","Superscript","-","NumberedList","BulletedList","Outdent","Indent","Blockquote","-","Format",], // Defines toolbar group without name
]
toolbar: globals.ckeditorToolbar
});
CKEDITOR.instances.body.on("key", function() {

View File

@ -92,7 +92,7 @@ if (empty($records)) {
// Pulsanti di default
echo '
<div id="pulsanti" data-spy="affix" data-offset-top="200">
<div id="pulsanti">
<a class="btn btn-warning" href="'.ROOTDIR.'/controller.php?id_module='.$id_module.'">
<i class="fa fa-chevron-left"></i> '.tr("Torna all'elenco").'
</a>
@ -117,6 +117,15 @@ if (empty($records)) {
$("#save").click(function(){
$("#submit").trigger("click");
});';
// Pulsanti dinamici
if (!isMobile()) {
echo '
$("#pulsanti").affix({
offset: {
top: 200
}
});
$("#pulsanti").on("affix.bs.affix", function(){
@ -125,7 +134,10 @@ if (empty($records)) {
$("#pulsanti").on("affix-top.bs.affix", function(){
$("#pulsanti").css("width", "100%");
});
});';
}
echo '
});
</script>

View File

@ -98,17 +98,31 @@ if (Auth::check()) {
echo '
};
globals = {
rootdir: \''.$rootdir.'\', js: \''.$paths['js'].'\', css: \''.$paths['css'].'\', img: \''.$paths['img'].'\',
rootdir: \''.$rootdir.'\',
js: \''.$paths['js'].'\',
css: \''.$paths['css'].'\',
img: \''.$paths['img'].'\',
id_module: \''.$id_module.'\',
id_record: \''.$id_record.'\',
aggiornamenti_id: \''.($dbo->isInstalled() ? Modules::get('Aggiornamenti')['id'] : '').'\',
cifre_decimali: '.get_var('Cifre decimali per importi').',
decimals: "'.Translator::getFormatter()->getNumberSeparators()['decimals'].'", thousands: "'.Translator::getFormatter()->getNumberSeparators()['thousands'].'",
decimals: "'.Translator::getFormatter()->getNumberSeparators()['decimals'].'",
thousands: "'.Translator::getFormatter()->getNumberSeparators()['thousands'].'",
search: search,
translations: translations,
locale: \''.$lang.'\',
start_date: \''.Translator::dateToLocale($_SESSION['period_start']).'\',
end_date: \''.Translator::dateToLocale($_SESSION['period_end']).'\',
locale: \''.$lang.'\',
ckeditorToolbar: [
[ "Bold", "Italic", "Underline", "Superscript", "-", "NumberedList", "BulletedList", "Outdent", "Indent", "Blockquote", "-", "Format"],
],
};
</script>';
}

View File

@ -119,11 +119,18 @@ echo '
emails = JSON.parse(response);
$(".destinatari").each(function(){
$(this).autocomplete({source: emails});
$(this).autocomplete({
source: emails,
minLength: 0
}).focus(function() {
$(this).autocomplete("search", $(this).val())
});;
});
});
CKEDITOR.replace("body");
CKEDITOR.replace("body", {
toolbar: globals.ckeditorToolbar
});
});
function send(){

View File

@ -84,35 +84,35 @@ echo '
</div>
<?php
// Variabili utilizzabili
$module_dir = DOCROOT.'/modules/'.Modules::get($records[0]['id_module'])['directory'];
$variables = [];
// Variabili utilizzabili
$module_dir = DOCROOT.'/modules/'.Modules::get($records[0]['id_module'])['directory'];
$variables = [];
if (file_exists($module_dir.'/custom/variables.php') ) {
$variables = include $module_dir.'/custom/variables.php';
} elseif (file_exists($module_dir.'/variables.php') ) {
$variables = include $module_dir.'/variables.php';
}
if (file_exists($module_dir.'/custom/variables.php')) {
$variables = include $module_dir.'/custom/variables.php';
} elseif (file_exists($module_dir.'/variables.php')) {
$variables = include $module_dir.'/variables.php';
}
if (sizeof($variables) > 0) {
echo '
if (sizeof($variables) > 0) {
echo '
<div class="alert alert-info">
<p>Puoi utilizzare le seguenti variabili nell\'oggetto e nel corpo della mail:</p>
<ul>';
foreach ($variables as $variable => $value) {
echo '<li>{'.$variable.'}</li>';
}
foreach ($variables as $variable => $value) {
echo '<li>{'.$variable.'}</li>';
}
echo '
echo '
</ul>
</div>';
} else {
echo '
} else {
echo '
<div class="alert alert-warning">
<i class="fa fa-warning"></i> Non sono state definite variabili da utilizzare nel template.
</div>';
}
?>
}
?>
</div>
</div>
@ -125,6 +125,8 @@ echo '
<script>
$(document).ready(function(){
CKEDITOR.replace("body");
CKEDITOR.replace("body", {
toolbar: globals.ckeditorToolbar
});
});
</script>