Path : /var/www/html/smart_kpp2_bk17 มีค 69/modules/budget/main/
File Upload :
Current File : /var/www/html/smart_kpp2_bk17 มีค 69/modules/budget/main/receive_income_bud.php

<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
require_once "modules/budget/time_inc.php";	

?>
<link type="text/css" href="./datepicker_thaiyear/css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />	
<script type="text/javascript" src="./datepicker_thaiyear/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="./datepicker_thaiyear/js/jquery-ui-1.8.10.offset.datepicker.min.js"></script>
<script type="text/javascript">
		  $(function () {
		    var d = new Date();
		    var toDay = d.getDate() + '/' + (d.getMonth() + 1) + '/' + (d.getFullYear() + 543);

		    $("#datepicker-th-1").datepicker({ changeMonth: true, changeYear: true,dateFormat: 'dd/mm/yy', isBuddhist: true, defaultDate: toDay,dayNames: ['อาทิตย์','จันทร์','อังคาร','พุธ','พฤหัสบดี','ศุกร์','เสาร์'],
              dayNamesMin: ['อา.','จ.','อ.','พ.','พฤ.','ศ.','ส.'],
              monthNames: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
              monthNamesShort: ['ม.ค.','ก.พ.','มี.ค.','เม.ย.','พ.ค.','มิ.ย.','ก.ค.','ส.ค.','ก.ย.','ต.ค.','พ.ย.','ธ.ค.']});
			});
</script>
<?php

if($result_permission['p7']!=1){
exit();
}

$officer=$_SESSION['login_user_id'];

$budget_status['1']="เงินสด";
$budget_status['2']="เช็ค/เงินฝากธนาคาร";
$budget_status['3']="เงินฝากส่วนราชการผู้เบิก";
$budget_status['4']="นำเงินสดฝากธนาคาร";
$budget_status['5']="นำเงินสดฝากส่วนราชการผู้เบิก";
$budget_status['6']="ถอนเงินฝากธนาคารเป็นเงินสด";
$budget_status['7']="ถอนเงินฝากธนาคารไปฝากส่วนราชการผู้เบิก";
$budget_status['8']="รับคืนเงินฝากส่วนราชการผู้เบิกมาเป็นเงินสด";
$budget_status['9']="รับคืนเงินฝากส่วนราชการมาเป็นเงินฝากธนาคาร";

if(!(isset($_REQUEST['type_id_index']))){
$_REQUEST['type_id_index']="";
}

//ปีงบประมาณ
$sql = "select * from  budget_year where year_active='1' order by budget_year desc limit 1";
$dbquery = mysqli_query($connect,$sql);
$year_active_result = mysqli_fetch_array($dbquery);

if($year_active_result['budget_year']==""){
echo "<br />";
echo "<div align='center'>ยังไม่ได้กำหนดทำงานในปีงบประมาณใด ๆ  กรุณาไปที่เมนูตั้งค่าระบบ เพื่อกำหนดปีงบประมาณ</div>";
exit();
}

//ส่วนหัว
echo "<br />";
if(!(($index==1) or ($index==2) or ($index==5) or ($index==7))){
echo "<table width='50%' border='0' align='center'>";
echo "<tr align='center'><td><font color='#006666' size='3'><strong>ทะเบียนรับเงินรายได้แผ่นดิน ปีงบประมาณ $year_active_result[budget_year]</strong></font></td></tr>";
echo "</table>";
}

//ส่วนฟอร์มรับข้อมูล
if($index==1){
echo "<form id='frm1' name='frm1'>";
echo "<Center>";
echo "<Font color='#006666' Size=3><B>เพิ่มข้อมูลการรับเงินรายได้แผ่นดิน ปีงบประมาณ $year_active_result[budget_year]</Font>";
echo "</Cener>";
echo "<Br><Br>";
echo "<Table width='60%' Border='0' Bgcolor='#Fcf9d8'>";

$today=date("Y-m-d");;
$today=getDateThai($today);
echo "<Tr align='left'><Td ></Td><Td align='right'>วันเดือนปี&nbsp;&nbsp;</Td>";
echo "<Td><Input Type='Text' Name='rec_date' id='datepicker-th-1' Size='10' value='$today'></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ที่เอกสาร&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='doc' id='doc' Size='20'></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ประเภทของเงิน&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='type_id' id='type_id' size='1'>";
echo  "<option  value = ''>เลือก</option>" ;

$sql = "select  * from  budget_type where category_id='3' and budget_year='$year_active_result[budget_year]' order by type_id";
$dbquery = mysqli_query($connect,$sql);
While ($result = mysqli_fetch_array($dbquery))
   {
$type_id = $result['type_id']; 
$type_name = $result['type_name'];
echo  "<option value = $type_id>$type_id $type_name</option>";
	}
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>รายการ&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='item' id='item' Size='60'></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right'>ลักษณะรายการ&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='status' id='status' size='1'>";
echo  "<option  value = ''>เลือก</option>" ;
echo  "<option value = '1'>$budget_status[1]</option>";
echo  "<option value = '2'>$budget_status[2]</option>";
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td width=20></Td><Td align='right'>จำนวนเงิน&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='receive_amount' id='receive_amount' Size='15' onkeydown='digitOnly()'></Td></Tr>";

echo "<Br>";
echo "</Table>";
echo "<Br>";
echo "<INPUT TYPE='button' name='smb' value='ตกลง' onclick='goto_url(1)'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ย้อนกลับ' onclick='goto_url(0)'>";

echo "</form>";
}

//ส่วนยืนยันการลบข้อมูล
if($index==2) {
echo "<table width='500' border='0' align='center'>";
echo "<tr><td align='center'><font color='#990000' size='4'>โปรดยืนยันความต้องการลบข้อมูลอีกครั้ง</font><br></td></tr>";
echo "<tr><td align=center>";
echo "<INPUT TYPE='button' name='smb' value='ยืนยัน' onclick='location.href=\"?option=budget&task=main/receive_income_bud&index=3&id=$_GET[id]&page=$_REQUEST[page]&type_id_index=$_REQUEST[type_id_index]\"'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ยกเลิก' onclick='location.href=\"?option=budget&task=main/receive_income_bud&page=$_REQUEST[page]&type_id_index=$_REQUEST[type_id_index]\"'";
echo "</td></tr></table>";
}

//ส่วนลบข้อมูล
if($index==3){
$sql = "delete from budget_main where id=$_GET[id]";
$dbquery = mysqli_query($connect,$sql);
}

//ส่วนบันทึกข้อมูล
if($index==4){
$rec_date=getDateEng($_POST['rec_date']);
$sql = "insert into budget_main (budget_year, doc, type_id, item, receive_amount, status,  rec_date, officer) values ('$year_active_result[budget_year]', '$_POST[doc]', '$_POST[type_id]', '$_POST[item]','$_POST[receive_amount]', '$_POST[status]', '$rec_date','$officer')";
$dbquery = mysqli_query($connect,$sql);
}

//ส่วนฟอร์มแก้ไขข้อมูล
if ($index==5){
echo "<form id='frm1' name='frm1'>";
echo "<Center>";
echo "<Font color='#006666' Size=3><B>แก้ไขทะเบียนรับเงินรายได้แผ่นดิน ปีงบประมาณ $year_active_result[budget_year]</B></Font>";
echo "</Cener>";
echo "<Br><Br>";

echo "<Table  width='60%' Border='0' Bgcolor='#Fcf9d8'>";

$sql = "select * from budget_main where id='$_GET[id]'";
$dbquery = mysqli_query($connect,$sql);
$ref_result = mysqli_fetch_array($dbquery);

$rec_date=getDateThai($ref_result['rec_date']);
echo "<Tr align='left'><Td ></Td><Td align='right'>วันเดือนปี&nbsp;&nbsp;</Td>";
echo "<Td align='left'><Input Type='Text' Name='rec_date' id='datepicker-th-1' Size='10' value='$rec_date'></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ที่เอกสาร&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='doc' id='doc' Size='20' value='$ref_result[doc]'></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ประเภทของเงิน&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='type_id' id='type_id' size='1'>";
echo  "<option  value = ''>เลือก</option>" ;

$sql = "select  * from  budget_type where category_id='3' and budget_year='$year_active_result[budget_year]' order by type_id";
$dbquery = mysqli_query($connect,$sql);
While ($result = mysqli_fetch_array($dbquery))
   {
$type_id = $result['type_id']; 
$type_name = $result['type_name'];
	if($type_id==$ref_result['type_id']){
	$select="selected";
	}
	else{
	$select="";
	}
echo  "<option value = $type_id $select>$type_id $type_name</option>";
	}
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>รายการ&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='item' id='item' Size='60' value='$ref_result[item]'></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ลักษณะรายการ&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='status' id='status' size='1'>";
echo  "<option  value = ''>เลือก</option>" ;
for($x=1;$x<=2;$x++){
	if($ref_result['status']==$x){
	echo  "<option value=$x selected>$budget_status[$x]</option>";
	}
	else {
	echo  "<option value=$x>$budget_status[$x]</option>";
	}
}
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td width=20></Td><Td align='right'>จำนวนเงิน&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='receive_amount' id='receive_amount' Size='15'  value='$ref_result[receive_amount]' onkeydown='digitOnly()'></Td></Tr>";
echo "</Table>";
echo "<Input Type=Hidden Name='id' Value='$_GET[id]'>";
echo "<Input Type=Hidden Name='page' Value='$_GET[page]'>";
echo "<Input Type=Hidden Name='type_id_index' Value='$_REQUEST[type_id_index]'>";
echo "<Br>";
echo "<INPUT TYPE='button' name='smb' value='ตกลง' onclick='goto_url_update(1)'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ย้อนกลับ' onclick='goto_url_update(0)'>";
echo "</form>";
}

//ส่วนปรับปรุงข้อมูล
if ($index==6){
$rec_date=getDateEng($_POST['rec_date']);
$sql = "update budget_main set doc='$_POST[doc]',type_id='$_POST[type_id]',item='$_POST[item]', receive_amount='$_POST[receive_amount]', status='$_POST[status]', officer='$officer' , rec_date='$rec_date' where id='$_POST[id]'";
$dbquery = mysqli_query($connect,$sql);
}

//ส่วนแสดงรายละเอียด
if ($index==7){
echo "<Center>";
echo "<Font color='#006666' Size=3><B>รายละเอียดรายการรับเงินรายได้แผ่นดิน ปีงบประมาณ $year_active_result[budget_year]</B></Font>";
echo "</Cener>";
echo "<Br>";
$sql = "select * from budget_main where id='$_GET[id]'";
$dbquery = mysqli_query($connect,$sql);
$ref_result = mysqli_fetch_array($dbquery);
echo "<Br>";
echo "<Table  align='center' width='60%' Border='0' Bgcolor='#Fcf9d8'>";
echo "<Tr ><Td colspan='7' align='right'><INPUT TYPE='button' name='smb' value='<<กลับหน้าก่อน' onclick='location.href=\"?option=budget&task=main/receive_income_bud&page=$_GET[page]\"'></Td></Tr>";

$to_date=thai_date_3($ref_result['rec_date']);	
echo "<Tr align='left'><Td align='right'>วันเดือนปี&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='' Size='10'  value='$to_date' readonly></Td></Tr>";

echo "<Tr align='left'><Td align='right'>ที่เอกสาร&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='doc' id='doc' Size='20' value='$ref_result[doc]'></Td></Tr>";

echo "<Tr align='left'><Td align='right'>ประเภทของเงิน&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='type_id' id='type_id' size='1'>";
$sql = "select  * from  budget_type where category_id='3' and budget_year='$year_active_result[budget_year]' order by type_id";
$dbquery = mysqli_query($connect,$sql);
While ($result = mysqli_fetch_array($dbquery))
   {
$type_id = $result['type_id']; 
$type_name = $result['type_name'];
		if($type_id==$ref_result['type_id']){
		echo  "<option value = $type_id $select>$type_id $type_name</option>";
		}
	}
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td align='right'>รายการ&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='item' id='item' Size='60' value='$ref_result[item]' readonly></Td></Tr>";

echo "<Tr align='left'><Td align='right'>ลักษณะรายการ&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='status' id='status' size='1'>";
for($x=1;$x<=2;$x++){
	if($ref_result['status']==$x){
	echo  "<option value=$x selected>$budget_status[$x]</option>";
	}
}
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td align='right'>จำนวนเงิน&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='receive_amount' id='receive_amount' Size='15'  value='$ref_result[receive_amount]' readonly></Td></Tr>";

$sql = "select  * from  person_main where person_id='$ref_result[officer]' ";
$dbquery = mysqli_query($connect,$sql);
$result = mysqli_fetch_array($dbquery);
$fullname=$result['prename'].$result['name']." ".$result['surname'];
echo "<Tr align='left'><Td align='right'>เจ้าหน้าที่&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='' Size='30' value='$fullname' readonly></Td></Tr>";

echo "</Table>";
}

//ส่วนแสดงผล
if(!(($index==1) or ($index==2) or ($index==5) or ($index==7))){

//ส่วนของการคำนวณ
if($_REQUEST['type_id_index']!=""){
$sql = "select id,receive_amount from  budget_main where budget_year='$year_active_result[budget_year]' and status between '1' and '2' and type_id='$_REQUEST[type_id_index]' order by rec_date, id";
}
else{
$sql = "select id,receive_amount from budget_main where budget_year='$year_active_result[budget_year]' and type_id between '300' and '399' and status between '1' and '2' order by rec_date, id";
}

$receive_total=0; //รวมรับ
$dbquery = mysqli_query($connect,$sql);
$num_rows = mysqli_num_rows($dbquery );  // นำตัวแปรไปใช้ในส่วนของการแยกหน้า
While ($result = mysqli_fetch_array($dbquery)) {
$receive_total=$receive_total+$result['receive_amount'];
$receive_total_ar[$result['id']]=$receive_total;   //รวมรับ รายรายการ
}

//ส่วนของการแยกหน้า
$pagelen=20;  // 1_กำหนดหน้าฺ
$url_link="option=budget&task=main/receive_income_bud";  // 2_กำหนดลิงค์ฺ

$totalpages=ceil($num_rows/$pagelen);
if(!(isset($_REQUEST['page']))){
$_REQUEST['page']="";
}
if($_REQUEST['page']==""){
$page=$totalpages;
		if($page<2){
		$page=1;
		}
}
else{
		if($totalpages<$_REQUEST['page']){
		$page=$totalpages;
					if($page<1){
					$page=1;
					}
		}
		else{
		$page=$_REQUEST['page'];
		}
}

$start=($page-1)*$pagelen;

if(($totalpages>1) and ($totalpages<16)){
echo "<div align=center>";
echo "หน้า	";
			for($i=1; $i<=$totalpages; $i++)	{
					if($i==$page){
					echo "[<b><font size=+1 color=#990000>$i</font></b>]";
					}
					else {
					echo "<a href=$PHP_SELF?$url_link&page=$i&type_id_index=$_REQUEST[type_id_index]>[$i]</a>";
					}
			}
echo "</div>";
}			
if($totalpages>15){
			if($page <=8){
			$e_page=15;
			$s_page=1;
			}
			if($page>8){
					if($totalpages-$page>=7){
					$e_page=$page+7;
					$s_page=$page-7;
					}
					else{
					$e_page=$totalpages;
					$s_page=$totalpages-15;
					}
			}
			echo "<div align=center>";
			if($page!=1){
			$f_page1=$page-1;
			echo "<<a href=$PHP_SELF?$url_link&page=1&type_id_index=$_REQUEST[type_id_index]>หน้าแรก </a>";
			echo "<<<a href=$PHP_SELF?$url_link&page=$f_page1&type_id_index=$_REQUEST[type_id_index]>หน้าก่อน </a>";
			}
			else {
			echo "หน้า	";
			}					
			for($i=$s_page; $i<=$e_page; $i++){
					if($i==$page){
					echo "[<b><font size=+1 color=#990000>$i</font></b>]";
					}
					else {
					echo "<a href=$PHP_SELF?$url_link&page=$i&type_id_index=$_REQUEST[type_id_index]>[$i]</a>";
					}
			}
			if($page<$totalpages)	{
			$f_page2=$page+1;
			echo "<a href=$PHP_SELF?$url_link&page=$f_page2&type_id_index=$_REQUEST[type_id_index]> หน้าถัดไป</a>>>";
			echo "<a href=$PHP_SELF?$url_link&page=$totalpages&type_id_index=$_REQUEST[type_id_index]> หน้าสุดท้าย</a>>";
			}
			echo " <select onchange=\"location.href=this.options[this.selectedIndex].value;\" size=\"1\" name=\"select\">";
			echo "<option  value=\"\">หน้า</option>";
				for($p=1;$p<=$totalpages;$p++){
				echo "<option  value=\"?$url_link&page=$p&type_id_index=$_REQUEST[type_id_index]\">$p</option>";
				}
			echo "</select>";
echo "</div>";  
}					
//จบแยกหน้า

		//link เพิ่มข้อมูล
		echo  "<table width=95% border=0 align=center>";
		echo "<Tr><Td align='left'><INPUT TYPE='button' name='smb' value='เพิ่มรายการรับ' onclick='location.href=\"?option=budget&task=main/receive_income_bud&index=1\"'></Td>";
		echo "<td>";
		//เลืิอกประเภท
		echo "<form id='frm1' name='frm1'>";
		echo "<div align='right'>";
		echo "<Select  name='type_id_index' size='1'>";
		echo  "<option  value = ''>ทุกประเภท</option>" ;
		$sql_type = "select  * from  budget_type where category_id='3' and budget_year='$year_active_result[budget_year]' order by type_id";
		$dbquery_type = mysqli_query($connect,$sql_type);
		While ($result_type = mysqli_fetch_array($dbquery_type))
		   {
		$type_id = $result_type['type_id']; 
		$type_name = $result_type['type_name'];
		$budget_type_ar[$type_id]=$type_name;  //อาเรย์
				if($type_id ==$_REQUEST['type_id_index']){
				$select="selected";
				}
				else {
				$select="";
				}
		echo  "<option value = $type_id $select>$type_id $type_name</option>";
			}
		echo "</select> <INPUT TYPE='button' name='smb' value='เลือก' onclick='goto_type(1)' class=entrybutton>";
		echo "</div>";
		echo "</form>";
		echo "</td></Tr></Table>";
		//จบส่วนเลือกประเภท

if($_REQUEST['type_id_index']!=""){
$sql = "select * from  budget_main where budget_year='$year_active_result[budget_year]' and status between '1' and '2' and type_id='$_REQUEST[type_id_index]' order by rec_date, id limit $start,$pagelen";
}
else{
$sql = "select * from budget_main where budget_year='$year_active_result[budget_year]' and type_id between '300' and '399' and status between '1' and '2' order by rec_date, id limit $start,$pagelen";
}

$dbquery = mysqli_query($connect,$sql);
$num_effect = mysqli_num_rows($dbquery );  // จำนวนข้อมูลในหน้านี้

echo  "<table width='95%' border='0' align='center'>";
echo "<Tr bgcolor=#FFCCCC align='center'><Td width='30'>ที่</Td><Td width='70'>วดป</Td><Td width='90'>ที่เอกสาร</Td><Td>รายการ</Td><td width='250'>ประเภท</td><Td width='130'>ลักษณะรายการ</Td><Td width='100'>จำนวนเงิน</Td><Td width='90'>รายละเอียด</Td><Td width='40'>ลบ</Td><Td width='40'>แก้ไข</Td><td width='60'>รวม</td></Tr>";
$N=(($page-1)*$pagelen)+1;
$M=1;
While ($result = mysqli_fetch_array($dbquery))
	{
		$id = $result['id'];
		$doc= $result['doc'];
		$item = $result['item'];
		$type = $result['type_id'];
		$receive_amount = $result['receive_amount'];
		$status = $result['status'];
		$receive_amount=number_format($receive_amount,2);
		$rec_date = $result['rec_date'];
		
list($rec_year,$rec_month,$rec_day) = explode("-",$rec_date);	
$t_year=($rec_year+543)-2500;		
			if(($M%2) == 0)
			$color="#FFFFC";
			else  	$color="#FFFFFF";

		echo "<Tr bgcolor=$color><Td align='center'>$N</Td> <Td>$rec_day $t_month[$rec_month] $t_year</Td><Td align=left>$doc</Td><Td align=left>$item";
		echo "</Td>";
		echo "<td>$budget_type_ar[$type]</td>";		
		echo "<Td>$budget_status[$status]</Td><Td align='right'>$receive_amount</Td>";
		echo "<Td width=90><div align=center><a href=?option=budget&task=main/receive_income_bud&id=$id&index=7&page=$page><img src=./images/browse.png border='0' alt='รายละเอียด'></a></td>";
		if($officer==$result['officer']){
		echo "<Td align=center><a href=?option=budget&task=main/receive_income_bud&index=2&id=$id&page=$page&type_id_index=$_REQUEST[type_id_index]><img src=images/drop.png border='0' alt='ลบ'></a></Td>
		<Td align=center><a href=?option=budget&task=main/receive_income_bud&index=5&id=$id&page=$page&type_id_index=$_REQUEST[type_id_index]><img src=images/edit.png border='0' alt='แก้ไข'></a></div></Td>";
		}
		else{
		echo "<td>&nbsp;</td><td>&nbsp;</td>";
		}
		//กำหนดสัญญาลักษ์ ถึงนี้ 
		if($M==$num_effect){
		$tungnee="ถึงนี้";
		}
		else {
		$tungnee="ถึงนี้>>";
		}
		
		if(!(isset($_GET['cal_id']))){
		$_GET['cal_id']="";
		}
		
		if($_GET['cal_id']==$id){
		echo "<Td align=center><a href=?option=budget&task=main/receive_income_bud&page=$page&type_id_index=$_REQUEST[type_id_index]>$tungnee</a></Td>";
		echo "</Tr>";
		break;  //ออกจากloop
		}
		else {
		echo "<Td align=center><a href=?option=budget&task=main/receive_income_bud&cal_id=$id&page=$page&type_id_index=$_REQUEST[type_id_index]>ถึงนี้</a></Td>";
		echo "</Tr>";
		}		

$M++;
$N++; //*เกี่ยวข้องกับการแยกหน้า
	}
	
//สรุป
if(isset($id) and isset($receive_total_ar[$id])){
$receive_item_total=number_format($receive_total_ar[$id],2);	
}
else{
$receive_item_total="";
}
echo "<Tr bgcolor=#FFCCCC><Td></Td><Td></Td><Td></Td><Td></Td><Td></Td><Td align='center'>รวม</Td><Td align='center'>$receive_item_total</Td><Td></Td><Td></Td><Td></Td><Td></Td></Tr>";
echo "</Table>";
}

?>
<script>
function goto_url(val){
	if(val==0){
		callfrm("?option=budget&task=main/receive_income_bud");   // page ย้อนกลับ 
	}else if(val==1){
		if(frm1.doc.value == ""){
			alert("กรุณากรอกที่เอกสาร");
		}else if(frm1.type_id.value==""){
			alert("กรุณาเลือกประเภทของเงิน");
		}else if(frm1.item.value == ""){
			alert("กรุณากรอกรายการรับเงิน");
		}else if(frm1.status.value == ""){
			alert("กรุณาเลือกลักษณะรายการ");
		}else if(frm1.receive_amount.value == ""){
			alert("กรุณากรอกจำนวนเงิน");
		}else{
			callfrm("?option=budget&task=main/receive_income_bud&index=4");   //page ประมวลผล
		}
	}
}

function goto_url_update(val){
	if(val==0){
		callfrm("?option=budget&task=main/receive_income_bud");   // page ย้อนกลับ 
	}else if(val==1){
		if(frm1.rec_date.value == ""){
			alert("กรุณาเลือกวันที่");
		}else if(frm1.doc.value==""){
			alert("กรุณากรอกที่เอกสาร");
		}else if(frm1.type_id.value==""){
			alert("กรุณาเลือกประเภทของเงิน");
		}else if(frm1.item.value == ""){
			alert("กรุณากรอกรายการรับเงิน");
		}else if(frm1.status.value == ""){
			alert("กรุณาเลือกลักษณะรายการ");
		}else if(frm1.receive_amount.value == ""){
			alert("กรุณากรอกจำนวนเงิน");
		}else{
			callfrm("?option=budget&task=main/receive_income_bud&index=6");   //page ประมวลผล
		}
	}
}

function goto_type(val){
	if(val==1){
		callfrm("?option=budget&task=main/receive_income_bud");   // page ย้อนกลับ 
		}
}
</script>