{include file="header.tpl" enable_calendar=true enable_ajax=TRUE body_onload="showPercent(); calcAmount();"}

<script	language=JavaScript>

{literal}
function showPercent() {
	if ( document.getElementById('type_id').value == 20 ) {
		document.getElementById('type_id-10').style.display = 'none';

		document.getElementById('type_id-20').className = '';
		document.getElementById('type_id-20').style.display = '';
	} else {
		document.getElementById('type_id-20').style.display = 'none';

		document.getElementById('type_id-10').className = '';
		document.getElementById('type_id-10').style.display = '';
	}
}

function calcAmount() {
	//Round rate and units to 2 decimals
	rate = MoneyFormat( document.getElementById('rate').value );
	units = MoneyFormat( document.getElementById('units').value );

	if ( ( document.getElementById('rate').value != '' && rate > 0 )
			|| ( document.getElementById('units').value != '' && units > 0 ) ) {
		document.getElementById('amount').disabled = true;

		amount = rate * units;
		document.getElementById('amount').value = amount.toFixed(2);
	} else {
		document.getElementById('amount').disabled = false;
	}
}

function MoneyFormat( val ) {
	if ( val != '' ) {
		return parseFloat( val ).toFixed(2);
	}

	return '';
}

var hwCallback = {
		getUserHourlyRate: function(result) {
			document.getElementById('rate').value = result;
			calcAmount();
		}
	}

var remoteHW = new AJAX_Server(hwCallback);

function getHourlyRate() {
	remoteHW.getUserHourlyRate( document.getElementById('user_id').value, document.getElementById('effective_date').value);
}
{/literal}
</script>

<div id="rowContent">
  <div id="titleTab"><div class="textTitle"><span class="textTitleSub">{$title}</span></div>
</div>
<div id="rowContentInner">

		<form method="post" action="{$smarty.server.SCRIPT_NAME}">
		    <div id="contentBoxTwoEdit">

				{if !$psaf->Validator->isValid()}
					{include file="form_errors.tpl" object="psaf"}
				{/if}

				<table class="editTable">

				<tr>
					<td class="{isvalid object="psaf" label="user" value="cellLeftEditTable"}">
						{t}Employee:{/t}
					</td>
					<td class="cellRightEditTable">
						<select id="user_id" name="pay_stub_amendment_data[user_id]">
							{html_options options=$pay_stub_amendment_data.user_options selected=$pay_stub_amendment_data.user_id}
						</select>
					</td>
				</tr>

				<tr onClick="showHelpEntry('status')">
					<td class="{isvalid object="psaf" label="status" value="cellLeftEditTable"}">
						{t}Status:{/t}
					</td>
					<td class="cellRightEditTable">
						<select name="pay_stub_amendment_data[status_id]">
							{html_options options=$pay_stub_amendment_data.status_options selected=$pay_stub_amendment_data.status_id}
						</select>
					</td>
				</tr>

				<tr onClick="showHelpEntry('pay_stub_entry_name_id')">
					<td class="{isvalid object="psaf" label="pay_stub_entry_name_id" value="cellLeftEditTable"}">
						{t}Pay Stub Account:{/t}
					</td>
					<td class="cellRightEditTable">
						<select name="pay_stub_amendment_data[pay_stub_entry_name_id]">
							{html_options options=$pay_stub_amendment_data.pay_stub_entry_name_options selected=$pay_stub_amendment_data.pay_stub_entry_name_id}
						</select>
					</td>
				</tr>

				<tr class="tblHeader">
					<td colspan="2">
						{t}Amount{/t}
					</td>
				</tr>

				<tr onClick="showHelpEntry('type')" onChange="showPercent()">
					<td class="{isvalid object="psaf" label="type_id" value="cellLeftEditTable"}">
						{t}Amount Type:{/t}
					</td>
					<td class="cellRightEditTable">
						<select name="pay_stub_amendment_data[type_id]" id="type_id">
							{html_options options=$pay_stub_amendment_data.type_options selected=$pay_stub_amendment_data.type_id}
						</select>
					</td>
				</tr>

				<tbody id="type_id-10" >

				<tr onClick="showHelpEntry('rate')">
					<td class="{isvalid object="psaf" label="rate" value="cellLeftEditTable"}">
						{t}Rate:{/t}
					</td>
					<td class="cellRightEditTable">
						<input type="text" size="10" name="pay_stub_amendment_data[rate]" id="rate" value="{$pay_stub_amendment_data.rate}" onKeyUp="calcAmount()" onChange="document.getElementById('rate').value = MoneyFormat( document.getElementById('rate').value );">
						<input type="button" name="getUserHourlyRate" value="{t}Get Employee Rate{/t}" onclick="getHourlyRate(); return false;"/>
					</td>
				</tr>

				<tr onClick="showHelpEntry('units')">
					<td class="{isvalid object="psaf" label="units" value="cellLeftEditTable"}">
						{t}Units:{/t}
					</td>
					<td class="cellRightEditTable">
						<input type="text" size="10" name="pay_stub_amendment_data[units]" id="units" value="{$pay_stub_amendment_data.units}" onKeyUp="calcAmount()" onChange="document.getElementById('units').value = MoneyFormat( document.getElementById('units').value );">
					</td>
				</tr>

				<tr onClick="showHelpEntry('amount')">
					<td class="{isvalid object="psaf" label="amount" value="cellLeftEditTable"}">
						{t}Amount:{/t}
					</td>
					<td class="cellRightEditTable">
						<input type="text" size="10" name="pay_stub_amendment_data[amount]" id="amount" value="{$pay_stub_amendment_data.amount}">
					</td>
				</tr>
				</tbody>

				<tbody id="type_id-20" style="display:none" >
				<tr onClick="showHelpEntry('percent_amount')">
					<td class="{isvalid object="psaf" label="percent_amount" value="cellLeftEditTable"}">
						{t}Percent:{/t}
					</td>
					<td class="cellRightEditTable">
						<input type="text" size="10" name="pay_stub_amendment_data[percent_amount]" value="{$pay_stub_amendment_data.percent_amount}">%
					</td>
				</tr>

				<tr onClick="showHelpEntry('percent_amount_entry_name')">
					<td class="{isvalid object="psaf" label="percent_amount_entry_name" value="cellLeftEditTable"}">
						{t}Percent Of:{/t}
					</td>
					<td class="cellRightEditTable">
						<select name="pay_stub_amendment_data[percent_amount_entry_name_id]">
							{html_options options=$pay_stub_amendment_data.percent_amount_entry_name_options selected=$pay_stub_amendment_data.percent_amount_entry_name_id}
						</select>
					</td>
				</tr>

				</tbody>

				<tr class="tblHeader">
					<td colspan="2">
						{t}Options{/t}
					</td>
				</tr>

				<tr onClick="showHelpEntry('description')">
					<td class="{isvalid object="psaf" label="description" value="cellLeftEditTable"}">
						{t}Description:{/t}
					</td>
					<td class="cellRightEditTable">
						<input type="text" size="50" name="pay_stub_amendment_data[description]" value="{$pay_stub_amendment_data.description|escape}">
					</td>
				</tr>

				<tr onClick="showHelpEntry('effective_date')">
					<td class="{isvalid object="psaf" label="effective_date" value="cellLeftEditTable"}">
						{t}Effective Date:{/t}
					</td>
					<td class="cellRightEditTable">
						<input type="text" size="15" id="effective_date" name="pay_stub_amendment_data[effective_date]" value="{getdate type="DATE" epoch=$pay_stub_amendment_data.effective_date}">
						<img src="{$BASE_URL}/images/cal.gif" id="cal_effective_date" width="16" height="16" border="0" alt="Pick a date" onMouseOver="calendar_setup('effective_date', 'cal_effective_date', false);">
					</td>
				</tr>
				
				<tr onClick="showHelpEntry('ytd_adjustment')">
					<td class="{isvalid object="psaf" label="ytd_adjustment" value="cellLeftEditTable"}">
						{t}Year to Date (YTD) Adjustment:{/t}
					</td>
					<td class="cellRightEditTable">
						<input type="checkbox" class="checkbox" name="pay_stub_amendment_data[ytd_adjustment]" value="1"{if $pay_stub_amendment_data.ytd_adjustment == TRUE}checked{/if}>
					</td>
				</tr>

			</table>
		</div>

		<div id="contentBoxFour">
			<input type="submit" class="button" name="action:submit" value="{t}Submit{/t}" {if $pay_stub_amendment_data.status_id == 55}disabled="true"{/if}>
			{*
			{if !isset($pay_stub_amendment_data.id)}
			<input type="submit" class="button" name="action:Release Vacation" value="{t}Release Vacation{/t}">
			{/if}
			*}
		</div>

		<input type="hidden" name="pay_stub_amendment_data[id]" value="{$pay_stub_amendment_data.id}">
		{* <input type="hidden" name="user_id" value="{$user_data->getId()}"> *}
		</form>
	</div>
</div>
{include file="footer.tpl"}
