2018-02-19 10:52:42 +01:00
|
|
|
<?php
|
|
|
|
|
2018-06-23 18:35:08 +02:00
|
|
|
$result['idarticolo'] = isset($result['idarticolo']) ? $result['idarticolo'] : null;
|
|
|
|
|
2018-11-23 16:08:23 +01:00
|
|
|
$_SESSION['superselect']['dir'] = $options['dir'];
|
|
|
|
$_SESSION['superselect']['idanagrafica'] = $options['idanagrafica'];
|
|
|
|
$_SESSION['superselect']['idarticolo'] = $options['idarticolo'];
|
2018-10-02 16:33:22 +02:00
|
|
|
|
2018-02-19 10:52:42 +01:00
|
|
|
// Articolo
|
2020-02-14 17:02:16 +01:00
|
|
|
if (empty($result['idarticolo'])) {
|
2018-02-19 11:50:42 +01:00
|
|
|
echo '
|
2018-02-19 10:52:42 +01:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
2019-11-15 15:15:48 +01:00
|
|
|
{[ "type": "select", "label": "'.tr('Articolo').'", "name": "idarticolo", "required": 1, "value": "'.$result['idarticolo'].'", "ajax-source": "articoli", "icon-after": "add|'.Modules::get('Articoli')['id'].'" ]}
|
2018-02-19 10:52:42 +01:00
|
|
|
</div>
|
|
|
|
</div>';
|
2018-02-19 11:50:42 +01:00
|
|
|
} else {
|
2018-09-20 12:05:22 +02:00
|
|
|
$database = database();
|
2020-04-15 16:25:44 +02:00
|
|
|
$articolo = $database->fetchArray('SELECT id, codice, descrizione FROM mg_articoli WHERE id = '.prepare($result['idarticolo']))[0];
|
2018-02-19 11:50:42 +01:00
|
|
|
|
|
|
|
echo '
|
2020-04-15 16:25:44 +02:00
|
|
|
<p><strong>'.tr('Articolo').':</strong> '.$articolo['codice'].' - '.$articolo['descrizione'].'.</p>
|
|
|
|
<input type="hidden" name="idarticolo" id="idarticolo" value="'.$articolo['id'].'">';
|
2020-02-14 17:02:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Selezione impianto per gli Interventi
|
|
|
|
if ($module['name'] == 'Interventi') {
|
|
|
|
echo '
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
{[ "type": "select", "label": "'.tr('Impianto su cui installare').'", "name": "idimpianto", "value": "'.$idimpianto.'", "ajax-source": "impianti-intervento" ]}
|
|
|
|
</div>
|
|
|
|
</div>';
|
2018-02-19 11:50:42 +01:00
|
|
|
}
|
2018-02-19 10:52:42 +01:00
|
|
|
|
|
|
|
echo App::internalLoad('riga.php', $result, $options);
|
|
|
|
|
2020-02-14 17:02:16 +01:00
|
|
|
// Informazioni aggiuntive
|
|
|
|
if ($module['name'] != 'Contratti' && $module['name'] != 'Preventivi') {
|
|
|
|
$disabled = empty($result['idarticolo']);
|
2018-02-19 10:52:42 +01:00
|
|
|
|
2020-02-14 17:02:16 +01:00
|
|
|
echo '
|
|
|
|
<div class="row" id="prezzi_articolo">
|
|
|
|
<div class="col-md-4 text-center">
|
2020-04-15 16:25:44 +02:00
|
|
|
<button type="button" class="btn btn-sm btn-info btn-block '.($disabled ? 'disabled' : '').'" '.($disabled ? 'disabled' : '').' onclick="$(\'#prezziacquisto\').toggleClass(\'hide\'); $(\'#prezziacquisto\').load(\''.ROOTDIR."/ajax_complete.php?module=Articoli&op=getprezziacquisto&idarticolo=' + ( $('#idarticolo option:selected').val() || $('#idarticolo').val()) + '&idanagrafica=".$options['idanagrafica'].'\');">
|
|
|
|
<i class="fa fa-search"></i> '.tr('Ultimi prezzi di acquisto').'
|
2020-02-14 17:02:16 +01:00
|
|
|
</button>
|
2020-04-15 16:25:44 +02:00
|
|
|
<div id="prezziacquisto" class="hide"></div>
|
2020-02-14 17:02:16 +01:00
|
|
|
</div>
|
2018-02-19 10:52:42 +01:00
|
|
|
|
2020-02-14 17:02:16 +01:00
|
|
|
<div class="col-md-4 text-center">
|
2020-04-15 16:25:44 +02:00
|
|
|
<button type="button" class="btn btn-sm btn-info btn-block '.($disabled ? 'disabled' : '').'" '.($disabled ? 'disabled' : '').' onclick="$(\'#prezzi\').toggleClass(\'hide\'); $(\'#prezzi\').load(\''.ROOTDIR."/ajax_complete.php?module=Articoli&op=getprezzi&idarticolo=' + ( $('#idarticolo option:selected').val() || $('#idarticolo').val()) + '&idanagrafica=".$options['idanagrafica'].'\');">
|
|
|
|
<i class="fa fa-search"></i> '.tr('Ultimi prezzi al cliente').'
|
2020-02-14 17:02:16 +01:00
|
|
|
</button>
|
2020-04-15 16:25:44 +02:00
|
|
|
<div id="prezzi" class="hide"></div>
|
2018-02-19 10:52:42 +01:00
|
|
|
</div>
|
|
|
|
|
2020-02-14 17:02:16 +01:00
|
|
|
<div class="col-md-4 text-center">
|
2020-04-15 16:25:44 +02:00
|
|
|
<button type="button" class="btn btn-sm btn-info btn-block '.($disabled ? 'disabled' : '').'" '.($disabled ? 'disabled' : '').' onclick="$(\'#prezzivendita\').toggleClass(\'hide\'); $(\'#prezzivendita\').load(\''.ROOTDIR."/ajax_complete.php?module=Articoli&op=getprezzivendita&idarticolo=' + ( $('#idarticolo option:selected').val() || $('#idarticolo').val()) + '&idanagrafica=".$options['idanagrafica'].'\');">
|
|
|
|
<i class="fa fa-search"></i> '.tr('Ultimi prezzi di vendita').'
|
2020-02-14 17:02:16 +01:00
|
|
|
</button>
|
|
|
|
<div id="prezzivendita" class="hide"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
$("#idarticolo").on("change", function(){
|
|
|
|
// Autoimpostazione dei valori relativi
|
|
|
|
if ($(this).val()) {
|
|
|
|
session_set("superselect,idarticolo", $(this).val(), 0);
|
|
|
|
session_set("superselect,idanagrafica", "'.$options['idanagrafica'].'", 0);
|
|
|
|
session_set("superselect,dir", "'.$options['dir'].'", 0);
|
|
|
|
|
|
|
|
$data = $(this).selectData();
|
|
|
|
|
|
|
|
var id_conto = $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').';
|
|
|
|
|
2020-02-14 18:31:07 +01:00
|
|
|
$("#prezzo_unitario").val($data.prezzo_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').');
|
2020-02-14 17:02:16 +01:00
|
|
|
|
2020-02-14 18:31:07 +01:00
|
|
|
$("#costo_unitario").val($data.prezzo_acquisto);
|
2020-02-14 17:02:16 +01:00
|
|
|
|
2020-02-26 17:23:43 +01:00
|
|
|
$("#descrizione_riga").val($data.descrizione);';
|
2020-02-14 17:02:16 +01:00
|
|
|
|
2020-02-27 16:19:07 +01:00
|
|
|
if ($options['dir'] == 'entrata') {
|
2020-02-26 17:23:43 +01:00
|
|
|
echo '
|
2020-02-14 17:02:16 +01:00
|
|
|
if( $data.idiva_vendita ){
|
|
|
|
$("#idiva").selectSetNew($data.idiva_vendita, $data.iva_vendita);
|
2020-02-26 17:23:43 +01:00
|
|
|
}';
|
|
|
|
}
|
2020-02-27 16:19:07 +01:00
|
|
|
|
2020-02-26 17:23:43 +01:00
|
|
|
echo '
|
2020-02-14 17:02:16 +01:00
|
|
|
if(id_conto) {
|
|
|
|
$("#idconto").selectSetNew(id_conto, $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').'_title);
|
|
|
|
}
|
|
|
|
$("#um").selectSetNew($data.um, $data.um);
|
|
|
|
}';
|
2018-02-19 10:52:42 +01:00
|
|
|
|
2020-02-14 17:02:16 +01:00
|
|
|
if ($module['name'] != 'Contratti' && $module['name'] != 'Preventivi') {
|
2018-02-19 11:50:42 +01:00
|
|
|
echo '
|
2020-02-14 17:02:16 +01:00
|
|
|
|
|
|
|
// Operazioni sui prezzi in fondo alla pagina
|
|
|
|
$("#prezzi_articolo button").attr("disabled", !$(this).val());
|
|
|
|
|
|
|
|
if ($(this).val()) {
|
|
|
|
$("#prezzi_articolo button").removeClass("disabled");
|
|
|
|
} else {
|
|
|
|
$("#prezzi_articolo button").addClass("disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#prezzi").html("");
|
|
|
|
$("#prezzivendita").html("");
|
|
|
|
$("#prezziacquisto").html("");';
|
2018-02-19 11:50:42 +01:00
|
|
|
}
|
2020-02-14 17:02:16 +01:00
|
|
|
|
|
|
|
echo '
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>';
|