<?php 

// create user enrollment id;

events::addListener('admin.user-new-form:col', function() { ?>
	<input type='hidden' name='meta[user:enrid]' value='<?php echo mt_rand(); ?>'>
<?php });

events::addListener( 'admin.user-edit-form:col-left', function($user) { 
	
	$bio = uss::$global['usermeta']->get('user:bio', $user['id']) ?? [];
	
	$request = array(
		'firstname' => ['first name', 'input'],
		'lastname' => ['last name', 'input'],
		'dob' => ['date of birth', 'date'],
		'gender' => ['gender', 'select', ['male', 'female']],
		'phone' => ['phone number', 'number']
	);
	
	echo "<h4 class='fs-18 fw-200 mb-4'>
		<i class='bi bi-info-circle'></i> Student Info
	</h4>";
	
	foreach( $request as $key => $data ):
?>
	
	<div class='row mb-3'>
		<label class='form-label col-sm-3 text-capitalize'><?php echo $data[0]; ?>:</label>
		<div class='col-sm-9'>
		
			<?php if( $data[1] == 'select' ): ?>
			
				<select name='meta[user:bio][<?php echo $key; ?>]' class='form-control form-select text-capitalize' value='<?php echo $bio[$key] ?? null; ?>'>
					<?php foreach( $data[2] as $value ): ?>
					<option value='<?php echo $value; ?>'>
						<?php echo $value; ?>
					</option>
					<?php endforeach; ?>
				</select>
				
			<?php else: ?>
			
				<input type='<?php echo $data[1]; ?>' class='form-control' name='meta[user:bio][<?php echo $key; ?>]' value='<?php echo $bio[$key] ?? null; ?>'>
				
			<?php endif; ?>
			
		</div>
	</div>
									
<?php 

	endforeach;
	
	echo "<hr/>";

}); 