Advertisement
dhiforester

ProsesEditPengaturanVclaim.php

Dec 18th, 2023
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.94 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.                                 //Validasi id_pengaturan tidak boleh kosong
  37.                                 if(empty($_POST['id_pengaturan'])){
  38.                                     echo '<small><code class="text-danger">ID Profile tidak boleh kosong!</code></small>';
  39.                                 }else{
  40.                                     //Variabel Lainnya
  41.                                     $kategori_pengaturan="Bridging Vclaim";
  42.                                     $id_pengaturan=$_POST['id_pengaturan'];
  43.                                     $url_api=$_POST['url_api'];
  44.                                     $cons_id=$_POST['cons_id'];
  45.                                     $user_key=$_POST['user_key'];
  46.                                     $secret_key=$_POST['secret_key'];
  47.                                     $kode_ppk=$_POST['kode_ppk'];
  48.                                     $status=$_POST['status'];
  49.                                     $profile_pengaturan=$_POST['profile_pengaturan'];
  50.                                     $NamaProfileLama=getDataDetail($Conn,'pengaturan','profile_pengaturan',$profile_pengaturan,'profile_pengaturan');
  51.                                     if($profile_pengaturan==$NamaProfileLama){
  52.                                         $ValidasiNamaProfile="";
  53.                                     }else{
  54.                                         $ValidasiNamaProfile=getDataDetail($Conn,'pengaturan','profile_pengaturan',$profile_pengaturan,'profile_pengaturan');
  55.                                     }
  56.                                     //Validasi Nama Profile Duplikat
  57.                                     if(!empty($ValidasiNamaProfile)){
  58.                                         echo '<small><code class="text-danger">Nama Profile yang anda input sudah terdaftar!</code></small>';
  59.                                     }else{
  60.                                         if($status=="Active"){
  61.                                             //Apabila Status Active maka De Activasi Yang Lain
  62.                                             $UpdateStatus = mysqli_query($Conn,"UPDATE pengaturan SET
  63.                                                status='Non Active'
  64.                                            WHERE kategori_pengaturan='$kategori_pengaturan' AND id_pengaturan='$id_pengaturan'") or die(mysqli_error($Conn));
  65.                                         }
  66.                                         //Membuat file json
  67.                                         $pengaturan = Array (
  68.                                             "url_api" => "$url_api",
  69.                                             "cons_id" => "$cons_id",
  70.                                             "user_key" => "$user_key",
  71.                                             "secret_key" => "$secret_key",
  72.                                             "kode_ppk" => "$kode_ppk"
  73.                                         );
  74.                                         $pengaturan = json_encode($pengaturan, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
  75.                                         //Simpan Data
  76.                                         $UpdatePengaturan = mysqli_query($Conn,"UPDATE pengaturan SET
  77.                                            profile_pengaturan='$profile_pengaturan',
  78.                                            pengaturan='$pengaturan',
  79.                                            status='$status'
  80.                                        WHERE id_pengaturan='$id_pengaturan'") or die(mysqli_error($Conn));
  81.                                         if($UpdatePengaturan){
  82.                                             echo '<small class="text-success" id="NotifikasiEditPengaturanVclaimBerhasil">Success</small>';
  83.                                         }else{
  84.                                             echo '<small class="text-danger">Terjadi kesalahan pada saat menyimpan data</small>';
  85.                                         }
  86.                                     }
  87.                                 }
  88.                             }
  89.                         }
  90.                     }
  91.                 }
  92.             }
  93.         }
  94.     }
  95. ?>
Tags: simrs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement