276 lines
10 KiB
PHP
276 lines
10 KiB
PHP
<?php
|
|
|
|
include_once(__DIR__."/../../core.php");
|
|
|
|
$iddocumento = $html->form('iddocumento');
|
|
$dir = get_var_tipodoc2($iddocumento,"dir");
|
|
|
|
|
|
$module_name=query_secca("","name","zz_modules","where id ='".$_SESSION['id_module']."'");
|
|
|
|
|
|
$rs = $dbo->fetchArray("SELECT * FROM co_documenti WHERE id='".$iddocumento."'");
|
|
$idanagrafica = $rs[0]['idanagrafica'];
|
|
$idconto = $rs[0]['idconto'];
|
|
( $rs[0]['numero_esterno'] != '' ) ? $numero=$rs[0]['numero_esterno'] : $numero=$rs[0]['numero'];
|
|
|
|
|
|
$matricola_primaria_des = $rs[0]['matricola'];
|
|
$id_impianto = $rs[0]['id_impianto'];
|
|
$nome_impianto = $rs[0]['nome_impianto'];
|
|
|
|
|
|
// Info Eventuale agente
|
|
// Info Listino
|
|
$qana = "SELECT idagente FROM an_anagrafiche WHERE idanagrafica='".$idanagrafica."'";
|
|
$rsana = $dbo->fetchArray($qana);
|
|
|
|
$qana = "SELECT perc_agente FROM an_anagrafiche WHERE idanagrafica='".$rsana[0]['idagente']."'";
|
|
$rsagente = $dbo->fetchArray($qana);
|
|
$per_utile_agente=$rsagente[0]['perc_agente'];
|
|
if ($per_utile_agente == '' ) {
|
|
$per_utile_agente = '0';
|
|
}
|
|
|
|
|
|
// Info matricola
|
|
$qana = "SELECT id,nome FROM my_impianti WHERE matricola='".$rs[0]['matricola']."'";
|
|
$rs_matricola = $dbo->fetchArray($qana);
|
|
$matricola_primaria=$rs_matricola[0]['nome'];
|
|
$id_matricola_primaria=$rs_matricola[0]['id'];
|
|
/*
|
|
Form di inserimento riga documento
|
|
*/
|
|
echo "<label>Documento numero $numero</label><br><br>\n";
|
|
echo "<form id=\"link_form\" action=\"".$rootdir."/editor.php?id_module=".$modules_info[$module_name]['id']."&id_record=".$iddocumento."\" method=\"post\">\n";
|
|
echo " <input type='hidden' name='op' value='addriga'>\n";
|
|
echo " <input type='hidden' name='dir' value='".$dir."'>\n";
|
|
echo " <input type='hidden' name='backto' value='record-edit'>\n";
|
|
|
|
//Descrizione
|
|
echo " <div class='row'>\n";
|
|
echo " <div class='col-md-12'>\n";
|
|
echo " <div class='form-group'>\n";
|
|
echo " <label>Descrizione</label>\n";
|
|
echo " <textarea name=\"descrizione\" id=\"descrizione\" class='form-control' ></textarea>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
|
|
|
|
|
|
|
|
|
|
echo " <div class='row'>\n";
|
|
//Iva
|
|
echo " <div class='col-md-6'>\n";
|
|
echo " <label>Iva</label>\n";
|
|
echo " <select id='idiva' class='superselect' name=\"idiva\">\n";
|
|
echo " <option value='0'>- Seleziona un valore -</option>\n";
|
|
//Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica
|
|
//if( $dir=='entrata' )
|
|
$idiva_predefinita = get_var("Iva predefinita");
|
|
$query = "SELECT * FROM co_iva ORDER BY descrizione ASC";
|
|
$rs = $dbo->fetchArray($query);
|
|
for( $i=0; $i<sizeof($rs); $i++ ){
|
|
( $rs[$i]['id'] == $idiva_predefinita ) ? $attr=' selected="selected"' : $attr='';
|
|
echo " <option value='".$rs[$i]['id']."' $attr>".$rs[$i]['descrizione']."</option>\n";
|
|
}
|
|
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
//Conto
|
|
echo " <div class='col-md-6'>\n";
|
|
echo " <label>Conto predefinito</label>\n";
|
|
echo " <select id='idconto_riga' class='superselect' name=\"idconto_riga\">\n";
|
|
$query = "SELECT co_pianodeiconti3.id, CONCAT_WS( ' ', co_pianodeiconti3.numero, co_pianodeiconti3.descrizione ) AS descrizione FROM co_pianodeiconti3 INNER JOIN (co_pianodeiconti2 INNER JOIN co_pianodeiconti1 ON co_pianodeiconti2.idpianodeiconti1=co_pianodeiconti1.id) ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti1.descrizione='Economico' AND co_pianodeiconti3.dir = '".$dir."' ORDER BY co_pianodeiconti3.numero ASC";
|
|
$rs = $dbo->fetchArray($query);
|
|
echo " <option value=''> - Seleziona un'opzione -</option>\n";
|
|
for( $i=0; $i<sizeof($rs); $i++ ){
|
|
( $rs[$i]['id'] == $idconto ) ? $attr=' selected="selected"' : $attr='';
|
|
echo " <option value='".$rs[$i]['id']."' $attr>".$rs[$i]['descrizione']."</option>\n";
|
|
}
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
|
|
echo " <div class='row'>\n";
|
|
//Rivalsa INPS
|
|
if( get_var("Percentuale rivalsa INPS") != "" ){
|
|
echo " <div class='col-md-6'>\n";
|
|
echo " <label>Rivalsa INPS:</label>\n";
|
|
echo " <select id='idrivalsainps' class='superselect' name=\"idrivalsainps\">\n";
|
|
echo " <option value=''>-</option>\n";
|
|
|
|
$query = "SELECT * FROM co_rivalsainps";
|
|
$rs = $dbo->fetchArray($query);
|
|
for( $i=0; $i<sizeof($rs); $i++ ){
|
|
( $rs[$i]['id'] == get_var("Percentuale rivalsa INPS") ) ? $attr='selected="true"' : $attr='';
|
|
echo " <option value='".$rs[$i]['id']."' ".$attr.">".$rs[$i]['descrizione']."</option>\n";
|
|
}
|
|
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
}
|
|
|
|
//Ritenuta d'acconto
|
|
if( get_var("Percentuale ritenuta d'acconto") != "" ){
|
|
echo " <div class='col-md-6'>\n";
|
|
echo " <label>Ritenuta d'acconto:</label>\n";
|
|
echo " <select id='idritenutaacconto' class='superselect' name=\"idritenutaacconto\">\n";
|
|
echo " <option value=''>-</option>\n";
|
|
|
|
$query = "SELECT * FROM co_ritenutaacconto";
|
|
$rs = $dbo->fetchArray($query);
|
|
for( $i=0; $i<sizeof($rs); $i++ ){
|
|
( $rs[$i]['id'] == get_var("Percentuale ritenuta d'acconto") ) ? $attr='selected="true"' : $attr='';
|
|
echo " <option value='".$rs[$i]['id']."' ".$attr.">".$rs[$i]['descrizione']."</option>\n";
|
|
}
|
|
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
}
|
|
echo " </div>\n";
|
|
|
|
echo " <div class='row'>\n";
|
|
echo " <div class='col-md-3'>\n";
|
|
echo " <div class='form-group'>\n";
|
|
echo " <label>Q.tà</label>\n";
|
|
echo " <div class='input-group'>\n";
|
|
echo " <input type='text' class='form-control inputmask-decimal' id='qta' maxlength='8' name='qta' value=\"1\">\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
|
|
//Unità di misura
|
|
echo " <div class='col-md-3'>\n";
|
|
echo ' {[ "type": "select", "label": "'. _("Unità di misura").'", "name": "um", "required": 0, "value": "", "ajax-source": "misure" ]}';
|
|
echo " </div>\n";
|
|
//Costo unitario
|
|
echo " <div class='col-md-3'>\n";
|
|
echo " <div class='form-group'>\n";
|
|
echo " <label>Costo unitario</label>\n";
|
|
echo " <div class='input-group'>\n";
|
|
echo " <input type='text' class='form-control inputmask-decimal' id='subtot' name='subtot' value=\"0,00\"><span class='input-group-addon'>€</span>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
|
|
|
|
if ($per_utile_agente != '0' ) {
|
|
// Utile agente
|
|
echo " <div class='col-md-2'>\n";
|
|
echo " <div class='form-group'>\n";
|
|
echo " <label>% Agente</label>\n";
|
|
echo " <div class='input-group'>\n";
|
|
echo " <input type='text' class='form-control inputmask-decimal' id='per_agente' maxlength='8' name='per_agente' value=\"".$per_utile_agente."\"><span class='input-group-addon'>".$um."</span>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
}
|
|
|
|
|
|
|
|
|
|
echo " </div>\n";
|
|
|
|
|
|
echo " <div class='row'>\n";
|
|
//Sconto
|
|
echo " <div class='col-md-3'>\n";
|
|
echo " <div class='form-group'>\n";
|
|
echo " <label>Sconto</label>\n";
|
|
echo " <div class='input-group'>\n";
|
|
echo " <input type='text' class='form-control inputmask-decimal' id='sconto' name='sconto' value=\"0,00\" /><span class='input-group-addon'></span>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
//Sconto Extra
|
|
echo " <div class='col-md-3'>\n";
|
|
echo " <div class='form-group'>\n";
|
|
echo " <label>Extra Sconto</label>\n";
|
|
echo " <div class='input-group'>\n";
|
|
echo " <input type='text' class='form-control inputmask-decimal' id='sconto_extra' name='sconto_extra' value=\"0,00\" /><span class='input-group-addon'></span>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
//Sconto Extra1
|
|
echo " <div class='col-md-3'>\n";
|
|
echo " <div class='form-group'>\n";
|
|
echo " <label>Extra Sconto</label>\n";
|
|
echo " <div class='input-group'>\n";
|
|
echo " <input type='text' class='form-control inputmask-decimal' id='sconto_extra1' name='sconto_extra1' value=\"0,00\" /><span class='input-group-addon'></span>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
|
|
//Tipo Sconto
|
|
$query = "SELECT * FROM co_tipisconto";
|
|
$rs = $dbo->fetchArray($query);
|
|
echo " <div class='col-md-3'>\n";
|
|
echo " <label>Tipologia Sconto</label>\n";
|
|
echo " <select id='idtiposconto' class='superselect' name=\"idtiposconto\">\n";
|
|
|
|
echo " <option value='1'>Fisso</option>\n";
|
|
for( $i=0; $i<sizeof($rs); $i++ ){
|
|
( $rs[$i]['id'] == "1" ) ? $attr=' selected="selected"' : $attr='';
|
|
echo " <option value='".$rs[$i]['id']."' $attr>".$rs[$i]['descrizione']."</option>\n";
|
|
}
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
|
|
|
|
//Installazioni
|
|
echo "<div class='panel panel-primary'>";
|
|
echo "<div class='panel-body'>";
|
|
echo " <div class='row'>\n";
|
|
//Tipo Sconto
|
|
|
|
if( $id_contratto > "0" ) {
|
|
$query="SELECT my_impianti.matricola as id , nome FROM my_impianti INNER JOIN my_impianti_contratti ON my_impianti.matricola=my_impianti_contratti.matricola WHERE
|
|
idanagrafica='".$idanagrafica."' and idcontratto ='".$id_contratto."' ORDER BY nome";
|
|
}else{
|
|
$query="SELECT my_impianti.matricola as id , nome FROM my_impianti WHERE idanagrafica='".$idanagrafica."' ORDER BY nome";
|
|
}
|
|
|
|
$rs = $dbo->fetchArray($query);
|
|
echo " <div class='col-md-4'>\n";
|
|
echo " <label>Installazione Impianti</label>\n";
|
|
echo " <select id='id_matricola' class='superselect' name=\"id_matricola\">\n";
|
|
|
|
|
|
if( $id_impianto != "0" ) echo " <option value='".$matricola_primaria_des."'>$nome_impianto</option>\n";
|
|
|
|
echo " <option value='0'>Nessuna Installazione</option>\n";
|
|
for( $i=0; $i<sizeof($rs); $i++ ){
|
|
echo " <option value='".$rs[$i]['id']."' $attr>".$rs[$i]['nome']."</option>\n";
|
|
}
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
echo " </div>\n";
|
|
|
|
|
|
?>
|
|
|
|
|
|
<script type="text/javascript">
|
|
function addriga(){
|
|
if( $('#descrizione').val()!='' && $('#idiva option:selected').val()!='' ){
|
|
$("#link_form").submit();
|
|
}
|
|
}
|
|
</script>
|
|
<script src="<?php echo $rootdir; ?>/lib/init.js"></script>
|
|
|
|
|
|
<?php
|
|
echo " <a onclick=\"addriga();\" class=\"btn btn-primary pull-right\"><i class=\"fa fa-plus\"></i> Aggiungi</a>\n";
|
|
echo "</form>\n";
|
|
|
|
?>
|
|
|
|
<div class="clearfix"></div>
|