⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mbook.php

📁 酒店管理系统
💻 PHP
字号:
<? 
header("Cache-Control: no-cache, must-revalidate");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
 header("Pragma: no-cache");

 require_once('include/connection.php'); 
 include('include/admin_or_user.php');
 require_once('include/sqlfuns.php');
 
 header("Refresh:600");

 ?>

<? 

if(isset($_POST['s1']))
{ $i=$_POST['rows'];
  $total=$_POST['paiedmoney'];
  $totalperson=$_POST['person'];
  
   for($j=1;$j<=$i;$j++)
      if(isset($_POST['checkbox'.$j]))  
          { $selectsql=sprintf("select distinct  room.room_person,roomlevel.room_prise from room,roomlevel where room.room_level=roomlevel.room_level and room_number=%s",
		     GetSQLValueString($_POST['checkbox'.$j], "text"));
			 
		     $selectprise=odbc_exec($conn,$selectsql);
			 $rp=odbc_result($selectprise,'room_person')*odbc_result($selectprise,'room_prise')*$_POST['days'];
			 $inperson=odbc_result($selectprise,'room_person');
			 $totalperson=$totalperson-$inperson;
			 if($totalperson<0)
			 $inperson=($inperson+$totalperson)*1;
			 if($inperson<0)
			 $inperson=0;
			 $total=$total-$rp;
			  if($total<0)
			  $rp=$rp+$total;
	 
		   $insertsql = sprintf("INSERT INTO coustom (room_number,name, paiedmoney,in_time,days,person) VALUES(%s, %s,%s,%s,%s,%s)",
                       GetSQLValueString($_POST['checkbox'.$j], "text"),
                       GetSQLValueString($_POST['name'], "text"),
					   GetSQLValueString($rp, "int"),
					   GetSQLValueString($_POST['in_time'], "text"),
					   GetSQLValueString($_POST['days'], "int"),
					   GetSQLValueString($inperson, "int")); 
				   
			odbc_exec($conn,$insertsql);
			$insertsql = sprintf("INSERT INTO coustombak (room_number,name, paiedmoney,in_time,days,person) VALUES(%s, %s,%s,%s,%s,%s)",
                       GetSQLValueString($_POST['checkbox'.$j], "text"),
                       GetSQLValueString($_POST['name'], "text"),
					   GetSQLValueString($rp, "int"),
					   GetSQLValueString($_POST['in_time'], "text"),
					   GetSQLValueString($_POST['days'], "int"),
					   GetSQLValueString($inperson, "int")); 
			odbc_exec($conn,$insertsql);		   
					  
			$updateroomsql = sprintf("update room set room_state=1 where room_number=%s",  
                      GetSQLValueString($_POST['checkbox'.$j], "text"));
			odbc_exec($conn,$updateroomsql);
			
			}
			
			if($total>0)
			{ $j=1;
			   $state=1;
			   while($state)
              { if(isset($_POST['checkbox'.$j]))  
			     { $updatesql = sprintf("update coustom set paiedmoney=paiedmoney+%s where room_number=%s",  
                       GetSQLValueString($total, "int"),
					   GetSQLValueString($_POST['checkbox'.$j], "text"));
					   odbc_exec($conn,$updatesql);
					  $state=0;
					  
					  }
					  $j++;
				 }
				}
}				
 ?>			
           

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-right: 0px;
	margin-top: 0px;
}
.STYLE1 {color: #FF0000}
-->
</style>
<script>
roomtemp=new Array();
var i1=0;
oldroom=parent.document.all.room_number.value;
function selectroom(k,roomtemp)
{ 

if(k.checked)
{
  roomtemp[i1]=k.value;
  
 i1=i1+1;
}
if(!k.checked)
  { var j1=0;
  while(j1<i1)
     {
	 
	 if (roomtemp[j1]==k.value)
	   roomtemp[j1]="";
	   j1=j1+1;
	  }
  } 
 j1=0;
 n=0;
 parent.document.all.room_number.value="";
 while(j1<i1) 
 { 
   if(roomtemp[j1]!="")
      { n=n+1;
    if (n==1)
      parent.document.all.room_number.value=roomtemp[j1];
	else
      
	  parent.document.all.room_number.value+=" "+roomtemp[j1];
	  n=n+1
	  }
   j1=j1+1;
   }

}
function selectroom1()
{ 
 var k3=0;
  parent.document.all.room_number.value=oldroom;
 while(roomtemp[k3]!=undefined)
   {roomtemp[k3]="";
    k3=k3+1;
	}
}

</script>
 <? 
 $month=date("m");
 $day=date("d");
 include ("include/book.as");?>

<?
    
     echo "<script>";
	 echo "var total=0;";
	 echo "var pson=0;";
	 echo "prise=new Array();";
	 echo "stime0=new Array();";
	 echo "today=today0=countday(".$month.",".$day.");";
     $prisesql="select room_level,room_prise from roomlevel order by room_level ";
	     $prise=odbc_exec($conn,$prisesql);
		 
		while(odbc_fetch_row($prise))
		 echo "prise[".odbc_result($prise,'room_level')."]=".odbc_result($prise,'room_prise').";";
		echo "</script>";





 
     echo "<script>";
	 echo "room=new Array();";
     $emptyroomsql="select * from room where room_state=-1 or room_state=0 order by room_level ,room_person ";
	     $emptyroom=odbc_exec($conn,$emptyroomsql);
		 $rows=0;
		$temp1=odbc_fetch_row($emptyroom,'1');
		 $roomlevel=odbc_result($emptyroom,'room_level');
		  
		
		 echo "level=new Array();";
		if($temp1)
		do
		 { 
		   $roomperson=odbc_result($emptyroom,'room_person');
		   $roomnumber=odbc_result($emptyroom,'room_number');
		   $roomlevel=odbc_result($emptyroom,'room_level');
		   
		   echo "level[".$rows."]='".$roomlevel."';";
		   echo "room[".$rows."]='".$roomnumber."'+',".$roomperson."';";
		    if(odbc_result($emptyroom,'room_state')==0)
		    {
		 $stimesql="select longintime from book where room_number like '%".odbc_result($emptyroom,'room_number')."%' and id=(select  max(id) as mid from (select * from book where room_number like '%".odbc_result($emptyroom,'room_number')."%'))"; 
		 
		
		   $stimeresult=odbc_exec($conn,$stimesql);
		   $statetime=odbc_result($stimeresult,'longintime');
		   $stimearray=explode("-",$statetime);
		   $m1=$stimearray[0];
		   $d1=$stimearray[1];
		   echo "stime0[".$rows."]=countday(".$m1.",".$d1.");";
          
			}
		    else
			
			  echo "stime0[".$rows."]=100;";
		   
		   $rows++;
		   
		   }while(odbc_fetch_row($emptyroom)) ;
		   
		   echo "</script>";
	
	
	
	
	
 echo "<script>";
		   echo "function f(room,level)
		             { 
					 totalarray=new Array();
					   total=0;
					   pson=0;
					   document.all.paiedmoney.value='';
					 document.all.div1.innerHTML='<span class=STYLE1>(括号内为可预定的天数)</span>';                    document.all.div2.innerHTML='';
					   document.all.div3.innerHTML='';
					 	m=1; 
						l=0;
						q=0;
						n=1;
						leandpe=new Array();
		                 for(i=0;i<=".$rows.";i++)
						  { 
						   if(room[i]!=undefined)
						   {  n++;
						     p=room[i].indexOf(',');
                             str2=room[i].substr(p+1);
                             str1=room[i].substr(0,p);
							 l1=level[i];
							 p1=str2;
							 if(l!=l1)
							 {
							 document.all.div1.innerHTML+='<hr /><br>'+l1+'星级:';
							 l=l1;
							 }
							  if(q!=p1)
							 { 
							  document.all.div1.innerHTML+='<br>&nbsp;&nbsp;'+str2+'人房: ';
							  q=p1;
							   }
							leandpe[m]=l+','+str2;
						    if(stime0[i]==100)
							  temp='长期';
							    else 
								   temp=stime0[i]-today-1;
							 if(temp=='长期'||temp>=document.all.days.value)
							 {	   
							     if(temp>0)
								  temp+='天';
						    document.all.div1.innerHTML+='&nbsp;&nbsp;<input type=checkbox name=checkbox'+m+' onclick=c1(this,leandpe,prise,'+m+');selectroom(this,roomtemp) value='+str1+' >';
							
					        document.all.div1.innerHTML+=str1;
							
							
							document.all.div1.innerHTML+='<span class=STYLE1>('+temp+')</span>';
						
						if(n>5)
							  {document.all.div1.innerHTML+='<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							   n=1;
							   }
							 
							
						    m++;
							}
						  }	
							
					     }
						 document.all.h1.value=2;";
						 
	 	echo "}";	 
	echo "</script>";	 
		 ?>

<script>

function t(room,level,s)
{ totalarray=new Array(); 
  total=0;
  pson=0;
  document.all.paiedmoney.value='';
   document.all.div1.innerHTML="<span class=STYLE1>(括号内为可预定的天数)</span><hr />";
   document.all.div2.innerHTML="";
   document.all.div3.innerHTML="";
    k=1;y=0;
	leandpe=new Array();
    for(i=0;i<=<? echo $rows;?>;i++)
	
	 if(room[i]!=undefined)
	  { index1=room[i].indexOf(',');
        person1=room[i].substr(index1+1);
        index2=s.value.indexOf(',');
	    l=s.value.substr(index2+1);
		person2=s.value.substr(0,index2);
	   if((l==level[i])&&(person2==person1))
	     { y++;
		   if(y>6)
		     {document.all.div1.innerHTML+='<br>';
		     y=1;
		      }
		    if(stime0[i]==100)
			  temp='长期';
				else 
			  temp=stime0[i]-today-1;
		   if(temp=='长期'||temp>=document.all.days.value)
			{ if(temp>0)
			  temp+='天';
		  document.all.div1.innerHTML+='&nbsp;&nbsp;<input type=checkbox name=checkbox'+k+' onclick=c1(this,leandpe,prise,'+k+');selectroom(this,roomtemp) value='+room[i].substr(0,index1)+' >';
		   
	      roomnumber=room[i].substr(0,index1);
          document.all.div1.innerHTML+=roomnumber;
		  document.all.div1.innerHTML+='<span class=STYLE1>('+temp+')</span>';
		  leandpe[k]=l+','+person2;
		  k=k+1;
		     }
		  }
	   }
 if(k==1)
	 {alert("暂无");}
 
document.all.h1.value=1;	
}
</script>
<script>
totalarray=new Array();

function c1(a,lp,p,c)
{  
   
   index3=lp[c].indexOf(',');
   person3=lp[c].substr(index3+1);
   level3=lp[c].substr(0,index3); 

      if(a.checked)
     { 
	   totalarray[c]=person3*p[level3];
	   pson+=person3*1;
	   total+=totalarray[c]*document.all.days.value;
	   
	   }
     
    else 
    {  totalarray[c]=0;
	    
	   pson-=person3;
	
	total-=person3*p[level3]*document.all.days.value;
	}
    document.all.paiedmoney.value=total;
	document.all.div3.innerHTML="可入住人数:<span class='STYLE1'>"+pson+"</span>";
   }
 
</script>
<script>
function tot(tp)
{ document.all.days.value=tp.value;
 var change=0;
 for(k2=1;k2<=<? echo $rows;?>;k2++)
     if(totalarray[k2]!=undefined)
	   
		change+=totalarray[k2]*tp.value;
		
		total=change;
		document.all.paiedmoney.value=change;
	}
function onsub()
{  if(pson<	document.all.person.value)
     {alert("房间可入住的人数少于客户的人数!");
	  return false;
	  }
	 else return true;
}
	
	function refreshfun()
	{ 
	 
	 switch(document.all.h1.value)
	   { case '1' : t(room,level,document.all.select1);break;
		 case '2' : f(room,level);break;
		
		}
	}	

<? if(isset($_POST['s1']))	{ ?>
   alert("操作成功");
   <? }?>
	</script>

<link href="css/hotel.css" rel="stylesheet" type="text/css" />
</head>

<body>




<form id="form1" name="form1" method="post" action="" onsubmit="return onsub()">
  <table width="100%" border="1">
    <tr>
      <td width="133" class="noboarder"><div align="right">入住天数:</div></td>
      <td colspan="2" class="noboarder"><label>
        <input name="days" type="text" id="days" onChange="tot(this)" value="1" size="3" maxlength="6" />
      天 *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      <input type="button" name="Submit" value="刷新数据" onclick="refreshfun()"; />
      <input name="h1" type="hidden" id="h1" value="0" />
      </label></td>
    </tr>
	<tr>
      <td class="noboarder"><div align="right">总 价 格:</div></td>
      <td class="noboarder"><label>
        <span class="STYLE1">&yen;        </span>
        <input name="paiedmoney" type="text" id="paiedmoney" size="6" maxlength="6" value="" />
      *</label></td>
      <td class="noboarder"> <div>
      <span id=div3>	  </span>	  </div></td>
	</tr>
    <tr>
      <td class="noboarder"><div align="right">选择房间:</div></td>
	
      <td colspan="2" class="noboarder">
        <select name="select1" id="select1">
		<? $selectperson="select distinct room_person ,room_level from room order by room_level,room_person";
		    $m=odbc_exec($conn,$selectperson);
			
			while(odbc_fetch_row($m))
			{
			?>
          <option value="<? echo odbc_result($m,'room_person');echo ","; echo odbc_result($m,'room_level');?>"><? echo odbc_result($m,'room_level');echo "星级"; echo odbc_result($m,'room_person');echo "人";  ?></option>
		  <?
		     
			}?>
      </select>
        &nbsp; <label>
        <input name="s1" type="button" id="s1" value="查询" onclick="t(room,level,select1);selectroom1()" />
       &nbsp;
       <input name="s2" type="button" id="s2" value="查询全部" onclick="f(room,level,prise);selectroom1();" /> 
       
      </label></td>
    </tr>
    <tr>
      <td><p align="center">选</p>
      <p align="center">择</p>
      <p align="center">房</p>
      <p align="center">间</p></td>
      <td colspan="2">
	  
	 <div>
	  <span id=div1>	  </span>	  </div>
	  <div>
	  <span id=div2>	  </span>	  </div>	  </td>
    </tr>
  </table>
 <div align="center"> 
  <label></label>
  <label>
  <input type="button" name="Submit2" value="确定" onclick="parent.document.all.div9.innerHTML='';"/>
  </label>
 </div>
</form>

 

</body>


</html>
<? odbc_close($conn);?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -