<?php
include("access.php");
include("include/admin.class.php");
include("include/conf.class.php");
$userinfo=$cartCore->get_user_info($CARTUSERNAME);
$cartAdminMain->check_grant($userinfo['USER_ID'],$page_name);
$cartCore->get_headder();
$cartCore->view_welcome($userinfo['USERNAME'],$userinfo['IMAGE']);
$cartCore->view_sidebar($userinfo['USER_ID'],$TOKEN_ID);
$cartCore->view_credit($COMPANY_ID,$bk);
if(isset($_POST['username'])){
	$delete_user=NULL;
	$cartAdminMain->add_edit_delete_user($userinfo['USERNAME'],$page_name,$TOKEN_ID,$delete_user);	
	exit;
}
?>
        <!-- top navigation -->
        <div class="top_nav">
          <div class="nav_menu">
            <nav>
              <div class="nav toggle">
                <a id="menu_toggle"><i class="fa fa-bars"></i></a>
              </div>

              <ul class="nav navbar-nav navbar-right">
              
              
              <?=$cartCore->view_userprofile($userinfo['USER_ID'],$userinfo['USERNAME'],$userinfo['IMAGE'],$TOKEN_ID,$COMPANY_ID,$bk)?>

                <li role="presentation" class="dropdown">
                  <a href="javascript:;" class="dropdown-toggle info-number" data-toggle="dropdown" aria-expanded="false">
                    <i class="fa fa-envelope-o"></i>
                    <span class="badge bg-green"><?=$cartAdminMain->getMessageCount($userinfo['USERNAME'])?></span>
                  </a>
                  <ul id="menu1" class="dropdown-menu list-unstyled msg_list" role="menu">
                  <?=$cartAdminMain->getUserMessage($userinfo['USERNAME'])?>
                    <li>
                      <div class="text-center">
                        <a href="message.php?token_id=<?=$TOKEN_ID?>&pid=<?=$cartCore->md5_base64_encode($userinfo['USERNAME'])?>">
                          <strong>See All Alerts</strong>
                          <i class="fa fa-angle-right"></i>
                        </a>
                      </div>
                    </li>
                  </ul>
                </li>
              </ul>
            </nav>
          </div>
        </div>
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
              <div class="title_left">
                <h3>
				<?php
                if(isset($_GET['pagename']) && $_GET['pagename'] != "")
				{
					echo $cartCore->md5_base64_decode($_GET['pagename']);
				}
				else
				{
					echo $cartCore->getPageHeading($page_name);
				}
				?>
			</h3>
              </div>
            </div>
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2><?=$cartCore->getMainPageHeading($page_name)?> 
                    <small><?php
                if(isset($_GET['pagename']) && $_GET['pagename'] != "")
				{
					$pagename=$cartCore->md5_base64_decode($_GET['pagename']);
					echo $pagename;
				}
				else
				{
					$pagename=$cartCore->getPageHeading($page_name);
					$pagename;
				}
				?></small></h2>
                
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li> 
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">

<?php
	if(isset($_GET['passid']) && $_GET['passid'] != "")
		{		
				$encryptid=$_GET['passid'];
				$rid=$cartCore->md5_base64_decode($encryptid);
				$rid = $cartCore->ClearInput($rid);
				$get_user_info=$cartCore->get_user_info($rid);
				$submit_key=true;		
		}
		else
		{		
				$encryptid=NULL;
				$rid=NULL;
				$get_user_info = NULL;
				$submit_key=false;
		}


		if(isset($_GET['success_msg']) && $_GET['success_msg']!="")
		{	
			echo $cartCore->display_sucess_msg($cartCore->md5_base64_decode($_GET['success_msg']));		  
		}
		if(isset($_GET['warning_msg']) && $_GET['warning_msg']!="")
		{	
			echo $cartCore->display_warning_msg($cartCore->md5_base64_decode($_GET['warning_msg']));		  
		}
		
?>


                    <form class="form-horizontal form-label-left" novalidate action="add_user.php?token_id=<?=$TOKEN_ID?>" method="post">
                     <input type="hidden" name="submit_key" value="<?=$submit_key?>" />
                     <input type="hidden" name="passid" value="<?=$encryptid?>" />
                     <input type="hidden" name="pagename" value="<?=$pagename?>" />
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Name <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="name" placeholder="both name(s)" required type="text" value="<?=$get_user_info['FULL_NAME']?>">
                        </div>
                      </div>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Email <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="email" id="email" name="email" required class="form-control col-md-7 col-xs-12" value="<?=$get_user_info['E_MAIL']?>">
                        </div>
                      </div>
   
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="occupation">Username <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        <?php if($rid==NULL){ ?> <input id="occupation" type="text" name="username" data-validate-length-range="5,20" class="form-control col-md-7 col-xs-12" required><?php } else {?> <input id="occupation" type="text" data-validate-length-range="5,20" class="form-control col-md-7 col-xs-12" value="<?=$get_user_info['USERNAME']?>" readonly> <input type="hidden" name="username" value="<?=$get_user_info['USERNAME']?>" /><?php } ?>
                         
                        </div>
                      </div>
                      <?php if($rid==NULL){ ?>
                      <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Password</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="password" type="password" name="password" class="form-control col-md-7 col-xs-12" required> 
                        </div>
                      </div> 
                      <div class="item form-group">
                        <label for="password2" class="control-label col-md-3 col-sm-3 col-xs-12">Repeat Password</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="password2" type="password" data-validate-linked="password" class="form-control col-md-7 col-xs-12" required>
                        </div>
                      </div>
                      <?php } ?>
                       <div class="item form-group">
                        <label class="control-label col-md-3">Status</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select class="form-control col-md-7 col-xs-12" name="status">
                            <?php if($rid==NULL){ ?> <option value="1">Enable</option><option value="0">Disable</option> <?php } else {?> <?=$cartAdminMain->findstatusforselectoption($get_user_info['USERNAME']);?><optgroup></optgroup> <option value="1">Enable</option><option value="0">Disable</option><?php } ?>
                          </select>
                        </div>
                      </div>
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          <button id="send" type="submit" class="btn btn-success">Submit</button>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

        <!-- footer content --><?=$cartCore->get_footer();?>
        <!-- /footer content -->
      </div>
    </div>

    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
    <!-- validator -->
    <script src="../vendors/validator/validator.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
  </body>
</html>