-
Notifications
You must be signed in to change notification settings - Fork 0
/
withdraw.php
174 lines (168 loc) · 6.09 KB
/
withdraw.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php include('template/head.php'); ?>
<?php
include('class/view.php');
$display = new display();
include('class/validate.php');
$validate = new validate();
?>
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="dashboard.php">Dashboard</a>
</li>
<li class="breadcrumb-item active">Withdraw money</li>
</ol>
<?php if (!isset($_GET['acc'])): ?>
<?php
$result = $display->active_deposit_accounts();
?>
<div class="card mb-3">
<div class="card-header">
<i class="fa fa-table"></i> View Deposit accounts
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Account no</th>
<th>Member name</th>
<th>Opening date</th>
<th>Maturity date</th>
<th>Current Balance</th>
<th>Option</th>
</tr>
</thead>
<tbody>
<?php while($row=mysqli_fetch_assoc($result)){ ?>
<tr>
<td><?php echo $row['account_no']; ?></td>
<td><?php echo $display->get_member_name($row['mem_id']); ?></td>
<td><?php echo $display->date_dmY($row['joining_date']); ?></td>
<td><?php $closing_date = date('d-m-Y', strtotime("+".$row['period']." months", strtotime($row['joining_date'])));
echo $closing_date; ?></td>
<td>
<?php
echo $display->current_balance($row['acc_id']);
?>
</td>
<td>
<a href="withdraw.php?acc=<?php echo $row['acc_id']; ?>" class="btn btn-sm btn-primary">Withdraw money</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<?php endif ?>
<?php if (isset($_GET['acc'])): ?>
<?php if ($validate->get_account_status($_GET['acc'])=='active'): ?>
<?php
$cndtn = "acc_id='".$_GET['acc']."'";
$result = $display->disp_cond("deposit_accounts", $cndtn);
// Displays member profile
$row = mysqli_fetch_assoc($result);
?>
<div class="offset-md-2 col-md-8 text-left border rounded mt-3">
<div class="row p-2">
<div class="col col-md-4 p-2">
<img style="max-height: 150px;" class="img-fluid" src="<?php echo $display->get_member_photo($row['mem_id']); ?>" alt="default profile picture">
</div>
<div class="col offset-md-3 col-md-5 p-2 media">
<img class="img-fluid img-thumbnail align-self-end" src="<?php echo $display->get_member_signature($row['mem_id']); ?>" alt="default profile picture">
</div>
</div>
<div class="row p-2">
<div class="col">Name :</div>
<div class="col"><b><?php echo $display->get_member_name($row['mem_id']); ?></b></div>
</div>
<div class="row p-2 bg-light-gray">
<div class="col">Account number :</div>
<div class="col"><b><?php echo $row['account_no']; ?></b></div>
</div>
<div class="row p-2 bg-light-gray">
<div class="col">Current balance :</div>
<div class="col"><b>Rs. <?php echo $display->current_balance($row['acc_id']); ?></b></div>
</div>
</div>
<form action="action/withdraw.php" method="POST">
<div class="row m-2 p-2">
<div class="offset-md-2 col-md-8">
<div class="form-group">
<div class="form-row">
<label for="amount">Enter amount</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text"> Rs.</div>
</div>
<input name="amount" class="form-control" id="amount" type="text" data-validation="required number" data-validation-allowing="range[1;<?php echo $display->current_balance($row['acc_id']); ?>]" data-validation-error-msg="Enter a valid amount" autocomplete="off">
</div>
</div>
</div>
<!-- Date of withdrawal -->
<div class="form-group">
<div class="form-row">
<label for="date_of_withdrawal">Date of withdrawal</label>
<?php if ($_SESSION['login_role']=='admin'): ?>
<div class="input-group">
<input class="form-control datepicker" name="date_of_withdrawal" data-validation="date" data-validation-format="dd-mm-yyyy" placeholder="dd-mm-yyyy" autocomplete="off">
</div>
<?php else: ?>
<div class="input-group">
<input class="form-control" name="date_of_withdrawal" value="<?php echo date("d-m-Y"); ?>" disabled>
</div>
<?php endif ?>
</div>
</div>
<button type="button" class="btn btn-primary btn-block" data-toggle="modal" onclick="getAmt()" data-target="#confirm_deposit">
Submit
</button>
</div>
</div>
<!-- Deposit modal -->
<div class="modal fade" id="confirm_deposit" tabindex="-1" role="dialog" aria-labelledby="confirm_deposit" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirm_deposit">Please confirm submit.</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Cick submit to withdraw money from account.
<br>
Name : <b><?php echo $display->get_member_name($row['mem_id']); ?></b>
<br>
Account No. : <b><?php echo $row['account_no']; ?></b>
<br>
Amount : <b>Rs. <span id="amtDiv"></span></b>
</div>
<div class="modal-footer">
<input type="hidden" name="acc_id" value="<?php echo $row['acc_id']; ?>">
<input type="hidden" name="mem_id" value="<?php echo $row['mem_id']; ?>">
<button type="submit" name="withdraw" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</form>
<?php else: ?>
<div><h3>Account status not active. Please contact admin</h3></div>
<div><a href="pay_installment.php">Go back</a></div>
<?php endif ?>
<?php endif ?>
<?php
$script = "<script>
function getAmt(){
var amount = document.getElementById('amount').value;
var amtDiv = document.getElementById('amtDiv');
if (amount == '') {
amount = '0.00';
}
amtDiv.innerHTML = amount;
}
</script>";
?>
<?php include('template/foot.php'); ?>