This commit is contained in:
Pek5892 2024-03-01 17:32:31 +01:00
parent cd801efce9
commit a69f016a29
8 changed files with 90 additions and 84 deletions

View File

@ -120,7 +120,7 @@ if (!empty($options['create_document'])) {
elseif ($final_module['name'] == 'Interventi') {
echo '
<div class="col-md-6">
{[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato_intervento", "required": 1, "values": "query=SELECT `id_statiintervento`.`id`, `in_statiintervento_lang`.`name` as `descrizione`, `colore` AS _bgcolor_ FROM `in_statiintervento` LEFT JOIN `in_statiintervento_lang` ON (`in_statiintervento`.`id` = `in_statiintervento_lang`.`id_record` AND `in_statiintervento_lang`.`id_lang` = '.prepare(setting('Lingua')).') WHERE `deleted_at` IS NULL AND `is_completato` = 0 ORDER BY `name`" ]}
{[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato_intervento", "required": 1, "values": "query=SELECT `in_statiintervento`.`id`, `in_statiintervento_lang`.`name` as `descrizione`, `colore` AS _bgcolor_ FROM `in_statiintervento` LEFT JOIN `in_statiintervento_lang` ON (`in_statiintervento`.`id` = `in_statiintervento_lang`.`id_record` AND `in_statiintervento_lang`.`id_lang` = '.prepare(setting('Lingua')).') WHERE `deleted_at` IS NULL AND `is_completato` = 0 ORDER BY `name`" ]}
</div>
<div class="col-md-6">

View File

@ -63,6 +63,7 @@ switch (filter('op')) {
break;
case 'delete':
$lista = Lista::find($id_record);
$lista->delete();
flash()->info(tr('Lista newsletter rimossa!'));

View File

@ -99,85 +99,86 @@ echo '
</div>
</form>';
$numero_destinatari = $lista->destinatari()->count();
$destinatari_senza_mail = $lista->getNumeroDestinatariSenzaEmail();
if ($lista) {
$numero_destinatari = $lista->destinatari()->count();
$destinatari_senza_mail = $lista->getNumeroDestinatariSenzaEmail();
echo '
<!-- Destinatari -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
'.tr('Destinatari').'
<span> ('.$numero_destinatari.')</span> <div class="pull-right" >
'.(($destinatari_senza_mail > 0) ? ' <span title="'.tr('Indirizzi e-mail mancanti').'" class="tip label label-danger clickable">'.$destinatari_senza_mail.'</span>' : '')
.'<span title="'.tr('Indirizzi e-mail senza consenso per newsletter').'" class="tip label label-warning clickable" id="numero_consenso_disabilitato"></span></div>
</h3>
echo '
<!-- Destinatari -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
'.tr('Destinatari').'
<span> ('.$numero_destinatari.')</span> <div class="pull-right" >
'.(($destinatari_senza_mail > 0) ? ' <span title="'.tr('Indirizzi e-mail mancanti').'" class="tip label label-danger clickable">'.$destinatari_senza_mail.'</span>' : '')
.'<span title="'.tr('Indirizzi e-mail senza consenso per newsletter').'" class="tip label label-warning clickable" id="numero_consenso_disabilitato"></span></div>
</h3>
</div>
<div class="panel-body">
<table class="table table-hover table-condensed table-bordered" id="destinatari">
<thead>
<tr>
<th>'.tr('Ragione sociale').'</th>
<th>'.tr('Tipo').'</th>
<th>'.tr('Tipologia').'</th>
<th class="text-center">'.tr('E-mail').'</th>
<th class="text-center">'.tr('Newsletter').'</th>
<th class="text-center" width="60">#</th>
</tr>
</thead>
</table>
<a class="btn btn-danger ask pull-right" data-backto="record-edit" data-op="remove_all_receivers">
<i class="fa fa-trash"></i> '.tr('Elimina tutti').'
</a>
</div>
</div>
<div class="panel-body">
<table class="table table-hover table-condensed table-bordered" id="destinatari">
<thead>
<tr>
<th>'.tr('Ragione sociale').'</th>
<th>'.tr('Tipo').'</th>
<th>'.tr('Tipologia').'</th>
<th class="text-center">'.tr('E-mail').'</th>
<th class="text-center">'.tr('Newsletter').'</th>
<th class="text-center" width="60">#</th>
</tr>
</thead>
</table>
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>
<script>
globals.newsletter = {
senza_consenso: "'.$lista->getNumeroDestinatariSenzaConsenso().'",
table_url: "'.Module::pool('Newsletter')->fileurl('ajax/table.php').'?id_list='.$id_record.'",
};
<a class="btn btn-danger ask pull-right" data-backto="record-edit" data-op="remove_all_receivers">
<i class="fa fa-trash"></i> '.tr('Elimina tutti').'
</a>
</div>
</div>
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';
echo '
<script>
globals.newsletter = {
senza_consenso: "'.$lista->getNumeroDestinatariSenzaConsenso().'",
table_url: "'.Module::pool('Newsletter')->fileurl('ajax/table.php').'?id_list='.$id_record.'",
};
$(document).ready(function() {
const senza_consenso = $("#numero_consenso_disabilitato");
if (globals.newsletter.senza_consenso > 0) {
senza_consenso.text(globals.newsletter.senza_consenso);
} else {
senza_consenso.hide();
}
const table = $("#destinatari").DataTable({
language: globals.translations.datatables,
retrieve: true,
ordering: false,
searching: true,
paging: true,
order: [],
lengthChange: false,
processing: true,
serverSide: true,
ajax: {
url: globals.newsletter.table_url,
type: "GET",
dataSrc: "data",
},
searchDelay: 500,
pageLength: 50,
});
table.on("processing.dt", function (e, settings, processing) {
if (processing) {
$("#mini-loader").show();
$(document).ready(function() {
const senza_consenso = $("#numero_consenso_disabilitato");
if (globals.newsletter.senza_consenso > 0) {
senza_consenso.text(globals.newsletter.senza_consenso);
} else {
$("#mini-loader").hide();
senza_consenso.hide();
}
const table = $("#destinatari").DataTable({
language: globals.translations.datatables,
retrieve: true,
ordering: false,
searching: true,
paging: true,
order: [],
lengthChange: false,
processing: true,
serverSide: true,
ajax: {
url: globals.newsletter.table_url,
type: "GET",
dataSrc: "data",
},
searchDelay: 500,
pageLength: 50,
});
table.on("processing.dt", function (e, settings, processing) {
if (processing) {
$("#mini-loader").show();
} else {
$("#mini-loader").hide();
}
});
});
});
</script>';
</script>';
}

View File

@ -35,7 +35,7 @@ switch (post('op')) {
], ['id' => $id_record]);
$dbo->update('in_statiintervento_lang', [
'descrizione' => post('descrizione'),
'name' => post('descrizione'),
], ['id_record' => $id_record, 'id_lang' => setting('Lingua')]);
flash()->info(tr('Informazioni salvate correttamente.'));

View File

@ -19,6 +19,9 @@
include_once __DIR__.'/../../core.php';
use Modules\Interventi\Stato;
$stato = Stato::find($id_record);
if ($record['can_delete']) {
$attr = '';
} else {
@ -39,7 +42,7 @@ if ($record['can_delete']) {
</div>
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": 1, "value": "$descrizione$" ]}
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": 1, "value": "<?php echo $stato->name; ?>" ]}
</div>
<div class="col-md-3">

View File

@ -20,5 +20,6 @@
include_once __DIR__.'/../../core.php';
if (isset($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM `in_statiintervento` LEFT JOIN `in_statiintervento_lang` ON (`in_statiintervento`.`id` = `in_statiintervento_lang`.`id_record` AND `in_statiintervento_lang`.`id_lang` = "'.prepare(setting('Lingua')).'") WHERE `id`='.prepare($id_record));
$record = $dbo->fetchOne('SELECT * FROM `in_statiintervento` LEFT JOIN `in_statiintervento_lang` ON (`in_statiintervento`.`id` = `in_statiintervento_lang`.`id_record` AND `in_statiintervento_lang`.`id_lang` = "'.prepare(setting('Lingua')).'") WHERE `in_statiintervento`.`id`='.prepare($id_record));
}

View File

@ -23,7 +23,6 @@ include_once __DIR__.'/../../core.php';
switch (post('op')) {
case 'update':
$tipo->name = post('descrizione');
$tipo->calcola_km = post('calcola_km');
$tipo->tempo_standard = post('tempo_standard');
$tipo->costo_orario = post('costo_orario');
@ -34,6 +33,8 @@ switch (post('op')) {
$tipo->costo_diritto_chiamata_tecnico = post('costo_diritto_chiamata_tecnico');
$tipo->save();
$database->query('UPDATE `in_tipiintervento_lang` SET `name` = '.prepare(post('descrizione')).' WHERE `id_record` = '.prepare($id_record).' AND `id_lang` = '.prepare(setting('Lingua')));
$fasce_ore = (array) post('fascia_ore');
$fascia_km = (array) post('fascia_km');
$fascia_diritto_chiamata = (array) post('fascia_diritto_chiamata');
@ -60,9 +61,9 @@ switch (post('op')) {
case 'add':
$codice = post('codice');
$descrizione = post('descrizione');
$tipo = Tipo::build($codice, $descrizione);
$tipo = Tipo::build($codice);
$database->query('INSERT INTO `in_tipiintervento_lang` (`id_lang`, `id_record`, `name`) VALUES ('.prepare(setting('Lingua')).', '.prepare($tipo->id).', '.prepare(post('descrizione')).')');
$tipo->tempo_standard = post('tempo_standard');
$tipo->calcola_km = post('calcola_km');

View File

@ -37,12 +37,11 @@ class Tipo extends Model
*
* @return self
*/
public static function build($codice, $descrizione)
public static function build($codice)
{
$model = new static();
$model->codice = $codice;
$model->name = $descrizione;
// Salvataggio delle informazioni
$model->save();