-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_payment.php
138 lines (127 loc) · 5.87 KB
/
add_payment.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
<?php
include('system_load.php');
//This loads system.
//user Authentication.
authenticate_user('subscriber');
//creating company object.
$new_store = new Store;
$store_access = new StoreAccess;
$vendor = new Vendor;
if(partial_access('admin') || $store_access->have_module_access('vendors')) {} else {
HEADER('LOCATION: store.php?message=warehouse');
}
if(!isset($_SESSION['store_id']) || $_SESSION['store_id'] == '') {
HEADER('LOCATION: stores.php?message=1');
} //select company redirect ends here.
$new_store->set_store($_SESSION['store_id']); //setting store.
if(isset($_POST['add_payment']) && $_POST['add_payment'] == 1) {
extract($_POST);
if($method == '') {
$message = 'Set payment method';
} else if($amount == '' || !is_numeric($amount)) {
$message = "Amount is empty or not numeric.";
} else {
//Process Payment here.
$payment_id = $vendor->add_payment($date, $method, $ref_no, $memo, $amount, $vendor_id);
$vendor->add_log($date, $vendor_id, 'Payment', $payment_id);
$clear_debts = $vendor->clear_debts($amount, $vendor_id);
HEADER('LOCATION: add_payment.php?message=Payment added successfuly!&vendor_id='.$_GET['vendor_id']);
}
}
$page_title = 'Add Payment'; //You can edit this to change your page title.
require_once("includes/header.php"); //including header file.
//display message if exist.
if(isset($message) && $message != '') {
echo '<div class="alert alert-success">';
echo $message;
echo '</div>';
}
if(isset($_GET['message']) && $_GET['message'] != '') {
echo '<div class="alert alert-success">';
echo $_GET['message'];
echo '</div>';
}
?>
<!--content here-->
<?php if(!isset($_GET['vendor_id']) || $_GET['vendor_id'] == '0'): ?>
<!--when vendor is not set-->
<h3>Please select Vendor</h3>
<form action="" method="get">
<div class="form-group">
<label class="label-control">Select Vendor:</label><br />
<select class="autofill" style="width:250px;" name="vendor_id">
<option value="0">Select Vendor</option>
<?php echo $vendor->vendor_options(); ?>
</select>
</div>
<input type="submit" class="btn btn-primary" value="Select" />
</form>
<!--when vendor is not set-->
<?php else: ?>
<!--when vendor is set.-->
<div class="row">
<div class="col-md-4">
<!--vendor info-->
<table width="100%" border="1px" cellspacing="0" cellpadding="5px">
<tr>
<td bgcolor="#666666"><strong style="color:#FFF;">Vendor Info</strong></td>
</tr>
<tr>
<td><?php $vendor_id = $_GET['vendor_id']; ?>
<p><strong><?php echo $vendor->get_vendor_info($vendor_id, 'full_name'); ?></strong><br />
Phone # : <?php echo $vendor->get_vendor_info($vendor_id, 'phone'); ?> Mob # : <?php echo $vendor->get_vendor_info($vendor_id, 'mobile'); ?><br />
Address: <?php echo $vendor->get_vendor_info($vendor_id, 'address'); ?> <?php echo $vendor->get_vendor_info($vendor_id, 'city'); ?> <?php echo $vendor->get_vendor_info($vendor_id, 'state'); ?> <?php echo $vendor->get_vendor_info($vendor_id, 'country'); ?><br>
<span style="text-align:right; background-color:#CCC; font-weight:bold; padding:2px; width:80%; float:right;">Total Payable: <?php echo currency_format($vendor->get_vendor_balance($vendor_id)); ?></span></p></td>
</tr>
</table>
<!--vendor info-->
</div>
<div class="col-md-4">
<table border="1px" width="100%" cellspacing="0" cellpadding="5px">
<tr>
<td bgcolor="#666666"><strong style="color:#FFF;">Add Payment</strong></td>
</tr>
<tr>
<td>
<form action="" method="post">
<table border="0" cellpadding="5">
<tr>
<th>Date:</th>
<td width="270"><input type="text" class="form-control datepick" readonly="readonly" value="<?php echo date('Y-m-d'); ?>" required="required" name="date" /></td>
</tr>
<tr>
<th>Method</th>
<td><input type="text" class="form-control" placeholder="Payment Method" required="required" name="method" /></td>
</tr>
<tr>
<th>Ref#:</th>
<td><input type="text" class="form-control" placeholder="Reference Number" name="ref_no" /></td>
</tr>
<tr>
<th>Memo:</th>
<td><textarea class="form-control" name="memo" placeholder="Memo"></textarea></td>
</tr>
<tr>
<th>Amount:</th>
<td><input type="text" class="form-control" placeholder="Amount Paid" required="required" name="amount" /></td>
</tr>
<tr>
<th> </th>
<td>
<input type="hidden" name="add_payment" value="1" />
<input type="hidden" name="vendor_id" value="<?php echo $_GET['vendor_id']; ?>" />
<input type="submit" class="btn btn-primary" value="Add Payment" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
<div class="clearfix"></div>
</div>
<!--when vendor is set.-->
<?php endif; ?>
<?php
require_once("includes/footer.php");
?>