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
|
2018-02-19 11:50:42 +01:00
|
|
|
if (!isset($options['edit_articolo']) || !empty($options['edit_articolo'])) {
|
|
|
|
echo '
|
2018-02-19 10:52:42 +01:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
2018-11-30 16:10:15 +01:00
|
|
|
{[ "type": "select", "label": "'.tr('Articolo').'", "name": "idarticolo", "required": 1, "value": "'.$result['idarticolo'].'", "ajax-source": "articoli", "icon-after": "add|'.Modules::get('Articoli')['id'].'||'.(($options['dir'] == 'uscita') ? '' : 'disabled').'" ]}
|
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();
|
2018-02-19 11:50:42 +01:00
|
|
|
$articolo = $database->fetchArray('SELECT codice, descrizione FROM mg_articoli WHERE id = '.prepare($result['idarticolo']))[0];
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<p>'.tr('Articolo').': '.$articolo['codice'].' - '.$articolo['descrizione'].'.</p>';
|
|
|
|
}
|
2018-02-19 10:52:42 +01:00
|
|
|
|
|
|
|
echo App::internalLoad('riga.php', $result, $options);
|
|
|
|
|
2018-02-19 11:50:42 +01:00
|
|
|
if (!isset($options['edit_articolo']) || !empty($options['edit_articolo'])) {
|
|
|
|
// Informazioni aggiuntive
|
|
|
|
if ($module['name'] != 'Contratti' && $module['name'] != 'Preventivi') {
|
|
|
|
$disabled = empty($result['idarticolo']);
|
|
|
|
|
|
|
|
echo '
|
2018-02-19 10:52:42 +01:00
|
|
|
<div class="row" id="prezzi_articolo">
|
|
|
|
<div class="col-md-4 text-center">
|
2018-02-19 11:50:42 +01: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() + '&idanagrafica=".$options['idanagrafica'].'\');">
|
2018-02-19 10:52:42 +01:00
|
|
|
<i class="fa fa-search"></i> '.tr('Visualizza ultimi prezzi (cliente)').'
|
|
|
|
</button>
|
|
|
|
<div id="prezzi" class="hide"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-4 text-center">
|
2018-02-19 11:50:42 +01: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() + '&idanagrafica=".$options['idanagrafica'].'\');">
|
2018-02-19 10:52:42 +01:00
|
|
|
<i class="fa fa-search"></i> '.tr('Visualizza ultimi prezzi (acquisto)').'
|
|
|
|
</button>
|
|
|
|
<div id="prezziacquisto" class="hide"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-4 text-center">
|
2018-02-19 11:50:42 +01: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() + '&idanagrafica=".$options['idanagrafica'].'\');">
|
2018-02-19 10:52:42 +01:00
|
|
|
<i class="fa fa-search"></i> '.tr('Visualizza ultimi prezzi (vendita)').'
|
|
|
|
</button>
|
|
|
|
<div id="prezzivendita" class="hide"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br>';
|
2018-02-19 11:50:42 +01:00
|
|
|
}
|
2018-02-19 10:52:42 +01:00
|
|
|
|
2018-02-19 11:50:42 +01:00
|
|
|
echo '
|
2018-02-19 10:52:42 +01:00
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
$("#idarticolo").on("change", function(){
|
|
|
|
// Autoimpostazione dei valori relativi
|
|
|
|
if ($(this).val()) {
|
2018-11-23 16:08:23 +01:00
|
|
|
|
2018-02-19 10:52:42 +01:00
|
|
|
session_set("superselect,idarticolo", $(this).val(), 0);
|
2018-10-02 16:33:22 +02:00
|
|
|
session_set("superselect,idanagrafica", "'.$options['idanagrafica'].'", 0);
|
|
|
|
session_set("superselect,dir", "'.$options['dir'].'", 0);
|
2018-11-23 16:08:23 +01:00
|
|
|
|
2018-10-02 16:33:22 +02:00
|
|
|
$data = $(this).selectData();
|
2018-02-19 10:52:42 +01:00
|
|
|
|
2018-09-27 12:54:57 +02:00
|
|
|
var id_conto = $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').';
|
|
|
|
|
2018-02-19 10:52:42 +01:00
|
|
|
$("#prezzo").val($data.prezzo_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').');
|
|
|
|
$("#descrizione_riga").val($data.descrizione);
|
2018-09-28 16:43:40 +02:00
|
|
|
$("#idiva").selectSetNew($data.idiva_vendita, $data.iva_vendita);
|
2018-09-27 12:54:57 +02:00
|
|
|
if(id_conto) {
|
|
|
|
$("#idconto").selectSetNew(id_conto, $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').'_title);
|
|
|
|
}
|
2018-02-19 10:52:42 +01:00
|
|
|
$("#um").selectSetNew($data.um, $data.um);
|
|
|
|
}';
|
|
|
|
|
2018-02-19 11:50:42 +01:00
|
|
|
if ($module['name'] != 'Contratti' && $module['name'] != 'Preventivi') {
|
|
|
|
echo '
|
2018-02-19 10:52:42 +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
|
|
|
}
|
2018-02-19 10:52:42 +01:00
|
|
|
|
2018-02-19 11:50:42 +01:00
|
|
|
echo '
|
2018-02-19 10:52:42 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>';
|
2018-02-19 11:50:42 +01:00
|
|
|
}
|