2017-08-04 16:28:16 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
* Copyright ( C ) DevCode s . n . c .
*
* 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 />.
*/
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2018-02-23 16:04:50 +01:00
?> <form action="" method="post" id="edit-form">
2017-08-04 16:28:16 +02:00
< 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 " >
2018-02-18 19:53:23 +01:00
< h3 class = " panel-title " >< ? php echo tr ( 'Dati' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " row " >
2018-10-04 17:37:28 +02:00
< div class = " col-md-6 " >
2018-10-24 19:08:11 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Descrizione'); ?> " , " name " : " descrizione " , " value " : " $descrizione $ " , " required " : 1 ]}
2017-09-13 13:05:35 +02:00
</ div >
2019-05-08 11:19:33 +02:00
< div class = " col-md-4 " >
2018-10-24 19:08:11 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Codice Modalità (Fatturazione Elettronica)'); ?> " , " name " : " codice_modalita_pagamento_fe " , " value " : " $codice_modalita_pagamento_fe $ " , " values " : " query=SELECT codice as id, CONCAT(codice, ' - ', descrizione) AS descrizione FROM fe_modalita_pagamento " , " required " : 1 ]}
2018-10-04 17:37:28 +02:00
</ div >
2019-05-08 11:19:33 +02:00
< div class = " col-md-2 " >
{[ " type " : " checkbox " , " label " : " <?php echo tr('Pagamento di tipo Ri.Ba.'); ?> " , " name " : " riba " , " value " : " $riba $ " , " help " : " <?php echo tr('Abilitando questa impostazione, nelle fatture verrà visualizzata la banca del cliente'); ?> " ]}
</ div >
2018-10-04 17:37:28 +02:00
</ div >
< div class = " row " >
< div class = " col-md-6 " >
2018-08-11 15:49:46 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Conto predefinito per le vendite'); ?> " , " name " : " idconto_vendite " , " value " : " $idconto_vendite $ " , " ajax-source " : " conti " ]}
2017-09-13 13:05:35 +02:00
</ div >
2018-10-04 17:37:28 +02:00
< div class = " col-md-6 " >
2018-08-11 15:49:46 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Conto predefinito per gli acquisti'); ?> " , " name " : " idconto_acquisti " , " value " : " $idconto_acquisti $ " , " ajax-source " : " conti " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2018-02-18 19:53:23 +01:00
< h3 class = " panel-title " >< ? php echo tr ( 'Rate' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " data " >
< ? php
$values = '' ;
for ( $i = 1 ; $i <= 31 ; ++ $i ) {
$values .= '\"' . $i . '\": \"' . $i . '\"' ;
if ( $i != 31 ) {
$values .= ',' ;
}
}
2018-07-18 15:20:10 +02:00
$results = $dbo -> fetchArray ( 'SELECT * FROM `co_pagamenti` WHERE descrizione=' . prepare ( $record [ 'descrizione' ]) . ' ORDER BY `num_giorni` ASC' );
2017-08-04 16:28:16 +02:00
$cont = 1 ;
foreach ( $results as $result ) {
echo '
< div class = " box box-success " >
< div class = " box-header with-border " >
2017-09-10 14:35:41 +02:00
< h3 class = " box-title " > '.tr(' Rata _NUMBER_ ' , [
'_NUMBER_' => $cont ,
]) . ' </ h3 >
2018-02-20 16:46:23 +01:00
< a class = " btn btn-danger pull-right " onclick = " ';
2017-09-04 12:02:29 +02:00
echo " if(confirm(' " . tr ( 'Eliminare questo elemento?' ) . " ')) { location.href=' " . $rootdir . '/editor.php?id_module=' . $id_module . '&id_record=' . $id_record . '&op=delete_rata&id=' . $result [ 'id' ] . " '; } " ;
echo '"><i class="fa fa-trash"></i> ' . tr ( 'Elimina' ) . ' </ a >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " box-body " >
< input type = " hidden " value = " '. $result['id'] .' " name = " id[] " >
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Percentuale').' " , " name " : " percentuale[] " , " value " : " '. $result['prc'] .' " , " icon-after " : " <i class= \" fa fa-percent \" ></i> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Scadenza').' " , " name " : " scadenza[] " , " values " : " list= \" 1 \" : \" '.tr('Data fatturazione').' \" , \" 2 \" : \" '.tr('Data fatturazione fine mese').' \" , \" 3 \" : \" '.tr('Data fatturazione giorno fisso').' \" , \" 4 \" : \" '.tr('Data fatturazione fine mese (giorno fisso)').' \" " , " value " : " ';
2018-01-26 22:21:08 +01:00
if ( $result [ 'giorno' ] == 0 ) {
2017-08-04 16:28:16 +02:00
$select = 1 ;
2018-01-26 22:21:08 +01:00
} elseif ( $result [ 'giorno' ] == - 1 ) {
2017-08-04 16:28:16 +02:00
$select = 2 ;
2018-01-26 22:21:08 +01:00
} elseif ( $result [ 'giorno' ] < - 1 ) {
2017-08-04 16:28:16 +02:00
$select = 4 ;
2018-01-26 22:21:08 +01:00
} elseif ( $result [ 'giorno' ] > 0 ) {
2017-08-04 16:28:16 +02:00
$select = 3 ;
}
echo $select ;
echo ' " ]}
</ div >
</ div >
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Giorno').' " , " name " : " giorno[] " , " values " : " list='. $values .' " , " value " : " ';
2017-08-04 16:28:16 +02:00
if ( $result [ 'giorno' ] != 0 && $result [ 'giorno' ] != - 1 ) {
echo ( $result [ 'giorno' ] < - 1 ) ? - $result [ 'giorno' ] - 1 : $result [ 'giorno' ];
}
echo '", "extra": "' ;
if ( $result [ 'giorno' ] == 0 || $result [ 'giorno' ] == - 1 ) {
echo ' disabled' ;
}
echo ' " ]}
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Distanza in giorni').' " , " name " : " distanza[] " , " decimals " : " 0 " , " value " : " '. $result['num_giorni'] .' " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div > ' ;
++ $cont ;
}
?>
</ div >
< div class = " pull-right " >
2017-09-04 12:02:29 +02:00
< button type = " button " class = " btn btn-info " id = " add " >< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Aggiungi' ); ?> </button>
< button type = " submit " class = " btn btn-success " >< i class = " fa fa-check " ></ i > < ? php echo tr ( 'Salva' ); ?> </button>
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ form >
< div class = " box box-warning box-solid text-center hide " id = " wait " >
< div class = " box-header with-border " >
2017-09-04 12:02:29 +02:00
< h3 class = " box-title " >< i class = " fa fa-warning " ></ i > < ? php echo tr ( 'Attenzione!' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " box-body " >
2017-09-04 12:02:29 +02:00
< p >< ? php echo tr ( 'Prima di poter continuare con il salvataggio è necessario che i valori percentuali raggiungano in totale il 100%' ); ?> .</p>
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< a class = " btn btn-danger ask " data - backto = " record-list " >
2017-09-04 12:02:29 +02:00
< i class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
2017-08-04 16:28:16 +02:00
</ a >
< ? php
echo '
< form class = " hide " id = " template " >
< div class = " box " >
< div class = " box-header with-border " >
2017-09-04 12:02:29 +02:00
< h3 class = " box-title " > '.tr(' Nuova rata ').' </ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " box-body " >
< input type = " hidden " value = " " name = " id[] " >
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Percentuale').' " , " name " : " percentuale[] " , " icon-after " : " <i class= \" fa fa-percent \" ></i> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Scadenza').' " , " name " : " scadenza[] " , " values " : " list= \" 1 \" : \" '.tr('Data fatturazione').' \" , \" 2 \" : \" '.tr('Data fatturazione fine mese').' \" , \" 3 \" : \" '.tr('Data fatturazione giorno fisso').' \" , \" 4 \" : \" '.tr('Data fatturazione fine mese (giorno fisso)').' \" " , " value " : 1 ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Giorno').' " , " name " : " giorno[] " , " values " : " list='. $values .' " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-02-20 16:46:23 +01:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Distanza in giorni').' " , " name " : " distanza[] " , " decimals " : " 0 " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
</ form > ' ;
?>
< script >
2020-07-31 14:25:50 +02:00
$ ( document ) . ready ( function () {
$ ( document ) . on ( 'click' , '#add' , function () {
2019-07-26 17:40:52 +02:00
cleanup_inputs ();
2017-08-04 16:28:16 +02:00
2019-07-26 17:40:52 +02:00
$ ( this ) . parent () . parent () . find ( '.data' ) . append ( $ ( '#template' ) . html ());
2017-08-04 16:28:16 +02:00
2019-07-26 17:40:52 +02:00
restart_inputs ();
2017-08-04 16:28:16 +02:00
});
2020-07-31 14:25:50 +02:00
$ ( document ) . on ( 'change' , '[id*=scadenza]' , function () {
2017-08-04 16:28:16 +02:00
if ( $ ( this ) . val () == 1 || $ ( this ) . val () == 2 ){
$ ( this ) . parentsUntil ( '.box' ) . find ( '[id*=giorno]' ) . prop ( 'disabled' , true );
} else {
$ ( this ) . parentsUntil ( '.box' ) . find ( '[id*=giorno]' ) . prop ( 'disabled' , false );
}
});
2018-08-11 15:49:46 +02:00
2020-07-31 14:25:50 +02:00
$ ( document ) . on ( 'change' , '[id*=percentuale]' , function () {
2018-07-23 11:15:38 +02:00
$ ( 'button[type=submit]' ) . prop ( 'disabled' , false ) . removeClass ( 'disabled' );
});
2017-08-04 16:28:16 +02:00
2018-07-23 11:15:38 +02:00
$ ( '#edit-form' ) . submit ( function ( event ) {
2017-08-04 16:28:16 +02:00
var tot = 0 ;
2020-07-31 14:25:50 +02:00
$ ( this ) . find ( '[id*=percentuale]' ) . each ( function () {
2017-08-11 12:11:57 +02:00
prc = $ ( this ) . val () . toEnglish ();
2017-08-04 16:28:16 +02:00
prc = ! isNaN ( prc ) ? prc : 0 ;
tot += prc ;
});
2018-07-23 11:15:38 +02:00
if ( tot != 100 ) {
2017-08-04 16:28:16 +02:00
$ ( '#wait' ) . removeClass ( " hide " );
event . preventDefault ();
2018-07-23 11:15:38 +02:00
} else {
$ ( '#wait' ) . addClass ( " hide " );
2018-10-24 19:17:31 +02:00
$ ( this ) . unbind ( 'submit' ) . submit ();
2017-08-04 16:28:16 +02:00
}
});
});
</ script >