<?php

$admin = 'user'; 

include ($PATH .'globals/globals.php');

$adminAct = $_REQUEST['adminAct'];

$fieldArray = array('userID','clientID','userAuth','userName','userPassword','userPass','userSalt','userFirstName','userLastName','userEmail','userStatus','userActiveDate','userExpireDate','userLastLogin');
$excludeArray = array('submit','adminType');

if ($adminAct == 'new') {
	$editInpID = ''; 
	$op = 'add';
	foreach($fieldArray as $value) { 
		if ($value == 'userID')
			$editID = ''; 
		else 	
			$$value = '';
	}
	$userActiveDate = $today;
	$userStatus = 1;
	$subBtn = 'Add User'; 
	$modalTitle = 'Create New User';
} else {
	$op = '';
	$editID = $_REQUEST['editID']; 
	$editInpID = '<input type="hidden" name="editID" value="'. $editID .'" />';
	
	$query = 'SELECT * FROM users WHERE userID=' . $editID; 
	$result = $con->query($query);
		
	while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
		foreach($fieldArray as $value) { 
			if ($value == 'userID') {
				// do nothing
			} else 	
				$$value = $row[$value];
		}
		if ($adminAct == 'react') {
			$op = 'react';
			$delConfirm = ""; 
			$subBtn = 'Reactivate User';
			$modalTitle = 'Reactivate User: '. $userFirstName . ' ' . $userLastName;
		} elseif ($adminAct == 'edit') {
			$op = 'edit';
			$delConfirm = ""; 
			$subBtn = 'Save Changes';
			$modalTitle = 'Edit User: '. $userFirstName . ' ' . $userLastName;
		} elseif ($adminAct == 'delete') {
			$op = 'delete';
			$delConfirm = ' onSubmit="return sure()"';
			$subBtn = 'Deactivate User';
			$modalTitle = 'Delete User: '. $userFirstName . ' ' . $userLastName  .'?';
		}
	}
}
$userCompany = getCompany($clientID,$con);
$userAuthLevel = getAuth($userAuth,$con);

include('form/user.php');

?>