Skip to content

Instantly share code, notes, and snippets.

@rizkyramadhan21
Created June 18, 2021 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rizkyramadhan21/b1820725b3f76b9d5ef23022b6f806f6 to your computer and use it in GitHub Desktop.
Save rizkyramadhan21/b1820725b3f76b9d5ef23022b6f806f6 to your computer and use it in GitHub Desktop.
Blogging Resources
<div class="container">
<br />
<div class="small text-muted">Home » Results</div>
<hr />
<div class="col-md-12">
<h5>Hasil Input Laporan Harian</h5>
<div class="panel panel-body">
Hi, data Anda berhasil diinput!<br /><br /><form id="telegramForm" method="POST">
<input id="telegram_id" class="form-control" name="chat_id" type="hidden" value="-1001059123456" />
<input class="form-control" name="text" type="hidden" value='Waktu : <?php echo date("Y-m-d H:i:s");?> <?php echo "\n";?>Nama : * <?php echo $this->input->post('nama');?> <?php echo "\n";?>Jumlah Penjualan : *<?php echo $this->input->post('sales');?> <?php echo "\n\n\n*>>>* _Laporan via bot Telegram_ *<<<*";?> '/>
<br />
<button id="sendToGroup" class="btn btn-primary" type="submit">Posting ke Group</button>
</form>
</div>
</div>
</div>
<script>
$(document).on('click', '#sendToGroup', function(e){
SwalTelegram();
e.preventDefault();
});
function SwalTelegram(){
if ($("#telegram_id").val()) {
swal({
title: 'Posting ke group?',
text: "Pastikan Laporan anda sudah benar",
type: 'question',
showCancelButton: true,
confirmButtonColor: '#3FC3EE',
cancelButtonColor: '#E91E63',
confirmButtonText: 'Ya!',
showLoaderOnConfirm: true,
preConfirm: function() {
return new Promise(function(resolve) {
$.ajax({
url: 'https://api.telegram.org/bot12345678:ABCDEFGHIJKLMnoPQRS-tUwXYZ/sendMessage?parse_mode=Markdown',
type: 'POST',
data: $('#telegramForm').serialize(),
dataType: 'html'
})
.done(function(response){
swal({
title: "Sukses!",
html: "Silahkan laporan berhasil dikirim",
type: "success",
allowOutsideClick: false,
timer:5000,
showConfirmButton: false,
animation: false,
customClass: 'animated jackInTheBox',
})
})
.fail(function(){
swal('Oops...', 'Ada kesalahan &#x2639;&#xfe0f;', 'error');
});
});
},
allowOutsideClick: false
});
}
else {
swal({
title: "Warning!",
html: "Ooops ada kesalahan system!",
type: "warning",
allowOutsideClick: false,
timer:3000,
showConfirmButton: false
});
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment