<?php

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

$adminAct = $_REQUEST['adminAct']; 
$variables = getVariables('client',$page);

$admin = 'client'; 
if ($adminAct == 'new') {
	$editInpID = ''; 
	$op = 'add';
		
	foreach ($variables['fieldArray'] as $value) {
		if ($value == 'clientSince')
			$$value = $today;
		elseif ($value == 'clientStatus')
			$$value = 2;
		else
			$$value = ''; 
	}
	$clientLastUpdate = $today;
	$loginfoText = 'Add Login Information'; 
	$subBtn = 'Add Client'; 
	$modalTitle = 'Create New Client';
} else {
	$op = '';
	$editID = $_REQUEST['editID']; 
	$editInpID = '<input type="hidden" name="editID" value="'. $editID .'" />';
		
	$query = "SELECT * FROM clients WHERE clientID=" . $editID; 
	$result = $con->query($query);
		
	while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
		$editInpID = '<input type="hidden" name="editID" value="'. $editID .'" />';
		$op = 'edit';
		
		foreach($variables['fieldArray'] as $value) {
			$$value =  $row[''. $value .''];
		}

		$clientLastUpdate = $today;
		$loginfoText = 'Update Login Information';
		if ($adminAct == 'react') {
			$op = 'react';
			$delConfirm = "";
			$subBtn = 'Reactivate Client';
			$modalTitle = 'Reactivate Client: '. $clientName;
		} elseif ($adminAct == 'edit') {
			$op = 'edit';
			$delConfirm = ""; 
			$subBtn = 'Save Changes';
			$modalTitle = 'Edit Client: '. $clientName;
		} elseif ($adminAct == 'delete') {
			$op = 'delete';
			$delConfirm = ' onSubmit="return sure()"';
			$subBtn = 'Deactivate Client';
			$modalTitle = 'Delete Client: '. $clientName . '?';
		}
	}
}
$clientSubCompany = getCompany($subClientOf,$con);
$clientTypeSelect = getCtypeSelect($clientType,$con);
$clientSupportSelect = getSupportSelect($clientSupport,$con);
include('form/client.php'); 

?>