Advertisement
dhiforester

ProsesTambahPengaturanVclaim

Dec 18th, 2023
776
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.22 KB | Source Code | 0 0
  1. <?php
  2.     //Koneksi
  3.     include "../../_Config/Connection.php";
  4.     include "../../_Config/Session.php";
  5.     include "../../_Config/Function.php";
  6.     date_default_timezone_set('Asia/Jakarta');
  7.     $tanggal_daftar=date('Y-m-d H:i:s');
  8.     //Validasi url_api tidak boleh kosong
  9.     if(empty($_POST['url_api'])){
  10.         echo '<small><code class="text-danger">URL tidak boleh kosong!</code></small>';
  11.     }else{
  12.         //Validasi cons_id tidak boleh kosong
  13.         if(empty($_POST['cons_id'])){
  14.             echo '<small><code class="text-danger">Cons ID tidak boleh kosong!</code></small>';
  15.         }else{
  16.             //Validasi user_key tidak boleh kosong
  17.             if(empty($_POST['user_key'])){
  18.                 echo '<small><code class="text-danger">User Key tidak boleh kosong!</code></small>';
  19.             }else{
  20.                 //Validasi secret_key tidak boleh kosong
  21.                 if(empty($_POST['secret_key'])){
  22.                     echo '<small><code class="text-danger">Secret Key tidak boleh kosong!</code></small>';
  23.                 }else{
  24.                     //Validasi kode_ppk tidak boleh kosong
  25.                     if(empty($_POST['kode_ppk'])){
  26.                         echo '<small><code class="text-danger">Kode PPK tidak boleh kosong!</code></small>';
  27.                     }else{
  28.                         //Validasi status tidak boleh kosong
  29.                         if(empty($_POST['status'])){
  30.                             echo '<small><code class="text-danger">Status tidak boleh kosong!</code></small>';
  31.                         }else{
  32.                             //Validasi profile_pengaturan tidak boleh kosong
  33.                             if(empty($_POST['profile_pengaturan'])){
  34.                                 echo '<small><code class="text-danger">Nama Profile tidak boleh kosong!</code></small>';
  35.                             }else{
  36.                                 //Variabel Lainnya
  37.                                 $kategori_pengaturan="Bridging Vclaim";
  38.                                 $url_api=$_POST['url_api'];
  39.                                 $cons_id=$_POST['cons_id'];
  40.                                 $user_key=$_POST['user_key'];
  41.                                 $secret_key=$_POST['secret_key'];
  42.                                 $kode_ppk=$_POST['kode_ppk'];
  43.                                 $status=$_POST['status'];
  44.                                 $profile_pengaturan=$_POST['profile_pengaturan'];
  45.                                 $ValidasiNamaProfile=getDataDetail($Conn,'pengaturan','profile_pengaturan',$profile_pengaturan,'profile_pengaturan');
  46.                                 //Validasi Nama Profile Duplikat
  47.                                 if(!empty($ValidasiNamaProfile)){
  48.                                     echo '<small><code class="text-danger">Nama Profile yang anda input sudah terdaftar!</code></small>';
  49.                                 }else{
  50.                                     if($status=="Active"){
  51.                                         //Apabila Status Active maka De Activasi Yang Lain
  52.                                         $UpdateStatus = mysqli_query($Conn,"UPDATE pengaturan SET
  53.                                            status='Non Active'
  54.                                        WHERE kategori_pengaturan='$kategori_pengaturan'") or die(mysqli_error($Conn));
  55.                                     }
  56.                                     //Membuat file json
  57.                                     $pengaturan = Array (
  58.                                         "url_api" => "$url_api",
  59.                                         "cons_id" => "$cons_id",
  60.                                         "user_key" => "$user_key",
  61.                                         "secret_key" => "$secret_key",
  62.                                         "kode_ppk" => "$kode_ppk"
  63.                                     );
  64.                                     $pengaturan = json_encode($pengaturan, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
  65.                                     //Simpan Data
  66.                                     $entry="INSERT INTO pengaturan (
  67.                                        profile_pengaturan,
  68.                                        kategori_pengaturan,
  69.                                        pengaturan,
  70.                                        status
  71.                                    ) VALUES (
  72.                                        '$profile_pengaturan',
  73.                                        '$kategori_pengaturan',
  74.                                        '$pengaturan',
  75.                                        '$status'
  76.                                    )";
  77.                                     $Input=mysqli_query($Conn, $entry);
  78.                                     if($Input){
  79.                                         echo '<small class="text-success" id="NotifikasiTambahPengaturanVclaimBerhasil">Success</small>';
  80.                                     }else{
  81.                                         echo '<small class="text-danger">Terjadi kesalahan pada saat menyimpan data</small>';
  82.                                     }
  83.                                 }
  84.                             }
  85.                         }
  86.                     }
  87.                 }
  88.             }
  89.         }
  90.     }
  91. ?>
Tags: simrs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement