1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-24 22:42:33 +01:00

Gestione verifica movimenti contabili

This commit is contained in:
MatteoPistorello 2023-10-23 16:39:27 +02:00
parent 4832ac44f4
commit 262e8016a7
3 changed files with 92 additions and 2 deletions

View File

@ -247,5 +247,36 @@ switch (post('op')) {
echo json_encode(['conti2' => $id_conti2, 'conti3' => $id_conti3, 'conti2_3' => $id_conti2_3]);
break;
case 'manage_verifica':
$id_movimento = post('id_movimento');
$is_verificato = post('is_verificato');
$response = null;
try {
$movimento = Movimento::find($id_movimento);
if ($is_verificato) {
$movimento->verified_at = date('Y-m-d H:i:s');
$movimento->verified_by = $user->id;
} else {
$movimento->verified_at = null;
$movimento->verified_by = 0;
}
$movimento->save();
$response = [
'result' => true
];
} catch (Error $e) {
$response = [
'result' => false,
'message' => $e->getMessage(),
];
}
echo json_encode($response);
break;
}

View File

@ -19,6 +19,8 @@
include_once __DIR__.'/../../core.php';
use Models\User;
$prima_nota = Modules::get('Prima nota');
$id_conto = get('id_conto');
@ -45,6 +47,7 @@ if (!empty($movimenti)) {
<th width="100">'.tr('Dare').'</th>
<th width="100">'.tr('Avere').'</th>
<th width="100">'.tr('Scalare').'</th>
<th width="80" class="text-center">'.tr('Verificato').'</th>
</tr>';
$scalare = array_sum(array_column($movimenti, 'totale'));
@ -97,6 +100,20 @@ if (!empty($movimenti)) {
$scalare -= $movimento['totale'];
// Verificato
$verified_by = '';
if ($movimento['verified_by']) {
$verified_user = User::find($movimento['verified_by']);
$verified_by = ($movimento['verified_by'] ? tr('Verificato da _USER_ il _DATE_', [
'_USER_' => $verified_user->username,
'_DATE_' => dateFormat($movimento['verified_at']).' '.timeFormat($movimento['verified_at']),
]) : '');
}
echo '
<td class="text-center">
<input type="checkbox" id="checked_'.$movimento['id'].'" name="verified['.$movimento['id'].']" class="tip" title="'.$verified_by.'" '.($movimento['verified_at'] ? 'checked' : '').' onclick="Verifica('.$movimento['id'].');" />
</td>';
echo '
</tr>';
}
@ -107,3 +124,42 @@ if (!empty($movimenti)) {
echo '
<span>'.tr('Nessun movimento presente').'</span>';
}
echo '
<script>
/*
* Verifica il movimento contabile
*/
function Verifica(id_movimento) {
$.ajax({
url: globals.rootdir + "/actions.php",
data: {
id_module: globals.id_module,
op: "manage_verifica",
id_movimento: id_movimento,
is_verificato: $("#checked_"+id_movimento).is(":checked") ? 1 : 0
},
type: "post",
success: function(response) {
$("#checked_"+id_movimento).tooltipster("destroy");
response = JSON.parse(response);
if (response.result) {
$("#checked_"+id_movimento).parent().parent().effect("highlight", {}, 500);
if ($("#checked_"+id_movimento).is(":checked")) {
$("#checked_"+id_movimento).attr("title", "'.tr('Verificato da _USER_ il _DATE_', [
'_USER_' => $user->username,
'_DATE_' => dateFormat(date('Y-m-d')).' '.date('H:i'),
]).'");
} else {
$("#checked_"+id_movimento).attr("title", "");
}
} else {
$("#checked_"+id_movimento).prop("checked", !$("#checked_"+id_movimento).is(":checked"));
alert(response.message);
}
init();
}
});
}
init();
</script>';

View File

@ -1,8 +1,11 @@
-- Aggiunto modulo Stati ordini
-- Aggiunto modulo Stati fatture
INSERT INTO `zz_modules` (`name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES ('Stati fatture', 'Stati fatture','stati_fattura', 'SELECT |select| FROM `co_statidocumento` WHERE 1=1 HAVING 2=2', '', 'fa fa-angle-right', '2.4.50', '2.4.50', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Tabelle'), '1', '1');
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati fatture'), 'Icona', 'icona', 3, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati fatture'), 'Descrizione', 'descrizione', 2, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati fatture'), 'id', 'id', 1, 0, 0, 1, 0),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati fatture'), 'color_Colore', 'colore', 1, 0, 0, 1, 0);
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati fatture'), 'color_Colore', 'colore', 1, 0, 0, 1, 0);
-- Flag verificato in Movimenti
ALTER TABLE `co_movimenti` ADD `verified_at` TIMESTAMP NULL AFTER `totale_reddito`, ADD `verified_by` INT NOT NULL AFTER `verified_at`;