2022-11-15 17:38:42 +01:00
< ? php
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
* Copyright ( C ) DevCode s . r . l .
*
* 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 />.
*/
2024-01-15 15:30:45 +01:00
use Models\Module ;
2023-01-11 18:02:09 +01:00
2022-11-15 17:38:42 +01: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 " >
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
2024-05-17 12:11:00 +02:00
< div class = " card-header " >
2024-05-16 18:02:50 +02:00
< h3 class = " card-title " > '.tr(' Listino ').' </ h3 >
2022-11-15 17:38:42 +01:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2022-11-15 17:38:42 +01:00
< div class = " row " >
2022-11-28 14:50:21 +01:00
< div class = " col-md-6 " >
2022-11-15 17:38:42 +01:00
{[ " type " : " text " , " label " : " '.tr('Nome').' " , " name " : " nome " , " value " : " $nome $ " , " required " : " 1 " ]}
</ div >
< div class = " col-md-3 " >
{[ " type " : " date " , " label " : " '.tr('Data attivazione').' " , " name " : " data_attivazione " , " value " : " $data_attivazione $ " , " required " : " 1 " ]}
</ div >
< div class = " col-md-3 " >
2023-12-28 16:18:02 +01:00
{[ " type " : " date " , " label " : " '.tr('Data scadenza predefinita').' " , " name " : " data_scadenza_predefinita " , " value " : " $data_scadenza_predefinita $ " , " required " : " 1 " ]}
2022-11-15 17:38:42 +01:00
</ div >
2022-11-28 14:50:21 +01:00
</ div >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " checkbox " , " label " : " '.tr('Sempre visibile').' " , " name " : " is_sempre_visibile " , " value " : " $is_sempre_visibile $ " , " help " : " '.tr('Se impostato il valore sarà sempre visibile sull \ 'articolo se il listino è attivo e la data di scadenza è ancora valida').' " ]}
</ div >
2022-11-15 17:38:42 +01:00
2022-11-28 14:50:21 +01:00
< div class = " col-md-6 " >
{[ " type " : " checkbox " , " label " : " '.tr('Attivo').' " , " name " : " attivo " , " value " : " $attivo $ " ]}
2022-11-15 17:38:42 +01:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " textarea " , " label " : " '.tr('Note').' " , " name " : " note " , " value " : " $note $ " ]}
</ div >
</ div >
< hr >
< div class = " row " >
2023-01-12 16:27:33 +01:00
< div class = " col-md-5 " >
2022-11-15 17:38:42 +01:00
{[ " type " : " select " , " label " : " '.tr('Articolo').' " , " ajax-source " : " articoli " , " select-options " : { " permetti_movimento_a_zero " : 1 , " id_listino " : '.$id_record.' } ]}
</ div >
2023-01-12 16:27:33 +01:00
< div class = " col-md-1 " >
2022-11-15 17:38:42 +01:00
< div class = " btn-group btn-group-flex " >
< button type = " button " class = " btn btn-primary " style = " margin-top:25px; " onclick = " aggiungiArticolo(this, true) " >
< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').'
</ button >
</ div >
</ div >
</ div >
2023-09-28 09:27:44 +02:00
< table class = " table table-hover table-condensed table-bordered " id = " tablelistini " width = " 100% " >
2023-01-11 18:02:09 +01:00
< thead >
2022-11-15 17:38:42 +01:00
< tr >
2023-01-11 18:02:09 +01:00
< th class = " text-center " >
2022-11-28 14:50:21 +01:00
< br >< input id = " check_all " type = " checkbox " />
</ th >
2023-09-06 09:58:24 +02:00
< th class = " text-center " > '.tr(' Codice ').' </ th >
< th class = " text-center " > '.tr(' Descrizione ').' </ th >
< th class = " text-center " > '.tr(' Data scadenza ').' </ th >
2023-01-12 16:27:33 +01:00
< th class = " text-center " > '.tr(' Minimo ').' </ th >
< th class = " text-center " > '.tr(' Prezzo di listino ').' </ th >
< th class = " text-center " > '.tr(' Prezzo ivato ').' </ th >
< th class = " text-center " > '.tr(' Sconto ').' </ th >
2023-09-06 09:58:24 +02:00
< th class = " text-center " ></ th >
2023-01-11 18:02:09 +01:00
</ tr >
</ thead >
</ table >
2022-11-28 14:50:21 +01:00
2023-01-11 18:02:09 +01:00
< div class = " btn-group " >
< button type = " button " class = " btn btn-xs btn-default disabled " id = " elimina_righe " onclick = " rimuoviArticolo(getSelectData()); " >
< i class = " fa fa-trash " ></ i >
</ button >
2022-11-15 17:38:42 +01:00
</ div >
</ div >
</ div >
</ form >
< a class = " btn btn-danger ask " data - backto = " record-list " >
< i class = " fa fa-trash " ></ i > '.tr(' Elimina ').'
</ a >
< script >
function aggiungiArticolo ( button ) {
2024-05-16 18:02:50 +02:00
let card = $ ( button ) . closest ( " .card " );
let id_articolo = card . find ( " select " ) . val ();
2022-11-15 17:38:42 +01:00
if ( id_articolo ) {
openModal ( " '.tr('Listino articolo').' " , " '. $structure->fileurl ('modals/manage_articolo.php').'?id_module='. $id_module .'&id_record='. $id_record .'&id_articolo= " + id_articolo );
} else {
swal ( " '.tr('Attenzione').' " , " '.tr('Inserire un articolo').' " , " warning " );
}
}
2023-01-11 18:02:09 +01:00
async function modificaArticolo ( button , id ) {
2022-11-15 17:38:42 +01:00
let riga = $ ( button ) . closest ( " tr " );
// Chiusura tooltip
if ( $ ( button ) . hasClass ( " tooltipstered " ))
$ ( button ) . tooltipster ( " close " );
// Apertura modal
openModal ( " '.tr('Listino articolo').' " , " '. $structure->fileurl ('modals/manage_articolo.php').'?id_module='. $id_module .'&id_record='. $id_record .'&id= " + id );
}
function rimuoviArticolo ( id ) {
swal ({
title : " '.tr('Rimuovere questo articolo?').' " ,
html : " '.tr('Sei sicuro di volere rimuovere questo articolo dal listino?').' '.tr( " L 'operazione è irreversibile").' . " ,
type : " warning " ,
showCancelButton : true ,
confirmButtonText : " '.tr('Sì').' "
}) . then ( function () {
$ . ajax ({
url : globals . rootdir + " /actions.php " ,
type : " POST " ,
dataType : " json " ,
data : {
id_module : globals . id_module ,
id_record : globals . id_record ,
op : " delete_articolo " ,
id : id ,
},
success : function ( response ) {
location . reload ();
},
error : function () {
location . reload ();
}
});
}) . catch ( swal . noop );
}
2022-11-28 14:50:21 +01:00
$ ( document ) . ready ( function (){
2023-01-11 18:02:09 +01:00
const table = $ ( " #tablelistini " ) . DataTable ({
language : globals . translations . datatables ,
retrieve : true ,
ordering : false ,
2023-01-12 16:27:33 +01:00
searching : true ,
2023-01-11 18:02:09 +01:00
paging : true ,
order : [],
lengthChange : false ,
processing : true ,
serverSide : true ,
ajax : {
2024-04-18 17:44:05 +02:00
url : " '.Module::find((new Module())->getByField('title', 'Listini cliente', Models \ Locale::getPredefined()->id))->fileurl('ajax/table.php').'?id_listino='. $id_record .' " ,
2023-01-11 18:02:09 +01:00
type : " GET " ,
dataSrc : " data " ,
},
searchDelay : 500 ,
pageLength : 15 ,
});
table . on ( " processing.dt " , function ( e , settings , processing ) {
if ( processing ) {
$ ( " #mini-loader " ) . show ();
} else {
$ ( " #mini-loader " ) . hide ();
}
});
2022-11-28 14:50:21 +01:00
});
// Estraggo le righe spuntate
function getSelectData () {
let data = new Array ();
$ ( \ ' #tablelistini\').find(\'.check:checked\').each(function (){
2023-01-11 18:02:09 +01:00
data . push ( $ ( this ) . attr ( \ ' id\ ' ));
2022-11-28 14:50:21 +01:00
});
return data ;
}
2023-01-11 18:02:09 +01:00
setTimeout ( function () {
$ ( " .check " ) . on ( " change " , function () {
let checked = 0 ;
$ ( " .check " ) . each ( function () {
if ( $ ( this ) . is ( " :checked " )) {
checked = 1 ;
}
});
if ( checked ) {
$ ( " #elimina_righe " ) . removeClass ( " disabled " );
} else {
$ ( " #elimina_righe " ) . addClass ( " disabled " );
2022-11-28 14:50:21 +01:00
}
});
2023-01-11 18:02:09 +01:00
}, 1000 );
2022-11-28 14:50:21 +01:00
$ ( " #check_all " ) . click ( function (){
if ( $ ( this ) . is ( " :checked " ) ){
$ ( " .check " ) . each ( function (){
if ( ! $ ( this ) . is ( " :checked " ) ){
$ ( this ) . trigger ( " click " );
}
});
} else {
$ ( " .check " ) . each ( function (){
if ( $ ( this ) . is ( " :checked " ) ){
$ ( this ) . trigger ( " click " );
}
});
}
});
2023-08-04 14:54:28 +02:00
</ script > ' ;