Aggiunta variabile revisione in stampa Preventivi

This commit is contained in:
Thomas Zilio 2020-03-09 14:24:59 +01:00
parent b70196bd51
commit 869416e401
2 changed files with 75 additions and 50 deletions

View File

@ -5,6 +5,8 @@ $r = $dbo->fetchOne('SELECT *,
an_anagrafiche.email an_anagrafiche.email
FROM co_preventivi INNER JOIN an_anagrafiche ON co_preventivi.idanagrafica=an_anagrafiche.idanagrafica WHERE co_preventivi.id='.prepare($id_record)); FROM co_preventivi INNER JOIN an_anagrafiche ON co_preventivi.idanagrafica=an_anagrafiche.idanagrafica WHERE co_preventivi.id='.prepare($id_record));
$revisione = $dbo->fetchNum('SELECT * FROM co_preventivi WHERE master_revision = (SELECT master_revision FROM co_preventivi WHERE id = '.prepare($id_record).') AND id < '.prepare($id_record)) + 1;
// Variabili da sostituire // Variabili da sostituire
return [ return [
'email' => $r['email'], 'email' => $r['email'],
@ -13,4 +15,5 @@ return [
'descrizione' => $r['descrizione'], 'descrizione' => $r['descrizione'],
'data' => Translator::dateToLocale($r['data_bozza']), 'data' => Translator::dateToLocale($r['data_bozza']),
'id_anagrafica' => $r['idanagrafica'], 'id_anagrafica' => $r['idanagrafica'],
'revisione' => $revisione,
]; ];

View File

@ -1,69 +1,91 @@
<?php <?php
include_once __DIR__.'/../../../core.php'; include_once __DIR__.'/../../../core.php';
echo "<form action='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$id_record."' method='post'>"; $revisione_principale = $dbo->fetchOne('SELECT master_revision FROM co_preventivi WHERE id = '.prepare($id_record));
echo " <input type='hidden' name='backto' value='record-edit'>";
echo " <input type='hidden' name='op' value='edit_revision'>";
echo " <input type='hidden' name='id_plugin' value='".$id_plugin."'>";
echo " <input type='hidden' name='id_record' value='".$id_record."'>";
$rs_master_revision = $dbo->fetchArray('SELECT master_revision FROM co_preventivi WHERE id='.prepare($id_record)); $revisioni = $dbo->fetchArray('SELECT * FROM co_preventivi WHERE master_revision = '.prepare($revisione_principale['master_revision']).' OR id = '.prepare($revisione_principale['master_revision']).' ORDER BY created_at');
echo " <input type='hidden' name='master_revision' value='".$rs_master_revision[0]['master_revision']."'>"; echo "
<form action='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$id_record."' method='post'>
<input type='hidden' name='backto' value='record-edit'>
<input type='hidden' name='op' value='edit_revision'>
<input type='hidden' name='id_plugin' value='".$id_plugin."'>
<input type='hidden' name='id_record' value='".$id_record."'>
<input type='hidden' name='master_revision' value='".$revisione_principale['master_revision']."'>
$rs_revisioni = $dbo->fetchArray('SELECT * FROM co_preventivi WHERE master_revision='.prepare($rs_master_revision[0]['master_revision']).' OR id='.prepare($rs_master_revision[0]['master_revision']).' ORDER BY created_at'); <div class='alert alert-info'>
<i class='fa fa-info-circle'></i> ".tr('Seleziona la spunta e clicca salva per cambiare la revisione del preventivo')."
</div>
echo " <div class='row'>"; <table class='table table-condensed table-bordered'>
echo " <div class='col-md-12'>"; <tr>
echo " <div class='alert alert-info'><i class='fa fa-info-circle'></i> Seleziona la spunta e clicca salva per cambiare la revisione del preventivo</div>";
echo " <table class='table table-condensed table-bordered'>";
echo " <tr>
<th style='width:50px;' class='text-center'>#</th> <th style='width:50px;' class='text-center'>#</th>
<th>Descrizione</th> <th>Descrizione</th>
<th style='width:50px;'></th> <th style='width:50px;'></th>
</tr>"; </tr>";
for ($i = 0; $i < sizeof($rs_revisioni); ++$i) {
if ($rs_revisioni[$i]['master_revision'] == $rs_revisioni[$i]['id'] || $rs_revisioni[$i]['default_revision'] == 1) { foreach ($revisioni as $i => $revisione) {
if ($revisione['master_revision'] == $revisione['id'] || $revisione['default_revision'] == 1) {
$disabled = 'disabled'; $disabled = 'disabled';
} else { } else {
$disabled = ''; $disabled = '';
} }
if ($rs_revisioni[$i]['default_revision']) {
if ($revisione['default_revision']) {
$cheched = 'checked'; $cheched = 'checked';
} else { } else {
$cheched = ''; $cheched = '';
} }
echo " <tr>
echo "
<tr>
<td class='text-center'> <td class='text-center'>
<input type='radio' class='revision_changer' name='idrevisione' value='".$rs_revisioni[$i]['id']."' ".$cheched.'> <input type='radio' class='revision_changer' name='idrevisione' value='".$revisione['id']."' ".$cheched.'>
</td> </td>
<td> <td>
Revisione '.($i + 1).' creata il '.Translator::dateToLocale($rs_revisioni[$i]['created_at']).' alle '.date('H:i', strtotime($rs_revisioni[$i]['created_at']))." '.tr('Revisione _NUM_ creata il _DATE_ alle _TIME_', [
'_NUM_' => ($i + 1),
'_DATE_' => dateFormat($revisione['created_at']),
'_TIME_' => timeFormat($revisione['created_at']),
])."
</td> </td>
<td class='text-center'>"; ?> <td class='text-center'>
<button type='button' class='btn btn-danger <?php echo $disabled; ?>' onclick='if(confirm("Vuoi cancellare questa revisione?")){$("#idrevisione").val("<?php echo $rs_revisioni[$i]['id']; ?>");$("#form_deleterevision").submit();}' <?php echo $disabled; ?>><i class='fa fa-trash'></i></button> <button type='button' class='btn btn-danger ".$disabled."' onclick='delete_revision(".$revisione['id'].")' ".$disabled.">
<?php <i class='fa fa-trash'></i>
echo ' </button>
</td> </td>
</tr>'; </tr>";
} }
echo ' </table>';
echo ' </div>'; echo '
echo ' </div>'; </table>';
echo " <div class='row'>";
echo " <div class='col-md-12 text-center'>";
echo ' <button '.((sizeof($rs_revisioni) < 2) ? 'disabled' : '')." type='submit' class='btn btn-primary' ><i class='fa fa-refresh'></i> ".tr('Cambia revisione').'</button>';
echo ' </div>';
echo ' </div>';
echo '</form>';
echo "<form action='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$id_record."' method='post' id='form_deleterevision'>"; echo "
echo " <input type='hidden' name='backto' value='record-edit'>"; <div class='row'>
echo " <input type='hidden' name='op' value='delete_revision'>"; <div class='col-md-12 text-center'>
echo " <input type='hidden' name='id_plugin' value='".$id_plugin."'>"; <button ".((count($revisioni) < 2) ? 'disabled' : '')." type='submit' class='btn btn-primary'>
echo " <input type='hidden' name='id_record' value='".$id_record."'>"; <i class='fa fa-refresh'></i> ".tr('Cambia revisione').'
echo " <input type='hidden' name='idrevisione' id='idrevisione' value=''>"; </button>
echo '</form>'; </div>
?> </div>
</form>';
echo "
<form action='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$id_record."' method='post' id='form_deleterevision'>
<input type='hidden' name='backto' value='record-edit'>
<input type='hidden' name='op' value='delete_revision'>
<input type='hidden' name='id_plugin' value='".$id_plugin."'>
<input type='hidden' name='id_record' value='".$id_record."'>
<input type='hidden' name='idrevisione' id='idrevisione' value=''>
</form>";
echo '
<script>
function delete_revision(id) {
if(confirm("'.tr('Vuoi cancellare questa revisione?').'")){
$("#idrevisione").val(id);
$("#form_deleterevision").submit();
}
}
</script>';