<!-- Page Heading -->



          <h1 class="h3 mb-2 text-gray-800">Template Email PKA</h1>



          <!-- <p class="mb-4">DataTables is a third party plugin that is used to generate the demo table below. For more information about DataTables, please visit the <a target="_blank" href="https://datatables.net">official DataTables documentation</a>.</p> -->







          <!-- DataTales Example -->











          <div class="card shadow mb-4">



            <div class="card-header py-3 bg-primary">



              <h6 class="m-0 font-weight-bold text-light">Accept PKA</h6>



            </div>



            <div class="card-body">



              <div class="row">



                <div class="col-md-12">



                  <form id="form_user_acc_pka">



                    <input type="hidden" id="id_template_email_user_acc_pka" name="id_template_email_user_acc_pka">



                    <div class="form-group">



                      <label>Subject</label>



                      <input type="text" id="sjk_user_acc_pka" class="form-control" name="sjk_user_acc_pka"/>



                    </div>



                    <div class="form-group">



                      <label>Message</label>



                      <textarea id="msg_user_acc_pka" class="form-control" name="msg_user_acc_pka"></textarea>



                      <small class="form-text text-muted">



                        Keterangan Variable :<br>



                        %login% = Link mengarah ke halaman login



                      </small>



                    </div>



                  </form>



                  <div class="btn-group float-right" role="group" aria-label="Basic example">



                    <a href="javascript:void(0)" class="btn btn-info btn-sm" id="test_user_acc_pka"><i class="fas fa-vial"></i> Test</a>



                    <a href="javascript:void(0)" class="btn btn-primary btn-sm" id="update_user_acc_pka"><i class="fas fa-edit"></i>Update Templalte</a>



                  </div>



                </div>



              </div>



            </div>



          </div>



          <!-- //////////////////////////////////////////////////-->



          <div class="card shadow mb-4">



            <div class="card-header py-3 bg-success">



              <h6 class="m-0 font-weight-bold text-light">Revition PKA</h6>



            </div>



            <div class="card-body">



              <div class="row">



                <div class="col-md-12">



                  <form id="form_user_rev_pka">



                    <input type="hidden" id="id_template_email_user_rev_pka" name="id_template_email_user_rev_pka">



                    <div class="form-group">



                      <label>Subject</label>



                      <input type="text" id="sjk_user_rev_pka" class="form-control" name="sjk_user_rev_pka"/>



                    </div>



                    <div class="form-group">



                      <label>Message</label>



                      <textarea id="msg_user_rev_pka" class="form-control" name="msg_user_rev_pka"></textarea>



                      <small class="form-text text-muted">



                        Keterangan Variable :<br>



                        %rev_message% = Pesan kesalahan yang harus direvisi user<br>



                        %login% = Link mengarah ke halaman login



                      </small>



                    </div>



                  </form>



                  <div class="btn-group float-right" role="group" aria-label="Basic example">



                    <a href="javascript:void(0)" class="btn btn-info btn-sm" id="test_user_rev_pka"><i class="fas fa-vial"></i> Test</a>



                    <a href="javascript:void(0)" class="btn btn-primary btn-sm" id="update_user_rev_pka"><i class="fas fa-edit"></i>Update Templalte</a>



                  </div>



                </div>



              </div>



            </div>



          </div>



<script type="text/javascript">



$(document).ready(function(){



    



    var base_url = "<?=base_url()?>";



    var kode_user = "<?=$this->session->userdata("kode_user")?>";



    $('#msg_user_acc_pka').summernote({placeholder: 'Silahkan isi disini',



            tabsize: 2,



            height: 150,



            dialogsInBody: true,



            toolbar: [



                ['style', ['bold', 'italic', 'underline', 'clear']],



                ['font', ['strikethrough', 'superscript', 'subscript']],



                ['fontsize', ['fontsize']],



                ['color', ['color']],



                ['para', ['ul', 'ol', 'paragraph','style']],



                ['height', ['height']]



            ]



    });



    $('#msg_user_rev_pka').summernote({placeholder: 'Silahkan isi disini',



            tabsize: 2,



            height: 150,



            dialogsInBody: true,



            toolbar: [



                ['style', ['bold', 'italic', 'underline', 'clear']],



                ['font', ['strikethrough', 'superscript', 'subscript']],



                ['fontsize', ['fontsize']],



                ['color', ['color']],



                ['para', ['ul', 'ol', 'paragraph','style']],



                ['height', ['height']]



            ]



    });







    template_email = function(){



      $.ajax({ 



              url: base_url + 'template_email/ambil_header_footer',



              type: "post",



              data:{},



              dataType: "json",



              async : 'false',



              success: function(response){



                $('#id_template_email_user_acc_pka').val(response.id_template_email);



                $('#id_template_email_user_rev_pka').val(response.id_template_email);







                $('#sjk_user_acc_pka').val(response.sjk_user_acc_pka);



                $('#msg_user_acc_pka').summernote('code', response.msg_user_acc_pka);



                $('#sjk_user_rev_pka').val(response.sjk_user_rev_pka);



                $('#msg_user_rev_pka').summernote('code', response.msg_user_rev_pka);



              },



              error: function(jqXHR, textStatus, errorThrown) {



                $('#loading').modal('show');



                Command: toastr["error"](errorThrown, "Error");



              },



              beforeSend: function () {



                $('#loading').modal('show');



              },



              complete: function () {



                $('#loading').modal('hide');



              }



      })



    }



    template_email();



    $("#update_user_acc_pka").click(function(){



      var form_data = new FormData($('#form_user_acc_pka')[0]);



      bootbox.confirm("Apakah Anda Yakin Akan Meng-Update Template?", function(result){ 



          if (result==true) {



            



            $.ajax({ 



              url: base_url + 'template_email/update_user_acc_pka',



              type            : "POST",



                dataType        : 'json',



                mimeType        : 'multipart/form-data',



                data            : form_data,



                contentType     : false,



                cache           : false,



                processData     : false,



              success: function(response){



                // alert(JSON.stringify(response))



                if (response == true) {



                  Command: toastr["success"]("Anda Berhasil Meng-Update Template", "success");



                }



              },



              error: function(jqXHR, textStatus, errorThrown) {



                $('#loading').modal('show');



                Command: toastr["error"](errorThrown, "Error");



              },



              beforeSend: function () {



                $('#loading').modal('show');



              },



              complete: function () {



                $('#loading').modal('hide');



              }



            })



          }



      })



    });



    $("#test_user_acc_pka").click(function(){



      var form_data = new FormData($('#form_user_acc_pka')[0]);



      bootbox.confirm("Apakah Anda Yakin Akan Mengetes Template?", function(result){ 



          if (result==true) {



            



            $.ajax({ 



              url: base_url + 'template_email/test_user_acc_pka',



              type            : "POST",



                dataType        : 'json',



                mimeType        : 'multipart/form-data',



                data            : form_data,



                contentType     : false,



                cache           : false,



                processData     : false,



              success: function(response){



                // alert(JSON.stringify(response))



                if (response == true) {



                  Command: toastr["success"]("Anda Berhasil Mengetes Template", "success");



                }else{



                  Command: toastr["warning"]("Anda Gagal Mengetes Template, ", "success");



                }



              },



              error: function(jqXHR, textStatus, errorThrown) {



                $('#loading').modal('show');



                Command: toastr["error"](errorThrown, "Error");



              },



              beforeSend: function () {



                $('#loading').modal('show');



              },



              complete: function () {



                $('#loading').modal('hide');



              }



            })



          }



      })



    });



    $("#update_user_rev_pka").click(function(){



      var form_data = new FormData($('#form_user_rev_pka')[0]);



      bootbox.confirm("Apakah Anda Yakin Akan Meng-Update Template?", function(result){ 



          if (result==true) {



            



            $.ajax({ 



              url: base_url + 'template_email/update_user_rev_pka',



              type            : "POST",



                dataType        : 'json',



                mimeType        : 'multipart/form-data',



                data            : form_data,



                contentType     : false,



                cache           : false,



                processData     : false,



              success: function(response){



                // alert(JSON.stringify(response))



                if (response == true) {



                  Command: toastr["success"]("Anda Berhasil Meng-Update Template", "success");



                }



              },



              error: function(jqXHR, textStatus, errorThrown) {



                $('#loading').modal('show');



                Command: toastr["error"](errorThrown, "Error");



              },



              beforeSend: function () {



                $('#loading').modal('show');



              },



              complete: function () {



                $('#loading').modal('hide');



              }



            })



          }



      })



    });



    $("#test_user_rev_pka").click(function(){



      var form_data = new FormData($('#form_user_rev_pka')[0]);



      bootbox.confirm("Apakah Anda Yakin Akan Mengetes Template?", function(result){ 



          if (result==true) {



            



            $.ajax({ 



              url: base_url + 'template_email/test_user_rev_pka',



              type            : "POST",



                dataType        : 'json',



                mimeType        : 'multipart/form-data',



                data            : form_data,



                contentType     : false,



                cache           : false,



                processData     : false,



              success: function(response){



                // alert(JSON.stringify(response))



                if (response == true) {



                  Command: toastr["success"]("Anda Berhasil Mengetes Template", "success");



                }else{



                  Command: toastr["warning"]("Anda Gagal Mengetes Template, ", "success");



                }



              },



              error: function(jqXHR, textStatus, errorThrown) {



                $('#loading').modal('show');



                Command: toastr["error"](errorThrown, "Error");



              },



              beforeSend: function () {



                $('#loading').modal('show');



              },



              complete: function () {



                $('#loading').modal('hide');



              }



            })



          }



      })



    });



  });



</script>



