2019-09-24 10:09:29 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2019-09-24 10:09:29 +02:00
2021-08-03 14:59:42 +02:00
use Models\Module ;
2021-08-02 18:27:28 +02:00
2019-09-24 10:09:29 +02:00
include_once __DIR__ . '/../../core.php' ;
echo '
< form action = " " method = " post " id = " edit-form " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
<!-- DATI -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " > '.tr(' Dati campagna ').' </ h3 >
</ div >
2020-09-07 15:04:06 +02:00
2019-09-24 10:09:29 +02:00
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " text " , " label " : " '.tr('Nome').' " , " name " : " name " , " required " : 1 , " value " : " $name $ " ]}
</ div >
</ div >
2020-09-07 15:04:06 +02:00
2019-09-24 10:09:29 +02:00
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " textarea " , " label " : " '.tr('Descrizione').' " , " name " : " description " , " required " : 0 , " value " : " $description $ " ]}
</ div >
</ div >
2020-09-07 15:04:06 +02:00
2019-09-24 10:09:29 +02:00
< div class = " row " >
< div class = " col-md-12 " >
2021-08-03 14:59:42 +02:00
' . input ([
'type' => 'textarea' ,
'label' => tr ( 'Query dinamica' ),
'name' => 'query' ,
'required' => 0 ,
'value' => $lista -> query ,
2021-09-17 10:54:39 +02:00
'help' => tr ( " La query SQL deve restituire gli identificativi delle anagrafiche da inserire nella lista, sotto un campo di nome ''id'' " ) . '. <br>' . tr ( 'Per esempio: _SQL_' , [
'_SQL_' => 'SELECT idanagrafica AS id, \'Modules\\\\Anagrafiche\\\\Anagrafica\' AS tipo FROM an_anagrafiche' ,
]) . '. <br>' . tr ( 'Sono supportati i seguenti oggetti: _LIST_' , [
'_LIST_' => implode ( ', ' , [
slashes ( Modules\Anagrafiche\Anagrafica :: class ),
slashes ( Modules\Anagrafiche\Sede :: class ),
slashes ( Modules\Anagrafiche\Referente :: class ),
]),
]) . '.' ,
2021-08-03 14:59:42 +02:00
]) . '
2019-09-24 10:09:29 +02:00
</ div >
</ div >
</ div >
</ div >
</ form >
< form action = " " method = " post " id = " receivers-form " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " add_receivers " >
2020-09-07 15:04:06 +02:00
2019-09-24 10:09:29 +02:00
<!-- Destinatari -->
< div class = " box box-primary " >
< div class = " box-header " >
< h3 class = " box-title " > '.tr(' Aggiunta destinatari ').' </ h3 >
</ div >
2020-09-07 15:04:06 +02:00
2019-09-24 10:09:29 +02:00
< div class = " box-body " >
< div class = " row " >
< div class = " col-md-12 " >
2021-08-02 18:27:28 +02:00
{[ " type " : " select " , " label " : " '.tr('Destinatari').' " , " name " : " receivers[] " , " ajax-source " : " destinatari_newsletter " , " multiple " : 1 , " disabled " : '.intval(!empty($lista->query)).' ]}
2019-09-24 10:09:29 +02:00
</ div >
</ div >
2020-09-07 15:04:06 +02:00
2019-09-24 10:09:29 +02:00
< div class = " row pull-right " >
< div class = " col-md-12 " >
< button type = " submit " class = " btn btn-primary " >
< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').'
</ button >
</ div >
</ div >
</ div >
</ div >
</ form > ' ;
2021-08-03 14:59:42 +02:00
$numero_destinatari = $lista -> destinatari () -> count ();
$destinatari_senza_mail = $lista -> getNumeroDestinatariSenzaEmail ();
2019-09-24 10:09:29 +02:00
echo '
<!-- Destinatari -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " >
'.tr(' Destinatari ').'
2021-08-03 14:59:42 +02:00
< 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>
2019-09-24 10:09:29 +02:00
</ h3 >
</ div >
2020-09-07 15:04:06 +02:00
2021-08-03 14:59:42 +02:00
< div class = " panel-body " >
< table class = " table table-hover table-condensed table-bordered " id = " destinatari " >
2019-09-24 10:09:29 +02:00
< thead >
< tr >
2021-08-03 14:59:42 +02:00
< 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 >
2019-09-24 10:09:29 +02:00
< th class = " text-center " width = " 60 " > #</th>
</ tr >
</ thead >
2021-08-03 14:59:42 +02:00
</ table >
2022-11-22 17:46:29 +01:00
< 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 >
2019-09-24 10:09:29 +02:00
</ div >
</ div >
< a class = " btn btn-danger ask " data - backto = " record-list " >
< i class = " fa fa-trash " ></ i > '.tr(' Elimina ').'
</ a > ' ;
2021-08-03 14:59:42 +02:00
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 ();
}
2021-08-05 12:21:34 +02:00
const table = $ ( " #destinatari " ) . DataTable ({
2021-08-03 14:59:42 +02:00
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 ,
});
2021-08-05 12:21:34 +02:00
table . on ( " processing.dt " , function ( e , settings , processing ) {
if ( processing ) {
$ ( " #mini-loader " ) . show ();
} else {
$ ( " #mini-loader " ) . hide ();
}
});
2021-08-03 14:59:42 +02:00
});
</ script > ' ;