<?php
    session_start();
    include 'function/classes.php';
        if(!isset($_SESSION['SESS_MEMBER_ID']) ||
                  (trim($_SESSION['SESS_MEMBER_ID'])==""))
                      {
                          echo "You will need admin rights to view this page";
                          exit();
                      }
       else{
            if (isset($_POST['btnsave'])){
                if($_POST['is_adm']=='on'||$_POST['is_adm']==1){ $is_adm=1; }else {$is_adm=0;};
                if($_POST['is_act']=='on'||$_POST['is_act']==1){ $is_act=1; }else {$is_act=0;};
                saveData('tb_admin', "admin_name='". $_POST['emp_name'] ."', is_admin='". $is_adm ."', is_active='". $is_act ."'", "admin_id='". $_GET['id'] ."'",'update');
                $saveMsg=TRUE;
            }
            $employeelist=getData('* ','tb_admin',"admin_id='" . $_GET['id'] . "'");
       }

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Mobivation</title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <link href="css/default.css" rel="stylesheet" type="text/css" />
    </head>


    <body>
        <div id="wrapper">
        <?php include 'include/header.php'; ?>
            <!-- end div#header -->
            <div id="page">
                <div id="content">
                    <div id="welcome">
                        <h1>Edit Admin Data</h1>
                        <!--body-->
                        <form name="frmlogin" method="post" action="<?=$_SERVER['PHP_SELF']?>?id=<?=$employeelist['admin_id']?>">
                        <table>
                            <?php if ($saveMsg)
                                {
                                    echo "<tr><td colspan='2'></td> <th>Data has been updated<th/></tr>";
                                }
                            ?>
                            <tr>
                                <th>Admin ID </th>
                                <th> : </th>
                                <td> <?php echo $employeelist['admin_id']; ?></td>
                            </tr>
                            <tr>
                                <th>Username </th>
                                <th> : </th>
                                <td> <?php echo $employeelist['username']; ?></td>
                            </tr>
                            <tr>
                                <th>Admin Name </th>
                                <th> : </th>
                                <td><input type="text" name="emp_name" id="emp_name" value="<?=$employeelist['admin_name']?>"> </input></td>
                            </tr>
                            <tr>
                                <th>Admin Flag</th>
                                <th> : </th>
                                <td><input type="checkbox" name="is_adm" 
                                           <?php if ($employeelist['is_admin']=="1") {
                                               echo "value='".$employeelist['is_admin']."'";
                                               echo "checked"; }?> /></td>
                            </tr>
                            <tr>
                                <th>Active </th>
                                <th> : </th>
                                <td><input type="checkbox" name="is_act"
                                           <?php if ($employeelist['is_active']=="1") {
                                               echo "value='".$employeelist['is_active']."'";
                                               echo "checked"; }?>/></td>
                            </tr>
                            <tr>
                                <th></th>
                                <th></th>
                                <td><input type="submit" name="btnsave" value="Save"/></td>
                            </tr>
                        </table>
                        </form>
                        <!--body ends-->
                    </div>

                    <!-- end div#welcome -->

                </div>
                <!-- end div#content -->
                <div id="sidebar">
                    <ul>
                    <?php include 'include/nav.php'; ?>
                        <!-- end navigation -->
                        <?php //include 'include/updates.php'; ?>
                        <!-- end updates -->
                    </ul>
                </div>
                <!-- end div#sidebar -->
                <div style="clear: both; height: 1px"></div>
            </div>
            <?php include 'include/footer.php'; ?>
        </div>
        <!-- end div#wrapper -->
    </body>
</html>


