mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-01 16:36:45 +01:00
Aggiunto campi dare e avere in modelli prima nota
This commit is contained in:
parent
5e5fafd5f0
commit
513176714b
@ -27,8 +27,16 @@ switch (post('op')) {
|
|||||||
|
|
||||||
for ($i = 0; $i < sizeof(post('idconto')); ++$i) {
|
for ($i = 0; $i < sizeof(post('idconto')); ++$i) {
|
||||||
$idconto = post('idconto')[$i];
|
$idconto = post('idconto')[$i];
|
||||||
|
$dare = post('dare')[$i];
|
||||||
|
$avere = post('avere')[$i];
|
||||||
|
|
||||||
if (!empty($idconto)) {
|
if (!empty($idconto)) {
|
||||||
$query = 'INSERT INTO co_movimenti_modelli(idmastrino, nome, descrizione, idconto) VALUES('.prepare($idmastrino).', '.prepare($nome).', '.prepare($descrizione).', '.prepare($idconto).')';
|
if(!empty($dare)){
|
||||||
|
$totale = $dare;
|
||||||
|
} else {
|
||||||
|
$totale = -$avere;
|
||||||
|
}
|
||||||
|
$query = 'INSERT INTO co_movimenti_modelli(idmastrino, nome, descrizione, idconto, totale) VALUES('.prepare($idmastrino).', '.prepare($nome).', '.prepare($descrizione).', '.prepare($idconto).', '.prepare($totale).')';
|
||||||
if ($dbo->query($query)) {
|
if ($dbo->query($query)) {
|
||||||
$id_record = $idmastrino;
|
$id_record = $idmastrino;
|
||||||
}
|
}
|
||||||
@ -47,8 +55,16 @@ switch (post('op')) {
|
|||||||
|
|
||||||
for ($i = 0; $i < sizeof(post('idconto')); ++$i) {
|
for ($i = 0; $i < sizeof(post('idconto')); ++$i) {
|
||||||
$idconto = post('idconto')[$i];
|
$idconto = post('idconto')[$i];
|
||||||
|
$dare = post('dare')[$i];
|
||||||
|
$avere = post('avere')[$i];
|
||||||
|
|
||||||
if (!empty($idconto)) {
|
if (!empty($idconto)) {
|
||||||
$query = 'INSERT INTO co_movimenti_modelli(idmastrino, nome, descrizione, idconto) VALUES('.prepare($idmastrino).', '.prepare($nome).', '.prepare($descrizione).', '.prepare($idconto).')';
|
if(!empty($dare)){
|
||||||
|
$totale = $dare;
|
||||||
|
} else {
|
||||||
|
$totale = -$avere;
|
||||||
|
}
|
||||||
|
$query = 'INSERT INTO co_movimenti_modelli(idmastrino, nome, descrizione, idconto, totale) VALUES('.prepare($idmastrino).', '.prepare($nome).', '.prepare($descrizione).', '.prepare($idconto).', '.prepare($totale).')';
|
||||||
if ($dbo->query($query)) {
|
if ($dbo->query($query)) {
|
||||||
$id_record = $idmastrino;
|
$id_record = $idmastrino;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,9 @@ include_once __DIR__.'/../../core.php';
|
|||||||
echo '
|
echo '
|
||||||
<table class="table table-striped table-condensed table-hover table-bordered"
|
<table class="table table-striped table-condensed table-hover table-bordered"
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Conto').'</th>
|
<th width="60%">'.tr('Conto').'</th>
|
||||||
|
<th width="20%">'.tr('Dare').'</th>
|
||||||
|
<th width="20%">'.tr('Avere').'</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
for ($i = 0; $i < 10; ++$i) {
|
for ($i = 0; $i < 10; ++$i) {
|
||||||
@ -55,6 +57,14 @@ include_once __DIR__.'/../../core.php';
|
|||||||
<td>
|
<td>
|
||||||
{[ "type": "select", "name": "idconto['.$i.']", "ajax-source": "conti", "required": "'.$required.'" ]}
|
{[ "type": "select", "name": "idconto['.$i.']", "ajax-source": "conti", "required": "'.$required.'" ]}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td class="text-right">
|
||||||
|
{[ "type": "number", "name": "dare['.$i.']", "id": "dare'.$id.'", "value": "'.($rs[$i]['totale']>0 ? $rs[$i]['totale'] : '').'"]}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="text-right">
|
||||||
|
{[ "type": "number", "name": "avere['.$i.']", "id": "avere'.$id.'", "value": "'.($rs[$i]['totale']<0 ? abs($rs[$i]['totale']) : '').'"]}
|
||||||
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,3 +109,42 @@ include_once __DIR__.'/../../core.php';
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready( function() {
|
||||||
|
$('#modals select').on('change', function() {
|
||||||
|
if($(this).parent().parent().find('input[disabled]').length != 1){
|
||||||
|
if($(this).val()) {
|
||||||
|
$(this).parent().parent().find('input').prop("disabled", false);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$(this).parent().parent().find('input').prop("disabled", true);
|
||||||
|
$(this).parent().parent().find('input').val("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#modals input[id*=dare], #modals input[id*=avere]").each(function() {
|
||||||
|
if (input(this).get() === 0) {
|
||||||
|
$(this).prop("disabled", true);
|
||||||
|
} else {
|
||||||
|
$(this).prop("disabled", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("keyup change", "#modals input[id*=dare]", function() {
|
||||||
|
let row = $(this).parent().parent();
|
||||||
|
|
||||||
|
if (!$(this).prop("disabled")) {
|
||||||
|
row.find("#modals input[id*=avere]").prop("disabled", input(this).get() !== 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("keyup change", "#modals input[id*=avere]", function() {
|
||||||
|
let row = $(this).parent().parent();
|
||||||
|
|
||||||
|
if (!$(this).prop("disabled")) {
|
||||||
|
row.find("#modals input[id*=dare]").prop("disabled", input(this).get() !== 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
@ -60,7 +60,9 @@ for ($x = 0; $x < sizeof($conti2); ++$x) {
|
|||||||
echo '
|
echo '
|
||||||
<table class="table table-striped table-condensed table-hover table-bordered"
|
<table class="table table-striped table-condensed table-hover table-bordered"
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Conto').'</th>
|
<th width="60%">'.tr('Conto').'</th>
|
||||||
|
<th width="20%">'.tr('Dare').'</th>
|
||||||
|
<th width="20%">'.tr('Avere').'</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
// Lettura movimenti del mastrino selezionato
|
// Lettura movimenti del mastrino selezionato
|
||||||
@ -74,6 +76,14 @@ for ($i = 0; $i < 10; ++$i) {
|
|||||||
<td>
|
<td>
|
||||||
{[ "type": "select", "name": "idconto['.$i.']", "value": "'.$rs[$i]['idconto'].'", "ajax-source": "conti-modelliprimanota", "required": "'.$required.'" ]}
|
{[ "type": "select", "name": "idconto['.$i.']", "value": "'.$rs[$i]['idconto'].'", "ajax-source": "conti-modelliprimanota", "required": "'.$required.'" ]}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td class="text-right">
|
||||||
|
{[ "type": "number", "name": "dare['.$i.']", "id": "dare'.$id.'", "value": "'.($rs[$i]['totale']>0 ? $rs[$i]['totale'] : '').'"]}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="text-right">
|
||||||
|
{[ "type": "number", "name": "avere['.$i.']", "id": "avere'.$id.'", "value": "'.($rs[$i]['totale']<0 ? abs($rs[$i]['totale']) : '').'"]}
|
||||||
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +106,34 @@ echo '
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("input[id*=dare], input[id*=avere]").each(function() {
|
||||||
|
let row = $(this).parent().parent();
|
||||||
|
|
||||||
|
if (!row.find("select").val()) {
|
||||||
|
if (input(this).get() === 0) {
|
||||||
|
$(this).prop("disabled", true);
|
||||||
|
} else {
|
||||||
|
$(this).prop("disabled", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("keyup change", "input[id*=dare]", function() {
|
||||||
|
let row = $(this).parent().parent();
|
||||||
|
|
||||||
|
if (!$(this).prop("disabled")) {
|
||||||
|
row.find("input[id*=avere]").prop("disabled", input(this).get() !== 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("keyup change", "input[id*=avere]", function() {
|
||||||
|
let row = $(this).parent().parent();
|
||||||
|
|
||||||
|
if (!$(this).prop("disabled")) {
|
||||||
|
row.find("input[id*=dare]").prop("disabled", input(this).get() !== 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@ -391,7 +391,7 @@ if ($permetti_modelli) {
|
|||||||
|
|
||||||
$.get(globals.rootdir + "/ajax_complete.php?op=get_conti&idmastrino=" + id_mastrino, function(data) {
|
$.get(globals.rootdir + "/ajax_complete.php?op=get_conti&idmastrino=" + id_mastrino, function(data) {
|
||||||
let conti = data.split(",");
|
let conti = data.split(",");
|
||||||
let table = $("table.scadenze").first();
|
let table = $("#modals table.scadenze").first();
|
||||||
let button = table.parent().find("button").first();
|
let button = table.parent().find("button").first();
|
||||||
|
|
||||||
// Creazione delle eventuali righe aggiuntive
|
// Creazione delle eventuali righe aggiuntive
|
||||||
@ -409,6 +409,7 @@ if ($permetti_modelli) {
|
|||||||
|
|
||||||
let id_conto = parseInt(dati_conto[0]);
|
let id_conto = parseInt(dati_conto[0]);
|
||||||
let descrizione_conto = dati_conto[1];
|
let descrizione_conto = dati_conto[1];
|
||||||
|
let totale = dati_conto[2];
|
||||||
|
|
||||||
// Sostituzione del conto dell\'Anagrafica
|
// Sostituzione del conto dell\'Anagrafica
|
||||||
if (id_conto === -1 && globals.prima_nota.id_documento !== ""){
|
if (id_conto === -1 && globals.prima_nota.id_documento !== ""){
|
||||||
@ -420,6 +421,15 @@ if ($permetti_modelli) {
|
|||||||
let select = $(righe[i + 1]).find("select");
|
let select = $(righe[i + 1]).find("select");
|
||||||
input(select).getElement()
|
input(select).getElement()
|
||||||
.selectSetNew(id_conto, descrizione_conto);
|
.selectSetNew(id_conto, descrizione_conto);
|
||||||
|
|
||||||
|
if(totale>0){
|
||||||
|
input_field = $(righe[i + 1]).find("input[id*=dare]");
|
||||||
|
} else{
|
||||||
|
input_field = $(righe[i + 1]).find("input[id*=avere]");
|
||||||
|
totale = -totale;
|
||||||
|
}
|
||||||
|
input(input_field).getElement()
|
||||||
|
.val(totale).trigger("change");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ switch ($resource) {
|
|||||||
$rs_conti = $dbo->fetchArray('SELECT *, (SELECT CONCAT ((SELECT numero FROM co_pianodeiconti2 WHERE id=co_pianodeiconti3.idpianodeiconti2), ".", numero, " ", descrizione) FROM co_pianodeiconti3 WHERE id=co_movimenti_modelli.idconto) AS descrizione_conto FROM co_movimenti_modelli WHERE idmastrino='.prepare($idmastrino).' GROUP BY id ORDER BY id');
|
$rs_conti = $dbo->fetchArray('SELECT *, (SELECT CONCAT ((SELECT numero FROM co_pianodeiconti2 WHERE id=co_pianodeiconti3.idpianodeiconti2), ".", numero, " ", descrizione) FROM co_pianodeiconti3 WHERE id=co_movimenti_modelli.idconto) AS descrizione_conto FROM co_movimenti_modelli WHERE idmastrino='.prepare($idmastrino).' GROUP BY id ORDER BY id');
|
||||||
|
|
||||||
for ($i = 0; $i < sizeof($rs_conti); ++$i) {
|
for ($i = 0; $i < sizeof($rs_conti); ++$i) {
|
||||||
$conti[$i] = $rs_conti[$i]['idconto'].';'.$rs_conti[$i]['descrizione_conto'];
|
$conti[$i] = $rs_conti[$i]['idconto'].';'.$rs_conti[$i]['descrizione_conto'].';'.$rs_conti[$i]['totale'];
|
||||||
}
|
}
|
||||||
|
|
||||||
echo implode(',', $conti);
|
echo implode(',', $conti);
|
||||||
|
@ -68,3 +68,6 @@ INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`
|
|||||||
|
|
||||||
-- Aggiunta colonna condizioni_fornitura in co_preventivi
|
-- Aggiunta colonna condizioni_fornitura in co_preventivi
|
||||||
ALTER TABLE `co_preventivi` ADD `condizioni_fornitura` TEXT NOT NULL AFTER `numero_revision`;
|
ALTER TABLE `co_preventivi` ADD `condizioni_fornitura` TEXT NOT NULL AFTER `numero_revision`;
|
||||||
|
|
||||||
|
-- Aggiunta colonna totale in modelli prima nota
|
||||||
|
ALTER TABLE `co_movimenti_modelli` ADD `totale` DECIMAL(12,6) NOT NULL AFTER `idconto`;
|
Loading…
x
Reference in New Issue
Block a user