mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-02 08:56:48 +01:00
Correzioni su associazione Intervento - Ordine
This commit is contained in:
parent
290fd56847
commit
bf2b4e24bc
@ -63,6 +63,7 @@ $rs = $dbo->fetchArray('SELECT
|
||||
AND in_interventi.id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL)
|
||||
AND in_interventi.id_preventivo IS NULL
|
||||
AND in_interventi.id_contratto IS NULL
|
||||
AND in_interventi.id_ordine IS NULL
|
||||
AND NOT in_interventi.id IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL)');
|
||||
foreach ($rs as $key => $value) {
|
||||
$intervento = \Modules\Interventi\Intervento::find($value['id']);
|
||||
|
@ -60,6 +60,7 @@ if (!empty($id_anagrafica)) {
|
||||
$id_intervento = filter('id_intervento');
|
||||
$id_contratto = filter('idcontratto');
|
||||
$id_promemoria_contratto = filter('idcontratto_riga');
|
||||
$id_ordine = null;
|
||||
|
||||
// Trasformazione di un Promemoria dei Contratti in Intervento
|
||||
if (!empty($id_contratto) && !empty($id_promemoria_contratto)) {
|
||||
@ -164,21 +165,23 @@ echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "'.(!$id_cliente ? $id_anagrafica : $id_cliente).'", "ajax-source": "clienti", "icon-after": "add|'.$module_anagrafiche['id'].'|tipoanagrafica=Cliente&readonly_tipo=1", "readonly": "'.((empty($id_anagrafica) && empty($id_cliente)) ? 0 : 1).'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Preventivo').'", "name": "idpreventivo", "value": "'.$id_preventivo.'", "ajax-source": "preventivi", "readonly": "'.(empty($id_preventivo) ? 0 : 1).'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Contratto').'", "name": "idcontratto", "value": "'.$id_contratto.'", "ajax-source": "contratti", "readonly": "'.(empty($id_contratto) ? 0 : 1).'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Ordine').'", "name": "idordine", "ajax-source": "ordini" ]}
|
||||
{[ "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]).' ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Contratto').'", "name": "idcontratto", "value": "'.$id_contratto.'", "ajax-source": "contratti", "readonly": "'.(empty($id_contratto) ? 0 : 1).'", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica]).' ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Ordine').'", "name": "idordine", "ajax-source": "ordini-cliente", "value": "'.$id_ordine.'", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica]).' ]}
|
||||
</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-').'" ]}
|
||||
</div>
|
||||
@ -186,14 +189,14 @@ echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Tipo').'", "name": "idtipointervento", "required": 1, "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC", "value": "'.$id_tipo.'", "ajax-source": "tipiintervento" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Stato').'", "name": "idstatointervento", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL", "value": "'.$id_stato.'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "ckeditor", "label": "'.tr('Richiesta').'", "name": "richiesta_add", "required": 1, "value": "'.$richiesta.'", "extra": "style=\'max-height:80px;\'" ]}
|
||||
</div>
|
||||
</div>';
|
||||
@ -361,12 +364,14 @@ echo '
|
||||
var sede = input("idsede_destinazione");
|
||||
var contratto = input("idcontratto");
|
||||
var preventivo = input("idpreventivo");
|
||||
var ordine = input("idordine");
|
||||
|
||||
$(document).ready(function() {
|
||||
if(!anagrafica.get()){
|
||||
sede.disable();
|
||||
input("idpreventivo").disable();
|
||||
input("idcontratto").disable();
|
||||
preventivo.disable();
|
||||
contratto.disable();
|
||||
ordine.disable();
|
||||
input("idimpianti").disable();
|
||||
input("componenti").disable();
|
||||
}
|
||||
@ -404,10 +409,13 @@ echo '
|
||||
sede.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
input("idpreventivo").setDisabled(value)
|
||||
preventivo.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
input("idcontratto").setDisabled(value)
|
||||
contratto.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
ordine.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
input("idimpianti").setDisabled(value);
|
||||
@ -436,13 +444,20 @@ echo '
|
||||
}
|
||||
});
|
||||
|
||||
// Gestione della modifica dell\'ordine selezionato
|
||||
ordine.change(function() {
|
||||
if (ordine.get()) {
|
||||
contratto.getElement().selectReset();
|
||||
preventivo.getElement().selectReset();
|
||||
}
|
||||
});
|
||||
|
||||
// Gestione della modifica del preventivo selezionato
|
||||
preventivo.change(function() {
|
||||
if (contratto.get() && preventivo.get()){
|
||||
contratto.getElement().selectReset();
|
||||
}
|
||||
|
||||
if (preventivo.get()){
|
||||
contratto.getElement().selectReset();
|
||||
ordine.getElement().selectReset();
|
||||
|
||||
input("idtipointervento").getElement()
|
||||
.selectSetNew($(this).selectData().idtipointervento, $(this).selectData().idtipointervento_descrizione);
|
||||
}
|
||||
@ -450,8 +465,10 @@ echo '
|
||||
|
||||
// Gestione della modifica del contratto selezionato
|
||||
contratto.change(function() {
|
||||
if (contratto.get() && preventivo.get()){
|
||||
if (contratto.get()){
|
||||
preventivo.getElement().selectReset();
|
||||
ordine.getElement().selectReset();
|
||||
|
||||
$("input[name=idcontratto_riga]").val("");
|
||||
}
|
||||
});
|
||||
|
@ -115,9 +115,7 @@ echo '
|
||||
}
|
||||
echo '
|
||||
|
||||
{[ "type": "select", "label": "'.tr('Ordine').'", "name": "idordine", "value": "'.$record['id_ordine'].'", "ajax-source": "ordini", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "readonly": "'.$record['flag_completato'].'" ]}
|
||||
|
||||
<input type="hidden" name="idcontratto_riga" value="'.$idcontratto_riga.'">
|
||||
{[ "type": "select", "label": "'.tr('Ordine').'", "name": "idordine", "value": "'.$record['id_ordine'].'", "ajax-source": "ordini-cliente", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "readonly": "'.$record['flag_completato'].'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -589,50 +587,94 @@ $(document).ready(function() {
|
||||
caricaCosti();
|
||||
});
|
||||
|
||||
$("#idanagrafica").change(function () {
|
||||
var anagrafica = input("idanagrafica");
|
||||
var sede = input("idsede_destinazione");
|
||||
var contratto = input("idcontratto");
|
||||
var preventivo = input("idpreventivo");
|
||||
var ordine = input("idordine");
|
||||
|
||||
// Gestione della modifica dell\'anagrafica
|
||||
anagrafica.change(function() {
|
||||
updateSelectOption("idanagrafica", $(this).val());
|
||||
session_set("superselect,idanagrafica", $(this).val(), 0);
|
||||
|
||||
$("#idsede_destinazione").selectReset();
|
||||
$("#idpreventivo").selectReset();
|
||||
$("#idcontratto").selectReset();
|
||||
let value = !$(this).val();
|
||||
let placeholder = value ? "'.tr('Seleziona prima un cliente').'" : "'.tr("Seleziona un'opzione").'";
|
||||
|
||||
if (($(this).val())) {
|
||||
if (($(this).selectData().idzona)) {
|
||||
$("#idzona").val($(this).selectData().idzona).change();
|
||||
sede.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
} else {
|
||||
$("#idzona").val("").change();
|
||||
}
|
||||
preventivo.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
contratto.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
ordine.setDisabled(value)
|
||||
.getElement().selectReset(placeholder);
|
||||
|
||||
input("idimpianti").setDisabled(value);
|
||||
|
||||
let data = anagrafica.getData();
|
||||
if (data) {
|
||||
input("idzona").set(data.idzona ? data.idzona : "");
|
||||
// session_set("superselect,idzona", $(this).selectData().idzona, 0);
|
||||
|
||||
// Impostazione del tipo intervento da anagrafica
|
||||
input("idtipointervento").getElement()
|
||||
.selectSetNew(data.idtipointervento, data.idtipointervento_descrizione);
|
||||
}
|
||||
});
|
||||
|
||||
$("#idpreventivo").change(function () {
|
||||
if ($("#idcontratto").val() && $(this).val()) {
|
||||
$("#idcontratto").val("").trigger("change");
|
||||
// Gestione della modifica della sede selezionato
|
||||
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) {
|
||||
input("idzona").set(data.idzona ? data.idzona : "");
|
||||
// session_set("superselect,idzona", $(this).selectData().idzona, 0);
|
||||
}
|
||||
});
|
||||
|
||||
$("#idcontratto").change(function () {
|
||||
if ($("#idpreventivo").val() && $(this).val()) {
|
||||
$("#idpreventivo").val("").trigger("change");
|
||||
// Gestione della modifica dell\'ordine selezionato
|
||||
ordine.change(function() {
|
||||
if (ordine.get()) {
|
||||
contratto.getElement().selectReset();
|
||||
preventivo.getElement().selectReset();
|
||||
}
|
||||
});
|
||||
|
||||
// Gestione della modifica del preventivo selezionato
|
||||
preventivo.change(function() {
|
||||
if (preventivo.get()){
|
||||
contratto.getElement().selectReset();
|
||||
ordine.getElement().selectReset();
|
||||
|
||||
input("idtipointervento").getElement()
|
||||
.selectSetNew($(this).selectData().idtipointervento, $(this).selectData().idtipointervento_descrizione);
|
||||
}
|
||||
});
|
||||
|
||||
// Gestione della modifica del contratto selezionato
|
||||
contratto.change(function() {
|
||||
if (contratto.get()){
|
||||
preventivo.getElement().selectReset();
|
||||
ordine.getElement().selectReset();
|
||||
|
||||
$("input[name=idcontratto_riga]").val("");
|
||||
}
|
||||
});
|
||||
|
||||
$("#matricola").change(function () {
|
||||
// Gestione delle modifiche agli impianti selezionati
|
||||
input("idimpianti").change(function() {
|
||||
updateSelectOption("matricola", $(this).val());
|
||||
session_set("superselect,matricola", $(this).val(), 0);
|
||||
});
|
||||
|
||||
$("#idsede").change(function () {
|
||||
if (($(this).val())) {
|
||||
if (($(this).selectData().idzona)) {
|
||||
$("#idzona").val($(this).selectData().idzona).change();
|
||||
} else {
|
||||
$("#idzona").val("").change();
|
||||
}
|
||||
//session_set("superselect,idzona", $(this).selectData().idzona, 0);
|
||||
}
|
||||
input("componenti").setDisabled(!$(this).val())
|
||||
.getElement().selectReset();
|
||||
});
|
||||
|
||||
$("#codice_cig, #codice_cup").bind("keyup change", function (e) {
|
||||
|
@ -24,9 +24,14 @@ switch ($resource) {
|
||||
* Opzioni utilizzate:
|
||||
* - idanagrafica
|
||||
*/
|
||||
case 'ordini':
|
||||
case 'ordini-cliente':
|
||||
if (isset($superselect['idanagrafica'])) {
|
||||
$query = 'SELECT or_ordini.id AS id, or_ordini.idanagrafica, CONCAT("Ordine ", numero, " del ", DATE_FORMAT(data, "%d/%m/%Y"), " [", (SELECT `descrizione` FROM `or_statiordine` WHERE `or_statiordine`.`id` = `idstatoordine`) , "]") AS descrizione, (SELECT SUM(subtotale) FROM or_righe_ordini WHERE idordine=or_ordini.id GROUP BY idordine) AS totale, (SELECT SUM(sconto) FROM or_righe_ordini WHERE idordine=or_ordini.id GROUP BY idordine) AS sconto FROM or_ordini INNER JOIN an_anagrafiche ON or_ordini.idanagrafica=an_anagrafiche.idanagrafica |where| ORDER BY id';
|
||||
$query = 'SELECT or_ordini.id AS id,
|
||||
CONCAT("Ordine ", numero, " del ", DATE_FORMAT(data, "%d/%m/%Y"), " [", (SELECT `descrizione` FROM `or_statiordine` WHERE `or_statiordine`.`id` = `idstatoordine`) , "]") AS descrizione
|
||||
FROM or_ordini
|
||||
INNER JOIN an_anagrafiche ON or_ordini.idanagrafica = an_anagrafiche.idanagrafica
|
||||
|where|
|
||||
ORDER BY id';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = 'id='.prepare($element);
|
||||
|
@ -306,7 +306,8 @@ UPDATE `zz_views` SET `order` = 8, `name`='Conto dare' WHERE `name`='Conto avere
|
||||
UPDATE `zz_views` SET `name`='Conto avere' WHERE `name`='Conto avere_new';
|
||||
|
||||
-- Aggiunta campo per scelta ordine in intervento
|
||||
ALTER TABLE `in_interventi` ADD `id_ordine` INT NOT NULL AFTER `id_contratto`;
|
||||
ALTER TABLE `in_interventi` ADD `id_ordine` INT(11) AFTER `id_contratto`;
|
||||
ALTER TABLE `in_interventi` ADD CONSTRAINT `in_interventi_ibfk_7` FOREIGN KEY (`id_ordine`) REFERENCES `or_ordini`(`id`) ON DELETE CASCADE;
|
||||
|
||||
-- Aggiunta plugin consuntivo per ordini
|
||||
INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES
|
||||
|
Loading…
x
Reference in New Issue
Block a user