<?php

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

//$fieldArray = array('feeID','feeDescID','clientID','feeAmt','feeDesc','feeStartDate','feeRecID','feeLastRec','feeNextRec','projectID','feeActive','display');
//$excludeArray = array('submit','feeActive','display','adminType','activateFee');
$variables = getVariables('rate',$page);

$adminAct = $_REQUEST['adminAct']; 

if ($adminAct == 'new') {
	$op = 'add';
	$editInpID = '<input type="hidden" name="op" value="'. $op .'" />'; 
	foreach($variables['fieldArray'] as $value) { 
		if ($value == 'feeAmt')
			$$value = 0;
		elseif (($value == 'feeActive') || ($value == 'display'))
			$$value = 1; 
		elseif ($value == 'clientID')
			$feeClientID = ''; 
		else 	
			$$value = '';
	}
	$feeNext = ''; 
	$feeLast = ''; 
	$subBtn = 'Add Client Rate'; 
	$modalTitle = 'Create New Client Rate';
	$feeActivated = false;
} else {
	$op = '';
	$editID = $_REQUEST['editID']; 
	$editInpID = '<input type="hidden" name="editID" value="'. $editID .'" />';
	
	$query = 'SELECT * FROM clientRates WHERE dateID=' . $editID; 
	$result = $con->query($query);
		
	while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
		foreach($variables['fieldArray'] as $value) { 
			if ($value == 'clientID') {
				$feeClientID = $row[''. $value .''];
			} else {
			 	$$value = $row[''. $value .''];
			}
		}
		
		if ($adminAct == 'react') {
			$op = 'react';
			$delConfirm = ""; 
			$subBtn = 'Reactivate Rate';
			$modalTitle = 'Reactivate Rate';
		} elseif ($adminAct == 'edit') {
			$op = 'edit';
			$delConfirm = ""; 
			$subBtn = 'Save Changes';
			$modalTitle = 'Edit Rate';
		} elseif ($adminAct == 'deact') {
			$op = 'deact';
			$delConfirm = ' onSubmit="return sure()"';
			$subBtn = 'Deactivate Rate';
			$modalTitle = 'Deactivate Rate?';
		} elseif ($adminAct == 'delete') {
			$op = 'delete';
			$delConfirm = ' onSubmit="return sure()"';
			$subBtn = 'Delete Rate';
			$modalTitle = 'Delete Rate?';
		}
	}
}
$rateClient = getCompany($clientID,$con);

include('form/rate.php'); 
	
?>