<?php
require_once("../layouts/members/head.php");
?>

<?php if(in_array($user_data['usertype'], ['Admin'])){ ?>

<?php
if(isset($_POST['popupupdate']) && $user_data['user_id']>0){
$popupalert = $_POST['popupalert'];
$popup_active = $_POST['popup_active'];
if(!empty($popupalert) && !empty($popup_active)){

$insData = array();
$insData['popupalert'] = $popupalert;
$insData['popup_active'] = $popup_active;
if(db_update("sitedata", $insData, " user_id='".$user_data['user_id']."' ")){
awal_alert_msg("Popup Updated Successfully!",'success','');  
}else{
awal_alert_msg("No Any Changes!",'info');  
}

}else{
awal_alert_msg("Please Fill All Valid Details!",'error');
}

}
?>

<div class="row">
  <div class="col-md-12 mb-2">
    <div class="card text-danger">
      <div class="card-header bg-primary text-white py-2">
        <div class="d-flex align-items-center">
          <span class="mr-auto"><?=file_name()?></span>
        </div>
      </div>
      <div class="p-3">
      <form class="row text-dark" method="POST" action="">
        <div class="col-md-12 mb-3">
          <textarea class="form-control" placeholder="Enter Content" id="popupalert" name="popupalert" required><?=$site_data['popupalert']?></textarea>
        </div>
        <div class="col-md-2 mb-3">
              <select name="popup_active" class="form-control">
                <option <?=$site_data['popup_active']=="ON" ? 'selected':''?> value="ON">ON</option>
                <option <?=$site_data['popup_active']=="OFF" ? 'selected':''?> value="OFF">OFF</option>
              </select>
        </div>

        <div class="col-md-4 mb-3">
          <button type="submit" class="btn btn-primary btn-block" name="popupupdate">Submit</button>
        </div>
      </form>
     </div>
    </div>
  </div>
</div>
<?php 
}else{
require_once("404.php");
} 
?>

<?php
require_once("../layouts/members/foot.php");
summernote('#popupalert');
?>