| 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/(Del)pathways.org.hk/MIS20140127/old20140407/Receipt/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<?php require_once '../include/head.php'; ?>
<?php require_once '../include/checkuser.php'; ?>
<?php require_once '../include/Nav_bar.php'; ?>
<?php include_once '../include/DBConnect.php'; ?>
<script>
var total = 0;
$(function() {
$('.date-picker').datetimepicker({pickTime: false});
$('.searchstun').select2();
$('.stun').select2();
$('#payway').change(function() {
var type = $('#payway').val();
$.get('receipt_search_ajax.php?paytype=' + type, ff);
});
function ff(res) {
$('#paytype_tr').html(res);
}
;
});
$(document).ready(function() {
$(function() {
$('#form').on('submit', function(e) {
var array = new Array();
for (var i = 0; i < (document.getElementsByName("selected_invoice[]")).length; i++) {
if (document.getElementsByName("selected_invoice[]")[i].checked == true) {
array.push((document.getElementsByName("selected_invoice[]")[i].value));
total += parseInt((document.getElementsByName("invoice_pay[]")[i].value));
alert(total);
}
}
if (total != $('#total_fee').val()) {
alert('Not match the total amount');
total = 0;
e.preventDefault();
}
});
});
});
</script>
</head>
<?php
$invoice_id;
$startdate = date('Y-m-d');
$enddate = date('Y-m-d');
$today = date('Y-m-d');
$countinvoice = 0;
if (isset($_POST['save'])) {
$totalmoney = 0;
$countinvoice = 0;
$name = $_POST['from_name'];
$money = $_POST['total_fee'];
$payof = $_POST['payof'][$countinvoice];
$payway = $_POST['payway'];
if ($payway == 1) {
$bank_name = $_POST['bankname'];
$cheque_no = $_POST['cheque_no'];
} else {
$bank_name = '0';
$cheque_no = '0';
}
$campus = $_POST['campus'];
$type = $_POST['type'];
$paydate = $_POST['paydate'];
$dontinsert = false;
$loadname;
$receiptNo = 'KL130001';
if ($campus != 1 && $campus != 2) {
$dontinsert = true;
echo "<script>alert('plz select a campus!!!')</script>";
}
if ($dontinsert == false) {
$sth = $dbh->prepare("INSERT INTO `receipt`(`receipt_code`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `receipt_date`, `receipt_from`, `payment_of`, `total_amount`, `is_cash`, `bank_name`, `cheque_code`, `is_normal`, `campus_id`) VALUES (?,1,now(),1,now(),1,0,?,?,?,?,?,?,?,?,?)");
$sth->bindParam(1, $receiptNo);
$sth->bindParam(2, $paydate);
$sth->bindParam(3, $name);
$sth->bindParam(4, $payof);
$sth->bindParam(5, $money);
$sth->bindParam(6, $payway);
$sth->bindParam(7, $bank_name);
$sth->bindParam(8, $cheque_no);
$sth->bindParam(9, $type);
$sth->bindParam(10, $campus);
$sth->execute();
echo "<script>alert('Insert data successful.')</script>";
echo("<script>location.href ='receipt_index.php';</script>");
}
}
?>
<body>
<!-- line between nav bar and content -->
<div class="text-right">
<ul class="breadcrumb">
<li class="active">Receipt</li>
</ul>
</div>
<div class="container-fluid pathways-container">
<div>
<table border="0" width="100%">
<tr>
<td><h2>Add Receipt</h2></td>
</tr>
</table>
</div>
<div class="pathways-search">
<form id="search_form" class="form-inline" action="" method="POST">
<div class="pathways-inline-block">
<label>Student</label>
<select name="searchstun" id="stun" class="stun" style="width:230px">
<option value="ALL"></option>
<?php $sth = $dbh->query("SELECT `root_id` root_id,linking_id,`New_stu_ID` id,CONCAT(last_name, ' ', first_name) studentname,`ch_name`FROM `student` WHERE `actived`=1 and`deleted`=0 group by `New_stu_ID`,`Sem_yr`"); ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option <?php if (isset($_POST['go'])) {
if ($_POST['searchstun'] == $ResultSet['root_id']) { ?> selected="" <?php }
} ?>value="<?= $ResultSet['root_id']; ?>"><?= $ResultSet['studentname'] ?> | <?= $ResultSet['id'] ?></option>
<?php } ?>
</select>
</div>
<div class="pathways-inline-block">
<button class="btn" name="go" value="go" style="margin-left:30px" type="submit">Search</button>
</div>
</form>
</div>
<?php
if (isset($_POST['go'])) {
$studentid = $_POST['searchstun'];
$Tdata = false;
if ($studentid == 'ALL') {
echo "<script>alert('Please select a student!')</script>";
} else {
$query = "select root_id from invoice where deleted = 0 and stu_linking_id = '$studentid' ";
$result = $dbh->query($query);
$result->setFetchMode(PDO::FETCH_OBJ);
while ($row = $result->fetch()) {
$Tdata = true;
}
?>
<form id="form" class="form-inline" action="" method="POST">
<?php if ($Tdata == true) { ?>
<table style=" background:#eeefde;" border="0" class="table table-bordered table-hover table-condensed">
<tr>
<td><label>Receipt From</label></td>
<td><input type="text" name="from_name" required=""></td>
<td><label>Total Money</label>
</td><td><input type="text" name="total_fee" id="total_fee" required=""></td>
</tr>
<tr>
<td width="20%"><label>Type</label></td>
<td><select name="type">
<option value="0">Normal</option>
<option value="1">Community Chest</option>
</select></td>
<td width="20%"><label>Date</label></td>
<td><div class="input-append date-picker">
<input id="start_date" class="dateISO" type="text" maxlength="200" data-format="yyyy-MM-dd" name="paydate" value="<?= $today ?>" style="width:90px" required>
<span class="add-on">
<i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
</span>
</div></td>
</tr>
<tr>
<td width="20%">Pay Type</td>
<td><select name ="payway" id="payway">
<option value="0">By cash</option>
<option value="1">By cheque</option>
</select></td>
<!--td width="10%"><label>Bank Name</label></td>
<td><input type="text" name="bankname"></td>
<td width="10%">Cheque No</td>
<td><input type="text" name="cheque_no"></td-->
</tr>
<tbody id="paytype_tr">
<tr>
</tr>
</tbody>
<tr>
<!--td width="20%"><label>Payment of:</label></td>
<td><input type="text" name="payof"></td-->
<td width="20%">Campus:</td>
<td><select name="campus" required="true">
<option></option>
<?php
$query = "Select campus_id,campus_name from campus";
$result = $dbh->query($query);
$result->setFetchMode(PDO::FETCH_OBJ);
while ($row = $result->fetch()) {
print '<option value=' . $row->campus_id . '>' . $row->campus_name . '</option>';
}
?>
</select>
</td>
</tr>
</table>
<?php } ?>
<table class="table table-striped table-bordered table-hover table-condensed" id="tablehead">
<thead>
<tr>
<th style="min-width:50px; width:5%"></th>
<th style="min-width:50px;">Invoice_Code</th>
<th style="min-width:50px;">Event_Code</th>
<th style="min-width:50px; width:10%">Total Amount</th>
<th style="min-width:50px; width:10%">Payed</th>
<th style="min-width:50px; width:10%">Pay</th>
</tr>
</thead>
<tbody>
<?php
//$query = "select receive_id, receive_code, is_normal from receive where deleted = 0 and invoice_id = 0 and receive_date between '$startdate' and '$enddate' ";
$query = "select root_id, total_amount, invoice_code, event_code from invoice where deleted = 0 and stu_linking_id = '$studentid' ";
$result = $dbh->query($query);
$result->setFetchMode(PDO::FETCH_OBJ);
while ($row = $result->fetch()) {
?>
<tr>
<td>
<input type="checkbox" name="selected_invoice[]" id="selected_invoice<?= $countinvoice ?>" value="1">
</td>
<td>
<input type="hidden" name="payof[]" value="<?=$row->invoice_code ?>" ><h5><?= $row->invoice_code ?></h5>
</td>
<td>
<h5><?= $row->event_code ?></h5>
</td>
<td>
<h5>$<?= $row->total_amount ?></h5>
</td>
<td>
<h5>0</h5>
</td>
<td>
<input type="text" name="invoice_pay[]" id="invoive_pay<?= $countinvoice ?>" value="" style="width: 100px">
</td>
</tr>
<?php
$countinvoice++;
}
if ($Tdata == FALSE) {
?>
<tr><td colspan = "5"><h5>No invoice searched</h5></td></tr>
<?php } ?>
</tbody>
</table>
<div class="pathways-inline-block">
<button class="btn" name="save" value="save" type="submit" style="margin-left:30px" >Save</button>
</div>
</form>
<?php
}
}
?>
</div> <!-- /container -->
</body>
</html>