Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save camilamoreiradev/a7e6a76db5ef065836bc21138fd8bf58 to your computer and use it in GitHub Desktop.
Save camilamoreiradev/a7e6a76db5ef065836bc21138fd8bf58 to your computer and use it in GitHub Desktop.
//onScriptInit
[sw_i] = array();
echo <<<HTML
<style>
input#rec_f0_top {
width: 160px !important;
padding: 10px !important;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js"></script>
<script>
$(document).ready(function() {
$('#sc_alterar_data_top').removeAttr('onclick');
$('#rec_f0_top').attr('type', 'date');
$('#brec_top').removeAttr('onclick').removeClass('scButton_default');
$('#rec_f0_top').on('change', function() {
var dt = $(this).val();
Cookies.set('sw_dt', dt);
});
$('#sc_alterar_data_top').on('click', function() {
if($('#rec_f0_top').val()=="") {
Swal.fire({
title: 'Ops!',
text: 'Por favor, preencha a data para alterar.',
icon: 'error'
});
} else {
sc_btn_alterar_data();
}
});
});
</script>
HTML;
//onRecord botão
[sw_i][] = {requisition_id};
//onFinish botão
if(isset($_COOKIE['sw_dt']) && (!empty($_COOKIE['sw_dt']))) {
$update = "UPDATE tb_requisitions SET requisition_target_fill_date = '".$_COOKIE['sw_dt']."' WHERE requisition_id IN (".implode(',', [sw_i]).")";
sc_exec_sql($update);
sc_commit_trans();
sc_redir('grid_tb_requisitions.php');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment