📄 produce_plan.php
字号:
<?php
require_once("configs/Configs.php");//加载配置文件
require_once("functions/login_flag.php");//是否已经登录
require_once("functions/func_common.php");//加载函数文件
require_once("functions/class_mysql.php");//加载数据库类文件
//获取当前建筑物表、城市表、资源增长表
$query=$db->query("select * from building where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$building_result = $db->fetch_array($query);
$query=$db->query("select * from resource where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$total_resource=$db->fetch_array($query);
//读取研究技术等级表
$query=$db->query("select * from study where `u_id`='".$_COOKIE['UserId']."' ");
$study_result=$db->fetch_array($query);
//生产比例调整
if($_POST['action']=="produce_plan_do"){
//各种资源循环更新比例
for($proi=1;$proi<=4;$proi++){
if(!is_numeric($_POST['worker_percent'.$proi])) echomsg("调整百分比不正确");
if($_POST['worker_percent'.$proi] < 0 or $_POST['worker_percent'.$proi] > 100) echomsg("调整百分比不正确");
if($_POST['worker_percent'.$proi]<=0){//更新资源
require_once("auto_grow_resource.php");
if($_POST['building_num'.$proi]>0)
$query=$db->query("update resource_grow set `last_grow_time`='0',`worker_percent`='".$_POST['worker_percent'.$proi]."' where `b_type`='".$proi."' and `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' ");
}elseif($_POST['building_num'.$proi]>0){
$query=$db->query("select * from resource_grow where `b_type`='".$proi."' and `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$percent_result = $db->fetch_array($query);
if($percent_result['last_grow_time']=="0"){
$query=$db->query("update resource_grow set `last_grow_time`='".time()."',`worker_percent`='".$_POST['worker_percent'.$proi]."' where `b_type`='".$proi."' and `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
}else{
$query=$db->query("update resource_grow set `worker_percent`='".$_POST['worker_percent'.$proi]."' where `b_type`='".$proi."' and `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
}
}
}
//调用produce_plan_process.php:用来计算总产量和当前使用工作////////////////.
include("produce_plan_processing.php");
update_resource();
echo "<script>";
echo "parent.infomation.refresh_self();";
echo "</script>";
echomsg("","?");
}
$query = $db->query("select `c_land_type` from `city` where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$user_info =$db->fetch_array($query);
$db->close();
?>
<!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>
<link href="css/id.css" rel="stylesheet" type="text/css">
<link href="css/css.css" rel="stylesheet" type="text/css">
<link href="css/build.css" rel="stylesheet" type="text/css">
<link href="css/box.css" rel="stylesheet" type="text/css">
<style>
body{
margin-top:0px;
}
</style>
</head>
<body>
<!--导航-->
<?php require_once("study_daohang.htm");?>
<div id="mb_01">
<div class="page_build_title">生产安排<a name="#produce"></a></div>
</div>
<div id="mb_04">
<!--替换区域开始-->
<div style="margin-top:20px;margin-left:45px; margin-right:auto; font-weight:bold; text-align:left; color:RED;">
土地:<?php echo $city_land_type_name[$user_info['c_land_type']];?>,<?php echo $land_add_produce[$user_info['c_land_type']];?>,5个士兵占用1个人口。
</div>
<form name="produce" action="" method="POST">
<input type="hidden" name="action" value="produce_plan_do">
<!--------队列阴影框----------->
<div class="out" style="margin-top:10px;">
<div class="in">
<div class="fox">
<div class="fom">
<!--------内部队列框----------->
<div class="med1_01">
<img src="images/med_01.gif" class="bac"/ style="margin-left:5px;">
<div class="produce_02"><strong>资源名称</strong></div>
<div class="produce_04"><strong>生产设施</strong></div>
<div class="produce_04"><strong>生产安排</strong></div>
<div class="produce_041"><strong>占用人口</strong></div>
<div class="produce_16"><strong>产量/每小时</strong></div>
<img src="images/med_02.gif" class="bac"/>
</div>
<?php
$current_need_person2=0;
if($b_type_name<>"") foreach ($b_type_name as $i=>$m){
if($i>4) break;
//获取生产百分比
$query=$db->query("select * from resource_grow where `b_type`='".$i."' and `u_id`='".$UserId."' and `c_id`='".$CityId."'");
$produce_percent=$db->fetch_array($query);
$grow_num=$building_result[$b_type_name_en[$i]];
?>
<input type="hidden" name="b_type<?php echo $i;?>" value="<?php echo $i;?>">
<div class="produce_07" style="color:#4C2805 "><?php echo $produce_resource_name[$i];?></div>
<div class="produce_03" style="color:#4C2805 "><input type="hidden" name="building_num<?php echo $i;?>" value="<?php echo $building_result[$b_type_name_en[$i]];?>">
<a href="buildinfo.php?b_type=<?php echo $i;?>&grade=<?php echo $building_result[$b_type_name_en[$i]];?>" target="_blank"><?php echo $m;?></a>(<?php echo $building_result[$b_type_name_en[$i]];?>级)</div>
<div class="produce_03" style="color:#4C2805; ">
<select name="worker_percent<?php echo $i;?>">
<?php for($j=10;$j>=0;$j--) { ?>
<option value="<?php echo ($j*10);?>" <?php if($produce_percent['worker_percent']==($j*10) or $j==100) echo "selected"; ?>> <?php echo ($j*10);?>%</option>
<?php } ?>
</select>
</div>
<div class="produce_03a" style="color:#4C2805; font-weight: bold;">
<?php
$query=$db->query("select * from building_attribute where `b_type`='".$i."'");
$base_result=$db->fetch_array($query);
//$current_need_person[$i] = (int)(add_workers($base_result['b_workers'],$grow_num) * ($produce_percent['worker_percent']/100));
$current_need_person2 += $produce_percent['true_workers'];
//当前实际工作人数
$true_workers = $true_workers + $produce_percent['true_workers'];
?>
<input type="hidden" name="used_workers<?php echo $i;?>" value="<?php echo $current_need_person[$i];?>">
<?php
echo $produce_percent['true_workers'];
?>
</div>
<div class="produce_031" style="color:#096F88; font-weight: bold;">
<?php echo $produce_percent['total_grow'];?>
<span style="color:RED;">
<?php
switch($user_info['c_land_type']){
case 1:{
echo "<span style=\"cursor:hand;\" title=\"平原地形增加产量\">+".round($produce_percent['total_grow'] * 0.02,0)."</span>";
break;
}
case 2:{
if($i=="4"){
echo "<span style=\"cursor:hand;\" title=\"沃土地形增加产量\">+".round($produce_percent['total_grow'] * 0.06,0)."</span>";
break;
}
break;
}
case 3:{
if($i=="1"){
echo "<span style=\"cursor:hand;\" title=\"森林地形增加产量\">+".round($produce_percent['total_grow'] * 0.06,0)."</span>";
break;
}
break;
}
case 4:{
if($i=="2"){
echo "<span style=\"cursor:hand;\" title=\"山岳地形增加产量\">+".round($produce_percent['total_grow'] * 0.06,0)."</span>";
break;
}
break;
}
case 5:{
if($i=="3"){
echo "<span style=\"cursor:hand;\" title=\"丘陵地形增加产量\">+".round($produce_percent['total_grow'] * 0.06,0)."</span>";
break;
}
break;
}
}
switch ($i){
case 1:{
if(!$study_result['s_cutting']) $study_result['s_cutting']=0;
echo "<span style=\"cursor:hand;\" title=\"伐木技术增加产量\">+".round($produce_percent['total_grow'] * 0.01 * $study_result['s_cutting'],0)."</span>";
break;
}
case 2:{
if(!$study_result['s_mining']) $study_result['s_mining']=0;
echo "<span style=\"cursor:hand;\" title=\"采矿技术增加产量\">+".round($produce_percent['total_grow'] * 0.01 * $study_result['s_mining'],0)."</span>";
break;
}
case 3:{
if(!$study_result['s_golds']) $study_result['s_golds']=0;
echo "<span style=\"cursor:hand;\" title=\"黄金提炼增加产量\">+".round($produce_percent['total_grow'] * 0.01 * $study_result['s_golds'],0)."</span>";
break;
}
case 4:{
if(!$study_result['s_flooding']) $study_result['s_flooding']=0;
echo "<span style=\"cursor:hand;\" title=\"灌溉技术增加产量\">+".round($produce_percent['total_grow'] * 0.01 * $study_result['s_flooding'],0)."</span>";
break;
}
}
?>
</span>
</div>
<?php } ?>
<div>
<img src="images/med_03.gif" class="bac" />
<div class="produce_101">
<input type="hidden" name="current_total_need_person" value="<?php echo $true_workers;?>">
生产比例:
<?php
echo $total_resource['grow_percent'] * 100;
?>%
<span><span style="margin-left:8px;">总人口:<?php echo $total_resource['total_house'];?></span>
工作人口:<span><?php echo $true_workers;?></span>
剩余人口:<span><?php echo $total_resource['total_house'] - $true_workers;?></span>
<a href="javascript:this.produce.submit();" class="d">【更新安排】</a>
</div>
<img src="images/med_04.gif" class="bac" />
</div>
<!--------内部队列框----------->
</div>
</div>
</div>
</div>
<!--------------队列阴影框----------->
</form>
<div style="padding-bottom:60px;"> </div>
</div>
<div id="mb_03"></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -