<?php
session_start();
error_reporting(1);
ini_set('display_errors', 1);
require_once "config.php";
include_once "../ichat/admin/route.php";
if ($session->is_logged_in() != true ) {
        redirect_to(WEB_LINK.'/login');
} else {
    $current_user = User::get_specific_id($session->admin_id);
    $current_user->set_online();
    $group = $current_user->prvlg_group;
}


require_once("../ichat/admin/assets/includes/Library/SessManager.php");
require_once("../ichat/admin/assets/includes/Library/User.php");
$session = new  SessManager();

//require_once "check_admin.php";
require_once 'database.php';
class emails extends database
{
   public function index($data)
    {
        return $this->update('email', $data);
    }
    
    public function getEmail()
    {
        return $this->fetchRow('email');
    }
}
$cat = new emails();
$msg="";
if(isset($_GET['message']))
{
    $msg=$_GET['message'];
}
if(isset($_POST['data']))
{
    $data=$_POST['data'];
    if(trim($data['email']) == '')
    {
        $msg.= "Email is required<br/>";
    }
    
    if($msg=="")
    {
         $res = $cat->index($data);
            if($res)
            {
                    header('Location:emails.php?message=Emails Updated Successfully');
            }
            else {
                $msg = 'Something Went Wrong';
            }
    }
}

$email = $cat->getEmail();

include 'header.php';
?>
            <!-- MAIN CONTENT-->
            <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="overview-wrap">
                                    <h2 class="title-1">Update Email</h2>
                                    
                                </div>
								<?php if($msg !=''){echo '<span class="col-md-6 alert alert-danger pull-left">'.$msg.'</span>';}?>
                            </div>
                        </div>
                        
                        <div class="row m-t-25 m-row">
					
                            <div class="col-lg-10">
                                <div class="card">
                                   
                                    <div class="card-body card-block">
									 <form method="post">
                                        <div class="col-md-12">
                                            <label>Emails</label>
                                            <input type="text" class="form-control" name="data[email]" value="<?php echo $email['email'] ?>" />
                                        </div>
                                       
                                        <div class="col-md-12 botm-cont">
                                            <button type="submit" class="track-btn pull-right">UPDATE EMAIL</button>
                                        </div>
                                    </form>
                                    </div>
                                </div>
                            </div>
                          
                        </div>
                       <script>
							$(document).ready(function(){
								$('.active').removeClass('active');
								$('#email-menu').addClass('active');
							}); 
						</script>              
                        
                       

  <?php
  include 'footer.php';
  ?>