You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

272 lines
12 KiB

<?php
// 載入db.php來連結資料庫
require_once "database.php";
include "header.php";
// 查詢提交成功的賬戶信息
$accountid=$_REQUEST['accountid'];
$contractno=$_REQUEST['contractno'];
if(!empty($accountid)&&!empty($contractno)){
$accountsql = "SELECT * FROM account where accountid='$accountid'";
$accountdata = mysqli_query($link,$accountsql);
$row = mysqli_fetch_array($accountdata, MYSQLI_ASSOC);
$contractsql = "SELECT * FROM contract where contractno='$contractno'";
$contractdata=mysqli_query($link,$contractsql);
$contractrows= mysqli_fetch_array($contractdata, MYSQLI_ASSOC);
}
if($_POST['type']=='facility'){
$contractno = $_POST["contractno"];//合同號
$customerid = $_POST["customerid"];//客戶編號
$creater = $_POST["creater"];//建檔人
$create_at = date('Y/m/d H:i:s');//創建時間
$facilitynos=json_decode($_POST['facilitynos'], true);
$weights=json_decode($_POST['weights'], true);
$numberofstops=json_decode($_POST['numberofstops'], true);
$numberoffloors=json_decode($_POST['numberoffloors'], true);
$opentypes=json_decode($_POST['opentypes'], true);
$speeds=json_decode($_POST['speeds'], true);
$repairtypes=json_decode($_POST['repairtypes'], true);
$longitudes=json_decode($_POST['longitudes'], true);
$latitudes=json_decode($_POST['latitudes'], true);
$addresss=json_decode($_POST['addresss'], true);
$repairerids=json_decode($_POST['repairerids'], true);
$repairernames=json_decode($_POST['repairernames'], true);
$success=0;
print_r($facilitynos);
for ($i = 0; $i<sizeof($facilitynos); $i++) {
echo $db_query3 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofstop, numberoffloor,opentype,speed,repairtype,longitude, latitude, address,repairerid,repairername,creater, create_at) VALUES
('$contractno', '$facilitynos[$i]', '$customerid', '$weights[$i]','$numberofstops[$i]', '$numberoffloors[$i]','$opentypes[$i]','$speeds[$i]','$repairtypes[$i]','$longitudes[$i]', '$latitudes[$i]', '$addresss[$i]','$repairerids[$i]','$repairernames[$i]','$creater', '$create_at')";
mysqli_query($link,$db_query3);
if (mysqli_affected_rows($link)>0) {
$success++;
}
}
echo $success;
exit();
if($success>0){
$jsonres['code']='200';
return json_encode($jsonres);
// header('location:custom-create-schedule.php?accountid='.$customerid.'&contractno='.$contractno);
// exit();
} ;
}
?>
<div class="container" id="accountadd">
<table class="table table-bordered" style="width:100%">
<thead>
<tr>
<th>帳號類型</th>
<th>帳號</th>
<th>密碼</th>
<th>姓名</th>
<th>電話</th>
<th>地址</th>
<th>電子郵件</th>
<th>Line ID</th>
<th>微信id</th>
<th>維修ID</th>
<th>直屬主管</th>
<th>建檔人</th>
<th>建檔時間</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $row['accounttype']; ?></td>
<td><?php echo $row['accountid']; ?></td>
<td><?php echo $row['pwd']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['tel']; ?></td>
<td><?php echo $row['address']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['lineid']; ?></td>
<td><?php echo $row['wechatid']; ?></td>
<td><?php echo $row['repairerid']; ?></td>
<td><?php echo $row['manager']; ?></td>
<td><?php echo $row['creater']; ?></td>
<td><?php echo $row['create_at']; ?></td>
</tr>
</tbody>
</table>
<table class="table table-bordered" style="width:100%">
<thead>
<tr>
<th>合約類型</th>
<th>合約號</th>
<th>公司名稱</th>
<th>統一編號</th>
<th>地址</th>
<th>電話</th>
<th>立約人</th>
<th>客戶維護帳號</th>
<!-- <th>業務聯繫人</th>-->
<!-- <th>業務聯繫人地址</th>-->
<th>業務聯繫人電話</th>
<th>業務聯繫人郵件地址</th>
<th>契約人員工號</th>
<th>合約起始日</th>
<th>合約終止日</th>
<th>建檔人</th>
<th>建檔時間</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $contractrows['contracttype']; ?></td>
<td><?php echo $contractrows['contractno']; ?></td>
<td><?php echo $contractrows['company']; ?></td>
<td><?php echo $contractrows['taxid']; ?></td>
<td><?php echo $contractrows['address']; ?></td>
<td><?php echo $contractrows['tel']; ?></td>
<td><?php echo $contractrows['promiser']; ?></td>
<td><?php echo $contractrows['customerid']; ?></td>
<!-- <td>--><?php //echo $contractrows['contractperson']; ?><!--</td>-->
<!-- <td>--><?php //echo $contractrows['contractaddress']; ?><!--</td>-->
<td><?php echo $contractrows['contracttel']; ?></td>
<td><?php echo $contractrows['contractemail']; ?></td>
<td><?php echo $contractrows['contract_employee']; ?></td>
<td><?php echo $contractrows['start_date']; ?></td>
<td><?php echo $contractrows['end_date']; ?></td>
<td><?php echo $contractrows['creater']; ?></td>
<td><?php echo $contractrows['create_at']; ?></td>
</tr>
</tbody>
</table>
<div class="text-center"> <h3>作番資料添加</h3> </div>
<div class="form-horizontal" >
<div class="form-group">
<div class="col-md-3">
<label for="contractno">合約號(必填)</label>
<input class="form-control contractno" type="text" id="contractno" value="<?php echo $contractrows['contractno']; ?>" required>
</div>
<div class="col-md-3">
<label for="customerid">客戶編號(必填)</label>
<input class="form-control customerid" type="text" id="customerid" value="<?php echo $contractrows['customerid']; ?>" required>
</div>
<div class="col-md-3">
<label for="creater">建檔人</label>
<input class="form-control creater" type="text" id="creater" value="<?php echo $user_id;?>" >
</div>
<div class="col-md-3">
<input class="form-control create_at" type="hidden" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<input class="form-control type" type="hidden" id="type" value="facility">
</div>
<div class="col-md-3 ">
<button onclick="tijiao()" class="btn btn-primary btn-lg pull-right" >點擊後提交作番資料</button>
</div>
</div>
<div id="facility">
<div class="form-group">
<div class="col-md-3">
<label for="facilityno">作番號(必填)</label>
<input class="form-control facilitynos" type="text" id="facilityno" required>
</div>
<div class="col-md-3">
<label for="weight">重量(必填)</label>
<input class="form-control weights " type="text" id="weight" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div>
<div class="col-md-3">
<label for="numberofstop">停數(必填)</label>
<input class="form-control numberofstops" type="text" id="numberofstop" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div>
<div class="col-md-3" >
<label for="numberoffloor">樓層數(必填)</label>
<input class="form-control numberoffloors" type="text" id="numberoffloor" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div>
</div>
<div class="form-group">
<div class="col-md-3" >
<label for="opentype">開門方式(必填)</label>
<Select class="form-control opentypes" id="opentype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="CO">CO</Option>
<Option Value="SO">SO</Option>
<Option Value="CO-SO">CO-SO</Option>
</Select>
</div>
<div class="col-md-3">
<label for="speed">速度(必填)</label>
<input class="form-control speeds" type="text" id="speed" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required>
</div class="col-md-3">
<div class="col-md-3">
<label for="repairtype">維修型態(必填)</label>
<Select class="form-control repairtypes" id="repairtype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option>
</Select>
</div>
<div class="col-md-3">
<label for="address">地址</label>
<input class="form-control addresss" type="text" id="address" >
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="longitude">經度(必填)</label>
<input class="form-control longitudes" type="text" id="longitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div>
<div class="col-md-3">
<label for="latitude">緯度(必填)</label>
<input class="form-control latitudes" type="latitude" id="latitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div>
<div class="col-md-3">
<label for="repairerid">維修人員工號(必填)</label>
<input class="form-control repairerids" type="text" id="repairerid" required>
</div>
<div class="col-md-3">
<label for="repairername">維修人員姓名(必填)</label>
<input class="form-control repairernames" type="text" id="repairername" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-center" >
<h1 onclick="tan('f')" style="cursor: pointer;">+</h1>
</div>
</div>
</div>
</div>