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.
50 lines
1.8 KiB
50 lines
1.8 KiB
<?php
|
|
require_once "database.php";
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
|
|
foreach ($_POST as $k => $v) {
|
|
$$k = htmlspecialchars(stripslashes(trim($v)));
|
|
}
|
|
$maintance_contract_id=$_POST['maintance_contract_id'];
|
|
|
|
$paymentdates=$_POST['paymentdates'];
|
|
$paymentdatearr = explode(",", $paymentdates);
|
|
|
|
$receivableamounts=$_POST['receivableamounts'];
|
|
$receivableamountsarr = explode(",", $receivableamounts);
|
|
|
|
$paidamounts=$_POST['paidamounts'];
|
|
$paidamountsarr = explode(",", $paidamounts);
|
|
|
|
$creater = $_POST['creater'];
|
|
$create_at = date('Y/m/d H:i:s');
|
|
$updatee_at=date('Y/m/d H:i:s');
|
|
|
|
for ($i=0; $i<count($paymentdatearr); $i++) {
|
|
$db_query = "insert into maintance_contract_receivable(maintance_contract_id,paymentdate,receivableamount,paidamount";
|
|
$db_query .= ",creater,create_at,updatee_at) values (";
|
|
$db_query .= "'$maintance_contract_id', '$paymentdatearr[$i]', '$receivableamountsarr[$i]', '$paidamountsarr[$i]',";
|
|
$db_query .= "'$creater','$create_at','$updatee_at')";
|
|
$result = mysqli_query($link, $db_query);
|
|
}
|
|
if ($mid = mysqli_insert_id($link)) {
|
|
header("Location: receivableview-index.php");
|
|
if (mysqli_affected_rows($link) > 0) {
|
|
echo "<script type ='text/JavaScript'>";
|
|
echo "alert('新增成功')";
|
|
echo "</script>";
|
|
//header("Location: pricereview-index.php");
|
|
} else {
|
|
echo "<script type ='text/JavaScript'>";
|
|
echo "alert('新增失敗,請重新操作[I]')";
|
|
echo "</script>";
|
|
}
|
|
} else {
|
|
echo "<script type ='text/JavaScript'>";
|
|
echo "alert('新增失敗,請重新操作[M]')";
|
|
echo "</script>";
|
|
}
|
|
|
|
mysqli_close($link);
|
|
}
|
|
?>
|