change expirty certificate
This commit is contained in:
+82
-3
@@ -58,7 +58,7 @@ $today = date('Y-m-d');
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#certificateTable').DataTable({
|
||||
window.certTable = $('#certificateTable').DataTable({
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.11.5/i18n/it-IT.json"
|
||||
},
|
||||
@@ -85,6 +85,66 @@ $today = date('Y-m-d');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Chip della scadenza (stesso aspetto dopo la modifica)
|
||||
function expChipHtml(id, user, date, expired) {
|
||||
var chip = $('<span>')
|
||||
.addClass('exp-chip exp-edit ' + (expired ? 'exp-expired' : 'exp-ok'))
|
||||
.attr({
|
||||
'data-id': id,
|
||||
'data-date': date,
|
||||
'data-user': user,
|
||||
'title': 'Clicca per modificare la scadenza'
|
||||
})
|
||||
.text(date + ' ')
|
||||
.append('<i class="fas fa-pen"></i>');
|
||||
return $('<div>').append(chip).html();
|
||||
}
|
||||
|
||||
// Clic sulla scadenza: scegli la nuova data e salva
|
||||
$(document).on('click', '.exp-edit', function() {
|
||||
var chip = $(this);
|
||||
var id = chip.attr('data-id');
|
||||
var user = chip.attr('data-user') || '';
|
||||
var current = chip.attr('data-date') || '';
|
||||
|
||||
Swal.fire({
|
||||
title: 'Modifica scadenza',
|
||||
html: 'Certificato di <strong>' + $('<div>').text(user).html() + '</strong>',
|
||||
input: 'date',
|
||||
inputValue: (/^\d{4}-\d{2}-\d{2}$/.test(current) && current !== '0000-00-00') ? current : '',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Salva',
|
||||
cancelButtonText: 'Annulla',
|
||||
confirmButtonColor: '#1ebf73',
|
||||
showLoaderOnConfirm: true,
|
||||
inputValidator: (v) => !v ? 'Scegli una data.' : undefined,
|
||||
preConfirm: (v) => {
|
||||
return $.post('admin_update_certificate_expiry.php', {
|
||||
id: id,
|
||||
expiry: v
|
||||
}, null, 'json')
|
||||
.then(function(resp) {
|
||||
if (!resp || !resp.success) throw new Error((resp && resp.message) || 'Errore durante il salvataggio.');
|
||||
return resp;
|
||||
})
|
||||
.catch(function(err) {
|
||||
Swal.showValidationMessage((err.responseJSON && err.responseJSON.message) || err.message || 'Errore durante il salvataggio.');
|
||||
});
|
||||
}
|
||||
}).then(function(r) {
|
||||
if (!r.isConfirmed || !r.value) return;
|
||||
var td = chip.closest('td');
|
||||
window.certTable.cell(td).data(expChipHtml(id, user, r.value.expiry, r.value.expired)).draw(false);
|
||||
Swal.fire({
|
||||
title: 'Fatto',
|
||||
text: 'Scadenza aggiornata al ' + r.value.expiry.split('-').reverse().join('/') + '.',
|
||||
icon: 'success',
|
||||
timer: 1800,
|
||||
showConfirmButton: false
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -156,6 +216,21 @@ $today = date('Y-m-d');
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.exp-edit {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.exp-edit i {
|
||||
font-size: 10px;
|
||||
opacity: 0.6;
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.exp-edit:hover {
|
||||
filter: brightness(0.95);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.exp-ok {
|
||||
background: #e3f2ec;
|
||||
color: #1a7f52;
|
||||
@@ -256,8 +331,12 @@ $today = date('Y-m-d');
|
||||
</td>
|
||||
<td><?php echo e($d['documentdescription']); ?></td>
|
||||
<td>
|
||||
<span class="exp-chip <?php echo $isExpired ? 'exp-expired' : 'exp-ok'; ?>">
|
||||
<?php echo e($d['expirydatedocument']); ?>
|
||||
<span class="exp-chip exp-edit <?php echo $isExpired ? 'exp-expired' : 'exp-ok'; ?>"
|
||||
data-id="<?php echo $idc; ?>"
|
||||
data-date="<?php echo e($d['expirydatedocument']); ?>"
|
||||
data-user="<?php echo e($fullName); ?>"
|
||||
title="Clicca per modificare la scadenza">
|
||||
<?php echo e($d['expirydatedocument']); ?> <i class="fas fa-pen"></i>
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo e($d['uploaded_at'] ?? 'N/D'); ?></td>
|
||||
|
||||
Reference in New Issue
Block a user