mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 19:40:44 +01:00
Aggiunta selezione impianto prima del cliente in add intervento
This commit is contained in:
parent
54e21ee731
commit
6d9a7d80c3
@ -38,21 +38,22 @@ switch ($resource) {
|
||||
* - idanagrafica
|
||||
*/
|
||||
case 'impianti-cliente':
|
||||
if (isset($superselect['idanagrafica'])) {
|
||||
$query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti |where| ORDER BY idsede';
|
||||
$query = 'SELECT my_impianti.id, CONCAT(my_impianti.matricola, " - ", my_impianti.nome) AS descrizione, my_impianti.idanagrafica, an_anagrafiche.ragione_sociale, my_impianti.idsede, IFNULL(an_sedi.nomesede, "Sede legale") AS nomesede FROM my_impianti LEFT JOIN an_anagrafiche ON my_impianti.idanagrafica=an_anagrafiche.idanagrafica LEFT JOIN an_sedi ON my_impianti.idsede=an_sedi.id |where| ORDER BY idsede';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = 'id='.prepare($element);
|
||||
}
|
||||
|
||||
$where[] = 'idanagrafica='.prepare($superselect['idanagrafica']);
|
||||
$where[] = 'idsede='.prepare($superselect['idsede_destinazione'] ?: 0);
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = 'nome LIKE '.prepare('%'.$search.'%');
|
||||
$search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = 'id='.prepare($element);
|
||||
}
|
||||
|
||||
if (!empty($superselect['idanagrafica'])) {
|
||||
$where[] = 'my_impianti.idanagrafica='.prepare($superselect['idanagrafica']);
|
||||
$where[] = 'my_impianti.idsede='.prepare($superselect['idsede_destinazione'] ?: 0);
|
||||
}
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = 'my_impianti.nome LIKE '.prepare('%'.$search.'%');
|
||||
$search_fields[] = 'my_impianti.matricola LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
|
@ -174,6 +174,20 @@ echo '
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Impianto').'", "multiple": 1, "name": "idimpianti[]", "value": "'.$impianti_collegati.'", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": '.($id_anagrafica ?: '""').', "idsede_destinazione": '.($id_sede ?: '""').'}, "icon-after": "add|'.Modules::get('Impianti')['id'].'|id_anagrafica='.$id_anagrafica.'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Componenti').'", "multiple": 1, "name": "componenti[]", "placeholder": "'.tr('Seleziona prima un impianto').'", "ajax-source": "componenti" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "ajax-source": "segmenti", "select-options": '.json_encode(['id_module' => $id_module, 'is_sezionale' => 1]).', "value": "'.$_SESSION['module_'.$id_module]['id_segment'].'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Preventivo').'", "name": "idpreventivo", "value": "'.$id_preventivo.'", "ajax-source": "preventivi", "readonly": "'.(empty($id_preventivo) ? 0 : 1).'", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica]).' ]}
|
||||
@ -188,16 +202,6 @@ echo '
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Referente').'", "name": "idreferente", "ajax-source": "referenti", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica, 'idclientefinale' => $id_cliente_finale]).', "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|id_plugin='.Plugins::get('Referenti')['id'].'&id_parent='.$id_anagrafica.'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "ajax-source": "segmenti", "select-options": '.json_encode(['id_module' => $id_module, 'is_sezionale' => 1]).', "value": "'.$_SESSION['module_'.$id_module]['id_segment'].'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "timestamp", "label": "'.tr('Data/ora richiesta').'", "name": "data_richiesta", "required": 1, "value": "'.($data_richiesta ?: '-now-').'" ]}
|
||||
@ -271,12 +275,8 @@ echo '
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Impianto').'", "multiple": 1, "name": "idimpianti[]", "value": "'.$impianti_collegati.'", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": '.($id_anagrafica ?: '""').', "idsede_destinazione": '.($id_sede ?: '""').'}, "icon-after": "add|'.Modules::get('Impianti')['id'].'|id_anagrafica='.$id_anagrafica.'" ]}
|
||||
{[ "type": "select", "label": "'.tr('Referente').'", "name": "idreferente", "ajax-source": "referenti", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica, 'idclientefinale' => $id_cliente_finale]).', "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|id_plugin='.Plugins::get('Referenti')['id'].'&id_parent='.$id_anagrafica.'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Componenti').'", "multiple": 1, "name": "componenti[]", "placeholder": "'.tr('Seleziona prima un impianto').'", "ajax-source": "componenti" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
@ -442,7 +442,6 @@ if (!empty($id_intervento)) {
|
||||
input("idcontratto").disable();
|
||||
input("idordine").disable();
|
||||
input("idreferente").disable();
|
||||
input("idimpianti").disable();
|
||||
input("componenti").disable();
|
||||
input("idanagrafica").disable();
|
||||
input("idclientefinale").disable();
|
||||
@ -485,7 +484,6 @@ echo '
|
||||
contratto.disable();
|
||||
ordine.disable();
|
||||
referente.disable();
|
||||
input("idimpianti").disable();
|
||||
input("componenti").disable();
|
||||
} else{
|
||||
let value = anagrafica.get();
|
||||
@ -539,7 +537,8 @@ echo '
|
||||
let selected = !$(this).val();
|
||||
let placeholder = selected ? "'.tr('Seleziona prima un cliente').'" : "'.tr("Seleziona un'opzione").'";
|
||||
|
||||
sede.setDisabled(selected)
|
||||
let selected_sede = !$(this).val() || $(this).prop("disabled") ? 1 : 0;
|
||||
sede.setDisabled(selected_sede)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
preventivo.setDisabled(selected)
|
||||
@ -554,7 +553,6 @@ echo '
|
||||
referente.setDisabled(selected)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
input("idimpianti").setDisabled(selected);
|
||||
|
||||
let data = anagrafica.getData();
|
||||
if (data) {
|
||||
@ -609,7 +607,7 @@ echo '
|
||||
sede.change(function() {
|
||||
updateSelectOption("idsede_destinazione", $(this).val());
|
||||
session_set("superselect,idsede_destinazione", $(this).val(), 0);
|
||||
input("idimpianti").getElement().selectReset();
|
||||
|
||||
|
||||
let data = sede.getData();
|
||||
if (data) {
|
||||
@ -656,6 +654,21 @@ echo '
|
||||
|
||||
input("componenti").setDisabled(!$(this).val())
|
||||
.getElement().selectReset();
|
||||
|
||||
// Selezione anagrafica in automatico in base impianto
|
||||
if ($(this).val()[0]) {
|
||||
input("idanagrafica").disable();
|
||||
input("idsede_destinazione").disable();
|
||||
|
||||
let data = $(this).selectData()[0];
|
||||
input("idanagrafica").getElement()
|
||||
.selectSetNew(data.idanagrafica, data.ragione_sociale);
|
||||
input("idsede_destinazione").getElement()
|
||||
.selectSetNew(data.idsede, data.nomesede);
|
||||
} else {
|
||||
input("idanagrafica").enable();
|
||||
input("idsede_destinazione").enable();
|
||||
}
|
||||
});
|
||||
|
||||
// Automatismo del tempo standard
|
||||
|
Loading…
x
Reference in New Issue
Block a user