You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/application/third_party/train/views/booking_write.php

202 lines
7.9 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">订单号</h3>
</div>
<div class="panel-body">
<form action="" method="post">
<input type="text" name="order" value="<?php echo isset($order_id)?$order_id:""; ?>">
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> 获取信息</button>
</form>
</div>
</div>
<form action="booking_do" method="post">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">列车信息</h3>
</div>
<div class="panel-body">
<table class="table table-bordered" id="back_table">
<thead>
<tr><th>车次</th><th>出发站简码</th><th>出发站名称</th><th>目的站简码</th><th>目的站名称</th><th>日期</th></tr>
</thead>
<tbody>
<tr>
<td><input type="text" name="train_booking_train_code" value="<?php if(!empty($order->cold[0])){echo $order->cold[0]->COLD_ServiceSN;}?>" placeholder="D5631" /></td>
<td><input type="text" name="train_booking_from_station_code" value="" placeholder="GLZ" /></td>
<td><input type="text" name="train_booking_from_station_name" value="<?php if(!empty($order->cold[0])){echo $order->cold[0]->COLD_LeaveCity;}?>" placeholder="如:桂林" /></td>
<td><input type="text" name="train_booking_to_station_code" value="" placeholder="GBZ" /></td>
<td><input type="text" name="train_booking_to_station_name" value="<?php if(!empty($order->cold[0])){echo $order->cold[0]->COLD_ServiceCity;}?>" placeholder="如:桂林北" /></td>
<td><input type="text" name="train_booking_date" value="<?php if(!empty($order->cold[0])){echo date("Y-m-d",strtotime($order->cold[0]->COLD_StartDate)) ;}?>" placeholder="2016-09-07" /></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">乘客信息</h3>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-bordered" id="back_table">
<thead>
<tr>
<!-- <th>序号</th> -->
<th>席别</th>
<th>票种</th>
<th>姓名</th>
<th>证件类型</th>
<th>证件号码</th>
<th>删除</th>
</tr>
</thead>
<tbody>
<?php if(!empty($order)):?>
<?php $num=0; foreach ($order->people as $v):?>
<tr id="rowTemplete_<?php echo $num++;?>">
<!-- <td>1</td> -->
<td>
<select name="train_booking_zw[]" id="">
<?php foreach ($code_zw as $key => $value):?>
<option value="<?php echo $key;?>"><?php echo $value;?></option>
<?php endforeach;?>
</select>
</td>
<td>
<select name="train_booking_piaotype[]" id="">
<?php foreach ($piaotype as $key => $value):?>
<option value="<?php echo $key;?>" <?php if($key==$v->BPE_GuestType){echo "selected";}?>><?php echo $value;?></option>
<?php endforeach;?>
</select>
</td>
<td>
<input type="text" value="<?php echo $v->BPE_FirstName.' '.$v->BPE_LastName;?>" name="train_booking_passengersename[]" />
</td>
<td>
<select name="train_booking_passportty[]" id="">
<?php foreach ($passportty as $key => $value):?>
<option value="<?php echo $key;?>"><?php echo $value;?></option>
<?php endforeach;?>
</select>
</td>
<td>
<input type="text" value="<?php echo $v->BPE_Passport;?>" name="train_booking_passportseno[]" />
</td>
<td>
<a href='javascript:void(0);' onclick='deleteBatchRow(this)' class="btn btn-warning btn-sm" style="border-radius: 3px;" ><span class="glyphicon glyphicon-remove"></span></a>
</td>
</tr>
<?php endforeach?>
<?php else:?>
<tr id="rowTemplete_0">
<!-- <td>1</td> -->
<td>
<select name="train_booking_zw[]" id="">
<?php foreach ($code_zw as $key => $value):?>
<option value="<?php echo $key;?>"><?php echo $value;?></option>
<?php endforeach;?>
</select>
</td>
<td>
<select name="train_booking_piaotype[]" id="">
<?php foreach ($piaotype as $key => $value):?>
<option value="<?php echo $key;?>"><?php echo $value;?></option>
<?php endforeach;?>
</select>
</td>
<td>
<input type="text" name="train_booking_passengersename[]" />
</td>
<td>
<select name="train_booking_passportty[]" id="">
<?php foreach ($passportty as $key => $value):?>
<option value="<?php echo $key;?>"><?php echo $value;?></option>
<?php endforeach;?>
</select>
</td>
<td>
<input type="text" name="train_booking_passportseno[]" />
</td>
<td>
<input type="text" name="train_booking_mobile[]" />
</td>
<td>
<a href='javascript:void(0);' onclick='deleteBatchRow(this)' class="btn btn-warning btn-sm" style="border-radius: 3px;" ><span class="glyphicon glyphicon-remove"></span></a>
</td>
</tr>
<?php endif;?>
</tbody>
</table>
</div>
<button type="button" id="add" class="btn btn-success btn-sm"><span class="glyphicon glyphicon-plus"></span>增加乘客</button>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<div style="text-align:center;">
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-ok"></span>提交订单</button>
</div>
</div>
</div>
</form>
</div>
<script>
//记录添加行数
var areaCount=<?php echo $order?count($order->people):1?>;;
//记录实际表格行数
var rowCount=<?php echo $order?count($order->people):1?>;
//删除模板html
var delRowTemplete = "<td><a href='javascript:void(0);' class='content_del' onclick='deleteBatchRow(this)'>删除</a></td>";
//表格行模板
var addRowTemplete= "";
$(function(){
//首先取出需要克隆的模板,模板行<tr>id为rowTemplete_0
addRowTemplete= $("#rowTemplete_0").html();
});
//增加行
function addBatchRow(type){
if(rowCount>4){
alert("一次最多填写五位乘客");
return false;
}
var templete = $("<tr id='rowTemplete_"+areaCount+"'></tr>");
//递增序号替换掉tr或者td中存在[0]、_0或者(0)防止id相同,这么设计主要是为了后台取值时方便
templete = templete.append(addRowTemplete.replace(/\[0\]/g,"["+areaCount+"]").replace(/_0/g,"_"+areaCount).replace("processStat(\"0\")","processStat("+areaCount+")").replace(/1111/g,rowCount+1));
//找到最后一条存在的行,在其后拼接一行
var flag = false;
for(var i=areaCount-1;i>=0;i--){
if($("#rowTemplete_"+i).length>0){
$("#rowTemplete_"+i).after(templete);
break;
}
}
//计数加一
areaCount++;
rowCount++;
}
//删除行
function deleteBatchRow(obj){
if(rowCount>1) {
$(obj).parents("tr").remove();
rowCount--;
} else
alert("至少保留一行");//如果全部删除了,那么也就没有办法再添加行了,模板行也被删了呀
}
//取得条数
function getAreaCount(){
return rowCount;
}
$("#add").click(function(){
addBatchRow();
});
// $("#test").blur(function(){
// alert();
// });
</script>