<?php
defined("BASEPATH") or exit("No direct access allowed");
if (isset($_POST['ubah'])){
    
    $smtp1a = mysqli_real_escape_string($con,$smtp1a);
    $smtp1b = mysqli_real_escape_string($con,$smtp1b);
    $smtp1c = mysqli_real_escape_string($con,$smtp1c);
    $smtp1d = mysqli_real_escape_string($con,$smtp1d);
            
    //simpan
    mysqli_query($con,"update apismtp set smtp1a='$smtp1a', smtp1b='$smtp1b', smtp1c='$smtp1c', smtp1d='$smtp1d' where id=1");
    echo '
        <script>
            swal("Good Job","Anda sukses menyimpan","success");
        </script>
        		';
        
}

$data=mysqli_fetch_row(mysqli_query($con,"select * from apismtp where id=1"));

?>
    
   <div class="card-header">
          
          <nav aria-label="breadcrumb">
                      <ol class="breadcrumb bg-warning text-white-all">
                        <li class="breadcrumb-item"><a href="#"><i class="fas fa-tachometer-alt"></i> Home</a></li>
                        <li class="breadcrumb-item"><a href="#"><i class="far fa-file"></i> Notif</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><i class="fas fa-list"></i>WA</li>
                      </ol>
                    </nav>
          </div>

            
              <a class="nav-link dropdown-toggle" href="#" id="pagesDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <img src="images/apismtp.png">
                <span>API SMTP</span>
              </a>
              <div class="dropdown-menu" aria-labelledby="pagesDropdown">
                <h6 class="dropdown-header">Sub Menu:</h6>
                <a class="dropdown-item" href="index.php?page=apismtp&set=mailketing"><img src="images/api.png"> Mailketing</a>
              </div>
           
         
            
            <?php
            IF($_GET['set']=='mailketing'){
            ?>
                <div class="card-body">
                       
                       <div class="alert alert-primary alert-has-icon p-4">
                <div class="alert-icon"><i class="far fa-lightbulb"></i></div>
                <div class="alert-body">
                <div class="alert-title">Petunjuk:</div>
                1. Daftar dulu pada layanan Mailketing <a href="https://app.mailketing.co.id/aff?affid=1025" target="_blank"><b>Disini</b></a>.<br>
                2. Input email sender yang terdaftar di layanan mailketing.<br>
                3. Input Api Token. <br>
                4. Cek Tracking di Auto BiznisTop dan juga di Mailketing.<br>
                5. Jika api smtp diaktifkan maka seluruh proses pengiriman email menggunakan api smtp ini.
                </div>
                </div>
                
                 
                    <form action="" method="POST" enctype="multipart/form-data"> 
    
                            <div class="form-group">
                                
                                <?php  
                                    
                                         if($data[1]==0) {
                                              $ktw = 'Tidak Aktif';
                                         }else{
                                              $ktw = 'Aktif';
                                         }     
                                         echo "
                                         <label for='tiga' class='col-sm-2 control-label'>Aktifkan SMTP?</label>
                                         <select name='smtp1a' class='form-control'>
                                         <option value=$data[1]>$ktw</option>
                                         <option value='0'>Tidak Aktif</option>
                                         <option value='1'>Aktif</option>
                                            </select> 
                                         ";
    
                                        ?>
                                        
                                <label for="tiga" class="col-sm-2 control-label">Nama Pengirim/Sender</label>
                                <input type="text" class="form-control" name="smtp1b"  value="<?php echo $data[2]; ?>" required>
                                <label for="tiga" class="col-sm-2 control-label">Email Pengirim/Sender</label>
                                <input type="text" class="form-control" name="smtp1c"  value="<?php echo $data[3]; ?>" required>
                                <label for="tiga" class="col-sm-2 control-label">API Token</label>
                                <input type="text" class="form-control" name="smtp1d"  value="<?php echo $data[4]; ?>" required>
                            </div>
                        
                            <div class="form-group">
                              <div class  ="col-sm-4">
                                <button type="submit" class="btn btn-primary" name="ubah"><span class="glyphicon glyphicon-pencil"></span> Simpan</button>
                              </div>
                            </div>
    
                    </form>
                </div>
            <?php } ?>
            
      
    