Skip to content

Instantly share code, notes, and snippets.

@camilamoreiradev
Created July 29, 2019 22:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save camilamoreiradev/f4a9167a63a89b03c0e10470f65f56e7 to your computer and use it in GitHub Desktop.
Save camilamoreiradev/f4a9167a63a89b03c0e10470f65f56e7 to your computer and use it in GitHub Desktop.
Mensagem de Confirmação - Scriptcase e Sweet Alert
?>
<style>
/*CSS PARA OCULTAR DOIS CAMPOS E DOIS LABELS*/
.css_qtd_min__label, .css_qtd_max__label, .css_qtd_min__line, .css_qtd_max__line {
display: none !important;
}
</style>
<script>
/*FUNÇÃO DO SCRIPTCASE ALTERADA*/
function cm_atualiza_line(x, y) {
if (Nm_Proc_Atualiz) {
return;
}
z = document.getElementById("idVertRow" + y).rowIndex;
document.F1.nmgp_parms.value = "";
document.F1.target = "_self";
document.F1.nmgp_opcao.value = x;
var qtdMin = parseInt($("#id_sc_field_qtd_min_"+y).val());
var qtdMax = parseInt($("#id_sc_field_qtd_max_"+y).val());
var qtdAtual = parseInt($("#id_sc_field_qtd_"+y).val());
if (x == "excluir") {
Swal.fire({
title: 'Cuidado!',
text: 'Deseja mesmo excluir este registro?',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#59b479',
cancelButtonColor: '#e36e6e',
cancelButtonText: 'Desistir',
confirmButtonText: 'Sim, excluir agora!'
}).then((result) => {
if (result.value) {
Swal.fire(
'Pronto!',
'O registro foi excluído com sucesso.',
'success'
)
Nm_Proc_Atualiz = true;
do_ajax_cadastro_inventario_submit_form(y, z);
} else {
return;
}
Nm_Proc_Atualiz = false;
});
}
if (x == "alterar") {
if((qtdAtual < qtdMin) || (qtdAtual > qtdMax)) {
Swal.fire(
'Ops!',
'Este produto não pode ter sua quantidade menor que ' + qtdMin + ' e maior que ' + qtdMax + '.',
'error'
);
} else {
Swal.fire({
title: 'Cuidado!',
text: "Deseja mesmo atualizar este registro ?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#59b479',
cancelButtonColor: '#e36e6e',
cancelButtonText: 'Cancelar',
confirmButtonText: 'Sim, atualizar agora!'
}).then((result) => {
if (result.value) {
Swal.fire(
'Pronto!',
'O registro foi atualizado com sucesso.',
'success'
)
Nm_Proc_Atualiz = true;
do_ajax_cadastro_inventario_submit_form(y, z);
} else {
return;
}
Nm_Proc_Atualiz = false;
});
}
}
if (x == "incluir") {
if((qtdAtual < qtdMin) || (qtdAtual > qtdMax)) {
Swal.fire(
'Ops!',
'Este produto não pode ter sua quantidade menor que ' + qtdMin + ' e maior que ' + qtdMax + '.',
'error'
);
} else {
Nm_Proc_Atualiz = true;
do_ajax_cadastro_inventario_submit_form(y, z);
}
}
}
$(function(){
/*FUNÇÃO PARA ALTERAR O NOME DAS FUNÇÕES ATRIBUIDAS NO EVENTO ONCLICK DOS ÍCONES*/
setInterval(function(){
$( "td.scFormDataOddMult a" ).each(function( index ) {
if($(this).attr("onclick")) {
var strOnClick = $(this).attr("onclick");
var newAtributo = strOnClick.replace("nm_atualiza_line", "cm_atualiza_line");
$(this).attr("onclick", newAtributo);
}
});
}, 1000);
});
</script>
<?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment