| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/innoutstorage/webadmin/ |
Upload File : |
<?php
require_once('check_login.php');
$invoice_type_info = get_master_type_code("INVOICE_TYPE");
$order_info = get_order(null, false);
$customer_info = get_customer();
$product_info = get_product();
$invoice_info = get_invoice();
$default_duedate = new DateTime();
$default_duedate->modify("+7 day");
?>
<!DOCTYPE html>
<html>
<head>
<?php require_once("html_head.php"); ?>
<script type="text/javascript" src="js/chosen_v1.4.1/chosen.jquery.min.js"></script>
<link rel="stylesheet" href="js/chosen_v1.4.1/chosen.min.css">
<script type="text/javascript">
$(function () {
$("#duedate").datepicker({dateFormat: 'yy-mm-dd'});
});
</script>
<script type="text/javascript">
function get_order_rent_info(order_id) {
if(parseInt(order_id) > 0){
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var result = $.trim(xmlhttp.responseText);
//console.log(1);
if (result == "" || result == null) {
$("#ajax_order_rent_info").hide();
} else {
$("#ajax_order_rent_info").show().html(result);
extra_rent_invoice();
var original_rent_price = $("#_original_rent_price").val();
var actual_rent_price = $("#_actual_rent_price").val();
$("#original_rent_price").text(original_rent_price);
$("#actual_rent_price").text(actual_rent_price);
$("#extra_rent_invoice_amount").val(actual_rent_price);
}
}
}
xmlhttp.open("POST", "_ajax.php?for=get_order_rent_info", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("order_id=" + order_id);
}
}
function extra_rent_invoice(){
//check if all rent invoice created
if($(".non_active_invoice").length <= 0 && $("#add_invoice_table").length > 0){
$("#extra_rent_invoice").show();
}else{
$("#extra_rent_invoice").hide();
}
}
function ajax_add_extra_rent_invoice(){
var extra_rent_invoice_amount = $("#extra_rent_invoice_amount").val();
if(!isNaN(extra_rent_invoice_amount) && parseFloat(extra_rent_invoice_amount) > 0){
var order_id = $("#order_id").val();
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var result = $.trim(xmlhttp.responseText);
if(!isNaN(result) && parseInt(result) > 0){
alert("成功新增非合約期月份。");
location.href='invoice_modifyform.php?id='+result;
}else{
alert(result);
}
}
}
xmlhttp.open("POST", "_ajax.php?for=add_extra_rent_invoice", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("order_id=" + order_id + "&extra_rent_invoice_amount=" +extra_rent_invoice_amount);
}else{
alert("請輸入正確的非合約期月份租金。");
}
}
function invoice_type(type_name){
if(type_name == "RENT"){
$(".RENT").show();
//$(".RENT input, .RENT select, .RENT textarea").removeAttr("disabled");
$(".non_RENT").hide();
//$(".non_RENT input, .non_RENT select, .non_RENT textarea ").attr("disabled", "disabled");
$("#duedate").val("");
//check if all rent invoice created
extra_rent_invoice();
}else{
$(".RENT").hide();
$(".non_RENT").show();
$("#duedate").val("<?=$default_duedate->format("Y-m-d")?>");
if(type_name == "ORDER_PRODUCT"){
$(".PENALTY").hide();
$(".ORDER_PRODUCT").show();
}else if(type_name == "PENALTY"){ //PENALTY
$(".ORDER_PRODUCT").hide();
$(".PENALTY").show();
$("#customer_tr").show();
}else{
$(".RENT").hide();
$(".non_RENT").hide();
$("#duedate").val("");
}
//$(".invoice_belong").hide();
}
}
function isInt(value) {
if (isNaN(value)) {
return false;
}
var x = parseFloat(value);
return (x | 0) === x;
}
function product_total_price(){
var total = 0;
$(".qty").each(function () {
var qty = $(this).val();
if(isFinite(qty) && isInt(qty) && parseInt(qty) > 0){
var price = $(this).parent().find(".price").val();
total += parseFloat(price) * parseInt(qty);
}else{
/*if(qty != "0"){
alert("請輸入正確的數量。");
return;
}*/
total += 0;
}
});
$("#total_product_amount").text("$"+total.toFixed(1));
return parseFloat(total);
}
$(function () {
$(".RENT").hide();
$(".non_RENT").hide();
$("select[name='invoice_type']").on("change", function () {
invoice_type($(this).val())
});
$(".qty").on("change keyup", function () {
product_total_price();
});
if($('#invoice_type').val() != "0"){
invoice_type($('#invoice_type').val());
}
if($("#order_id").val() != "0"){
get_order_rent_info($("#order_id").val());
}
<?php
/*if(isset($_SESSION["invoice_type"])){
echo "$('#invoice_type').val('".$_SESSION["invoice_type"]."').change();";
}
if(isset($_SESSION["order_id"])){
echo "$('#order_id').val('".$_SESSION["order_id"]."').change();";
}*/
?>
$("#invoice_type").chosen({width: "150px", search_contains: true});
$("#order_id").chosen({width: "150px", search_contains: true});
$("#customer_id").chosen({width: "200px", search_contains: true});
$("#invoice_id").chosen({width: "150px", search_contains: true});
$("input[name='penalty_amount']").on("change keyup", function () {
if(parseFloat($(this).val()) < 0 || parseFloat($(this).val()) != $(this).val()){
alert("請輸入正確的金額。");
}
});
//console.log(parseInt($("#order_id").val()));
//check if all rent invoice created
extra_rent_invoice();
});
</script>
</head>
<body>
<form action="invoice_add.php" method="post" name="modifyform" enctype="multipart/form-data" class="form_field">
<input type="hidden" name="invoice_belong" value="NEW">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="70" align="right" valign="middle" class="icontxt">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50" align="center" style="font-size: 12px;">
<input type="image" alt="submit" src="images/iconSave.png" width="32" height="32" border="0"><br>
儲存 </a></td>
<td width="50" align="center">
<a href="order_index.php?<?php
if (isset($_SESSION["index_url_parameter"])){
if(substr($_SESSION["index_url_parameter"],-18) == urlencode("取消")){
echo $_SESSION["index_url_parameter"];
} else {
echo $_SESSION["index_url_parameter"] . "&msg=取消";
}
}
?>"
>
<img src="images/iconCancel.png" alt="取消" width="32" height="32" border="0"><br>
取消
</a>
</td>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<span style="float:left;" class="pagetitletxt">
<b><img src="images/iconList.jpg" width="48" height="48" align="absmiddle"/> 新增發票
</b></span>
</td>
</tr>
<tr>
<td align="left" valign="middle"><!-- Content -->
<table style="width: 1200px; padding-left: 15px;">
<tr>
<td style="width: 120px;">
<p class="required">發票類型: </p>
</td>
<td>
<select name="invoice_type" id="invoice_type">
<option value="0">---請選擇---</option>
<?php
foreach ($invoice_type_info as $invoice_type) {
echo '<option value="' . $invoice_type["code"] . '">' . $invoice_type["name_tc"] . '</option>';
}
?>
</select>
</td>
</tr>
<tr class="RENT" style="display: none;">
<td>
<p class="required">合約編號: </p>
</td>
<td>
<select name="order_id" id="order_id" onchange="get_order_rent_info(this.value)">
<option value="0">---請選擇---</option>
<?php
foreach ($order_info as $order) {
echo '<option value="' . $order["id"] . '">' . $order["code"] . '</option>';
}
?>
</select>
</td>
</tr>
<!--<tr class="PENALTY non_RENT" style="display: none;">
<td>
<p class="required">發票方式 :</p>
</td>
<td>
<input type="radio" name="invoice_belong" value="NEW" onclick="$('#customer_tr').show();$('#invoice_tr').hide();"> 全新發票
<input type="radio" name="invoice_belong" value="OLD" onclick="$('#customer_tr').hide();$('#invoice_tr').show();"> 加入到現有發票
</td>
</tr>-->
<tr class="non_RENT invoice_belong" id="customer_tr" style="display: none;">
<td>
<p class="required">客戶: </p>
</td>
<td>
<select name="customer_id" id="customer_id">
<option value="0">---請選擇---</option>
<?php
foreach ($customer_info as $customer) {
if($customer["deleted"] == 1)
continue;
echo '<option value="' . $customer["id"] . '">' . $customer["customer_name"] . ' ('.$customer["code"].')</option>';
}
?>
</select>
</td>
</tr>
<!--<tr class="PENALTY non_RENT invoice_belong" id="invoice_tr" style="display: none;">
<td>
<p class="required">租金發票: </p>
</td>
<td>
<select name="invoice_id" id="invoice_id">
<option value="0">---請選擇---</option>
<?php
/* foreach ($invoice_info as $invoice) {
if($invoice["status"] == "SETTLED"){
continue;
}
echo '<option value="' . $invoice["invoice_id"] . '">' . $invoice["invoice_code"] . '</option>';
}
*/?>
</select>
</td>
</tr>-->
<tr class="RENT">
<td>
<p class="required">租金月份</p>
</td>
<td>
<div id="ajax_order_rent_info"></div>
<br>
</td>
</tr>
<tr class="RENT" id="extra_rent_invoice">
<td>
<p>非合約期月份</p>
</td>
<td>
租金 $<input name="extra_rent_invoice_amount" id="extra_rent_invoice_amount" value="0" style="width: 70px;"><button id="add_extra_rent_invoice" type="button" style="margin-left: 20px;" onclick="ajax_add_extra_rent_invoice();">+ 新增非合約期月份</button>
<br><br>
(每月原本租金 : $<span id="original_rent_price"></span>, 每月實際租金 : $<span id="actual_rent_price"></span>)
</td>
</tr>
<tr class="ORDER_PRODUCT non_RENT">
<td>
<p class="required">可選購物品 : </p>
</td>
<td>
<table cellpadding="5" id="product_table">
<tr>
<td>名稱</td>
<td>數量</td>
<td>價格</td>
</tr>
<?php
if(!empty($product_info)){
foreach($product_info as $product){
echo "<tr>
<td>".$product["name_tc"]."</td>
<td>
<input type='hidden' name='product_id[".$product["id"]."]' value='".$product["id"]."' class='product_id'>
<input type='hidden' name='product_name[".$product["id"]."]' value='".$product["name_tc"]."' class='product_name'>
<input type='text' name='qty[".$product["id"]."]' value='0' style='width: 40px;' class='qty'>
<input type='hidden' name='price[".$product["id"]."]' value='".$product["price"]."' class='price'>
</td>
<td>$".numberformat($product["price"])."</td>
</tr>";
}
}
?>
<tr>
<td colspan="3" style="border: 0;">總物品金額: <span id="total_product_amount">$0</span></td>
</tr>
</table>
</td>
</tr>
<tr class="PENALTY non_RENT">
<td>
<p>類型 : </p>
</td>
<td>
<input type="text" name="remark" style="width: 200px;">
<br>
<span style="font-size: 12px;">eg: 行政費</span>
</td>
</tr>
<tr class="PENALTY non_RENT">
<td>
<p class="required">金額: </p>
</td>
<td>
$<input type="text" name="penalty_amount" style="width: 138px;">
</td>
</tr>
<tr>
<td>
<p class="required">繳費日期 : </p>
</td>
<td>
<input type="text" name="duedate" id="duedate" style="width: 145px;">
</td>
</tr>
<tr>
<td>
<p>發票備註 : </p>
</td>
<td>
<textarea name="invoice_remark" style="width: 500px; height: 100px;"></textarea>
</td>
</tr>
<tr>
<td></td>
<td>
<p class="red">* 必須填寫</p>
</td>
</tr>
</table>
<br><br><br><br>
<!-- End Content -->
</td>
</tr>
</table>
</form>
</body>
</html>