mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-25 15:58:56 +01:00
Fix js per ie, aggiunto campo sede obbligatorio per impianti e select che cambia in base al cliente selezionato
This commit is contained in:
parent
7101dbf2ce
commit
08f9d4792b
@ -606,7 +606,7 @@ function start_datatables() {
|
||||
$(win.document.body)
|
||||
.css('font-size', '10pt')
|
||||
.append(
|
||||
'<table class="main-records table table-condensed table-bordered dataTable" ><tfoot><tr><td></td><td class="pull-right" >' + $('#summable').text() + '</td><td></td></tr></tfoot></table>',
|
||||
'<table class="main-records table table-condensed table-bordered dataTable" ><tfoot><tr><td></td><td class="pull-right" >' + $('#summable').text() + '</td><td></td></tr></tfoot></table>'
|
||||
);
|
||||
$(win.document.body).find('table')
|
||||
.addClass('compact')
|
||||
|
@ -14,6 +14,7 @@ $op = 'edit-pianifica';
|
||||
$data_conclusione = $dbo->fetchArray('SELECT `data_conclusione` FROM `co_contratti` WHERE `id` = '.prepare($id_record))[0]['data_conclusione'];
|
||||
$idanagrafica = $dbo->fetchArray('SELECT `idanagrafica` FROM `co_contratti` WHERE `id` = '.prepare($id_record))[0]['idanagrafica'];
|
||||
|
||||
//tutti gli impianti a contratto
|
||||
$idimpianti = $dbo->fetchArray('SELECT GROUP_CONCAT(`idimpianto`) AS idimpianti FROM `my_impianti_contratti` WHERE `idcontratto` = '.prepare($id_record))[0]['idimpianti'];
|
||||
|
||||
$idimpianto = explode(",", $idimpianti);
|
||||
@ -32,12 +33,21 @@ if (!empty($get['idcontratto_riga'])) {
|
||||
$rsp = $dbo->fetchArray($qp);
|
||||
|
||||
$data_richiesta = readDate($rsp[0]['data_richiesta']);
|
||||
$idimpianti = trim($rsp[0]['idimpianti']);
|
||||
$idsede = $rsp[0]['idsede'];
|
||||
$tempo_standard = $rsp[0]['tempo_standard'];
|
||||
|
||||
|
||||
//sede nel promemoria
|
||||
$idsede = $rsp[0]['idsede'];
|
||||
|
||||
$tempo_standard = $rsp[0]['tempo_standard'];
|
||||
|
||||
//if (!empty($rsp[0]['idtipointervento']))
|
||||
$idtipointervento = $rsp[0]['idtipointervento'];
|
||||
|
||||
if (!empty($idsede)){
|
||||
|
||||
//if (!empty($rsp[0]['idimpianti']))
|
||||
$idimpianti = trim($rsp[0]['idimpianti']);
|
||||
$readonly = 'readonly';
|
||||
}
|
||||
|
||||
$hide = '';
|
||||
$list .= ', \"0\":\"'.tr('Pianificare a partire da questo promemoria ').$data_richiesta.'\"';
|
||||
@ -75,7 +85,7 @@ echo '
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Tipo intervento').'", "name": "idtipointervento", "required": 1, "id": "idtipointervento_", "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC", "value": "'.$rsp[0]['idtipointervento'].'", "extra": "'.$readonly.'", "ajax-source": "tipiintervento" ]}
|
||||
{[ "type": "select", "label": "'.tr('Tipo intervento').'", "name": "idtipointervento", "required": 1, "id": "idtipointervento_", "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC", "value": "'.$rsp[0]['idtipointervento'].'", "extra": "'.$readonly.'", "ajax-source": "tipiintervento", "value": "'.$idtipointervento.'" ]}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -83,14 +93,14 @@ echo '
|
||||
|
||||
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "multiple": "1", "label": "'.tr('Impianti a contratto').'", "name": "idimpianti[]", "values": "query=SELECT my_impianti.id AS id, my_impianti.nome AS descrizione FROM my_impianti_contratti INNER JOIN my_impianti ON my_impianti_contratti.idimpianto = my_impianti.id WHERE my_impianti_contratti.idcontratto = '.$id_record.' ORDER BY descrizione", "value": "'.$idimpianti.'", "extra":"'.$readonly.'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede_c", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT( CONCAT_WS( \' (\', CONCAT_WS(\', \', `nomesede`, `citta`), `indirizzo` ), \')\') AS descrizione FROM an_sedi WHERE idanagrafica='.$idanagrafica.'", "value": "'.$idsede.'", "extra":"'.$readonly.'" ]}
|
||||
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede_c", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT( CONCAT_WS( \' (\', CONCAT_WS(\', \', `nomesede`, `citta`), `indirizzo` ), \')\') AS descrizione FROM an_sedi WHERE idanagrafica='.$idanagrafica.'", "value": "'.$idsede.'", "extra":"'.$readonly.'", "required" : "1" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "multiple": "1", "label": "'.tr('Impianti a contratto').'", "name": "idimpianti[]", "help": "'.tr('Impianti sede selezionata').'", "values": "query=SELECT my_impianti.id AS id, my_impianti.nome AS descrizione FROM my_impianti_contratti INNER JOIN my_impianti ON my_impianti_contratti.idimpianto = my_impianti.id WHERE my_impianti_contratti.idcontratto = '.$id_record.' ORDER BY descrizione", "value": "'.$idimpianti.'", "extra":"'.$readonly.'" ]}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -9,12 +9,23 @@ switch (filter('op')) {
|
||||
case 'add-pianifica':
|
||||
|
||||
$data_richiesta = filter('data_richiesta');
|
||||
$query = 'INSERT INTO `co_contratti_promemoria` ( `idcontratto`, `data_richiesta` ) VALUES ('.prepare($id_record).', '.prepare($data_richiesta).')';
|
||||
$idtipointervento = filter('idtipointervento');
|
||||
$query = 'INSERT INTO `co_contratti_promemoria` ( `idcontratto`, `data_richiesta`, idtipointervento ) VALUES ('.prepare($id_record).', '.prepare($data_richiesta).', '.prepare($idtipointervento).' )';
|
||||
|
||||
if ($dbo->query($query)) {
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr("Errore durante l'aggiunta del promemoria!");
|
||||
}
|
||||
//$are_duplicated = $dbo->fetchNum('SELECT id FROM co_contratti_promemoria WHERE data_richiesta = '.prepare($data_richiesta).' AND idtipointervento = '.prepare($idtipointervento).' AND idcontratto = '.prepare($id_record) );
|
||||
|
||||
//if (empty($are_duplicated)){
|
||||
if ($dbo->query($query)) {
|
||||
ob_clean();
|
||||
echo $dbo->lastInsertedID();
|
||||
ob_end();
|
||||
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr("Errore durante l'aggiunta del promemoria!");
|
||||
}
|
||||
//}else{
|
||||
//$_SESSION['warnings'][] = tr('Promemoria non inserito perché esiste già per questa data e per questo tipo intervento.');
|
||||
//}
|
||||
break;
|
||||
|
||||
case 'edit-pianifica':
|
||||
@ -29,13 +40,13 @@ switch (filter('op')) {
|
||||
$idimpianti = implode(',', $post['idimpianti']);
|
||||
|
||||
$query = 'UPDATE co_contratti_promemoria SET idtipointervento='.prepare($idtipointervento).', data_richiesta='.prepare($data_richiesta).', richiesta='.prepare($richiesta).', idsede='.prepare($idsede).', idimpianti='.prepare($idimpianti).' WHERE id = '.prepare($idcontratto_riga);
|
||||
|
||||
|
||||
if (isset($id_record)) {
|
||||
if ($dbo->query($query)) {
|
||||
$_SESSION['infos'][] = tr('Promemoria inserito!');
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Errore durante la modifica del promemoria!');
|
||||
}
|
||||
if ($dbo->query($query)) {
|
||||
$_SESSION['infos'][] = tr('Promemoria inserito!');
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Errore durante la modifica del promemoria!');
|
||||
}
|
||||
}
|
||||
|
||||
redirect($rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'#tab_'.$id_plugin);
|
||||
@ -475,36 +486,68 @@ echo '
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
$inputOptions = $dbo->fetchArray('SELECT GROUP_CONCAT(CONCAT(\'"\', idtipointervento, \'"\',\':\', \'"\', descrizione, \'"\')) AS inputOptions FROM `in_tipiintervento`')[0]['inputOptions'];
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function askTipoIntervento () {
|
||||
|
||||
swal({
|
||||
|
||||
title: '<?php echo tr('Aggiungere un nuovo promemoria?'); ?>',
|
||||
type: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '<?php echo tr('Aggiungi'); ?>',
|
||||
confirmButtonClass: 'btn btn-lg btn-success',
|
||||
input: 'select',
|
||||
inputOptions: {<?php echo $inputOptions; ?>},
|
||||
inputPlaceholder: '<?php echo tr('Tipo intervento'); ?>',
|
||||
inputValidator: (value) => {
|
||||
return new Promise((resolve) => {
|
||||
if (value === '') {
|
||||
|
||||
alert ('Seleziona un tipo intervento');
|
||||
$('.swal2-select').attr('disabled', false);
|
||||
$('.swal2-confirm').attr('disabled', false);
|
||||
$('.swal2-cancel').attr('disabled', false);
|
||||
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}).then(
|
||||
function (result) {
|
||||
prev_html = $("#add_promemoria").html();
|
||||
$("#add_promemoria").html("<i class='fa fa-spinner fa-pulse fa-fw'></i> <?php echo tr('Attendere...'); ?>");
|
||||
$("#add_promemoria").prop('disabled', true);
|
||||
|
||||
$.post( "<?php echo $rootdir; ?>/editor.php?id_module=<?php echo Modules::get('Contratti')['id']; ?>&id_record=<?php echo $id_record; ?>", { backto: "record-edit", op: "add-pianifica", data_richiesta: '<?php echo date('Y-m-d'); ?>', idtipointervento: $('.swal2-select').val() })
|
||||
.done(function( data ) {
|
||||
|
||||
launch_modal('Nuovo promemoria', '<?php echo $rootdir; ?>/modules/contratti/plugins/addpianficazione.php?id_module=<?php echo Modules::get('Contratti')['id']; ?>&id_plugin=<?php echo Plugins::get('Pianificazione interventi')['id']; ?>&ref=interventi_contratti&id_record=<?php echo $id_record; ?>&idcontratto_riga='+data+'', 1, '#bs-popup');
|
||||
|
||||
$("#add_promemoria").html(prev_html);
|
||||
$("#add_promemoria").prop('disabled', false);
|
||||
|
||||
});
|
||||
},
|
||||
function (dismiss) {}
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$( "#add_promemoria" ).click(function() {
|
||||
|
||||
swal({
|
||||
title: '<?php echo tr('Aggiungere un nuovo promemoria?'); ?>',
|
||||
type: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '<?php echo tr('Aggiungi'); ?>',
|
||||
confirmButtonClass: 'btn btn-lg btn-success',
|
||||
}).then(
|
||||
function (result) {
|
||||
prev_html = $("#add_promemoria").html();
|
||||
$("#add_promemoria").html("<i class='fa fa-spinner fa-pulse fa-fw'></i> <?php echo tr('Attendere...'); ?>");
|
||||
$("#add_promemoria").prop('disabled', true);
|
||||
|
||||
$.post( "<?php echo $rootdir; ?>/editor.php?id_module=<?php echo Modules::get('Contratti')['id']; ?>&id_record=<?php echo $id_record; ?>", { backto: "record-edit", op: "add-pianifica", data_richiesta: '<?php echo date('Y-m-d'); ?>' })
|
||||
.done(function( data ) {
|
||||
launch_modal('Nuovo promemoria', '<?php echo $rootdir; ?>/modules/contratti/plugins/addpianficazione.php?id_module=<?php echo Modules::get('Contratti')['id']; ?>&id_plugin=<?php echo Plugins::get('Pianificazione interventi')['id']; ?>&ref=interventi_contratti&id_record=<?php echo $id_record; ?>', 1, '#bs-popup');
|
||||
|
||||
$("#add_promemoria").html(prev_html);
|
||||
$("#add_promemoria").prop('disabled', false);
|
||||
|
||||
});
|
||||
},
|
||||
function (dismiss) {}
|
||||
);
|
||||
|
||||
askTipoIntervento();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
//unset($_SESSION['superselect']['idanagrafica']);
|
||||
//unset($_SESSION['superselect']['idsede']);
|
||||
|
||||
|
||||
$source = get('source');
|
||||
$idanagrafica = null;
|
||||
|
||||
@ -23,11 +27,15 @@ if ($source == 'Attività') {
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1 ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "required": 1, "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Cliente' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "<?php echo $idanagrafica; ?>", "ajax-source": "clienti" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Sede'); ?>", "name": "idsede", "values": "query=SELECT 0 AS id, 'Sede legale' AS descrizione UNION SELECT id, CONCAT_WS( ' - ', nomesede, citta ) AS descrizione FROM an_sedi WHERE idanagrafica='$idanagrafica$'", "value": "$idsede$", "required": "1", "ajax-source": "sedi" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Tecnico'); ?>", "name": "idtecnico", "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Tecnico' AND deleted_at IS NULL ORDER BY ragione_sociale" ]}
|
||||
</div>
|
||||
</div>
|
||||
@ -39,3 +47,25 @@ if ($source == 'Attività') {
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#idanagrafica').change( function(){
|
||||
|
||||
session_set('superselect,idanagrafica', $(this).val(), 0);
|
||||
|
||||
var value = !$(this).val() ? true : false;
|
||||
|
||||
$("#idsede").prop("disabled", value);
|
||||
$("#idsede").selectReset();
|
||||
|
||||
});
|
||||
|
||||
$('#idsede').change( function(){
|
||||
//session_set('superselect,idsede', $(this).val(), 0);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
@ -2,6 +2,10 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
//unset($_SESSION['superselect']['idanagrafica']);
|
||||
//unset($_SESSION['superselect']['idsede']);
|
||||
|
||||
|
||||
$img = null;
|
||||
if (!empty($records[0]['immagine'])) {
|
||||
$fileinfo = Uploads::fileInfo($records[0]['immagine']);
|
||||
@ -40,7 +44,7 @@ if (!empty($records[0]['immagine'])) {
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "required": 1, "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Cliente' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "$idanagrafica$", "extra": "onchange=\"load_preventivi( this.value ); load_contratti( this.value ); $('#idsede').load( '<?php echo $rootdir; ?>/ajax_complete.php?module=Anagrafiche&op=get_sedi_select&idanagrafica='+$('#idanagrafica option:selected').val() ); load_impianti( $('#idanagrafica option:selected').val(), $('#idsede option:selected').val() );\"", "ajax-source": "clienti" ]}
|
||||
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "required": 1, "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Cliente' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "$idanagrafica$", "extra": "", "ajax-source": "clienti" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -56,7 +60,7 @@ if (!empty($records[0]['immagine'])) {
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Sede'); ?>", "name": "idsede", "values": "query=SELECT 0 AS id, 'Sede legale' AS descrizione UNION SELECT id, CONCAT_WS( ' - ', nomesede, citta ) AS descrizione FROM an_sedi WHERE idanagrafica='$idanagrafica$'", "value": "$idsede$" ]}
|
||||
{[ "type": "select", "label": "<?php echo tr('Sede'); ?>", "name": "idsede", "values": "query=SELECT 0 AS id, 'Sede legale' AS descrizione UNION SELECT id, CONCAT_WS( ' - ', nomesede, citta ) AS descrizione FROM an_sedi WHERE idanagrafica='$idanagrafica$'", "value": "$idsede$", "required": "1", "ajax-source": "sedi" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -110,3 +114,25 @@ if (!empty($records[0]['immagine'])) {
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||
</a>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#idanagrafica').change( function(){
|
||||
|
||||
session_set('superselect,idanagrafica', $(this).val(), 0);
|
||||
|
||||
var value = !$(this).val() ? true : false;
|
||||
|
||||
$("#idsede").prop("disabled", value);
|
||||
$("#idsede").selectReset();
|
||||
|
||||
});
|
||||
|
||||
$('#idsede').change( function(){
|
||||
//session_set('superselect,idsede', $(this).val(), 0);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user