<?php
function addSourceFundUser($txtfundcode, $connection){
	$bleft = "border-left:1px solid gray";
	$bright = "border-right:1px solid gray";
	$btop = "border-top:1px solid gray";
	$bbottom = "border-bottom:1px solid gray";
	//header
	echo "<table width='350px' cellspacing=0 cellpadding=0>
		<col width='20px'><col width='20px'><col width='150px'><col width='160px'>";
	echo "<tr bgcolor='#D0D0D0' height='20px'>
			<td style='$bbottom;$bleft;$btop;'></td><td style='$bbottom;$btop;'></td>
			<td align='center' style='$bbottom;$btop;'><span class='style1'>Code</span></td>
			<td align='center' style='$bbottom;$bright;$btop;'><span class='style1'>Username</span></td>
		  </tr>";
	echo "</table>";
	
	//detail
	echo "<div style='width:365px;height:150px;overflow-y:scroll;overflow-x:hidden;'>";
	$i=0;
	echo "<table width='350px' cellspacing=0 cellpadding=0>
		<col width='20px'><col width='20px'><col width='120px'><col width='140px'>";
		
	if ($txtfundcode != ''){
		$querydt = "select funddt_id, Source_Fundsdt.user_code, user_name from Source_Fundsdt
					inner join ".$_SESSION['dbLabel'].".users on users.user_account = Source_Fundsdt.user_code
					where sourceFund_Code = '$txtfundcode' ";
		$resdt = mysql_query($querydt, $connection);			
		while ($rwdt = mysql_fetch_array($resdt)){
			echo "<tr>
				<td align='center' style='$bbottom;$bleft;'><img src='img/button_edit.png' onmouseover=\"style.cursor='hand';\" onclick=\"addFundUser('$i','$txtfundcode');\" title='Add Record' style='cursor: pointer;'></td>
				<td align='center' style='$bbottom;'><img src='img/c_delete.png' onmouseover=\"style.cursor='hand';\" onclick=\"deleteFundUser('$i','$txtfundcode');\" height='11px' width='10px' title='Clear Record' style='cursor: pointer;'></td>
				<td align='center' style='$bbottom;'>
					<input type='hidden' name='funddtid$i' id='funddtid$i' value='$rwdt[0]'>
					<input type='text' name='usercode$i' id='usercode$i' value='$rwdt[1]' style='width:100px; border-radius:4px; font-size:11px;' readonly>
					<label><span class='style1'><img src='img/btnopen.jpg' title=' Select User ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistUsers('$i');\"  /></span></label>
				</td>
				<td align='center' style='$bbottom;$bright;'>
					<input type='text' name='username$i' id='username$i' value='$rwdt[2]' style='width:155px; border-radius:4px; font-size:11px;' readonly>
				</td>
			  </tr>";
			$i++;  
		}
	}	
	echo "<tr>
			<td align='center' style='$bbottom;$bleft;'><img src='img/button_edit.png' onmouseover=\"style.cursor='hand';\" onclick=\"addFundUser('$i','$txtfundcode');\" title='Add Record' style='cursor: pointer;'></td>
			<td align='center' style='$bbottom;'><img src='img/undo-1.png' onmouseover=\"style.cursor='hand';\" onclick=\"clearFundUser('$i','$txtfundcode');\" height='11px' width='10px' title='Clear Record' style='cursor: pointer;'></td>
			<td align='center' style='$bbottom;'>
				<input type='hidden' name='funddtid$i' id='funddtid$i' value=''>
				<input type='text' name='usercode$i' id='usercode$i' value='' style='width:100px; border-radius:4px; font-size:11px;' readonly>
				<label><span class='style1'><img src='img/btnopen.jpg' title=' Select User ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistUsers('$i');\"  /></span></label>
			</td>
			<td align='center' style='$bbottom;$bright;'>
				<input type='text' name='username$i' id='username$i' value='' style='width:155px; border-radius:4px; font-size:11px;' readonly>
			</td>
		  </tr>";
	echo "</table>";
	echo "</div>";
}

function addPaymentModeGrid($connection){
	$bleft = "border-left:1px solid gray";
	$bright = "border-right:1px solid gray";
	$btop = "border-top:1px solid gray";
	$bbottom = "border-bottom:1px solid gray";
	
	echo "<table width=400px cellpadding=0 cellspacing=0>
		<col width=20px><col width=20px><col width=150px><col width=210px>";
	echo "<tr bgcolor='#D0D0D0' height='30px'>
			<td style='$bbottom;$bleft;$btop;'></td><td style='$bbottom;$btop;'></td>
			<td align='center' style='$bbottom;$btop;'><span class='style1'>Payment Code</span></td>
			<td align='center' style='$bbottom;$bright;$btop;'><span class='style1'>Payment Description</span></td>
		  </tr>";
		  
	echo "</table>";	
	//detail
	echo "<div style='width:420px;height:280px;overflow-y:scroll;overflow-x:hidden;'>";
	$i=0;
	echo "<table width=400px cellpadding=0 cellspacing=0>
		<col width=20px><col width=20px><col width=150px><col width=210px>";
	$query = "select paymentmode_code, paymentmode_desc from Payment_Mode order by paymentmode_code ";
	$result = mysql_query($query, $connection);	
	while ($row = mysql_fetch_array($result)){
		echo "<tr height='20px'>
				<td align='center'><img src='img/button_edit.png' onmouseover=\"style.cursor='hand';\" onclick=\"addPayment('$i','$row[0]');\" title='Add Record' style='cursor: pointer;'></td>
				<td align='center'><img src='img/c_delete.png' onmouseover=\"style.cursor='hand';\" onclick=\"deletePayment('$i','$row[0]');\" height='11px' width='10px' title='Delete Record' style='cursor: pointer;'></td>
				<td align='center'>
					<input type='text' name='paymentcode$i' id='paymentcode$i' value='$row[0]' style='width:145px; border-radius:4px; font-size:11px;'>
				</td>
				<td align='center'>
					<input type='text' name='paymentdesc$i' id='paymentdesc$i' value='$row[1]' style='width:200px; border-radius:4px; font-size:11px;'>
				</td>
			  </tr>";
			$i++;  
		
	}
	echo "<tr height='20px'>
			<td align='center'><img src='img/button_edit.png' onmouseover=\"style.cursor='hand';\" onclick=\"addPayment('$i','');\" title='Add Record' style='cursor: pointer;'></td>
			<td align='center'><img src='img/c_delete.png' onmouseover=\"style.cursor='hand';\" onclick=\"clearPayment('$i','');\" height='11px' width='10px' title='Clear Record' style='cursor: pointer;'></td>
			<td align='center'>
				<input type='text' name='paymentcode$i' id='paymentcode$i' value='' style='width:145px; border-radius:4px; font-size:11px;'>
			</td>
			<td align='center'>
				<input type='text' name='paymentdesc$i' id='paymentdesc$i' value='' style='width:200px; border-radius:4px; font-size:11px;'>
			</td>
		  </tr>";
	echo "</table>";
	echo "</div>";
}
?>